From 3b1622af95400814a85c8c8c24e9bac316d02bb5 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Wed, 25 Sep 2024 20:01:10 +0200 Subject: [PATCH] Common: fix crash on dedicated server First change callback of cvar 'mp_gamemode' must be removed as its client only, calling this on the server causes a crash as we never initialize client specific systems, therefore, the globals used in the change callback are null. --- src/common/global.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common/global.cpp b/src/common/global.cpp index 63721f29..13dae4a4 100644 --- a/src/common/global.cpp +++ b/src/common/global.cpp @@ -273,6 +273,12 @@ void ConVar_InitShipped(void) base_tickinterval_mp->RemoveFlags(FCVAR_DEVELOPMENTONLY); mp_gamemode->RemoveFlags(FCVAR_DEVELOPMENTONLY); + +#ifdef DEDICATED + // The base callback is for client builds only, must be removed from the + // dedicated server as it features client globals. + mp_gamemode->RemoveChangeCallback(mp_gamemode->GetChangeCallback(0), 0); +#endif // DEDICATED mp_gamemode->InstallChangeCallback(MP_GameMode_Changed_f, nullptr, false); net_usesocketsforloopback->RemoveFlags(FCVAR_DEVELOPMENTONLY); #ifndef DEDICATED