1
0
Fork 0
forked from fte/fteqw

Quake II: read the skin, effects, renderfx, and solidsize fields as unsigned shorts (#200)

* Quake II: read the skin, effects, renderfx, and solidsize fields as unsigned shorts.

* Add missing header definition for int MSG_ReadUShort();

* Rename MSG_ReadUShort() to MSG_ReadUInt16() as per @Shpoike's wishes

* solidsize needs to be read in via MSG_ReadSize16 because it does protocol conversions (@Shpoike)

* Q2UFRAME16 and Q2USOUND should be read unsigned as well, as it matches the internal data within FTE (@Shpoike)
This commit is contained in:
Marco Cawthorne 2023-07-26 12:12:21 -07:00 committed by GitHub
parent 65dccaf2db
commit f317282571
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 5 deletions

View file

@ -976,28 +976,28 @@ static void CLQ2_ParseDelta (entity_state_t *from, entity_state_t *to, int numbe
if (bits & Q2U_FRAME8) if (bits & Q2U_FRAME8)
to->frame = MSG_ReadByte (); to->frame = MSG_ReadByte ();
if (bits & Q2U_FRAME16) if (bits & Q2U_FRAME16)
to->frame = MSG_ReadShort (); to->frame = MSG_ReadUInt16();
if ((bits & Q2U_SKIN8) && (bits & Q2U_SKIN16)) //used for laser colors if ((bits & Q2U_SKIN8) && (bits & Q2U_SKIN16)) //used for laser colors
to->skinnum = MSG_ReadLong(); to->skinnum = MSG_ReadLong();
else if (bits & Q2U_SKIN8) else if (bits & Q2U_SKIN8)
to->skinnum = MSG_ReadByte(); to->skinnum = MSG_ReadByte();
else if (bits & Q2U_SKIN16) else if (bits & Q2U_SKIN16)
to->skinnum = MSG_ReadShort(); to->skinnum = MSG_ReadUInt16();
if ( (bits & (Q2U_EFFECTS8|Q2U_EFFECTS16)) == (Q2U_EFFECTS8|Q2U_EFFECTS16) ) if ( (bits & (Q2U_EFFECTS8|Q2U_EFFECTS16)) == (Q2U_EFFECTS8|Q2U_EFFECTS16) )
to->effects = MSG_ReadLong(); to->effects = MSG_ReadLong();
else if (bits & Q2U_EFFECTS8) else if (bits & Q2U_EFFECTS8)
to->effects = MSG_ReadByte(); to->effects = MSG_ReadByte();
else if (bits & Q2U_EFFECTS16) else if (bits & Q2U_EFFECTS16)
to->effects = MSG_ReadShort(); to->effects = MSG_ReadUInt16();
if ( (bits & (Q2U_RENDERFX8|Q2U_RENDERFX16)) == (Q2U_RENDERFX8|Q2U_RENDERFX16) ) 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. to->u.q2.renderfx = MSG_ReadLong() & 0x0007ffff; //only the standard ones actually supported by vanilla q2.
else if (bits & Q2U_RENDERFX8) else if (bits & Q2U_RENDERFX8)
to->u.q2.renderfx = MSG_ReadByte(); to->u.q2.renderfx = MSG_ReadByte();
else if (bits & Q2U_RENDERFX16) else if (bits & Q2U_RENDERFX16)
to->u.q2.renderfx = MSG_ReadShort(); to->u.q2.renderfx = MSG_ReadUInt16();
if (bits & Q2U_ORIGIN1) if (bits & Q2U_ORIGIN1)
to->origin[0] = MSG_ReadCoord (); 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 & Q2U_SOUND)
{ {
if (bits & Q2UX_INDEX16) if (bits & Q2UX_INDEX16)
to->u.q2.sound = MSG_ReadShort(); to->u.q2.sound = MSG_ReadUInt16();
else else
to->u.q2.sound = MSG_ReadByte (); to->u.q2.sound = MSG_ReadByte ();
} }

View file

@ -2183,6 +2183,30 @@ int MSG_ReadShort (void)
return c; 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 MSG_ReadLong (void)
{ {
int c; int c;

View file

@ -352,6 +352,7 @@ int MSG_ReadChar (void);
int MSG_ReadBits(int bits); int MSG_ReadBits(int bits);
int MSG_ReadByte (void); int MSG_ReadByte (void);
int MSG_ReadShort (void); int MSG_ReadShort (void);
int MSG_ReadUInt16 (void);
int MSG_ReadLong (void); int MSG_ReadLong (void);
qint64_t MSG_ReadInt64 (void); qint64_t MSG_ReadInt64 (void);
quint64_t MSG_ReadUInt64 (void); quint64_t MSG_ReadUInt64 (void);