diff options
author | Patric Stout <truebrain@openttd.org> | 2020-12-13 16:28:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-13 16:28:06 +0100 |
commit | c66bd18a1087d4b34d79faf68afb9ff8fea89be4 (patch) | |
tree | 8a6127387ff47514e586867238bfb3156140786a /src/settings.cpp | |
parent | 40edc2863ccec78eac80ee2918188f1e1d605ce0 (diff) | |
download | openttd-c66bd18a1087d4b34d79faf68afb9ff8fea89be4.tar.xz |
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.
Diffstat (limited to 'src/settings.cpp')
-rw-r--r-- | src/settings.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index 2966a3e22..02cd52004 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -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; } |