Browse Source

engine: net_encode: remove naive clientdata/weapondata copy, only copy fields explicitly listed in deltalst

pull/2/head
Alibek Omarov 3 years ago
parent
commit
ea5937bce0
  1. 12
      engine/common/net_encode.c

12
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_t *pField;
delta_info_t *dt; delta_info_t *dt;
int i; int i;
qboolean noChanges;
dt = Delta_FindStruct( "clientdata_t" ); dt = Delta_FindStruct( "clientdata_t" );
Assert( dt && dt->bInitialized ); Assert( dt && dt->bInitialized );
@ -1612,15 +1613,14 @@ void MSG_ReadClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, d
pField = dt->pFields; pField = dt->pFields;
Assert( pField != NULL ); Assert( pField != NULL );
*to = *from; noChanges = !cls.legacymode && !MSG_ReadOneBit( msg );
if( !cls.legacymode && !MSG_ReadOneBit( msg ))
return; // we have no changes
// process fields // process fields
for( i = 0; i < dt->numFields; i++, pField++ ) 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 #endif
} }
@ -1691,8 +1691,6 @@ void MSG_ReadWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to,
pField = dt->pFields; pField = dt->pFields;
Assert( pField != NULL ); Assert( pField != NULL );
*to = *from;
// process fields // process fields
for( i = 0; i < dt->numFields; i++, pField++ ) for( i = 0; i < dt->numFields; i++, pField++ )
{ {

Loading…
Cancel
Save