From 6aa0b2a92bec2cfb0be2012eee6a1c8b4de81d73 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sun, 24 Mar 2024 13:22:42 +0200 Subject: [PATCH] server: QII97 protocol version check unification --- src/client/cl_parse.c | 12 +++--------- src/common/header/common.h | 8 +++++++- src/common/movemsg.c | 5 +---- src/common/protocol.c | 10 ++-------- src/server/sv_user.c | 2 +- 5 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/client/cl_parse.c b/src/client/cl_parse.c index 3491b69d..391c01f4 100644 --- a/src/client/cl_parse.c +++ b/src/client/cl_parse.c @@ -143,10 +143,7 @@ CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits) VectorCopy(from->origin, to->old_origin); to->number = number; - if ((cls.serverProtocol == PROTOCOL_RELEASE_VERSION) || - (cls.serverProtocol == PROTOCOL_DEMO_VERSION) || - (cls.serverProtocol == PROTOCOL_XATRIX_VERSION) || - (cls.serverProtocol == PROTOCOL_RR97_VERSION)) + if (IS_QII97_PROTOCOL(cls.serverProtocol)) { if (bits & U_MODEL) { @@ -882,10 +879,7 @@ CL_ParseServerData(void) /* another demo hack */ if (Com_ServerState() && ( - (i == PROTOCOL_RELEASE_VERSION) || - (i == PROTOCOL_DEMO_VERSION) || - (i == PROTOCOL_XATRIX_VERSION) || - (i == PROTOCOL_RR97_VERSION) || + IS_QII97_PROTOCOL(i) || (i == PROTOCOL_RR22_VERSION) || (i == PROTOCOL_RR23_VERSION) || (i == PROTOCOL_VERSION))) @@ -903,7 +897,7 @@ CL_ParseServerData(void) Com_Printf("Quake 2 Release Demo\n"); break; /* Network protocol */ - case PROTOCOL_RR97_VERSION: + case PROTOCOL_R97_VERSION: Com_Printf("Quake 2\n"); break; /* ReRelease Demo */ diff --git a/src/common/header/common.h b/src/common/header/common.h index 62345a35..661e54e9 100644 --- a/src/common/header/common.h +++ b/src/common/header/common.h @@ -182,7 +182,7 @@ void Info_Print(char *s); /* Quake 2 Xatrix Demo */ #define PROTOCOL_XATRIX_VERSION 32 /* Quake 2 Network Release */ -#define PROTOCOL_RR97_VERSION 34 +#define PROTOCOL_R97_VERSION 34 /* ReRelease demo files */ #define PROTOCOL_RR22_VERSION 2022 /* ReRelease network protocol */ @@ -190,6 +190,12 @@ void Info_Print(char *s); /* Quake 2 Customized Network Release */ #define PROTOCOL_VERSION 2024 +#define IS_QII97_PROTOCOL(x) ( \ + ((x) == PROTOCOL_RELEASE_VERSION) || \ + ((x) == PROTOCOL_DEMO_VERSION) || \ + ((x) == PROTOCOL_XATRIX_VERSION) || \ + ((x) == PROTOCOL_R97_VERSION)) + /* ========================================= */ #define PORT_MASTER 27900 diff --git a/src/common/movemsg.c b/src/common/movemsg.c index 7a378c20..fd312c29 100644 --- a/src/common/movemsg.c +++ b/src/common/movemsg.c @@ -645,10 +645,7 @@ MSG_WriteDeltaEntity(entity_state_t *from, MSG_WriteByte(msg, to->number); } - if ((protocol == PROTOCOL_RELEASE_VERSION) || - (protocol == PROTOCOL_DEMO_VERSION) || - (protocol == PROTOCOL_XATRIX_VERSION) || - (protocol == PROTOCOL_RR97_VERSION)) + if (IS_QII97_PROTOCOL(protocol)) { if (bits & U_MODEL) { diff --git a/src/common/protocol.c b/src/common/protocol.c index c0e9ac2f..6ec9c150 100644 --- a/src/common/protocol.c +++ b/src/common/protocol.c @@ -51,10 +51,7 @@ int P_ConvertConfigStringFrom(int i, int protocol) { - if (protocol == PROTOCOL_RELEASE_VERSION || - protocol == PROTOCOL_DEMO_VERSION || - protocol == PROTOCOL_XATRIX_VERSION || - protocol == PROTOCOL_RR97_VERSION) + if (IS_QII97_PROTOCOL(protocol)) { if (i >= CS_MODELS_Q2DEMO && i < CS_SOUNDS_Q2DEMO) { @@ -93,10 +90,7 @@ P_ConvertConfigStringFrom(int i, int protocol) int P_ConvertConfigStringTo(int i, int protocol) { - if (protocol == PROTOCOL_RELEASE_VERSION || - protocol == PROTOCOL_DEMO_VERSION || - protocol == PROTOCOL_XATRIX_VERSION || - protocol == PROTOCOL_RR97_VERSION) + if (IS_QII97_PROTOCOL(protocol)) { if (i >= CS_MODELS && i < CS_SOUNDS) { diff --git a/src/server/sv_user.c b/src/server/sv_user.c index 272b0713..ed9816b7 100644 --- a/src/server/sv_user.c +++ b/src/server/sv_user.c @@ -78,7 +78,7 @@ SV_New_f(void) if (ge->apiversion == GAME_API_R97_VERSION) { /* backward compatibility */ - sv_client->protocol = PROTOCOL_RR97_VERSION; + sv_client->protocol = PROTOCOL_R97_VERSION; } else {