Fix setting callbacks when using setting_newgame console command
See: https://github.com/OpenTTD/OpenTTD/issues/12059
This commit is contained in:
@@ -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);
|
||||||
|
Reference in New Issue
Block a user