From 0154fe4aa232fa3b9686ce25d651c32b49767544 Mon Sep 17 00:00:00 2001 From: g-cont Date: Sat, 27 Feb 2016 00:00:00 +0300 Subject: [PATCH] 27 Feb 2016 --- engine/client/cl_frame.c | 10 ++-------- engine/client/cl_main.c | 4 ++-- engine/client/cl_pmove.c | 35 +++++++++++++++++++---------------- engine/common/common.h | 2 +- engine/common/crclib.c | 4 ++-- engine/common/mod_local.h | 2 +- engine/common/model.c | 9 ++++++--- engine/common/net_encode.c | 10 +++++----- engine/server/sv_client.c | 4 ++-- engine/server/sv_init.c | 2 +- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/engine/client/cl_frame.c b/engine/client/cl_frame.c index 174aa465..7f4d6e26 100644 --- a/engine/client/cl_frame.c +++ b/engine/client/cl_frame.c @@ -574,8 +574,8 @@ void CL_UpdateStudioVars( cl_entity_t *ent, entity_state_t *newstate, qboolean n { // client got new packet, shuffle animtimes ent->latched.prevanimtime = ent->curstate.animtime; - VectorCopy( newstate->origin, ent->latched.prevorigin ); - VectorCopy( newstate->angles, ent->latched.prevangles ); + VectorCopy( ent->curstate.origin, ent->latched.prevorigin ); + VectorCopy( ent->curstate.angles, ent->latched.prevangles ); for( i = 0; i < 4; i++ ) ent->latched.prevcontroller[i] = newstate->controller[i]; @@ -591,12 +591,6 @@ void CL_UpdateStudioVars( cl_entity_t *ent, entity_state_t *newstate, qboolean n // copy blends for( i = 0; i < 2; i++ ) ent->latched.prevblending[i] = ent->curstate.blending[i]; - - if( !VectorCompare( newstate->origin, ent->curstate.origin )) - VectorCopy( ent->curstate.origin, ent->latched.prevorigin ); - - if( !VectorCompare( newstate->angles, ent->curstate.angles )) - VectorCopy( ent->curstate.angles, ent->latched.prevangles ); } /* diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index a099f54c..73106a87 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1155,7 +1155,7 @@ void CL_PrepVideo( void ) // let the render dll load the map Q_strncpy( mapname, cl.model_precache[1], MAX_STRING ); - Mod_LoadWorld( mapname, &map_checksum, false ); + Mod_LoadWorld( mapname, &map_checksum, cl.maxclients > 1 ); cl.worldmodel = Mod_Handle( 1 ); // get world pointer Cvar_SetFloat( "scr_loading", 25.0f ); @@ -1616,8 +1616,8 @@ void CL_InitLocal( void ) // userinfo Cvar_Get( "password", "", CVAR_USERINFO, "player password" ); - name = Cvar_Get( "name", Sys_GetCurrentUser(), CVAR_USERINFO|CVAR_ARCHIVE|CVAR_PRINTABLEONLY, "player name" ); model = Cvar_Get( "model", "player", CVAR_USERINFO|CVAR_ARCHIVE, "player model ('player' is a singleplayer model)" ); + name = Cvar_Get( "name", Sys_GetCurrentUser(), CVAR_USERINFO|CVAR_ARCHIVE|CVAR_PRINTABLEONLY, "player name" ); topcolor = Cvar_Get( "topcolor", "0", CVAR_USERINFO|CVAR_ARCHIVE, "player top color" ); bottomcolor = Cvar_Get( "bottomcolor", "0", CVAR_USERINFO|CVAR_ARCHIVE, "player bottom color" ); rate = Cvar_Get( "rate", "25000", CVAR_USERINFO|CVAR_ARCHIVE, "player network rate" ); diff --git a/engine/client/cl_pmove.c b/engine/client/cl_pmove.c index ca90908f..90f7d1c1 100644 --- a/engine/client/cl_pmove.c +++ b/engine/client/cl_pmove.c @@ -762,13 +762,14 @@ void CL_RunUsercmd( local_state_t *from, local_state_t *to, usercmd_t *u, qboole pmove->watertype = fcd->watertype; pmove->onground = fcd->flags & FL_ONGROUND; pmove->deadflag = fcd->deadflag; - VectorCopy(fcd->velocity, pmove->velocity); - VectorCopy(fcd->view_ofs, pmove->view_ofs); - VectorCopy(fs->origin, pmove->origin); - VectorCopy(fs->basevelocity, pmove->basevelocity); - VectorCopy(fcd->punchangle, pmove->punchangle); - VectorCopy(fs->angles, pmove->angles); - VectorCopy(fs->angles, pmove->oldangles); + VectorCopy( fcd->velocity, pmove->velocity ); + VectorCopy( fcd->view_ofs, pmove->view_ofs ); + VectorCopy( fs->origin, pmove->origin ); + VectorCopy( fs->basevelocity, pmove->basevelocity ); + VectorCopy( fcd->punchangle, pmove->punchangle ); + VectorCopy( fs->angles, pmove->angles ); + pmove->angles[PITCH] = -( fs->angles[PITCH] * 3.0f ); // restore viewangle pitch + VectorCopy( pmove->angles, pmove->oldangles ); pmove->friction = fs->friction; pmove->usehull = fs->usehull; pmove->oldbuttons = fs->oldbuttons; @@ -791,10 +792,10 @@ void CL_RunUsercmd( local_state_t *from, local_state_t *to, usercmd_t *u, qboole pmove->fuser2 = fcd->fuser2; pmove->fuser3 = fcd->fuser3; pmove->fuser4 = fcd->fuser4; - VectorCopy(fcd->vuser1, pmove->vuser1); - VectorCopy(fcd->vuser2, pmove->vuser2); - VectorCopy(fcd->vuser3, pmove->vuser3); - VectorCopy(fcd->vuser4, pmove->vuser4); + VectorCopy( fcd->vuser1, pmove->vuser1 ); + VectorCopy( fcd->vuser2, pmove->vuser2 ); + VectorCopy( fcd->vuser3, pmove->vuser3 ); + VectorCopy( fcd->vuser4, pmove->vuser4 ); clgame.dllFuncs.pfnPlayerMove( pmove, false ); @@ -808,11 +809,13 @@ void CL_RunUsercmd( local_state_t *from, local_state_t *to, usercmd_t *u, qboole tcd->waterlevel = pmove->waterlevel; tcd->maxspeed = pmove->clientmaxspeed; tcd->deadflag = pmove->deadflag; - VectorCopy(pmove->velocity, tcd->velocity); - VectorCopy(pmove->view_ofs, tcd->view_ofs); - VectorCopy(pmove->origin, ts->origin); - VectorCopy(pmove->basevelocity, ts->basevelocity); - VectorCopy(pmove->punchangle, tcd->punchangle); + VectorCopy( pmove->velocity, tcd->velocity ); + VectorCopy( pmove->view_ofs, tcd->view_ofs ); + VectorCopy( pmove->origin, ts->origin ); + VectorCopy( pmove->basevelocity, ts->basevelocity ); + VectorCopy( pmove->punchangle, tcd->punchangle ); + VectorCopy( pmove->angles, ts->angles ); + ts->angles[PITCH] = -( pmove->angles[PITCH] / 3.0f ); ts->oldbuttons = pmove->oldbuttons; ts->friction = pmove->friction; ts->movetype = pmove->movetype; diff --git a/engine/common/common.h b/engine/common/common.h index d6762ef2..db4ea639 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -716,7 +716,7 @@ void CRC32_ProcessBuffer( dword *pulCRC, const void *pBuffer, int nBuffer ); void CRC32_ProcessByte( dword *pulCRC, byte ch ); void CRC32_Final( dword *pulCRC ); qboolean CRC32_File( dword *crcvalue, const char *filename ); -qboolean CRC32_MapFile( dword *crcvalue, const char *filename ); +qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multiplayer ); void MD5Init( MD5Context_t *ctx ); void MD5Update( MD5Context_t *ctx, const byte *buf, uint len ); void MD5Final( byte digest[16], MD5Context_t *ctx ); diff --git a/engine/common/crclib.c b/engine/common/crclib.c index 5ed078c0..7630ed1d 100644 --- a/engine/common/crclib.c +++ b/engine/common/crclib.c @@ -228,7 +228,7 @@ qboolean CRC32_File( dword *crcvalue, const char *filename ) return true; } -qboolean CRC32_MapFile( dword *crcvalue, const char *filename ) +qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multiplayer ) { file_t *f; dheader_t *header; @@ -241,7 +241,7 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename ) if( !crcvalue ) return false; // always calc same checksum for singleplayer - if( cls.state >= ca_connected && SV_Active() && CL_GetMaxClients() == 1 ) + if( multiplayer == false ) { *crcvalue = (('H'<<24)+('S'<<16)+('A'<<8)+'X'); return true; diff --git a/engine/common/mod_local.h b/engine/common/mod_local.h index 214933ce..16adb12e 100644 --- a/engine/common/mod_local.h +++ b/engine/common/mod_local.h @@ -107,7 +107,7 @@ void Mod_PrintBSPFileSizes( void ); void Mod_SetupHulls( vec3_t mins[MAX_MAP_HULLS], vec3_t maxs[MAX_MAP_HULLS] ); void Mod_GetBounds( int handle, vec3_t mins, vec3_t maxs ); void Mod_GetFrames( int handle, int *numFrames ); -void Mod_LoadWorld( const char *name, uint *checksum, qboolean force ); +void Mod_LoadWorld( const char *name, uint *checksum, qboolean multiplayer ); void Mod_FreeUnused( void ); void *Mod_Calloc( int number, size_t size ); void *Mod_CacheCheck( struct cache_user_s *c ); diff --git a/engine/common/model.c b/engine/common/model.c index 40ca1e43..ffa53d7c 100644 --- a/engine/common/model.c +++ b/engine/common/model.c @@ -2997,7 +2997,7 @@ Mod_LoadWorld Loads in the map and all submodels ================== */ -void Mod_LoadWorld( const char *name, uint *checksum, qboolean force ) +void Mod_LoadWorld( const char *name, uint *checksum, qboolean multiplayer ) { int i; @@ -3011,8 +3011,11 @@ void Mod_LoadWorld( const char *name, uint *checksum, qboolean force ) world.block_size = BLOCK_SIZE_MAX; else world.block_size = BLOCK_SIZE_DEFAULT; - if( !Q_stricmp( cm_models[0].name, name ) && !force ) + if( !Q_stricmp( cm_models[0].name, name )) { + // recalc the checksum in force-mode + CRC32_MapFile( &world.checksum, worldmodel->name, multiplayer ); + // singleplayer mode: server already loaded map if( checksum ) *checksum = world.checksum; @@ -3038,7 +3041,7 @@ void Mod_LoadWorld( const char *name, uint *checksum, qboolean force ) // load the newmap world.loading = true; worldmodel = Mod_ForName( name, true ); - CRC32_MapFile( &world.checksum, worldmodel->name ); + CRC32_MapFile( &world.checksum, worldmodel->name, multiplayer ); world.loading = false; if( checksum ) *checksum = world.checksum; diff --git a/engine/common/net_encode.c b/engine/common/net_encode.c index 855259f1..77e5963c 100644 --- a/engine/common/net_encode.c +++ b/engine/common/net_encode.c @@ -1035,10 +1035,10 @@ qboolean Delta_CompareField( delta_t *pField, void *from, void *to, float timeba } else if( pField->flags & DT_TIMEWINDOW_8 ) { - val_a = (*(float *)((byte *)from + pField->offset )) * 100.0f; - val_b = (*(float *)((byte *)to + pField->offset )) * 100.0f; - val_a -= (timebase * 100.0f); - val_b -= (timebase * 100.0f); + val_a = Q_rint((*(float *)((byte *)from + pField->offset )) * 100.0f ); + val_b = Q_rint((*(float *)((byte *)to + pField->offset )) * 100.0f ); + val_a -= Q_rint(timebase * 100.0f); + val_b -= Q_rint(timebase * 100.0f); fromF = *((int *)&val_a); toF = *((int *)&val_b); } @@ -1137,7 +1137,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 = (timebase * 100.0f) - (flValue * 100.0f); + flTime = Q_rint( timebase * 100.0f ) - Q_rint(flValue * 100.0f); iValue = (uint)abs( flTime ); BF_WriteBitLong( msg, iValue, pField->bits, bSigned ); diff --git a/engine/server/sv_client.c b/engine/server/sv_client.c index 0c168f68..53842976 100644 --- a/engine/server/sv_client.c +++ b/engine/server/sv_client.c @@ -1820,12 +1820,12 @@ void SV_UserinfoChanged( sv_client_t *cl, const char *userinfo ) Q_snprintf( temp2, sizeof( temp2 ), "%s (%u)", temp1, dupc++ ); Info_SetValueForKey( cl->userinfo, "name", temp2 ); val = Info_ValueForKey( cl->userinfo, "name" ); - Q_strcpy( cl->name, temp2 ); + Q_strncpy( cl->name, temp2, sizeof( cl->name )); } else { if( dupc == 1 ) // unchanged - Q_strcpy( cl->name, temp1 ); + Q_strncpy( cl->name, temp1, sizeof( cl->name )); break; } } diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index a0490bbc..6f8a9a74 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -551,7 +551,7 @@ qboolean SV_SpawnServer( const char *mapname, const char *startspot ) else sv.startspot[0] = '\0'; Q_snprintf( sv.model_precache[1], sizeof( sv.model_precache[0] ), "maps/%s.bsp", sv.name ); - Mod_LoadWorld( sv.model_precache[1], &sv.checksum, false ); + Mod_LoadWorld( sv.model_precache[1], &sv.checksum, sv_maxclients->integer > 1 ); sv.worldmodel = Mod_Handle( 1 ); // get world pointer for( i = 1; i < sv.worldmodel->numsubmodels; i++ )