diff options
Diffstat (limited to 'code/qcommon')
-rw-r--r-- | code/qcommon/huffman.c | 10 | ||||
-rw-r--r-- | code/qcommon/msg.c | 11 | ||||
-rw-r--r-- | code/qcommon/qcommon.h | 21 |
3 files changed, 35 insertions, 7 deletions
diff --git a/code/qcommon/huffman.c b/code/qcommon/huffman.c index b230b5b..2ff4ae5 100644 --- a/code/qcommon/huffman.c +++ b/code/qcommon/huffman.c @@ -39,6 +39,16 @@ void Huff_putBit( int bit, byte *fout, int *offset) { *offset = bloc; } +int Huff_getBloc(void) +{ + return bloc; +} + +void Huff_setBloc(int _bloc) +{ + bloc = _bloc; +} + int Huff_getBit( byte *fin, int *offset) { int t; bloc = *offset; diff --git a/code/qcommon/msg.c b/code/qcommon/msg.c index b26cf8f..3840a8c 100644 --- a/code/qcommon/msg.c +++ b/code/qcommon/msg.c @@ -389,6 +389,17 @@ int MSG_ReadByte( msg_t *msg ) { return c; } +int MSG_LookaheadByte( msg_t *msg ) { + const int bloc = Huff_getBloc(); + const int readcount = msg->readcount; + const int bit = msg->bit; + int c = MSG_ReadByte(msg); + Huff_setBloc(bloc); + msg->readcount = readcount; + msg->bit = bit; + return c; +} + int MSG_ReadShort( msg_t *msg ) { int c; diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index f535d68..58b0a29 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -92,7 +92,7 @@ char *MSG_ReadBigString (msg_t *sb); char *MSG_ReadStringLine (msg_t *sb); float MSG_ReadAngle16 (msg_t *sb); void MSG_ReadData (msg_t *sb, void *buffer, int size); - +int MSG_LookaheadByte (msg_t *msg); void MSG_WriteDeltaUsercmd( msg_t *msg, struct usercmd_s *from, struct usercmd_s *to ); void MSG_ReadDeltaUsercmd( msg_t *msg, struct usercmd_s *from, struct usercmd_s *to ); @@ -276,9 +276,10 @@ enum svc_ops_e { svc_snapshot, svc_EOF, -#if USE_VOIP - svc_voip -#endif + // svc_extension follows a svc_EOF, followed by another svc_* ... + // this keeps legacy clients compatible. + svc_extension, + svc_voip, // not wrapped in USE_VOIP, so this value is reserved. }; @@ -293,9 +294,10 @@ enum clc_ops_e { clc_clientCommand, // [string] message clc_EOF, -#if USE_VOIP - clc_voip, // packet of voice data. -#endif + // clc_extension follows a clc_EOF, followed by another clc_* ... + // this keeps legacy servers compatible. + clc_extension, + clc_voip, // not wrapped in USE_VOIP, so this value is reserved. }; /* @@ -1112,6 +1114,11 @@ void Huff_offsetTransmit (huff_t *huff, int ch, byte *fout, int *offset); void Huff_putBit( int bit, byte *fout, int *offset); int Huff_getBit( byte *fout, int *offset); +// don't use if you don't know what you're doing. +int Huff_getBloc(void); +void Huff_setBloc(int _bloc); + + extern huffman_t clientHuffTables; #define SV_ENCODE_START 4 |