Browse Source

engine: match DT_TIMEWINDOW_* behaviour to GoldSrc: it's always signed and it's more of an integer than float value

pull/2/head
Alibek Omarov 4 years ago
parent
commit
a28d15e519
  1. 21
      engine/common/net_encode.c

21
engine/common/net_encode.c

@ -1177,17 +1177,17 @@ qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to
} }
else if( pField->flags & DT_TIMEWINDOW_8 ) else if( pField->flags & DT_TIMEWINDOW_8 )
{ {
bSigned = true; // timewindow is always signed
flValue = *(float *)((byte *)to + pField->offset ); flValue = *(float *)((byte *)to + pField->offset );
flTime = Q_rint( timebase * 100.0f ) - Q_rint( flValue * 100.0f ); iValue = (int)Q_rint( timebase * 100.0f ) - (int)Q_rint( flValue * 100.0f );
iValue = (uint)abs( flTime );
iValue = Delta_ClampIntegerField( pField, iValue, bSigned, pField->bits ); iValue = Delta_ClampIntegerField( pField, iValue, bSigned, pField->bits );
MSG_WriteBitLong( msg, iValue, pField->bits, bSigned ); MSG_WriteBitLong( msg, iValue, pField->bits, bSigned );
} }
else if( pField->flags & DT_TIMEWINDOW_BIG ) else if( pField->flags & DT_TIMEWINDOW_BIG )
{ {
bSigned = true; // timewindow is always signed
flValue = *(float *)((byte *)to + pField->offset ); flValue = *(float *)((byte *)to + pField->offset );
flTime = Q_rint( timebase * pField->multiplier ) - Q_rint( flValue * pField->multiplier ); iValue = (int)Q_rint( timebase * pField->multiplier ) - (int)Q_rint( flValue * pField->multiplier );
iValue = (uint)abs( flTime );
iValue = Delta_ClampIntegerField( pField, iValue, bSigned, pField->bits ); iValue = Delta_ClampIntegerField( pField, iValue, bSigned, pField->bits );
MSG_WriteBitLong( msg, iValue, pField->bits, bSigned ); MSG_WriteBitLong( msg, iValue, pField->bits, bSigned );
} }
@ -1314,9 +1314,9 @@ qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to,
{ {
if( bChanged ) if( bChanged )
{ {
bSigned = true; // timewindow is always signed
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
flValue = (float)((int)(iValue * 0.01f )); flTime = ((timebase * 100.0f) - iValue ) / 100.0f;
flTime = timebase + flValue;
} }
else else
{ {
@ -1328,9 +1328,12 @@ qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to,
{ {
if( bChanged ) if( bChanged )
{ {
bSigned = true; // timewindow is always signed
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); iValue = MSG_ReadBitLong( msg, pField->bits, bSigned );
flValue = (float)((int)iValue) * ( 1.0f / pField->multiplier ); flTime = ((timebase * pField->multiplier) - iValue );
flTime = timebase + flValue;
if( pField->multiplier != 1.0f )
flTime /= pField->multiplier;
} }
else else
{ {
@ -1357,7 +1360,7 @@ qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to,
/* /*
============================================================================= =============================================================================
1
usercmd_t communication usercmd_t communication
============================================================================= =============================================================================

Loading…
Cancel
Save