diff --git a/common/features.h b/common/features.h index b33fe12b..83b98392 100644 --- a/common/features.h +++ b/common/features.h @@ -23,7 +23,7 @@ GNU General Public License for more details. #define ENGINE_PHYSICS_PUSHER_EXT (1<<3) // enable sets of improvements for MOVETYPE_PUSH physics #define ENGINE_LARGE_LIGHTMAPS (1<<4) // change lightmap sizes from 128x128 to 1024x1024 #define ENGINE_COMPENSATE_QUAKE_BUG (1<<5) // compensate stupid quake bug (inverse pitch) for mods where this bug is fixed -// reserved +#define ENGINE_IMPROVED_LINETRACE (1<<6) // new traceline that tracing through alphatextures #define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine #endif//FEATURES_H \ No newline at end of file diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index da7518e8..f52c14e9 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -3124,6 +3124,7 @@ void TriFog( float flFogColor[3], float flStart, float flEnd, int bOn ) // check for invalid parms if( flEnd <= flStart ) { + glState.isFogEnabled = false; RI.fogCustom = false; pglDisable( GL_FOG ); return; diff --git a/engine/client/cl_gameui.c b/engine/client/cl_gameui.c index 022f1179..3a191782 100644 --- a/engine/client/cl_gameui.c +++ b/engine/client/cl_gameui.c @@ -378,7 +378,7 @@ static HIMAGE pfnPIC_Load( const char *szPicName, const byte *image_buf, long im { HIMAGE tx; - if( !szPicName || !*szPicName ) + if( !COM_CheckString( szPicName )) { Con_Reportf( S_ERROR "CL_LoadImage: bad name!\n" ); return 0; diff --git a/engine/client/gl_local.h b/engine/client/gl_local.h index da3f866d..e372b58e 100644 --- a/engine/client/gl_local.h +++ b/engine/client/gl_local.h @@ -612,6 +612,7 @@ typedef struct GLboolean texIdentityMatrix[MAX_TEXTURE_UNITS]; GLint genSTEnabled[MAX_TEXTURE_UNITS]; // 0 - disabled, OR 1 - S, OR 2 - T, OR 4 - R GLint texCoordArrayMode[MAX_TEXTURE_UNITS]; // 0 - disabled, 1 - enabled, 2 - cubemap + GLint isFogEnabled; int faceCull; diff --git a/engine/client/gl_rmain.c b/engine/client/gl_rmain.c index f84009c7..dd60704f 100644 --- a/engine/client/gl_rmain.c +++ b/engine/client/gl_rmain.c @@ -43,18 +43,14 @@ static int R_RankForRenderMode( int rendermode ) void R_AllowFog( int allowed ) { - static int isFogEnabled; - if( allowed ) { - if( isFogEnabled ) + if( glState.isFogEnabled ) pglEnable( GL_FOG ); } else { - isFogEnabled = pglIsEnabled( GL_FOG ); - - if( isFogEnabled ) + if( glState.isFogEnabled ) pglDisable( GL_FOG ); } } @@ -487,6 +483,9 @@ static void R_SetupFrame( void ) // setup viewplane dist RI.viewplanedist = DotProduct( RI.vieworg, RI.vforward ); + // NOTE: this request is the fps-killer on some NVidia drivers + glState.isFogEnabled = pglIsEnabled( GL_FOG ); + if( !gl_nosort->value ) { // sort translucents entities by rendermode and distance @@ -690,7 +689,11 @@ static void R_CheckFog( void ) // in some cases waterlevel jumps from 3 to 1. Catch it RI.cached_waterlevel = cl.local.waterlevel; RI.cached_contents = CONTENTS_EMPTY; - if( !RI.fogCustom ) pglDisable( GL_FOG ); + if( !RI.fogCustom ) + { + glState.isFogEnabled = false; + pglDisable( GL_FOG ); + } } return; } diff --git a/engine/client/gl_rmisc.c b/engine/client/gl_rmisc.c index c19f5a62..afaa038f 100644 --- a/engine/client/gl_rmisc.c +++ b/engine/client/gl_rmisc.c @@ -178,6 +178,7 @@ void R_NewMap( void ) for( i = 0; i < cl.worldmodel->numleafs; i++ ) cl.worldmodel->leafs[i+1].efrags = NULL; + glState.isFogEnabled = false; tr.skytexturenum = -1; tr.max_recursion = 0; pglDisable( GL_FOG ); diff --git a/engine/client/gl_rsurf.c b/engine/client/gl_rsurf.c index 6c1b8338..aede8ea0 100644 --- a/engine/client/gl_rsurf.c +++ b/engine/client/gl_rsurf.c @@ -204,7 +204,7 @@ void GL_SetupFogColorForSurfaces( void ) vec3_t fogColor; float factor, div; - if( !pglIsEnabled( GL_FOG )) + if( !glState.isFogEnabled ) return; if( RI.currententity && RI.currententity->curstate.rendermode == kRenderTransTexture ) @@ -224,7 +224,7 @@ void GL_SetupFogColorForSurfaces( void ) void GL_ResetFogColor( void ) { // restore fog here - if( pglIsEnabled( GL_FOG )) + if( glState.isFogEnabled ) pglFogfv( GL_FOG_COLOR, RI.fogColor ); } @@ -1081,7 +1081,7 @@ void R_RenderBrushPoly( msurface_t *fa, int cull_type ) if( CVAR_TO_BOOL( r_detailtextures )) { - if( pglIsEnabled( GL_FOG )) + if( glState.isFogEnabled ) { // don't apply detail textures for windows in the fog if( RI.currententity->curstate.rendermode != kRenderTransTexture ) diff --git a/engine/client/gl_studio.c b/engine/client/gl_studio.c index 3ec7057d..ff2072e0 100644 --- a/engine/client/gl_studio.c +++ b/engine/client/gl_studio.c @@ -1553,8 +1553,6 @@ StudioCalcAttachments static void R_StudioCalcAttachments( void ) { mstudioattachment_t *pAtt; - vec3_t forward, bonepos; - vec3_t localOrg, localAng; int i; // calculate attachment points @@ -1563,11 +1561,6 @@ static void R_StudioCalcAttachments( void ) for( i = 0; i < Q_min( MAXSTUDIOATTACHMENTS, m_pStudioHeader->numattachments ); i++ ) { Matrix3x4_VectorTransform( g_studio.lighttransform[pAtt[i].bone], pAtt[i].org, RI.currententity->attachment[i] ); - VectorSubtract( RI.currententity->attachment[i], RI.currententity->origin, localOrg ); - Matrix3x4_OriginFromMatrix( g_studio.lighttransform[pAtt[i].bone], bonepos ); - VectorSubtract( localOrg, bonepos, forward ); // make forward - VectorNormalizeFast( forward ); - VectorAngles( forward, localAng ); } } @@ -3803,7 +3796,7 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture ptexture->index = (int)((byte *)phdr) + ptexture->index; size = sizeof( mstudiotexture_t ) + ptexture->width * ptexture->height + 768; - if( FBitSet( host.features, ENGINE_LOAD_DELUXEDATA ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED )) + if( FBitSet( host.features, ENGINE_IMPROVED_LINETRACE ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED )) flags |= TF_KEEP_SOURCE; // Paranoia2 texture alpha-tracing // build the texname diff --git a/engine/common/cmd.c b/engine/common/cmd.c index 8645f992..e1df2a7b 100644 --- a/engine/common/cmd.c +++ b/engine/common/cmd.c @@ -976,9 +976,8 @@ void Cmd_ExecuteString( char *text ) { Cmd_ForwardToServer(); } - else if( text[0] != '@' && Cvar_VariableInteger( "host_gameloaded" )) + else if( Cvar_VariableInteger( "host_gameloaded" )) { - // commands with leading '@' are hidden system commands Con_Printf( S_WARN "Unknown command \"%s\"\n", text ); } } diff --git a/engine/common/common.c b/engine/common/common.c index b2bf432e..dfa37bf5 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -22,16 +22,16 @@ GNU General Public License for more details. const char *file_exts[10] = { - ".cfg", - ".lst", - ".exe", - ".vbs", - ".com", - ".bat", - ".dll", - ".ini", - ".log", - ".sys", + "cfg", + "lst", + "exe", + "vbs", + "com", + "bat", + "dll", + "ini", + "log", + "sys", }; #ifdef _DEBUG diff --git a/engine/common/common.h b/engine/common/common.h index a0164229..650f53e2 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -891,7 +891,6 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float void SV_StartMusic( const char *curtrack, const char *looptrack, long position ); void SV_CreateDecal( struct sizebuf_s *msg, const float *origin, int decalIndex, int entityIndex, int modelIndex, int flags, float scale ); void Log_Printf( const char *fmt, ... ); -struct sizebuf_s *SV_GetReliableDatagram( void ); void SV_BroadcastCommand( const char *fmt, ... ); qboolean SV_RestoreCustomDecal( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent ); void SV_BroadcastPrintf( struct sv_client_s *ignore, char *fmt, ... ); diff --git a/engine/common/console.c b/engine/common/console.c index e4b07314..585c48a6 100644 --- a/engine/common/console.c +++ b/engine/common/console.c @@ -154,7 +154,7 @@ void Con_SetColor_f( void ) { vec3_t color; - switch( Cmd_Argc() ) + switch( Cmd_Argc( )) { case 1: Con_Printf( "\"con_color\" is %i %i %i\n", g_color_table[7][0], g_color_table[7][1], g_color_table[7][2] ); diff --git a/engine/common/host.c b/engine/common/host.c index fba8efcd..8b12125f 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -411,6 +411,7 @@ double Host_CalcFPS( void ) else { fps = host_maxfps->value; + if( fps == 0.0 ) fps = MAX_FPS; fps = bound( MIN_FPS, fps, MAX_FPS ); } diff --git a/engine/common/mod_bmodel.c b/engine/common/mod_bmodel.c index ee48efd3..99fe8c83 100644 --- a/engine/common/mod_bmodel.c +++ b/engine/common/mod_bmodel.c @@ -1632,7 +1632,7 @@ static void Mod_LoadEntities( dbspmodel_t *bmod ) { byte *entpatch = NULL; char token[MAX_TOKEN]; - char wadstring[2048]; + char wadstring[MAX_TOKEN]; string keyname; char *pfile; @@ -1640,7 +1640,7 @@ static void Mod_LoadEntities( dbspmodel_t *bmod ) { char entfilename[MAX_QPATH]; long entpatchsize; - size_t ft1, ft2; + long ft1, ft2; // world is check for entfile too Q_strncpy( entfilename, loadmodel->name, sizeof( entfilename )); @@ -1960,7 +1960,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) tx->width = mt->width; tx->height = mt->height; - if( FBitSet( host.features, ENGINE_LOAD_DELUXEDATA ) && mt->name[0] == '{' ) + if( FBitSet( host.features, ENGINE_IMPROVED_LINETRACE ) && mt->name[0] == '{' ) SetBits( txFlags, TF_KEEP_SOURCE ); // Paranoia2 texture alpha-tracing if( mt->offsets[0] > 0 ) diff --git a/engine/common/mod_studio.c b/engine/common/mod_studio.c index 2da5a4ba..d9deee58 100644 --- a/engine/common/mod_studio.c +++ b/engine/common/mod_studio.c @@ -507,6 +507,8 @@ void Mod_StudioGetAttachment( const edict_t *e, int iAtt, float *origin, float * { mstudioattachment_t *pAtt; vec3_t angles2; + matrix3x4 localPose; + matrix3x4 worldPose; model_t *mod; mod = SV_ModelHandle( e->v.modelindex ); @@ -534,19 +536,15 @@ void Mod_StudioGetAttachment( const edict_t *e, int iAtt, float *origin, float * pBlendAPI->SV_StudioSetupBones( mod, e->v.frame, e->v.sequence, angles2, e->v.origin, e->v.controller, e->v.blending, pAtt->bone, e ); - // compute pos and angles - if( origin != NULL ) - Matrix3x4_VectorTransform( studio_bones[pAtt->bone], pAtt->org, origin ); + Matrix3x4_LoadIdentity( localPose ); + Matrix3x4_SetOrigin( localPose, pAtt->org[0], pAtt->org[1], pAtt->org[2] ); + Matrix3x4_ConcatTransforms( worldPose, studio_bones[pAtt->bone], localPose ); - if( FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ) && origin != NULL && angles != NULL ) - { - vec3_t forward, bonepos; + if( origin != NULL ) // origin is used always + Matrix3x4_OriginFromMatrix( worldPose, origin ); - Matrix3x4_OriginFromMatrix( studio_bones[pAtt->bone], bonepos ); - VectorSubtract( origin, bonepos, forward ); // make forward - VectorNormalizeFast( forward ); - VectorAngles( forward, angles ); - } + if( FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ) && angles != NULL ) + Matrix3x4_AnglesFromMatrix( worldPose, angles ); } /* @@ -565,7 +563,7 @@ void Mod_GetBonePosition( const edict_t *e, int iBone, float *origin, float *ang pBlendAPI->SV_StudioSetupBones( mod, e->v.frame, e->v.sequence, e->v.angles, e->v.origin, e->v.controller, e->v.blending, iBone, e ); if( origin ) Matrix3x4_OriginFromMatrix( studio_bones[iBone], origin ); - if( angles ) VectorAngles( studio_bones[iBone][0], angles ); // bone forward to angles + if( angles ) Matrix3x4_AnglesFromMatrix( studio_bones[iBone], angles ); } /* diff --git a/engine/common/model.c b/engine/common/model.c index adee5d08..64757c1b 100644 --- a/engine/common/model.c +++ b/engine/common/model.c @@ -137,6 +137,11 @@ static void Mod_FreeModel( model_t *mod ) =============================================================================== */ +/* +================ +Mod_Init +================ +*/ void Mod_Init( void ) { com_studiocache = Mem_AllocPool( "Studio Cache" ); diff --git a/engine/common/net_buffer.c b/engine/common/net_buffer.c index 6ba6090d..91a56817 100644 --- a/engine/common/net_buffer.c +++ b/engine/common/net_buffer.c @@ -616,7 +616,6 @@ void MSG_ReadVec3Angles( sizebuf_t *sb, vec3_t fa ) fa[2] = MSG_ReadBitAngle( sb, 16 ); } - long MSG_ReadLong( sizebuf_t *sb ) { return MSG_ReadSBitLong( sb, sizeof( long ) << 3 ); diff --git a/engine/common/net_encode.c b/engine/common/net_encode.c index eedda99f..f1552643 100644 --- a/engine/common/net_encode.c +++ b/engine/common/net_encode.c @@ -308,7 +308,7 @@ delta_info_t *Delta_FindStruct( const char *name ) { int i; - if( !name || !name[0] ) + if( !COM_CheckString( name )) return NULL; for( i = 0; i < NUM_FIELDS( dt_info ); i++ ) @@ -427,8 +427,12 @@ qboolean Delta_AddField( const char *pStructName, const char *pName, int flags, { if( !Q_strcmp( pField->name, pName )) { - Con_Reportf( "Delta_Add: %s->%s already existing\n", pStructName, pName ); - return false; // field already exist + // update existed field + pField->flags = flags; + pField->bits = bits; + pField->multiplier = mul; + pField->post_multiplier = post_mul; + return true; } } @@ -470,7 +474,7 @@ void Delta_WriteTableField( sizebuf_t *msg, int tableIndex, const delta_t *pFiel Assert( pField != NULL ); - if( !pField->name || !*pField->name ) + if( !COM_CheckString( pField->name )) return; // not initialized ? dt = Delta_FindStructByIndex( tableIndex ); @@ -480,7 +484,7 @@ void Delta_WriteTableField( sizebuf_t *msg, int tableIndex, const delta_t *pFiel Assert( nameIndex >= 0 && nameIndex < dt->maxFields ); MSG_BeginServerCmd( msg, svc_deltatable ); - MSG_WriteUBitLong( msg, tableIndex, 4 ); // assume we support 16 network tables + MSG_WriteUBitLong( msg, tableIndex, 4 ); // assume we support 16 network tables MSG_WriteUBitLong( msg, nameIndex, 8 ); // 255 fields by struct should be enough MSG_WriteUBitLong( msg, pField->flags, 10 ); // flags are indicated various input types MSG_WriteUBitLong( msg, pField->bits - 1, 5 ); // max received value is 32 (32 bit) @@ -526,10 +530,10 @@ void Delta_ParseTableField( sizebuf_t *msg ) if( MSG_ReadOneBit( msg )) post_mul = MSG_ReadFloat( msg ); - +#if 0 // delta encoders it's already initialized on this machine (local game) if( delta_init ) return; - +#endif // add field to table Delta_AddField( dt->pName, pName, flags, bits, mul, post_mul ); } @@ -610,7 +614,6 @@ qboolean Delta_ParseField( char **delta_script, const delta_field_t *pInfo, delt } // read delta-bits - if(( *delta_script = COM_ParseFile( *delta_script, token )) == NULL ) { Con_DPrintf( S_ERROR "Delta_ReadField: %s field bits argument is missing\n", pField->name ); @@ -765,13 +768,8 @@ void Delta_InitFields( void ) Delta_ParseTable( &pfile, dt, encodeDll, encodeFunc ); } + Mem_Free( afile ); -#if 0 - // adding some required fields that user may forget or don't know how to specified - Delta_AddField( "event_t", "velocity[0]", DT_SIGNED | DT_FLOAT, 16, 8.0f, 1.0f ); - Delta_AddField( "event_t", "velocity[1]", DT_SIGNED | DT_FLOAT, 16, 8.0f, 1.0f ); - Delta_AddField( "event_t", "velocity[2]", DT_SIGNED | DT_FLOAT, 16, 8.0f, 1.0f ); -#endif } void Delta_Init( void ) @@ -1193,7 +1191,7 @@ qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to else if( pField->flags & DT_TIMEWINDOW_8 ) { flValue = *(float *)((byte *)to + pField->offset ); - flTime = Q_rint( timebase * 100.0f ) - Q_rint(flValue * 100.0f); + flTime = Q_rint( timebase * 100.0f ) - Q_rint( flValue * 100.0f ); iValue = (uint)abs( flTime ); MSG_WriteBitLong( msg, iValue, pField->bits, bSigned ); diff --git a/engine/common/netchan.h b/engine/common/netchan.h index 8db97a49..af8b4495 100644 --- a/engine/common/netchan.h +++ b/engine/common/netchan.h @@ -58,10 +58,10 @@ GNU General Public License for more details. // { // byte (on/off) // int (fragment id) -// short (startpos) -// short (length) +// int (startpos) +// int (length) // } -#define HEADER_BYTES ( 8 + MAX_STREAMS * 9 ) +#define HEADER_BYTES ( 8 + MAX_STREAMS * 13 ) // Pad this to next higher 16 byte boundary // This is the largest packet that can come in/out over the wire, before processing the header diff --git a/engine/common/zone.c b/engine/common/zone.c index c36388c8..3d5961e5 100644 --- a/engine/common/zone.c +++ b/engine/common/zone.c @@ -256,7 +256,7 @@ qboolean Mem_IsAllocatedExt( byte *poolptr, void *data ) void Mem_CheckHeaderSentinels( void *data, const char *filename, int fileline ) { - memheader_t *mem; + memheader_t *mem; if( data == NULL ) Sys_Error( "Mem_CheckSentinels: data == NULL (sentinel check at %s:%i)\n", filename, fileline ); @@ -269,7 +269,7 @@ void Mem_CheckHeaderSentinels( void *data, const char *filename, int fileline ) Sys_Error( "Mem_CheckSentinels: trashed header sentinel 1 (block allocated at %s:%i, sentinel check at %s:%i)\n", mem->filename, mem->fileline, filename, fileline ); } - if( *((byte *) mem + sizeof(memheader_t) + mem->size) != MEMHEADER_SENTINEL2 ) + if( *((byte *)mem + sizeof(memheader_t) + mem->size) != MEMHEADER_SENTINEL2 ) { mem->filename = Mem_CheckFilename( mem->filename ); // make sure what we don't crash var_args 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 ); diff --git a/engine/server/server.h b/engine/server/server.h index 1b84a366..aad464b2 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -263,7 +263,6 @@ typedef struct sv_client_s a program error, like an overflowed reliable buffer ============================================================================= */ - // MAX_CHALLENGES is made large to prevent a denial // of service attack that could cycle all of them // out before legitimate users connected diff --git a/engine/server/sv_cmds.c b/engine/server/sv_cmds.c index 996fa4c5..d205bec8 100644 --- a/engine/server/sv_cmds.c +++ b/engine/server/sv_cmds.c @@ -869,6 +869,7 @@ void SV_EntityInfo_f( void ) Con_Printf( "\n" ); } } + /* ================== SV_InitHostCommands diff --git a/engine/server/sv_frame.c b/engine/server/sv_frame.c index 9af9a4ae..2309ebc2 100644 --- a/engine/server/sv_frame.c +++ b/engine/server/sv_frame.c @@ -155,7 +155,7 @@ static void SV_AddEntitiesToPacket( edict_t *pViewEnt, edict_t *pClient, client_ if( fullvis ) continue; // portal ents will be added anyway, ignore recursion - // if its a portal entity, add everything visible from its camera position + // if it's a portal entity, add everything visible from its camera position if( from_client && FBitSet( ent->v.effects, EF_MERGE_VISIBILITY )) { SetBits( sv.hostflags, SVF_MERGE_VISIBILITY ); @@ -658,7 +658,7 @@ void SV_WriteEntitiesToClient( sv_client_t *cl, sizebuf_t *msg ) if( c_notsend > 0 ) Con_Printf( S_ERROR "Too many entities in visible packet list. Ignored %d entities\n", c_notsend ); cl->ignored_ents = c_notsend; - } + } // if there were portals visible, there may be out of order entities // in the list which will need to be resorted for the delta compression @@ -809,33 +809,18 @@ void SV_UpdateToReliableMessages( void ) continue; // reliables go to all connected or spawned if( MSG_GetNumBytesWritten( &sv.reliable_datagram ) < MSG_GetNumBytesLeft( &cl->netchan.message )) - { MSG_WriteBits( &cl->netchan.message, MSG_GetBuf( &sv.reliable_datagram ), MSG_GetNumBitsWritten( &sv.reliable_datagram )); - } - else - { - Netchan_CreateFragments( &cl->netchan, &sv.reliable_datagram ); - } + else Netchan_CreateFragments( &cl->netchan, &sv.reliable_datagram ); if( MSG_GetNumBytesWritten( &sv.datagram ) < MSG_GetNumBytesLeft( &cl->datagram )) - { MSG_WriteBits( &cl->datagram, MSG_GetBuf( &sv.datagram ), MSG_GetNumBitsWritten( &sv.datagram )); - } - else - { - Con_DPrintf( S_WARN "Ignoring unreliable datagram for %s, would overflow\n", cl->name ); - } + else Con_DPrintf( S_WARN "Ignoring unreliable datagram for %s, would overflow\n", cl->name ); if( FBitSet( cl->flags, FCL_HLTV_PROXY )) { if( MSG_GetNumBytesWritten( &sv.spec_datagram ) < MSG_GetNumBytesLeft( &cl->datagram )) - { MSG_WriteBits( &cl->datagram, MSG_GetBuf( &sv.spec_datagram ), MSG_GetNumBitsWritten( &sv.spec_datagram )); - } - else - { - Con_DPrintf( S_WARN "Ignoring spectator datagram for %s, would overflow\n", cl->name ); - } + else Con_DPrintf( S_WARN "Ignoring spectator datagram for %s, would overflow\n", cl->name ); } } diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index 766c3aad..9b851e54 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -752,18 +752,18 @@ Create entity patch for selected map */ void SV_WriteEntityPatch( const char *filename ) { - int ver = -1, lumpofs = 0, lumplen = 0; - byte buf[MAX_SYSPATH]; // 1 kb + int lumpofs = 0, lumplen = 0; + byte buf[MAX_TOKEN]; // 1 kb string bspfilename; dheader_t *header; file_t *f; - Q_strncpy( bspfilename, va( "maps/%s.bsp", filename ), sizeof( bspfilename )); + Q_strncpy( bspfilename, va( "maps/%s.bsp", filename ), sizeof( bspfilename )); f = FS_Open( bspfilename, "rb", false ); if( !f ) return; - memset( buf, 0, MAX_SYSPATH ); - FS_Read( f, buf, MAX_SYSPATH ); + memset( buf, 0, MAX_TOKEN ); + FS_Read( f, buf, MAX_TOKEN ); header = (dheader_t *)buf; // check all the lumps and some other errors @@ -801,9 +801,9 @@ pfnMapIsValid use this static char *SV_ReadEntityScript( const char *filename, int *flags ) { string bspfilename, entfilename; - int ver = -1, lumpofs = 0, lumplen = 0; + int lumpofs = 0, lumplen = 0; + byte buf[MAX_TOKEN]; char *ents = NULL; - byte buf[1024]; dheader_t *header; size_t ft1, ft2; file_t *f; @@ -815,8 +815,8 @@ static char *SV_ReadEntityScript( const char *filename, int *flags ) if( !f ) return NULL; SetBits( *flags, MAP_IS_EXIST ); - memset( buf, 0, MAX_SYSPATH ); - FS_Read( f, buf, MAX_SYSPATH ); + memset( buf, 0, MAX_TOKEN ); + FS_Read( f, buf, MAX_TOKEN ); header = (dheader_t *)buf; // check all the lumps and some other errors @@ -834,7 +834,7 @@ static char *SV_ReadEntityScript( const char *filename, int *flags ) // check for entfile too Q_strncpy( entfilename, va( "maps/%s.ent", filename ), sizeof( entfilename )); - // make sure what entity patch is never than bsp + // make sure what entity patch is newer than bsp ft1 = FS_FileTime( bspfilename, false ); ft2 = FS_FileTime( entfilename, true ); @@ -875,7 +875,7 @@ int SV_MapIsValid( const char *filename, const char *spawn_entity, const char *l if( ents ) { qboolean need_landmark = Q_strlen( landmark_name ) > 0 ? true : false; - char token[2048]; + char token[MAX_TOKEN]; string check_name; // g-cont. in-dev mode we can entering on map even without "info_player_start" @@ -1280,6 +1280,7 @@ pfnSetModel void pfnSetModel( edict_t *e, const char *m ) { char name[MAX_QPATH]; + qboolean found = false; model_t *mod; int i; @@ -1296,10 +1297,13 @@ void pfnSetModel( edict_t *e, const char *m ) for( i = 1; i < MAX_MODELS && sv.model_precache[i][0]; i++ ) { if( !Q_stricmp( sv.model_precache[i], name )) + { + found = true; break; + } } - if( i == MAX_MODELS ) + if( !found ) { Con_Printf( S_ERROR "no precache: %s\n", name ); return; @@ -2780,7 +2784,7 @@ void pfnWriteString( const char *src ) { static char string[MAX_USERMSG_LENGTH]; int len = Q_strlen( src ) + 1; - int rem = rem = sizeof( string ) - 1; + int rem = sizeof( string ) - 1; char *dst; if( len == 1 ) diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index a59d7b08..aacd07a4 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -135,7 +135,6 @@ int SV_SoundIndex( const char *filename ) char name[MAX_QPATH]; int i; - // don't precache sentence names! if( !COM_CheckString( filename )) return 0; @@ -263,7 +262,7 @@ int SV_GenericIndex( const char *filename ) ================ SV_ModelHandle -register unique model for a server and client +get model by handle ================ */ model_t *SV_ModelHandle( int modelindex ) @@ -273,6 +272,13 @@ model_t *SV_ModelHandle( int modelindex ) return sv.models[modelindex]; } +/* +================ +SV_CreateGenericResources + +loads external resource list +================ +*/ void SV_CreateGenericResources( void ) { string filename, token; @@ -303,6 +309,13 @@ void SV_CreateGenericResources( void ) Mem_Free( afile ); } +/* +================ +SV_CreateResourceList + +add resources to common list +================ +*/ void SV_CreateResourceList( void ) { qboolean ffirstsent = false; diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index a9f56e71..19de4a46 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -260,6 +260,13 @@ void SV_CheckCmdTimes( void ) } } +/* +================= +SV_ProcessFile + +process incoming file (customization) +================= +*/ void SV_ProcessFile( sv_client_t *cl, const char *filename ) { customization_t *pList; @@ -548,11 +555,6 @@ qboolean SV_IsSimulating( void ) return false; } -/* -================= -SV_RunGameFrame -================= -*/ /* ================= SV_RunGameFrame @@ -874,7 +876,7 @@ to totally exit after returning from this function. */ void SV_FinalMessage( const char *message, qboolean reconnect ) { - byte msg_buf[64]; + byte msg_buf[1024]; sv_client_t *cl; sizebuf_t msg; int i; diff --git a/engine/server/sv_pmove.c b/engine/server/sv_pmove.c index 7a4bbe89..d3671d9b 100644 --- a/engine/server/sv_pmove.c +++ b/engine/server/sv_pmove.c @@ -304,7 +304,7 @@ void SV_AddLaddersToPmove( areanode_t *node, const vec3_t pmove_mins, const vec3 model_t *mod; physent_t *pe; - // get water edicts + // get ladder edicts for( l = node->solid_edicts.next; l != &node->solid_edicts; l = next ) { next = l->next; @@ -760,11 +760,11 @@ static void SV_FinishPMove( playermove_t *pmove, sv_client_t *cl ) if( pmove->onground == -1 ) { - clent->v.flags &= ~FL_ONGROUND; + ClearBits( clent->v.flags, FL_ONGROUND ); } else if( pmove->onground >= 0 && pmove->onground < pmove->numphysent ) { - clent->v.flags |= FL_ONGROUND; + SetBits( clent->v.flags, FL_ONGROUND ); clent->v.groundentity = EDICT_NUM( pmove->physents[pmove->onground].info ); } @@ -885,10 +885,7 @@ void SV_SetupMoveInterpolant( sv_client_t *cl ) if( SV_UnlagCheckTeleport( state->origin, lerp->finalpos )) lerp->nointerp = true; } - else - { - lerp->firstframe = true; - } + else lerp->firstframe = true; VectorCopy( state->origin, lerp->finalpos ); } @@ -986,10 +983,10 @@ void SV_RestoreMoveInterpolant( sv_client_t *cl ) oldlerp = &svgame.interp[i]; - if( VectorCompare( oldlerp->oldpos, oldlerp->newpos ) || !oldlerp->moving ) + if( VectorCompareEpsilon( oldlerp->oldpos, oldlerp->newpos, ON_EPSILON )) continue; // they didn't actually move. - if( !oldlerp->active ) + if( !oldlerp->moving || !oldlerp->active ) continue; if( VectorCompare( oldlerp->curpos, check->edict->v.origin )) @@ -1039,9 +1036,7 @@ void SV_RunCmd( sv_client_t *cl, usercmd_t *ucmd, int random_seed ) } if( !FBitSet( cl->flags, FCL_FAKECLIENT )) - { SV_SetupMoveInterpolant( cl ); - } svgame.dllFuncs.pfnCmdStart( cl->edict, ucmd, random_seed ); diff --git a/engine/server/sv_world.c b/engine/server/sv_world.c index 1a30f1f1..0d3fa050 100644 --- a/engine/server/sv_world.c +++ b/engine/server/sv_world.c @@ -1113,6 +1113,7 @@ or custom physics implementation */ void SV_CustomClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, trace_t *trace ) { + // initialize custom trace memset( trace, 0, sizeof( trace_t )); VectorCopy( end, trace->endpos ); trace->allsolid = true; @@ -1256,7 +1257,7 @@ static void SV_ClipToLinks( areanode_t *node, moveclip_t *clip ) if( !SV_ClipToEntity( touch, clip )) return; // trace.allsoild } - + // recurse down both sides if( node->axis == -1 ) return; @@ -1288,7 +1289,7 @@ static void SV_ClipToPortals( areanode_t *node, moveclip_t *clip ) if( !SV_ClipToEntity( touch, clip )) return; // trace.allsoild } - + // recurse down both sides if( node->axis == -1 ) return;