Skip to content

Commit

Permalink
engine: client: allocate static entities only when server sends stati…
Browse files Browse the repository at this point in the history
…c entity packet
  • Loading branch information
a1batross committed Dec 18, 2024
1 parent 2aa13c8 commit 98e5872
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion engine/client/cl_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ void CL_InitEdicts( int maxclients )
cls.num_client_entities = CL_UPDATE_BACKUP * NUM_PACKET_ENTITIES;
cls.packet_entities = Mem_Realloc( clgame.mempool, cls.packet_entities, sizeof( entity_state_t ) * cls.num_client_entities );
clgame.entities = Mem_Calloc( clgame.mempool, sizeof( cl_entity_t ) * clgame.maxEntities );
clgame.static_entities = Mem_Calloc( clgame.mempool, sizeof( cl_entity_t ) * MAX_STATIC_ENTITIES );
clgame.static_entities = NULL; // will be initialized later
clgame.numStatics = 0;

if(( clgame.maxRemapInfos - 1 ) != clgame.maxEntities )
Expand Down
7 changes: 5 additions & 2 deletions engine/client/cl_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,13 @@ static client entity
static void CL_ParseStaticEntity( sizebuf_t *msg )
{
int i, newnum;
entity_state_t from, to;
const entity_state_t from = { 0 };
entity_state_t to;
cl_entity_t *ent;

memset( &from, 0, sizeof( from ));
if( !clgame.static_entities )
clgame.static_entities = Mem_Calloc( clgame.mempool, sizeof( cl_entity_t ) * MAX_STATIC_ENTITIES );

newnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
MSG_ReadDeltaEntity( msg, &from, &to, 0, DELTA_STATIC, cl.mtime[0] );

Expand Down
6 changes: 4 additions & 2 deletions engine/client/cl_parse_48.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ static client entity
static void CL_LegacyParseStaticEntity( sizebuf_t *msg )
{
int i;
entity_state_t state;
entity_state_t state = { 0 };
cl_entity_t *ent;

memset( &state, 0, sizeof( state ));
if( !clgame.static_entities )
clgame.static_entities = Mem_Calloc( clgame.mempool, sizeof( cl_entity_t ) * MAX_STATIC_ENTITIES );

state.modelindex = MSG_ReadShort( msg );
state.sequence = MSG_ReadByte( msg );
state.frame = MSG_ReadByte( msg );
Expand Down
5 changes: 3 additions & 2 deletions engine/client/cl_qparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,12 @@ CL_ParseStaticEntity
*/
static void CL_ParseQuakeStaticEntity( sizebuf_t *msg )
{
entity_state_t state;
entity_state_t state = { 0 };
cl_entity_t *ent;
int i;

memset( &state, 0, sizeof( state ));
if( !clgame.static_entities )
clgame.static_entities = Mem_Calloc( clgame.mempool, sizeof( cl_entity_t ) * MAX_STATIC_ENTITIES );

state.modelindex = MSG_ReadByte( msg );
state.frame = MSG_ReadByte( msg );
Expand Down

0 comments on commit 98e5872

Please sign in to comment.