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/object_sl.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/saveload/object_sl.cpp') diff --git a/src/saveload/object_sl.cpp b/src/saveload/object_sl.cpp index dcf5fd65c..57e34af3a 100644 --- a/src/saveload/object_sl.cpp +++ b/src/saveload/object_sl.cpp @@ -8,10 +8,12 @@ /** @file object_sl.cpp Code handling saving and loading of objects */ #include "../stdafx.h" -#include "../object_base.h" -#include "../object_map.h" #include "saveload.h" +#include "compat/object_sl_compat.h" + +#include "../object_base.h" +#include "../object_map.h" #include "newgrf_sl.h" #include "../safeguards.h" @@ -29,6 +31,8 @@ static const SaveLoad _object_desc[] = { static void Save_OBJS() { + SlTableHeader(_object_desc); + /* Write the objects */ for (Object *o : Object::Iterate()) { SlSetArrayIndex(o->index); @@ -38,10 +42,12 @@ static void Save_OBJS() static void Load_OBJS() { + const std::vector slt = SlCompatTableHeader(_object_desc, _object_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { Object *o = new (index) Object(); - SlObject(o, _object_desc); + SlObject(o, slt); } } @@ -67,8 +73,8 @@ static void Load_OBID() } static const ChunkHandler object_chunk_handlers[] = { - { 'OBID', Save_OBID, Load_OBID, nullptr, nullptr, CH_ARRAY }, - { 'OBJS', Save_OBJS, Load_OBJS, Ptrs_OBJS, nullptr, CH_ARRAY }, + { 'OBID', Save_OBID, Load_OBID, nullptr, nullptr, CH_TABLE }, + { 'OBJS', Save_OBJS, Load_OBJS, Ptrs_OBJS, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _object_chunk_handlers(object_chunk_handlers); -- cgit v1.2.3-54-g00ecf