diff options
author | Patric Stout <truebrain@openttd.org> | 2021-06-06 09:59:33 +0200 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2021-06-15 19:36:15 +0200 |
commit | 88edfd4ef16bedd98a07a2142e693ab50fbdcef2 (patch) | |
tree | f39b00764786763b3350dd06c2c4014605678ca1 /src/settings.cpp | |
parent | b9ab9e4d051eea7d6aedfb60930b039b778568af (diff) | |
download | openttd-88edfd4ef16bedd98a07a2142e693ab50fbdcef2.tar.xz |
Change: rework several CH_RIFF chunks to use CH_ARRAY instead
This adds two byte extra to those chunks, and might feel a bit
silly at first. But in later changes we will prefix CH_ARRAY with
a table header, and then this change shines.
Without this, we could still add headers to these chunks, but any
external reader wouldn't know if the CH_RIFF has them or not. This
way is much more practical, as they are now more like any other
chunk.
Diffstat (limited to 'src/settings.cpp')
-rw-r--r-- | src/settings.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index 54189a0fc..169549955 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -2045,7 +2045,9 @@ static void LoadSettings(const SettingTable &settings, void *object) { const std::vector<SaveLoad> slt = GetSettingsDesc(settings, true); + if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return; SlObject(object, slt); + if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many settings entries"); /* Ensure all IntSettings are valid (min/max could have changed between versions etc). */ for (auto &sd : settings) { @@ -2070,6 +2072,7 @@ static void SaveSettings(const SettingTable &settings, void *object) { const std::vector<SaveLoad> slt = GetSettingsDesc(settings, false); + SlSetArrayIndex(0); SlObject(object, slt); } @@ -2102,8 +2105,8 @@ static void Save_PATS() } static const ChunkHandler setting_chunk_handlers[] = { - { 'OPTS', nullptr, Load_OPTS, nullptr, nullptr, CH_RIFF }, - { 'PATS', Save_PATS, Load_PATS, nullptr, Check_PATS, CH_RIFF }, + { 'OPTS', nullptr, Load_OPTS, nullptr, nullptr, CH_RIFF }, + { 'PATS', Save_PATS, Load_PATS, nullptr, Check_PATS, CH_ARRAY }, }; extern const ChunkHandlerTable _setting_chunk_handlers(setting_chunk_handlers); |