From cdb3dd0493749dd5c62378f318ea61bcb85f988f Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sun, 30 May 2021 15:59:40 +0200 Subject: Add: store headers for most savegame chunks When a header is added, the chunk changes from CH_ARRAY type to CH_TABLE type. --- src/saveload/depot_sl.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/saveload/depot_sl.cpp') diff --git a/src/saveload/depot_sl.cpp b/src/saveload/depot_sl.cpp index 6af08e718..c1252562a 100644 --- a/src/saveload/depot_sl.cpp +++ b/src/saveload/depot_sl.cpp @@ -8,10 +8,12 @@ /** @file depot_sl.cpp Code handling saving and loading of depots */ #include "../stdafx.h" -#include "../depot_base.h" -#include "../town.h" #include "saveload.h" +#include "compat/depot_sl_compat.h" + +#include "../depot_base.h" +#include "../town.h" #include "../safeguards.h" @@ -29,6 +31,8 @@ static const SaveLoad _depot_desc[] = { static void Save_DEPT() { + SlTableHeader(_depot_desc); + for (Depot *depot : Depot::Iterate()) { SlSetArrayIndex(depot->index); SlObject(depot, _depot_desc); @@ -37,11 +41,13 @@ static void Save_DEPT() static void Load_DEPT() { + const std::vector slt = SlCompatTableHeader(_depot_desc, _depot_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { Depot *depot = new (index) Depot(); - SlObject(depot, _depot_desc); + SlObject(depot, slt); /* Set the town 'pointer' so we can restore it later. */ if (IsSavegameVersionBefore(SLV_141)) depot->town = (Town *)(size_t)_town_index; @@ -57,7 +63,7 @@ static void Ptrs_DEPT() } static const ChunkHandler depot_chunk_handlers[] = { - { 'DEPT', Save_DEPT, Load_DEPT, Ptrs_DEPT, nullptr, CH_ARRAY }, + { 'DEPT', Save_DEPT, Load_DEPT, Ptrs_DEPT, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _depot_chunk_handlers(depot_chunk_handlers); -- cgit v1.2.3-54-g00ecf