From ff47fbaedcef35db2cdaa4675b592fb22ae80ea9 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 14 Oct 2024 03:15:36 +0300 Subject: [PATCH] engine: client: another fix baselines and entities parsing for GoldSrc, ensure we always call MSG_EndBitWriting --- engine/client/cl_parse.c | 8 +------- engine/client/cl_parse_gs.c | 8 ++++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index eef1d28d..c4b092ae 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -1230,9 +1230,6 @@ void CL_ParseBaseline( sizebuf_t *msg, connprotocol_t proto ) Delta_InitClient (); // finalize client delta's - if( proto == PROTO_GOLDSRC ) - MSG_StartBitWriting( msg ); - while( 1 ) { cl_entity_t *ent; @@ -1270,7 +1267,6 @@ void CL_ParseBaseline( sizebuf_t *msg, connprotocol_t proto ) if( proto == PROTO_GOLDSRC ) { int type = MSG_ReadUBitLong( msg, 2 ); - int bits = MSG_GetNumBitsWritten( msg ); int delta_type; if( player ) delta_type = DT_ENTITY_STATE_PLAYER_T; @@ -1278,6 +1274,7 @@ void CL_ParseBaseline( sizebuf_t *msg, connprotocol_t proto ) else delta_type = DT_ENTITY_STATE_T; Delta_ReadGSFields( msg, delta_type, &ent->prevstate, &ent->baseline, 1.0f ); + ent->baseline.entityType = type; } else MSG_ReadDeltaEntity( msg, &nullstate, &ent->baseline, newnum, player, 1.0f ); @@ -1302,9 +1299,6 @@ void CL_ParseBaseline( sizebuf_t *msg, connprotocol_t proto ) } } } - - if( proto == PROTO_GOLDSRC ) - MSG_EndBitWriting( msg ); } /* diff --git a/engine/client/cl_parse_gs.c b/engine/client/cl_parse_gs.c index 7b7d4601..980d7926 100644 --- a/engine/client/cl_parse_gs.c +++ b/engine/client/cl_parse_gs.c @@ -191,7 +191,6 @@ static void CL_FlushEntityPacketGS( frame_t *frame, sizebuf_t *msg ) if( MSG_ReadWord( msg ) != 0 ) { MSG_SeekToBit( msg, -16, SEEK_CUR ); - num = CL_ParseDeltaHeader( msg, false, num, &hdr ); } else break; @@ -204,8 +203,6 @@ static void CL_FlushEntityPacketGS( frame_t *frame, sizebuf_t *msg ) Delta_ReadGSFields( msg, CL_GetEntityDelta( &hdr, num ), &from, &to, cl.mtime[0] ); } - - MSG_EndBitWriting( msg ); } static void CL_DeltaEntityGS( const delta_header_t *hdr, sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t *from, qboolean has_update ) @@ -301,7 +298,9 @@ static int CL_ParsePacketEntitiesGS( sizebuf_t *msg, qboolean delta ) if( !CL_ValidateDeltaPacket( oldpacket, oldframe )) { + MSG_StartBitWriting( msg ); CL_FlushEntityPacketGS( frame, msg ); + MSG_EndBitWriting( msg ); return playerbytes; } } @@ -648,8 +647,9 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart; break; case svc_spawnbaseline: + MSG_StartBitWriting( msg ); CL_ParseBaseline( msg, PROTO_GOLDSRC ); - break; + MSG_EndBitWriting( msg ); break; case svc_setpause: cl.paused = ( MSG_ReadOneBit( msg ) != 0 );