From fbf95f64ad033e52f700d06ccd7873f8a566709f Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:50:38 +0100 Subject: [PATCH] Common: fully replace 'mp_common' change callback There was a bug where we only removed the old change callback on the dedicated server. On client builds we added a second one causing SetupGameMode to be called twice, and the second call will be with the incorrect (previously set) gamemode. We now fully replace the callback because the one we have in the SDK is identical to the one in the engine, except it does not call SetupGamemode through the client's engine interface. --- src/common/global.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/global.cpp b/src/common/global.cpp index ef70c7f2..d05a2250 100644 --- a/src/common/global.cpp +++ b/src/common/global.cpp @@ -272,14 +272,14 @@ void ConVar_InitShipped(void) base_tickinterval_sp->RemoveFlags(FCVAR_DEVELOPMENTONLY); 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. + // The base callback is for client builds only, must be replaced with the + // dedicated server variant as the original one runs this through + // CEngineClient::SetupGamemode(). The callback is effectively the same + // with the exception that it calls SetupGamemode directly, and not + // through an interface like CEngineClient. 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 language_cvar->InstallChangeCallback(LanguageChanged_f, nullptr, false);