MCPcopy Create free account
hub / github.com/JACoders/OpenJK / MSG_WriteDeltaEntity

Function MSG_WriteDeltaEntity

code/qcommon/msg.cpp:721–803  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

719*/
720#if 0 // Removed by BTO (VV)
721void MSG_WriteDeltaEntity( msg_t *msg, struct entityState_s *from, struct entityState_s *to,
722 qboolean force ) {
723 int c;
724 int i;
725 const netField_t *field;
726 int *fromF, *toF;
727 int blah;
728 bool stuffChanged = false;
729 const int numFields = sizeof(entityStateFields)/sizeof(entityStateFields[0]);
730 byte changeVector[(numFields/8) + 1];
731
732
733 // all fields should be 32 bits to avoid any compiler packing issues
734 // the "number" field is not part of the field list
735 // if this assert fails, someone added a field to the entityState_t
736 // struct without updating the message fields
737 blah = sizeof( *from );
738 assert( numFields + 1 == blah/4);
739
740 c = msg->cursize;
741
742 // a NULL to is a delta remove message
743 if ( to == NULL ) {
744 if ( from == NULL ) {
745 return;
746 }
747 MSG_WriteBits( msg, from->number, GENTITYNUM_BITS );
748 MSG_WriteBits( msg, 1, 1 );
749 return;
750 }
751
752 if ( to->number < 0 || to->number >= MAX_GENTITIES ) {
753 Com_Error (ERR_FATAL, "MSG_WriteDeltaEntity: Bad entity number: %i", to->number );
754 }
755
756 memset(changeVector, 0, sizeof(changeVector));
757
758 // build the change vector as bytes so it is endien independent
759 for ( i = 0, field = entityStateFields ; i < numFields ; i++, field++ ) {
760 fromF = (int *)( (byte *)from + field->offset );
761 toF = (int *)( (byte *)to + field->offset );
762 if ( *fromF != *toF ) {
763 changeVector[ i>>3 ] |= 1 << ( i & 7 );
764 stuffChanged = true;
765 }
766 }
767
768 if ( stuffChanged )
769 {
770 MSG_WriteBits( msg, to->number, GENTITYNUM_BITS );
771 MSG_WriteBits( msg, 0, 1 ); // not removed
772 MSG_WriteBits( msg, 1, 1 ); // we have a delta
773
774 // we need to write the entire delta
775 for ( i = 0 ; i + 8 <= numFields ; i += 8 ) {
776 MSG_WriteByte( msg, changeVector[i>>3] );
777 }
778 if ( numFields & 7 ) {

Callers

nothing calls this directly

Calls 4

MSG_WriteFieldFunction · 0.85
MSG_WriteBitsFunction · 0.70
Com_ErrorFunction · 0.70
MSG_WriteByteFunction · 0.70

Tested by

no test coverage detected