From f7dc2777c536b485d2b935ac174d13400b580195 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sun, 24 Mar 2024 12:32:30 +0200 Subject: [PATCH] server: support of load original game library --- src/client/cl_parse.c | 2 +- src/common/header/shared.h | 20 -------------------- src/common/protocol.c | 20 ++++++++++++++++++++ src/game/header/game.h | 1 + src/server/sv_game.c | 3 ++- src/server/sv_user.c | 13 +++++++++++-- 6 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/client/cl_parse.c b/src/client/cl_parse.c index d749bbb1..3491b69d 100644 --- a/src/client/cl_parse.c +++ b/src/client/cl_parse.c @@ -1159,7 +1159,7 @@ CL_ParseConfigString(void) Q_strlcpy(olds, cl.configstrings[i], sizeof(olds)); length = strlen(s); - if (length > sizeof(cl.configstrings) - sizeof(cl.configstrings[0])*i - 1) + if (length > sizeof(cl.configstrings) - sizeof(cl.configstrings[0]) * i - 1) { Com_Error(ERR_DROP, "%s: oversize configstring", __func__); } diff --git a/src/common/header/shared.h b/src/common/header/shared.h index 4ed49d0b..30036e76 100644 --- a/src/common/header/shared.h +++ b/src/common/header/shared.h @@ -169,16 +169,6 @@ typedef unsigned char byte; #define PRINTF_ATTR(FMT, VARGS) __attribute__((format(printf, FMT , VARGS ))) #endif -/* per-level limits Quake 2 Protocol version 26 */ -#define MAX_CLIENTS_Q2DEMO 256 /* absolute limit */ -#define MAX_EDICTS_Q2DEMO 1024 /* must change protocol to increase more */ -#define MAX_LIGHTSTYLES_Q2DEMO 256 -#define MAX_MODELS_Q2DEMO 256 /* these are sent over the net as bytes */ -#define MAX_SOUNDS_Q2DEMO 256 /* so they cannot be blindly increased */ -#define MAX_IMAGES_Q2DEMO 256 -#define MAX_ITEMS_Q2DEMO 256 -#define MAX_GENERAL_Q2DEMO (MAX_CLIENTS_Q2DEMO * 2) /* general config strings */ - /* per-level limits */ #define MAX_CLIENTS 256 /* absolute limit */ #define MAX_EDICTS 1024 /* must change protocol to increase more */ @@ -1164,16 +1154,6 @@ typedef enum #define CS_MAXCLIENTS 30 #define CS_MAPCHECKSUM 31 /* for catching cheater maps */ -/* CS structure Quake 2 Protocol version 26 */ -#define CS_MODELS_Q2DEMO 32 -#define CS_SOUNDS_Q2DEMO (CS_MODELS_Q2DEMO + MAX_MODELS_Q2DEMO) -#define CS_IMAGES_Q2DEMO (CS_SOUNDS_Q2DEMO + MAX_SOUNDS_Q2DEMO) -#define CS_LIGHTS_Q2DEMO (CS_IMAGES_Q2DEMO + MAX_IMAGES_Q2DEMO) -#define CS_ITEMS_Q2DEMO (CS_LIGHTS_Q2DEMO + MAX_LIGHTSTYLES_Q2DEMO) -#define CS_PLAYERSKINS_Q2DEMO (CS_ITEMS_Q2DEMO + MAX_ITEMS_Q2DEMO) -#define CS_GENERAL_Q2DEMO (CS_PLAYERSKINS_Q2DEMO + MAX_CLIENTS_Q2DEMO) -#define MAX_CONFIGSTRINGS_Q2DEMO (CS_GENERAL_Q2DEMO + MAX_GENERAL_Q2DEMO) - #define CS_MODELS 32 #define CS_SOUNDS (CS_MODELS + MAX_MODELS) #define CS_IMAGES (CS_SOUNDS + MAX_SOUNDS) diff --git a/src/common/protocol.c b/src/common/protocol.c index f5f4115e..c0e9ac2f 100644 --- a/src/common/protocol.c +++ b/src/common/protocol.c @@ -27,6 +27,26 @@ #include "header/shared.h" #include "header/common.h" +/* per-level limits Quake 2 Protocol version 26 */ +#define MAX_CLIENTS_Q2DEMO 256 /* absolute limit */ +#define MAX_EDICTS_Q2DEMO 1024 /* must change protocol to increase more */ +#define MAX_LIGHTSTYLES_Q2DEMO 256 +#define MAX_MODELS_Q2DEMO 256 /* these are sent over the net as bytes */ +#define MAX_SOUNDS_Q2DEMO 256 /* so they cannot be blindly increased */ +#define MAX_IMAGES_Q2DEMO 256 +#define MAX_ITEMS_Q2DEMO 256 +#define MAX_GENERAL_Q2DEMO (MAX_CLIENTS_Q2DEMO * 2) /* general config strings */ + +/* CS structure Quake 2 Protocol version 26 */ +#define CS_MODELS_Q2DEMO 32 +#define CS_SOUNDS_Q2DEMO (CS_MODELS_Q2DEMO + MAX_MODELS_Q2DEMO) +#define CS_IMAGES_Q2DEMO (CS_SOUNDS_Q2DEMO + MAX_SOUNDS_Q2DEMO) +#define CS_LIGHTS_Q2DEMO (CS_IMAGES_Q2DEMO + MAX_IMAGES_Q2DEMO) +#define CS_ITEMS_Q2DEMO (CS_LIGHTS_Q2DEMO + MAX_LIGHTSTYLES_Q2DEMO) +#define CS_PLAYERSKINS_Q2DEMO (CS_ITEMS_Q2DEMO + MAX_ITEMS_Q2DEMO) +#define CS_GENERAL_Q2DEMO (CS_PLAYERSKINS_Q2DEMO + MAX_CLIENTS_Q2DEMO) +#define MAX_CONFIGSTRINGS_Q2DEMO (CS_GENERAL_Q2DEMO + MAX_GENERAL_Q2DEMO) + /* Convert from current protocol to internal */ int P_ConvertConfigStringFrom(int i, int protocol) diff --git a/src/game/header/game.h b/src/game/header/game.h index 683d201c..5b61f956 100644 --- a/src/game/header/game.h +++ b/src/game/header/game.h @@ -35,6 +35,7 @@ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ +#define GAME_API_R97_VERSION 3 #define GAME_API_VERSION 4 /* edict->svflags */ diff --git a/src/server/sv_game.c b/src/server/sv_game.c index d0b1b169..3e5173a8 100644 --- a/src/server/sv_game.c +++ b/src/server/sv_game.c @@ -458,7 +458,8 @@ SV_InitGameProgs(void) Com_Error(ERR_DROP, "failed to load game DLL"); } - if (ge->apiversion != GAME_API_VERSION) + if (ge->apiversion != GAME_API_VERSION && + ge->apiversion != GAME_API_R97_VERSION) { Com_Error(ERR_DROP, "game is version %i, not %i", ge->apiversion, GAME_API_VERSION); diff --git a/src/server/sv_user.c b/src/server/sv_user.c index 9259bc03..272b0713 100644 --- a/src/server/sv_user.c +++ b/src/server/sv_user.c @@ -75,9 +75,18 @@ SV_New_f(void) gamedir = (char *)Cvar_VariableString("gamedir"); /* send the serverdata */ - sv_client->protocol = PROTOCOL_VERSION; + if (ge->apiversion == GAME_API_R97_VERSION) + { + /* backward compatibility */ + sv_client->protocol = PROTOCOL_RR97_VERSION; + } + else + { + sv_client->protocol = PROTOCOL_VERSION; + } + MSG_WriteByte(&sv_client->netchan.message, svc_serverdata); - MSG_WriteLong(&sv_client->netchan.message, PROTOCOL_VERSION); + MSG_WriteLong(&sv_client->netchan.message, sv_client->protocol); MSG_WriteLong(&sv_client->netchan.message, svs.spawncount); MSG_WriteByte(&sv_client->netchan.message, sv.attractloop); MSG_WriteString(&sv_client->netchan.message, gamedir);