diff options
57 files changed, 1409 insertions, 288 deletions
diff --git a/src/saveload/CMakeLists.txt b/src/saveload/CMakeLists.txt index 52f103fa7..5f83309a4 100644 --- a/src/saveload/CMakeLists.txt +++ b/src/saveload/CMakeLists.txt @@ -1,3 +1,5 @@ +add_subdirectory(compat) + add_files( afterload.cpp ai_sl.cpp diff --git a/src/saveload/ai_sl.cpp b/src/saveload/ai_sl.cpp index 1c44ef732..047a08d5b 100644 --- a/src/saveload/ai_sl.cpp +++ b/src/saveload/ai_sl.cpp @@ -8,9 +8,12 @@ /** @file ai_sl.cpp Handles the saveload part of the AIs */ #include "../stdafx.h" -#include "../company_base.h" #include "../debug.h" + #include "saveload.h" +#include "compat/ai_sl_compat.h" + +#include "../company_base.h" #include "../string_func.h" #include "../ai/ai.hpp" @@ -25,7 +28,7 @@ static int _ai_saveload_version; static std::string _ai_saveload_settings; static bool _ai_saveload_is_random; -static const SaveLoad _ai_company[] = { +static const SaveLoad _ai_company_desc[] = { SLEG_SSTR("name", _ai_saveload_name, SLE_STR), SLEG_SSTR("settings", _ai_saveload_settings, SLE_STR), SLEG_CONDVAR("version", _ai_saveload_version, SLE_UINT32, SLV_108, SL_MAX_VERSION), @@ -49,13 +52,15 @@ static void SaveReal_AIPL(int *index_ptr) _ai_saveload_is_random = config->IsRandom(); _ai_saveload_settings = config->SettingsToString(); - SlObject(nullptr, _ai_company); + SlObject(nullptr, _ai_company_desc); /* If the AI was active, store its data too */ if (Company::IsValidAiID(index)) AI::Save(index); } static void Load_AIPL() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_ai_company_desc, _ai_company_sl_compat); + /* Free all current data */ for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { AIConfig::GetConfig(c, AIConfig::SSS_FORCE_GAME)->Change(nullptr); @@ -67,7 +72,7 @@ static void Load_AIPL() _ai_saveload_is_random = false; _ai_saveload_version = -1; - SlObject(nullptr, _ai_company); + SlObject(nullptr, slt); if (_networking && !_network_server) { if (Company::IsValidAiID(index)) AIInstance::LoadEmpty(); @@ -114,6 +119,8 @@ static void Load_AIPL() static void Save_AIPL() { + SlTableHeader(_ai_company_desc); + for (int i = COMPANY_FIRST; i < MAX_COMPANIES; i++) { SlSetArrayIndex(i); SlAutolength((AutolengthProc *)SaveReal_AIPL, &i); @@ -121,7 +128,7 @@ static void Save_AIPL() } static const ChunkHandler ai_chunk_handlers[] = { - { 'AIPL', Save_AIPL, Load_AIPL, nullptr, nullptr, CH_ARRAY }, + { 'AIPL', Save_AIPL, Load_AIPL, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _ai_chunk_handlers(ai_chunk_handlers); diff --git a/src/saveload/airport_sl.cpp b/src/saveload/airport_sl.cpp index 114e5672a..6862fc133 100644 --- a/src/saveload/airport_sl.cpp +++ b/src/saveload/airport_sl.cpp @@ -35,8 +35,8 @@ static void Load_ATID() } static const ChunkHandler airport_chunk_handlers[] = { - { 'ATID', Save_ATID, Load_ATID, nullptr, nullptr, CH_ARRAY }, - { 'APID', Save_APID, Load_APID, nullptr, nullptr, CH_ARRAY }, + { 'ATID', Save_ATID, Load_ATID, nullptr, nullptr, CH_TABLE }, + { 'APID', Save_APID, Load_APID, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _airport_chunk_handlers(airport_chunk_handlers); diff --git a/src/saveload/animated_tile_sl.cpp b/src/saveload/animated_tile_sl.cpp index 2e0666d4a..50fe05df2 100644 --- a/src/saveload/animated_tile_sl.cpp +++ b/src/saveload/animated_tile_sl.cpp @@ -8,12 +8,14 @@ /** @file animated_tile_sl.cpp Code handling saving and loading of animated tiles */ #include "../stdafx.h" + +#include "saveload.h" +#include "compat/animated_tile_sl_compat.h" + #include "../tile_type.h" #include "../core/alloc_func.hpp" #include "../core/smallvec_type.hpp" -#include "saveload.h" - #include "../safeguards.h" extern std::vector<TileIndex> _animated_tiles; @@ -27,6 +29,8 @@ static const SaveLoad _animated_tile_desc[] = { */ static void Save_ANIT() { + SlTableHeader(_animated_tile_desc); + SlSetArrayIndex(0); SlGlobList(_animated_tile_desc); } @@ -57,17 +61,15 @@ static void Load_ANIT() return; } + const std::vector<SaveLoad> slt = SlCompatTableHeader(_animated_tile_desc, _animated_tile_sl_compat); + if (SlIterateArray() == -1) return; - SlGlobList(_animated_tile_desc); + SlGlobList(slt); if (SlIterateArray() != -1) SlErrorCorrupt("Too many ANIT entries"); } -/** - * "Definition" imported by the saveload code to be able to load and save - * the animated tile table. - */ static const ChunkHandler animated_tile_chunk_handlers[] = { - { 'ANIT', Save_ANIT, Load_ANIT, nullptr, nullptr, CH_ARRAY }, + { 'ANIT', Save_ANIT, Load_ANIT, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _animated_tile_chunk_handlers(animated_tile_chunk_handlers); diff --git a/src/saveload/autoreplace_sl.cpp b/src/saveload/autoreplace_sl.cpp index f54866c10..2c848c96d 100644 --- a/src/saveload/autoreplace_sl.cpp +++ b/src/saveload/autoreplace_sl.cpp @@ -8,9 +8,11 @@ /** @file autoreplace_sl.cpp Code handling saving and loading of autoreplace rules */ #include "../stdafx.h" -#include "../autoreplace_base.h" #include "saveload.h" +#include "compat/autoreplace_sl_compat.h" + +#include "../autoreplace_base.h" #include "../safeguards.h" @@ -25,6 +27,8 @@ static const SaveLoad _engine_renew_desc[] = { static void Save_ERNW() { + SlTableHeader(_engine_renew_desc); + for (EngineRenew *er : EngineRenew::Iterate()) { SlSetArrayIndex(er->index); SlObject(er, _engine_renew_desc); @@ -33,11 +37,13 @@ static void Save_ERNW() static void Load_ERNW() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_engine_renew_desc, _engine_renew_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { EngineRenew *er = new (index) EngineRenew(); - SlObject(er, _engine_renew_desc); + SlObject(er, slt); /* Advanced vehicle lists, ungrouped vehicles got added */ if (IsSavegameVersionBefore(SLV_60)) { @@ -56,7 +62,7 @@ static void Ptrs_ERNW() } static const ChunkHandler autoreplace_chunk_handlers[] = { - { 'ERNW', Save_ERNW, Load_ERNW, Ptrs_ERNW, nullptr, CH_ARRAY }, + { 'ERNW', Save_ERNW, Load_ERNW, Ptrs_ERNW, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _autoreplace_chunk_handlers(autoreplace_chunk_handlers); diff --git a/src/saveload/cargomonitor_sl.cpp b/src/saveload/cargomonitor_sl.cpp index abb0d59b9..e00d38332 100644 --- a/src/saveload/cargomonitor_sl.cpp +++ b/src/saveload/cargomonitor_sl.cpp @@ -8,9 +8,11 @@ /** @file cargomonitor_sl.cpp Code handling saving and loading of Cargo monitoring. */ #include "../stdafx.h" -#include "../cargomonitor.h" #include "saveload.h" +#include "compat/cargomonitor_sl_compat.h" + +#include "../cargomonitor.h" #include "../safeguards.h" @@ -44,6 +46,8 @@ static CargoMonitorID FixupCargoMonitor(CargoMonitorID number) /** Save the #_cargo_deliveries monitoring map. */ static void SaveDelivery() { + SlTableHeader(_cargomonitor_pair_desc); + TempStorage storage; int i = 0; @@ -63,13 +67,15 @@ static void SaveDelivery() /** Load the #_cargo_deliveries monitoring map. */ static void LoadDelivery() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_cargomonitor_pair_desc, _cargomonitor_pair_sl_compat); + TempStorage storage; bool fix = IsSavegameVersionBefore(SLV_FIX_CARGO_MONITOR); ClearCargoDeliveryMonitoring(); for (;;) { if (SlIterateArray() < 0) break; - SlObject(&storage, _cargomonitor_pair_desc); + SlObject(&storage, slt); if (fix) storage.number = FixupCargoMonitor(storage.number); @@ -82,6 +88,8 @@ static void LoadDelivery() /** Save the #_cargo_pickups monitoring map. */ static void SavePickup() { + SlTableHeader(_cargomonitor_pair_desc); + TempStorage storage; int i = 0; @@ -101,13 +109,15 @@ static void SavePickup() /** Load the #_cargo_pickups monitoring map. */ static void LoadPickup() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_cargomonitor_pair_desc, _cargomonitor_pair_sl_compat); + TempStorage storage; bool fix = IsSavegameVersionBefore(SLV_FIX_CARGO_MONITOR); ClearCargoPickupMonitoring(); for (;;) { if (SlIterateArray() < 0) break; - SlObject(&storage, _cargomonitor_pair_desc); + SlObject(&storage, slt); if (fix) storage.number = FixupCargoMonitor(storage.number); @@ -117,9 +127,9 @@ static void LoadPickup() } /** Chunk definition of the cargomonitoring maps. */ -static const ChunkHandler cargomonitor_chunk_handlers[] = { - { 'CMDL', SaveDelivery, LoadDelivery, nullptr, nullptr, CH_ARRAY }, - { 'CMPU', SavePickup, LoadPickup, nullptr, nullptr, CH_ARRAY }, +extern const ChunkHandler cargomonitor_chunk_handlers[] = { + { 'CMDL', SaveDelivery, LoadDelivery, nullptr, nullptr, CH_TABLE }, + { 'CMPU', SavePickup, LoadPickup, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _cargomonitor_chunk_handlers(cargomonitor_chunk_handlers); diff --git a/src/saveload/cargopacket_sl.cpp b/src/saveload/cargopacket_sl.cpp index 96c96cabc..def62a7b9 100644 --- a/src/saveload/cargopacket_sl.cpp +++ b/src/saveload/cargopacket_sl.cpp @@ -8,10 +8,12 @@ /** @file cargopacket_sl.cpp Code handling saving and loading of cargo packets */ #include "../stdafx.h" -#include "../vehicle_base.h" -#include "../station_base.h" #include "saveload.h" +#include "compat/cargopacket_sl_compat.h" + +#include "../vehicle_base.h" +#include "../station_base.h" #include "../safeguards.h" @@ -94,9 +96,6 @@ SaveLoadTable GetCargoPacketDesc() SLE_VAR(CargoPacket, feeder_share, SLE_INT64), SLE_CONDVAR(CargoPacket, source_type, SLE_UINT8, SLV_125, SL_MAX_VERSION), SLE_CONDVAR(CargoPacket, source_id, SLE_UINT16, SLV_125, SL_MAX_VERSION), - - /* Used to be paid_for, but that got changed. */ - SLE_CONDNULL(1, SL_MIN_VERSION, SLV_121), }; return _cargopacket_desc; } @@ -106,6 +105,8 @@ SaveLoadTable GetCargoPacketDesc() */ static void Save_CAPA() { + SlTableHeader(GetCargoPacketDesc()); + for (CargoPacket *cp : CargoPacket::Iterate()) { SlSetArrayIndex(cp->index); SlObject(cp, GetCargoPacketDesc()); @@ -117,17 +118,18 @@ static void Save_CAPA() */ static void Load_CAPA() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(GetCargoPacketDesc(), _cargopacket_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { CargoPacket *cp = new (index) CargoPacket(); - SlObject(cp, GetCargoPacketDesc()); + SlObject(cp, slt); } } -/** Chunk handlers related to cargo packets. */ static const ChunkHandler cargopacket_chunk_handlers[] = { - { 'CAPA', Save_CAPA, Load_CAPA, nullptr, nullptr, CH_ARRAY }, + { 'CAPA', Save_CAPA, Load_CAPA, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _cargopacket_chunk_handlers(cargopacket_chunk_handlers); diff --git a/src/saveload/cheat_sl.cpp b/src/saveload/cheat_sl.cpp index 6c6bab4dd..cef8b7e90 100644 --- a/src/saveload/cheat_sl.cpp +++ b/src/saveload/cheat_sl.cpp @@ -8,9 +8,11 @@ /** @file cheat_sl.cpp Code handling saving and loading of cheats */ #include "../stdafx.h" -#include "../cheat_type.h" #include "saveload.h" +#include "compat/cheat_sl_compat.h" + +#include "../cheat_type.h" #include "../safeguards.h" @@ -23,18 +25,12 @@ static const SaveLoad _cheats_desc[] = { SLE_VAR(Cheats, money.value, SLE_BOOL), SLE_VAR(Cheats, crossing_tunnels.been_used, SLE_BOOL), SLE_VAR(Cheats, crossing_tunnels.value, SLE_BOOL), - SLE_NULL(1), - SLE_NULL(1), // Needs to be two NULL fields. See Load_CHTS(). SLE_VAR(Cheats, no_jetcrash.been_used, SLE_BOOL), SLE_VAR(Cheats, no_jetcrash.value, SLE_BOOL), - SLE_NULL(1), - SLE_NULL(1), // Needs to be two NULL fields. See Load_CHTS(). SLE_VAR(Cheats, change_date.been_used, SLE_BOOL), SLE_VAR(Cheats, change_date.value, SLE_BOOL), SLE_VAR(Cheats, setup_prod.been_used, SLE_BOOL), SLE_VAR(Cheats, setup_prod.value, SLE_BOOL), - SLE_NULL(1), - SLE_NULL(1), // Needs to be two NULL fields. See Load_CHTS(). SLE_VAR(Cheats, edit_max_hl.been_used, SLE_BOOL), SLE_VAR(Cheats, edit_max_hl.value, SLE_BOOL), }; @@ -44,9 +40,9 @@ static const SaveLoad _cheats_desc[] = { */ static void Save_CHTS() { - SlSetArrayIndex(0); + SlTableHeader(_cheats_desc); - SlSetLength(std::size(_cheats_desc)); + SlSetArrayIndex(0); SlObject(&_cheats, _cheats_desc); } @@ -55,18 +51,23 @@ static void Save_CHTS() */ static void Load_CHTS() { - size_t count = SlGetFieldLength(); - std::vector<SaveLoad> slt; + std::vector<SaveLoad> slt = SlCompatTableHeader(_cheats_desc, _cheats_sl_compat); + + if (IsSavegameVersionBefore(SLV_TABLE_CHUNKS)) { + size_t count = SlGetFieldLength(); + std::vector<SaveLoad> oslt; - /* Cheats were added over the years without a savegame bump. They are - * stored as 2 SLE_BOOLs per entry. "count" indicates how many SLE_BOOLs - * are stored for this savegame. So read only "count" SLE_BOOLs (and in - * result "count / 2" cheats). */ - for (auto &sld : _cheats_desc) { - count--; - slt.push_back(sld); + /* Cheats were added over the years without a savegame bump. They are + * stored as 2 SLE_BOOLs per entry. "count" indicates how many SLE_BOOLs + * are stored for this savegame. So read only "count" SLE_BOOLs (and in + * result "count / 2" cheats). */ + for (auto &sld : slt) { + count--; + oslt.push_back(sld); - if (count == 0) break; + if (count == 0) break; + } + slt = oslt; } if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return; @@ -75,7 +76,7 @@ static void Load_CHTS() } static const ChunkHandler cheat_chunk_handlers[] = { - { 'CHTS', Save_CHTS, Load_CHTS, nullptr, nullptr, CH_ARRAY }, + { 'CHTS', Save_CHTS, Load_CHTS, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _cheat_chunk_handlers(cheat_chunk_handlers); diff --git a/src/saveload/compat/CMakeLists.txt b/src/saveload/compat/CMakeLists.txt new file mode 100644 index 000000000..1737f9493 --- /dev/null +++ b/src/saveload/compat/CMakeLists.txt @@ -0,0 +1,26 @@ +add_files( + ai_sl_compat.h + autoreplace_sl_compat.h + cargomonitor_sl_compat.h + cargopacket_sl_compat.h + cheat_sl_compat.h + depot_sl_compat.h + economy_sl_compat.h + engine_sl_compat.h + game_sl_compat.h + goal_sl_compat.h + group_sl_compat.h + industry_sl_compat.h + labelmaps_sl_compat.h + map_sl_compat.h + misc_sl_compat.h + newgrf_sl_compat.h + object_sl_compat.h + order_sl_compat.h + settings_sl_compat.h + signs_sl_compat.h + station_sl_compat.h + storage_sl_compat.h + story_sl_compat.h + subsidy_sl_compat.h +) diff --git a/src/saveload/compat/ai_sl_compat.h b/src/saveload/compat/ai_sl_compat.h new file mode 100644 index 000000000..dba2855a1 --- /dev/null +++ b/src/saveload/compat/ai_sl_compat.h @@ -0,0 +1,23 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file ai_sl_compat.h Loading for ai chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_AI_H +#define SAVELOAD_COMPAT_AI_H + +#include "../saveload.h" + +/** Original field order for _ai_company_desc. */ +const SaveLoadCompat _ai_company_sl_compat[] = { + SLC_VAR("name"), + SLC_VAR("settings"), + SLC_VAR("version"), + SLC_VAR("is_random"), +}; + +#endif /* SAVELOAD_COMPAT_AI_H */ diff --git a/src/saveload/compat/animated_tile_sl_compat.h b/src/saveload/compat/animated_tile_sl_compat.h new file mode 100644 index 000000000..1fcea5818 --- /dev/null +++ b/src/saveload/compat/animated_tile_sl_compat.h @@ -0,0 +1,20 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file animated_tile_sl_compat.h Loading for animated_tile chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_ANIMATED_TILE_H +#define SAVELOAD_COMPAT_ANIMATED_TILE_H + +#include "../saveload.h" + +/** Original field order for _animated_tile_desc. */ +const SaveLoadCompat _animated_tile_sl_compat[] = { + SLC_VAR("tiles"), +}; + +#endif /* SAVELOAD_COMPAT_ANIMATED_TILE_H */ diff --git a/src/saveload/compat/autoreplace_sl_compat.h b/src/saveload/compat/autoreplace_sl_compat.h new file mode 100644 index 000000000..abb4b0e28 --- /dev/null +++ b/src/saveload/compat/autoreplace_sl_compat.h @@ -0,0 +1,24 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file autoreplace_sl_compat.h Loading for autoreplace chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_AUTOREPLACE_H +#define SAVELOAD_COMPAT_AUTOREPLACE_H + +#include "../saveload.h" + +/** Original field order for _engine_renew_desc. */ +const SaveLoadCompat _engine_renew_sl_compat[] = { + SLC_VAR("from"), + SLC_VAR("to"), + SLC_VAR("next"), + SLC_VAR("group_id"), + SLC_VAR("replace_when_old"), +}; + +#endif /* SAVELOAD_COMPAT_AUTOREPLACE_H */ diff --git a/src/saveload/compat/cargomonitor_sl_compat.h b/src/saveload/compat/cargomonitor_sl_compat.h new file mode 100644 index 000000000..2bb1e999a --- /dev/null +++ b/src/saveload/compat/cargomonitor_sl_compat.h @@ -0,0 +1,21 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file cargomonitor_sl_compat.h Loading for cargomonitor chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_CARGOMONITOR_H +#define SAVELOAD_COMPAT_CARGOMONITOR_H + +#include "../saveload.h" + +/** Original field order for _cargomonitor_pair_desc. */ +const SaveLoadCompat _cargomonitor_pair_sl_compat[] = { + SLC_VAR("number"), + SLC_VAR("amount"), +}; + +#endif /* SAVELOAD_COMPAT_CARGOMONITOR_H */ diff --git a/src/saveload/compat/cargopacket_sl_compat.h b/src/saveload/compat/cargopacket_sl_compat.h new file mode 100644 index 000000000..eee308bcb --- /dev/null +++ b/src/saveload/compat/cargopacket_sl_compat.h @@ -0,0 +1,28 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file cargopacket_sl_compat.h Loading for cargopacket chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_CARGOPACKET_H +#define SAVELOAD_COMPAT_CARGOPACKET_H + +#include "../saveload.h" + +/** Original field order for _cargopacket_desc. */ +const SaveLoadCompat _cargopacket_sl_compat[] = { + SLC_VAR("source"), + SLC_VAR("source_xy"), + SLC_VAR("loaded_at_xy"), + SLC_VAR("count"), + SLC_VAR("days_in_transit"), + SLC_VAR("feeder_share"), + SLC_VAR("source_type"), + SLC_VAR("source_id"), + SLC_NULL(1, SL_MIN_VERSION, SLV_121), +}; + +#endif /* SAVELOAD_COMPAT_CARGOPACKET_H */ diff --git a/src/saveload/compat/cheat_sl_compat.h b/src/saveload/compat/cheat_sl_compat.h new file mode 100644 index 000000000..f3c756097 --- /dev/null +++ b/src/saveload/compat/cheat_sl_compat.h @@ -0,0 +1,41 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file cheat_sl_compat.h Loading for cheat chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_CHEAT_H +#define SAVELOAD_COMPAT_CHEAT_H + +#include "../saveload.h" + +/** Original field order for _cheats_desc. */ +const SaveLoadCompat _cheats_sl_compat[] = { + SLC_VAR("magic_bulldozer.been_used"), + SLC_VAR("magic_bulldozer.value"), + SLC_VAR("switch_company.been_used"), + SLC_VAR("switch_company.value"), + SLC_VAR("money.been_used"), + SLC_VAR("money.value"), + SLC_VAR("crossing_tunnels.been_used"), + SLC_VAR("crossing_tunnels.value"), + SLC_NULL(1, SL_MIN_VERSION, SLV_TABLE_CHUNKS), + SLC_NULL(1, SL_MIN_VERSION, SLV_TABLE_CHUNKS), // Need to be two NULL fields. See Load_CHTS(). + SLC_VAR("no_jetcrash.been_used"), + SLC_VAR("no_jetcrash.value"), + SLC_NULL(1, SL_MIN_VERSION, SLV_TABLE_CHUNKS), + SLC_NULL(1, SL_MIN_VERSION, SLV_TABLE_CHUNKS), // Need to be two NULL fields. See Load_CHTS(). + SLC_VAR("change_date.been_used"), + SLC_VAR("change_date.value"), + SLC_VAR("setup_prod.been_used"), + SLC_VAR("setup_prod.value"), + SLC_NULL(1, SL_MIN_VERSION, SLV_TABLE_CHUNKS), + SLC_NULL(1, SL_MIN_VERSION, SLV_TABLE_CHUNKS), // Need to be two NULL fields. See Load_CHTS(). + SLC_VAR("edit_max_hl.been_used"), + SLC_VAR("edit_max_hl.value"), +}; + +#endif /* SAVELOAD_COMPAT_CHEAT_H */ diff --git a/src/saveload/compat/depot_sl_compat.h b/src/saveload/compat/depot_sl_compat.h new file mode 100644 index 000000000..8fcf4b686 --- /dev/null +++ b/src/saveload/compat/depot_sl_compat.h @@ -0,0 +1,25 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file depot_sl_compat.h Loading for depot chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_DEPOT_H +#define SAVELOAD_COMPAT_DEPOT_H + +#include "../saveload.h" + +/** Original field order for _depot_desc. */ +const SaveLoadCompat _depot_sl_compat[] = { + SLC_VAR("xy"), + SLC_VAR("town_index"), + SLC_VAR("town"), + SLC_VAR("town_cn"), + SLC_VAR("name"), + SLC_VAR("build_date"), +}; + +#endif /* SAVELOAD_COMPAT_DEPOT_H */ diff --git a/src/saveload/compat/economy_sl_compat.h b/src/saveload/compat/economy_sl_compat.h new file mode 100644 index 000000000..560673a0d --- /dev/null +++ b/src/saveload/compat/economy_sl_compat.h @@ -0,0 +1,38 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file economy_sl_compat.h Loading for economy chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_ECONOMY_H +#define SAVELOAD_COMPAT_ECONOMY_H + +#include "../saveload.h" + +/** Original field order for _economy_desc. */ +const SaveLoadCompat _economy_sl_compat[] = { + SLC_NULL(4, SL_MIN_VERSION, SLV_65), + SLC_NULL(8, SLV_65, SLV_144), + SLC_VAR("old_max_loan_unround"), + SLC_VAR("old_max_loan_unround_fract"), + SLC_VAR("inflation_prices"), + SLC_VAR("inflation_payment"), + SLC_VAR("fluct"), + SLC_VAR("interest_rate"), + SLC_VAR("infl_amount"), + SLC_VAR("infl_amount_pr"), + SLC_VAR("industry_daily_change_counter"), +}; + +/** Original field order for _cargopayment_desc. */ +const SaveLoadCompat _cargopayment_sl_compat[] = { + SLC_VAR("front"), + SLC_VAR("route_profit"), + SLC_VAR("visual_profit"), + SLC_VAR("visual_transfer"), +}; + +#endif /* SAVELOAD_COMPAT_ECONOMY_H */ diff --git a/src/saveload/compat/engine_sl_compat.h b/src/saveload/compat/engine_sl_compat.h new file mode 100644 index 000000000..68a839bef --- /dev/null +++ b/src/saveload/compat/engine_sl_compat.h @@ -0,0 +1,48 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file engine_sl_compat.h Loading for engine chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_ENGINE_H +#define SAVELOAD_COMPAT_ENGINE_H + +#include "../saveload.h" + +/** Original field order for _engine_desc. */ +const SaveLoadCompat _engine_sl_compat[] = { + SLC_VAR("intro_date"), + SLC_VAR("age"), + SLC_VAR("reliability"), + SLC_VAR("reliability_spd_dec"), + SLC_VAR("reliability_start"), + SLC_VAR("reliability_max"), + SLC_VAR("reliability_final"), + SLC_VAR("duration_phase_1"), + SLC_VAR("duration_phase_2"), + SLC_VAR("duration_phase_3"), + SLC_NULL(1, SL_MIN_VERSION, SLV_121), + SLC_VAR("flags"), + SLC_NULL(1, SL_MIN_VERSION, SLV_179), + SLC_VAR("preview_asked"), + SLC_VAR("preview_company"), + SLC_VAR("preview_wait"), + SLC_NULL(1, SL_MIN_VERSION, SLV_45), + SLC_VAR("company_avail"), + SLC_VAR("company_hidden"), + SLC_VAR("name"), + SLC_NULL(16, SLV_2, SLV_144), +}; + +/** Original field order for _engine_id_mapping_desc. */ +const SaveLoadCompat _engine_id_mapping_sl_compat[] = { + SLC_VAR("grfid"), + SLC_VAR("internal_id"), + SLC_VAR("type"), + SLC_VAR("substitute_id"), +}; + +#endif /* SAVELOAD_COMPAT_ENGINE_H */ diff --git a/src/saveload/compat/game_sl_compat.h b/src/saveload/compat/game_sl_compat.h new file mode 100644 index 000000000..204504e3b --- /dev/null +++ b/src/saveload/compat/game_sl_compat.h @@ -0,0 +1,23 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file game_sl_compat.h Loading for game chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_GAME_H +#define SAVELOAD_COMPAT_GAME_H + +#include "../saveload.h" + +/** Original field order for _game_script_desc. */ +const SaveLoadCompat _game_script_sl_compat[] = { + SLC_VAR("name"), + SLC_VAR("settings"), + SLC_VAR("version"), + SLC_VAR("is_random"), +}; + +#endif /* SAVELOAD_COMPAT_GAME_H */ diff --git a/src/saveload/compat/goal_sl_compat.h b/src/saveload/compat/goal_sl_compat.h new file mode 100644 index 000000000..5dc205462 --- /dev/null +++ b/src/saveload/compat/goal_sl_compat.h @@ -0,0 +1,25 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file goal_sl_compat.h Loading of goal chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_GOAL_H +#define SAVELOAD_COMPAT_GOAL_H + +#include "../saveload.h" + +/** Original field order for _goals_desc. */ +const SaveLoadCompat _goals_sl_compat[] = { + SLC_VAR("company"), + SLC_VAR("type"), + SLC_VAR("dst"), + SLC_VAR("text"), + SLC_VAR("progress"), + SLC_VAR("completed"), +}; + +#endif /* SAVELOAD_COMPAT_GOAL_H */ diff --git a/src/saveload/compat/group_sl_compat.h b/src/saveload/compat/group_sl_compat.h new file mode 100644 index 000000000..50021079f --- /dev/null +++ b/src/saveload/compat/group_sl_compat.h @@ -0,0 +1,28 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file group_sl_compat.h Loading of group chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_GROUP_H +#define SAVELOAD_COMPAT_GROUP_H + +#include "../saveload.h" + +/** Original field order for _group_desc. */ +const SaveLoadCompat _group_sl_compat[] = { + SLC_VAR("name"), + SLC_NULL(2, SL_MIN_VERSION, SLV_164), + SLC_VAR("owner"), + SLC_VAR("vehicle_type"), + SLC_VAR("flags"), + SLC_VAR("livery.in_use"), + SLC_VAR("livery.colour1"), + SLC_VAR("livery.colour2"), + SLC_VAR("parent"), +}; + +#endif /* SAVELOAD_COMPAT_GROUP_H */ diff --git a/src/saveload/compat/industry_sl_compat.h b/src/saveload/compat/industry_sl_compat.h new file mode 100644 index 000000000..990cc64d5 --- /dev/null +++ b/src/saveload/compat/industry_sl_compat.h @@ -0,0 +1,72 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file industry_sl_compat.h Loading of industry chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_INDUSTRY_H +#define SAVELOAD_COMPAT_INDUSTRY_H + +#include "../saveload.h" + +/** Original field order for _industry_desc. */ +const SaveLoadCompat _industry_sl_compat[] = { + SLC_VAR("location.tile"), + SLC_VAR("location.w"), + SLC_VAR("location.h"), + SLC_VAR("town"), + SLC_VAR("neutral_station"), + SLC_NULL(2, SL_MIN_VERSION, SLV_61), + SLC_VAR("produced_cargo"), + SLC_VAR("incoming_cargo_waiting"), + SLC_VAR("produced_cargo_waiting"), + SLC_VAR("production_rate"), + SLC_NULL(3, SL_MIN_VERSION, SLV_61), + SLC_VAR("accepts_cargo"), + SLC_VAR("prod_level"), + SLC_VAR("this_month_production"), + SLC_VAR("this_month_transported"), + SLC_VAR("last_month_pct_transported"), + SLC_VAR("last_month_production"), + SLC_VAR("last_month_transported"), + SLC_VAR("counter"), + SLC_VAR("type"), + SLC_VAR("owner"), + SLC_VAR("random_colour"), + SLC_VAR("last_prod_year"), + SLC_VAR("was_cargo_delivered"), + SLC_VAR("ctlflags"), + SLC_VAR("founder"), + SLC_VAR("construction_date"), + SLC_VAR("construction_type"), + SLC_VAR("last_cargo_accepted_at[0]"), + SLC_VAR("last_cargo_accepted_at"), + SLC_VAR("selected_layout"), + SLC_VAR("exclusive_supplier"), + SLC_VAR("exclusive_consumer"), + SLC_VAR("storage"), + SLC_VAR("psa"), + SLC_NULL(1, SLV_82, SLV_197), + SLC_VAR("random"), + SLC_VAR("text"), + SLC_NULL(32, SLV_2, SLV_144), +}; + +/** Original field order for _industry_builder_desc. */ +const SaveLoadCompat _industry_builder_sl_compat[] = { + SLC_VAR("wanted_inds"), +}; + +/** Original field order for _industrytype_builder_desc. */ +const SaveLoadCompat _industrytype_builder_sl_compat[] = { + SLC_VAR("probability"), + SLC_VAR("min_number"), + SLC_VAR("target_count"), + SLC_VAR("max_wait"), + SLC_VAR("wait_count"), +}; + +#endif /* SAVELOAD_COMPAT_INDUSTRY_H */ diff --git a/src/saveload/compat/labelmaps_sl_compat.h b/src/saveload/compat/labelmaps_sl_compat.h new file mode 100644 index 000000000..8664cec19 --- /dev/null +++ b/src/saveload/compat/labelmaps_sl_compat.h @@ -0,0 +1,20 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file labelmaps_sl_compat.h Loading of labelmaps chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_LABELMAPS_H +#define SAVELOAD_COMPAT_LABELMAPS_H + +#include "../saveload.h" + +/** Original field order for _label_object_desc. */ +const SaveLoadCompat _label_object_sl_compat[] = { + SLC_VAR("label"), +}; + +#endif /* SAVELOAD_COMPAT_LABELMAPS_H */ diff --git a/src/saveload/compat/map_sl_compat.h b/src/saveload/compat/map_sl_compat.h new file mode 100644 index 000000000..84cfb2865 --- /dev/null +++ b/src/saveload/compat/map_sl_compat.h @@ -0,0 +1,21 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file map_sl_compat.h Loading for map chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_MAP_H +#define SAVELOAD_COMPAT_MAP_H + +#include "../saveload.h" + +/** Original field order for _map_desc. */ +const SaveLoadCompat _map_sl_compat[] = { + SLC_VAR("dim_x"), + SLC_VAR("dim_y"), +}; + +#endif /* SAVELOAD_COMPAT_MAP_H */ diff --git a/src/saveload/compat/misc_sl_compat.h b/src/saveload/compat/misc_sl_compat.h new file mode 100644 index 000000000..02d26002a --- /dev/null +++ b/src/saveload/compat/misc_sl_compat.h @@ -0,0 +1,68 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file misc_sl_compat.h Loading for misc chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_MISC_H +#define SAVELOAD_COMPAT_MISC_H + +#include "../saveload.h" + +/** Original field order for _date_desc. */ +const SaveLoadCompat _date_sl_compat[] = { + SLC_VAR("date"), + SLC_VAR("date_fract"), + SLC_VAR("tick_counter"), + SLC_NULL(2, SL_MIN_VERSION, SLV_157), + SLC_VAR("age_cargo_skip_counter"), + SLC_NULL(1, SL_MIN_VERSION, SLV_46), + SLC_VAR("cur_tileloop_tile"), + SLC_VAR("next_disaster_start"), + SLC_NULL(2, SL_MIN_VERSION, SLV_120), + SLC_VAR("random_state[0]"), + SLC_VAR("random_state[1]"), + SLC_NULL(1, SL_MIN_VERSION, SLV_10), + SLC_NULL(4, SLV_10, SLV_120), + SLC_VAR("company_tick_counter"), + SLC_VAR("next_competitor_start"), + SLC_VAR("trees_tick_counter"), + SLC_VAR("pause_mode"), + SLC_NULL(4, SLV_11, SLV_120), +}; + +/** Original field order for _date_check_desc. */ +const SaveLoadCompat _date_check_sl_compat[] = { + SLC_VAR("date"), + SLC_NULL(2, SL_MIN_VERSION, SL_MAX_VERSION), // date_fract + SLC_NULL(2, SL_MIN_VERSION, SL_MAX_VERSION), // tick_counter + SLC_NULL(2, SL_MIN_VERSION, SLV_157), + SLC_NULL(1, SL_MIN_VERSION, SLV_162), // age_cargo_skip_counter + SLC_NULL(1, SL_MIN_VERSION, SLV_46), + SLC_NULL(2, SL_MIN_VERSION, SLV_6), // cur_tileloop_tile + SLC_NULL(4, SLV_6, SL_MAX_VERSION), // cur_tileloop_tile + SLC_NULL(2, SL_MIN_VERSION, SL_MAX_VERSION), // disaster_delay + SLC_NULL(2, SL_MIN_VERSION, SLV_120), + SLC_NULL(4, SL_MIN_VERSION, SL_MAX_VERSION), // random.state[0] + SLC_NULL(4, SL_MIN_VERSION, SL_MAX_VERSION), // random.state[1] + SLC_NULL(1, SL_MIN_VERSION, SLV_10), + SLC_NULL(4, SLV_10, SLV_120), + SLC_NULL(1, SL_MIN_VERSION, SL_MAX_VERSION), // cur_company_tick_index + SLC_NULL(2, SL_MIN_VERSION, SLV_109), // next_competitor_start + SLC_NULL(4, SLV_109, SL_MAX_VERSION), // next_competitor_start + SLC_NULL(1, SL_MIN_VERSION, SL_MAX_VERSION), // trees_tick_ctr + SLC_NULL(1, SLV_4, SL_MAX_VERSION), // pause_mode + SLC_NULL(4, SLV_11, SLV_120), +}; + +/** Original field order for _view_desc. */ +const SaveLoadCompat _view_sl_compat[] = { + SLC_VAR("x"), + SLC_VAR("y"), + SLC_VAR("zoom"), +}; + +#endif /* SAVELOAD_COMPAT_MISC_H */ diff --git a/src/saveload/compat/newgrf_sl_compat.h b/src/saveload/compat/newgrf_sl_compat.h new file mode 100644 index 000000000..8a1803946 --- /dev/null +++ b/src/saveload/compat/newgrf_sl_compat.h @@ -0,0 +1,33 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file newgrf_sl_compat.h Loading of newgrf chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_NEWGRF_H +#define SAVELOAD_COMPAT_NEWGRF_H + +#include "../saveload.h" + +/** Original field order for _newgrf_mapping_desc. */ +const SaveLoadCompat _newgrf_mapping_sl_compat[] = { + SLC_VAR("grfid"), + SLC_VAR("entity_id"), + SLC_VAR("substitute_id"), +}; + +/** Original field order for _newgrf_desc. */ +const SaveLoadCompat _grfconfig_sl_compat[] = { + SLC_VAR("filename"), + SLC_VAR("ident.grfid"), + SLC_VAR("ident.md5sum"), + SLC_VAR("version"), + SLC_VAR("param"), + SLC_VAR("num_params"), + SLC_VAR("palette"), +}; + +#endif /* SAVELOAD_COMPAT_NEWGRF_H */ diff --git a/src/saveload/compat/object_sl_compat.h b/src/saveload/compat/object_sl_compat.h new file mode 100644 index 000000000..a4a9fca6a --- /dev/null +++ b/src/saveload/compat/object_sl_compat.h @@ -0,0 +1,27 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file object_sl_compat.h Loading of object chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_OBJECT_H +#define SAVELOAD_COMPAT_OBJECT_H + +#include "../saveload.h" + +/** Original field order for _object_desc. */ +const SaveLoadCompat _object_sl_compat[] = { + SLC_VAR("location.tile"), + SLC_VAR("location.w"), + SLC_VAR("location.h"), + SLC_VAR("town"), + SLC_VAR("build_date"), + SLC_VAR("colour"), + SLC_VAR("view"), + SLC_VAR("type"), +}; + +#endif /* SAVELOAD_COMPAT_OBJECT_H */ diff --git a/src/saveload/compat/order_sl_compat.h b/src/saveload/compat/order_sl_compat.h new file mode 100644 index 000000000..62c879cf1 --- /dev/null +++ b/src/saveload/compat/order_sl_compat.h @@ -0,0 +1,52 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file order_sl_compat.h Loading of order chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_ORDER_H +#define SAVELOAD_COMPAT_ORDER_H + +#include "../saveload.h" + +/** Original field order for _order_desc. */ +const SaveLoadCompat _order_sl_compat[] = { + SLC_VAR("type"), + SLC_VAR("flags"), + SLC_VAR("dest"), + SLC_VAR("next"), + SLC_VAR("refit_cargo"), + SLC_NULL(1, SLV_36, SLV_182), + SLC_VAR("wait_time"), + SLC_VAR("travel_time"), + SLC_VAR("max_speed"), + SLC_NULL(10, SLV_5, SLV_36), +}; + +/** Original field order for _orderlist_desc. */ +const SaveLoadCompat _orderlist_sl_compat[] = { + SLC_VAR("first"), +}; + +/** Original field order for _order_backup_desc. */ +const SaveLoadCompat _order_backup_sl_compat[] = { + SLC_VAR("user"), + SLC_VAR("tile"), + SLC_VAR("group"), + SLC_VAR("service_interval"), + SLC_VAR("name"), + SLC_NULL(2, SL_MIN_VERSION, SLV_192), + SLC_VAR("clone"), + SLC_VAR("cur_real_order_index"), + SLC_VAR("cur_implicit_order_index"), + SLC_VAR("current_order_time"), + SLC_VAR("lateness_counter"), + SLC_VAR("timetable_start"), + SLC_VAR("vehicle_flags"), + SLC_VAR("orders"), +}; + +#endif /* SAVELOAD_COMPAT_ORDER_H */ diff --git a/src/saveload/compat/settings_sl_compat.h b/src/saveload/compat/settings_sl_compat.h new file mode 100644 index 000000000..081779bf5 --- /dev/null +++ b/src/saveload/compat/settings_sl_compat.h @@ -0,0 +1,266 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file settings_sl_compat.h Loading of settings chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_SETTINGS_H +#define SAVELOAD_COMPAT_SETTINGS_H + +#include "../saveload.h" + +/** Original field order for _gameopt. */ +const SaveLoadCompat _gameopt_sl_compat[] = { + SLC_VAR("diff_custom"), + SLC_VAR("diff_level"), + SLC_VAR("locale.currency"), + SLC_VAR("units"), + SLC_VAR("game_creation.town_name"), + SLC_VAR("game_creation.landscape"), + SLC_VAR("game_creation.snow_line_height"), + SLC_NULL(1, SLV_22, SLV_165), + SLC_NULL(1, SL_MIN_VERSION, SLV_23), + SLC_VAR("vehicle.road_side"), +}; + +/** Original field order for _settings. */ +const SaveLoadCompat _settings_sl_compat[] = { + SLC_VAR("difficulty.max_no_competitors"), + SLC_NULL(1, SLV_97, SLV_110), + SLC_VAR("difficulty.number_towns"), + SLC_VAR("difficulty.industry_density"), + SLC_VAR("difficulty.max_loan"), + SLC_VAR("difficulty.initial_interest"), + SLC_VAR("difficulty.vehicle_costs"), + SLC_VAR("difficulty.competitor_speed"), + SLC_NULL(1, SLV_97, SLV_110), + SLC_VAR("difficulty.vehicle_breakdowns"), + SLC_VAR("difficulty.subsidy_multiplier"), + SLC_VAR("difficulty.subsidy_duration"), + SLC_VAR("difficulty.construction_cost"), + SLC_VAR("difficulty.terrain_type"), + SLC_VAR("difficulty.quantity_sea_lakes"), + SLC_VAR("difficulty.economy"), + SLC_VAR("difficulty.line_reverse_mode"), + SLC_VAR("difficulty.disasters"), + SLC_VAR("difficulty.town_council_tolerance"), + SLC_VAR("diff_level"), + SLC_VAR("game_creation.town_name"), + SLC_VAR("game_creation.landscape"), + SLC_NULL(1, SLV_97, SLV_164), + SLC_VAR("vehicle.road_side"), + SLC_VAR("construction.map_height_limit"), + SLC_VAR("game_creation.heightmap_height"), + SLC_VAR("construction.build_on_slopes"), + SLC_VAR("construction.command_pause_level"), + SLC_VAR("construction.terraform_per_64k_frames"), + SLC_VAR("construction.terraform_frame_burst"), + SLC_VAR("construction.clear_per_64k_frames"), + SLC_VAR("construction.clear_frame_burst"), + SLC_VAR("construction.tree_per_64k_frames"), + SLC_VAR("construction.tree_frame_burst"), + SLC_VAR("construction.autoslope"), + SLC_VAR("construction.extra_dynamite"), + SLC_VAR("construction.max_bridge_length"), + SLC_VAR("construction.max_bridge_height"), + SLC_VAR("construction.max_tunnel_length"), + SLC_NULL(1, SL_MIN_VERSION, SLV_159), + SLC_VAR("construction.train_signal_side"), + SLC_VAR("station.never_expire_airports"), + SLC_VAR("economy.town_layout"), + SLC_VAR("economy.allow_town_roads"), + SLC_VAR("economy.found_town"), + SLC_VAR("economy.allow_town_level_crossings"), + SLC_VAR("economy.town_cargogen_mode"), + SLC_VAR("linkgraph.recalc_interval"), + SLC_VAR("linkgraph.recalc_time"), + SLC_VAR("linkgraph.distribution_pax"), + SLC_VAR("linkgraph.distribution_mail"), + SLC_VAR("linkgraph.distribution_armoured"), + SLC_VAR("linkgraph.distribution_default"), + SLC_VAR("linkgraph.accuracy"), + SLC_VAR("linkgraph.demand_distance"), + SLC_VAR("linkgraph.demand_size"), + SLC_VAR("linkgraph.short_path_saturation"), + SLC_VAR("vehicle.train_acceleration_model"), + SLC_VAR("vehicle.roadveh_acceleration_model"), + SLC_VAR("vehicle.train_slope_steepness"), + SLC_VAR("vehicle.roadveh_slope_steepness"), + SLC_VAR("pf.forbid_90_deg"), + SLC_VAR("vehicle.max_train_length"), + SLC_NULL(1, SL_MIN_VERSION, SLV_159), + SLC_VAR("vehicle.smoke_amount"), + SLC_NULL(1, SL_MIN_VERSION, SLV_159), + SLC_VAR("pf.roadveh_queue"), + SLC_VAR("pf.new_pathfinding_all"), + SLC_VAR("pf.yapf.ship_use_yapf"), + SLC_VAR("pf.yapf.road_use_yapf"), + SLC_VAR("pf.yapf.rail_use_yapf"), + SLC_VAR("pf.pathfinder_for_trains"), + SLC_VAR("pf.pathfinder_for_roadvehs"), + SLC_VAR("pf.pathfinder_for_ships"), + SLC_VAR("vehicle.never_expire_vehicles"), + SLC_VAR("vehicle.max_trains"), + SLC_VAR("vehicle.max_roadveh"), + SLC_VAR("vehicle.max_aircraft"), + SLC_VAR("vehicle.max_ships"), + SLC_VAR("_old_vds.servint_ispercent"), + SLC_VAR("_old_vds.servint_trains"), + SLC_VAR("_old_vds.servint_roadveh"), + SLC_VAR("_old_vds.servint_ships"), + SLC_VAR("_old_vds.servint_aircraft"), + SLC_VAR("order.no_servicing_if_no_breakdowns"), + SLC_VAR("vehicle.wagon_speed_limits"), + SLC_VAR("vehicle.disable_elrails"), + SLC_VAR("vehicle.freight_trains"), + SLC_NULL(1, SLV_67, SLV_159), + SLC_VAR("vehicle.plane_speed"), + SLC_VAR("vehicle.dynamic_engines"), + SLC_VAR("vehicle.plane_crashes"), + SLC_NULL(1, SL_MIN_VERSION, SLV_159), + SLC_VAR("gui.sg_full_load_any"), + SLC_VAR("order.improved_load"), + SLC_VAR("order.selectgoods"), + SLC_VAR("gui.sg_new_nonstop"), + SLC_NULL(1, SL_MIN_VERSION, SLV_159), + SLC_VAR("station.station_spread"), + SLC_VAR("order.serviceathelipad"), + SLC_VAR("station.modified_catchment"), + SLC_VAR("station.serve_neutral_industries"), + SLC_VAR("order.gradual_loading"), + SLC_VAR("construction.road_stop_on_town_road"), + SLC_VAR("construction.road_stop_on_competitor_road"), + SLC_VAR("station.adjacent_stations"), + SLC_VAR("economy.station_noise_level"), + SLC_VAR("station.distant_join_stations"), + SLC_VAR("economy.inflation"), + SLC_VAR("construction.raw_industry_construction"), + SLC_VAR("construction.industry_platform"), + SLC_VAR("economy.multiple_industry_per_town"), + SLC_NULL(1, SL_MIN_VERSION, SLV_141), + SLC_VAR("economy.bribe"), + SLC_VAR("economy.exclusive_rights"), + SLC_VAR("economy.fund_buildings"), + SLC_VAR("economy.fund_roads"), + SLC_VAR("economy.give_money"), + SLC_VAR("game_creation.snow_line_height"), + SLC_VAR("game_creation.snow_coverage"), + SLC_VAR("game_creation.desert_coverage"), + SLC_NULL(4, SL_MIN_VERSION, SLV_144), + SLC_VAR("game_creation.starting_year"), + SLC_NULL(4, SL_MIN_VERSION, SLV_105), + SLC_VAR("game_creation.ending_year"), + SLC_VAR("economy.type"), + SLC_VAR("economy.allow_shares"), + SLC_VAR("economy.min_years_for_shares"), + SLC_VAR("economy.feeder_payment_share"), + SLC_VAR("economy.town_growth_rate"), + SLC_VAR("economy.larger_towns"), + SLC_VAR("economy.initial_city_size"), + SLC_VAR("economy.mod_road_rebuild"), + SLC_NULL(1, SL_MIN_VERSION, SLV_107), + SLC_VAR("script.settings_profile"), + SLC_VAR("ai.ai_in_multiplayer"), + SLC_VAR("ai.ai_disable_veh_train"), + SLC_VAR("ai.ai_disable_veh_roadveh"), + SLC_VAR("ai.ai_disable_veh_aircraft"), + SLC_VAR("ai.ai_disable_veh_ship"), + SLC_VAR("script.script_max_opcode_till_suspend"), + SLC_VAR("script.script_max_memory_megabytes"), + SLC_VAR("vehicle.extend_vehicle_life"), + SLC_VAR("economy.dist_local_authority"), + SLC_VAR("pf.reverse_at_signals"), + SLC_VAR("pf.wait_oneway_signal"), + SLC_VAR("pf.wait_twoway_signal"), + SLC_VAR("economy.town_noise_population[0]"), + SLC_VAR("economy.town_noise_population[1]"), + SLC_VAR("economy.town_noise_population[2]"), + SLC_VAR("economy.infrastructure_maintenance"), + SLC_VAR("pf.wait_for_pbs_path"), + SLC_VAR("pf.reserve_paths"), + SLC_VAR("pf.path_backoff_interval"), + SLC_NULL(3, SL_MIN_VERSION, SLV_REMOVE_OPF), + SLC_VAR("pf.npf.npf_max_search_nodes"), + SLC_VAR("pf.npf.npf_rail_firstred_penalty"), + SLC_VAR("pf.npf.npf_rail_firstred_exit_penalty"), + SLC_VAR("pf.npf.npf_rail_lastred_penalty"), + SLC_VAR("pf.npf.npf_rail_station_penalty"), + SLC_VAR("pf.npf.npf_rail_slope_penalty"), + SLC_VAR("pf.npf.npf_rail_curve_penalty"), + SLC_VAR("pf.npf.npf_rail_depot_reverse_penalty"), + SLC_VAR("pf.npf.npf_rail_pbs_cross_penalty"), + SLC_VAR("pf.npf.npf_rail_pbs_signal_back_penalty"), + SLC_VAR("pf.npf.npf_buoy_penalty"), + SLC_VAR("pf.npf.npf_water_curve_penalty"), + SLC_VAR("pf.npf.npf_road_curve_penalty"), + SLC_VAR("pf.npf.npf_crossing_penalty"), + SLC_VAR("pf.npf.npf_road_drive_through_penalty"), + SLC_VAR("pf.npf.npf_road_dt_occupied_penalty"), + SLC_VAR("pf.npf.npf_road_bay_occupied_penalty"), + SLC_VAR("pf.npf.maximum_go_to_depot_penalty"), + SLC_VAR("pf.yapf.disable_node_optimization"), + SLC_VAR("pf.yapf.max_search_nodes"), + SLC_VAR("pf.yapf.rail_firstred_twoway_eol"), + SLC_VAR("pf.yapf.rail_firstred_penalty"), + SLC_VAR("pf.yapf.rail_firstred_exit_penalty"), + SLC_VAR("pf.yapf.rail_lastred_penalty"), + SLC_VAR("pf.yapf.rail_lastred_exit_penalty"), + SLC_VAR("pf.yapf.rail_station_penalty"), + SLC_VAR("pf.yapf.rail_slope_penalty"), + SLC_VAR("pf.yapf.rail_curve45_penalty"), + SLC_VAR("pf.yapf.rail_curve90_penalty"), + SLC_VAR("pf.yapf.rail_depot_reverse_penalty"), + SLC_VAR("pf.yapf.rail_crossing_penalty"), + SLC_VAR("pf.yapf.rail_look_ahead_max_signals"), + SLC_VAR("pf.yapf.rail_look_ahead_signal_p0"), + SLC_VAR("pf.yapf.rail_look_ahead_signal_p1"), + SLC_VAR("pf.yapf.rail_look_ahead_signal_p2"), + SLC_VAR("pf.yapf.rail_pbs_cross_penalty"), + SLC_VAR("pf.yapf.rail_pbs_station_penalty"), + SLC_VAR("pf.yapf.rail_pbs_signal_back_penalty"), + SLC_VAR("pf.yapf.rail_doubleslip_penalty"), + SLC_VAR("pf.yapf.rail_longer_platform_penalty"), + SLC_VAR("pf.yapf.rail_longer_platform_per_tile_penalty"), + SLC_VAR("pf.yapf.rail_shorter_platform_penalty"), + SLC_VAR("pf.yapf.rail_shorter_platform_per_tile_penalty"), + SLC_VAR("pf.yapf.road_slope_penalty"), + SLC_VAR("pf.yapf.road_curve_penalty"), + SLC_VAR("pf.yapf.road_crossing_penalty"), + SLC_VAR("pf.yapf.road_stop_penalty"), + SLC_VAR("pf.yapf.road_stop_occupied_penalty"), + SLC_VAR("pf.yapf.road_stop_bay_occupied_penalty"), + SLC_VAR("pf.yapf.maximum_go_to_depot_penalty"), + SLC_VAR("pf.yapf.ship_curve45_penalty"), + SLC_VAR("pf.yapf.ship_curve90_penalty"), + SLC_VAR("game_creation.land_generator"), + SLC_VAR("game_creation.oil_refinery_limit"), + SLC_VAR("game_creation.tgen_smoothness"), + SLC_VAR("game_creation.variety"), + SLC_VAR("game_creation.generation_seed"), + SLC_VAR("game_creation.tree_placer"), + SLC_VAR("construction.freeform_edges"), + SLC_VAR("game_creation.water_borders"), + SLC_VAR("game_creation.custom_town_number"), + SLC_VAR("construction.extra_tree_placement"), + SLC_VAR("game_creation.custom_terrain_type"), + SLC_VAR("game_creation.custom_sea_level"), + SLC_VAR("game_creation.min_river_length"), + SLC_VAR("game_creation.river_route_random"), + SLC_VAR("game_creation.amount_of_rivers"), + SLC_VAR("locale.currency"), + SLC_VAR("units"), + SLC_VAR("locale.units_velocity"), + SLC_VAR("locale.units_power"), + SLC_VAR("locale.units_weight"), + SLC_VAR("locale.units_volume"), + SLC_VAR("locale.units_force"), + SLC_VAR("locale.units_height"), + SLC_VAR("locale.digit_group_separator"), + SLC_VAR("locale.digit_group_separator_currency"), + SLC_VAR("locale.digit_decimal_separator"), +}; + +#endif /* SAVELOAD_COMPAT_SETTINGS_H */ diff --git a/src/saveload/compat/signs_sl_compat.h b/src/saveload/compat/signs_sl_compat.h new file mode 100644 index 000000000..80bc70789 --- /dev/null +++ b/src/saveload/compat/signs_sl_compat.h @@ -0,0 +1,24 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file signs_sl_compat.h Loading of signs chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_SIGNS_H +#define SAVELOAD_COMPAT_SIGNS_H + +#include "../saveload.h" + +/** Original field order for _sign_desc. */ +const SaveLoadCompat _sign_sl_compat[] = { + SLC_VAR("name"), + SLC_VAR("x"), + SLC_VAR("y"), + SLC_VAR("owner"), + SLC_VAR("z"), +}; + +#endif /* SAVELOAD_COMPAT_SIGNS_H */ diff --git a/src/saveload/compat/station_sl_compat.h b/src/saveload/compat/station_sl_compat.h new file mode 100644 index 000000000..397e1660f --- /dev/null +++ b/src/saveload/compat/station_sl_compat.h @@ -0,0 +1,29 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file station_sl_compat.h Loading of station chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_STATION_H +#define SAVELOAD_COMPAT_STATION_H + +#include "../saveload.h" + +/** Original field order for _roadstop_desc. */ +const SaveLoadCompat _roadstop_sl_compat[] = { + SLC_VAR("xy"), + SLC_NULL(1, SL_MIN_VERSION, SLV_45), + SLC_VAR("status"), + SLC_NULL(4, SL_MIN_VERSION, SLV_9), + SLC_NULL(2, SL_MIN_VERSION, SLV_45), + SLC_NULL(1, SL_MIN_VERSION, SLV_26), + SLC_VAR("next"), + SLC_NULL(2, SL_MIN_VERSION, SLV_45), + SLC_NULL(4, SL_MIN_VERSION, SLV_25), + SLC_NULL(1, SLV_25, SLV_26), +}; + +#endif /* SAVELOAD_COMPAT_STATION_H */ diff --git a/src/saveload/compat/storage_sl_compat.h b/src/saveload/compat/storage_sl_compat.h new file mode 100644 index 000000000..f4f6d0d9a --- /dev/null +++ b/src/saveload/compat/storage_sl_compat.h @@ -0,0 +1,21 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file storage_sl_compat.h Loading of storage chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_STORAGE_H +#define SAVELOAD_COMPAT_STORAGE_H + +#include "../saveload.h" + +/** Original field order for _storage_desc. */ +const SaveLoadCompat _storage_sl_compat[] = { + SLC_VAR("grfid"), + SLC_VAR("storage"), +}; + +#endif /* SAVELOAD_COMPAT_STORAGE_H */ diff --git a/src/saveload/compat/story_sl_compat.h b/src/saveload/compat/story_sl_compat.h new file mode 100644 index 000000000..519ca2bf1 --- /dev/null +++ b/src/saveload/compat/story_sl_compat.h @@ -0,0 +1,32 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file story_sl_compat.h Loading for story chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_STORE_H +#define SAVELOAD_COMPAT_STORE_H + +#include "../saveload.h" + +/** Original field order for _story_page_elements_desc. */ +const SaveLoadCompat _story_page_elements_sl_compat[] = { + SLC_VAR("sort_value"), + SLC_VAR("page"), + SLC_VAR("type"), + SLC_VAR("referenced_id"), + SLC_VAR("text"), +}; + +/** Original field order for _story_pages_desc. */ +const SaveLoadCompat _story_pages_sl_compat[] = { + SLC_VAR("sort_value"), + SLC_VAR("date"), + SLC_VAR("company"), + SLC_VAR("title"), +}; + +#endif /* SAVELOAD_COMPAT_STORE_H */ diff --git a/src/saveload/compat/subsidy_sl_compat.h b/src/saveload/compat/subsidy_sl_compat.h new file mode 100644 index 000000000..7ae758318 --- /dev/null +++ b/src/saveload/compat/subsidy_sl_compat.h @@ -0,0 +1,26 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file subsidy_sl_compat.h Loading of subsidy chunks before table headers were added. */ + +#ifndef SAVELOAD_COMPAT_SUBSIDY_H +#define SAVELOAD_COMPAT_SUBSIDY_H + +#include "../saveload.h" + +/** Original field order for _subsidies_desc. */ +const SaveLoadCompat _subsidies_sl_compat[] = { + SLC_VAR("cargo_type"), + SLC_VAR("remaining"), + SLC_VAR("awarded"), + SLC_VAR("src_type"), + SLC_VAR("dst_type"), + SLC_VAR("src"), + SLC_VAR("dst"), +}; + +#endif /* SAVELOAD_COMPAT_SUBSIDY_H */ 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<SaveLoad> 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); diff --git a/src/saveload/economy_sl.cpp b/src/saveload/economy_sl.cpp index d8624f5d6..4d7890b4b 100644 --- a/src/saveload/economy_sl.cpp +++ b/src/saveload/economy_sl.cpp @@ -8,10 +8,12 @@ /** @file economy_sl.cpp Code handling saving and loading of economy data */ #include "../stdafx.h" -#include "../economy_func.h" -#include "../economy_base.h" #include "saveload.h" +#include "compat/economy_sl_compat.h" + +#include "../economy_func.h" +#include "../economy_base.h" #include "../safeguards.h" @@ -34,8 +36,6 @@ static void Load_CAPR() } static const SaveLoad _economy_desc[] = { - SLE_CONDNULL(4, SL_MIN_VERSION, SLV_65), // max_loan - SLE_CONDNULL(8, SLV_65, SLV_144), // max_loan SLE_CONDVAR(Economy, old_max_loan_unround, SLE_FILE_I32 | SLE_VAR_I64, SL_MIN_VERSION, SLV_65), SLE_CONDVAR(Economy, old_max_loan_unround, SLE_INT64, SLV_65, SLV_126), SLE_CONDVAR(Economy, old_max_loan_unround_fract, SLE_UINT16, SLV_70, SLV_126), @@ -51,6 +51,8 @@ static const SaveLoad _economy_desc[] = { /** Economy variables */ static void Save_ECMY() { + SlTableHeader(_economy_desc); + SlSetArrayIndex(0); SlObject(&_economy, _economy_desc); } @@ -58,8 +60,10 @@ static void Save_ECMY() /** Economy variables */ static void Load_ECMY() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_economy_desc, _economy_sl_compat); + if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return; - SlObject(&_economy, _economy_desc); + SlObject(&_economy, slt); if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many ECMY entries"); StartupIndustryDailyChanges(IsSavegameVersionBefore(SLV_102)); // old savegames will need to be initialized @@ -74,6 +78,8 @@ static const SaveLoad _cargopayment_desc[] = { static void Save_CAPY() { + SlTableHeader(_cargopayment_desc); + for (CargoPayment *cp : CargoPayment::Iterate()) { SlSetArrayIndex(cp->index); SlObject(cp, _cargopayment_desc); @@ -82,11 +88,13 @@ static void Save_CAPY() static void Load_CAPY() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_cargopayment_desc, _cargopayment_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { CargoPayment *cp = new (index) CargoPayment(); - SlObject(cp, _cargopayment_desc); + SlObject(cp, slt); } } @@ -99,10 +107,10 @@ static void Ptrs_CAPY() static const ChunkHandler economy_chunk_handlers[] = { - { 'CAPY', Save_CAPY, Load_CAPY, Ptrs_CAPY, nullptr, CH_ARRAY }, + { 'CAPY', Save_CAPY, Load_CAPY, Ptrs_CAPY, nullptr, CH_TABLE }, { 'PRIC', nullptr, Load_PRIC, nullptr, nullptr, CH_READONLY }, { 'CAPR', nullptr, Load_CAPR, nullptr, nullptr, CH_READONLY }, - { 'ECMY', Save_ECMY, Load_ECMY, nullptr, nullptr, CH_ARRAY }, + { 'ECMY', Save_ECMY, Load_ECMY, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _economy_chunk_handlers(economy_chunk_handlers); diff --git a/src/saveload/engine_sl.cpp b/src/saveload/engine_sl.cpp index 12670449e..109d90434 100644 --- a/src/saveload/engine_sl.cpp +++ b/src/saveload/engine_sl.cpp @@ -8,6 +8,10 @@ /** @file engine_sl.cpp Code handling saving and loading of engines */ #include "../stdafx.h" + +#include "saveload.h" +#include "compat/engine_sl_compat.h" + #include "saveload_internal.h" #include "../engine_base.h" #include "../string_func.h" @@ -28,20 +32,14 @@ static const SaveLoad _engine_desc[] = { SLE_VAR(Engine, duration_phase_1, SLE_UINT16), SLE_VAR(Engine, duration_phase_2, SLE_UINT16), SLE_VAR(Engine, duration_phase_3, SLE_UINT16), - - SLE_CONDNULL(1, SL_MIN_VERSION, SLV_121), SLE_VAR(Engine, flags, SLE_UINT8), - SLE_CONDNULL(1, SL_MIN_VERSION, SLV_179), // old preview_company_rank SLE_CONDVAR(Engine, preview_asked, SLE_UINT16, SLV_179, SL_MAX_VERSION), SLE_CONDVAR(Engine, preview_company, SLE_UINT8, SLV_179, SL_MAX_VERSION), SLE_VAR(Engine, preview_wait, SLE_UINT8), - SLE_CONDNULL(1, SL_MIN_VERSION, SLV_45), SLE_CONDVAR(Engine, company_avail, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_104), SLE_CONDVAR(Engine, company_avail, SLE_UINT16, SLV_104, SL_MAX_VERSION), SLE_CONDVAR(Engine, company_hidden, SLE_UINT16, SLV_193, SL_MAX_VERSION), SLE_CONDSSTR(Engine, name, SLE_STR, SLV_84, SL_MAX_VERSION), - - SLE_CONDNULL(16, SLV_2, SLV_144), // old reserved space }; static std::vector<Engine*> _temp_engine; @@ -84,6 +82,8 @@ Engine *GetTempDataEngine(EngineID index) static void Save_ENGN() { + SlTableHeader(_engine_desc); + for (Engine *e : Engine::Iterate()) { SlSetArrayIndex(e->index); SlObject(e, _engine_desc); @@ -92,13 +92,15 @@ static void Save_ENGN() static void Load_ENGN() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_engine_desc, _engine_sl_compat); + /* As engine data is loaded before engines are initialized we need to load * this information into a temporary array. This is then copied into the * engine pool after processing NewGRFs by CopyTempEngineData(). */ int index; while ((index = SlIterateArray()) != -1) { Engine *e = GetTempDataEngine(index); - SlObject(e, _engine_desc); + SlObject(e, slt); if (IsSavegameVersionBefore(SLV_179)) { /* preview_company_rank was replaced with preview_company and preview_asked. @@ -175,6 +177,8 @@ static const SaveLoad _engine_id_mapping_desc[] = { static void Save_EIDS() { + SlTableHeader(_engine_id_mapping_desc); + uint index = 0; for (EngineIDMapping &eid : _engine_mngr) { SlSetArrayIndex(index); @@ -185,17 +189,19 @@ static void Save_EIDS() static void Load_EIDS() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_engine_id_mapping_desc, _engine_id_mapping_sl_compat); + _engine_mngr.clear(); while (SlIterateArray() != -1) { EngineIDMapping *eid = &_engine_mngr.emplace_back(); - SlObject(eid, _engine_id_mapping_desc); + SlObject(eid, slt); } } static const ChunkHandler engine_chunk_handlers[] = { - { 'EIDS', Save_EIDS, Load_EIDS, nullptr, nullptr, CH_ARRAY }, - { 'ENGN', Save_ENGN, Load_ENGN, nullptr, nullptr, CH_ARRAY }, + { 'EIDS', Save_EIDS, Load_EIDS, nullptr, nullptr, CH_TABLE }, + { 'ENGN', Save_ENGN, Load_ENGN, nullptr, nullptr, CH_TABLE }, { 'ENGS', nullptr, Load_ENGS, nullptr, nullptr, CH_READONLY }, }; diff --git a/src/saveload/game_sl.cpp b/src/saveload/game_sl.cpp index 1ef513c63..059e17333 100644 --- a/src/saveload/game_sl.cpp +++ b/src/saveload/game_sl.cpp @@ -9,9 +9,11 @@ #include "../stdafx.h" #include "../debug.h" + #include "saveload.h" -#include "../string_func.h" +#include "compat/game_sl_compat.h" +#include "../string_func.h" #include "../game/game.hpp" #include "../game/game_config.hpp" #include "../network/network.h" @@ -25,7 +27,7 @@ static int _game_saveload_version; static std::string _game_saveload_settings; static bool _game_saveload_is_random; -static const SaveLoad _game_script[] = { +static const SaveLoad _game_script_desc[] = { SLEG_SSTR("name", _game_saveload_name, SLE_STR), SLEG_SSTR("settings", _game_saveload_settings, SLE_STR), SLEG_VAR("version", _game_saveload_version, SLE_UINT32), @@ -48,19 +50,21 @@ static void SaveReal_GSDT(int *index_ptr) _game_saveload_is_random = config->IsRandom(); _game_saveload_settings = config->SettingsToString(); - SlObject(nullptr, _game_script); + SlObject(nullptr, _game_script_desc); Game::Save(); } static void Load_GSDT() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_game_script_desc, _game_script_sl_compat); + /* Free all current data */ GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME)->Change(nullptr); if (SlIterateArray() == -1) return; _game_saveload_version = -1; - SlObject(nullptr, _game_script); + SlObject(nullptr, slt); if (_networking && !_network_server) { GameInstance::LoadEmpty(); @@ -104,6 +108,7 @@ static void Load_GSDT() static void Save_GSDT() { + SlTableHeader(_game_script_desc); SlSetArrayIndex(0); SlAutolength((AutolengthProc *)SaveReal_GSDT, nullptr); } @@ -180,7 +185,7 @@ static void Save_GSTR() static const ChunkHandler game_chunk_handlers[] = { { 'GSTR', Save_GSTR, Load_GSTR, nullptr, nullptr, CH_ARRAY }, - { 'GSDT', Save_GSDT, Load_GSDT, nullptr, nullptr, CH_ARRAY }, + { 'GSDT', Save_GSDT, Load_GSDT, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _game_chunk_handlers(game_chunk_handlers); diff --git a/src/saveload/goal_sl.cpp b/src/saveload/goal_sl.cpp index 2f6679759..68ba3597a 100644 --- a/src/saveload/goal_sl.cpp +++ b/src/saveload/goal_sl.cpp @@ -8,9 +8,11 @@ /** @file goal_sl.cpp Code handling saving and loading of goals */ #include "../stdafx.h" -#include "../goal_base.h" #include "saveload.h" +#include "compat/goal_sl_compat.h" + +#include "../goal_base.h" #include "../safeguards.h" @@ -25,6 +27,8 @@ static const SaveLoad _goals_desc[] = { static void Save_GOAL() { + SlTableHeader(_goals_desc); + for (Goal *s : Goal::Iterate()) { SlSetArrayIndex(s->index); SlObject(s, _goals_desc); @@ -33,6 +37,8 @@ static void Save_GOAL() static void Load_GOAL() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_goals_desc, _goals_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { Goal *s = new (index) Goal(); @@ -41,7 +47,7 @@ static void Load_GOAL() } static const ChunkHandler goal_chunk_handlers[] = { - { 'GOAL', Save_GOAL, Load_GOAL, nullptr, nullptr, CH_ARRAY }, + { 'GOAL', Save_GOAL, Load_GOAL, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _goal_chunk_handlers(goal_chunk_handlers); diff --git a/src/saveload/group_sl.cpp b/src/saveload/group_sl.cpp index f41091611..77ab23bd8 100644 --- a/src/saveload/group_sl.cpp +++ b/src/saveload/group_sl.cpp @@ -12,13 +12,13 @@ #include "../company_base.h" #include "saveload.h" +#include "compat/group_sl_compat.h" #include "../safeguards.h" static const SaveLoad _group_desc[] = { SLE_CONDVAR(Group, name, SLE_NAME, SL_MIN_VERSION, SLV_84), SLE_CONDSSTR(Group, name, SLE_STR | SLF_ALLOW_CONTROL, SLV_84, SL_MAX_VERSION), - SLE_CONDNULL(2, SL_MIN_VERSION, SLV_164), // num_vehicle SLE_VAR(Group, owner, SLE_UINT8), SLE_VAR(Group, vehicle_type, SLE_UINT8), SLE_VAR(Group, flags, SLE_UINT8), @@ -30,6 +30,8 @@ static const SaveLoad _group_desc[] = { static void Save_GRPS() { + SlTableHeader(_group_desc); + for (Group *g : Group::Iterate()) { SlSetArrayIndex(g->index); SlObject(g, _group_desc); @@ -39,24 +41,26 @@ static void Save_GRPS() static void Load_GRPS() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_group_desc, _group_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { Group *g = new (index) Group(); - SlObject(g, _group_desc); + SlObject(g, slt); if (IsSavegameVersionBefore(SLV_189)) g->parent = INVALID_GROUP; if (IsSavegameVersionBefore(SLV_GROUP_LIVERIES)) { - const Company *c = Company::Get(g->owner); - g->livery.colour1 = c->livery[LS_DEFAULT].colour1; - g->livery.colour2 = c->livery[LS_DEFAULT].colour2; + const Company *c = Company::Get(g->owner); + g->livery.colour1 = c->livery[LS_DEFAULT].colour1; + g->livery.colour2 = c->livery[LS_DEFAULT].colour2; } } } static const ChunkHandler group_chunk_handlers[] = { - { 'GRPS', Save_GRPS, Load_GRPS, nullptr, nullptr, CH_ARRAY }, + { 'GRPS', Save_GRPS, Load_GRPS, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _group_chunk_handlers(group_chunk_handlers); diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp index 139a5c1af..1be1ad219 100644 --- a/src/saveload/industry_sl.cpp +++ b/src/saveload/industry_sl.cpp @@ -8,9 +8,11 @@ /** @file industry_sl.cpp Code handling saving and loading of industries */ #include "../stdafx.h" -#include "../industry.h" #include "saveload.h" +#include "compat/industry_sl_compat.h" + +#include "../industry.h" #include "newgrf_sl.h" #include "../safeguards.h" @@ -24,7 +26,6 @@ static const SaveLoad _industry_desc[] = { SLE_VAR(Industry, location.h, SLE_FILE_U8 | SLE_VAR_U16), SLE_REF(Industry, town, REF_TOWN), SLE_CONDREF(Industry, neutral_station, REF_STATION, SLV_SERVE_NEUTRAL_INDUSTRIES, SL_MAX_VERSION), - SLE_CONDNULL( 2, SL_MIN_VERSION, SLV_61), ///< used to be industry's produced_cargo SLE_CONDARR(Industry, produced_cargo, SLE_UINT8, 2, SLV_78, SLV_EXTEND_INDUSTRY_CARGO_SLOTS), SLE_CONDARR(Industry, produced_cargo, SLE_UINT8, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SL_MAX_VERSION), SLE_CONDARR(Industry, incoming_cargo_waiting, SLE_UINT16, 3, SLV_70, SLV_EXTEND_INDUSTRY_CARGO_SLOTS), @@ -33,7 +34,6 @@ static const SaveLoad _industry_desc[] = { SLE_CONDARR(Industry, produced_cargo_waiting, SLE_UINT16, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SL_MAX_VERSION), SLE_CONDARR(Industry, production_rate, SLE_UINT8, 2, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS), SLE_CONDARR(Industry, production_rate, SLE_UINT8, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SL_MAX_VERSION), - SLE_CONDNULL( 3, SL_MIN_VERSION, SLV_61), ///< used to be industry's accepts_cargo SLE_CONDARR(Industry, accepts_cargo, SLE_UINT8, 3, SLV_78, SLV_EXTEND_INDUSTRY_CARGO_SLOTS), SLE_CONDARR(Industry, accepts_cargo, SLE_UINT8, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SL_MAX_VERSION), SLE_VAR(Industry, prod_level, SLE_UINT8), @@ -70,15 +70,14 @@ static const SaveLoad _industry_desc[] = { SLEG_CONDARR("storage", _old_ind_persistent_storage.storage, SLE_UINT32, 16, SLV_76, SLV_161), SLE_CONDREF(Industry, psa, REF_STORAGE, SLV_161, SL_MAX_VERSION), - SLE_CONDNULL(1, SLV_82, SLV_197), // random_triggers SLE_CONDVAR(Industry, random, SLE_UINT16, SLV_82, SL_MAX_VERSION), SLE_CONDSSTR(Industry, text, SLE_STR | SLF_ALLOW_CONTROL, SLV_INDUSTRY_TEXT, SL_MAX_VERSION), - - SLE_CONDNULL(32, SLV_2, SLV_144), // old reserved space }; static void Save_INDY() { + SlTableHeader(_industry_desc); + /* Write the industries */ for (Industry *ind : Industry::Iterate()) { SlSetArrayIndex(ind->index); @@ -98,13 +97,15 @@ static void Save_TIDS() static void Load_INDY() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_industry_desc, _industry_sl_compat); + int index; Industry::ResetIndustryCounts(); while ((index = SlIterateArray()) != -1) { Industry *i = new (index) Industry(); - SlObject(i, _industry_desc); + SlObject(i, slt); /* Before savegame version 161, persistent storages were not stored in a pool. */ if (IsSavegameVersionBefore(SLV_161) && !IsSavegameVersionBefore(SLV_76)) { @@ -142,6 +143,8 @@ static const SaveLoad _industry_builder_desc[] = { /** Save industry builder. */ static void Save_IBLD() { + SlTableHeader(_industry_builder_desc); + SlSetArrayIndex(0); SlGlobList(_industry_builder_desc); } @@ -149,8 +152,10 @@ static void Save_IBLD() /** Load industry builder. */ static void Load_IBLD() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_industry_builder_desc, _industry_builder_sl_compat); + if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return; - SlGlobList(_industry_builder_desc); + SlGlobList(slt); if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many IBLD entries"); } @@ -166,6 +171,8 @@ static const SaveLoad _industrytype_builder_desc[] = { /** Save industry-type build data. */ static void Save_ITBL() { + SlTableHeader(_industrytype_builder_desc); + for (int i = 0; i < NUM_INDUSTRYTYPES; i++) { SlSetArrayIndex(i); SlObject(_industry_builder.builddata + i, _industrytype_builder_desc); @@ -175,22 +182,24 @@ static void Save_ITBL() /** Load industry-type build data. */ static void Load_ITBL() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_industrytype_builder_desc, _industrytype_builder_sl_compat); + for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) { _industry_builder.builddata[it].Reset(); } int index; while ((index = SlIterateArray()) != -1) { if ((uint)index >= NUM_INDUSTRYTYPES) SlErrorCorrupt("Too many industry builder datas"); - SlObject(_industry_builder.builddata + index, _industrytype_builder_desc); + SlObject(_industry_builder.builddata + index, slt); } } static const ChunkHandler industry_chunk_handlers[] = { - { 'INDY', Save_INDY, Load_INDY, Ptrs_INDY, nullptr, CH_ARRAY }, - { 'IIDS', Save_IIDS, Load_IIDS, nullptr, nullptr, CH_ARRAY }, - { 'TIDS', Save_TIDS, Load_TIDS, nullptr, nullptr, CH_ARRAY }, - { 'IBLD', Save_IBLD, Load_IBLD, nullptr, nullptr, CH_ARRAY }, - { 'ITBL', Save_ITBL, Load_ITBL, nullptr, nullptr, CH_ARRAY }, + { 'INDY', Save_INDY, Load_INDY, Ptrs_INDY, nullptr, CH_TABLE }, + { 'IIDS', Save_IIDS, Load_IIDS, nullptr, nullptr, CH_TABLE }, + { 'TIDS', Save_TIDS, Load_TIDS, nullptr, nullptr, CH_TABLE }, + { 'IBLD', Save_IBLD, Load_IBLD, nullptr, nullptr, CH_TABLE }, + { 'ITBL', Save_ITBL, Load_ITBL, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _industry_chunk_handlers(industry_chunk_handlers); diff --git a/src/saveload/labelmaps_sl.cpp b/src/saveload/labelmaps_sl.cpp index 5a7d6fae9..6b8509b53 100644 --- a/src/saveload/labelmaps_sl.cpp +++ b/src/saveload/labelmaps_sl.cpp @@ -8,11 +8,13 @@ /** @file labelmaps_sl.cpp Code handling saving and loading of rail type label mappings */ #include "../stdafx.h" -#include "../station_map.h" -#include "../tunnelbridge_map.h" #include "saveload.h" +#include "compat/labelmaps_sl_compat.h" + #include "saveload_internal.h" +#include "../station_map.h" +#include "../tunnelbridge_map.h" #include "../safeguards.h" @@ -99,6 +101,8 @@ static const SaveLoad _label_object_desc[] = { static void Save_RAIL() { + SlTableHeader(_label_object_desc); + LabelObject lo; for (RailType r = RAILTYPE_BEGIN; r != RAILTYPE_END; r++) { @@ -111,18 +115,20 @@ static void Save_RAIL() static void Load_RAIL() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_label_object_desc, _label_object_sl_compat); + ResetLabelMaps(); LabelObject lo; while (SlIterateArray() != -1) { - SlObject(&lo, _label_object_desc); + SlObject(&lo, slt); _railtype_list.push_back((RailTypeLabel)lo.label); } } static const ChunkHandler labelmaps_chunk_handlers[] = { - { 'RAIL', Save_RAIL, Load_RAIL, nullptr, nullptr, CH_ARRAY }, + { 'RAIL', Save_RAIL, Load_RAIL, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _labelmaps_chunk_handlers(labelmaps_chunk_handlers); diff --git a/src/saveload/map_sl.cpp b/src/saveload/map_sl.cpp index 476a9a89a..e55ac665a 100644 --- a/src/saveload/map_sl.cpp +++ b/src/saveload/map_sl.cpp @@ -8,13 +8,15 @@ /** @file map_sl.cpp Code handling saving and loading of map */ #include "../stdafx.h" + +#include "saveload.h" +#include "compat/map_sl_compat.h" + #include "../map_func.h" #include "../core/bitmath_func.hpp" #include "../fios.h" #include <array> -#include "saveload.h" - #include "../safeguards.h" static uint32 _map_dim_x; @@ -27,6 +29,8 @@ static const SaveLoad _map_desc[] = { static void Save_MAPS() { + SlTableHeader(_map_desc); + _map_dim_x = MapSizeX(); _map_dim_y = MapSizeY(); @@ -36,8 +40,10 @@ static void Save_MAPS() static void Load_MAPS() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_map_desc, _map_sl_compat); + if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return; - SlGlobList(_map_desc); + SlGlobList(slt); if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many MAPS entries"); AllocateMap(_map_dim_x, _map_dim_y); @@ -45,8 +51,10 @@ static void Load_MAPS() static void Check_MAPS() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_map_desc, _map_sl_compat); + if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return; - SlGlobList(_map_desc); + SlGlobList(slt); if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many MAPS entries"); _load_check_data.map_size_x = _map_dim_x; @@ -303,7 +311,7 @@ static void Save_MAP8() static const ChunkHandler map_chunk_handlers[] = { - { 'MAPS', Save_MAPS, Load_MAPS, nullptr, Check_MAPS, CH_ARRAY }, + { 'MAPS', Save_MAPS, Load_MAPS, nullptr, Check_MAPS, CH_TABLE }, { 'MAPT', Save_MAPT, Load_MAPT, nullptr, nullptr, CH_RIFF }, { 'MAPH', Save_MAPH, Load_MAPH, nullptr, nullptr, CH_RIFF }, { 'MAPO', Save_MAP1, Load_MAP1, nullptr, nullptr, CH_RIFF }, diff --git a/src/saveload/misc_sl.cpp b/src/saveload/misc_sl.cpp index eb227e336..35b59a021 100644 --- a/src/saveload/misc_sl.cpp +++ b/src/saveload/misc_sl.cpp @@ -8,6 +8,10 @@ /** @file misc_sl.cpp Saving and loading of things that didn't fit anywhere else */ #include "../stdafx.h" + +#include "saveload.h" +#include "compat/misc_sl_compat.h" + #include "../date_func.h" #include "../zoom_func.h" #include "../window_gui.h" @@ -17,8 +21,6 @@ #include "../core/random_func.hpp" #include "../fios.h" -#include "saveload.h" - #include "../safeguards.h" extern TileIndex _cur_tileloop_tile; @@ -72,73 +74,52 @@ static const SaveLoad _date_desc[] = { SLEG_CONDVAR("date", _date, SLE_FILE_U16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31), SLEG_CONDVAR("date", _date, SLE_INT32, SLV_31, SL_MAX_VERSION), SLEG_VAR("date_fract", _date_fract, SLE_UINT16), - SLEG_VAR("tick_counter", _tick_counter, SLE_UINT16), - SLE_CONDNULL(2, SL_MIN_VERSION, SLV_157), // _vehicle_id_ctr_day + SLEG_VAR("tick_counter", _tick_counter, SLE_UINT16), SLEG_CONDVAR("age_cargo_skip_counter", _age_cargo_skip_counter, SLE_UINT8, SL_MIN_VERSION, SLV_162), - SLE_CONDNULL(1, SL_MIN_VERSION, SLV_46), SLEG_CONDVAR("cur_tileloop_tile", _cur_tileloop_tile, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6), SLEG_CONDVAR("cur_tileloop_tile", _cur_tileloop_tile, SLE_UINT32, SLV_6, SL_MAX_VERSION), - SLEG_VAR("next_disaster_start", _disaster_delay, SLE_UINT16), - SLE_CONDNULL(2, SL_MIN_VERSION, SLV_120), + SLEG_VAR("next_disaster_start", _disaster_delay, SLE_UINT16), SLEG_VAR("random_state[0]", _random.state[0], SLE_UINT32), SLEG_VAR("random_state[1]", _random.state[1], SLE_UINT32), - SLE_CONDNULL(1, SL_MIN_VERSION, SLV_10), - SLE_CONDNULL(4, SLV_10, SLV_120), - SLEG_VAR("company_tick_counter", _cur_company_tick_index, SLE_FILE_U8 | SLE_VAR_U32), + SLEG_VAR("company_tick_counter", _cur_company_tick_index, SLE_FILE_U8 | SLE_VAR_U32), SLEG_CONDVAR("next_competitor_start", _next_competitor_start, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_109), SLEG_CONDVAR("next_competitor_start", _next_competitor_start, SLE_UINT32, SLV_109, SL_MAX_VERSION), SLEG_VAR("trees_tick_counter", _trees_tick_ctr, SLE_UINT8), SLEG_CONDVAR("pause_mode", _pause_mode, SLE_UINT8, SLV_4, SL_MAX_VERSION), - SLE_CONDNULL(4, SLV_11, SLV_120), }; static const SaveLoad _date_check_desc[] = { SLEG_CONDVAR("date", _load_check_data.current_date, SLE_FILE_U16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31), SLEG_CONDVAR("date", _load_check_data.current_date, SLE_INT32, SLV_31, SL_MAX_VERSION), - SLE_NULL(2), // _date_fract - SLE_NULL(2), // _tick_counter - SLE_CONDNULL(2, SL_MIN_VERSION, SLV_157), // _vehicle_id_ctr_day - SLE_CONDNULL(1, SL_MIN_VERSION, SLV_162), // _age_cargo_skip_counter - SLE_CONDNULL(1, SL_MIN_VERSION, SLV_46), - SLE_CONDNULL(2, SL_MIN_VERSION, SLV_6), // _cur_tileloop_tile - SLE_CONDNULL(4, SLV_6, SL_MAX_VERSION), // _cur_tileloop_tile - SLE_NULL(2), // _disaster_delay - SLE_CONDNULL(2, SL_MIN_VERSION, SLV_120), - SLE_NULL(4), // _random.state[0] - SLE_NULL(4), // _random.state[1] - SLE_CONDNULL(1, SL_MIN_VERSION, SLV_10), - SLE_CONDNULL(4, SLV_10, SLV_120), - SLE_NULL(1), // _cur_company_tick_index - SLE_CONDNULL(2, SL_MIN_VERSION, SLV_109), // _next_competitor_start - SLE_CONDNULL(4, SLV_109, SL_MAX_VERSION), // _next_competitor_start - SLE_NULL(1), // _trees_tick_ctr - SLE_CONDNULL(1, SLV_4, SL_MAX_VERSION), // _pause_mode - SLE_CONDNULL(4, SLV_11, SLV_120), }; /* Save load date related variables as well as persistent tick counters * XXX: currently some unrelated stuff is just put here */ static void Save_DATE() { + SlTableHeader(_date_desc); + SlSetArrayIndex(0); SlGlobList(_date_desc); } -static void Load_DATE_common(const SaveLoadTable &slt) +static void Load_DATE_common(const SaveLoadTable &slt, const SaveLoadCompatTable &slct) { + const std::vector<SaveLoad> oslt = SlCompatTableHeader(slt, slct); + if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return; - SlGlobList(slt); + SlGlobList(oslt); if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many DATE entries"); } static void Load_DATE() { - Load_DATE_common(_date_desc); + Load_DATE_common(_date_desc, _date_sl_compat); } static void Check_DATE() { - Load_DATE_common(_date_check_desc); + Load_DATE_common(_date_check_desc, _date_check_sl_compat); if (IsSavegameVersionBefore(SLV_31)) { _load_check_data.current_date += DAYS_TILL_ORIGINAL_BASE_YEAR; @@ -156,20 +137,24 @@ static const SaveLoad _view_desc[] = { static void Save_VIEW() { + SlTableHeader(_view_desc); + SlSetArrayIndex(0); SlGlobList(_view_desc); } static void Load_VIEW() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_view_desc, _view_sl_compat); + if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return; - SlGlobList(_view_desc); + SlGlobList(slt); if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many DATE entries"); } static const ChunkHandler misc_chunk_handlers[] = { - { 'DATE', Save_DATE, Load_DATE, nullptr, Check_DATE, CH_ARRAY }, - { 'VIEW', Save_VIEW, Load_VIEW, nullptr, nullptr, CH_ARRAY }, + { 'DATE', Save_DATE, Load_DATE, nullptr, Check_DATE, CH_TABLE }, + { 'VIEW', Save_VIEW, Load_VIEW, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _misc_chunk_handlers(misc_chunk_handlers); diff --git a/src/saveload/newgrf_sl.cpp b/src/saveload/newgrf_sl.cpp index f92da0db3..20b658562 100644 --- a/src/saveload/newgrf_sl.cpp +++ b/src/saveload/newgrf_sl.cpp @@ -8,10 +8,12 @@ /** @file newgrf_sl.cpp Code handling saving and loading of newgrf config */ #include "../stdafx.h" -#include "../fios.h" #include "saveload.h" +#include "compat/newgrf_sl_compat.h" + #include "newgrf_sl.h" +#include "../fios.h" #include "../safeguards.h" @@ -28,6 +30,8 @@ static const SaveLoad _newgrf_mapping_desc[] = { */ void Save_NewGRFMapping(const OverrideManagerBase &mapping) { + SlTableHeader(_newgrf_mapping_desc); + for (uint i = 0; i < mapping.GetMaxMapping(); i++) { if (mapping.mapping_ID[i].grfid == 0 && mapping.mapping_ID[i].entity_id == 0) continue; @@ -42,6 +46,8 @@ void Save_NewGRFMapping(const OverrideManagerBase &mapping) */ void Load_NewGRFMapping(OverrideManagerBase &mapping) { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_newgrf_mapping_desc, _newgrf_mapping_sl_compat); + /* Clear the current mapping stored. * This will create the manager if ever it is not yet done */ mapping.ResetMapping(); @@ -51,7 +57,7 @@ void Load_NewGRFMapping(OverrideManagerBase &mapping) int index; while ((index = SlIterateArray()) != -1) { if ((uint)index >= max_id) SlErrorCorrupt("Too many NewGRF entity mappings"); - SlObject(&mapping.mapping_ID[index], _newgrf_mapping_desc); + SlObject(&mapping.mapping_ID[index], slt); } } @@ -69,6 +75,8 @@ static const SaveLoad _grfconfig_desc[] = { static void Save_NGRF() { + SlTableHeader(_grfconfig_desc); + int index = 0; for (GRFConfig *c = _grfconfig; c != nullptr; c = c->next) { @@ -81,10 +89,12 @@ static void Save_NGRF() static void Load_NGRF_common(GRFConfig *&grfconfig) { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_grfconfig_desc, _grfconfig_sl_compat); + ClearGRFConfigList(&grfconfig); while (SlIterateArray() != -1) { GRFConfig *c = new GRFConfig(); - SlObject(c, _grfconfig_desc); + SlObject(c, slt); if (IsSavegameVersionBefore(SLV_101)) c->SetSuitablePalette(); AppendToGRFConfigList(&grfconfig, c); } @@ -112,7 +122,7 @@ static void Check_NGRF() } static const ChunkHandler newgrf_chunk_handlers[] = { - { 'NGRF', Save_NGRF, Load_NGRF, nullptr, Check_NGRF, CH_ARRAY } + { 'NGRF', Save_NGRF, Load_NGRF, nullptr, Check_NGRF, CH_TABLE } }; extern const ChunkHandlerTable _newgrf_chunk_handlers(newgrf_chunk_handlers); 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<SaveLoad> 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); diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp index 81e485606..4d9bf3d8f 100644 --- a/src/saveload/order_sl.cpp +++ b/src/saveload/order_sl.cpp @@ -8,12 +8,15 @@ /** @file order_sl.cpp Code handling saving and loading of orders */ #include "../stdafx.h" + +#include "saveload.h" +#include "compat/order_sl_compat.h" + +#include "saveload_internal.h" #include "../order_backup.h" #include "../settings_type.h" #include "../network/network.h" -#include "saveload_internal.h" - #include "../safeguards.h" /** @@ -107,14 +110,9 @@ SaveLoadTable GetOrderDescription() SLE_VAR(Order, dest, SLE_UINT16), SLE_REF(Order, next, REF_ORDER), SLE_CONDVAR(Order, refit_cargo, SLE_UINT8, SLV_36, SL_MAX_VERSION), - SLE_CONDNULL(1, SLV_36, SLV_182), // refit_subtype SLE_CONDVAR(Order, wait_time, SLE_UINT16, SLV_67, SL_MAX_VERSION), SLE_CONDVAR(Order, travel_time, SLE_UINT16, SLV_67, SL_MAX_VERSION), SLE_CONDVAR(Order, max_speed, SLE_UINT16, SLV_172, SL_MAX_VERSION), - - /* Leftover from the minor savegame version stuff - * We will never use those free bytes, but we have to keep this line to allow loading of old savegames */ - SLE_CONDNULL(10, SLV_5, SLV_36), }; return _order_desc; @@ -122,9 +120,12 @@ SaveLoadTable GetOrderDescription() static void Save_ORDR() { + const SaveLoadTable slt = GetOrderDescription(); + SlTableHeader(slt); + for (Order *order : Order::Iterate()) { SlSetArrayIndex(order->index); - SlObject(order, GetOrderDescription()); + SlObject(order, slt); } } @@ -176,11 +177,13 @@ static void Load_ORDR() if (prev != nullptr) prev->next = o; } } else { + const std::vector<SaveLoad> slt = SlCompatTableHeader(GetOrderDescription(), _order_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { Order *order = new (index) Order(); - SlObject(order, GetOrderDescription()); + SlObject(order, slt); } } } @@ -206,20 +209,25 @@ SaveLoadTable GetOrderListDescription() static void Save_ORDL() { + const SaveLoadTable slt = GetOrderListDescription(); + SlTableHeader(slt); + for (OrderList *list : OrderList::Iterate()) { SlSetArrayIndex(list->index); - SlObject(list, GetOrderListDescription()); + SlObject(list, slt); } } static void Load_ORDL() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(GetOrderListDescription(), _orderlist_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { /* set num_orders to 0 so it's a valid OrderList */ OrderList *list = new (index) OrderList(0); - SlObject(list, GetOrderListDescription()); + SlObject(list, slt); } } @@ -240,7 +248,6 @@ SaveLoadTable GetOrderBackupDescription() SLE_CONDVAR(OrderBackup, service_interval, SLE_FILE_U32 | SLE_VAR_U16, SL_MIN_VERSION, SLV_192), SLE_CONDVAR(OrderBackup, service_interval, SLE_UINT16, SLV_192, SL_MAX_VERSION), SLE_SSTR(OrderBackup, name, SLE_STR), - SLE_CONDNULL(2, SL_MIN_VERSION, SLV_192), // clone (2 bytes of pointer, i.e. garbage) SLE_CONDREF(OrderBackup, clone, REF_VEHICLE, SLV_192, SL_MAX_VERSION), SLE_VAR(OrderBackup, cur_real_order_index, SLE_UINT8), SLE_CONDVAR(OrderBackup, cur_implicit_order_index, SLE_UINT8, SLV_176, SL_MAX_VERSION), @@ -257,6 +264,9 @@ SaveLoadTable GetOrderBackupDescription() static void Save_BKOR() { + const SaveLoadTable slt = GetOrderBackupDescription(); + SlTableHeader(slt); + /* We only save this when we're a network server * as we want this information on our clients. For * normal games this information isn't needed. */ @@ -264,18 +274,20 @@ static void Save_BKOR() for (OrderBackup *ob : OrderBackup::Iterate()) { SlSetArrayIndex(ob->index); - SlObject(ob, GetOrderBackupDescription()); + SlObject(ob, slt); } } void Load_BKOR() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(GetOrderBackupDescription(), _order_backup_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { /* set num_orders to 0 so it's a valid OrderList */ OrderBackup *ob = new (index) OrderBackup(); - SlObject(ob, GetOrderBackupDescription()); + SlObject(ob, slt); } } @@ -287,9 +299,9 @@ static void Ptrs_BKOR() } static const ChunkHandler order_chunk_handlers[] = { - { 'BKOR', Save_BKOR, Load_BKOR, Ptrs_BKOR, nullptr, CH_ARRAY }, - { 'ORDR', Save_ORDR, Load_ORDR, Ptrs_ORDR, nullptr, CH_ARRAY }, - { 'ORDL', Save_ORDL, Load_ORDL, Ptrs_ORDL, nullptr, CH_ARRAY }, + { 'BKOR', Save_BKOR, Load_BKOR, Ptrs_BKOR, nullptr, CH_TABLE }, + { 'ORDR', Save_ORDR, Load_ORDR, Ptrs_ORDR, nullptr, CH_TABLE }, + { 'ORDL', Save_ORDL, Load_ORDL, Ptrs_ORDL, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _order_chunk_handlers(order_chunk_handlers); diff --git a/src/saveload/signs_sl.cpp b/src/saveload/signs_sl.cpp index 388a92af9..4479ff63d 100644 --- a/src/saveload/signs_sl.cpp +++ b/src/saveload/signs_sl.cpp @@ -8,10 +8,12 @@ /** @file signs_sl.cpp Code handling saving and loading of economy data */ #include "../stdafx.h" -#include "../signs_base.h" -#include "../fios.h" #include "saveload.h" +#include "compat/signs_sl_compat.h" + +#include "../signs_base.h" +#include "../fios.h" #include "../safeguards.h" @@ -31,6 +33,8 @@ static const SaveLoad _sign_desc[] = { /** Save all signs */ static void Save_SIGN() { + SlTableHeader(_sign_desc); + for (Sign *si : Sign::Iterate()) { SlSetArrayIndex(si->index); SlObject(si, _sign_desc); @@ -40,10 +44,12 @@ static void Save_SIGN() /** Load all signs */ static void Load_SIGN() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_sign_desc, _sign_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { Sign *si = new (index) Sign(); - SlObject(si, _sign_desc); + SlObject(si, slt); /* Before version 6.1, signs didn't have owner. * Before version 83, invalid signs were determined by si->str == 0. * Before version 103, owner could be a bankrupted company. @@ -61,9 +67,8 @@ static void Load_SIGN() } } -/** Chunk handlers related to signs. */ static const ChunkHandler sign_chunk_handlers[] = { - { 'SIGN', Save_SIGN, Load_SIGN, nullptr, nullptr, CH_ARRAY }, + { 'SIGN', Save_SIGN, Load_SIGN, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _sign_chunk_handlers(sign_chunk_handlers); diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index 5b99b09f7..ebf2c94f4 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -8,13 +8,16 @@ /** @file station_sl.cpp Code handling saving and loading of stations. */ #include "../stdafx.h" + +#include "saveload.h" +#include "compat/station_sl_compat.h" + #include "../station_base.h" #include "../waypoint_base.h" #include "../roadstop_base.h" #include "../vehicle_base.h" #include "../newgrf_station.h" -#include "saveload.h" #include "table/strings.h" #include "../safeguards.h" @@ -142,18 +145,8 @@ void AfterLoadRoadStops() static const SaveLoad _roadstop_desc[] = { SLE_VAR(RoadStop, xy, SLE_UINT32), - SLE_CONDNULL(1, SL_MIN_VERSION, SLV_45), SLE_VAR(RoadStop, status, SLE_UINT8), - /* Index was saved in some versions, but this is not needed */ - SLE_CONDNULL(4, SL_MIN_VERSION, SLV_9), - SLE_CONDNULL(2, SL_MIN_VERSION, SLV_45), - SLE_CONDNULL(1, SL_MIN_VERSION, SLV_26), - SLE_REF(RoadStop, next, REF_ROADSTOPS), - SLE_CONDNULL(2, SL_MIN_VERSION, SLV_45), - - SLE_CONDNULL(4, SL_MIN_VERSION, SLV_25), - SLE_CONDNULL(1, SLV_25, SLV_26), }; static uint16 _waiting_acceptance; @@ -678,6 +671,8 @@ static void Ptrs_STNN() static void Save_ROADSTOP() { + SlTableHeader(_roadstop_desc); + for (RoadStop *rs : RoadStop::Iterate()) { SlSetArrayIndex(rs->index); SlObject(rs, _roadstop_desc); @@ -686,12 +681,14 @@ static void Save_ROADSTOP() static void Load_ROADSTOP() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_roadstop_desc, _roadstop_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { RoadStop *rs = new (index) RoadStop(INVALID_TILE); - SlObject(rs, _roadstop_desc); + SlObject(rs, slt); } } @@ -705,7 +702,7 @@ static void Ptrs_ROADSTOP() static const ChunkHandler station_chunk_handlers[] = { { 'STNS', nullptr, Load_STNS, Ptrs_STNS, nullptr, CH_READONLY }, { 'STNN', Save_STNN, Load_STNN, Ptrs_STNN, nullptr, CH_ARRAY }, - { 'ROAD', Save_ROADSTOP, Load_ROADSTOP, Ptrs_ROADSTOP, nullptr, CH_ARRAY }, + { 'ROAD', Save_ROADSTOP, Load_ROADSTOP, Ptrs_ROADSTOP, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _station_chunk_handlers(station_chunk_handlers); diff --git a/src/saveload/storage_sl.cpp b/src/saveload/storage_sl.cpp index 50f858f11..4838e9f12 100644 --- a/src/saveload/storage_sl.cpp +++ b/src/saveload/storage_sl.cpp @@ -8,8 +8,11 @@ /** @file storage_sl.cpp Code handling saving and loading of persistent storages. */ #include "../stdafx.h" -#include "../newgrf_storage.h" + #include "saveload.h" +#include "compat/storage_sl_compat.h" + +#include "../newgrf_storage.h" #include "../safeguards.h" @@ -23,18 +26,22 @@ static const SaveLoad _storage_desc[] = { /** Load persistent storage data. */ static void Load_PSAC() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_storage_desc, _storage_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { assert(PersistentStorage::CanAllocateItem()); PersistentStorage *ps = new (index) PersistentStorage(0, 0, 0); - SlObject(ps, _storage_desc); + SlObject(ps, slt); } } /** Save persistent storage data. */ static void Save_PSAC() { + SlTableHeader(_storage_desc); + /* Write the industries */ for (PersistentStorage *ps : PersistentStorage::Iterate()) { ps->ClearChanges(); @@ -43,9 +50,8 @@ static void Save_PSAC() } } -/** Chunk handler for persistent storages. */ static const ChunkHandler persistent_storage_chunk_handlers[] = { - { 'PSAC', Save_PSAC, Load_PSAC, nullptr, nullptr, CH_ARRAY }, + { 'PSAC', Save_PSAC, Load_PSAC, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _persistent_storage_chunk_handlers(persistent_storage_chunk_handlers); diff --git a/src/saveload/story_sl.cpp b/src/saveload/story_sl.cpp index df5b1406f..9dabd5cbf 100644 --- a/src/saveload/story_sl.cpp +++ b/src/saveload/story_sl.cpp @@ -8,9 +8,11 @@ /** @file story_sl.cpp Code handling saving and loading of story pages */ #include "../stdafx.h" -#include "../story_base.h" #include "saveload.h" +#include "compat/story_sl_compat.h" + +#include "../story_base.h" #include "../safeguards.h" @@ -38,6 +40,8 @@ static const SaveLoad _story_page_elements_desc[] = { static void Save_STORY_PAGE_ELEMENT() { + SlTableHeader(_story_page_elements_desc); + for (StoryPageElement *s : StoryPageElement::Iterate()) { SlSetArrayIndex(s->index); SlObject(s, _story_page_elements_desc); @@ -46,11 +50,13 @@ static void Save_STORY_PAGE_ELEMENT() static void Load_STORY_PAGE_ELEMENT() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_story_page_elements_desc, _story_page_elements_sl_compat); + int index; uint32 max_sort_value = 0; while ((index = SlIterateArray()) != -1) { StoryPageElement *s = new (index) StoryPageElement(); - SlObject(s, _story_page_elements_desc); + SlObject(s, slt); if (s->sort_value > max_sort_value) { max_sort_value = s->sort_value; } @@ -72,6 +78,8 @@ static const SaveLoad _story_pages_desc[] = { static void Save_STORY_PAGE() { + SlTableHeader(_story_pages_desc); + for (StoryPage *s : StoryPage::Iterate()) { SlSetArrayIndex(s->index); SlObject(s, _story_pages_desc); @@ -80,11 +88,13 @@ static void Save_STORY_PAGE() static void Load_STORY_PAGE() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_story_pages_desc, _story_pages_sl_compat); + int index; uint32 max_sort_value = 0; while ((index = SlIterateArray()) != -1) { StoryPage *s = new (index) StoryPage(); - SlObject(s, _story_pages_desc); + SlObject(s, slt); if (s->sort_value > max_sort_value) { max_sort_value = s->sort_value; } @@ -96,8 +106,8 @@ static void Load_STORY_PAGE() } static const ChunkHandler story_page_chunk_handlers[] = { - { 'STPE', Save_STORY_PAGE_ELEMENT, Load_STORY_PAGE_ELEMENT, nullptr, nullptr, CH_ARRAY }, - { 'STPA', Save_STORY_PAGE, Load_STORY_PAGE, nullptr, nullptr, CH_ARRAY }, + { 'STPE', Save_STORY_PAGE_ELEMENT, Load_STORY_PAGE_ELEMENT, nullptr, nullptr, CH_TABLE }, + { 'STPA', Save_STORY_PAGE, Load_STORY_PAGE, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _story_page_chunk_handlers(story_page_chunk_handlers); diff --git a/src/saveload/strings_sl.cpp b/src/saveload/strings_sl.cpp index 784d89d8f..70d001e73 100644 --- a/src/saveload/strings_sl.cpp +++ b/src/saveload/strings_sl.cpp @@ -130,7 +130,6 @@ static void Load_NAME() } } -/** Chunk handlers related to strings. */ static const ChunkHandler name_chunk_handlers[] = { { 'NAME', nullptr, Load_NAME, nullptr, nullptr, CH_READONLY }, }; diff --git a/src/saveload/subsidy_sl.cpp b/src/saveload/subsidy_sl.cpp index 9ed65a04e..0a9c25ebd 100644 --- a/src/saveload/subsidy_sl.cpp +++ b/src/saveload/subsidy_sl.cpp @@ -8,9 +8,11 @@ /** @file subsidy_sl.cpp Code handling saving and loading of subsidies */ #include "../stdafx.h" -#include "../subsidy_base.h" #include "saveload.h" +#include "compat/subsidy_sl_compat.h" + +#include "../subsidy_base.h" #include "../safeguards.h" @@ -29,6 +31,8 @@ static const SaveLoad _subsidies_desc[] = { static void Save_SUBS() { + SlTableHeader(_subsidies_desc); + for (Subsidy *s : Subsidy::Iterate()) { SlSetArrayIndex(s->index); SlObject(s, _subsidies_desc); @@ -37,15 +41,17 @@ static void Save_SUBS() static void Load_SUBS() { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_subsidies_desc, _subsidies_sl_compat); + int index; while ((index = SlIterateArray()) != -1) { Subsidy *s = new (index) Subsidy(); - SlObject(s, _subsidies_desc); + SlObject(s, slt); } } static const ChunkHandler subsidy_chunk_handlers[] = { - { 'SUBS', Save_SUBS, Load_SUBS, nullptr, nullptr, CH_ARRAY }, + { 'SUBS', Save_SUBS, Load_SUBS, nullptr, nullptr, CH_TABLE }, }; extern const ChunkHandlerTable _subsidy_chunk_handlers(subsidy_chunk_handlers); diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp index c653db53a..faca4180c 100644 --- a/src/saveload/town_sl.cpp +++ b/src/saveload/town_sl.cpp @@ -325,9 +325,8 @@ static void Ptrs_TOWN() } } -/** Chunk handler for towns. */ static const ChunkHandler town_chunk_handlers[] = { - { 'HIDS', Save_HIDS, Load_HIDS, nullptr, nullptr, CH_ARRAY }, + { 'HIDS', Save_HIDS, Load_HIDS, nullptr, nullptr, CH_TABLE }, { 'CITY', Save_TOWN, Load_TOWN, Ptrs_TOWN, nullptr, CH_ARRAY }, }; diff --git a/src/settings.cpp b/src/settings.cpp index 6368dea11..837c6ae02 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -67,6 +67,8 @@ #include "strings_func.h" #include "vehicle_func.h" +#include "saveload/compat/settings_sl_compat.h" + #include "void_map.h" #include "station_base.h" @@ -2193,27 +2195,31 @@ static std::vector<SaveLoad> GetSettingsDesc(const SettingTable &settings, bool if (sd->flags & SF_NOT_IN_SAVE) continue; if (is_loading && (sd->flags & SF_NO_NETWORK_SYNC) && _networking && !_network_server) { - /* We don't want to read this setting, so we do need to skip over it. */ - saveloads.push_back({sd->name, sd->save.cmd, GetVarFileType(sd->save.conv) | SLE_VAR_NULL, sd->save.length, sd->save.version_from, sd->save.version_to, 0, nullptr, 0, nullptr}); + if (IsSavegameVersionBefore(SLV_TABLE_CHUNKS)) { + /* We don't want to read this setting, so we do need to skip over it. */ + saveloads.push_back({sd->name, sd->save.cmd, GetVarFileType(sd->save.conv) | SLE_VAR_NULL, sd->save.length, sd->save.version_from, sd->save.version_to, 0, nullptr, 0, nullptr}); + } continue; } - saveloads.push_back(sd->save); + SaveLoad sv = sd->save; + /* Replace the name with the actual name of the setting. */ + if (!sd->name.empty()) sv.name = sd->name; + saveloads.push_back(sv); } return saveloads; } - /** * Save and load handler for settings * @param settings SettingDesc struct containing all information * @param object can be either nullptr in which case we load global variables or * a pointer to a struct which is getting saved */ -static void LoadSettings(const SettingTable &settings, void *object) +static void LoadSettings(const SettingTable &settings, void *object, const SaveLoadCompatTable &slct) { - const std::vector<SaveLoad> slt = GetSettingsDesc(settings, true); + const std::vector<SaveLoad> slt = SlCompatTableHeader(GetSettingsDesc(settings, true), slct); if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return; SlObject(object, slt); @@ -2243,6 +2249,8 @@ static void SaveSettings(const SettingTable &settings, void *object) { const std::vector<SaveLoad> slt = GetSettingsDesc(settings, false); + SlTableHeader(slt); + SlSetArrayIndex(0); SlObject(object, slt); } @@ -2253,7 +2261,7 @@ static void Load_OPTS() * a networking environment. This ensures for example that the local * autosave-frequency stays when joining a network-server */ PrepareOldDiffCustom(); - LoadSettings(_gameopt_settings, &_settings_game); + LoadSettings(_gameopt_settings, &_settings_game, _gameopt_sl_compat); HandleOldDiffCustom(true); } @@ -2262,12 +2270,12 @@ static void Load_PATS() /* Copy over default setting since some might not get loaded in * a networking environment. This ensures for example that the local * currency setting stays when joining a network-server */ - LoadSettings(_settings, &_settings_game); + LoadSettings(_settings, &_settings_game, _settings_sl_compat); } static void Check_PATS() { - LoadSettings(_settings, &_load_check_data.settings); + LoadSettings(_settings, &_load_check_data.settings, _settings_sl_compat); } static void Save_PATS() @@ -2276,8 +2284,8 @@ static void Save_PATS() } static const ChunkHandler setting_chunk_handlers[] = { - { 'OPTS', nullptr, Load_OPTS, nullptr, nullptr, CH_READONLY }, - { 'PATS', Save_PATS, Load_PATS, nullptr, Check_PATS, CH_ARRAY }, + { 'OPTS', nullptr, Load_OPTS, nullptr, nullptr, CH_READONLY }, + { 'PATS', Save_PATS, Load_PATS, nullptr, Check_PATS, CH_TABLE }, }; extern const ChunkHandlerTable _setting_chunk_handlers(setting_chunk_handlers); diff --git a/src/table/settings/gameopt_settings.ini b/src/table/settings/gameopt_settings.ini index 447400623..a30400e85 100644 --- a/src/table/settings/gameopt_settings.ini +++ b/src/table/settings/gameopt_settings.ini @@ -158,15 +158,6 @@ min = MIN_SNOWLINE_HEIGHT * TILE_HEIGHT max = UINT8_MAX to = SLV_22 -[SDT_NULL] -length = 1 -from = SLV_22 -to = SLV_165 - -[SDT_NULL] -length = 1 -to = SLV_23 - [SDTC_OMANY] var = gui.autosave type = SLE_UINT8 diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index 601493a7e..fae6e5636 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -62,7 +62,6 @@ SDT_BOOL = SDT_BOOL(GameSettings, $var, $flags, $def, SDT_OMANY = SDT_OMANY(GameSettings, $var, $type, $flags, $def, $max, $full, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $load, $cat, $extra, $startup), SDT_SSTR = SDT_SSTR(GameSettings, $var, $type, $flags, $def, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), SDT_VAR = SDT_VAR(GameSettings, $var, $type, $flags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), -SDT_NULL = SDT_NULL( $length, $from, $to), [validation] SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size"); @@ -355,12 +354,6 @@ strhelp = STR_CONFIG_SETTING_LANDSCAPE_HELPTEXT strval = STR_CHEAT_SWITCH_CLIMATE_TEMPERATE_LANDSCAPE cat = SC_BASIC -; Snow line (or snow_line_height * TILE_HEIGHT) -[SDT_NULL] -length = 1 -from = SLV_97 -to = SLV_164 - [SDT_OMANY] var = vehicle.road_side type = SLE_UINT8 @@ -536,11 +529,6 @@ str = STR_CONFIG_SETTING_MAX_TUNNEL_LENGTH strhelp = STR_CONFIG_SETTING_MAX_TUNNEL_LENGTH_HELPTEXT strval = STR_CONFIG_SETTING_TILE_LENGTH -# construction.longbridges -[SDT_NULL] -length = 1 -to = SLV_159 - [SDT_VAR] var = construction.train_signal_side type = SLE_UINT8 @@ -843,11 +831,6 @@ strhelp = STR_CONFIG_SETTING_TRAIN_LENGTH_HELPTEXT strval = STR_CONFIG_SETTING_TILE_LENGTH cat = SC_BASIC -; vehicle.mammoth_trains -[SDT_NULL] -length = 1 -to = SLV_159 - [SDT_VAR] var = vehicle.smoke_amount type = SLE_UINT8 @@ -860,11 +843,6 @@ str = STR_CONFIG_SETTING_SMOKE_AMOUNT strhelp = STR_CONFIG_SETTING_SMOKE_AMOUNT_HELPTEXT strval = STR_CONFIG_SETTING_NONE -; order.gotodepot -[SDT_NULL] -length = 1 -to = SLV_159 - ; path finder [SDT_BOOL] @@ -1083,12 +1061,6 @@ strhelp = STR_CONFIG_SETTING_FREIGHT_TRAINS_HELPTEXT strval = STR_JUST_COMMA post_cb = UpdateConsists -; order.timetabling -[SDT_NULL] -length = 1 -from = SLV_67 -to = SLV_159 - [SDT_VAR] var = vehicle.plane_speed type = SLE_UINT8 @@ -1123,11 +1095,6 @@ strhelp = STR_CONFIG_SETTING_PLANE_CRASHES_HELPTEXT strval = STR_CONFIG_SETTING_PLANE_CRASHES_NONE cat = SC_BASIC -; station.join_stations -[SDT_NULL] -length = 1 -to = SLV_159 - [SDTC_BOOL] var = gui.sg_full_load_any from = SLV_22 @@ -1151,11 +1118,6 @@ from = SLV_22 to = SLV_93 def = false -; station.nonuniform_stations -[SDT_NULL] -length = 1 -to = SLV_159 - [SDT_VAR] var = station.station_spread type = SLE_UINT8 @@ -1277,10 +1239,6 @@ def = false str = STR_CONFIG_SETTING_MULTIPINDTOWN strhelp = STR_CONFIG_SETTING_MULTIPINDTOWN_HELPTEXT -[SDT_NULL] -length = 1 -to = SLV_141 - [SDT_BOOL] var = economy.bribe def = true @@ -1365,10 +1323,6 @@ strhelp = STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT strval = STR_CONFIG_SETTING_DESERT_COVERAGE_VALUE cat = SC_BASIC -[SDT_NULL] -length = 4 -to = SLV_144 - [SDT_VAR] var = game_creation.starting_year type = SLE_INT32 @@ -1380,10 +1334,6 @@ str = STR_CONFIG_SETTING_STARTING_YEAR strval = STR_JUST_INT cat = SC_BASIC -[SDT_NULL] -length = 4 -to = SLV_105 - [SDT_VAR] var = game_creation.ending_year type = SLE_INT32 @@ -1486,11 +1436,6 @@ from = SLV_77 def = true cat = SC_EXPERT -; previously ai-new setting. -[SDT_NULL] -length = 1 -to = SLV_107 - [SDT_OMANY] var = script.settings_profile type = SLE_UINT8 @@ -1665,13 +1610,6 @@ min = 1 max = 255 cat = SC_EXPERT -## -; Used to be pf.opf.pf_maxlength & pf.opf.pf_maxdepth -[SDT_NULL] -length = 3 -to = SLV_REMOVE_OPF - -## [SDT_VAR] var = pf.npf.npf_max_search_nodes type = SLE_UINT |