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/saveload/economy_sl.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/saveload/economy_sl.cpp')
-rw-r--r-- | src/saveload/economy_sl.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/saveload/economy_sl.cpp b/src/saveload/economy_sl.cpp index 82e3014ad..7a0f536b2 100644 --- a/src/saveload/economy_sl.cpp +++ b/src/saveload/economy_sl.cpp @@ -51,13 +51,17 @@ static const SaveLoad _economy_desc[] = { /** Economy variables */ static void Save_ECMY() { + SlSetArrayIndex(0); SlObject(&_economy, _economy_desc); } /** Economy variables */ static void Load_ECMY() { + if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return; SlObject(&_economy, _economy_desc); + if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many ECMY entries"); + StartupIndustryDailyChanges(IsSavegameVersionBefore(SLV_102)); // old savegames will need to be initialized } @@ -98,7 +102,7 @@ static const ChunkHandler economy_chunk_handlers[] = { { 'CAPY', Save_CAPY, Load_CAPY, Ptrs_CAPY, nullptr, CH_ARRAY }, { 'PRIC', nullptr, Load_PRIC, nullptr, nullptr, CH_RIFF }, { 'CAPR', nullptr, Load_CAPR, nullptr, nullptr, CH_RIFF }, - { 'ECMY', Save_ECMY, Load_ECMY, nullptr, nullptr, CH_RIFF }, + { 'ECMY', Save_ECMY, Load_ECMY, nullptr, nullptr, CH_ARRAY }, }; extern const ChunkHandlerTable _economy_chunk_handlers(economy_chunk_handlers); |