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