diff --git a/engine/client/cl_demo.c b/engine/client/cl_demo.c index 9a2e43ce9..dd7167307 100644 --- a/engine/client/cl_demo.c +++ b/engine/client/cl_demo.c @@ -765,7 +765,7 @@ void CL_Record_f (void) int n, i, j; char *s, *p, *fname; entity_t *ent; - entity_state_t *es, blankes; + entity_state_t *es; player_info_t *player; extern char gamedirfile[]; int seq = 1; @@ -1051,12 +1051,11 @@ void CL_Record_f (void) // baselines - memset(&blankes, 0, sizeof(blankes)); - for (i = 0; i < MAX_EDICTS; i++) + for (i = 0; i < cl_baselines_count; i++) { es = cl_baselines + i; - if (memcmp(es, &blankes, sizeof(blankes))) + if (memcmp(es, &nullentitystate, sizeof(nullentitystate))) { MSG_WriteByte (&buf,svc_spawnbaseline); MSG_WriteShort (&buf, i); diff --git a/engine/client/cl_ents.c b/engine/client/cl_ents.c index 75413e357..1074b2609 100644 --- a/engine/client/cl_ents.c +++ b/engine/client/cl_ents.c @@ -604,7 +604,9 @@ void CL_ParsePacketEntities (qboolean delta) newp->entities = BZ_Realloc(newp->entities, sizeof(entity_state_t)*newp->max_entities); } - CL_ParseDelta (&cl_baselines[newnum], &newp->entities[newindex], word, true); + if (!CL_CheckBaselines(newnum)) + Host_EndGame("CL_ParsePacketEntities: check baselines failed with size %i", newnum); + CL_ParseDelta (cl_baselines + newnum, &newp->entities[newindex], word, true); newindex++; continue; } @@ -1064,7 +1066,9 @@ void CLNQ_ParseEntity(unsigned int bits) from = CL_FindOldPacketEntity(num); //this could be optimised. - base = &cl_baselines[num]; + if (!CL_CheckBaselines(num)) + Host_EndGame("CLNQ_ParseEntity: check baselines failed with size %i", num); + base = cl_baselines + num; state->number = num; @@ -2661,7 +2665,7 @@ guess_pm_type: if (cl.lerpplayers[num].frame != state->frame) { cl.lerpplayers[num].oldframechange = cl.lerpplayers[num].framechange; - cl.lerpplayers[num].framechange = cl.servertime; + cl.lerpplayers[num].framechange = cl.time; cl.lerpplayers[num].frame = state->frame; //don't care about position interpolation. @@ -3058,8 +3062,8 @@ void CL_LinkViewModel(void) lerptime[r_refdef.currentplayernum] = realtime; } ent.lerpfrac = 1-(realtime-lerptime[r_refdef.currentplayernum])*10; - if (ent.lerpfrac<0)ent.lerpfrac=0; - if (ent.lerpfrac>1)ent.lerpfrac=1; + ent.lerpfrac = bound(0, ent.lerpfrac, 1); + #define Q2RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors #define Q2RF_WEAPONMODEL 4 // only draw through eyes #define Q2RF_DEPTHHACK 16 // for view weapon Z crunching diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index b7af4a5cd..238eed365 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -155,7 +155,7 @@ client_static_t cls; client_state_t cl; // alot of this should probably be dynamically allocated -entity_state_t cl_baselines[MAX_EDICTS]; +entity_state_t *cl_baselines; efrag_t cl_efrags[MAX_EFRAGS]; entity_t cl_static_entities[MAX_STATIC_ENTITIES]; trailstate_t *cl_static_emit[MAX_STATIC_ENTITIES]; @@ -163,6 +163,7 @@ lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES]; //lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES]; dlight_t cl_dlights[MAX_DLIGHTS]; +int cl_baselines_count; int dlights_running, dlights_software; // refresh list @@ -987,12 +988,12 @@ void CL_ClearState (void) dlights_running = 0; - for (i = 0; i < MAX_EDICTS; i++) + if (cl_baselines) { - memcpy(&cl_baselines[i], &nullentitystate, sizeof(cl_baselines[i])); + BZ_Free(cl_baselines); + cl_baselines = NULL; } - - + cl_baselines_count = 0; // // allocate the efrags and chain together into a free list diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index 1dbf53b37..3a83cf93f 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -2320,6 +2320,30 @@ void CLQ2_ParseConfigString (void) #endif +qboolean CL_CheckBaselines (int size) +{ + int i; + + if (size < 0) + return false; + if (size > MAX_EDICTS) + return false; + + size = (size + 64) & ~63; // round up to next 64 + if (size < cl_baselines_count) + return true; + + cl_baselines = BZ_Realloc(cl_baselines, sizeof(*cl_baselines)*size); + for (i = cl_baselines_count; i < size; i++) + { + memcpy(cl_baselines + i, &nullentitystate, sizeof(*cl_baselines)); + } + + cl_baselines_count = size; + + return true; +} + /* ================== CL_ParseBaseline @@ -2347,7 +2371,9 @@ void CL_ParseBaseline2 (void) entity_state_t es; CL_ParseDelta(&nullentitystate, &es, MSG_ReadShort(), true); - memcpy(&cl_baselines[es.number], &es, sizeof(es)); + if (!CL_CheckBaselines(es.number)) + Host_EndGame("CL_ParseBaseline2: check baselines failed with size %i", es.number); + memcpy(cl_baselines + es.number, &es, sizeof(es)); } void CLQ2_Precache_f (void) @@ -4007,7 +4033,9 @@ void CL_ParseServerMessage (void) case svc_spawnbaseline: i = MSG_ReadShort (); - CL_ParseBaseline (&cl_baselines[i]); + if (!CL_CheckBaselines(i)) + Host_EndGame("CL_ParseServerMessage: svc_spawnbaseline failed with size %i", i); + CL_ParseBaseline (cl_baselines + i); break; case svc_spawnbaseline2: CL_ParseBaseline2 (); @@ -4678,7 +4706,9 @@ void CLNQ_ParseServerMessage (void) case svc_spawnbaseline: i = MSG_ReadShort (); - CL_ParseBaseline (&cl_baselines[i]); + if (!CL_CheckBaselines(i)) + Host_EndGame("CLNQ_ParseServerMessage: svc_spawnbaseline failed with size %i", i); + CL_ParseBaseline (cl_baselines + i); break; case svc_time: diff --git a/engine/client/client.h b/engine/client/client.h index 9b0a9942e..0c9752337 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -638,7 +638,7 @@ extern cvar_t name; extern client_state_t cl; // FIXME, allocate dynamically -extern entity_state_t cl_baselines[MAX_EDICTS]; +extern entity_state_t *cl_baselines; extern efrag_t cl_efrags[MAX_EFRAGS]; extern entity_t cl_static_entities[MAX_STATIC_ENTITIES]; extern trailstate_t *cl_static_emit[MAX_STATIC_ENTITIES]; @@ -646,6 +646,7 @@ extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES]; extern dlight_t cl_dlights[MAX_DLIGHTS]; extern int dlights_running, dlights_software; +extern int cl_baselines_count; extern qboolean nomaster; extern float server_version; // version of server we connected to diff --git a/engine/common/protocol.h b/engine/common/protocol.h index bdb3c7570..a5182f8f7 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -458,6 +458,8 @@ enum clcq2_ops_e #define U_COLOURMOD (1<<10) //rgb #define U_DPFLAGS (1<<11) + + #define U_TAGINFO (1<<12) #define U_LIGHT (1<<13) #define U_EFFECTS16 (1<<14) diff --git a/engine/server/sv_ents.c b/engine/server/sv_ents.c index 94cd547ee..84f187a07 100644 --- a/engine/server/sv_ents.c +++ b/engine/server/sv_ents.c @@ -543,12 +543,8 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb if ((to->colormod[0]!=from->colormod[0]||to->colormod[1]!=from->colormod[1]||to->colormod[2]!=from->colormod[2]) && protext & PEXT_COLOURMOD) evenmorebits |= U_COLOURMOD; - if (to->dpflags != from->dpflags && protext & PEXT_DPFLAGS) - evenmorebits |= U_DPFLAGS; - - if (to->glowsize != from->glowsize) - to->dpflags |= 4; + to->dpflags |= 2; // RENDER_GLOWTRAIL if (to->dpflags != from->dpflags && protext & PEXT_DPFLAGS) evenmorebits |= U_DPFLAGS;