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.
This commit is contained in:
Patric Stout
2021-06-06 09:59:33 +02:00
committed by Patric Stout
parent b9ab9e4d05
commit 88edfd4ef1
10 changed files with 97 additions and 32 deletions

View File

@@ -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);