01 Aug 2008

This commit is contained in:
g-cont 2008-08-01 00:00:00 +04:00 committed by Alibek Omarov
parent ad1f8e3181
commit 89286b5444
54 changed files with 795 additions and 2916 deletions

View File

@ -45,5 +45,4 @@ launch\studio\
launch\viewer\
launch\wadlib\
launch\credits\
launch\install\
launch\dedicated\
launch\install\

View File

@ -66,7 +66,7 @@ shader_t *FindShader( const char *texture )
int i;
// convert to lower case
strlower(texture, texname );
com.strlwr(texture, texname );
// build full path
com.sprintf (shader, "textures/%s", texname );

View File

@ -2550,9 +2550,9 @@ void CreateModelScript( void )
{
// FIXME: make cases for "attack_%"
FS_Printf( f, "$sequence \"t->filenames[i]\" \"t->filenames[i]\"" );
if(stristr(t->filenames[i], "walk" )) FS_Printf( f, "LX fps 30 loop ACT_WALK 1\n" );
else if(stristr(t->filenames[i], "run" )) FS_Printf( f, "LX fps 30 loop ACT_RUN 1\n" );
else if(stristr(t->filenames[i], "idle")) FS_Printf( f, "fps 16 loop ACT_IDLE 50\n" );
if(com.stristr(t->filenames[i], "walk" )) FS_Printf( f, "LX fps 30 loop ACT_WALK 1\n" );
else if(com.stristr(t->filenames[i], "run" )) FS_Printf( f, "LX fps 30 loop ACT_RUN 1\n" );
else if(com.stristr(t->filenames[i], "idle")) FS_Printf( f, "fps 16 loop ACT_IDLE 50\n" );
else FS_Printf( f, "fps 16\n" );
}
FS_Printf(f, "\n" ); //finished

View File

@ -721,15 +721,15 @@ int lookup_texture( char *texturename )
for (i = 0; i < numtextures; i++)
{
if (stricmp( texture[i].name, texturename ) == 0)
if (com.stricmp( texture[i].name, texturename ) == 0)
return i;
}
strncpy( texture[i].name, texturename, sizeof(texture[i].name));
com.strncpy( texture[i].name, texturename, sizeof(texture[i].name));
if(stristr( texturename, "chrome" ) != NULL)
if(com.stristr( texturename, "chrome" ) != NULL)
texture[i].flags = STUDIO_NF_FLATSHADE | STUDIO_NF_CHROME;
else if(stristr( texturename, "bright" ) != NULL)
else if(com.stristr( texturename, "bright" ) != NULL)
texture[i].flags = STUDIO_NF_FLATSHADE | STUDIO_NF_FULLBRIGHT;
else texture[i].flags = 0;

View File

@ -75,5 +75,5 @@ if exist vsound\vsound.plg del /f /q vsound\vsound.plg
echo Build succeeded!
echo Please wait. Xash is now loading
cd D:\Xash3D\
quake.exe -log -game tmpQuArK -debug -dev 3 +map walk_test
quake.exe -log -game tmpQuArK -debug -dev 3 +map qctest
:done

View File

@ -119,11 +119,11 @@ void CL_SetSky_f( void )
return;
}
if(Cmd_Argc() > 2) rotate = atof(Cmd_Argv(2));
if(Cmd_Argc() > 2) rotate = com.atof(Cmd_Argv(2));
else rotate = 0;
if(Cmd_Argc() == 6)
{
VectorSet(axis, atof(Cmd_Argv(3)), atof(Cmd_Argv(4)), atof(Cmd_Argv(5)));
VectorSet(axis, com.atof(Cmd_Argv(3)), com.atof(Cmd_Argv(4)), com.atof(Cmd_Argv(5)));
}
else
{

View File

@ -73,8 +73,8 @@ void Con_ToggleConsole_f( void )
UI_HideMenu();
cls.key_dest = key_console;
if(Cvar_VariableValue ("maxclients") == 1 && Host_ServerState())
Cvar_SetValue("paused", 1 );
if(com.atoi(cl.configstrings[CS_MAXCLIENTS]) == 1 && Host_ServerState())
Cvar_SetValue( "paused", 1 );
}
}

View File

@ -221,7 +221,7 @@ void CL_ParseFrame( sizebuf_t *msg )
memset( &cl.frame, 0, sizeof(cl.frame));
cl.frame.serverframe = MSG_ReadLong (msg);
cl.frame.deltaframe = MSG_ReadLong (msg);
cl.frame.servertime = cl.frame.serverframe * HOST_FRAMETIME;
cl.frame.servertime = cl.frame.serverframe * Host_FrameTime();
cl.surpressCount = MSG_ReadByte( msg );
// If the frame is delta compressed from data that we
@ -257,8 +257,8 @@ void CL_ParseFrame( sizebuf_t *msg )
// clamp time
if( cl.time > cl.frame.servertime ) cl.time = cl.frame.servertime;
else if( cl.time < cl.frame.servertime - HOST_FRAMETIME )
cl.time = cl.frame.servertime - HOST_FRAMETIME;
else if( cl.time < cl.frame.servertime - Host_FrameTime())
cl.time = cl.frame.servertime - Host_FrameTime();
// read areabits
len = MSG_ReadByte( msg );
@ -289,7 +289,7 @@ void CL_ParseFrame( sizebuf_t *msg )
cls.state = ca_active;
cl.force_refdef = true;
// getting a valid frame message ends the connection process
VectorScale( cl.frame.ps.origin, CL_COORD_FRAC, cl.predicted_origin );
VectorCopy( cl.frame.ps.origin, cl.predicted_origin );
VectorCopy( cl.frame.ps.viewangles, cl.predicted_angles );
}
CL_CheckPredictionError();
@ -473,11 +473,11 @@ void CL_CalcViewValues( void )
cl.time = cl.frame.servertime;
cl.lerpfrac = 1.0f;
}
else if (cl.time < cl.frame.servertime - HOST_FRAMETIME )
else if (cl.time < cl.frame.servertime - Host_FrameTime())
{
if (cl_showclamp->value)
Msg ("low clamp %i\n", cl.frame.servertime - host_frametime->value - cl.time);
cl.time = cl.frame.servertime - HOST_FRAMETIME;
Msg( "low clamp %i\n", cl.frame.servertime - Host_FrameTime() - cl.time);
cl.time = cl.frame.servertime - Host_FrameTime();
cl.lerpfrac = 0.0f;
}
else
@ -514,13 +514,13 @@ void CL_CalcViewValues( void )
// smooth out stair climbing
delta = cls.realtime - cl.predicted_step_time;
if( delta < HOST_FRAMETIME ) cl.refdef.vieworg[2] -= cl.predicted_step * (HOST_FRAMETIME - delta) * 0.01f;
if( delta < Host_FrameTime()) cl.refdef.vieworg[2] -= cl.predicted_step * (Host_FrameTime() - delta) * 0.01f;
}
else
{
// just use interpolated values
for( i = 0; i < 3; i++ )
cl.refdef.vieworg[i] = LerpView( ops->origin[i] * CL_COORD_FRAC, ps->origin[i] * CL_COORD_FRAC, ops->viewoffset[i], ps->viewoffset[i], lerp );
cl.refdef.vieworg[i] = LerpView( ops->origin[i], ps->origin[i], ops->viewoffset[i], ps->viewoffset[i], lerp );
}
// if not running a demo or on a locked frame, add the local angle movement

View File

@ -62,7 +62,7 @@ void CL_RunLightStyles (void)
clightstyle_t *ls;
int i;
ofs = cl.time / HOST_FRAMETIME;
ofs = cl.time / Host_FrameTime();
if( ofs == lastofs ) return;
lastofs = ofs;

View File

@ -136,7 +136,7 @@ void IN_KeyDown( kbutton_t *b )
char *c;
c = Cmd_Argv(1);
if (c[0]) k = atoi(c);
if (c[0]) k = com.atoi(c);
else k = -1; // typed manually at the console for continuous down
if (k == b->down[0] || k == b->down[1])
@ -156,7 +156,7 @@ void IN_KeyDown( kbutton_t *b )
c = Cmd_Argv(2);
b->downtime = com.atoi(c);
if (!b->downtime) b->downtime = host.frametime[0] - HOST_FRAMETIME;
if (!b->downtime) b->downtime = host.frametime[0] - Host_FrameTime();
b->state |= 1 + 2; // down + impulse down
}

View File

@ -132,7 +132,7 @@ static void FindMatches( const char *s, const char *unused1, const char *unused2
{
int i;
if(com.strnicmp( s, completionString, strlen( completionString )))
if(com.strnicmp( s, completionString, com.strlen( completionString )))
return;
matchCount++;
@ -145,7 +145,7 @@ static void FindMatches( const char *s, const char *unused1, const char *unused2
// cut shortestMatch to the amount common with s
for ( i = 0; s[i]; i++ )
{
if ( com.tolower(shortestMatch[i]) != tolower(s[i]))
if ( com.tolower(shortestMatch[i]) != com.tolower(s[i]))
shortestMatch[i] = 0;
}
}
@ -157,7 +157,7 @@ PrintMatches
*/
static void PrintMatches( const char *s, const char *unused1, const char *m, void *unused2 )
{
if(!com.strnicmp( s, shortestMatch, strlen( shortestMatch )))
if(!com.strnicmp( s, shortestMatch, com.strlen( shortestMatch )))
if(m && *m) Msg( " %s ^3\"%s\"\n", s, m );
else Msg( " %s\n", s ); // variable or command without description
}
@ -169,19 +169,19 @@ static void keyConcatArgs( void )
for ( i = 1; i < Cmd_Argc(); i++ )
{
strncat( completionField->buffer, " ", sizeof( completionField->buffer ));
com.strncat( completionField->buffer, " ", sizeof( completionField->buffer ));
arg = Cmd_Argv( i );
while (*arg)
{
if (*arg == ' ')
{
strncat( completionField->buffer, "\"", sizeof( completionField->buffer ));
com.strncat( completionField->buffer, "\"", sizeof( completionField->buffer ));
break;
}
arg++;
}
strncat( completionField->buffer, Cmd_Argv( i ), sizeof( completionField->buffer ));
if (*arg == ' ') strncat( completionField->buffer, "\"", sizeof( completionField->buffer ));
com.strncat( completionField->buffer, Cmd_Argv( i ), sizeof( completionField->buffer ));
if (*arg == ' ') com.strncat( completionField->buffer, "\"", sizeof( completionField->buffer ));
}
}
@ -189,15 +189,15 @@ static void ConcatRemaining( const char *src, const char *start )
{
char *str;
str = strstr(src, start);
str = com.strstr(src, start);
if (!str)
{
keyConcatArgs();
return;
}
str += strlen(start);
strncat( completionField->buffer, str, sizeof( completionField->buffer ));
str += com.strlen(start);
com.strncat( completionField->buffer, str, sizeof( completionField->buffer ));
}
/*
@ -224,7 +224,7 @@ void Field_CompleteCommand( field_t *field )
matchCount = 0;
shortestMatch[0] = 0;
if(!strlen( completionString)) return;
if(!com.strlen( completionString)) return;
Cmd_LookupCmds( NULL, NULL, FindMatches );
Cvar_LookupVars( 0, NULL, NULL, FindMatches );
@ -237,35 +237,35 @@ void Field_CompleteCommand( field_t *field )
bool result = false;
// autocomplete second arg
if(!stricmp(Cmd_Argv(0), "map" ) || !stricmp(Cmd_Argv(0), "\\map" ))
if(!com.stricmp(Cmd_Argv(0), "map" ) || !com.stricmp(Cmd_Argv(0), "\\map" ))
{
result = Cmd_GetMapList(Cmd_Argv(1), filename, MAX_STRING );
}
else if(!stricmp(Cmd_Argv(0), "playsound" ) || !stricmp(Cmd_Argv(0), "\\playsound" ))
else if(!com.stricmp(Cmd_Argv(0), "playsound" ) || !com.stricmp(Cmd_Argv(0), "\\playsound" ))
{
result = Cmd_GetSoundList(Cmd_Argv(1), filename, MAX_STRING );
}
else if(!stricmp(Cmd_Argv(0), "playdemo" ) || !stricmp(Cmd_Argv(0), "\\playdemo" ))
else if(!com.stricmp(Cmd_Argv(0), "playdemo" ) || !com.stricmp(Cmd_Argv(0), "\\playdemo" ))
{
result = Cmd_GetDemoList(Cmd_Argv(1), filename, MAX_STRING );
}
else if(!stricmp(Cmd_Argv(0), "movie" ) || !stricmp(Cmd_Argv(0), "\\movie" ))
else if(!com.stricmp(Cmd_Argv(0), "movie" ) || !com.stricmp(Cmd_Argv(0), "\\movie" ))
{
result = Cmd_GetMovieList(Cmd_Argv(1), filename, MAX_STRING );
}
else if(!stricmp(Cmd_Argv(0), "changelevel" ) || !stricmp(Cmd_Argv(0), "\\changelevel" ))
else if(!com.stricmp(Cmd_Argv(0), "changelevel" ) || !com.stricmp(Cmd_Argv(0), "\\changelevel" ))
{
result = Cmd_GetMapList(Cmd_Argv(1), filename, MAX_STRING );
}
else if(!stricmp(Cmd_Argv(0), "setfont" ) || !stricmp(Cmd_Argv(0), "\\setfont" ))
else if(!com.stricmp(Cmd_Argv(0), "setfont" ) || !com.stricmp(Cmd_Argv(0), "\\setfont" ))
{
result = Cmd_GetFontList(Cmd_Argv(1), filename, MAX_STRING );
}
else if(!stricmp(Cmd_Argv(0), "music" ) || !stricmp(Cmd_Argv(0), "\\music" ))
else if(!com.stricmp(Cmd_Argv(0), "music" ) || !com.stricmp(Cmd_Argv(0), "\\music" ))
{
result = Cmd_GetMusicList(Cmd_Argv(1), filename, MAX_STRING );
}
else if(!stricmp(Cmd_Argv(0), "compile" ) || !stricmp(Cmd_Argv(0), "\\compile" ))
else if(!com.stricmp(Cmd_Argv(0), "compile" ) || !com.stricmp(Cmd_Argv(0), "\\compile" ))
{
result = Cmd_GetSourceList(Cmd_Argv(1), filename, MAX_STRING );
}
@ -289,7 +289,7 @@ void Field_CompleteCommand( field_t *field )
// multiple matches, complete to shortest
com.sprintf( completionField->buffer, "\\%s", shortestMatch );
completionField->cursor = strlen( completionField->buffer );
completionField->cursor = com.strlen( completionField->buffer );
ConcatRemaining( temp.buffer, completionString );
Msg( "]%s\n", completionField->buffer );
@ -317,7 +317,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, b
char str[MAX_SYSPATH];
drawLen = edit->widthInChars;
len = strlen( edit->buffer ) + 1;
len = com.strlen( edit->buffer ) + 1;
// guarantee that cursor will be visible
if ( len <= drawLen ) prestep = 0;
@ -451,12 +451,12 @@ void Field_KeyDownEvent( field_t *edit, int key )
if ( edit->cursor < edit->scroll ) edit->scroll--;
return;
}
if ( key == K_HOME || ( tolower(key) == 'a' && keys[K_CTRL].down ))
if ( key == K_HOME || ( com.tolower(key) == 'a' && keys[K_CTRL].down ))
{
edit->cursor = 0;
return;
}
if ( key == K_END || ( tolower(key) == 'e' && keys[K_CTRL].down ))
if ( key == K_END || ( com.tolower(key) == 'e' && keys[K_CTRL].down ))
{
edit->cursor = len;
return;
@ -489,7 +489,7 @@ void Field_CharEvent( field_t *edit, int ch )
Field_Clear( edit );
return;
}
len = strlen( edit->buffer );
len = com.strlen( edit->buffer );
if ( ch == 'a' - 'a' + 1 )
{
@ -595,7 +595,7 @@ void Key_Console(int key)
}
// command history (ctrl-p ctrl-n for unix style)
if ( (key == K_MWHEELUP && keys[K_SHIFT].down) || ( key == K_UPARROW ) || ( key == K_KP_UPARROW ) || (( tolower(key) == 'p' ) && keys[K_CTRL].down ))
if ( (key == K_MWHEELUP && keys[K_SHIFT].down) || ( key == K_UPARROW ) || ( key == K_KP_UPARROW ) || (( com.tolower(key) == 'p' ) && keys[K_CTRL].down ))
{
if ( nextHistoryLine - historyLine < COMMAND_HISTORY && historyLine > 0 )
{
@ -604,7 +604,7 @@ void Key_Console(int key)
g_consoleField = historyEditLines[ historyLine % COMMAND_HISTORY ];
return;
}
if ( (key == K_MWHEELDOWN && keys[K_SHIFT].down) || ( key == K_DOWNARROW ) || ( key == K_KP_DOWNARROW ) || (( tolower(key) == 'n' ) && keys[K_CTRL].down ))
if ( (key == K_MWHEELDOWN && keys[K_SHIFT].down) || ( key == K_DOWNARROW ) || ( key == K_KP_DOWNARROW ) || (( com.tolower(key) == 'n' ) && keys[K_CTRL].down ))
{
if (historyLine == nextHistoryLine) return;
historyLine++;
@ -753,7 +753,7 @@ int Key_StringToKeynum( char *str )
if ( !str[1] ) return str[0];
// check for hex code
if ( str[0] == '0' && str[1] == 'x' && strlen( str ) == 4)
if ( str[0] == '0' && str[1] == 'x' && com.strlen( str ) == 4)
{
int n1, n2;
@ -785,7 +785,7 @@ int Key_StringToKeynum( char *str )
// scan for a text match
for ( kn = keynames; kn->name; kn++ )
{
if( !stricmp( str,kn->name ))
if( !com.stricmp( str,kn->name ))
return kn->keynum;
}
return -1;
@ -882,7 +882,7 @@ int Key_GetKey(char *binding)
for (i = 0; i < 256; i++)
{
if (keys[i].binding && !stricmp(binding, keys[i].binding))
if (keys[i].binding && !com.stricmp(binding, keys[i].binding))
return i;
}
@ -965,8 +965,8 @@ void Key_Bind_f (void)
cmd[0] = 0; // start out with a null string
for (i = 2; i < c; i++)
{
strcat (cmd, Cmd_Argv(i));
if (i != (c-1)) strcat (cmd, " ");
com.strcat (cmd, Cmd_Argv(i));
if (i != (c-1)) com.strcat (cmd, " ");
}
Key_SetBinding (b, cmd);
}

View File

@ -128,12 +128,11 @@ void CL_Pause_f (void)
return; // but allow pause in demos
// never pause in multiplayer
if( Cvar_VariableValue ("maxclients") > 1 )
if(com.atoi(cl.configstrings[CS_MAXCLIENTS]) > 1 )
{
Cvar_SetValue ("paused", 0);
Cvar_SetValue( "paused", 0 );
return;
}
Cvar_SetValue( "paused", !cl_paused->value );
}
@ -258,7 +257,7 @@ void CL_Connect_f (void)
CL_Disconnect();
cls.state = ca_connecting;
strncpy (cls.servername, server, sizeof(cls.servername)-1);
com.strncpy (cls.servername, server, sizeof(cls.servername)-1);
cls.connect_time = MAX_HEARTBEAT; // CL_CheckForResend() will fire immediately
}
@ -290,22 +289,22 @@ void CL_Rcon_f (void)
message[3] = (char)255;
message[4] = 0;
strcat (message, "rcon ");
com.strcat (message, "rcon ");
strcat (message, rcon_client_password->string);
strcat (message, " ");
com.strcat (message, rcon_client_password->string);
com.strcat (message, " ");
for (i=1 ; i<Cmd_Argc() ; i++)
{
strcat (message, Cmd_Argv(i));
strcat (message, " ");
com.strcat (message, Cmd_Argv(i));
com.strcat (message, " ");
}
if (cls.state >= ca_connected)
to = cls.netchan.remote_address;
else
{
if (!strlen(rcon_address->string))
if (!com.strlen(rcon_address->string))
{
Msg ("You must either be connected,\n"
"or set the 'rcon_address' cvar\n"
@ -318,7 +317,7 @@ void CL_Rcon_f (void)
to.port = BigShort (PORT_SERVER);
}
NET_SendPacket (NS_CLIENT, strlen(message)+1, message, to);
NET_SendPacket (NS_CLIENT, com.strlen(message)+1, message, to);
}
@ -366,9 +365,9 @@ void CL_Disconnect( void )
// send a disconnect message to the server
final[0] = clc_stringcmd;
com.strcpy ((char *)final+1, "disconnect");
Netchan_Transmit(&cls.netchan, strlen(final), final);
Netchan_Transmit(&cls.netchan, strlen(final), final);
Netchan_Transmit(&cls.netchan, strlen(final), final);
Netchan_Transmit(&cls.netchan, com.strlen(final), final);
Netchan_Transmit(&cls.netchan, com.strlen(final), final);
Netchan_Transmit(&cls.netchan, com.strlen(final), final);
CL_ClearState ();
@ -422,7 +421,7 @@ void CL_Packet_f (void)
out = send+4;
send[0] = send[1] = send[2] = send[3] = (char)0xff;
l = strlen (in);
l = com.strlen (in);
for (i=0 ; i<l ; i++)
{
if (in[i] == '\\' && in[i+1] == 'n')
@ -720,7 +719,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
}
// remote command from gui front end
if(!strcmp(c, "cmd"))
if(!com.strcmp(c, "cmd"))
{
if(!NET_IsLocalAddress(from))
{
@ -735,7 +734,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
return;
}
// print command from somewhere
if (!strcmp(c, "print"))
if (!com.strcmp(c, "print"))
{
// print command from somewhere
s = MSG_ReadString( msg );
@ -745,14 +744,14 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
}
// ping from somewhere
if (!strcmp(c, "ping"))
if (!com.strcmp(c, "ping"))
{
Netchan_OutOfBandPrint( NS_CLIENT, from, "ack" );
return;
}
// challenge from the server we are connecting to
if (!strcmp(c, "challenge"))
if (!com.strcmp(c, "challenge"))
{
cls.challenge = com.atoi(Cmd_Argv(1));
CL_SendConnectPacket();
@ -760,7 +759,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
}
// echo request from server
if (!strcmp(c, "echo"))
if (!com.strcmp(c, "echo"))
{
Netchan_OutOfBandPrint( NS_CLIENT, from, "%s", Cmd_Argv(1) );
return;
@ -999,16 +998,16 @@ void CL_RequestNextDownload (void)
continue;
}
if ((p = strchr(cl.configstrings[CS_PLAYERSKINS+i], '\\')) != NULL)
if ((p = com.strchr(cl.configstrings[CS_PLAYERSKINS+i], '\\')) != NULL)
p++;
else p = cl.configstrings[CS_PLAYERSKINS+i];
strcpy(model, p);
p = strchr(model, '/');
if (!p) p = strchr(model, '\\');
com.strcpy(model, p);
p = com.strchr(model, '/');
if (!p) p = com.strchr(model, '\\');
if (p)
{
*p++ = 0;
strcpy(skin, p);
com.strcpy(skin, p);
}
else *skin = 0;
@ -1210,33 +1209,6 @@ void CL_InitLocal (void)
Cmd_AddCommand ("precache", CL_Precache_f, "precache specified resource (by index)" );
Cmd_AddCommand ("download", CL_Download_f, "download specified resource (by name)" );
//
// forward to server commands
//
// the only thing this does is allow command completion
// to work -- all unknown commands are automatically
// forwarded to the server
Cmd_AddCommand ("wave", NULL, NULL );
Cmd_AddCommand ("inven", NULL, NULL );
Cmd_AddCommand ("kill", NULL, NULL );
Cmd_AddCommand ("use", NULL, NULL );
Cmd_AddCommand ("drop", NULL, NULL );
Cmd_AddCommand ("say", NULL, NULL );
Cmd_AddCommand ("say_team", NULL, NULL );
Cmd_AddCommand ("enum_activity", NULL, NULL );
Cmd_AddCommand ("info", NULL, NULL );
Cmd_AddCommand ("prog", NULL, NULL );
Cmd_AddCommand ("give", NULL, NULL );
Cmd_AddCommand ("god", NULL, NULL );
Cmd_AddCommand ("notarget", NULL, NULL );
Cmd_AddCommand ("noclip", NULL, NULL );
Cmd_AddCommand ("invuse", NULL, NULL );
Cmd_AddCommand ("invprev", NULL, NULL );
Cmd_AddCommand ("invnext", NULL, NULL );
Cmd_AddCommand ("invdrop", NULL, NULL );
Cmd_AddCommand ("weapnext", NULL, NULL );
Cmd_AddCommand ("weapprev", NULL, NULL );
UI_ShowMenu();
}
@ -1315,7 +1287,7 @@ void CL_FixCvarCheats (void)
int i;
cheatvar_t *var;
if ( !strcmp(cl.configstrings[CS_MAXCLIENTS], "1")
if ( !com.strcmp(cl.configstrings[CS_MAXCLIENTS], "1")
|| !cl.configstrings[CS_MAXCLIENTS][0] )
return; // single player can cheat
@ -1333,7 +1305,7 @@ void CL_FixCvarCheats (void)
// make sure they are all set to the proper values
for (i=0, var = cheatvars ; i<numcheatvars ; i++, var++)
{
if ( strcmp (var->var->string, var->value) )
if ( com.strcmp (var->var->string, var->value) )
{
Cvar_Set (var->name, var->value);
}

View File

@ -676,7 +676,7 @@ VM_ComStrlen, // #30 float strlen( string text )
VM_TimeStamp, // #31 string Com_TimeStamp( float format )
VM_LocalCmd, // #32 void LocalCmd( ... )
VM_SubString, // #33 string substring( string s, float start, float length )
NULL, // #34 -- reserved --
VM_AddCommand, // #34 void Add_Command( string s )
NULL, // #35 -- reserved --
NULL, // #36 -- reserved --
NULL, // #37 -- reserved --

View File

@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void CL_DownloadFileName(char *dest, int destlen, char *fn)
{
strncpy(dest, fn, destlen );
com.strncpy(dest, fn, destlen );
}
/*
@ -42,7 +42,7 @@ bool CL_CheckOrDownloadFile (char *filename)
file_t *fp;
char name[MAX_SYSPATH];
if (strstr (filename, ".."))
if (com.strstr (filename, ".."))
{
Msg ("Refusing to download a path with ..\n");
return true;
@ -54,8 +54,8 @@ bool CL_CheckOrDownloadFile (char *filename)
return true;
}
strcpy (cls.downloadname, filename);
strcpy (cls.downloadtempname, filename);
com.strcpy (cls.downloadname, filename);
com.strcpy (cls.downloadtempname, filename);
// download to a temp name, and only rename
// to the real name when done, so if interrupted
@ -115,7 +115,7 @@ void CL_Download_f (void)
com.sprintf(filename, "%s", Cmd_Argv(1));
if (strstr (filename, ".."))
if (com.strstr (filename, ".."))
{
Msg ("Refusing to download a path with ..\n");
return;
@ -128,8 +128,8 @@ void CL_Download_f (void)
return;
}
strcpy (cls.downloadname, filename);
strcpy (cls.downloadtempname, filename);
com.strcpy (cls.downloadname, filename);
com.strcpy (cls.downloadtempname, filename);
Msg ("Downloading %s\n", cls.downloadname);
@ -344,13 +344,13 @@ void CL_LoadClientinfo (clientinfo_t *ci, char *s)
char model_filename[MAX_QPATH];
char weapon_filename[MAX_QPATH];
strncpy(ci->cinfo, s, sizeof(ci->cinfo));
com.strncpy(ci->cinfo, s, sizeof(ci->cinfo));
ci->cinfo[sizeof(ci->cinfo)-1] = 0;
// isolate the player's name
strncpy(ci->name, s, sizeof(ci->name));
com.strncpy(ci->name, s, sizeof(ci->name));
ci->name[sizeof(ci->name)-1] = 0;
t = strstr (s, "\\");
t = com.strstr (s, "\\");
if (t)
{
ci->name[t-s] = 0;
@ -369,13 +369,13 @@ void CL_LoadClientinfo (clientinfo_t *ci, char *s)
{
// isolate the model name
com.strcpy (model_name, s);
t = strstr(model_name, "/");
if (!t) t = strstr(model_name, "\\");
t = com.strstr(model_name, "/");
if (!t) t = com.strstr(model_name, "\\");
if (!t) t = model_name;
*t = 0;
// isolate the skin name
strcpy (skin_name, s + strlen(model_name) + 1);
com.strcpy (skin_name, s + com.strlen(model_name) + 1);
// model file
com.sprintf (model_filename, "models/players/%s/player.mdl", model_name);
@ -389,7 +389,7 @@ void CL_LoadClientinfo (clientinfo_t *ci, char *s)
// if we don't have the skin and the model wasn't male,
// see if the male has it (this is for CTF's skins)
if (!ci->skin && strcasecmp(model_name, "male"))
if (!ci->skin && com.stricmp(model_name, "male"))
{
// change model to male
com.strcpy(model_name, "male");
@ -451,10 +451,10 @@ void CL_ParseConfigString( sizebuf_t *msg )
if (i < 0 || i >= MAX_CONFIGSTRINGS) Host_Error("configstring > MAX_CONFIGSTRINGS\n");
s = MSG_ReadString( msg );
strncpy (olds, cl.configstrings[i], sizeof(olds));
com.strncpy (olds, cl.configstrings[i], sizeof(olds));
olds[sizeof(olds) - 1] = 0;
strcpy (cl.configstrings[i], s);
com.strcpy (cl.configstrings[i], s);
// do something apropriate
@ -482,7 +482,7 @@ void CL_ParseConfigString( sizebuf_t *msg )
}
else if (i >= CS_PLAYERSKINS && i < CS_PLAYERSKINS+MAX_CLIENTS)
{
if (cl.refresh_prepped && strcmp(olds, s))
if (cl.refresh_prepped && com.strcmp(olds, s))
CL_ParseClientinfo (i-CS_PLAYERSKINS);
}
}

View File

@ -45,7 +45,7 @@ void CL_CheckPredictionError (void)
// save the prediction error for interpolation
len = abs(delta[0]) + abs(delta[1]) + abs(delta[2]);
if( len > 640 * SV_COORD_FRAC ) // 80 world units
if( len > 640 ) // 80 world units
{ // a teleport or something
VectorClear (cl.prediction_error);
}
@ -57,7 +57,7 @@ void CL_CheckPredictionError (void)
VectorCopy (cl.frame.ps.origin, cl.predicted_origins[frame]);
// save for error itnerpolation
VectorScale( delta, CL_COORD_FRAC, cl.prediction_error );
VectorCopy( delta, cl.prediction_error );
}
}
@ -316,12 +316,12 @@ void CL_PredictMovement (void)
step = pm.ps.origin[2] - oldz;
if( step > 63 && step < 160 )
{
cl.predicted_step = step * CL_COORD_FRAC;
cl.predicted_step = step;
cl.predicted_step_time = cls.realtime - cls.frametime * 500;
}
}
// copy results out for rendering
VectorScale( pm.ps.origin, CL_COORD_FRAC, cl.predicted_origin );
VectorCopy( pm.ps.origin, cl.predicted_origin );
VectorCopy(pm.ps.viewangles, cl.predicted_angles);
}

View File

@ -500,7 +500,7 @@ VM_ComStrlen, // #30 float strlen( string text )
VM_TimeStamp, // #31 string Com_TimeStamp( float format )
VM_LocalCmd, // #32 void LocalCmd( ... )
VM_SubString, // #33 string substring( string s, float start, float length )
NULL, // #34 -- reserved --
VM_AddCommand, // #34 void Add_Command( string s )
NULL, // #35 -- reserved --
NULL, // #36 -- reserved --
NULL, // #37 -- reserved --
@ -592,8 +592,8 @@ void CL_InitClientProgs( void )
{
Msg("\n");
PRVM_Begin;
PRVM_InitProg( PRVM_CLIENTPROG );
PRVM_InitProg( PRVM_CLIENTPROG );
if( !prog->loaded )
{
prog->progs_mempool = Mem_AllocPool( "Client Progs" );

View File

@ -371,7 +371,7 @@ void *dpv_open( const char *filename, char **errorstring )
if( s->info_framerate > 0.0f )
{
s->videopixels = (uint *)Z_Malloc(s->info_imagewidth * s->info_imageheight * sizeof(*s->videopixels));
s->videopixels = (uint *)Mem_Alloc( cls.mempool, s->info_imagewidth * s->info_imageheight * sizeof(*s->videopixels));
s->videoframenum = MAX_HEARTBEAT;
return s;
}

View File

@ -729,6 +729,29 @@ void VM_LocalCmd( void )
Cbuf_AddText(VM_VarArgs( 0 ));
}
/*
=========
VM_AddCommand
void Add_Command( string s )
=========
*/
void VM_AddCommand( void )
{
const char *name;
if(!VM_ValidateArgs( "Add_Command", 1 ))
return;
VM_ValidateString(PRVM_G_STRING(OFS_PARM0));
name = PRVM_G_STRING(OFS_PARM0);
// register new command
// NOTE: cmd without callback will be forwarded to server
Cmd_AddCommand( name, NULL, NULL );
}
/*
=========
VM_ComVA
@ -1633,8 +1656,8 @@ VM_ComVA, // #29 string va( ... )
VM_ComStrlen, // #30 float strlen( string text )
VM_TimeStamp, // #31 string Com_TimeStamp( float format )
VM_LocalCmd, // #32 void LocalCmd( ... )
NULL, // #33 -- reserved --
NULL, // #34 -- reserved --
VM_SubString, // #33 string substring( string s, float start, float length )
VM_AddCommand, // #34 void Add_Command( string s )
NULL, // #35 -- reserved --
NULL, // #36 -- reserved --
NULL, // #37 -- reserved --
@ -1795,7 +1818,7 @@ void Info_RemoveKey (char *s, char *key)
char value[512];
char *o;
if (strstr (key, "\\")) return;
if (com.strstr (key, "\\")) return;
while (1)
{
@ -1818,9 +1841,9 @@ void Info_RemoveKey (char *s, char *key)
}
*o = 0;
if (!strcmp (key, pkey) )
if (!com.strcmp (key, pkey) )
{
strcpy (start, s); // remove this part
com.strcpy (start, s); // remove this part
return;
}
if (!*s) return;
@ -1837,8 +1860,8 @@ can mess up the server's parsing
*/
bool Info_Validate (char *s)
{
if (strstr (s, "\"")) return false;
if (strstr (s, ";")) return false;
if (com.strstr (s, "\"")) return false;
if (com.strstr (s, ";")) return false;
return true;
}
@ -1847,23 +1870,23 @@ void Info_SetValueForKey (char *s, char *key, char *value)
char newi[MAX_INFO_STRING], *v;
int c, maxsize = MAX_INFO_STRING;
if (strstr (key, "\\") || strstr (value, "\\") )
if (com.strstr (key, "\\") || com.strstr (value, "\\") )
{
Msg ("Can't use keys or values with a \\\n");
return;
}
if (strstr (key, ";") )
if (com.strstr (key, ";") )
{
Msg ("Can't use keys or values with a semicolon\n");
return;
}
if (strstr (key, "\"") || strstr (value, "\"") )
if (com.strstr (key, "\"") || com.strstr (value, "\"") )
{
Msg ("Can't use keys or values with a \"\n");
return;
}
if (strlen(key) > MAX_INFO_KEY - 1 || strlen(value) > MAX_INFO_KEY-1)
if (com.strlen(key) > MAX_INFO_KEY - 1 || com.strlen(value) > MAX_INFO_KEY-1)
{
Msg ("Keys and values must be < 64 characters.\n");
return;
@ -1936,7 +1959,7 @@ bool Cmd_GetMapList( const char *s, char *completedname, int length )
if( !t ) return false;
FS_FileBase(t->filenames[0], matchbuf );
strncpy( completedname, matchbuf, length );
com.strncpy( completedname, matchbuf, length );
if(t->numfilenames == 1) return true;
for(i = 0, nummaps = 0; i < t->numfilenames; i++)
@ -1949,7 +1972,7 @@ bool Cmd_GetMapList( const char *s, char *completedname, int length )
if( com.stricmp(ext, "bsp" )) continue;
strncpy(message, "^1error^7", sizeof(message));
com.strncpy(message, "^1error^7", sizeof(message));
f = FS_Open(t->filenames[i], "rb" );
if( f )
@ -1975,7 +1998,7 @@ bool Cmd_GetMapList( const char *s, char *completedname, int length )
else
{
lump_t ents; // quake1 entity lump
memcpy(&ents, buf + 4, sizeof(lump_t)); // skip first four bytes (version)
Mem_Copy(&ents, buf + 4, sizeof(lump_t)); // skip first four bytes (version)
ver = LittleLong(((int *)buf)[0]);
switch( ver )
@ -2012,13 +2035,13 @@ bool Cmd_GetMapList( const char *s, char *completedname, int length )
data = entities;
while(Com_ParseToken(&data))
{
if(!strcmp(com_token, "{" )) continue;
else if(!strcmp(com_token, "}" )) break;
else if(!strcmp(com_token, "message" ))
if(!com.strcmp(com_token, "{" )) continue;
else if(!com.strcmp(com_token, "}" )) break;
else if(!com.strcmp(com_token, "message" ))
{
// get the message contents
Com_ParseToken(&data);
strncpy(message, com_token, sizeof(message));
com.strncpy(message, com_token, sizeof(message));
}
}
}
@ -2029,14 +2052,14 @@ bool Cmd_GetMapList( const char *s, char *completedname, int length )
switch(ver)
{
case 28: strncpy((char *)buf, "Quake1 beta", sizeof(buf)); break;
case 29: strncpy((char *)buf, "Quake1", sizeof(buf)); break;
case 30: strncpy((char *)buf, "Half-Life", sizeof(buf)); break;
case 38: strncpy((char *)buf, "Quake 2", sizeof(buf)); break;
case 39: strncpy((char *)buf, "Xash 3D", sizeof(buf)); break;
case 46: strncpy((char *)buf, "Quake 3", sizeof(buf)); break;
case 47: strncpy((char *)buf, "RTCW", sizeof(buf)); break;
default: strncpy((char *)buf, "??", sizeof(buf)); break;
case 28: com.strncpy((char *)buf, "Quake1 beta", sizeof(buf)); break;
case 29: com.strncpy((char *)buf, "Quake1", sizeof(buf)); break;
case 30: com.strncpy((char *)buf, "Half-Life", sizeof(buf)); break;
case 38: com.strncpy((char *)buf, "Quake 2", sizeof(buf)); break;
case 39: com.strncpy((char *)buf, "Xash 3D", sizeof(buf)); break;
case 46: com.strncpy((char *)buf, "Quake 3", sizeof(buf)); break;
case 47: com.strncpy((char *)buf, "RTCW", sizeof(buf)); break;
default: com.strncpy((char *)buf, "??", sizeof(buf)); break;
}
Msg("%16s (%s) ^3%s^7\n", matchbuf, buf, message);
nummaps++;
@ -2047,7 +2070,7 @@ bool Cmd_GetMapList( const char *s, char *completedname, int length )
// cut shortestMatch to the amount common with s
for( i = 0; matchbuf[i]; i++ )
{
if(tolower(completedname[i]) != tolower(matchbuf[i]))
if(com.tolower(completedname[i]) != com.tolower(matchbuf[i]))
completedname[i] = 0;
}
return true;
@ -2090,7 +2113,7 @@ bool Cmd_GetFontList( const char *s, char *completedname, int length )
{
for( i = 0; matchbuf[i]; i++ )
{
if(com.tolower(completedname[i]) != tolower(matchbuf[i]))
if(com.tolower(completedname[i]) != com.tolower(matchbuf[i]))
completedname[i] = 0;
}
}
@ -2135,7 +2158,7 @@ bool Cmd_GetDemoList( const char *s, char *completedname, int length )
{
for( i = 0; matchbuf[i]; i++ )
{
if(com.tolower(completedname[i]) != tolower(matchbuf[i]))
if(com.tolower(completedname[i]) != com.tolower(matchbuf[i]))
completedname[i] = 0;
}
}
@ -2182,7 +2205,7 @@ bool Cmd_GetSourceList( const char *s, char *completedname, int length )
{
for( i = 0; matchbuf[i]; i++ )
{
if(com.tolower(completedname[i]) != tolower(matchbuf[i]))
if(com.tolower(completedname[i]) != com.tolower(matchbuf[i]))
completedname[i] = 0;
}
}
@ -2206,7 +2229,7 @@ bool Cmd_GetMovieList( const char *s, char *completedname, int length )
if(!t) return false;
FS_FileBase(t->filenames[0], matchbuf );
if(completedname && length) strncpy( completedname, matchbuf, length );
if(completedname && length) com.strncpy( completedname, matchbuf, length );
if(t->numfilenames == 1) return true;
for(i = 0, nummovies = 0; i < t->numfilenames; i++)
@ -2226,7 +2249,7 @@ bool Cmd_GetMovieList( const char *s, char *completedname, int length )
{
for( i = 0; matchbuf[i]; i++ )
{
if(com.tolower(completedname[i]) != tolower(matchbuf[i]))
if(com.tolower(completedname[i]) != com.tolower(matchbuf[i]))
completedname[i] = 0;
}
}
@ -2251,7 +2274,7 @@ bool Cmd_GetMusicList( const char *s, char *completedname, int length )
if(!t) return false;
FS_FileBase(t->filenames[0], matchbuf );
if(completedname && length) strncpy( completedname, matchbuf, length );
if(completedname && length) com.strncpy( completedname, matchbuf, length );
if(t->numfilenames == 1) return true;
for(i = 0, numtracks = 0; i < t->numfilenames; i++)
@ -2271,7 +2294,7 @@ bool Cmd_GetMusicList( const char *s, char *completedname, int length )
{
for( i = 0; matchbuf[i]; i++ )
{
if(com.tolower(completedname[i]) != tolower(matchbuf[i]))
if(com.tolower(completedname[i]) != com.tolower(matchbuf[i]))
completedname[i] = 0;
}
}
@ -2377,7 +2400,7 @@ bool Cmd_CheckMapsList( void )
else
{
lump_t ents; // quake1 entity lump
memcpy(&ents, buf + 4, sizeof(lump_t)); // skip first four bytes (version)
Mem_Copy(&ents, buf + 4, sizeof(lump_t)); // skip first four bytes (version)
ver = LittleLong(((int *)buf)[0]);
switch( ver )
@ -2414,16 +2437,16 @@ bool Cmd_CheckMapsList( void )
while(Com_ParseToken(&data))
{
if(!strcmp(com_token, "{" )) continue;
else if(!strcmp(com_token, "}" )) break;
else if(!strcmp(com_token, "message" ))
if(!com.strcmp(com_token, "{" )) continue;
else if(!com.strcmp(com_token, "}" )) break;
else if(!com.strcmp(com_token, "message" ))
{
// get the message contents
Com_ParseToken(&data);
if(!strcmp(com_token, "" )) continue;
if(!com.strcmp(com_token, "" )) continue;
com.strncpy(message, com_token, sizeof(message));
}
else if(!strcmp(com_token, "classname" ))
else if(!com.strcmp(com_token, "classname" ))
{
Com_ParseToken(&data);
if(!com.strcmp(com_token, "info_player_deatchmatch"))
@ -2446,7 +2469,7 @@ bool Cmd_CheckMapsList( void )
if( t ) Mem_Free(t); // free search result
// write generated maps.lst
if(FS_WriteFile("scripts/maps.lst", buffer, strlen(buffer)))
if(FS_WriteFile("scripts/maps.lst", buffer, com.strlen(buffer)))
{
if( buffer ) Mem_Free(buffer);
return true;

View File

@ -22,7 +22,6 @@ extern vsound_exp_t *se;
#define MAX_ENTNUMBER 99999 // for server and client parsing
#define MAX_HEARTBEAT -99999 // connection time
#define HOST_FRAMETIME 100 // host.frametime in msecs (change with caution)
#define MAX_EVENTS 1024
/*
@ -129,9 +128,7 @@ void IN_MouseEvent( int mstate );
// cvars
extern cvar_t *host_serverstate;
extern cvar_t *host_frametime;
extern cvar_t *host_cheats;
extern cvar_t *cm_paused;
extern cvar_t *crosshair;
extern cvar_t *scr_loading;
extern cvar_t *scr_width;
@ -198,7 +195,8 @@ void Host_Main ( void );
void Host_Free ( void );
void Host_SetServerState( int state );
int Host_ServerState( void );
float Host_FrameTime( void );
int Host_FrameTime( void );
int Host_MaxClients( void );
void Host_AbortCurrentFrame( void );
dword Host_EventLoop( void );
@ -352,6 +350,7 @@ void VM_CvarSetValue( void );
void VM_CvarGetValue( void );
void VM_CvarSetString( void );
void VM_CvarGetString( void );
void VM_AddCommand( void );
void VM_ComVA( void );
void VM_ComStrlen( void );
void VM_TimeStamp( void );

View File

@ -7,6 +7,126 @@
#include "byteorder.h"
#include "mathlib.h"
static net_field_t ent_fields[] =
{
{ ES_FIELD(ed_type), NET_BYTE, true },
{ ES_FIELD(soundindex), NET_WORD, false }, // 512 sounds ( OpenAL software limit is 255 )
{ ES_FIELD(origin[0]), NET_FLOAT, false },
{ ES_FIELD(origin[1]), NET_FLOAT, false },
{ ES_FIELD(origin[2]), NET_FLOAT, false },
{ ES_FIELD(angles[0]), NET_FLOAT, false },
{ ES_FIELD(angles[1]), NET_FLOAT, false },
{ ES_FIELD(angles[2]), NET_FLOAT, false },
{ ES_FIELD(velocity[0]), NET_FLOAT, false },
{ ES_FIELD(velocity[1]), NET_FLOAT, false },
{ ES_FIELD(velocity[2]), NET_FLOAT, false },
{ ES_FIELD(old_origin[0]), NET_FLOAT, true }, // send always
{ ES_FIELD(old_origin[1]), NET_FLOAT, true },
{ ES_FIELD(old_origin[2]), NET_FLOAT, true },
{ ES_FIELD(old_velocity[0]), NET_FLOAT, false }, // client velocity
{ ES_FIELD(old_velocity[1]), NET_FLOAT, false },
{ ES_FIELD(old_velocity[2]), NET_FLOAT, false },
{ ES_FIELD(model.index), NET_WORD, false }, // 4096 models
{ ES_FIELD(model.colormap), NET_WORD, false }, // encoded as two shorts for top and bottom color
{ ES_FIELD(model.scale), NET_COLOR, false }, // 0-255 values
{ ES_FIELD(model.frame), NET_FLOAT, false }, // interpolate value
{ ES_FIELD(model.animtime), NET_FLOAT, false }, // auto-animating time
{ ES_FIELD(model.framerate), NET_FLOAT, false }, // custom framerate
{ ES_FIELD(model.sequence), NET_WORD, false }, // 1024 sequences
{ ES_FIELD(model.gaitsequence), NET_WORD, false }, // 1024 gaitsequences
{ ES_FIELD(model.skin), NET_BYTE, false }, // 255 skins
{ ES_FIELD(model.body), NET_BYTE, false }, // 255 bodies
{ ES_FIELD(model.blending[0]), NET_COLOR, false }, // animation blending
{ ES_FIELD(model.blending[1]), NET_COLOR, false },
{ ES_FIELD(model.blending[2]), NET_COLOR, false },
{ ES_FIELD(model.blending[3]), NET_COLOR, false },
{ ES_FIELD(model.blending[4]), NET_COLOR, false }, // send flags (first 4 bytes)
{ ES_FIELD(model.blending[5]), NET_COLOR, false },
{ ES_FIELD(model.blending[6]), NET_COLOR, false },
{ ES_FIELD(model.blending[7]), NET_COLOR, false },
{ ES_FIELD(model.blending[8]), NET_COLOR, false },
{ ES_FIELD(model.controller[0]), NET_COLOR, false }, // bone controllers #
{ ES_FIELD(model.controller[1]), NET_COLOR, false },
{ ES_FIELD(model.controller[2]), NET_COLOR, false },
{ ES_FIELD(model.controller[3]), NET_COLOR, false },
{ ES_FIELD(model.controller[4]), NET_COLOR, false },
{ ES_FIELD(model.controller[5]), NET_COLOR, false },
{ ES_FIELD(model.controller[6]), NET_COLOR, false },
{ ES_FIELD(model.controller[7]), NET_COLOR, false },
{ ES_FIELD(model.controller[8]), NET_COLOR, false },
{ ES_FIELD(model.controller[9]), NET_COLOR, false },
{ ES_FIELD(model.controller[10]), NET_COLOR, false },
{ ES_FIELD(model.controller[11]), NET_COLOR, false },
{ ES_FIELD(model.controller[12]), NET_COLOR, false },
{ ES_FIELD(model.controller[13]), NET_COLOR, false },
{ ES_FIELD(model.controller[14]), NET_COLOR, false },
{ ES_FIELD(model.controller[15]), NET_COLOR, false },
{ ES_FIELD(model.controller[16]), NET_COLOR, false }, // FIXME: sending as array
{ ES_FIELD(solidtype), NET_BYTE, false },
{ ES_FIELD(movetype), NET_BYTE, false }, // send flags (second 4 bytes)
{ ES_FIELD(gravity), NET_SHORT, false }, // gravity multiplier
{ ES_FIELD(aiment), NET_WORD, false }, // entity index
{ ES_FIELD(solid), NET_LONG, false }, // encoded mins/maxs
{ ES_FIELD(mins[0]), NET_FLOAT, false },
{ ES_FIELD(mins[1]), NET_FLOAT, false },
{ ES_FIELD(mins[2]), NET_FLOAT, false },
{ ES_FIELD(maxs[0]), NET_FLOAT, false },
{ ES_FIELD(maxs[1]), NET_FLOAT, false },
{ ES_FIELD(maxs[2]), NET_FLOAT, false },
{ ES_FIELD(effects), NET_LONG, false }, // effect flags
{ ES_FIELD(renderfx), NET_LONG, false }, // renderfx flags
{ ES_FIELD(renderamt), NET_COLOR, false }, // alpha amount
{ ES_FIELD(rendercolor[0]), NET_COLOR, false }, // animation blending
{ ES_FIELD(rendercolor[1]), NET_COLOR, false },
{ ES_FIELD(rendercolor[2]), NET_COLOR, false },
{ ES_FIELD(rendermode), NET_BYTE, false }, // render mode (legacy stuff)
{ ES_FIELD(pm_type), NET_BYTE, false }, // 16 player movetypes allowed
{ ES_FIELD(pm_flags), NET_WORD, false }, // 16 movetype flags allowed
{ ES_FIELD(pm_time), NET_BYTE, false }, // each unit 8 msec
{ ES_FIELD(delta_angles[0]), NET_FLOAT, false },
{ ES_FIELD(delta_angles[1]), NET_FLOAT, false },
{ ES_FIELD(delta_angles[2]), NET_FLOAT, false },
{ ES_FIELD(punch_angles[0]), NET_SCALE, false },
{ ES_FIELD(punch_angles[1]), NET_SCALE, false },
{ ES_FIELD(punch_angles[2]), NET_SCALE, false },
{ ES_FIELD(viewangles[0]), NET_FLOAT, false }, // for fixed views
{ ES_FIELD(viewangles[1]), NET_FLOAT, false },
{ ES_FIELD(viewangles[2]), NET_FLOAT, false },
{ ES_FIELD(viewoffset[0]), NET_SCALE, false },
{ ES_FIELD(viewoffset[1]), NET_SCALE, false },
{ ES_FIELD(viewoffset[2]), NET_SCALE, false },
{ ES_FIELD(maxspeed), NET_WORD, false }, // send flags (third 4 bytes )
{ ES_FIELD(fov), NET_FLOAT, false }, // client horizontal field of view
{ ES_FIELD(health), NET_FLOAT, false }, // client health
{ ES_FIELD(vmodel.index), NET_WORD, false }, // 4096 models
{ ES_FIELD(vmodel.colormap), NET_LONG, false }, // 4096 models
{ ES_FIELD(vmodel.sequence), NET_WORD, false }, // 1024 sequences
{ ES_FIELD(vmodel.frame), NET_FLOAT, false }, // interpolate value
{ ES_FIELD(vmodel.body), NET_BYTE, false }, // 255 bodies
{ ES_FIELD(vmodel.skin), NET_BYTE, false }, // 255 skins
{ ES_FIELD(pmodel.index), NET_WORD, false }, // 4096 models
{ ES_FIELD(pmodel.colormap), NET_LONG, false }, // 4096 models
{ ES_FIELD(pmodel.sequence), NET_WORD, false }, // 1024 sequences
{ ES_FIELD(vmodel.frame), NET_FLOAT, false }, // interpolate value
{ NULL }, // terminator
};
// probably usercmd_t never reached 32 field integer limit (in theory of course)
static net_field_t cmd_fields[] =
{
{ CM_FIELD(msec), NET_BYTE, true },
{ CM_FIELD(angles[0]), NET_WORD, false },
{ CM_FIELD(angles[1]), NET_WORD, false },
{ CM_FIELD(angles[2]), NET_WORD, false },
{ CM_FIELD(forwardmove), NET_SHORT, false },
{ CM_FIELD(sidemove), NET_SHORT, false },
{ CM_FIELD(upmove), NET_SHORT, false },
{ CM_FIELD(buttons), NET_BYTE, false },
{ CM_FIELD(impulse), NET_BYTE, false },
{ CM_FIELD(lightlevel), NET_BYTE, false },
{ NULL },
};
/*
=============================================================================
@ -168,14 +288,6 @@ void _MSG_WriteBits( sizebuf_t *msg, int value, int net_type, const char *filena
buf[0] = value & 0xff;
buf[1] = value>>8;
break;
case NET_COORD:
value *= SV_COORD_FRAC;
buf = MSG_GetSpace( msg, 4 );
buf[0] = (value>>0 ) & 0xff;
buf[1] = (value>>8 ) & 0xff;
buf[2] = (value>>16) & 0xff;
buf[3] = (value>>24);
break;
default:
Host_Error( "MSG_WriteBits: bad net.type (called at %s:%i)\n", filename, fileline );
break;
@ -231,11 +343,6 @@ long _MSG_ReadBits( sizebuf_t *msg, int net_type, const char *filename, const in
value = SHORT2ANGLE( value );
msg->readcount += 2;
break;
case NET_COORD:
value = (long)BuffLittleLong(msg->data + msg->readcount);
value *= CL_COORD_FRAC;
msg->readcount += 4;
break;
default:
Host_Error( "MSG_ReadBits: bad net.type (called at %s:%i)\n", filename, fileline );
break;

View File

@ -147,133 +147,12 @@ static const net_desc_t NWDesc[] =
#define CS_GENERAL (CS_PLAYERSKINS+MAX_CLIENTS)
#define MAX_CONFIGSTRINGS (CS_GENERAL+MAX_GENERAL)
// sound flags
// sound flags (get rid of this)
#define SND_VOL (1<<0) // a scaled byte
#define SND_ATTN (1<<1) // a byte
#define SND_POS (1<<2) // three coordinates
#define SND_ENT (1<<3) // a short 0 - 2: channel, 3 - 12: entity
static net_field_t ent_fields[] =
{
{ ES_FIELD(ed_type), NET_BYTE, true },
{ ES_FIELD(soundindex), NET_WORD, false }, // 512 sounds ( OpenAL software limit is 255 )
{ ES_FIELD(origin[0]), NET_FLOAT, false },
{ ES_FIELD(origin[1]), NET_FLOAT, false },
{ ES_FIELD(origin[2]), NET_FLOAT, false },
{ ES_FIELD(angles[0]), NET_FLOAT, false },
{ ES_FIELD(angles[1]), NET_FLOAT, false },
{ ES_FIELD(angles[2]), NET_FLOAT, false },
{ ES_FIELD(velocity[0]), NET_FLOAT, false },
{ ES_FIELD(velocity[1]), NET_FLOAT, false },
{ ES_FIELD(velocity[2]), NET_FLOAT, false },
{ ES_FIELD(old_origin[0]), NET_FLOAT, true }, // send always
{ ES_FIELD(old_origin[1]), NET_FLOAT, true },
{ ES_FIELD(old_origin[2]), NET_FLOAT, true },
{ ES_FIELD(old_velocity[0]), NET_FLOAT, true }, // client velocity
{ ES_FIELD(old_velocity[1]), NET_FLOAT, true },
{ ES_FIELD(old_velocity[2]), NET_FLOAT, true },
{ ES_FIELD(model.index), NET_WORD, false }, // 4096 models
{ ES_FIELD(model.colormap), NET_WORD, false }, // encoded as two shorts for top and bottom color
{ ES_FIELD(model.scale), NET_COLOR, false }, // 0-255 values
{ ES_FIELD(model.frame), NET_FLOAT, false }, // interpolate value
{ ES_FIELD(model.animtime), NET_FLOAT, false }, // auto-animating time
{ ES_FIELD(model.framerate), NET_FLOAT, false }, // custom framerate
{ ES_FIELD(model.sequence), NET_WORD, false }, // 1024 sequences
{ ES_FIELD(model.gaitsequence), NET_WORD, false }, // 1024 gaitsequences
{ ES_FIELD(model.skin), NET_BYTE, false }, // 255 skins
{ ES_FIELD(model.body), NET_BYTE, false }, // 255 bodies
{ ES_FIELD(model.blending[0]), NET_COLOR, false }, // animation blending
{ ES_FIELD(model.blending[1]), NET_COLOR, false },
{ ES_FIELD(model.blending[2]), NET_COLOR, false },
{ ES_FIELD(model.blending[3]), NET_COLOR, false },
{ ES_FIELD(model.blending[4]), NET_COLOR, false }, // send flags (first 4 bytes)
{ ES_FIELD(model.blending[5]), NET_COLOR, false },
{ ES_FIELD(model.blending[6]), NET_COLOR, false },
{ ES_FIELD(model.blending[7]), NET_COLOR, false },
{ ES_FIELD(model.blending[8]), NET_COLOR, false },
{ ES_FIELD(model.controller[0]), NET_COLOR, false }, // bone controllers #
{ ES_FIELD(model.controller[1]), NET_COLOR, false },
{ ES_FIELD(model.controller[2]), NET_COLOR, false },
{ ES_FIELD(model.controller[3]), NET_COLOR, false },
{ ES_FIELD(model.controller[4]), NET_COLOR, false },
{ ES_FIELD(model.controller[5]), NET_COLOR, false },
{ ES_FIELD(model.controller[6]), NET_COLOR, false },
{ ES_FIELD(model.controller[7]), NET_COLOR, false },
{ ES_FIELD(model.controller[8]), NET_COLOR, false },
{ ES_FIELD(model.controller[9]), NET_COLOR, false },
{ ES_FIELD(model.controller[10]), NET_COLOR, false },
{ ES_FIELD(model.controller[11]), NET_COLOR, false },
{ ES_FIELD(model.controller[12]), NET_COLOR, false },
{ ES_FIELD(model.controller[13]), NET_COLOR, false },
{ ES_FIELD(model.controller[14]), NET_COLOR, false },
{ ES_FIELD(model.controller[15]), NET_COLOR, false },
{ ES_FIELD(model.controller[16]), NET_COLOR, false }, // FIXME: sending as array
{ ES_FIELD(solidtype), NET_BYTE, false },
{ ES_FIELD(movetype), NET_BYTE, false }, // send flags (second 4 bytes)
{ ES_FIELD(gravity), NET_SHORT, false }, // gravity multiplier
{ ES_FIELD(aiment), NET_WORD, false }, // entity index
{ ES_FIELD(solid), NET_LONG, false }, // encoded mins/maxs
{ ES_FIELD(mins[0]), NET_FLOAT, false },
{ ES_FIELD(mins[1]), NET_FLOAT, false },
{ ES_FIELD(mins[2]), NET_FLOAT, false },
{ ES_FIELD(maxs[0]), NET_FLOAT, false },
{ ES_FIELD(maxs[1]), NET_FLOAT, false },
{ ES_FIELD(maxs[2]), NET_FLOAT, false },
{ ES_FIELD(effects), NET_LONG, false }, // effect flags
{ ES_FIELD(renderfx), NET_LONG, false }, // renderfx flags
{ ES_FIELD(renderamt), NET_COLOR, false }, // alpha amount
{ ES_FIELD(rendercolor[0]), NET_COLOR, false }, // animation blending
{ ES_FIELD(rendercolor[1]), NET_COLOR, false },
{ ES_FIELD(rendercolor[2]), NET_COLOR, false },
{ ES_FIELD(rendermode), NET_BYTE, false }, // render mode (legacy stuff)
{ ES_FIELD(pm_type), NET_BYTE, false }, // 16 player movetypes allowed
{ ES_FIELD(pm_flags), NET_WORD, true }, // 16 movetype flags allowed
{ ES_FIELD(pm_time), NET_BYTE, true }, // each unit 8 msec
{ ES_FIELD(delta_angles[0]), NET_FLOAT, false },
{ ES_FIELD(delta_angles[1]), NET_FLOAT, false },
{ ES_FIELD(delta_angles[2]), NET_FLOAT, false },
{ ES_FIELD(punch_angles[0]), NET_SCALE, false },
{ ES_FIELD(punch_angles[1]), NET_SCALE, false },
{ ES_FIELD(punch_angles[2]), NET_SCALE, false },
{ ES_FIELD(viewangles[0]), NET_FLOAT, false }, // for fixed views
{ ES_FIELD(viewangles[1]), NET_FLOAT, false },
{ ES_FIELD(viewangles[2]), NET_FLOAT, false },
// FIXME: replace with viewoffset
//{ ES_FIELD(viewheight), NET_SHORT, false }, // client viewheight
{ ES_FIELD(viewoffset[0]), NET_SCALE, false }, // get rid of this
{ ES_FIELD(viewoffset[1]), NET_SCALE, false },
{ ES_FIELD(viewoffset[2]), NET_SCALE, false },
{ ES_FIELD(maxspeed), NET_WORD, false }, // send flags (third 4 bytes )
{ ES_FIELD(fov), NET_FLOAT, false }, // client horizontal field of view
{ ES_FIELD(vmodel.index), NET_WORD, false }, // 4096 models
{ ES_FIELD(vmodel.colormap), NET_LONG, false }, // 4096 models
{ ES_FIELD(vmodel.sequence), NET_WORD, false }, // 1024 sequences
{ ES_FIELD(vmodel.frame), NET_FLOAT, false }, // interpolate value
{ ES_FIELD(vmodel.body), NET_BYTE, false }, // 255 bodies
{ ES_FIELD(vmodel.skin), NET_BYTE, false }, // 255 skins
{ ES_FIELD(pmodel.index), NET_WORD, false }, // 4096 models
{ ES_FIELD(pmodel.colormap), NET_LONG, false }, // 4096 models
{ ES_FIELD(pmodel.sequence), NET_WORD, false }, // 1024 sequences
{ ES_FIELD(vmodel.frame), NET_FLOAT, false }, // interpolate value
{ NULL }, // terminator
};
// probably usercmd_t never reached 32 field integer limit (in theory of course)
static net_field_t cmd_fields[] =
{
{ CM_FIELD(msec), NET_BYTE, true },
{ CM_FIELD(angles[0]), NET_WORD, false },
{ CM_FIELD(angles[1]), NET_WORD, false },
{ CM_FIELD(angles[2]), NET_WORD, false },
{ CM_FIELD(forwardmove), NET_SHORT, false },
{ CM_FIELD(sidemove), NET_SHORT, false },
{ CM_FIELD(upmove), NET_SHORT, false },
{ CM_FIELD(buttons), NET_BYTE, false },
{ CM_FIELD(impulse), NET_BYTE, false },
{ CM_FIELD(lightlevel), NET_BYTE, false },
{ NULL },
};
/*
==============================================================================

View File

@ -29,12 +29,16 @@ cvar_t *host_serverstate;
cvar_t *host_frametime;
cvar_t *host_cheats;
cvar_t *host_maxfps;
cvar_t *host_maxclients;
cvar_t *r_fullscreen;
cvar_t *r_xpos; // X coordinate of window position
cvar_t *r_ypos; // Y coordinate of window position
cvar_t *vid_gamma;
cvar_t *cm_paused; // remove this
// these cvars will be duplicated on each client across network
int Host_FrameTime( void ) { return (int)(bound( 1, Cvar_VariableValue( "host_frametime" ) * 1000, 100 )); }
int Host_ServerState( void ) { return (int)Cvar_VariableValue( "host_serverstate" ); }
int Host_MaxClients( void ) { return (int)bound( 1, Cvar_VariableValue( "host_maxclients" ), 255 ); }
/*
=======
@ -210,26 +214,6 @@ void Host_AbortCurrentFrame( void )
longjmp( host.abortframe, 1 );
}
/*
==================
Host_GetFrameTime
==================
*/
float Host_FrameTime( void )
{
return Cvar_VariableValue( "host_frametime" );
}
/*
==================
Host_GetServerState
==================
*/
int Host_ServerState( void )
{
return (int)Cvar_VariableValue( "host_serverstate" );
}
/*
==================
Host_SetServerState
@ -237,7 +221,7 @@ Host_SetServerState
*/
void Host_SetServerState( int state )
{
Cvar_SetValue("host_serverstate", state );
Cvar_SetValue( "host_serverstate", state );
}
/*
@ -740,8 +724,6 @@ void Host_Init( int argc, char **argv)
host.state = HOST_INIT; // initialzation started
host.type = g_Instance;
srand(time(NULL)); // init random generator
Host_InitCommon( argc, argv ); // loading common.dll
Key_Init();
@ -756,7 +738,7 @@ void Host_Init( int argc, char **argv)
Cbuf_Execute();
// init commands and vars
if(host.developer)
if( host.developer )
{
Cmd_AddCommand ("error", Host_Error_f, "just throw a fatal error to test shutdown procedures" );
Cmd_AddCommand ("crash", Host_Crash_f, "a way to force a bus error for development reasons");
@ -764,9 +746,9 @@ void Host_Init( int argc, char **argv)
host_cheats = Cvar_Get("host_cheats", "1", CVAR_SYSTEMINFO, "allow cheat variables to enable" );
host_maxfps = Cvar_Get( "host_maxfps", "100", CVAR_ARCHIVE, "host fps upper limit" );
cm_paused = Cvar_Get("cm_paused", "0", 0, "physics module pause" );
host_frametime = Cvar_Get ("host_frametime", "0.1", 0, "host frametime" );
host_serverstate = Cvar_Get ("host_serverstate", "0", 0, "displays current server state" );
host_frametime = Cvar_Get ("host_frametime", "0.1", CVAR_SERVERINFO, "host frametime" );
host_maxclients = Cvar_Get ("host_maxclients", "1", CVAR_SERVERINFO|CVAR_LATCH, "server maxplayers limit" );
host_serverstate = Cvar_Get ("host_serverstate", "0", CVAR_SERVERINFO, "displays current server state" );
timescale = Cvar_Get ("timescale", "1", 0, "physics world timescale" );
s = va("^1Xash %g ^3%s", GI->version, buildstring );

View File

@ -77,6 +77,7 @@ typedef struct server_s
float time; // always sv.framenum * 50 msec
float frametime;
dword timeleft;
int framenum;
char name[MAX_QPATH]; // map name, or cinematic name
@ -112,9 +113,7 @@ typedef struct sv_client_s
{
cl_state_t state;
entity_state_t ps; // communicated by server to clients
char userinfo[MAX_INFO_STRING]; // name, etc
int lastframe; // for delta compression
usercmd_t lastcmd; // for filling in big drops
usercmd_t cmd; // current user commands
@ -125,6 +124,7 @@ typedef struct sv_client_s
int ping;
int rate;
int surpressCount; // number of messages rate supressed
int sendtime; // time before send next packet
edict_t *edict; // EDICT_NUM(clientnum+1)
char name[32]; // extracted from userinfo, high bits masked
@ -223,8 +223,8 @@ typedef struct
int spawncount; // incremented each server start
// used to check late spawns
sv_client_t *clients; // [maxclients->value]
int num_client_entities; // maxclients->value*UPDATE_BACKUP*MAX_PACKET_ENTITIES
sv_client_t *clients; // [host_maxclients->integer]
int num_client_entities; // host_maxclients->integer*UPDATE_BACKUP
int next_client_entities; // next client_entity to use
entity_state_t *client_entities; // [num_client_entities]
entity_state_t *baselines; // [host.max_edicts]
@ -243,7 +243,6 @@ extern server_static_t svs; // persistant server info
extern server_t sv; // local server
extern cvar_t *sv_paused;
extern cvar_t *maxclients;
extern cvar_t *sv_noreload; // don't reload level state when reentering
extern cvar_t *sv_airaccelerate; // don't reload level state when reentering
extern cvar_t *sv_accelerate;
@ -262,6 +261,7 @@ extern cvar_t *sv_playersonly;
extern cvar_t *sv_rollangle;
extern cvar_t *sv_rollspeed;
extern cvar_t *sv_maxspeed;
extern cvar_t *host_frametime;
extern sv_client_t *sv_client;
@ -384,9 +384,7 @@ void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
void SV_FreeEdict (edict_t *ed);
void SV_InitEdict (edict_t *e);
edict_t *SV_Spawn (void);
void SV_RunFrame (void);
bool SV_ClientConnect (edict_t *ent, char *userinfo);
void ClientThink (edict_t *ent, usercmd_t *ucmd);
void SV_TouchTriggers (edict_t *ent);
//

View File

@ -90,7 +90,7 @@ void SV_DirectConnect( netadr_t from )
userinfo[sizeof(userinfo) - 1] = 0;
// quick reject
for( i = 0, cl = svs.clients; i < maxclients->integer; i++, cl++ )
for( i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++ )
{
if( cl->state == cs_free ) continue;
if( NET_CompareBaseAdr(from, cl->netchan.remote_address) && (cl->netchan.qport == qport || from.port == cl->netchan.remote_address.port))
@ -136,7 +136,7 @@ void SV_DirectConnect( netadr_t from )
memset( newcl, 0, sizeof(sv_client_t));
// if there is already a slot for this ip, reuse it
for( i = 0, cl = svs.clients; i < maxclients->integer; i++, cl++ )
for( i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++ )
{
if( cl->state == cs_free ) continue;
if( NET_CompareBaseAdr(from, cl->netchan.remote_address) && (cl->netchan.qport == qport || from.port == cl->netchan.remote_address.port))
@ -149,7 +149,7 @@ void SV_DirectConnect( netadr_t from )
// find a client slot
newcl = NULL;
for( i = 0, cl = svs.clients; i < maxclients->value; i++, cl++)
for( i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++)
{
if( cl->state == cs_free )
{
@ -203,9 +203,9 @@ gotnewcl:
// if this was the first client on the server, or the last client
// the server can hold, send a heartbeat to the master.
for( i = 0, cl = svs.clients; i < maxclients->integer; i++, cl++ )
for( i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++ )
if( cl->state >= cs_connected ) count++;
if( count == 1 || count == maxclients->integer )
if( count == 1 || count == Host_MaxClients())
svs.last_heartbeat = MAX_HEARTBEAT;
}
@ -223,7 +223,6 @@ bool SV_ClientConnect( edict_t *ent, char *userinfo )
// make sure we start with known default
ent->progs.sv->flags = 0;
ent->progs.sv->health = 100;
MsgDev(D_NOTE, "SV_ClientConnect()\n");
prog->globals.sv->time = sv.time;
@ -266,12 +265,12 @@ void SV_DropClient( sv_client_t *drop )
// to the master so it is known the server is empty
// send a heartbeat now so the master will get up to date info
// if there is already a slot for this ip, reuse it
for( i = 0; i < maxclients->integer; i++ )
for( i = 0; i < Host_MaxClients(); i++ )
{
if( svs.clients[i].state >= cs_connected )
break;
}
if( i == maxclients->integer ) svs.last_heartbeat = MAX_HEARTBEAT;
if( i == Host_MaxClients()) svs.last_heartbeat = MAX_HEARTBEAT;
}
/*
@ -341,9 +340,9 @@ char *SV_StatusString( void )
com.strcpy( status, Cvar_Serverinfo());
com.strcat( status, "\n" );
statusLength = strlen(status);
statusLength = com.strlen(status);
for( i = 0; i < maxclients->value; i++ )
for( i = 0; i < Host_MaxClients(); i++ )
{
cl = &svs.clients[i];
if( cl->state == cs_connected || cl->state == cs_spawned )
@ -397,8 +396,7 @@ void SV_Info( netadr_t from )
int version;
// ignore in single player
if( maxclients->value == 1 )
return;
if(Host_MaxClients() == 1 ) return;
version = com.atoi(Cmd_Argv( 1 ));
@ -406,10 +404,10 @@ void SV_Info( netadr_t from )
com.sprintf( string, "%s: wrong version\n", hostname->string, sizeof(string));
else
{
for( i = 0; i < maxclients->value; i++ )
for( i = 0; i < Host_MaxClients(); i++ )
if( svs.clients[i].state >= cs_connected )
count++;
com.sprintf( string, "%16s %8s %2i/%2i\n", hostname->string, sv.name, count, (int)maxclients->value );
com.sprintf( string, "%16s %8s %2i/%2i\n", hostname->string, sv.name, count, Host_MaxClients());
}
Netchan_OutOfBandPrint( NS_SERVER, from, "info\n%s", string );
}
@ -490,6 +488,7 @@ void SV_PutClientInServer( edict_t *ent )
ent->priv.sv->free = false;
(int)ent->progs.sv->flags &= ~FL_DEADMONSTER;
ent->priv.sv->s.ed_type = ED_CLIENT; // init edict type
if( !sv.loadgame )
{
@ -499,17 +498,15 @@ void SV_PutClientInServer( edict_t *ent )
ent->progs.sv->origin[2] += 1; // make sure off ground
VectorCopy( ent->progs.sv->origin, ent->progs.sv->old_origin );
}
// setup playerstate
memset( &client->ps, 0, sizeof(client->ps));
client->ps.fov = 90;
client->ps.fov = bound(1, client->ps.fov, 160);
client->ps.vmodel.index = SV_ModelIndex(PRVM_GetString(ent->progs.sv->v_model));
client->ps.pmodel.index = SV_ModelIndex(PRVM_GetString(ent->progs.sv->p_model));
VectorScale( ent->progs.sv->origin, SV_COORD_FRAC, client->ps.origin );
VectorCopy( ent->progs.sv->v_angle, client->ps.viewangles );
for( i = 0; i < 3; i++ ) client->ps.delta_angles[i] = ANGLE2SHORT(ent->progs.sv->v_angle[i]);
ent->priv.sv->s.fov = 90; // FIXME: get from qc
ent->priv.sv->s.fov = bound(1, ent->priv.sv->s.fov, 160);
ent->priv.sv->s.health = ent->progs.sv->health;
ent->priv.sv->s.vmodel.index = SV_ModelIndex(PRVM_GetString(ent->progs.sv->v_model));
ent->priv.sv->s.pmodel.index = SV_ModelIndex(PRVM_GetString(ent->progs.sv->p_model));
VectorCopy( ent->progs.sv->origin, ent->priv.sv->s.origin );
VectorCopy( ent->progs.sv->v_angle, ent->priv.sv->s.viewangles );
for( i = 0; i < 3; i++ ) ent->priv.sv->s.delta_angles[i] = ANGLE2SHORT(ent->progs.sv->v_angle[i]);
SV_LinkEdict( ent ); // m_pmatrix calculated here, so we need call this before pe->CreatePlayer
ent->priv.sv->physbody = pe->CreatePlayer( ent->priv.sv, SV_GetModelPtr( ent ), ent->progs.sv->m_pmatrix );
@ -857,7 +854,7 @@ void SV_ExecuteClientCommand( sv_client_t *cl, char *s )
{
if(!com.strcmp(Cmd_Argv(0), u->name))
{
Msg("ucmd->%s\n", u->name );
MsgDev( D_NOTE, "ucmd->%s()\n", u->name );
u->func( cl );
break;
}
@ -903,7 +900,7 @@ void _MSG_Send( msgtype_t msg_type, vec3_t origin, edict_t *ent, const char *fil
byte *mask = NULL;
int leafnum = 0, cluster = 0;
int area1 = 0, area2 = 0;
int j, numclients = maxclients->value;
int j, numclients = Host_MaxClients();
sv_client_t *cl, *current = svs.clients;
bool reliable = false;
@ -1012,29 +1009,31 @@ void SV_ApplyClientMove( sv_client_t *cl, usercmd_t *cmd )
{
short temp;
int i;
edict_t *ent = cl->edict;
// set the edict fields
cl->edict->progs.sv->button0 = cmd->buttons & 1;
cl->edict->progs.sv->button2 = (cmd->buttons & 2)>>1;
if( cmd->impulse ) cl->edict->progs.sv->impulse = cmd->impulse;
ent->progs.sv->button0 = cmd->buttons & 1;
ent->progs.sv->button2 = (cmd->buttons & 2)>>1;
if( cmd->impulse ) ent->progs.sv->impulse = cmd->impulse;
// only send the impulse to qc once
cmd->impulse = 0;
// circularly clamp the angles with deltas
for( i = 0; i < 3; i++ )
{
temp = cmd->angles[i] + cl->ps.delta_angles[i];
cl->ps.viewangles[i] = SHORT2ANGLE( temp );
temp = cmd->angles[i] + ent->priv.sv->s.delta_angles[i];
ent->priv.sv->s.viewangles[i] = SHORT2ANGLE( temp );
}
// don't let the player look up or down more than 90 degrees
if( cl->ps.viewangles[PITCH] > 89 && cl->ps.viewangles[PITCH] < 180 )
cl->ps.viewangles[PITCH] = 89;
else if( cl->ps.viewangles[PITCH] < 271 && cl->ps.viewangles[PITCH] >= 180 )
cl->ps.viewangles[PITCH] = 271;
if( ent->priv.sv->s.viewangles[PITCH] > 89 && ent->priv.sv->s.viewangles[PITCH] < 180 )
ent->priv.sv->s.viewangles[PITCH] = 89;
else if( ent->priv.sv->s.viewangles[PITCH] < 271 && ent->priv.sv->s.viewangles[PITCH] >= 180 )
ent->priv.sv->s.viewangles[PITCH] = 271;
VectorCopy( cl->ps.viewangles, cl->edict->progs.sv->v_angle );
VectorCopy( cl->ps.viewangles, cl->edict->progs.sv->angles );
VectorCopy( ent->priv.sv->s.viewangles, cl->edict->progs.sv->v_angle );
VectorCopy( ent->priv.sv->s.viewangles, cl->edict->progs.sv->angles );
VectorCopy( ent->progs.sv->view_ofs, cl->edict->priv.sv->s.viewoffset );
}
void SV_DropPunchAngle( sv_client_t *cl )
@ -1281,8 +1280,8 @@ void SV_ClientThink( sv_client_t *cl, usercmd_t *cmd )
vec3_t v_angle;
cl->cmd = *cmd;
cl->skipframes = 0;
#if 1
//cl->skipframes = 0;
// may have been kicked during the last usercmd
if( sv_paused->integer ) return;
@ -1338,11 +1337,8 @@ void SV_ClientThink( sv_client_t *cl, usercmd_t *cmd )
SV_AirMove( cl, &cl->cmd );
SV_CheckVelocity( cl->edict );
VectorCopy( cl->edict->progs.sv->origin, cl->ps.origin );
VectorCopy( cl->edict->progs.sv->velocity, cl->ps.velocity );
#else
ClientThink( cl->edict, cmd );
#endif
VectorCopy( cl->edict->progs.sv->origin, cl->edict->priv.sv->s.origin );
VectorCopy( cl->edict->progs.sv->velocity, cl->edict->priv.sv->s.velocity );
}
/*
@ -1364,6 +1360,7 @@ static void SV_UserMove( sv_client_t *cl, sizebuf_t *msg )
int latency, net_drop;
int checksumIndex, lastframe;
int checksum, calculatedChecksum;
float frametime[2];
checksumIndex = msg->readcount;
checksum = MSG_ReadByte( msg );
@ -1399,6 +1396,10 @@ static void SV_UserMove( sv_client_t *cl, sizebuf_t *msg )
if( !sv_paused->value )
{
frametime[0] = sv.frametime;
frametime[1] = prog->globals.sv->frametime;
prog->globals.sv->frametime = sv.frametime = newcmd.msec * 0.001f;
net_drop = cl->netchan.dropped;
if( net_drop < 20 )
{
@ -1412,6 +1413,8 @@ static void SV_UserMove( sv_client_t *cl, sizebuf_t *msg )
}
SV_Physics_ClientMove( cl, &newcmd );
}
sv.frametime = frametime[0];
prog->globals.sv->frametime = frametime[1];
cl->lastcmd = newcmd;
}

View File

@ -52,10 +52,8 @@ void SV_BroadcastPrintf( int level, char *fmt, ... )
va_end( argptr );
// echo to console
if( host.type == HOST_DEDICATED )
Msg( "%s", string );
for( i = 0, cl = svs.clients; i < maxclients->value; i++, cl++ )
if( host.type == HOST_DEDICATED ) Msg( "%s", string );
for( i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++ )
{
if( level < cl->messagelevel) continue;
if( cl->state != cs_spawned ) continue;
@ -108,25 +106,25 @@ void SV_SetMaster_f( void )
// make sure the server is listed public
Cvar_Set ("public", "1");
for (i = 1; i < MAX_MASTERS; i++)
for( i = 1; i < MAX_MASTERS; i++ )
{
memset(&master_adr[i], 0, sizeof(master_adr[i]));
}
// slot 0 will always contain the id master
for (i = 1, slot = 1; i < Cmd_Argc(); i++)
for( i = 1, slot = 1; i < Cmd_Argc(); i++ )
{
if (slot == MAX_MASTERS) break;
if (!NET_StringToAdr (Cmd_Argv(i), &master_adr[i]))
if( slot == MAX_MASTERS ) break;
if(!NET_StringToAdr(Cmd_Argv(i), &master_adr[i]))
{
Msg ("Bad address: %s\n", Cmd_Argv(i));
Msg( "Bad address: %s\n", Cmd_Argv(i));
continue;
}
if(!master_adr[slot].port) master_adr[slot].port = BigShort (PORT_MASTER);
Msg ("Master server at %s\n", NET_AdrToString (master_adr[slot]));
Msg ("Sending a ping.\n");
Netchan_OutOfBandPrint (NS_SERVER, master_adr[slot], "ping");
Msg( "Master server at %s\n", NET_AdrToString (master_adr[slot]));
Msg( "Sending a ping.\n");
Netchan_OutOfBandPrint( NS_SERVER, master_adr[slot], "ping" );
slot++;
}
svs.last_heartbeat = MAX_HEARTBEAT;
@ -150,16 +148,16 @@ bool SV_SetPlayer( void )
s = Cmd_Argv(1);
// numeric values are just slot numbers
if (s[0] >= '0' && s[0] <= '9')
if( s[0] >= '0' && s[0] <= '9' )
{
idnum = atoi(Cmd_Argv(1));
if (idnum < 0 || idnum >= maxclients->integer)
idnum = com.atoi(Cmd_Argv(1));
if( idnum < 0 || idnum >= Host_MaxClients())
{
Msg("Bad client slot: %i\n", idnum);
return false;
}
sv_client = &svs.clients[idnum];
if (!sv_client->state)
if( !sv_client->state )
{
Msg("Client %i is not active\n", idnum);
return false;
@ -168,16 +166,16 @@ bool SV_SetPlayer( void )
}
// check for a name match
for (i = 0, cl = svs.clients; i < maxclients->integer; i++, cl++)
for( i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++ )
{
if (!cl->state) continue;
if (!strcmp(cl->name, s))
if( !cl->state ) continue;
if( !com.strcmp(cl->name, s))
{
sv_client = cl;
return true;
}
}
Msg ("Userid %s is not on the server\n", s);
Msg( "Userid %s is not on the server\n", s );
return false;
}
@ -193,7 +191,7 @@ void SV_Map_f( void )
{
char filename[MAX_QPATH];
if(Cmd_Argc() != 2)
if( Cmd_Argc() != 2 )
{
Msg("Usage: map <filename>\n");
return;
@ -208,13 +206,13 @@ void SV_Map_f( void )
SV_InitGame(); // reset previous state
SV_BroadcastCommand("changing\n");
SV_BroadcastCommand( "changing\n" );
SV_SendClientMessages();
SV_SpawnServer( filename, NULL, ss_active );
SV_BroadcastCommand ("reconnect\n");
SV_BroadcastCommand( "reconnect\n" );
// archive server state
com.strncpy (svs.mapcmd, filename, sizeof(svs.mapcmd) - 1);
com.strncpy( svs.mapcmd, filename, sizeof(svs.mapcmd) - 1);
}
/*
@ -337,15 +335,15 @@ void SV_ChangeLevel_f( void )
// clear all the client free flags before saving so that
// when the level is re-entered, the clients will spawn
// at spawn points instead of occupying body shells
savedFree = Z_Malloc(maxclients->integer * sizeof(bool));
for (i = 0, cl = svs.clients; i < maxclients->integer; i++, cl++)
savedFree = Z_Malloc(Host_MaxClients() * sizeof(bool));
for (i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++)
{
savedFree[i] = cl->edict->priv.sv->free;
cl->edict->priv.sv->free = true;
}
SV_WriteSaveFile( "save0.bin" ); // autosave
// we must restore these for clients to transfer over correctly
for (i = 0, cl = svs.clients; i < maxclients->integer; i++, cl++)
for (i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++)
cl->edict->priv.sv->free = savedFree[i];
Mem_Free(savedFree);
}
@ -373,7 +371,7 @@ void SV_Restart_f( void )
if(sv.state != ss_active) return;
strncpy( filename, svs.mapcmd, MAX_QPATH );
com.strncpy( filename, svs.mapcmd, MAX_QPATH );
FS_StripExtension( filename );
// just sending console command
@ -402,33 +400,12 @@ void SV_Kick_f( void )
}
if(!SV_SetPlayer()) return;
SV_BroadcastPrintf (PRINT_CONSOLE, "%s was kicked\n", sv_client->name);
SV_BroadcastPrintf( PRINT_CONSOLE, "%s was kicked\n", sv_client->name );
SV_ClientPrintf(sv_client, PRINT_CONSOLE, "You were kicked from the game\n");
SV_DropClient(sv_client);
sv_client->lastmessage = svs.realtime; // min case there is a funny zombie
}
void SV_Noclip_f( void )
{
sv_client_t *cl;
if( maxclients->integer != 1 ) return;
cl = svs.clients; // use first client
if( !cl->state ) return;
if( cl->edict->progs.sv->movetype == MOVETYPE_WALK )
{
Msg("noclip on\n" );
cl->edict->progs.sv->movetype = MOVETYPE_NOCLIP;
}
else
{
Msg("noclip off\n" );
cl->edict->progs.sv->movetype = MOVETYPE_WALK;
}
}
/*
================
SV_Status_f
@ -449,7 +426,7 @@ void SV_Status_f( void )
Msg("num score ping name lastmsg address port \n");
Msg("--- ----- ------- --------------- ------- --------------------- ------\n");
for(i = 0, cl = svs.clients; i < maxclients->integer; i++, cl++)
for(i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++)
{
int j, l, ping;
char *s;
@ -473,7 +450,7 @@ void SV_Status_f( void )
Msg ("%9i ", svs.realtime - cl->lastmessage );
s = NET_AdrToString ( cl->netchan.remote_address);
Msg ("%s", s);
l = 22 - strlen(s);
l = 22 - com.strlen(s);
for (j = 0; j < l; j++) Msg (" ");
Msg("%5i", cl->netchan.qport);
Msg("\n");
@ -494,7 +471,7 @@ void SV_ConSay_f( void )
if(Cmd_Argc() < 2) return;
strncpy(text, "console: ", MAX_SYSPATH );
com.strncpy(text, "console: ", MAX_SYSPATH );
p = Cmd_Args();
if(*p == '"')
@ -504,10 +481,10 @@ void SV_ConSay_f( void )
}
com.strncat(text, p, MAX_SYSPATH );
for (i = 0, client = svs.clients; i < maxclients->integer; i++, client++)
for (i = 0, client = svs.clients; i < Host_MaxClients(); i++, client++)
{
if (client->state != cs_spawned) continue;
SV_ClientPrintf(client, PRINT_CHAT, "%s\n", text );
if( client->state != cs_spawned ) continue;
SV_ClientPrintf( client, PRINT_CHAT, "%s\n", text );
}
}
@ -590,11 +567,6 @@ void SV_InitOperatorCommands( void )
Cmd_AddCommand("restart", SV_Restart_f, "restarting current level" );
Cmd_AddCommand("sectorlist", SV_SectorList_f, "display pvs sectors" );
if( host_cheats->integer )
{
Cmd_AddCommand("noclip", SV_Noclip_f, "enable player noclip" );
}
if( host.type == HOST_DEDICATED )
{
Cmd_AddCommand ("say", SV_ConSay_f, "send a chat message to everyone on the server" );

View File

@ -72,14 +72,6 @@ void SV_UpdateEntityState( edict_t *ent )
VectorCopy (ent->progs.sv->old_origin, ent->priv.sv->s.old_origin);
ent->priv.sv->s.model.index = (int)ent->progs.sv->modelindex;
ent->priv.sv->s.health = ent->progs.sv->health;
if( ent->priv.sv->client )
{
// attached weaponmodel
// FIXME: let any entity send weaponmodel
ent->priv.sv->s.pmodel.index = ent->priv.sv->client->ps.pmodel.index;
}
ent->priv.sv->s.model.skin = (short)ent->progs.sv->skin; // studio model skin
ent->priv.sv->s.model.body = (byte)ent->progs.sv->body; // studio model submodel
ent->priv.sv->s.model.frame = ent->progs.sv->frame; // any model current frame
@ -88,6 +80,12 @@ void SV_UpdateEntityState( edict_t *ent )
ent->priv.sv->s.renderfx = (int)ent->progs.sv->renderfx; // renderer flags
ent->priv.sv->s.renderamt = ent->progs.sv->alpha; // alpha value
ent->priv.sv->s.model.animtime = ent->progs.sv->animtime; // auto-animating time
// copy viewmodel info
ent->priv.sv->s.vmodel.frame = ent->progs.sv->v_frame;
ent->priv.sv->s.vmodel.body = ent->progs.sv->v_body;
ent->priv.sv->s.vmodel.skin = ent->progs.sv->v_skin;
ent->priv.sv->s.vmodel.sequence = ent->progs.sv->v_sequence;
}
/*
@ -141,7 +139,7 @@ void SV_EmitPacketEntities( client_frame_t *from, client_frame_t *to, sizebuf_t
// in any bytes being emited if the entity has not changed at all
// note that players are always 'newentities', this updates their oldorigin always
// and prevents warping
MSG_WriteDeltaEntity( oldent, newent, msg, false, newent->number <= maxclients->value );
MSG_WriteDeltaEntity( oldent, newent, msg, false, newent->number <= Host_MaxClients());
oldindex++;
newindex++;
continue;
@ -252,8 +250,8 @@ void SV_BuildClientFrame( sv_client_t *cl )
frame->msg_sent = svs.realtime; // save it for ping calc later
// find the client's PVS
VectorScale( clent->priv.sv->client->ps.origin, CL_COORD_FRAC, org );
VectorAdd( org, clent->priv.sv->client->ps.viewoffset, org );
VectorCopy( clent->priv.sv->s.origin, org );
VectorAdd( org, clent->priv.sv->s.viewoffset, org );
// calculate fat pvs
if( sv_fatpvs->integer ) SV_FatPVS( org );
@ -266,7 +264,7 @@ void SV_BuildClientFrame( sv_client_t *cl )
frame->areabytes = pe->WriteAreaBits( frame->areabits, clientarea );
// grab the current player state
frame->ps = clent->priv.sv->client->ps;
frame->ps = clent->priv.sv->s;
clientpvs = pe->ClusterPVS( clientcluster );
clientphs = pe->ClusterPHS( clientcluster );
@ -460,7 +458,7 @@ void SV_SendClientMessages( void )
int i;
// send a message to each connected client
for( i = 0, cl = svs.clients; i < maxclients->value; i++, cl++ )
for( i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++ )
{
if( !cl->state ) continue;

View File

@ -48,7 +48,7 @@ int SV_FindIndex (const char *name, int start, int end, bool create)
}
// register new resource
strncpy (sv.configstrings[start+i], name, sizeof(sv.configstrings[i]));
com.strncpy (sv.configstrings[start+i], name, sizeof(sv.configstrings[i]));
if (sv.state != ss_loading)
{
@ -157,9 +157,10 @@ void SV_SpawnServer( char *server, char *savename, sv_state_t serverstate )
// wipe the entire per-level structure
memset (&sv, 0, sizeof(sv));
svs.realtime = 0;
sv.timeleft = 0;
// save name for levels that don't set message
strcpy (sv.configstrings[CS_NAME], server);
com.strcpy (sv.configstrings[CS_NAME], server);
if( Cvar_VariableValue ("deathmatch") )
com.sprintf( sv.configstrings[CS_AIRACCEL], "%g", sv_airaccelerate->value );
else com.strcpy( sv.configstrings[CS_AIRACCEL], "0" );
@ -170,7 +171,7 @@ void SV_SpawnServer( char *server, char *savename, sv_state_t serverstate )
SV_VM_Begin();
// leave slots at start for clients only
for (i = 0; i < maxclients->value; i++)
for (i = 0; i < Host_MaxClients(); i++)
{
// needs to reconnect
if (svs.clients[i].state > cs_connected)
@ -180,7 +181,7 @@ void SV_SpawnServer( char *server, char *savename, sv_state_t serverstate )
sv.time = 1.0f;
strcpy(sv.name, server);
com.strcpy(sv.name, server);
FS_FileBase(server, sv.configstrings[CS_NAME]);
if (serverstate != ss_active)
@ -223,8 +224,11 @@ void SV_SpawnServer( char *server, char *savename, sv_state_t serverstate )
}
// run two frames to allow everything to settle
SV_RunFrame();
SV_RunFrame();
for( i = 0; i < 2; i++ )
{
sv.frametime = 0.1f;
SV_Physics();
}
// all precaches are complete
sv.state = serverstate;
@ -275,31 +279,32 @@ void SV_InitGame( void )
// so unless they explicity set coop, force it to deathmatch
if( host.type == HOST_DEDICATED )
{
if (!Cvar_VariableValue ("coop"))
Cvar_FullSet ("deathmatch", "1", CVAR_SERVERINFO | CVAR_LATCH);
if(!Cvar_VariableValue( "coop" ))
Cvar_FullSet( "deathmatch", "1", CVAR_SERVERINFO|CVAR_LATCH );
}
// init clients
if (Cvar_VariableValue ("deathmatch"))
if( Cvar_VariableValue( "deathmatch" ))
{
if (maxclients->value <= 1)
Cvar_FullSet ("maxclients", "8", CVAR_SERVERINFO | CVAR_LATCH);
else if (maxclients->value > MAX_CLIENTS)
Cvar_FullSet ("maxclients", va("%i", MAX_CLIENTS), CVAR_SERVERINFO | CVAR_LATCH);
if(Host_MaxClients() <= 1)
Cvar_FullSet( "host_maxclients", "8", CVAR_SERVERINFO|CVAR_LATCH );
else if(Host_MaxClients() > MAX_CLIENTS )
Cvar_FullSet( "host_maxclients", va("%i", MAX_CLIENTS), CVAR_SERVERINFO|CVAR_LATCH );
}
else if (Cvar_VariableValue ("coop"))
else if( Cvar_VariableValue( "coop" ))
{
if (maxclients->value <= 1 || maxclients->value > 4)
Cvar_FullSet ("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH);
if( Host_MaxClients() <= 1 || Host_MaxClients() > 4 )
Cvar_FullSet( "host_maxclients", "4", CVAR_SERVERINFO|CVAR_LATCH );
}
else // non-deathmatch, non-coop is one player
else
{
Cvar_FullSet ("maxclients", "1", CVAR_SERVERINFO | CVAR_LATCH);
// non-deathmatch, non-coop is one player
Cvar_FullSet( "host_maxclients", "1", CVAR_SERVERINFO|CVAR_LATCH );
}
svs.spawncount = RANDOM_LONG( 0, 65535 );
svs.clients = Z_Malloc (sizeof(sv_client_t)*maxclients->value);
svs.num_client_entities = maxclients->value * UPDATE_BACKUP * 64;
svs.clients = Z_Malloc( sizeof(sv_client_t) * Host_MaxClients());
svs.num_client_entities = Host_MaxClients() * UPDATE_BACKUP;// * 64; g-cont: what a mem waster ???????
svs.client_entities = Z_Malloc( sizeof(entity_state_t) * svs.num_client_entities );
svs.baselines = Z_Malloc( sizeof(entity_state_t) * host.max_edicts );
@ -313,7 +318,7 @@ void SV_InitGame( void )
SV_VM_Begin();
for (i = 0; i < maxclients->value; i++)
for (i = 0; i < Host_MaxClients(); i++)
{
ent = PRVM_EDICT_NUM(i + 1);
ent->priv.sv->serialnumber = i + 1;

View File

@ -29,9 +29,6 @@ cvar_t *sv_rollspeed;
cvar_t *sv_maxspeed;
cvar_t *sv_accelerate;
cvar_t *sv_friction;
cvar_t *maxclients; // FIXME: rename sv_maxclients
cvar_t *hostname;
cvar_t *public_server; // should heartbeats be sent
@ -50,25 +47,17 @@ Updates the cl->ping variables
*/
void SV_CalcPings (void)
{
int i, j;
int i, j;
sv_client_t *cl;
int total, count;
int total, count;
for (i=0 ; i<maxclients->value ; i++)
// clamp fps counter
for( i = 0; i < Host_MaxClients(); i++ )
{
cl = &svs.clients[i];
if (cl->state != cs_spawned )
continue;
if( cl->state != cs_spawned ) continue;
#if 0
if (cl->lastframe > 0)
cl->frame_latency[sv.framenum&(LATENCY_COUNTS-1)] = sv.framenum - cl->lastframe + 1;
else
cl->frame_latency[sv.framenum&(LATENCY_COUNTS-1)] = 0;
#endif
total = 0;
count = 0;
total = count = 0;
for( j = 0; j < UPDATE_BACKUP; j++ )
{
if( cl->frames[j].latency > 0 )
@ -115,7 +104,7 @@ void SV_PacketEvent( netadr_t from, sizebuf_t *msg )
qport = (int)MSG_ReadShort( msg ) & 0xffff;
// check for packets from connected clients
for( i = 0, cl = svs.clients; i < maxclients->value; i++, cl++ )
for( i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++ )
{
if( cl->state == cs_free ) continue;
if( !NET_CompareBaseAdr( from, cl->netchan.remote_address )) continue;
@ -136,11 +125,11 @@ void SV_PacketEvent( netadr_t from, sizebuf_t *msg )
}
break;
}
if( i != maxclients->integer ) return;
if( i != Host_MaxClients()) return;
// if we received a sequenced packet from an address we don't recognize,
// send an out of band disconnect packet to it
//Netchan_OutOfBandPrint( NS_SERVER, from, "disconnect\n" );
Netchan_OutOfBandPrint( NS_SERVER, from, "disconnect\n" );
SV_VM_End();
}
@ -167,7 +156,10 @@ void SV_CheckTimeouts( void )
droppoint = svs.realtime - 1000 * timeout->value;
zombiepoint = svs.realtime - 1000 * zombietime->value;
for( i = 0, cl = svs.clients; i < maxclients->value; i++, cl++ )
if( host_frametime->modified )
Cvar_SetValue( "host_frametime", bound( 0.001f, host_frametime->value, 0.1f ));
for( i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++ )
{
// message times may be wrong across a changelevel
if( cl->lastmessage > svs.realtime )
@ -187,6 +179,7 @@ void SV_CheckTimeouts( void )
}
}
/*
=================
SV_RunGameFrame
@ -194,7 +187,7 @@ SV_RunGameFrame
*/
void SV_RunGameFrame (void)
{
if( sv_paused->integer && maxclients->integer == 1 )
if( sv_paused->integer && Host_MaxClients() == 1 )
return;
// we always need to bump framenum, even if we
@ -202,8 +195,8 @@ void SV_RunGameFrame (void)
// compression can get confused when a client
// has the "current" frame
sv.framenum++;
sv.frametime = HOST_FRAMETIME * 0.001f;
sv.time = sv.framenum * sv.frametime;
sv.frametime = Host_FrameTime() * 0.001f;
//sv.time = sv.framenum * sv.frametime;
SV_Physics();
@ -236,14 +229,16 @@ void SV_Frame( dword time )
// check timeouts
SV_CheckTimeouts ();
if( !sv_playersonly->integer ) pe->Frame( sv.frametime );
// move autonomous things around if enough time has passed
if( svs.realtime < (sv.time * 1000))
{
// never let the time get too far off
if((sv.time * 1000) - svs.realtime > HOST_FRAMETIME )
if((sv.time * 1000) - svs.realtime > Host_FrameTime())
{
Msg ("sv lowclamp\n");
svs.realtime = (sv.time * 1000 ) - HOST_FRAMETIME;
svs.realtime = (sv.time * 1000 ) - Host_FrameTime();
}
NET_Sleep((sv.time*1000) - svs.realtime);
@ -365,10 +360,9 @@ void SV_Init (void)
Cvar_Get ("timelimit", "0", CVAR_SERVERINFO, "multiplayer timelimit" );
Cvar_Get ("protocol", va("%i", PROTOCOL_VERSION), CVAR_SERVERINFO|CVAR_INIT, "displays server protocol version" );
sv_fps = Cvar_Get( "sv_fps", "60", CVAR_ARCHIVE|CVAR_LATCH, "running server at" );
sv_fps = Cvar_Get( "sv_fps", "60", CVAR_ARCHIVE, "running server at" );
sv_stepheight = Cvar_Get( "sv_stepheight", "18", CVAR_ARCHIVE|CVAR_LATCH, "how high you can step up" );
sv_playersonly = Cvar_Get( "playersonly", "0", 0, "freezes time, except for players" );
maxclients = Cvar_Get ("maxclients", "1", CVAR_SERVERINFO | CVAR_LATCH, "max count of clients for current game" );
hostname = Cvar_Get ("hostname", "unnamed", CVAR_SERVERINFO | CVAR_ARCHIVE, "host name" );
timeout = Cvar_Get ("timeout", "125", 0, "connection timeout" );
zombietime = Cvar_Get ("zombietime", "2", 0, "timeout for clients-zombie (who died but not respawned)" );
@ -423,11 +417,11 @@ void SV_FinalMessage (char *message, bool reconnect)
// send it twice
// stagger the packets to crutch operating system limited buffers
for( i = 0, cl = svs.clients; i < maxclients->value; i++, cl++ )
for( i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++ )
if( cl->state >= cs_connected )
Netchan_Transmit( &cl->netchan, msg.cursize, msg.data );
for( i = 0, cl = svs.clients; i < maxclients->value; i++, cl++ )
for( i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++ )
if( cl->state >= cs_connected )
Netchan_Transmit( &cl->netchan, msg.cursize, msg.data );
}

View File

@ -446,15 +446,15 @@ void SV_PlayerMove( sv_edict_t *ed )
memset( &pm, 0, sizeof(pm) );
if( player->progs.sv->movetype == MOVETYPE_NOCLIP )
client->ps.pm_type = PM_SPECTATOR;
else client->ps.pm_type = PM_NORMAL;
client->ps.gravity = sv_gravity->value;
player->priv.sv->s.pm_type = PM_SPECTATOR;
else player->priv.sv->s.pm_type = PM_NORMAL;
player->priv.sv->s.gravity = sv_gravity->value;
if( player->progs.sv->teleport_time )
client->ps.pm_flags |= PMF_TIME_TELEPORT;
else client->ps.pm_flags &= ~PMF_TIME_TELEPORT;
player->priv.sv->s.pm_flags |= PMF_TIME_TELEPORT;
else player->priv.sv->s.pm_flags &= ~PMF_TIME_TELEPORT;
pm.ps = client->ps;
pm.ps = player->priv.sv->s;
pm.cmd = client->lastcmd;
pm.body = ed->physbody; // member body ptr
@ -464,13 +464,13 @@ void SV_PlayerMove( sv_edict_t *ed )
pe->PlayerMove( &pm, false ); // server move
// save results of pmove
client->ps = pm.ps;
player->priv.sv->s = pm.ps;
VectorCopy(pm.ps.origin, player->progs.sv->origin);
VectorCopy(pm.ps.velocity, player->progs.sv->velocity);
VectorCopy(pm.mins, player->progs.sv->mins);
VectorCopy(pm.maxs, player->progs.sv->maxs);
VectorCopy(pm.ps.viewangles, client->ps.viewangles);
VectorCopy(pm.ps.viewangles, player->priv.sv->s.viewangles );
}
void SV_PlaySound( sv_edict_t *ed, float volume, const char *sample )

View File

@ -115,7 +115,7 @@ trace_t SV_Trace( const vec3_t start, const vec3_t mins, const vec3_t maxs, cons
traceowner = passedict ? PRVM_PROG_TO_EDICT(passedict->progs.sv->owner) : 0;
// clip to entities
// because this uses World_EntitiestoBox, we know all entity boxes overlap
// because this uses SV_AreaEdicts, we know all entity boxes overlap
// the clip region, so we can skip culling checks in the loop below
numtouchedicts = SV_AreaEdicts( clipboxmins, clipboxmaxs, touchedicts, host.max_edicts );
if( numtouchedicts > host.max_edicts )
@ -378,6 +378,42 @@ void SV_Impact( edict_t *e1, trace_t *trace )
PRVM_POP_GLOBALS;
}
/*
============
SV_TouchTriggers
called by player or monster
============
*/
void SV_TouchTriggers( edict_t *ent )
{
int i, num;
edict_t *touch[MAX_EDICTS];
// dead things don't activate triggers!
if(!((int)ent->progs.sv->flags & FL_CLIENT) && (ent->progs.sv->health <= 0))
return;
num = SV_AreaEdicts( ent->progs.sv->absmin, ent->progs.sv->absmax, touch, host.max_edicts );
PRVM_PUSH_GLOBALS;
// be careful, it is possible to have an entity in this
// list removed before we get to it (killtriggered)
for( i = 0; i < num; i++ )
{
if( touch[i]->priv.sv->free ) continue;
prog->globals.sv->pev = PRVM_EDICT_TO_PROG(touch[i]);
prog->globals.sv->other = PRVM_EDICT_TO_PROG(ent);
prog->globals.sv->time = sv.time;
if(touch[i]->progs.sv->touch)
PRVM_ExecuteProgram( touch[i]->progs.sv->touch, "pev->touch");
}
// restore state
PRVM_POP_GLOBALS;
}
/*
============
SV_ClampMove
@ -386,18 +422,11 @@ clamp the move to 1/8 units, so the position will
be accurate for client side prediction
============
*/
void SV_ClampCoord( vec3_t coord )
{
coord[0] -= SV_COORD_FRAC * floor(coord[0] * CL_COORD_FRAC);
coord[1] -= SV_COORD_FRAC * floor(coord[1] * CL_COORD_FRAC);
coord[2] -= SV_COORD_FRAC * floor(coord[2] * CL_COORD_FRAC);
}
void SV_ClampAngle( vec3_t angle )
{
angle[0] -= SV_ANGLE_FRAC * floor(angle[0] * CL_ANGLE_FRAC);
angle[1] -= SV_ANGLE_FRAC * floor(angle[1] * CL_ANGLE_FRAC);
angle[2] -= SV_ANGLE_FRAC * floor(angle[2] * CL_ANGLE_FRAC);
angle[0] -= 360.0 * floor(angle[0] * (1.0 / 360.0));
angle[1] -= 360.0 * floor(angle[1] * (1.0 / 360.0));
angle[2] -= 360.0 * floor(angle[2] * (1.0 / 360.0));
}
/*
@ -478,7 +507,7 @@ int SV_FlyMove( edict_t *ent, float time, float *stepnormal, int contentsmask )
{
// floor
blocked |= 1;
ent->progs.sv->aiflags = (int)ent->progs.sv->flags | AI_ONGROUND;
ent->progs.sv->aiflags = (int)ent->progs.sv->aiflags | AI_ONGROUND;
ent->progs.sv->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
}
}
@ -568,6 +597,7 @@ int SV_FlyMove( edict_t *ent, float time, float *stepnormal, int contentsmask )
// this came from QW and allows you to get out of water more easily
if(((int)ent->progs.sv->aiflags & AI_WATERJUMP))
VectorCopy( primal_velocity, ent->progs.sv->velocity );
return blocked;
}
@ -579,7 +609,9 @@ SV_AddGravity
*/
void SV_AddGravity( edict_t *ent )
{
ent->progs.sv->velocity[2] -= ent->progs.sv->gravity * sv_gravity->value * sv.frametime;
if( ent->progs.sv->gravity )
ent->progs.sv->velocity[2] -= ent->progs.sv->gravity * sv.frametime;
else ent->progs.sv->velocity[2] -= sv_gravity->value * sv.frametime;
}
/*
@ -950,7 +982,7 @@ void SV_CheckStuck( edict_t *ent )
{
if(!SV_TestEntityPosition( ent, unstickoffsets + i))
{
MsgDev( D_INFO, "Unstuck player with offset %g %g %g.\n", unstickoffsets[i+0], unstickoffsets[i+1], unstickoffsets[i+2]);
MsgDev( D_NOTE, "Unstuck player with offset %g %g %g.\n", unstickoffsets[i+0], unstickoffsets[i+1], unstickoffsets[i+2]);
SV_LinkEdict( ent );
return;
}
@ -959,11 +991,11 @@ void SV_CheckStuck( edict_t *ent )
VectorSubtract( ent->progs.sv->old_origin, ent->progs.sv->origin, offset );
if(!SV_TestEntityPosition( ent, offset ))
{
MsgDev( D_INFO, "Unstuck player by restoring oldorigin.\n" );
MsgDev( D_NOTE, "Unstuck player by restoring oldorigin.\n" );
SV_LinkEdict( ent );
return;
}
MsgDev( D_INFO, "Stuck player\n" );
MsgDev( D_NOTE, "Stuck player\n" );
}
bool SV_UnstickEntity( edict_t *ent )
@ -1053,7 +1085,7 @@ Only used by players
*/
void SV_WalkMove( edict_t *ent )
{
int clip, oldonground, originalmove_clip, originalmove_flags;
int clip, oldonground, originalmove_clip, originalmove_aiflags;
int originalmove_groundentity, contentsmask;
vec3_t upmove, downmove, start_origin, start_velocity, stepnormal;
vec3_t originalmove_origin, originalmove_velocity;
@ -1063,15 +1095,13 @@ void SV_WalkMove( edict_t *ent )
if( sv.frametime <= 0 ) return;
contentsmask = SV_ContentsMask( ent );
SV_CheckVelocity( ent );
SV_CheckVelocity( ent );
// do a regular slide move unless it looks like you ran into a step
oldonground = (int)ent->progs.sv->aiflags & AI_ONGROUND;
VectorCopy( ent->progs.sv->origin, start_origin );
VectorCopy( ent->progs.sv->velocity, start_velocity );
clip = SV_FlyMove( ent, sv.frametime, NULL, contentsmask );
// if the move did not hit the ground at any point, we're not on ground
@ -1082,7 +1112,7 @@ void SV_WalkMove( edict_t *ent )
VectorCopy( ent->progs.sv->origin, originalmove_origin );
VectorCopy( ent->progs.sv->velocity, originalmove_velocity );
originalmove_clip = clip;
originalmove_flags = (int)ent->progs.sv->flags;
originalmove_aiflags = (int)ent->progs.sv->aiflags;
originalmove_groundentity = ent->progs.sv->groundentity;
if((int)ent->progs.sv->aiflags & AI_WATERJUMP)
@ -1131,7 +1161,7 @@ void SV_WalkMove( edict_t *ent )
// stepping up didn't make any progress, revert to original move
VectorCopy( originalmove_origin, ent->progs.sv->origin );
VectorCopy( originalmove_velocity, ent->progs.sv->velocity );
ent->progs.sv->flags = originalmove_flags;
ent->progs.sv->aiflags = originalmove_aiflags;
ent->progs.sv->groundentity = originalmove_groundentity;
return;
}
@ -1157,7 +1187,7 @@ void SV_WalkMove( edict_t *ent )
//if (ent->progs.sv->solid == SOLID_BSP)
{
//Con_Printf("onground\n");
ent->progs.sv->flags = (int)ent->progs.sv->flags | FL_ONGROUND;
ent->progs.sv->aiflags = (int)ent->progs.sv->aiflags | AI_ONGROUND;
ent->progs.sv->groundentity = PRVM_EDICT_TO_PROG(downtrace.ent);
}
#endif
@ -1169,7 +1199,7 @@ void SV_WalkMove( edict_t *ent )
// cause the player to hop up higher on a slope too steep to climb
VectorCopy( originalmove_origin, ent->progs.sv->origin );
VectorCopy( originalmove_velocity, ent->progs.sv->velocity );
ent->progs.sv->flags = originalmove_flags;
ent->progs.sv->aiflags = originalmove_aiflags;
ent->progs.sv->groundentity = originalmove_groundentity;
}
SV_CheckVelocity( ent );
@ -1337,7 +1367,7 @@ void SV_Physics_Toss( edict_t *ent )
VectorClear( ent->progs.sv->velocity );
VectorClear( ent->progs.sv->avelocity );
}
else ent->progs.sv->flags = (int)ent->progs.sv->aiflags & ~AI_ONGROUND;
else ent->progs.sv->aiflags = (int)ent->progs.sv->aiflags & ~AI_ONGROUND;
}
else
{
@ -1449,7 +1479,7 @@ void SV_Physics_Conveyor( edict_t *ent )
VectorScale( ent->progs.sv->movedir, ent->progs.sv->speed, v );
VectorScale( v, 0.1f, move );
for( i = 0; i < maxclients->integer; i++ )
for( i = 0; i < Host_MaxClients(); i++ )
{
player = PRVM_EDICT_NUM(i) + 1;
if( player->priv.sv->free ) continue;
@ -1498,7 +1528,7 @@ void SV_Physics_Noclip( edict_t *ent )
VectorMA( ent->progs.sv->angles, sv.frametime, ent->progs.sv->avelocity, ent->progs.sv->angles );
VectorMA( ent->progs.sv->origin, sv.frametime, ent->progs.sv->velocity, ent->progs.sv->origin );
}
SV_LinkEdict(ent);
SV_LinkEdict( ent );
}
@ -1644,6 +1674,9 @@ void SV_Physics_ClientEntity( edict_t *ent )
SV_LinkEdict( ent );
SV_CheckVelocity( ent );
if( ent->progs.sv->movetype != MOVETYPE_NOCLIP )
SV_TouchTriggers( ent );
// call standard player post-think
prog->globals.sv->time = sv.time;
prog->globals.sv->pev = PRVM_EDICT_TO_PROG(ent);
@ -1688,6 +1721,9 @@ void SV_Physics_ClientMove( sv_client_t *client, usercmd_t *cmd )
SV_LinkEdict( ent );
SV_CheckVelocity( ent );
if( ent->progs.sv->movetype != MOVETYPE_NOCLIP )
SV_TouchTriggers( ent );
// call standard player post-think, with frametime = 0
prog->globals.sv->time = sv.time;
prog->globals.sv->frametime = 0;
@ -1730,18 +1766,10 @@ void SV_Physics( void )
if( ent->priv.sv->free ) continue;
VectorCopy( ent->progs.sv->origin, ent->progs.sv->old_origin );
if(i <= maxclients->value) SV_Physics_ClientEntity( ent );
if(i <= Host_MaxClients());// SV_Physics_ClientEntity( ent );
else if(!sv_playersonly->integer)SV_Physics_Entity( ent );
}
// FIXME: calc frametime
for( i = 0; i < 6; i++ )
{
if( sv_playersonly->integer )
continue;
pe->Frame( sv.frametime * i );
}
prog->globals.sv->pev = PRVM_EDICT_TO_PROG(prog->edicts);
prog->globals.sv->other = PRVM_EDICT_TO_PROG(prog->edicts);
prog->globals.sv->time = sv.time;

View File

@ -13,78 +13,72 @@ byte *sav_base;
============
SV_CalcBBox
Returns the actual bounding box of a bmodel. This is a big improvement over
what q2 normally does with rotating bmodels - q2 sets absmin, absmax to a cube
that will completely contain the bmodel at *any* rotation on *any* axis, whether
the bmodel can actually rotate to that angle or not. This leads to a lot of
false block tests in SV_Push if another bmodel is in the vicinity.
FIXME: get to work
============
*/
void SV_CalcBBox(edict_t *ent, vec3_t mins, vec3_t maxs)
void SV_CalcBBox( edict_t *ent, vec3_t mins, vec3_t maxs )
{
vec3_t forward, left, up, f1, l1, u1;
vec3_t p[8];
int i, j, k, j2, k4;
vec3_t rmin, rmax;
int i, j, k, l;
float a, *angles;
vec3_t bounds[2];
float xvector[2], yvector[2];
vec3_t base, transformed;
for(k = 0; k < 2; k++)
// find min / max for rotations
angles = ent->progs.sv->angles;
a = angles[1]/180 * M_PI;
xvector[0] = cos(a);
xvector[1] = sin(a);
yvector[0] = -sin(a);
yvector[1] = cos(a);
VectorCopy( mins, bounds[0] );
VectorCopy( maxs, bounds[1] );
rmin[0] = rmin[1] = rmin[2] = 9999;
rmax[0] = rmax[1] = rmax[2] = -9999;
for( i = 0; i <= 1; i++ )
{
k4 = k * 4;
if(k) p[k4][2] = maxs[2];
else p[k4][2] = mins[2];
p[k4 + 1][2] = p[k4][2];
p[k4 + 2][2] = p[k4][2];
p[k4 + 3][2] = p[k4][2];
for(j = 0; j < 2; j++)
base[0] = bounds[i][0];
for( j = 0; j <= 1; j++ )
{
j2 = j * 2;
if(j) p[j2+k4][1] = maxs[1];
else p[j2+k4][1] = mins[1];
p[j2 + k4 + 1][1] = p[j2 + k4][1];
for(i = 0; i < 2; i++)
base[1] = bounds[j][1];
for( k = 0; k <= 1; k++ )
{
if(i) p[i + j2 + k4][0] = maxs[0];
else p[i + j2 + k4][0] = mins[0];
base[2] = bounds[k][2];
// transform the point
transformed[0] = xvector[0] * base[0] + yvector[0] * base[1];
transformed[1] = xvector[1] * base[0] + yvector[1] * base[1];
transformed[2] = base[2];
for( l = 0; l < 3; l++ )
{
if( transformed[l] < rmin[l] ) rmin[l] = transformed[l];
if( transformed[l] > rmax[l] ) rmax[l] = transformed[l];
}
}
}
}
AngleVectors(ent->progs.sv->angles, forward, left, up);
for(i = 0; i < 8; i++)
{
VectorScale(forward, p[i][0], f1);
VectorScale(left, -p[i][1], l1);
VectorScale(up, p[i][2], u1);
VectorAdd(ent->progs.sv->origin, f1, p[i]);
VectorAdd(p[i], l1, p[i]);
VectorAdd(p[i], u1, p[i]);
}
VectorCopy(p[0], ent->progs.sv->mins);
VectorCopy(p[0], ent->progs.sv->maxs);
for(i = 1; i < 8; i++)
{
ent->progs.sv->mins[0] = min(ent->progs.sv->mins[0], p[i][0]);
ent->progs.sv->mins[1] = min(ent->progs.sv->mins[1], p[i][1]);
ent->progs.sv->mins[2] = min(ent->progs.sv->mins[2], p[i][2]);
ent->progs.sv->maxs[0] = max(ent->progs.sv->maxs[0], p[i][0]);
ent->progs.sv->maxs[1] = max(ent->progs.sv->maxs[1], p[i][1]);
ent->progs.sv->maxs[2] = max(ent->progs.sv->maxs[2], p[i][2]);
}
VectorCopy( rmin, ent->progs.sv->mins );
VectorCopy( rmax, ent->progs.sv->maxs );
}
void SV_SetMinMaxSize (edict_t *e, float *min, float *max, bool rotate)
void SV_SetMinMaxSize( edict_t *e, float *min, float *max, bool rotate )
{
int i;
for (i = 0; i < 3; i++)
for( i = 0; i < 3; i++ )
if( min[i] > max[i] )
PRVM_ERROR("SV_SetMinMaxSize: backwards mins/maxs");
rotate = false; // FIXME
// set derived values
if( rotate && e->progs.sv->solid == SOLID_BBOX )
{
@ -95,7 +89,7 @@ void SV_SetMinMaxSize (edict_t *e, float *min, float *max, bool rotate)
VectorCopy( min, e->progs.sv->mins);
VectorCopy( max, e->progs.sv->maxs);
}
VectorSubtract (max, min, e->progs.sv->size );
VectorSubtract( max, min, e->progs.sv->size );
// TODO: fill also mass and density
SV_LinkEdict (e);
@ -371,12 +365,12 @@ void SV_WriteSaveFile( char *name )
if( sv.state != ss_active )
return;
if(Cvar_VariableValue("deathmatch"))
if(Cvar_VariableValue("deathmatch") || Cvar_VariableValue("coop"))
{
MsgDev(D_ERROR, "SV_WriteSaveFile: can't savegame in a deathmatch\n");
MsgDev(D_ERROR, "SV_WriteSaveFile: can't savegame in a multiplayer\n");
return;
}
if( maxclients->integer == 1 && svs.clients[0].edict->progs.sv->health <= 0 )
if(Host_MaxClients() == 1 && svs.clients[0].edict->progs.sv->health <= 0 )
{
MsgDev(D_ERROR, "SV_WriteSaveFile: can't savegame while dead!\n");
return;
@ -1809,7 +1803,7 @@ void PF_clientcmd( void )
VM_ValidateString(PRVM_G_STRING(OFS_PARM1));
i = (int)PRVM_G_FLOAT(OFS_PARM0);
if( sv.state != ss_active || i < 0 || i >= maxclients->integer || svs.clients[i].state != cs_spawned)
if( sv.state != ss_active || i < 0 || i >= Host_MaxClients() || svs.clients[i].state != cs_spawned)
{
VM_Warning( "ClientCommand: client/server is not active!\n" );
return;
@ -1977,7 +1971,7 @@ void PF_ClientPrint( void )
num = PRVM_G_EDICTNUM( OFS_PARM1 );
type = (int)PRVM_G_FLOAT( OFS_PARM0 );
if( num < 1 || num > maxclients->value || svs.clients[num - 1].state != cs_spawned )
if( num < 1 || num > Host_MaxClients() || svs.clients[num - 1].state != cs_spawned )
{
VM_Warning("ClientPrint: tired print to a non-client!\n");
return;
@ -2051,7 +2045,7 @@ void PF_InfoPrint( void )
if(!VM_ValidateArgs( "Info_Print", 1 )) return;
num = PRVM_G_EDICTNUM(OFS_PARM0);
if( num < 1 || num > maxclients->integer )
if( num < 1 || num > Host_MaxClients())
{
VM_Warning( "Info_Print: not a client\n" );
return;
@ -2077,7 +2071,7 @@ void PF_InfoValueForKey( void )
VM_ValidateString(PRVM_G_STRING(OFS_PARM1));
num = PRVM_G_EDICTNUM(OFS_PARM0);
if( num < 1 || num > maxclients->integer )
if( num < 1 || num > Host_MaxClients())
{
VM_Warning("Info_ValueForKey: not a client\n" );
return;
@ -2105,7 +2099,7 @@ void PF_InfoRemoveKey( void )
VM_ValidateString(PRVM_G_STRING(OFS_PARM1));
num = PRVM_G_EDICTNUM(OFS_PARM0);
if( num < 1 || num > maxclients->integer )
if( num < 1 || num > Host_MaxClients())
{
VM_Warning("Info_RemoveKey: not a client\n" );
return;
@ -2134,7 +2128,7 @@ void PF_InfoSetValueForKey( void )
VM_ValidateString(PRVM_G_STRING(OFS_PARM2));
num = PRVM_G_EDICTNUM(OFS_PARM0);
if( num < 1 || num > maxclients->integer )
if( num < 1 || num > Host_MaxClients())
{
VM_Warning("InfoSetValueForKey: not a client\n" );
return;
@ -2173,7 +2167,7 @@ void PF_dropclient( void )
{
int clientnum = PRVM_G_EDICTNUM(OFS_PARM0) - 1;
if( clientnum < 0 || clientnum >= maxclients->integer )
if( clientnum < 0 || clientnum >= Host_MaxClients())
{
VM_Warning("dropclient: not a client\n");
return;
@ -2229,7 +2223,7 @@ VM_ComStrlen, // #30 float strlen( string text )
VM_TimeStamp, // #31 string Com_TimeStamp( float format )
VM_LocalCmd, // #32 void LocalCmd( ... )
VM_SubString, // #33 string substring( string s, float start, float length )
NULL, // #34 -- reserved --
VM_AddCommand, // #34 void Add_Command( string s )
NULL, // #35 -- reserved --
NULL, // #36 -- reserved --
NULL, // #37 -- reserved --
@ -2388,14 +2382,14 @@ void SV_SpawnEntities( const char *mapname, const char *entities )
ent->progs.sv->solid = SOLID_BSP;
ent->progs.sv->movetype = MOVETYPE_PUSH;
SV_ConfigString (CS_MAXCLIENTS, va("%i", maxclients->integer ));
SV_ConfigString (CS_MAXCLIENTS, va("%i", Host_MaxClients()));
prog->globals.sv->mapname = PRVM_SetEngineString( sv.name );
// spawn the rest of the entities on the map
*prog->time = sv.time;
// set client fields on player ents
for( i = 0; i < maxclients->value; i++ )
for( i = 0; i < Host_MaxClients(); i++ )
{
// setup all clients
ent = PRVM_EDICT_NUM( i );
@ -2419,7 +2413,7 @@ void SV_InitServerProgs( void )
PRVM_Begin;
PRVM_InitProg( PRVM_SERVERPROG );
prog->reserved_edicts = maxclients->integer;
prog->reserved_edicts = Host_MaxClients();
prog->loadintoworld = true;
if( !prog->loaded )

View File

@ -1,226 +1,6 @@
#include "common.h"
#include "server.h"
edict_t *pm_passent;
// pmove doesn't need to know about passent and contentmask
void PM_trace( vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, trace_t *tr )
{
if( pm_passent->progs.sv->health > 0 )
*tr = SV_Trace (start, mins, maxs, end, MOVE_NORMAL, pm_passent, MASK_PLAYERSOLID );
*tr = SV_Trace (start, mins, maxs, end, MOVE_NORMAL, pm_passent, MASK_DEADSOLID );
}
int PM_pointcontents( vec3_t point )
{
return SV_PointContents( point );
}
/*
============
SV_TouchTriggers
============
*/
void SV_TouchTriggers (edict_t *ent)
{
int i, num;
edict_t *touch[MAX_EDICTS], *hit;
// dead things don't activate triggers!
if ((ent->priv.sv->client || ((int)ent->progs.sv->flags & FL_MONSTER)) && (ent->progs.sv->health <= 0))
return;
num = SV_AreaEdicts(ent->progs.sv->absmin, ent->progs.sv->absmax, touch, host.max_edicts );
PRVM_PUSH_GLOBALS;
// be careful, it is possible to have an entity in this
// list removed before we get to it (killtriggered)
for (i = 0; i < num; i++)
{
hit = touch[i];
if (hit->priv.sv->free) continue;
prog->globals.sv->pev = PRVM_EDICT_TO_PROG(hit);
prog->globals.sv->other = PRVM_EDICT_TO_PROG(ent);
prog->globals.sv->time = sv.time;
if( hit->progs.sv->touch )
{
PRVM_ExecuteProgram (hit->progs.sv->touch, "pev->touch");
}
}
// restore state
PRVM_POP_GLOBALS;
}
static edict_t *current_player;
static sv_client_t *current_client;
static vec3_t forward, right, up;
float xyspeed, bobmove, bobfracsin; // sin(bobfrac*M_PI)
int bobcycle; // odd cycles are right foot going forward
/*
===============
SV_CalcRoll
===============
*/
static float SV_CalcRoll (vec3_t angles, vec3_t velocity)
{
float sign;
float side;
float value;
side = DotProduct (velocity, right);
sign = side < 0 ? -1 : 1;
side = fabs(side);
value = 2;
if (side < 200) side = side * value / 200;
else side = value;
return side*sign;
}
void SV_CalcViewOffset (edict_t *ent)
{
float *angles;
float bob;
float delta;
vec3_t v;
// base angles
angles = ent->priv.sv->client->ps.punch_angles;
VectorCopy(ent->progs.sv->punchangle, angles);
// add angles based on velocity
delta = DotProduct (ent->progs.sv->velocity, forward);
angles[PITCH] += delta * 0.002;
delta = DotProduct (ent->progs.sv->velocity, right);
angles[ROLL] += delta * 0.005;
// add angles based on bob
delta = bobfracsin * 0.002 * xyspeed;
if (ent->priv.sv->client->ps.pm_flags & PMF_DUCKED)
delta *= 6; // crouching
angles[PITCH] += delta;
delta = bobfracsin * 0.002 * xyspeed;
if (ent->priv.sv->client->ps.pm_flags & PMF_DUCKED)
delta *= 6; // crouching
if (bobcycle & 1) delta = -delta;
angles[ROLL] += delta;
VectorCopy( ent->progs.sv->view_ofs, v ); // base origin
if( ent->priv.sv->client->ps.pm_flags & PMF_DUCKED )
v[2] = -2;
// add bob height
bob = bobfracsin * xyspeed * 0.005;
if( bob > 6 ) bob = 6;
v[2] += bob;
v[0] = bound( -14, v[0], 14 );
v[1] = bound( -14, v[1], 14 );
v[2] = bound( -22, v[2], 48 );
VectorCopy( v, ent->priv.sv->client->ps.viewoffset );
}
void ClientEndServerFrame (edict_t *ent)
{
float bobtime = 0;
current_player = ent;
current_client = ent->priv.sv->client;
//
// If the origin or velocity have changed since ClientThink(),
// update the pmove values. This will happen when the client
// is pushed by a bmodel or kicked by an explosion.
//
// If it wasn't updated here, the view position would lag a frame
// behind the body position when pushed -- "sinking into plats"
//
VectorScale(ent->progs.sv->origin, SV_COORD_FRAC, current_client->ps.origin );
VectorScale(ent->progs.sv->velocity, SV_COORD_FRAC, current_client->ps.velocity );
AngleVectors (ent->priv.sv->client->ps.viewangles, forward, right, up);
//
// set model angles from view angles so other things in
// the world can tell which direction you are looking
//
if (ent->priv.sv->client->ps.viewangles[PITCH] > 180)
ent->progs.sv->angles[PITCH] = (-360 + ent->priv.sv->client->ps.viewangles[PITCH])/3;
else ent->progs.sv->angles[PITCH] = ent->priv.sv->client->ps.viewangles[PITCH]/3;
ent->progs.sv->angles[YAW] = ent->priv.sv->client->ps.viewangles[YAW];
ent->progs.sv->angles[ROLL] = 0;
ent->progs.sv->angles[ROLL] = SV_CalcRoll (ent->progs.sv->angles, ent->progs.sv->velocity)*4;
//
// calculate speed and cycle to be used for
// all cyclic walking effects
//
xyspeed = sqrt(ent->progs.sv->velocity[0] * ent->progs.sv->velocity[0] + ent->progs.sv->velocity[1] * ent->progs.sv->velocity[1]);
if( xyspeed < 5 ) bobmove = 0;
else if (ent->progs.sv->groundentity)
{
// so bobbing only cycles when on ground
if (xyspeed > 210) bobmove = 0.25;
else if (xyspeed > 100) bobmove = 0.125;
else bobmove = 0.0625;
}
bobtime += bobmove;
if (current_client->ps.pm_flags & PMF_DUCKED)
bobtime *= 4;
bobcycle = (int)bobtime;
bobfracsin = fabs(sin(bobtime*M_PI));
// determine the view offsets
SV_CalcViewOffset (ent);
}
/*
=================
ClientEndServerFrames
=================
*/
void ClientEndServerFrames (void)
{
int i;
// calc the player views now that all pushing
// and damage has been added
for (i = 0; i < maxclients->value; i++)
{
if(svs.clients[i].state != cs_spawned) continue;
ClientEndServerFrame (svs.clients[i].edict);
}
}
/*
================
SV_RunFrame
Advances the world by 0.1 seconds
================
*/
void SV_RunFrame( void )
{
;
//ClientEndServerFrames();
}
/*
==============
ClientThink
@ -231,83 +11,10 @@ usually be a couple times for each server frame.
*/
void ClientThink (edict_t *ent, usercmd_t *ucmd)
{
sv_client_t *client;
edict_t *other;
pmove_t pm;
vec3_t view;
vec3_t oldorigin, oldvelocity;
int i, j;
pmove_t pm;
client = ent->priv.sv->client;
// call standard client pre-think
prog->globals.sv->time = sv.time;
prog->globals.sv->pev = PRVM_EDICT_TO_PROG(ent);
PRVM_ExecuteProgram (prog->globals.sv->PlayerPreThink, "PlayerPreThink");
VectorCopy(ent->progs.sv->origin, oldorigin);
VectorCopy(ent->progs.sv->velocity, oldvelocity);
ent->priv.sv->client->ps.pm_flags &= ~PMF_NO_PREDICTION;
VectorCopy(ent->progs.sv->origin, view);
pm_passent = ent;
// set up for pmove
memset (&pm, 0, sizeof(pm));
if (ent->progs.sv->movetype == MOVETYPE_NOCLIP) client->ps.pm_type = PM_SPECTATOR;
else client->ps.pm_type = PM_NORMAL;
client->ps.gravity = sv_gravity->value;
if(ent->progs.sv->teleport_time)
{
// next frame will be cleared teleport flag
client->ps.pm_flags |= PMF_TIME_TELEPORT;
ent->progs.sv->teleport_time = 0;
}
else client->ps.pm_flags &= ~PMF_TIME_TELEPORT;
pm.ps = client->ps;
memcpy( &client->lastcmd, ucmd, sizeof(usercmd_t));//IMPORTANT!!!
VectorScale(ent->progs.sv->origin, SV_COORD_FRAC, pm.ps.origin );
VectorScale(ent->progs.sv->velocity, SV_COORD_FRAC, pm.ps.velocity );
pm.cmd = *ucmd;
pm.trace = PM_trace; // adds default parms
pm.pointcontents = PM_pointcontents;
// perform a pmove
pe->PlayerMove( &pm, false );
// save results of pmove
client->ps = pm.ps;
VectorScale(pm.ps.origin, CL_COORD_FRAC, ent->progs.sv->origin);
VectorScale(pm.ps.velocity, CL_COORD_FRAC, ent->progs.sv->velocity);
VectorCopy(pm.mins, ent->progs.sv->mins);
VectorCopy(pm.maxs, ent->progs.sv->maxs);
VectorCopy(pm.ps.viewangles, ent->progs.sv->v_angle);
VectorCopy(pm.ps.viewangles, ent->progs.sv->angles);
if( pm.groundentity )
ent->progs.sv->groundentity = PRVM_EDICT_TO_PROG( pm.groundentity );
else ent->progs.sv->groundentity = 0;
// copy viewmodel info
client->ps.vmodel.frame = ent->progs.sv->v_frame;
client->ps.vmodel.body = ent->progs.sv->v_body;
client->ps.vmodel.skin = ent->progs.sv->v_skin;
client->ps.vmodel.sequence = ent->progs.sv->v_sequence;
SV_LinkEdict(ent);
if (ent->progs.sv->movetype != MOVETYPE_NOCLIP)
SV_TouchTriggers (ent);
PRVM_PUSH_GLOBALS;
for (i = 0; i < pm.numtouch; i++)
{
other = pm.touchents[i];
@ -327,12 +34,6 @@ void ClientThink (edict_t *ent, usercmd_t *ucmd)
PRVM_ExecuteProgram (other->progs.sv->touch, "pev->touch");
}
}
PRVM_POP_GLOBALS;
// call standard player post-think
prog->globals.sv->time = sv.time;
prog->globals.sv->pev = PRVM_EDICT_TO_PROG(ent);
PRVM_ExecuteProgram (prog->globals.sv->PlayerPostThink, "PlayerPostThink");
}
/*

View File

@ -184,17 +184,17 @@ void SV_LinkEdict( edict_t *ent )
if (ent->progs.sv->solid == SOLID_BBOX && !((int)ent->progs.sv->flags & FL_DEADMONSTER))
{
// assume that x/y are equal and symetric
i = ent->progs.sv->maxs[0] / SV_COORD_FRAC;
i = ent->progs.sv->maxs[0]/8;
i = bound( 1, i, 255 );
// z is not symetric
j = (-ent->progs.sv->mins[2]) / SV_COORD_FRAC;
j = (-ent->progs.sv->mins[2])/8;
j = bound( 1, j, 255 );
// and z maxs can be negative...
k = (ent->progs.sv->maxs[2] + 32)/SV_COORD_FRAC;
k = (ent->progs.sv->maxs[2] + 32)/8;
k = bound( 1, k, 255 );
sv_ent->solid = (k<<16) | (j<<8) | i;
sv_ent->solid = (k<<16)|(j<<8)|i;
}
else if (ent->progs.sv->solid == SOLID_BSP)
{

View File

@ -18,6 +18,7 @@
#define PACKFILE_FLAG_DEFLATED (1<<1) // file compressed using the deflate algorithm
#define FILE_BUFF_SIZE 2048
// filesystem flags
#define FS_READONLY_PATH 1
typedef struct
@ -645,8 +646,6 @@ void FS_FileBase( const char *in, char *out )
start = 0;
else start++;
if(in[start] == '#') start++;
// Length of new sting
len = end - start + 1;
@ -1491,7 +1490,6 @@ FS_Init
*/
void FS_Init( void )
{
char szTemp[4096];
stringlist_t dirs;
int i;
@ -1518,8 +1516,7 @@ void FS_Init( void )
{
if( Sys.app_name == COMP_BSPLIB )
com_strcpy( gs_basedir, fs_defaultdir->string );
else if(GetModuleFileName( NULL, szTemp, MAX_SYSPATH ))
FS_FileBase( szTemp, gs_basedir );
else if(Sys_GetModuleName( gs_basedir, MAX_SYSPATH ));
else com_strcpy( gs_basedir, fs_defaultdir->string ); // default dir
}
// checked nasty path: "bin" it's a reserved word

View File

@ -512,7 +512,7 @@ void *_mem_get_array_element( byte *arrayptr, size_t index )
return (void *)(l->arrays[i].data + j * l->recordsize);
}
void _mem_checkheadersentinels(void *data, const char *filename, int fileline)
void _mem_checkheadersentinels( void *data, const char *filename, int fileline )
{
memheader_t *mem;
@ -524,7 +524,7 @@ void _mem_checkheadersentinels(void *data, const char *filename, int fileline)
Sys_Error("Mem_CheckSentinels: trashed header sentinel 2 (block allocated at %s:%i, sentinel check at %s:%i)\n", mem->filename, mem->fileline, filename, fileline);
}
static void _mem_checkclumpsentinels(memclump_t *clump, const char *filename, int fileline)
static void _mem_checkclumpsentinels( memclump_t *clump, const char *filename, int fileline )
{
// this isn't really very useful
if (clump->sentinel1 != MEMCLUMP_SENTINEL)
@ -583,13 +583,13 @@ void _mem_printlist( size_t minallocationsize )
{
Msg("%5luk (%5luk actual) %s (%+3li byte change)\n", (dword) ((pool->totalsize + 1023) / 1024), (dword)((pool->realsize + 1023) / 1024), pool->name, (long)pool->totalsize - pool->lastchecksize );
pool->lastchecksize = pool->totalsize;
for (mem = pool->chain; mem; mem = mem->next)
if (mem->size >= minallocationsize)
Msg("%10lu bytes allocated at %s:%i\n", (dword)mem->size, mem->filename, mem->fileline);
for( mem = pool->chain; mem; mem = mem->next )
if( mem->size >= minallocationsize )
Msg("%10lu bytes allocated at %s:%i\n", (dword)mem->size, mem->filename, mem->fileline );
}
}
void MemList_f(void)
void MemList_f( void )
{
switch(Cmd_Argc())
{
@ -598,7 +598,7 @@ void MemList_f(void)
_mem_printstats();
break;
case 2:
_mem_printlist(atoi(Cmd_Argv(1)) * 1024);
_mem_printlist(com.atoi(Cmd_Argv(1)) * 1024);
_mem_printstats();
break;
default:
@ -627,5 +627,5 @@ void Memory_Shutdown( void )
void Memory_Init_Commands( void )
{
Cmd_AddCommand("memlist", MemList_f, "prints memory pool information (or if used as memlist 5 lists individual allocations of 5K or larger, 0 lists all allocations)");
Cmd_AddCommand( "memlist", MemList_f, "prints memory pool information (or if used as memlist 5 lists individual allocations of 5K or larger, 0 lists all allocations)");
}

View File

@ -453,6 +453,17 @@ const char* com_timestamp( int format )
return timestamp;
}
/*
============
strstr
search case - sensitive for string2 in string
============
*/
char *com_strstr( const char *string, const char *string2 )
{
return strstr( string, string2 ); //FIXME
}
/*
============

View File

@ -16,6 +16,7 @@ launch_exp_t *Host; // callback to mainframe
sys_event_t event_que[MAX_QUED_EVENTS];
int event_head, event_tail;
FILE *logfile;
FILE *memfile;
dll_info_t common_dll = { "common.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(launch_exp_t) };
dll_info_t engine_dll = { "engine.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(launch_exp_t) };
@ -202,7 +203,7 @@ void Sys_GetStdAPI( void )
com.strncmp = com_strncmp;
com.strcmp = com_strcmp;
com.stristr = com_stristr;
com.strstr = com_stristr; // FIXME
com.strstr = com_strstr;
com.strpack = com_strpack;
com.strunpack = com_strunpack;
com.vsprintf = com_vsprintf;
@ -219,42 +220,56 @@ void Sys_GetStdAPI( void )
==================
Parse program name to launch and determine work style
NOTE: at this day we have eleven instances
NOTE: at this day we have ten instances
1. "host_shared" - normal game launch
2. "host_dedicated" - dedicated server
3. "host_editor" - resource editor
4. "bsplib" - three BSP compilers in one
5. "imglib" - convert old formats (mip, pcx, lmp) to 32-bit tga
6. "qcclib" - quake c complier
7. "roqlib" - roq video file maker
8. "sprite" - sprite creator (requires qc. script)
9. "studio" - Half-Life style models creator (requires qc. script)
10. "credits" - display credits of engine developers
11. "host_setup" - write current path into registry (silently)
1. "normal" - normal or dedicated game launch
2. "viewer" - resource editor
3. "bsplib" - three BSP compilers in one
4. "imglib" - convert old formats (mip, pcx, lmp) to 32-bit tga
5. "qcclib" - quake c complier
6. "roqlib" - roq video file maker
7. "sprite" - sprite creator (requires qc. script)
8. "studio" - Half-Life style models creator (requires qc. script)
9. "credits" - display credits of engine developers
10. "host_setup" - write current path into registry (silently)
This list will be expnaded in future
==================
*/
void Sys_LookupInstance( void )
{
char szTemp[4096];
bool dedicated_mode = false;
Sys.app_name = HOST_OFFLINE;
if(GetModuleFileName( NULL, szTemp, MAX_SYSPATH ))
FS_FileBase( szTemp, Sys.ModuleName );
// determine host type
if( Sys.ModuleName[0] == '#' )
{
// cutoff '#'
com_strncpy( szTemp, Sys.ModuleName + 1, MAX_SYSPATH );
com_strncpy( Sys.ModuleName, szTemp, MAX_SYSPATH );
dedicated_mode = true;
}
// lookup all instances
if(!com_strcmp(Sys.progname, "normal"))
{
Sys.app_name = HOST_NORMAL;
Sys.con_readonly = true;
// don't show console as default
if(!Sys.debug) Sys.con_showalways = false;
Sys.linked_dll = &engine_dll; // pointer to engine.dll info
com_sprintf(Sys.log_path, "engine.log", com_timestamp(TIME_NO_SECONDS)); // logs folder
com_strcpy(Sys.caption, va("Xash3D ver.%g", XASH_VERSION ));
}
else if(!com_strcmp(Sys.progname, "dedicated"))
{
Sys.app_name = HOST_DEDICATED;
Sys.con_readonly = false;
if( dedicated_mode )
{
Sys.app_name = HOST_DEDICATED;
Sys.con_readonly = false;
}
else
{
Sys.app_name = HOST_NORMAL;
Sys.con_readonly = true;
// don't show console as default
if(!Sys.debug) Sys.con_showalways = false;
}
Sys.linked_dll = &engine_dll; // pointer to engine.dll info
com_sprintf(Sys.log_path, "engine.log", com_timestamp(TIME_NO_SECONDS)); // logs folder
com_strcpy(Sys.caption, va("Xash3D ver.%g", XASH_VERSION ));
@ -266,7 +281,7 @@ void Sys_LookupInstance( void )
//don't show console as default
if(!Sys.debug) Sys.con_showalways = false;
Sys.linked_dll = &viewer_dll; // pointer to viewer.dll info
Sys.log_active = Sys.developer = Sys.debug = 0; // clear all dbg states
com_sprintf(Sys.log_path, "%s/editor.log", sys_rootdir ); // logs folder
com_strcpy(Sys.caption, va("Xash3D Resource Viewer ver.%g", XASH_VERSION ));
}
else if(!com_strcmp(Sys.progname, "splash"))
@ -397,8 +412,8 @@ void Sys_CreateInstance( void )
// export
launch_t CreateHost, CreateBaserc;
Sys_LoadLibrary( Sys.linked_dll ); // loading library if need
srand(time(NULL)); // init random generator
Sys_LoadLibrary( Sys.linked_dll ); // loading library if need
// pre initializations
switch( Sys.app_name )
@ -542,22 +557,35 @@ void Sys_ParseCommandLine (LPSTR lpCmdLine)
void Sys_InitLog( void )
{
// create log if needed
if(!Sys.log_active || !com_strlen(Sys.log_path) || Sys.con_silentmode) return;
logfile = fopen( Sys.log_path, "w");
if(!logfile) Sys_Error("Sys_InitLog: can't create log file %s\n", Sys.log_path );
string path;
fprintf(logfile, "=======================================================================\n" );
fprintf(logfile, "\t%s started at %s\n", Sys.caption, com_timestamp(TIME_FULL));
fprintf(logfile, "=======================================================================\n");
if( Sys.developer == D_MEMORY )
{
com_snprintf( path, MAX_STRING, "%s/memhistory.log", sys_rootdir );
memfile = fopen( path, "w" );
if(!memfile) Sys_Error("Sys_InitLog: can't create memhistory log file %s\n", path );
fprintf(memfile, "=======================================================================\n" );
fprintf(memfile, "\t%s started at %s\n", Sys.caption, com_timestamp(TIME_FULL));
fprintf(memfile, "=======================================================================\n");
}
// create log if needed
if( Sys.log_active && !Sys.con_silentmode )
{
logfile = fopen( Sys.log_path, "w");
if(!logfile) Sys_Error("Sys_InitLog: can't create log file %s\n", Sys.log_path );
fprintf(logfile, "=======================================================================\n" );
fprintf(logfile, "\t%s started at %s\n", Sys.caption, com_timestamp(TIME_FULL));
fprintf(logfile, "=======================================================================\n");
}
}
void Sys_CloseLog( void )
{
string event_name;
if(!logfile) return;
switch( Sys.app_state )
{
case SYS_CRASH: com_strncpy( event_name, "crashed", MAX_STRING ); break;
@ -566,13 +594,26 @@ void Sys_CloseLog( void )
default: com_strncpy( event_name, "stopped", MAX_STRING ); break;
}
fprintf(logfile, "\n");
fprintf(logfile, "=======================================================================");
fprintf(logfile, "\n\t%s %s at %s\n", Sys.caption, event_name, com_timestamp(TIME_FULL));
fprintf(logfile, "=======================================================================");
if( logfile )
{
fprintf(logfile, "\n");
fprintf(logfile, "=======================================================================");
fprintf(logfile, "\n\t%s %s at %s\n", Sys.caption, event_name, com_timestamp(TIME_FULL));
fprintf(logfile, "=======================================================================");
fclose(logfile);
logfile = NULL;
fclose( logfile );
logfile = NULL;
}
if( memfile )
{
fprintf(memfile, "\n");
fprintf(memfile, "=======================================================================");
fprintf(memfile, "\n\t%s %s at %s\n", Sys.caption, event_name, com_timestamp(TIME_FULL));
fprintf(memfile, "=======================================================================");
fclose( memfile );
memfile = NULL;
}
}
void Sys_PrintLog( const char *pMsg )
@ -581,6 +622,12 @@ void Sys_PrintLog( const char *pMsg )
fprintf(logfile, "%s", pMsg );
}
void Sys_PrintMem( const char *pMsg )
{
if(!memfile) return;
fprintf(memfile, "%s", pMsg );
}
/*
================
Sys_Print
@ -654,7 +701,7 @@ formatted message
*/
void Sys_Msg( const char *pMsg, ... )
{
va_list argptr;
va_list argptr;
char text[MAX_MSGLEN];
va_start (argptr, pMsg);
@ -671,8 +718,8 @@ void Sys_MsgDev( int level, const char *pMsg, ... )
if(Sys.developer < level) return;
va_start (argptr, pMsg);
com_vsprintf (text, pMsg, argptr);
va_start( argptr, pMsg );
com_vsprintf( text, pMsg, argptr );
va_end (argptr);
switch( level )
@ -693,7 +740,10 @@ void Sys_MsgDev( int level, const char *pMsg, ... )
Sys_Print( text );
break;
case D_MEMORY:
Sys_Print( text );
Sys_PrintMem( text );
break;
case D_STRING:
Sys_Print(va("^6AllocString: ^7%s", text));
break;
}
}
@ -1376,6 +1426,15 @@ sys_event_t Sys_GetEvent( void )
return ev;
}
bool Sys_GetModuleName( char *buffer, size_t length )
{
if(Sys.ModuleName[0] == '\0' )
return false;
com_strncpy( buffer, Sys.ModuleName, length + 1 );
return true;
}
//=======================================================================
// REGISTRY COMMON TOOLS
//=======================================================================

View File

@ -47,6 +47,7 @@ typedef struct system_s
bool stuffcmdsrun;
byte packet_received[MAX_MSGLEN]; // network data
uint msg_time; // GetMessage time
char ModuleName[4096]; // exe.filename
HINSTANCE hInstance;
LPTOP_LEVEL_EXCEPTION_FILTER oldFilter;
@ -120,6 +121,7 @@ double Sys_DoubleTime( void );
dword Sys_Milliseconds( void );
char *Sys_GetClipboardData( void );
char *Sys_GetCurrentUser( void );
bool Sys_GetModuleName( char *buffer, size_t length );
void Sys_Sleep( int msec );
void Sys_Init( void );
void Sys_Exit( void );
@ -134,6 +136,7 @@ void Sys_CloseLog( void );
void Sys_Error(const char *error, ...);
void Sys_Break(const char *error, ...);
void Sys_PrintLog( const char *pMsg );
void Sys_PrintMem( const char *pMsg );
void Sys_Print(const char *pMsg);
void Sys_Msg( const char *pMsg, ... );
void Sys_MsgDev( int level, const char *pMsg, ... );
@ -195,6 +198,7 @@ int com_strncmp (const char *s1, const char *s2, int n);
int com_strcmp (const char *s1, const char *s2);
const char* com_timestamp( int format );
char *com_stristr( const char *string, const char *string2 );
char *com_strstr( const char *string, const char *string2 );
size_t com_strpack( byte *buffer, size_t pos, char *string, int n );
size_t com_strunpack( byte *buffer, size_t pos, char *string );
int com_vsnprintf(char *buffer, size_t buffersize, const char *format, va_list args);

View File

@ -20,11 +20,11 @@ cvar_t *cm_leavenudge;
cvar_t *cm_prefernudgedfraction;
static uint brushforbox_index = 0;
static cpointf_t polyf_points[256];
static cplanef_t polyf_planes[256 + 2];
static cpointf_t polyf_points[512];
static cplanef_t polyf_planes[512 + 2];
static cbrushf_t polyf_brush;
static cpointf_t polyf_pointsstart[256], polyf_pointsend[256];
static cplanef_t polyf_planesstart[256 + 2], polyf_planesend[256 + 2];
static cpointf_t polyf_pointsstart[512], polyf_pointsend[512];
static cplanef_t polyf_planesstart[512 + 2], polyf_planesend[512 + 2];
static cbrushf_t polyf_brushstart, polyf_brushend;
static cpointf_t brushforbox_point[MAX_BRUSHFORBOX*8];
static cplanef_t brushforbox_plane[MAX_BRUSHFORBOX*6];
@ -143,17 +143,17 @@ cbrushf_t *CM_CollisionNewBrushFromPlanes( byte *mempool, int numoriginalplanes,
{
// TODO: planesbuf could be replaced by a remapping table
int j, k, m, w, xyzflags;
int numpointsbuf = 0, maxpointsbuf = 256, numplanesbuf = 0;
int maxplanesbuf = 256, numelementsbuf = 0, maxelementsbuf = 256;
int numpointsbuf = 0, maxpointsbuf = 512, numplanesbuf = 0;
int maxplanesbuf = 512, numelementsbuf = 0, maxelementsbuf = 512;
double maxdist;
cbrushf_t *brush;
cpointf_t pointsbuf[256];
cplanef_t planesbuf[256];
int elementsbuf[1024];
int polypointbuf[256];
int pmaxpoints = 64;
cpointf_t pointsbuf[512];
cplanef_t planesbuf[512];
int elementsbuf[2048];
int polypointbuf[512];
int pmaxpoints = 128;
int pnumpoints;
double p[2][192];
double p[2][384];
#if 0
// enable these if debugging to avoid seeing garbage in unused data
@ -555,10 +555,10 @@ void CM_CollisionTraceBrushBrushFloat( trace_t *trace, const cbrushf_t *thisbrus
VectorClear( newimpactnormal );
for (nplane = 0;nplane < thatbrush_start->numplanes + thisbrush_start->numplanes;nplane++)
for( nplane = 0; nplane < thatbrush_start->numplanes + thisbrush_start->numplanes; nplane++ )
{
nplane2 = nplane;
if (nplane2 >= thatbrush_start->numplanes)
if( nplane2 >= thatbrush_start->numplanes )
{
nplane2 -= thatbrush_start->numplanes;
startplane = thisbrush_start->planes + nplane2;
@ -834,9 +834,9 @@ void CM_CollisionSnapCopyPoints( int numpoints, const cpointf_t *in, cpointf_t *
void CM_CollisionTraceBrushPolygonFloat( trace_t *trace, const cbrushf_t *thisbrush_start, const cbrushf_t *thisbrush_end, int numpoints, const float *points, int supercontents )
{
if( numpoints > 256 )
if( numpoints > 512 )
{
MsgDev( D_ERROR, "Polygon with more than 256 points not supported yet (fixme!)\n" );
MsgDev( D_ERROR, "Polygon with more than 512 points not supported\n" );
return;
}
polyf_brush.numpoints = numpoints;
@ -881,9 +881,9 @@ void CM_CollisionTraceBrushTriangleMeshFloat( trace_t *trace, const cbrushf_t *t
void CM_CollisionTraceLinePolygonFloat( trace_t *trace, const vec3_t linestart, const vec3_t lineend, int numpoints, const float *points, int supercontents )
{
if( numpoints > 256 )
if( numpoints > 512 )
{
MsgDev( D_ERROR, "Polygon with more than 256 points not supported yet (fixme!)\n" );
MsgDev( D_ERROR, "Polygon with more than 512 points not supported\n" );
return;
}
@ -937,9 +937,9 @@ void CM_CollisionTraceBrushPolygonTransformFloat( trace_t *trace, const cbrushf_
{
int i;
if( numpoints > 256 )
if( numpoints > 512 )
{
MsgDev( D_ERROR, "Polygon with more than 256 points not supported yet (fixme!)\n" );
MsgDev( D_ERROR, "Polygon with more than 512 points not supported\n" );
return;
}

View File

@ -161,8 +161,8 @@ typedef struct clipmap_s
csurface_t *surfdesc;
cbrush_t *brushes;
cbrushside_t *brushsides;
byte *visibility;
dvis_t *vis; // vis offset
byte *visbase; // vis offset
dvis_t *vis;
NewtonCollision *collision;
char *stringdata;
int *stringtable;

View File

@ -117,7 +117,7 @@ void BSP_CreateMeshBuffer( int modelnum )
loadmodel = &cm.bmodels[modelnum];
if( modelnum ) loadmodel->type = mod_brush;
loadmodel->type = mod_static; // level static geometry
else loadmodel->type = mod_world; // level static geometry
loadmodel->TraceBox = CM_TraceBmodel;
loadmodel->PointContents = CM_PointContents;
@ -180,6 +180,12 @@ void BSP_LoadModels( lump_t *l )
out->maxs[j] = LittleFloat(in->maxs[j]) + 1;
}
out->firstface = n = LittleLong( in->firstface );
out->numfaces = c = LittleLong( in->numfaces );
// skip other stuff, not using for building collision tree
if( app_name == COMP_BSPLIB ) continue;
// FIXME: calc bounding box right
VectorCopy( out->mins, out->normalmins );
VectorCopy( out->maxs, out->normalmaxs );
@ -188,8 +194,6 @@ void BSP_LoadModels( lump_t *l )
VectorCopy( out->mins, out->yawmins );
VectorCopy( out->maxs, out->yawmaxs );
out->firstface = n = LittleLong( in->firstface );
out->numfaces = c = LittleLong( in->numfaces );
if( n < 0 || n + c > cm.numfaces )
Host_Error("BSP_LoadModels: invalid face range %i : %i (%i faces)\n", n, n+c, cm.numfaces );
out->firstbrush = n = LittleLong( in->firstbrush );
@ -197,7 +201,7 @@ void BSP_LoadModels( lump_t *l )
if( n < 0 || n + c > cm.numbrushes )
Host_Error("BSP_LoadModels: invalid brush range %i : %i (%i brushes)\n", n, n+c, cm.numfaces );
com.strncpy( out->name, va("*%i", i ), sizeof(out->name));
out->mempool = Mem_AllocPool( out->name );
out->mempool = Mem_AllocPool( va("^2%s", out->name )); // difference with render and cm pools
BSP_CreateMeshBuffer( i ); // bsp physic
}
}
@ -554,15 +558,16 @@ void BSP_LoadVisibility( lump_t *l )
{
int i;
if(!l->filelen)
if( !l->filelen )
{
cm.vis = NULL;
cm.vis = (dvis_t *)Mem_Alloc( cmappool, MAX_MAP_VISIBILITY );
cm.visbase = NULL; // invalidate
return;
}
cm.visibility = (byte *)Mem_Alloc( cmappool, l->filelen );
Mem_Copy( cm.visibility, cm.mod_base + l->fileofs, l->filelen );
cm.vis = (dvis_t *)cm.visibility; // conversion
cm.visbase = (byte *)Mem_Alloc( cmappool, l->filelen );
Mem_Copy( cm.visbase, cm.mod_base + l->fileofs, l->filelen );
cm.vis = (dvis_t *)cm.visbase; // conversion
cm.vis->numclusters = LittleLong( cm.vis->numclusters );
for (i = 0; i < cm.vis->numclusters; i++)
{
@ -741,6 +746,8 @@ static void BSP_RecursiveFindNumLeafs( cnode_t *node )
node = node->children[1];
}
numleafs = ((cleaf_t *)node - cm.leafs) + 1;
// these never happens
if( cm.numleafs < numleafs ) cm.numleafs = numleafs;
}
@ -1031,12 +1038,8 @@ cmodel_t *CM_BeginRegistration( const char *name, bool clientload, uint *checksu
BSP_LoadModels(&hdr->lumps[LUMP_MODELS]);
BSP_LoadCollision(&hdr->lumps[LUMP_COLLISION]);
// test, these probably unneeded
Msg("cm.numleafs %i\n", cm.numleafs );
BSP_RecursiveFindNumLeafs( cm.nodes );
BSP_RecursiveSetParent( cm.nodes, NULL );
Msg("cm.numleafs %i\n", cm.numleafs );
CM_LoadWorld( buf );// load physics collision
Mem_Free( buf ); // release map buffer
@ -1449,7 +1452,7 @@ cmodel_t *CM_RegisterModel( const char *name )
}
MsgDev(D_NOTE, "CM_LoadModel: load %s\n", name );
mod->mempool = Mem_AllocPool(mod->name);
mod->mempool = Mem_AllocPool( va("^2%s", mod->name ));
loadmodel = mod;
// call the apropriate loader

View File

@ -229,7 +229,6 @@ void CM_ServerMove( pmove_t *pmove )
m_isAirBorne = true;
VectorSet( m_stepContact, 0.0f, -m_size[2], 0.0f );
pm->ps.viewheight = 22;
NewtonUpVectorSetPin( cm.upVector, &vec3_up[0] );
}

File diff suppressed because it is too large Load Diff

View File

@ -61,14 +61,14 @@ void CM_DecompressVis( byte *in, byte *out )
byte *CM_ClusterPVS( int cluster )
{
if( cluster == -1 || !cm.vis ) memset( cm.pvsrow, 0, (cm.numclusters + 7)>>3 );
else CM_DecompressVis( cm.visibility + cm.vis->bitofs[cluster][DVIS_PVS], cm.pvsrow );
else CM_DecompressVis( cm.visbase + cm.vis->bitofs[cluster][DVIS_PVS], cm.pvsrow );
return cm.pvsrow;
}
byte *CM_ClusterPHS (int cluster)
{
if( cluster == -1 || !cm.vis ) memset( cm.phsrow, 0, (cm.numclusters + 7)>>3 );
else CM_DecompressVis( cm.visibility + cm.vis->bitofs[cluster][DVIS_PHS], cm.phsrow );
else CM_DecompressVis( cm.visbase + cm.vis->bitofs[cluster][DVIS_PHS], cm.phsrow );
return cm.phsrow;
}
@ -118,7 +118,7 @@ void CM_FloodAreaConnections( void )
for( i = 1; i < cm.numareas; i++ )
{
area = &cm.areas[i];
if (area->floodvalid == cm.floodvalid)
if( area->floodvalid == cm.floodvalid )
continue; // already flooded into
floodnum++;
FloodArea_r( area, floodnum );

View File

@ -279,7 +279,7 @@ void CM_TraceBmodel( const vec3_t start, const vec3_t end, const vec3_t mins, co
if( surface->numtriangles ) CM_CollisionTraceLineTriangleMeshFloat( trace, start, end, surface->numtriangles, surface->indices, surface->vertices, surface->contentflags, surface->surfaceflags, surface, segmentmins, segmentmaxs );
}
}
else CM_TraceBrush_r( trace, model, cm.nodes, thisbrush_start, thisbrush_end, ++markframe, segmentmins, segmentmaxs);
else CM_TraceBrush_r( trace, model, cm.nodes, thisbrush_start, thisbrush_end, ++markframe, segmentmins, segmentmaxs );
}
}

View File

@ -15,7 +15,7 @@ enum host_state
{ // paltform states
HOST_OFFLINE = 0, // host_init( g_Instance ) same much as:
HOST_NORMAL, // "normal"
HOST_DEDICATED, // "dedicated"
HOST_DEDICATED, // "#normal"
HOST_VIEWER, // "viewer"
HOST_CREDITS, // "splash" (easter egg)
HOST_INSTALL, // "install"
@ -40,21 +40,6 @@ enum host_state
#define bound(min, num, max) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min))
#define DLLEXPORT __declspec(dllexport)
//#define USE_COORD_FRAC //FIXME: disable this
// network precision coords factor
#ifdef USE_COORD_FRAC
#define SV_COORD_FRAC (8.0f / 1.0f)
#define CL_COORD_FRAC (1.0f / 8.0f)
#else
#define SV_COORD_FRAC 1.0f
#define CL_COORD_FRAC 1.0f
#endif
#define SV_ANGLE_FRAC (360.0f / 1.0f )
#define CL_ANGLE_FRAC (1.0f / 360.0f )
typedef long fs_offset_t;
typedef enum { NA_BAD, NA_LOOPBACK, NA_BROADCAST, NA_IP, NA_IPX, NA_BROADCAST_IPX } netadrtype_t;
typedef enum { NS_CLIENT, NS_SERVER } netsrc_t;
@ -64,7 +49,7 @@ typedef struct { byte r; byte g; byte b; byte a; } color32;
typedef struct { const char *name; void **func; } dllfunc_t; // Sys_LoadLibrary stuff
typedef struct { int ofs; int type; const char *name; } fields_t; // prvm custom fields
typedef void (*cmread_t) (void* handle, void* buffer, size_t size);
typedef enum { mod_bad, mod_static, mod_brush, mod_studio, mod_sprite } modtype_t;
typedef enum { mod_bad, mod_world, mod_brush, mod_studio, mod_sprite } modtype_t;
typedef void (*cmsave_t) (void* handle, const void* buffer, size_t size);
typedef void (*cmdraw_t)( int color, int numpoints, const float *points );
typedef struct { int numfilenames; char **filenames; char *filenamesbuffer; } search_t;
@ -178,7 +163,6 @@ typedef struct model_state_s
int body; // sub-model selection for studiomodels
float blending[8]; // studio animation blending
float controller[32]; // studio bone controllers
vec3_t calcbonepos[128]; // too hard: ragdoll or like it, animated by physic engine
} model_state_t;
// entity_state_t communication
@ -218,8 +202,7 @@ typedef struct entity_state_s
vec3_t delta_angles; // add to command angles to get view direction
vec3_t punch_angles; // add to view direction to get render angles
vec3_t viewangles; // already calculated view angles on server-side
vec3_t viewoffset; // FIXME: replace with viewheight
int viewheight; // height over ground
vec3_t viewoffset; // viewoffset over ground
int maxspeed; // sv_maxspeed will be duplicate on all clients
float health; // client health (other parms can be send by custom messages)
float fov; // horizontal field of view
@ -320,12 +303,11 @@ typedef struct dll_info_s
const char *entry; // entrypoint name (internal libs only)
void *link; // hinstance of loading library
// xash dlls entrypoint
// xash interface
void *(*main)( void*, void* );
bool crash; // crash if dll not found
// xash dlls validator
size_t api_size; // generic interface size
size_t api_size; // interface size
} dll_info_t;
@ -421,6 +403,7 @@ enum dev_level
D_LOAD, // "-dev 4", show messages about loading resources
D_NOTE, // "-dev 5", show system notifications for engine develeopers
D_MEMORY, // "-dev 6", show memory allocation
D_STRING, // "-dev 7", show tempstrings allocation
};
/*
@ -845,10 +828,6 @@ stdlib function names that not across with windows stdlib
*/
#define timestamp com.timestamp
#define copystring( str ) com.stralloc( NULL, str, __FILE__, __LINE__ )
#define strcasecmp com.stricmp
#define strncasecmp com.strnicmp
#define strlower com.strlwr
#define stristr com.stristr
#define va com.va
#endif//LAUNCH_DLL

View File

@ -446,7 +446,6 @@ void GL_InitBackend( void )
glw_state.wndproc = ri.WndProc;
glw_state.hInst = GetModuleHandle( NULL );
r_temppool = Mem_AllocPool( "Render Memory" );
if( !r_framebuffer ) r_framebuffer = Z_Malloc( r_width->integer * r_height->integer * 3 );
// init tables
for( i = 0; i < 256; i++ ) r_turbsin[i] *= 0.5f;
@ -546,6 +545,7 @@ void GL_InitExtensions( void )
// initialize gl extensions
GL_CheckExtension( "OpenGL 1.1.0", opengl_110funcs, NULL, R_OPENGL_110 );
if( !r_framebuffer ) r_framebuffer = Z_Malloc( r_width->integer * r_height->integer * 3 );
// get our various GL strings
gl_config.vendor_string = pglGetString( GL_VENDOR );
@ -765,7 +765,7 @@ void GL_TextureMode( char *string )
for (i=0 ; i< NUM_GL_MODES ; i++)
{
if ( !strcasecmp( modes[i].name, string ) )
if ( !com.stricmp( modes[i].name, string ) )
break;
}
@ -801,7 +801,7 @@ void GL_TextureAlphaMode( char *string )
for (i=0 ; i< NUM_GL_ALPHA_MODES ; i++)
{
if ( !strcasecmp( gl_alpha_modes[i].name, string ) )
if ( !com.stricmp( gl_alpha_modes[i].name, string ) )
break;
}
@ -825,7 +825,7 @@ void GL_TextureSolidMode( char *string )
for (i=0 ; i< NUM_GL_SOLID_MODES ; i++)
{
if ( !strcasecmp( gl_solid_modes[i].name, string ) )
if ( !com.stricmp( gl_solid_modes[i].name, string ) )
break;
}

View File

@ -35,7 +35,7 @@ image_t *Draw_FindPic( const char *name )
size_t bufsize = 0;
//HACKHACK: use default font
if(stristr(name, "fonts" ))
if(com.stristr(name, "fonts" ))
buffer = FS_LoadInternal( "default.dds", &bufsize );
com.snprintf( fullname, MAX_STRING, "gfx/%s", name );

View File

@ -200,7 +200,7 @@ model_t *Mod_ForName(char *name, bool crash)
for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
{
if (!mod->name[0]) continue;
if (!strcmp (mod->name, name))
if (!com.strcmp (mod->name, name))
{
// prolonge registration
mod->registration_sequence = registration_sequence;
@ -233,7 +233,7 @@ model_t *Mod_ForName(char *name, bool crash)
return NULL;
}
mod->mempool = Mem_AllocPool(mod->name);
mod->mempool = Mem_AllocPool(va("^1%s", mod->name ));
loadmodel = mod;
@ -242,7 +242,7 @@ model_t *Mod_ForName(char *name, bool crash)
//
// call the apropriate loader
switch (LittleLong(*(unsigned *)buf))
switch (LittleLong(*(uint *)buf))
{
case IDBSPMODHEADER:
Mod_LoadBrushModel (mod, buf);
@ -878,7 +878,7 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer)
dheader_t *header;
loadmodel->type = mod_static;
loadmodel->type = mod_world;
if (loadmodel != mod_known)
{
Msg("Warning: loaded a brush model after the world\n");

View File

@ -981,7 +981,7 @@ int R_Init( void *hinstance )
R_StudioInit();
R_CheckForErrors();
return 1;
return true;
}
/*

View File

@ -107,7 +107,7 @@ Doom1
bool Conv_ShaderGetFlags1( const char *imagename, const char *shadername, const char *ext, int *flags, int *contents )
{
if(!com.strnicmp(imagename, "sky", 3 )) *flags |= SURF_SKY;
if(stristr(imagename, "lit" )) *flags |= SURF_LIGHT;
if(com.stristr(imagename, "lit" )) *flags |= SURF_LIGHT;
if(!com.strnicmp( "sw", imagename, 2 ))
{
@ -178,17 +178,17 @@ bool Conv_ShaderGetFlags2( const char *imagename, const char *shadername, const
// light definition
if(com.strchr(imagename, '~')) *flags |= SURF_LIGHT;
if(stristr( imagename, "water" ))
if(com.stristr( imagename, "water" ))
{
*contents |= CONTENTS_WATER;
*flags |= SURF_WARP; // liquids
}
else if(stristr( imagename, "slime" ))
else if(com.stristr( imagename, "slime" ))
{
*contents |= CONTENTS_SLIME;
*flags |= SURF_WARP; // liquids
}
else if(stristr( imagename, "lava" ))
else if(com.stristr( imagename, "lava" ))
{
*contents |= CONTENTS_LAVA;
*flags |= SURF_WARP; // liquids
@ -220,7 +220,7 @@ bool Conv_CreateShader( const char *name, rgbdata_t *pic, const char *ext, const
FS_FileBase( shadername, shadername ); // remove "textures" from path
FS_FileBase( name, imagename );
com.snprintf( shaderpath, MAX_STRING, "%s/scripts/shaders/%s.txt", gs_gamedir, shadername );
if(stristr(name, "textures")) com.snprintf( imagepath, MAX_STRING, "%s", name ); // full path
if(com.stristr(name, "textures")) com.snprintf( imagepath, MAX_STRING, "%s", name ); // full path
else com.snprintf( imagepath, MAX_STRING, "textures/%s", name ); // build full path
nextanimchain[0] = 0; // clear chain
@ -229,7 +229,7 @@ bool Conv_CreateShader( const char *name, rgbdata_t *pic, const char *ext, const
flags |= surf; // .wal can transmit flags here
contents |= cnt;
if(!strnicmp(ext, "flt", 3 )) // doom definitions
if(!com.strnicmp(ext, "flt", 3 )) // doom definitions
Conv_ShaderGetFlags1( imagename, shadername, ext, &flags, &contents );
else Conv_ShaderGetFlags2( imagename, shadername, ext, &flags, &contents );

View File

@ -10,9 +10,6 @@ SprExplorer
fopen завешивает приложение, при попытке создать файл в несуществующей директории. Ну вылетал бы чтоли, или ошибку
возвращал.
Замеченные баги:
0. viewer ничего не пишет в лог (сцуко)
Отложенные задачи:
1. Поддержка loop для ogg vorbis
2. dpvencoder в common.dll
@ -21,14 +18,10 @@ fopen
Текущие задачи:
0. Исправить отрисовку bbox
1. Нормальная линковка OpenGL32.dll OK
2. Убить лишние расширения OK
3. Навести порядок в public OK
4. Навести порядок в basetypes.h OK
5. Собрать все ресурсы в builtin.h OK
6. r_backend.c
1. Настроить время на сервере
2. Server 60 FPS
3. cl.time синхронизировать с sv.time
0. Новый сетевой протоколб смена entity_state_t
Физика игрока:
1. Убрать отскоки от стен

View File

@ -144,9 +144,9 @@ void GUI_AddMenuItem( HMENU menu, const char *name, uint itemId, uint hotkey )
int length = strlen(name) - 1;
//parse modifiers
if (stristr (name, "ctrl")) style |= FCONTROL;
if (stristr (name, "shift")) style |= FSHIFT;
if (stristr (name, "alt")) style |= FALT;
if (com.stristr (name, "ctrl")) style |= FCONTROL;
if (com.stristr (name, "shift")) style |= FSHIFT;
if (com.stristr (name, "alt")) style |= FALT;
GUI_AddAccelerator(hotkey, style, itemId);
}

View File

@ -1918,7 +1918,7 @@ int PRVM_SetEngineString( const char *s )
if (vm.prog->knownstrings[i] == s)
return -1 - i;
// new unknown engine string
MsgDev(D_MEMORY, "new engine string %p\n", s );
MsgDev(D_STRING, "new engine string %p\n", s );
for (i = vm.prog->firstfreeknownstring;i < vm.prog->numknownstrings;i++)
if (!vm.prog->knownstrings[i])
break;
@ -1961,7 +1961,7 @@ int PRVM_SetTempString( const char *s )
if (!s) return 0;
size = (int)com.strlen(s) + 1;
MsgDev( D_MEMORY, "PRVM_SetTempString: cursize %i, size %i\n", vm_tempstringsbuf.cursize, size);
MsgDev( D_STRING, "PRVM_SetTempString: cursize %i, size %i\n", vm_tempstringsbuf.cursize, size);
if (vm_tempstringsbuf.maxsize < vm_tempstringsbuf.cursize + size)
{
size_t old_maxsize = vm_tempstringsbuf.maxsize;