From f7ec7d268e48acb6a38717790873fc611ad9b3a4 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Wed, 24 Apr 2024 00:11:01 +0300 Subject: [PATCH] server: use game api version for protocol detect --- src/server/header/server.h | 1 + src/server/sv_cmd.c | 4 ++-- src/server/sv_game.c | 5 +---- src/server/sv_user.c | 26 ++++++++++++++++---------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/server/header/server.h b/src/server/header/server.h index 04c19785..e4afa0b1 100644 --- a/src/server/header/server.h +++ b/src/server/header/server.h @@ -238,6 +238,7 @@ void SV_StartSound(vec3_t origin, edict_t *entity, int channel, void SV_ClientPrintf(client_t *cl, int level, const char *fmt, ...); void SV_BroadcastPrintf(int level, const char *fmt, ...); void SV_BroadcastCommand(const char *fmt, ...); +int SV_GetRecomendedProtocol(void); void SV_Nextserver(void); void SV_ExecuteClientMessage(client_t *cl); diff --git a/src/server/sv_cmd.c b/src/server/sv_cmd.c index f707434f..e3bfab8d 100644 --- a/src/server/sv_cmd.c +++ b/src/server/sv_cmd.c @@ -186,7 +186,7 @@ SV_GameMap_f(void) return; } - Com_DPrintf("SV_GameMap(%s)\n", Cmd_Argv(1)); + Com_DPrintf("%s(%s)\n", __func__, Cmd_Argv(1)); FS_CreatePath(va("%s/save/current/", FS_Gamedir())); @@ -595,7 +595,7 @@ SV_ServerRecord_f(void) /* serverdata needs to go over for all types of servers to make sure the protocol is right, and to set the gamedir */ MSG_WriteByte(&buf, svc_serverdata); - MSG_WriteLong(&buf, PROTOCOL_VERSION); + MSG_WriteLong(&buf, SV_GetRecomendedProtocol()); MSG_WriteLong(&buf, svs.spawncount); /* 2 means server demo */ diff --git a/src/server/sv_game.c b/src/server/sv_game.c index 8cd62ed6..6e03254e 100644 --- a/src/server/sv_game.c +++ b/src/server/sv_game.c @@ -201,10 +201,7 @@ PF_Configstring(int index, const char *val) val = ""; } - if (sv_client) - { - index = P_ConvertConfigStringFrom(index, sv_client->protocol); - } + index = P_ConvertConfigStringFrom(index, SV_GetRecomendedProtocol()); if ((index < 0) || (index >= MAX_CONFIGSTRINGS)) { diff --git a/src/server/sv_user.c b/src/server/sv_user.c index ed9816b7..2850e2b0 100644 --- a/src/server/sv_user.c +++ b/src/server/sv_user.c @@ -44,6 +44,21 @@ SV_BeginDemoserver(void) } } +int +SV_GetRecomendedProtocol(void) +{ + if (ge->apiversion == GAME_API_R97_VERSION) + { + /* backward compatibility */ + return PROTOCOL_R97_VERSION; + } + else + { + return PROTOCOL_VERSION; + } + +} + /* * Sends the first message from the server to a connected client. * This will be sent on the initial connection and upon each server load. @@ -75,16 +90,7 @@ SV_New_f(void) gamedir = (char *)Cvar_VariableString("gamedir"); /* send the serverdata */ - if (ge->apiversion == GAME_API_R97_VERSION) - { - /* backward compatibility */ - sv_client->protocol = PROTOCOL_R97_VERSION; - } - else - { - sv_client->protocol = PROTOCOL_VERSION; - } - + sv_client->protocol = SV_GetRecomendedProtocol(); MSG_WriteByte(&sv_client->netchan.message, svc_serverdata); MSG_WriteLong(&sv_client->netchan.message, sv_client->protocol); MSG_WriteLong(&sv_client->netchan.message, svs.spawncount);