Skip to content

Commit

Permalink
PARSING: Support FTE's sv_bigcoords extension
Browse files Browse the repository at this point in the history
  • Loading branch information
meag committed Sep 17, 2020
1 parent bd4a278 commit 3284dcb
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
13 changes: 13 additions & 0 deletions net_msg.c
Expand Up @@ -4,6 +4,8 @@
#include "qw_protocol.h"
#include "net_msg.h"

static qbool use_bigcoords = false;

sizebuf_t net_message;
int msg_readcount;
qbool msg_badread;
Expand Down Expand Up @@ -162,11 +164,17 @@ char *MSG_ReadStringLine(void)

float MSG_ReadCoord (void)
{
if (use_bigcoords) {
return MSG_ReadFloat();
}
return MSG_ReadShort() * (1.0f / 8);
}

float MSG_ReadAngle (void)
{
if (use_bigcoords) {
return MSG_ReadAngle16();
}
return MSG_ReadChar() * (360.0f / 256);
}

Expand Down Expand Up @@ -237,3 +245,8 @@ void MSG_ReadDeltaUsercmd(usercmd_t *from, usercmd_t *move, int protoversion)
move->msec = MSG_ReadByte (); // always sent
}
}

void MSG_SetBigCoordSupport(qbool enabled)
{
use_bigcoords = enabled;
}
1 change: 1 addition & 0 deletions net_msg.h
Expand Up @@ -26,5 +26,6 @@ float MSG_ReadAngle16 (void);
#define CM_MSEC (1 << 7) // same as CM_ANGLE2

void MSG_ReadDeltaUsercmd(usercmd_t *from, usercmd_t *move, int protoversion);
void MSG_SetBigCoordSupport(qbool enabled);

#endif // __NET_MSG_H__
21 changes: 20 additions & 1 deletion netmsg_parser.c
Expand Up @@ -818,7 +818,26 @@ static void NetMsg_Parser_Parse_svc_setangle(void)

static void NetMsg_Parser_Parse_svc_serverdata(mvd_info_t *mvd)
{
mvd->serverinfo.protocol_version = MSG_ReadLong();
int protocol;

while (true) {
protocol = MSG_ReadLong();
if (protocol == PROTOCOL_VERSION_FTE) {
mvd->extension_flags_fte1 = MSG_ReadLong();
MSG_SetBigCoordSupport(mvd->extension_flags_fte1 & FTE_PEXT_FLOATCOORDS);
}
else if (protocol == PROTOCOL_VERSION_FTE2) {
mvd->extension_flags_fte2 = MSG_ReadLong();
}
else if (protocol == PROTOCOL_VERSION_MVD1) {
mvd->extension_flags_mvd = MSG_ReadLong();
}
else {
break;
}
}

mvd->serverinfo.protocol_version = protocol;
mvd->serverinfo.servercount = MSG_ReadLong();

// Gamedir.
Expand Down
11 changes: 11 additions & 0 deletions qw_protocol.h
Expand Up @@ -546,6 +546,10 @@ typedef struct mvd_info_s

log_event_t *log_events_tail;
log_event_t *log_events_head;

unsigned int extension_flags_fte1;
unsigned int extension_flags_fte2;
unsigned int extension_flags_mvd;
} mvd_info_t;

// usercmd button bits
Expand Down Expand Up @@ -584,4 +588,11 @@ typedef struct temp_entity_list_s

temp_entity_list_t temp_entities;

// Protocol extensions
#define PROTOCOL_VERSION_FTE (('F'<<0) + ('T'<<8) + ('E'<<16) + ('X' << 24)) //fte extensions.
#define PROTOCOL_VERSION_FTE2 (('F'<<0) + ('T'<<8) + ('E'<<16) + ('2' << 24)) //fte extensions.
#define PROTOCOL_VERSION_MVD1 (('M'<<0) + ('V'<<8) + ('D'<<16) + ('1' << 24)) //mvdsv extensions.

#define FTE_PEXT_FLOATCOORDS 0x00008000

#endif // __QW_PROTOCOL_H__

0 comments on commit 3284dcb

Please sign in to comment.