|
|
@ -1114,7 +1114,7 @@ assume from and to is valid |
|
|
|
qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to, double timebase ) |
|
|
|
qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to, double timebase ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qboolean bSigned = ( pField->flags & DT_SIGNED ) ? true : false; |
|
|
|
qboolean bSigned = ( pField->flags & DT_SIGNED ) ? true : false; |
|
|
|
float flValue, flAngle, flTime; |
|
|
|
float flValue, flAngle; |
|
|
|
uint iValue; |
|
|
|
uint iValue; |
|
|
|
const char *pStr; |
|
|
|
const char *pStr; |
|
|
|
|
|
|
|
|
|
|
@ -1204,6 +1204,53 @@ qboolean Delta_WriteField( sizebuf_t *msg, delta_t *pField, void *from, void *to |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
==================== |
|
|
|
|
|
|
|
Delta_CopyField |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
==================== |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
static void Delta_CopyField( delta_t *pField, void *from, void *to, double timebase ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
qboolean bSigned = FBitSet( pField->flags, DT_SIGNED ); |
|
|
|
|
|
|
|
uint8_t *to_field = (uint8_t *)to + pField->offset; |
|
|
|
|
|
|
|
uint8_t *from_field = (uint8_t *)from + pField->offset; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( FBitSet( pField->flags, DT_BYTE )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( bSigned ) |
|
|
|
|
|
|
|
*(int8_t *)( to_field ) = *(int8_t *)( from_field ); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
*(uint8_t *)( to_field ) = *(uint8_t *)( from_field ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if( FBitSet( pField->flags, DT_SHORT )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( bSigned ) |
|
|
|
|
|
|
|
*(int16_t *)( to_field ) = *(int16_t *)( from_field ); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
*(uint16_t *)( to_field ) = *(uint16_t *)( from_field ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if( FBitSet( pField->flags, DT_INTEGER )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( bSigned ) |
|
|
|
|
|
|
|
*(int32_t *)( to_field ) = *(int32_t *)( from_field ); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
*(uint32_t *)( to_field ) = *(uint32_t *)( from_field ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if( FBitSet( pField->flags, DT_FLOAT|DT_ANGLE|DT_TIMEWINDOW_8|DT_TIMEWINDOW_BIG )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
*(float *)( to_field ) = *(float *)( from_field ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if( FBitSet( pField->flags, DT_STRING )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Q_strncpy( to_field, from_field, pField->size ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Assert( 0 ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
===================== |
|
|
|
===================== |
|
|
|
Delta_ReadField |
|
|
|
Delta_ReadField |
|
|
@ -1216,30 +1263,24 @@ qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to, |
|
|
|
{ |
|
|
|
{ |
|
|
|
qboolean bSigned = ( pField->flags & DT_SIGNED ) ? true : false; |
|
|
|
qboolean bSigned = ( pField->flags & DT_SIGNED ) ? true : false; |
|
|
|
float flValue, flAngle, flTime; |
|
|
|
float flValue, flAngle, flTime; |
|
|
|
qboolean bChanged; |
|
|
|
|
|
|
|
uint iValue; |
|
|
|
uint iValue; |
|
|
|
const char *pStr; |
|
|
|
const char *pStr; |
|
|
|
char *pOut; |
|
|
|
char *pOut; |
|
|
|
|
|
|
|
|
|
|
|
bChanged = MSG_ReadOneBit( msg ); |
|
|
|
if( !MSG_ReadOneBit( msg ) ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Delta_CopyField( pField, from, to, timebase ); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Assert( pField->multiplier != 0.0f ); |
|
|
|
Assert( pField->multiplier != 0.0f ); |
|
|
|
|
|
|
|
|
|
|
|
if( pField->flags & DT_BYTE ) |
|
|
|
if( pField->flags & DT_BYTE ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( bChanged ) |
|
|
|
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); |
|
|
|
{ |
|
|
|
if( !Q_equal( pField->multiplier, 1.0 ) ) |
|
|
|
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); |
|
|
|
iValue /= pField->multiplier; |
|
|
|
if( !Q_equal( pField->multiplier, 1.0 ) ) |
|
|
|
|
|
|
|
iValue /= pField->multiplier; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( bSigned ) |
|
|
|
|
|
|
|
iValue = *(int8_t *)((uint8_t *)from + pField->offset ); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
iValue = *(uint8_t *)((uint8_t *)from + pField->offset ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if( bSigned ) |
|
|
|
if( bSigned ) |
|
|
|
*(int8_t *)((uint8_t *)to + pField->offset ) = iValue; |
|
|
|
*(int8_t *)((uint8_t *)to + pField->offset ) = iValue; |
|
|
|
else |
|
|
|
else |
|
|
@ -1247,19 +1288,10 @@ qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to, |
|
|
|
} |
|
|
|
} |
|
|
|
else if( pField->flags & DT_SHORT ) |
|
|
|
else if( pField->flags & DT_SHORT ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( bChanged ) |
|
|
|
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); |
|
|
|
{ |
|
|
|
if( !Q_equal( pField->multiplier, 1.0 ) ) |
|
|
|
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); |
|
|
|
iValue /= pField->multiplier; |
|
|
|
if( !Q_equal( pField->multiplier, 1.0 ) ) |
|
|
|
|
|
|
|
iValue /= pField->multiplier; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( bSigned ) |
|
|
|
|
|
|
|
iValue = *(int16_t *)((uint8_t *)from + pField->offset ); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
iValue = *(uint16_t *)((uint8_t *)from + pField->offset ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if( bSigned ) |
|
|
|
if( bSigned ) |
|
|
|
*(int16_t *)((uint8_t *)to + pField->offset ) = iValue; |
|
|
|
*(int16_t *)((uint8_t *)to + pField->offset ) = iValue; |
|
|
|
else |
|
|
|
else |
|
|
@ -1267,19 +1299,10 @@ qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to, |
|
|
|
} |
|
|
|
} |
|
|
|
else if( pField->flags & DT_INTEGER ) |
|
|
|
else if( pField->flags & DT_INTEGER ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( bChanged ) |
|
|
|
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); |
|
|
|
{ |
|
|
|
if( !Q_equal( pField->multiplier, 1.0 ) ) |
|
|
|
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); |
|
|
|
iValue /= pField->multiplier; |
|
|
|
if( !Q_equal( pField->multiplier, 1.0 ) ) |
|
|
|
|
|
|
|
iValue /= pField->multiplier; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( bSigned ) |
|
|
|
|
|
|
|
iValue = *(int32_t *)((uint8_t *)from + pField->offset ); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
iValue = *(uint32_t *)((uint8_t *)from + pField->offset ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if( bSigned ) |
|
|
|
if( bSigned ) |
|
|
|
*(int32_t *)((uint8_t *)to + pField->offset ) = iValue; |
|
|
|
*(int32_t *)((uint8_t *)to + pField->offset ) = iValue; |
|
|
|
else |
|
|
|
else |
|
|
@ -1287,85 +1310,52 @@ qboolean Delta_ReadField( sizebuf_t *msg, delta_t *pField, void *from, void *to, |
|
|
|
} |
|
|
|
} |
|
|
|
else if( pField->flags & DT_FLOAT ) |
|
|
|
else if( pField->flags & DT_FLOAT ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( bChanged ) |
|
|
|
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); |
|
|
|
{ |
|
|
|
if( bSigned ) |
|
|
|
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); |
|
|
|
flValue = (int)iValue; |
|
|
|
if( bSigned ) |
|
|
|
else |
|
|
|
flValue = (int)iValue; |
|
|
|
flValue = iValue; |
|
|
|
else |
|
|
|
|
|
|
|
flValue = iValue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( !Q_equal( pField->multiplier, 1.0 ) ) |
|
|
|
if( !Q_equal( pField->multiplier, 1.0 ) ) |
|
|
|
flValue = flValue / pField->multiplier; |
|
|
|
flValue = flValue / pField->multiplier; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( !Q_equal( pField->post_multiplier, 1.0 ) ) |
|
|
|
|
|
|
|
flValue = flValue * pField->post_multiplier; |
|
|
|
|
|
|
|
|
|
|
|
if( !Q_equal( pField->post_multiplier, 1.0 ) ) |
|
|
|
|
|
|
|
flValue = flValue * pField->post_multiplier; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flValue = *(float *)((byte *)from + pField->offset ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*(float *)((byte *)to + pField->offset ) = flValue; |
|
|
|
*(float *)((byte *)to + pField->offset ) = flValue; |
|
|
|
} |
|
|
|
} |
|
|
|
else if( pField->flags & DT_ANGLE ) |
|
|
|
else if( pField->flags & DT_ANGLE ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( bChanged ) |
|
|
|
flAngle = MSG_ReadBitAngle( msg, pField->bits ); |
|
|
|
{ |
|
|
|
|
|
|
|
flAngle = MSG_ReadBitAngle( msg, pField->bits ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flAngle = *(float *)((byte *)from + pField->offset ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*(float *)((byte *)to + pField->offset ) = flAngle; |
|
|
|
*(float *)((byte *)to + pField->offset ) = flAngle; |
|
|
|
} |
|
|
|
} |
|
|
|
else if( pField->flags & DT_TIMEWINDOW_8 ) |
|
|
|
else if( pField->flags & DT_TIMEWINDOW_8 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( bChanged ) |
|
|
|
bSigned = true; // timewindow is always signed
|
|
|
|
{ |
|
|
|
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); |
|
|
|
bSigned = true; // timewindow is always signed
|
|
|
|
flTime = (timebase * 100.0 - iValue) / 100.0; |
|
|
|
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); |
|
|
|
|
|
|
|
flTime = (timebase * 100.0 - iValue) / 100.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
flTime = *(float *)((byte *)from + pField->offset ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*(float *)((byte *)to + pField->offset ) = flTime; |
|
|
|
*(float *)((byte *)to + pField->offset ) = flTime; |
|
|
|
} |
|
|
|
} |
|
|
|
else if( pField->flags & DT_TIMEWINDOW_BIG ) |
|
|
|
else if( pField->flags & DT_TIMEWINDOW_BIG ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( bChanged ) |
|
|
|
bSigned = true; // timewindow is always signed
|
|
|
|
{ |
|
|
|
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); |
|
|
|
bSigned = true; // timewindow is always signed
|
|
|
|
|
|
|
|
iValue = MSG_ReadBitLong( msg, pField->bits, bSigned ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( !Q_equal( pField->multiplier, 1.0 ) ) |
|
|
|
if( !Q_equal( pField->multiplier, 1.0 ) ) |
|
|
|
flTime = ( timebase * pField->multiplier - iValue ) / pField->multiplier; |
|
|
|
flTime = ( timebase * pField->multiplier - iValue ) / pField->multiplier; |
|
|
|
else |
|
|
|
|
|
|
|
flTime = timebase - iValue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
flTime = timebase - iValue; |
|
|
|
flTime = *(float *)((byte *)from + pField->offset ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*(float *)((byte *)to + pField->offset ) = flTime; |
|
|
|
*(float *)((byte *)to + pField->offset ) = flTime; |
|
|
|
} |
|
|
|
} |
|
|
|
else if( pField->flags & DT_STRING ) |
|
|
|
else if( pField->flags & DT_STRING ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( bChanged ) |
|
|
|
pStr = MSG_ReadString( msg ); |
|
|
|
{ |
|
|
|
|
|
|
|
pStr = MSG_ReadString( msg ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pStr = (char *)((byte *)from + pField->offset ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pOut = (char *)((byte *)to + pField->offset ); |
|
|
|
pOut = (char *)((byte *)to + pField->offset ); |
|
|
|
Q_strncpy( pOut, pStr, pField->size ); |
|
|
|
Q_strncpy( pOut, pStr, pField->size ); |
|
|
|
} |
|
|
|
} |
|
|
|
return bChanged; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|