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

@@ -287,6 +287,7 @@ static void Load_LGRJ()
*/
static void Save_LGRS()
{
SlSetArrayIndex(0);
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
}
@@ -295,7 +296,9 @@ static void Save_LGRS()
*/
static void Load_LGRS()
{
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return;
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many LGRS entries");
}
/**
@@ -309,7 +312,7 @@ static void Ptrs_LGRS()
static const ChunkHandler linkgraph_chunk_handlers[] = {
{ 'LGRP', Save_LGRP, Load_LGRP, nullptr, nullptr, CH_ARRAY },
{ 'LGRJ', Save_LGRJ, Load_LGRJ, nullptr, nullptr, CH_ARRAY },
{ 'LGRS', Save_LGRS, Load_LGRS, Ptrs_LGRS, nullptr, CH_RIFF }
{ 'LGRS', Save_LGRS, Load_LGRS, Ptrs_LGRS, nullptr, CH_ARRAY },
};
extern const ChunkHandlerTable _linkgraph_chunk_handlers(linkgraph_chunk_handlers);