Skip to content

Commit

Permalink
eliteforce: Revert "[qcommon] Remove dead serialization code"
Browse files Browse the repository at this point in the history
This reverts commit d047210.
  • Loading branch information
zturtleman committed Mar 4, 2018
1 parent e45538b commit d2ee25c
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions code/qcommon/msg.c
Expand Up @@ -668,10 +668,55 @@ int MSG_HashKey(const char *string, int maxlen) {
return hash;
}

/*
=============================================================================
delta functions
=============================================================================
*/

extern cvar_t *cl_shownet;

#define LOG(x) if( cl_shownet && cl_shownet->integer == 4 ) { Com_Printf("%s ", x ); };

void MSG_WriteDelta( msg_t *msg, int oldV, int newV, int bits ) {
if ( oldV == newV ) {
MSG_WriteBits( msg, 0, 1 );
return;
}
MSG_WriteBits( msg, 1, 1 );
MSG_WriteBits( msg, newV, bits );
}

int MSG_ReadDelta( msg_t *msg, int oldV, int bits ) {
if ( MSG_ReadBits( msg, 1 ) ) {
return MSG_ReadBits( msg, bits );
}
return oldV;
}

void MSG_WriteDeltaFloat( msg_t *msg, float oldV, float newV ) {
floatint_t fi;
if ( oldV == newV ) {
MSG_WriteBits( msg, 0, 1 );
return;
}
fi.f = newV;
MSG_WriteBits( msg, 1, 1 );
MSG_WriteBits( msg, fi.i, 32 );
}

float MSG_ReadDeltaFloat( msg_t *msg, float oldV ) {
if ( MSG_ReadBits( msg, 1 ) ) {
floatint_t fi;

fi.i = MSG_ReadBits( msg, 32 );
return fi.f;
}
return oldV;
}

/*
=============================================================================
Expand Down

0 comments on commit d2ee25c

Please sign in to comment.