summaryrefslogtreecommitdiff
path: root/src/saveload/linkgraph_sl.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-06-06 09:59:33 +0200
committerPatric Stout <github@truebrain.nl>2021-06-15 19:36:15 +0200
commit88edfd4ef16bedd98a07a2142e693ab50fbdcef2 (patch)
treef39b00764786763b3350dd06c2c4014605678ca1 /src/saveload/linkgraph_sl.cpp
parentb9ab9e4d051eea7d6aedfb60930b039b778568af (diff)
downloadopenttd-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/linkgraph_sl.cpp')
-rw-r--r--src/saveload/linkgraph_sl.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp
index fc72d4383..7000946da 100644
--- a/src/saveload/linkgraph_sl.cpp
+++ b/src/saveload/linkgraph_sl.cpp
@@ -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);