diff --git a/engine/client/clq2_ents.c b/engine/client/clq2_ents.c index edde53395..eec30ac0c 100644 --- a/engine/client/clq2_ents.c +++ b/engine/client/clq2_ents.c @@ -976,28 +976,28 @@ static void CLQ2_ParseDelta (entity_state_t *from, entity_state_t *to, int numbe if (bits & Q2U_FRAME8) to->frame = MSG_ReadByte (); if (bits & Q2U_FRAME16) - to->frame = MSG_ReadShort (); + to->frame = MSG_ReadUInt16(); if ((bits & Q2U_SKIN8) && (bits & Q2U_SKIN16)) //used for laser colors to->skinnum = MSG_ReadLong(); else if (bits & Q2U_SKIN8) to->skinnum = MSG_ReadByte(); else if (bits & Q2U_SKIN16) - to->skinnum = MSG_ReadShort(); + to->skinnum = MSG_ReadUInt16(); if ( (bits & (Q2U_EFFECTS8|Q2U_EFFECTS16)) == (Q2U_EFFECTS8|Q2U_EFFECTS16) ) to->effects = MSG_ReadLong(); else if (bits & Q2U_EFFECTS8) to->effects = MSG_ReadByte(); else if (bits & Q2U_EFFECTS16) - to->effects = MSG_ReadShort(); + to->effects = MSG_ReadUInt16(); if ( (bits & (Q2U_RENDERFX8|Q2U_RENDERFX16)) == (Q2U_RENDERFX8|Q2U_RENDERFX16) ) to->u.q2.renderfx = MSG_ReadLong() & 0x0007ffff; //only the standard ones actually supported by vanilla q2. else if (bits & Q2U_RENDERFX8) to->u.q2.renderfx = MSG_ReadByte(); else if (bits & Q2U_RENDERFX16) - to->u.q2.renderfx = MSG_ReadShort(); + to->u.q2.renderfx = MSG_ReadUInt16(); if (bits & Q2U_ORIGIN1) to->origin[0] = MSG_ReadCoord (); @@ -1031,7 +1031,7 @@ static void CLQ2_ParseDelta (entity_state_t *from, entity_state_t *to, int numbe if (bits & Q2U_SOUND) { if (bits & Q2UX_INDEX16) - to->u.q2.sound = MSG_ReadShort(); + to->u.q2.sound = MSG_ReadUInt16(); else to->u.q2.sound = MSG_ReadByte (); } diff --git a/engine/common/common.c b/engine/common/common.c index eba3fa935..a4bbdb799 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -2183,6 +2183,30 @@ int MSG_ReadShort (void) return c; } +int MSG_ReadUInt16 (void) +{ + int c; + unsigned int msg_readcount; + + if (msg_readmsg->packing!=SZ_RAWBYTES) + return (short)MSG_ReadBits(16); + + msg_readcount = msg_readmsg->currentbit>>3; + if (msg_readcount+2 > msg_readmsg->cursize) + { + msg_badread = true; + return -1; + } + + c = (unsigned short)(msg_readmsg->data[msg_readcount] + + (msg_readmsg->data[msg_readcount+1]<<8)); + + msg_readcount += 2; + msg_readmsg->currentbit = msg_readcount<<3; + + return c; +} + int MSG_ReadLong (void) { int c; diff --git a/engine/common/common.h b/engine/common/common.h index d49cb78ca..397b08f22 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -352,6 +352,7 @@ int MSG_ReadChar (void); int MSG_ReadBits(int bits); int MSG_ReadByte (void); int MSG_ReadShort (void); +int MSG_ReadUInt16 (void); int MSG_ReadLong (void); qint64_t MSG_ReadInt64 (void); quint64_t MSG_ReadUInt64 (void);