Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 122 additions & 53 deletions src/netmsg_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,67 +510,74 @@ static void SetStat(mvd_info_t *mvd, int stat, int value)
cp->stats[stat] = value;
}

static void NetMsg_Parser_ParsePacketEntities(mvd_info_t *mvd, qbool delta)
static void NetMsg_Parser_ParseEntityNum(unsigned int *entnum, unsigned int *bits, unsigned int *morebits)
{
byte from;
int bits;
*entnum = *bits = *morebits = 0;

if (delta)
{
from = MSG_ReadByte();
*bits = MSG_ReadShort();

if ((outgoing_sequence - incoming_sequence - 1) >= UPDATE_MASK)
{
return;
}
}
*entnum = *bits & 0x1FF;
*bits &= ~0x1FF;

while (true)
if (*bits & U_MOREBITS)
{
bits = MSG_ReadShort();

if (msg_badread)
*bits |= MSG_ReadByte();
if (*bits & U_FTE_EVENMORE)
{
// Something didn't parse right...
Sys_PrintError("NetMsg_Parser_ParsePacketEntities: msg_badread in packetentities.\n");
return;
}
*morebits = MSG_ReadByte();
if (*morebits & U_FTE_YETMORE)
{
*morebits |= MSG_ReadByte() << 8;
}

if (!bits)
{
break;
if (*morebits & U_FTE_ENTITYDBL)
{
*entnum += 512;
}
if (*morebits & U_FTE_ENTITYDBL2)
{
*entnum += 1024;
}
}
}
}

bits &= ~0x1FF; // Strip the first 9 bits.
static void NetMsg_Parser_ParseEntityDelta(unsigned int bits, unsigned int morebits)
{
if (bits & U_MODEL)
MSG_ReadByte();
else if (morebits & U_FTE_MODELDBL)
MSG_ReadShort();

// Read any more bits.
if (bits & U_MOREBITS)
{
bits |= MSG_ReadByte();
}
if (bits & U_FRAME)
MSG_ReadByte();
if (bits & U_COLORMAP)
MSG_ReadByte();
if (bits & U_SKIN)
MSG_ReadByte();
if (bits & U_EFFECTS)
MSG_ReadByte();
if (bits & U_ORIGIN1)
MSG_ReadCoord();
if (bits & U_ORIGIN2)
MSG_ReadCoord();
if (bits & U_ORIGIN3)
MSG_ReadCoord();
if (bits & U_ANGLE1)
MSG_ReadAngle();
if (bits & U_ANGLE2)
MSG_ReadAngle();
if (bits & U_ANGLE3)
MSG_ReadAngle();

if (bits & U_MODEL)
MSG_ReadByte();
if (bits & U_FRAME)
MSG_ReadByte();
if (bits & U_COLORMAP)
MSG_ReadByte();
if (bits & U_SKIN)
MSG_ReadByte();
if (bits & U_EFFECTS)
MSG_ReadByte();
if (bits & U_ORIGIN1)
MSG_ReadCoord();
if (bits & U_ORIGIN2)
MSG_ReadCoord();
if (bits & U_ORIGIN3)
MSG_ReadCoord();
if (bits & U_ANGLE1)
MSG_ReadAngle();
if (bits & U_ANGLE2)
MSG_ReadAngle();
if (bits & U_ANGLE3)
MSG_ReadAngle();
if (morebits & U_FTE_TRANS)
MSG_ReadByte();

if (morebits & U_FTE_COLOURMOD)
{
MSG_ReadByte(); // r
MSG_ReadByte(); // g
MSG_ReadByte(); // b
}
}

Expand Down Expand Up @@ -958,6 +965,13 @@ static void NetMsg_Parser_Parse_svc_spawnstatic(void)
}
}

static void NetMsg_Parser_Parse_svc_fte_spawnstatic2(void)
{
unsigned int entnum, bits, morebits;
NetMsg_Parser_ParseEntityNum(&entnum, &bits, &morebits);
NetMsg_Parser_ParseEntityDelta(bits, morebits);
}

static void NetMsg_Parser_Parse_svc_spawnbaseline(void)
{
int i;
Expand All @@ -975,6 +989,13 @@ static void NetMsg_Parser_Parse_svc_spawnbaseline(void)
}
}

static void NetMsg_Parser_Parse_svc_fte_spawnbaseline2(void)
{
unsigned int entnum, bits, morebits;
NetMsg_Parser_ParseEntityNum(&entnum, &bits, &morebits);
NetMsg_Parser_ParseEntityDelta(bits, morebits);
}

static void NetMsg_Parser_Parse_svc_temp_entity(void)
{
int i;
Expand Down Expand Up @@ -1270,10 +1291,10 @@ static void NetMsg_Parser_Parse_svc_chokecount(void)
MSG_ReadByte();
}

static void NetMsg_Parser_Parse_svc_modellist(void)
static void NetMsg_Parser_Parse_svc_modellist(qbool extended)
{
char *str;
int model_count = MSG_ReadByte();
int model_count = extended ? MSG_ReadShort() : MSG_ReadByte();

while (true)
{
Expand Down Expand Up @@ -1313,6 +1334,39 @@ static void NetMsg_Parser_Parse_svc_soundlist(mvd_info_t *mvd)
MSG_ReadByte(); // Ignore.
}

static void NetMsg_Parser_ParsePacketEntities(mvd_info_t *mvd, qbool delta)
{
if (delta)
{
MSG_ReadByte();
if ((outgoing_sequence - incoming_sequence - 1) >= UPDATE_MASK)
{
return;
}
}

while (true)
{
unsigned int entnum, bits, morebits;

NetMsg_Parser_ParseEntityNum(&entnum, &bits, &morebits);

if (msg_badread)
{
// Something didn't parse right...
Sys_PrintError("NetMsg_Parser_ParsePacketEntities: msg_badread in packetentities.\n");
return;
}

if (!entnum)
{
break;
}

NetMsg_Parser_ParseEntityDelta(bits, morebits);
}
}

static void NetMsg_Parser_Parse_svc_packetentities(mvd_info_t *mvd)
{
NetMsg_Parser_ParsePacketEntities(mvd, false);
Expand Down Expand Up @@ -1541,7 +1595,12 @@ qbool NetMsg_Parser_StartParse(mvd_info_t *mvd)
}
case svc_modellist :
{
NetMsg_Parser_Parse_svc_modellist();
NetMsg_Parser_Parse_svc_modellist(false);
break;
}
case svc_fte_modellistshort :
{
NetMsg_Parser_Parse_svc_modellist(true);
break;
}
case svc_soundlist :
Expand All @@ -1559,6 +1618,11 @@ qbool NetMsg_Parser_StartParse(mvd_info_t *mvd)
NetMsg_Parser_Parse_svc_spawnbaseline();
break;
}
case svc_fte_spawnbaseline2 :
{
NetMsg_Parser_Parse_svc_fte_spawnbaseline2();
break;
}
case svc_updatefrags :
{
NetMsg_Parser_Parse_svc_updatefrags(mvd);
Expand Down Expand Up @@ -1674,6 +1738,11 @@ qbool NetMsg_Parser_StartParse(mvd_info_t *mvd)
NetMsg_Parser_Parse_svc_spawnstatic();
break;
}
case svc_fte_spawnstatic2 :
{
NetMsg_Parser_Parse_svc_fte_spawnstatic2();
break;
}
case svc_foundsecret :
{
NetMsg_Parser_Parse_svc_foundsecret();
Expand Down
6 changes: 3 additions & 3 deletions src/qw_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ char *svc_strings[] =
"svc_damage", // [byte] impact [byte] blood [vec3] from

"svc_spawnstatic",
"OBSOLETE svc_spawnbinary",
"svc_fte_spawnstatic2",
"svc_spawnbaseline",

"svc_temp_entity", // <variable>
Expand Down Expand Up @@ -78,13 +78,13 @@ char *svc_strings[] =
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"svc_fte_modellistshort",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL",
"NEW PROTOCOL"
"svc_fte_spawnbaseline2"
};


Expand Down
30 changes: 21 additions & 9 deletions src/qw_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extern char *print_strings[]; // Contains descriptions of the print levels.
#define svc_damage 19

#define svc_spawnstatic 20
// svc_spawnbinary 21
#define svc_fte_spawnstatic2 21
#define svc_spawnbaseline 22

#define svc_temp_entity 23 // variable
Expand Down Expand Up @@ -138,6 +138,8 @@ extern char *print_strings[]; // Contains descriptions of the print levels.
#define svc_serverinfo 52 // serverinfo
#define svc_updatepl 53 // [byte] [byte]
#define svc_nails2 54
#define svc_fte_modellistshort 60
#define svc_fte_spawnbaseline2 66
#define svc_qizmovoice 83

//==============================================
Expand Down Expand Up @@ -221,14 +223,24 @@ extern char *print_strings[]; // Contains descriptions of the print levels.
#define U_MOREBITS (1 << 15)

// if MOREBITS is set, these additional flags are read in next
#define U_ANGLE1 (1 << 0)
#define U_ANGLE3 (1 << 1)
#define U_MODEL (1 << 2)
#define U_COLORMAP (1 << 3)
#define U_SKIN (1 << 4)
#define U_EFFECTS (1 << 5)
#define U_SOLID (1 << 6) // the entity should be solid for prediction

#define U_ANGLE1 (1 << 0)
#define U_ANGLE3 (1 << 1)
#define U_MODEL (1 << 2)
#define U_COLORMAP (1 << 3)
#define U_SKIN (1 << 4)
#define U_EFFECTS (1 << 5)
#define U_SOLID (1 << 6) // the entity should be solid for prediction
#define U_FTE_EVENMORE (1 << 7)

// if EVENMORE is set, these additional flags are read in next
#define U_FTE_TRANS (1 << 1)
#define U_FTE_MODELDBL (1 << 3)
#define U_FTE_ENTITYDBL (1 << 5)
#define U_FTE_ENTITYDBL2 (1 << 6)
#define U_FTE_YETMORE (1 << 7)

// if YETMORE is set, these additional flags are read in next
#define U_FTE_COLOURMOD (1 << 10)
//==============================================

// a sound with no channel is a local only sound
Expand Down
2 changes: 2 additions & 0 deletions src/shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz)
}
#endif // LINUX & WIN32

#if !defined(__APPLE__)
size_t strlcat(char *dst, const char *src, size_t siz)
{
register char *d = dst;
Expand Down Expand Up @@ -185,6 +186,7 @@ size_t strlcat(char *dst, const char *src, size_t siz)

return(dlen + (s - src)); /* count does not include NUL */
}
#endif

// Implemented in later versions of Visual Studio (https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010)
#if defined(_MSC_VER) && _MSC_VER < 1900
Expand Down
2 changes: 1 addition & 1 deletion src/sys_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <sys/wait.h>
#include <sys/mman.h>
#include <semaphore.h>
#ifndef __FreeBSD__
#if !defined(__FreeBSD__) && !defined(__APPLE__)
#include <linux/rtc.h>
#endif
#include <sys/ioctl.h>
Expand Down