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.
This commit is contained in:
Kawe Mazidjatari 2024-12-05 13:50:38 +01:00
parent 7fd33da180
commit fbf95f64ad

View File

@ -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);