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

Function MSG_ReadField

code/qcommon/msg.cpp:658–701  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

656}
657
658void MSG_ReadField (msg_t *msg, int *toF, const netField_t *field, int print)
659{
660 int trunc;
661
662 if ( field->bits == -1)
663 { // a -1 in the bits field means it's a float that's always between -1 and 1
664 int temp = MSG_ReadBits( msg, -16);
665 *(float *)toF = (float)temp / 32767;
666 }
667 else
668 if ( field->bits == 0 ) {
669 // float
670 if ( MSG_ReadBits( msg, 1 ) == 0 ) {
671 *(float *)toF = 0.0f;
672 } else {
673 if ( MSG_ReadBits( msg, 1 ) == 0 ) {
674 // integral float
675 trunc = MSG_ReadBits( msg, FLOAT_INT_BITS );
676 // bias to allow equal parts positive and negative
677 trunc -= FLOAT_INT_BIAS;
678 *(float *)toF = trunc;
679 if ( print ) {
680 Com_Printf( "%s:%i ", field->name, trunc );
681 }
682 } else {
683 // full floating point value
684 *toF = MSG_ReadBits( msg, 32 );
685 if ( print ) {
686 Com_Printf( "%s:%f ", field->name, *(float *)toF );
687 }
688 }
689 }
690 } else {
691 if ( MSG_ReadBits( msg, 1 ) == 0 ) {
692 *toF = 0;
693 } else {
694 // integer
695 *toF = MSG_ReadBits( msg, field->bits );
696 if ( print ) {
697 Com_Printf( "%s:%i ", field->name, *toF );
698 }
699 }
700 }
701}
702
703
704/*

Callers 2

MSG_ReadDeltaEntityFunction · 0.85
MSG_ReadDeltaPlayerstateFunction · 0.85

Calls 2

MSG_ReadBitsFunction · 0.70
Com_PrintfFunction · 0.70

Tested by

no test coverage detected