From 6da731fec12126616fde8aacd0db3a59b1a78713 Mon Sep 17 00:00:00 2001 From: Jeff Teunissen Date: Thu, 8 Feb 2001 17:43:14 +0000 Subject: [PATCH] Clear packet entities when they are removed. This fixes a bug in particle trails, and possibly others as well. Eliminate cl_oldvisedicts and cl_visedicts_list, change cl_visedicts's definition to compensate. It isn't used any more, so they just waste memory. --- include/cl_main.h | 5 ++--- source/cl_ents.c | 12 ++++++------ source/cl_main.c | 5 ++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/cl_main.h b/include/cl_main.h index 791b96f..3f28f00 100644 --- a/include/cl_main.h +++ b/include/cl_main.h @@ -49,9 +49,8 @@ qboolean CL_DemoBehind(void); void CL_BeginServerConnect(void); #define MAX_VISEDICTS 256 -extern int cl_numvisedicts, cl_oldnumvisedicts; -extern entity_t **cl_visedicts, **cl_oldvisedicts; -extern entity_t *cl_visedicts_list[2][MAX_VISEDICTS]; +extern int cl_numvisedicts; +extern entity_t *cl_visedicts[MAX_VISEDICTS]; extern char emodel_name[], pmodel_name[], prespawn_name[], modellist_name[], soundlist_name[]; diff --git a/source/cl_ents.c b/source/cl_ents.c index 02a3f53..de743b0 100644 --- a/source/cl_ents.c +++ b/source/cl_ents.c @@ -440,6 +440,7 @@ CL_ParsePacketEntities (qboolean delta) if (newindex >= MAX_PACKET_ENTITIES) Host_EndGame ("CL_ParsePacketEntities: newindex == MAX_PACKET_ENTITIES"); CL_ParseDelta (&cl_baselines[newnum], &newp->entities[newindex], word); + newindex++; continue; } @@ -449,11 +450,13 @@ CL_ParsePacketEntities (qboolean delta) cl.validsequence = 0; Con_Printf ("WARNING: delta on full update"); } - if (word & U_REMOVE) { + if (word & U_REMOVE) { // Clear the entity + entity_t *ent = &cl_packet_ents[newnum]; + memset (ent, 0, sizeof (entity_t)); oldindex++; continue; } -// Con_Printf ("delta %i\n",newnum); +// Con_Printf ("delta %i\n", newnum); CL_ParseDelta (&oldp->entities[oldindex], &newp->entities[newindex], word); newindex++; oldindex++; @@ -512,6 +515,7 @@ CL_LinkPacketEntities (void) ent = CL_NewTempEntity (); if (!ent) break; // object list is full + *ent = &cl_packet_ents[s1->number]; (*ent)->keynum = s1->number; @@ -1131,10 +1135,6 @@ CL_EmitEntities (void) if (!cl.validsequence) return; - cl_oldnumvisedicts = cl_numvisedicts; - cl_oldvisedicts = cl_visedicts_list[!(cls.netchan.incoming_sequence & 1)]; - cl_visedicts = cl_visedicts_list[cls.netchan.incoming_sequence & 1]; - cl_numvisedicts = 0; CL_LinkPlayers (); diff --git a/source/cl_main.c b/source/cl_main.c index 67b4364..0c608fe 100644 --- a/source/cl_main.c +++ b/source/cl_main.c @@ -166,9 +166,8 @@ dlight_t cl_dlights[MAX_DLIGHTS]; // refresh list // this is double buffered so the last frame // can be scanned for oldorigins of trailing objects -int cl_numvisedicts, cl_oldnumvisedicts; -entity_t **cl_visedicts, **cl_oldvisedicts; -entity_t *cl_visedicts_list[2][MAX_VISEDICTS]; +int cl_numvisedicts; +entity_t *cl_visedicts[MAX_VISEDICTS]; double connect_time = -1; // for connection retransmits