From 77f2894bc32a8e206423e4b2c57dbac3573c955e Mon Sep 17 00:00:00 2001
From: toaster <rollerorbital@gmail.com>
Date: Fri, 27 May 2022 23:21:25 +0100
Subject: [PATCH] Make a server report its preferred gametype on the MS
 listing, not its current one.

The intent is to stop servers from needing to dedicate their limited name/MOTD space to things like advertising `lessbattlevotes`, and to avoid "punishing" a server in visibility for allowing temporary gametype switches. However, this is possibly a controversial change, so I'm doing it in its own commit in case there's a clear consensus to revert.
---
 src/d_clisrv.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/d_clisrv.c b/src/d_clisrv.c
index 6f9158623..22bd659c6 100644
--- a/src/d_clisrv.c
+++ b/src/d_clisrv.c
@@ -1478,6 +1478,9 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
 	UINT8 *p;
 	size_t mirror_length;
 	const char *httpurl = cv_httpsource.string;
+	UINT8 gt = (cv_kartgametypepreference.value == -1)
+		? gametype
+		: cv_kartgametypepreference.value;
 
 	netbuffer->packettype = PT_SERVERINFO;
 	netbuffer->u.serverinfo._255 = 255;
@@ -1492,7 +1495,10 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
 
 	netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers();
 	netbuffer->u.serverinfo.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value));
-	netbuffer->u.serverinfo.gametype = (UINT8)(G_BattleGametype() ? VANILLA_GT_MATCH : VANILLA_GT_RACE); // SRB2Kart: Vanilla's gametype constants for MS support
+
+	// SRB2Kart: Vanilla's gametype constants for MS support
+	netbuffer->u.serverinfo.gametype = (UINT8)((gt == GT_MATCH) ? VANILLA_GT_MATCH : VANILLA_GT_RACE);
+
 	netbuffer->u.serverinfo.modifiedgame = (UINT8)modifiedgame;
 	netbuffer->u.serverinfo.cheatsenabled = CV_CheatsEnabled();
 
-- 
GitLab