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

Function MSG_ReadDeltaPlayerstate

code/qcommon/msg.cpp:1175–1284  ·  view source on GitHub ↗

=================== MSG_ReadDeltaPlayerstate =================== */

Source from the content-addressed store, hash-verified

1173===================
1174*/
1175void MSG_ReadDeltaPlayerstate (msg_t *msg, playerState_t *from, playerState_t *to ) {
1176 int i;
1177 int bits;
1178 const netField_t *field;
1179 int numFields;
1180 int startBit, endBit;
1181 int print;
1182 int *fromF, *toF;
1183 playerState_t dummy;
1184
1185 if ( !from ) {
1186 from = &dummy;
1187 memset( &dummy, 0, sizeof( dummy ) );
1188 }
1189 *to = *from;
1190
1191 if ( msg->bit == 0 ) {
1192 startBit = msg->readcount * 8 - GENTITYNUM_BITS;
1193 } else {
1194 startBit = ( msg->readcount - 1 ) * 8 + msg->bit - GENTITYNUM_BITS;
1195 }
1196
1197 // shownet 2/3 will interleave with other printed info, -2 will
1198 // just print the delta records
1199 if ( cl_shownet->integer >= 2 || cl_shownet->integer == -2 ) {
1200 print = 1;
1201 Com_Printf( "%3i: playerstate ", msg->readcount );
1202 } else {
1203 print = 0;
1204 }
1205
1206 numFields = sizeof( playerStateFields ) / sizeof( playerStateFields[0] );
1207 for ( i = 0, field = playerStateFields ; i < numFields ; i++, field++ ) {
1208 fromF = (int *)( (byte *)from + field->offset );
1209 toF = (int *)( (byte *)to + field->offset );
1210
1211 if ( ! MSG_ReadBits( msg, 1 ) ) {
1212 // no change
1213 *toF = *fromF;
1214 } else {
1215 MSG_ReadField( msg, toF, field, print);
1216 }
1217 }
1218
1219 // read the arrays
1220
1221 // parse stats
1222 if ( MSG_ReadBits( msg, 1 ) ) {
1223 LOG("PS_STATS");
1224 bits = MSG_ReadShort (msg);
1225 for (i=0 ; i<MAX_STATS ; i++) {
1226 if (bits & (1<<i) ) {
1227 to->stats[i] = MSG_ReadBits(msg,32);
1228 }
1229 }
1230 }
1231
1232 // parse persistant stats

Callers 1

CL_ParseSnapshotFunction · 0.50

Calls 6

MSG_ReadFieldFunction · 0.85
MSG_ReadSShortFunction · 0.85
Com_PrintfFunction · 0.70
MSG_ReadBitsFunction · 0.70
MSG_ReadShortFunction · 0.70
MSG_ReadLongFunction · 0.70

Tested by

no test coverage detected