From ea5937bce0541fdf2f10995f122f5b4ab4011a54 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 14 Jan 2022 14:46:52 +0300 Subject: [PATCH] engine: net_encode: remove naive clientdata/weapondata copy, only copy fields explicitly listed in deltalst --- engine/common/net_encode.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/engine/common/net_encode.c b/engine/common/net_encode.c index 10eb1920..04aa323d 100644 --- a/engine/common/net_encode.c +++ b/engine/common/net_encode.c @@ -1605,6 +1605,7 @@ void MSG_ReadClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, d delta_t *pField; delta_info_t *dt; int i; + qboolean noChanges; dt = Delta_FindStruct( "clientdata_t" ); Assert( dt && dt->bInitialized ); @@ -1612,15 +1613,14 @@ void MSG_ReadClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, d pField = dt->pFields; Assert( pField != NULL ); - *to = *from; - - if( !cls.legacymode && !MSG_ReadOneBit( msg )) - return; // we have no changes + noChanges = !cls.legacymode && !MSG_ReadOneBit( msg ); // process fields for( i = 0; i < dt->numFields; i++, pField++ ) { - Delta_ReadField( msg, pField, from, to, timebase ); + if( noChanges ) + Delta_CopyField( pField, from, to, timebase ); + else Delta_ReadField( msg, pField, from, to, timebase ); } #endif } @@ -1691,8 +1691,6 @@ void MSG_ReadWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to, pField = dt->pFields; Assert( pField != NULL ); - *to = *from; - // process fields for( i = 0; i < dt->numFields; i++, pField++ ) {