From 7ffc8c0173cea7b364636e4a0686e72947095a9a Mon Sep 17 00:00:00 2001 From: terkhen Date: Sun, 12 Jun 2011 20:49:07 +0000 Subject: (svn r22568) -Change: Add a list of persistent storages to the Town class. --- src/saveload/town_sl.cpp | 19 +++++++++++++++++-- src/town.h | 4 ++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp index e246f61f7..06b70d074 100644 --- a/src/saveload/town_sl.cpp +++ b/src/saveload/town_sl.cpp @@ -171,6 +171,8 @@ static const SaveLoad _town_desc[] = { SLE_CONDVAR(Town, larger_town, SLE_BOOL, 56, SL_MAX_VERSION), SLE_CONDVAR(Town, layout, SLE_UINT8, 113, SL_MAX_VERSION), + SLE_CONDLST(Town, psa_list, REF_STORAGE, 161, SL_MAX_VERSION), + /* reserve extra space in savegame here. (currently 30 bytes) */ SLE_CONDNULL(30, 2, SL_MAX_VERSION), @@ -207,7 +209,20 @@ static void Load_TOWN() } } +/** Fix pointers when loading town data. */ +static void Ptrs_TOWN() +{ + /* Don't run when savegame version lower than 161. */ + if (IsSavegameVersionBefore(161)) return; + + Town *t; + FOR_ALL_TOWNS(t) { + SlObject(t, _town_desc); + } +} + +/** Chunk handler for towns. */ extern const ChunkHandler _town_chunk_handlers[] = { - { 'HIDS', Save_HIDS, Load_HIDS, NULL, NULL, CH_ARRAY }, - { 'CITY', Save_TOWN, Load_TOWN, NULL, NULL, CH_ARRAY | CH_LAST}, + { 'HIDS', Save_HIDS, Load_HIDS, NULL, NULL, CH_ARRAY }, + { 'CITY', Save_TOWN, Load_TOWN, Ptrs_TOWN, NULL, CH_ARRAY | CH_LAST}, }; diff --git a/src/town.h b/src/town.h index 0f6229a89..c61f31522 100644 --- a/src/town.h +++ b/src/town.h @@ -17,6 +17,8 @@ #include "command_type.h" #include "town_map.h" #include "subsidy_type.h" +#include "newgrf_storage.h" +#include template struct BuildingCounts { @@ -105,6 +107,8 @@ struct Town : TownPool::PoolItem<&_town_pool> { bool larger_town; TownLayoutByte layout; ///< town specific road layout + std::list psa_list; + PartOfSubsidyByte part_of_subsidy; ///< NOSAVE: is this town a source/destination of a subsidy? /* NOSAVE: UpdateTownRadius updates this given the house count. */ -- cgit v1.2.3-70-g09d2