12 #include "../stdafx.h" 13 #include "../newgrf_house.h" 15 #include "../landscape.h" 16 #include "../subsidy_func.h" 17 #include "../strings_func.h" 22 #include "../safeguards.h" 30 InitializeBuildingCounts();
42 town = Town::GetByTile(t);
52 UpdateTownRadius(town);
86 if (t == north_tile) {
87 const HouseSpec *hs = HouseSpec::Get(house_type);
88 bool valid_house =
true;
106 if (!valid_house) DoClearSquare(t);
145 SLE_CONDVAR(
Town, supplied[CT_PASSENGERS].old_max, SLE_FILE_U16 | SLE_VAR_U32, 0, 8),
146 SLE_CONDVAR(
Town, supplied[CT_MAIL].old_max, SLE_FILE_U16 | SLE_VAR_U32, 0, 8),
147 SLE_CONDVAR(
Town, supplied[CT_PASSENGERS].new_max, SLE_FILE_U16 | SLE_VAR_U32, 0, 8),
148 SLE_CONDVAR(
Town, supplied[CT_MAIL].new_max, SLE_FILE_U16 | SLE_VAR_U32, 0, 8),
149 SLE_CONDVAR(
Town, supplied[CT_PASSENGERS].old_act, SLE_FILE_U16 | SLE_VAR_U32, 0, 8),
150 SLE_CONDVAR(
Town, supplied[CT_MAIL].old_act, SLE_FILE_U16 | SLE_VAR_U32, 0, 8),
151 SLE_CONDVAR(
Town, supplied[CT_PASSENGERS].new_act, SLE_FILE_U16 | SLE_VAR_U32, 0, 8),
152 SLE_CONDVAR(
Town, supplied[CT_MAIL].new_act, SLE_FILE_U16 | SLE_VAR_U32, 0, 8),
154 SLE_CONDVAR(
Town, supplied[CT_PASSENGERS].old_max, SLE_UINT32, 9, 164),
156 SLE_CONDVAR(
Town, supplied[CT_PASSENGERS].new_max, SLE_UINT32, 9, 164),
158 SLE_CONDVAR(
Town, supplied[CT_PASSENGERS].old_act, SLE_UINT32, 9, 164),
160 SLE_CONDVAR(
Town, supplied[CT_PASSENGERS].new_act, SLE_UINT32, 9, 164),
174 SLE_CONDVAR(
Town, time_until_rebuild, SLE_FILE_U8 | SLE_VAR_U16, 0, 53),
203 static const SaveLoad _town_supplied_desc[] = {
212 static const SaveLoad _town_received_desc[] = {
221 static void Save_HIDS()
226 static void Load_HIDS()
234 static const SaveLoad _tilematrix_desc[] = {
241 return _tilematrix_desc;
244 static void RealSave_Town(
Town *t)
251 for (
int i = TE_BEGIN; i <
NUM_TE; i++) {
264 static void Save_TOWN()
269 SlSetArrayIndex(t->
index);
274 static void Load_TOWN()
285 for (
int i = TE_BEGIN; i <
TE_END; i++) {
289 if (t->townnamegrfid == 0 && !
IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1) &&
GetStringTab(t->townnametype) != TEXT_TAB_OLD_CUSTOM) {
321 {
'HIDS', Save_HIDS, Load_HIDS, NULL, NULL, CH_ARRAY },
#define SLE_CONDNULL(length, from, to)
Empty space in some savegame versions.
TileIndexDiff GetHouseNorthPart(HouseID &house)
Determines if a given HouseID is part of a multitile house.
AcceptanceMatrix cargo_accepted
Bitmap of cargoes accepted by houses for each 4*4 map square of the town.
static void Ptrs_TOWN()
Fix pointers when loading town data.
TransportedCargoStat< uint16 > received[NUM_TE]
Cargo statistics about received cargotypes.
void UpdateTownCargoes(Town *t)
Update cargo acceptance for the complete town.
Code handling saving and loading of NewGRF mappings.
void UpdateTownCargoTotal(Town *t)
Update the total cargo acceptance of the whole town.
#define SLE_CONDSTR(base, variable, type, length, from, to)
Storage of a string in some savegame versions.
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
void RebuildTownCaches()
Rebuild all the cached variables of towns.
static const SaveLoad _town_desc[]
Save and load of towns.
void UpdateHousesAndTowns()
Check and update town and house values.
Tindex index
Index of this pool item.
const ChunkHandler _town_chunk_handlers[]
Chunk handler for towns.
Cargo behaves water-like.
static StringTab GetStringTab(StringID str)
Extract the StringTab from a StringID.
uint16 HouseID
OpenTTD ID of house types.
uint32 population
Current population of people.
uint16 w
The width of the area.
#define SLE_CONDLST(base, variable, type, from, to)
Storage of a list in some savegame versions.
void UpdateTownCargoBitmap()
Updates the bitmap of all cargoes accepted by houses.
static void SetHouseType(TileIndex t, HouseID house_id)
Set the house type.
byte population
population (Zero on other tiles in multi tile house.)
void SlArray(void *array, size_t length, VarType conv)
Save/Load an array.
static bool IsHouseCompleted(TileIndex t)
Get the completion of this house.
T * data
Pointer to data array.
Functions/types related to saving and loading games.
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a give tiletype.
static HouseID GetCleanHouseType(TileIndex t)
Get the type of this house, which is an index into the house spec array without doing any NewGRF rela...
allow control codes in the strings
#define SL_MAX_VERSION
Highest possible savegame version.
static bool IsSavegameVersionBefore(uint16 major, byte minor=0)
Checks whether the savegame is below major.
BuildingFlags building_flags
some flags that describe the house (size, stadium etc...)
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Maximum number of companies.
Handlers and description of chunk.
TileArea area
Area covered by the matrix.
Maximal number of cargo types in a game.
void Load_NewGRFMapping(OverrideManagerBase &mapping)
Load a GRF ID + local id -> OpenTTD's id mapping.
#define SLE_END()
End marker of a struct/class save or load.
static uint MapSize()
Get the size of the map.
#define SLE_CONDARR(base, variable, type, length, from, to)
Storage of an array in some savegame versions.
uint32 TileIndex
The index/ID of a Tile.
static HouseID GetHouseType(TileIndex t)
Get the type of this house, which is an index into the house spec array.
void SlObject(void *object, const SaveLoad *sld)
Main SaveLoad function.
TownCache cache
Container for all cacheable data.
static const HouseID NEW_HOUSE_OFFSET
Offset for new houses.
void SlAutolength(AutolengthProc *proc, void *arg)
Do something of which I have no idea what it is :P.
Cargo behaves food/fizzy-drinks-like.
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
TransportedCargoStat< uint32 > supplied[NUM_CARGO]
Cargo statistics about supplied cargo.
byte CargoID
Cargo slots to indicate a cargo type within a game.
void IncreaseBuildingCount(Town *t, HouseID house_id)
IncreaseBuildingCount() Increase the count of a building when it has been added by a town...
uint32 num_houses
Amount of houses.
void Save_NewGRFMapping(const OverrideManagerBase &mapping)
Save a GRF ID + local id -> OpenTTD's id mapping.
uint16 h
The height of the area.
Last chunk in this array.
uint16 GetSubstituteID(uint16 entity_id) const
Gives the substitute of the entity, as specified by the grf file.
Load/save a reference to a persistent storage.