Add: save openttd.cfg immediately on changing a setting (#8358)
Formally it was only done on exit. This means that if it crashes changes in settings were not stored. This is often rather frustrating. Additionally, targets (like emscripten) where people are unlike to use "Exit Game", will never see their configuration stored. The drawback is that on every setting change there is some minor I/O of writing the ini file to disk again.
This commit is contained in:
@@ -1913,6 +1913,8 @@ CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
||||
}
|
||||
|
||||
SetWindowClassesDirty(WC_GAME_OPTIONS);
|
||||
|
||||
if (_save_config) SaveToConfig();
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
@@ -1981,12 +1983,15 @@ bool SetSettingValue(uint index, int32 value, bool force_newgame)
|
||||
|
||||
SetWindowClassesDirty(WC_GAME_OPTIONS);
|
||||
|
||||
if (_save_config) SaveToConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (force_newgame) {
|
||||
void *var2 = GetVariableAddress(&_settings_newgame, &sd->save);
|
||||
Write_ValidateSetting(var2, sd, value);
|
||||
|
||||
if (_save_config) SaveToConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2080,6 +2085,7 @@ bool SetSettingValue(uint index, const char *value, bool force_newgame)
|
||||
}
|
||||
if (sd->desc.proc != nullptr) sd->desc.proc(0);
|
||||
|
||||
if (_save_config) SaveToConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user