diff options
author | Patric Stout <truebrain@openttd.org> | 2021-06-12 13:23:19 +0200 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2021-06-15 16:45:04 +0200 |
commit | 0d2e3437e3317a5bc7f9a806e76a89091d2cb6d3 (patch) | |
tree | 7cb3b36e1630ef8d33ec020a5d7a519b5dfb37ac /src/saveload | |
parent | 75e7451151ea9ab1ed18cd04b1229f68b7d3dcf5 (diff) | |
download | openttd-0d2e3437e3317a5bc7f9a806e76a89091d2cb6d3.tar.xz |
Change: switch SL_DEQUE and SL_REFLIST length field to a gamma
The current SaveLoad is a bit inconsistent how long a length field
is. Sometimes it is a 32bit, sometimes a gamma. Make it consistent
across the board by making them all gammas.
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/saveload.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 9f3aa7d1d..2d1e6fc78 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -1261,7 +1261,7 @@ public: const SlStorageT *list = static_cast<const SlStorageT *>(storage); - int type_size = SlCalcConvFileLen(SLE_FILE_U32); // Size of the length of the list. + int type_size = SlGetArrayLength(list->size()); int item_size = SlCalcConvFileLen(cmd == SL_VAR ? conv : (VarType)SLE_FILE_U32); return list->size() * item_size + type_size; } @@ -1290,7 +1290,7 @@ public: switch (_sl.action) { case SLA_SAVE: - SlWriteUint32((uint32)list->size()); + SlWriteArrayLength(list->size()); for (auto &item : *list) { SlSaveLoadMember(cmd, &item, conv); @@ -1301,8 +1301,8 @@ public: case SLA_LOAD: { size_t length; switch (cmd) { - case SL_VAR: length = SlReadUint32(); break; - case SL_REF: length = IsSavegameVersionBefore(SLV_69) ? SlReadUint16() : SlReadUint32(); break; + case SL_VAR: length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? SlReadUint32() : SlReadArrayLength(); break; + case SL_REF: length = IsSavegameVersionBefore(SLV_69) ? SlReadUint16() : IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? SlReadUint32() : SlReadArrayLength(); break; default: NOT_REACHED(); } |