/* ================== MSG_ReadWeaponData Read the clientdata ================== */ void MSG_ReadWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to, float timebase ) { delta_t *pField; delta_info_t *dt; int i; dt = Delta_FindStruct( "weapon_data_t" ); ASSERT( dt && dt->bInitialized ); pField = dt->pFields; ASSERT( pField ); *to = *from; // process fields for( i = 0; i < dt->numFields; i++, pField++ ) { Delta_ReadField( msg, pField, from, to, timebase ); } }
void MSG_ReadDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *to ) { delta_t *pField; delta_info_t *dt; int i; dt = Delta_FindStruct( "movevars_t" ); ASSERT( dt && dt->bInitialized ); pField = dt->pFields; ASSERT( pField ); *to = *from; // process fields for( i = 0; i < dt->numFields; i++, pField++ ) { Delta_ReadField( msg, pField, from, to, 0.0f ); } }
/* ================== MSG_ReadClientData Read the clientdata ================== */ void MSG_ReadClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, float timebase ) { delta_t *pField; delta_info_t *dt; int i; dt = Delta_FindStruct( "clientdata_t" ); if( !dt || !dt->bInitialized ) { Host_Error( "MSG_ReadClientData: delta not initialized!\n" ); } pField = dt->pFields; ASSERT( pField ); *to = *from; // process fields for( i = 0; i < dt->numFields; i++, pField++ ) { Delta_ReadField( msg, pField, from, to, timebase ); } }
/* ===================== MSG_ReadDeltaEvent ===================== */ void MSG_ReadDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to ) { delta_t *pField; delta_info_t *dt; int i; dt = Delta_FindStruct( "event_t" ); if( !dt || !dt->bInitialized ) { Host_Error( "MSG_ReadDeltaEvent: delta not initialized!\n" ); } pField = dt->pFields; ASSERT( pField ); *to = *from; // process fields for( i = 0; i < dt->numFields; i++, pField++ ) { Delta_ReadField( msg, pField, from, to, 0.0f ); } }
/* ================== MSG_ReadDeltaEntity The entity number has already been read from the message, which is how the from state is identified. If the delta removes the entity, entity_state_t->number will be set to MAX_EDICTS Can go from either a baseline or a previous packet_entity ================== */ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state_t *to, int number, qboolean player, float timebase ) { delta_info_t *dt = NULL; delta_t *pField; int i, fRemoveType; #ifndef XASH_DEDICATED if( number < 0 || number >= clgame.maxEntities ) { // broken packet, try to skip it MsgDev( D_ERROR, "MSG_ReadDeltaEntity: bad delta entity number: %i\n", number ); return false; } *to = *from; to->number = number; fRemoveType = BF_ReadUBitLong( msg, 2 ); if( fRemoveType ) { // check for a remove Q_memset( to, 0, sizeof( *to )); if( fRemoveType & 1 ) { // removed from delta-message return false; } if( fRemoveType & 2 ) { // entity was removed from server to->number = -1; return false; } MsgDev( D_ERROR, "MSG_ReadDeltaEntity: unknown update type %i\n", fRemoveType ); return false; } if( BF_ReadOneBit( msg )) to->entityType = BF_ReadUBitLong( msg, 2 ); if( to->entityType == ENTITY_BEAM ) { dt = Delta_FindStruct( "custom_entity_state_t" ); } else // ENTITY_NORMAL or other (try predict type) { /* Omit connection drop on wromg data from server. * I know that it is very dirty, * but i don't know how to do it better.*/ if( to->entityType != ENTITY_NORMAL ) MsgDev( D_NOTE, "MSG_ReadDeltaEntity: broken delta: entityType = %d\n", to->entityType ); if( player ) { dt = Delta_FindStruct( "entity_state_player_t" ); } else { dt = Delta_FindStruct( "entity_state_t" ); } } if( !(dt && dt->bInitialized) ) // Broken delta? { MsgDev( D_ERROR, "MSG_ReadDeltaEntity: broken delta\n"); return true; } pField = dt->pFields; ASSERT( pField ); // process fields for( i = 0; i < dt->numFields; i++, pField++ ) { Delta_ReadField( msg, pField, from, to, timebase ); } #endif // message parsed return true; }
/* ================== MSG_ReadDeltaEntity The entity number has already been read from the message, which is how the from state is identified. If the delta removes the entity, entity_state_t->number will be set to MAX_EDICTS Can go from either a baseline or a previous packet_entity ================== */ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state_t *to, int number, qboolean player, float timebase ) { delta_info_t *dt = NULL; delta_t *pField; int i, fRemoveType; #ifndef _DEDICATED if( number < 0 || number >= clgame.maxEntities ) Host_Error( "MSG_ReadDeltaEntity: bad delta entity number: %i\n", number ); #endif *to = *from; to->number = number; fRemoveType = BF_ReadUBitLong( msg, 2 ); if( fRemoveType ) { // check for a remove Q_memset( to, 0, sizeof( *to )); if( fRemoveType & 1 ) { // removed from delta-message return false; } if( fRemoveType & 2 ) { // entity was removed from server to->number = -1; return false; } Host_Error( "MSG_ReadDeltaEntity: unknown update type %i\n", fRemoveType ); } if( BF_ReadOneBit( msg )) to->entityType = BF_ReadUBitLong( msg, 2 ); if( to->entityType == ENTITY_NORMAL ) { if( player ) { dt = Delta_FindStruct( "entity_state_player_t" ); } else { dt = Delta_FindStruct( "entity_state_t" ); } } else if( to->entityType == ENTITY_BEAM ) { dt = Delta_FindStruct( "custom_entity_state_t" ); } ASSERT( dt && dt->bInitialized ); pField = dt->pFields; ASSERT( pField ); // process fields for( i = 0; i < dt->numFields; i++, pField++ ) { Delta_ReadField( msg, pField, from, to, timebase ); } // message parsed return true; }