Changeset - r17773:70894fef31f4
[Not reviewed]
master
0 2 0
terkhen - 13 years ago 2011-06-12 20:49:07
terkhen@openttd.org
(svn r22568) -Change: Add a list of persistent storages to the Town class.
2 files changed with 21 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/saveload/town_sl.cpp
Show inline comments
 
@@ -168,12 +168,14 @@ static const SaveLoad _town_desc[] = {
 
	SLE_CONDVAR(Town, exclusivity,           SLE_UINT8,                  2, SL_MAX_VERSION),
 
	SLE_CONDVAR(Town, exclusive_counter,     SLE_UINT8,                  2, SL_MAX_VERSION),
 

	
 
	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),
 

	
 
	SLE_END()
 
};
 

	
 
@@ -204,10 +206,23 @@ static void Load_TOWN()
 
	while ((index = SlIterateArray()) != -1) {
 
		Town *t = new (index) Town();
 
		SlObject(t, _town_desc);
 
	}
 
}
 

	
 
/** 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},
 
};
src/town.h
Show inline comments
 
@@ -14,12 +14,14 @@
 

	
 
#include "core/pool_type.hpp"
 
#include "viewport_type.h"
 
#include "command_type.h"
 
#include "town_map.h"
 
#include "subsidy_type.h"
 
#include "newgrf_storage.h"
 
#include <list>
 

	
 
template <typename T>
 
struct BuildingCounts {
 
	T id_count[HOUSE_MAX];
 
	T class_count[HOUSE_CLASS_MAX];
 
};
 
@@ -102,12 +104,14 @@ struct Town : TownPool::PoolItem<&_town_
 
	byte road_build_months;
 

	
 
	/* If this is a larger town, and should grow more quickly. */
 
	bool larger_town;
 
	TownLayoutByte layout; ///< town specific road layout
 

	
 
	std::list<PersistentStorage *> psa_list;
 

	
 
	PartOfSubsidyByte part_of_subsidy; ///< NOSAVE: is this town a source/destination of a subsidy?
 

	
 
	/* NOSAVE: UpdateTownRadius updates this given the house count. */
 
	uint32 squared_town_zone_radius[HZB_END];
 

	
 
	BuildingCounts<uint16> building_counts; ///< NOSAVE: The number of each type of building in the town.
0 comments (0 inline, 0 general)