Fix setting callbacks when using setting_newgame console command

See: https://github.com/OpenTTD/OpenTTD/issues/12059
This commit is contained in:
Jonathan G Rennison
2024-02-16 18:25:47 +00:00
parent bd74340416
commit 3ec77973df

View File

@@ -3381,6 +3381,12 @@ void IConsoleSetSetting(const char *name, const char *value, bool force_newgame)
return; return;
} }
const auto old_game_mode = _game_mode;
if (force_newgame) _game_mode = GM_MENU;
auto guard = scope_guard([force_newgame, old_game_mode]() {
if (force_newgame) _game_mode = old_game_mode;
});
bool success = true; bool success = true;
if (sd->IsStringSetting()) { if (sd->IsStringSetting()) {
success = SetSettingValue(sd->AsStringSetting(), value, force_newgame); success = SetSettingValue(sd->AsStringSetting(), value, force_newgame);