diff --git a/src/netmsg_parser.c b/src/netmsg_parser.c index 958659b..098fbc3 100644 --- a/src/netmsg_parser.c +++ b/src/netmsg_parser.c @@ -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 } } @@ -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; @@ -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; @@ -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) { @@ -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); @@ -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 : @@ -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); @@ -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(); diff --git a/src/qw_protocol.c b/src/qw_protocol.c index 2a218d2..4f6870b 100644 --- a/src/qw_protocol.c +++ b/src/qw_protocol.c @@ -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", // @@ -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" }; diff --git a/src/qw_protocol.h b/src/qw_protocol.h index 869798c..5f870a0 100644 --- a/src/qw_protocol.h +++ b/src/qw_protocol.h @@ -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 @@ -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 //============================================== @@ -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 diff --git a/src/shared.c b/src/shared.c index 8d61354..e035db3 100644 --- a/src/shared.c +++ b/src/shared.c @@ -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; @@ -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 diff --git a/src/sys_linux.c b/src/sys_linux.c index d36a251..a60d07d 100644 --- a/src/sys_linux.c +++ b/src/sys_linux.c @@ -17,7 +17,7 @@ #include #include #include -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__APPLE__) #include #endif #include