OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
16 #include "../newgrf_house.h"
18 #include "../landscape.h"
19 #include "../subsidy_func.h"
20 #include "../strings_func.h"
21 #include "../tilematrix_type.hpp"
23 #include "../safeguards.h"
32 InitializeBuildingCounts();
37 town->cache.population = 0;
38 town->cache.num_houses = 0;
45 Town *town = Town::GetByTile(t);
55 UpdateTownRadius(town);
87 if (t == north_tile) {
88 const HouseSpec *hs = HouseSpec::Get(house_type);
89 bool valid_house =
true;
107 if (!valid_house) DoClearSquare(t);
120 inline static const SaveLoad description[] = {
140 void Save(
Town *t)
const override
148 void Load(
Town *t)
const override
151 for (
CargoID i = 0; i < num_cargo; i++) {
159 inline static const SaveLoad description[] = {
167 void Save(
Town *t)
const override
170 for (
size_t i = TE_BEGIN; i <
TE_END; i++) {
175 void Load(
Town *t)
const override
178 for (
size_t i = 0; i < length; i++) {
186 inline static const SaveLoad description[] = {
193 void Load(
Town *t)
const override
198 if (dummy.
area.
w != 0) {
199 uint arr_len = dummy.
area.
w / AcceptanceMatrix::GRID * dummy.
area.
h / AcceptanceMatrix::GRID;
205 static const SaveLoad _town_desc[] = {
287 SlSetArrayIndex(t->
index);
302 if (t->townnamegrfid == 0 && !
IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1) &&
GetStringTab(t->townnametype) != TEXT_TAB_OLD_CUSTOM) {
size_t GetNumCargo() const
Get the number of cargoes used by this savegame version.
@ TE_WATER
Cargo behaves water-like.
#define SLEG_CONDSTRUCTLIST(name, handler, from, to)
Storage of a list of structs in some savegame versions.
@ MP_HOUSE
A house by a town.
uint32 TileIndex
The index/ID of a Tile.
static StringTab GetStringTab(StringID str)
Extract the StringTab from a StringID.
Default handler for saving/loading an object to/from disk.
@ SL_MIN_VERSION
First savegame version.
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
static bool IsHouseCompleted(TileIndex t)
Get the completion of this house.
#define SLE_CONDARR(base, variable, type, length, from, to)
Storage of a fixed-size array of SL_VAR elements in some savegame versions.
@ TE_FOOD
Cargo behaves food/fizzy-drinks-like.
void UpdateHousesAndTowns()
Check and update town and house values.
Tindex index
Index of this pool item.
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
TileIndexDiff GetHouseNorthPart(HouseID &house)
Determines if a given HouseID is part of a multitile house.
A simple matrix that stores one value per N*N square of the map.
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
SaveLoadTable GetLoadDescription() const
Get the description for how to load the chunk.
void Save() const override
Save the chunk.
Handlers and description of chunk.
TileArea area
Area covered by the matrix.
const SaveLoadCompat _town_acceptance_matrix_sl_compat[]
Original field order for SlTownAcceptanceMatrix.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
void RebuildTownCaches()
Rebuild all the cached variables of towns.
static HouseID GetHouseType(TileIndex t)
Get the type of this house, which is an index into the house spec array.
uint32 population
Current population of people.
@ SLF_ALLOW_CONTROL
Allow control codes in the strings.
static uint MapSize()
Get the size of the map.
A trimmed down version of what std::span will be in C++20.
static const HouseID NEW_HOUSE_OFFSET
Offset for new houses.
@ NUM_TE
Amount of town effects.
@ SLV_REMOVE_TOWN_CARGO_CACHE
219 PR#8258 Remove town cargo acceptance and production caches.
BuildingFlags building_flags
some flags that describe the house (size, stadium etc...)
@ TE_END
End of town effects.
uint16 w
The width of the area.
@ MAX_COMPANIES
Maximum number of companies.
@ SLV_EXTEND_CARGOTYPES
199 PR#6802 Extend cargotypes to 64
@ REF_STORAGE
Load/save a reference to a persistent storage.
static bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
const SaveLoadCompat _town_supplied_sl_compat[]
Original field order for SlTownSupplied.
void Load() const override
Load the chunk.
void FixPointers() const override
Fix the pointers.
byte population
population (Zero on other tiles in multi tile house.)
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
size_t SlGetStructListLength(size_t limit)
Get the length of this list; if it exceeds the limit, error out.
@ SLV_2
2.0 0.3.0 2.1 0.3.1, 0.3.2
const SaveLoadCompat _town_sl_compat[]
Original field order for town_desc.
uint16 h
The height of the area.
@ SL_MAX_VERSION
Highest possible saveload version.
uint16 HouseID
OpenTTD ID of house types.
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
const SaveLoadCompat _town_received_sl_compat[]
Original field order for SlTownReceived.
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
void IncreaseBuildingCount(Town *t, HouseID house_id)
IncreaseBuildingCount() Increase the count of a building when it has been added by a town.
uint16 GetSubstituteID(uint16 entity_id) const
Gives the substitute of the entity, as specified by the grf file.
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
@ NUM_CARGO
Maximal number of cargo types in a game.
TownCache cache
Container for all cacheable data.
#define SLE_CONDREFLIST(base, variable, type, from, to)
Storage of a list of SL_REF elements in some savegame versions.
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...
byte CargoID
Cargo slots to indicate a cargo type within a game.
@ SLV_SAVELOAD_LIST_LENGTH
293 PR#9374 Consistency in list length with SL_STRUCT / SL_STRUCTLIST / SL_DEQUE / SL_REFLIST.
uint32 num_houses
Amount of houses.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
void SlSetStructListLength(size_t length)
Set the length of this list.
@ SLV_4
4.0 1 4.1 122 0.3.3, 0.3.4 4.2 1222 0.3.5 4.3 1417 4.4 1426
static void SetHouseType(TileIndex t, HouseID house_id)
Set the house type.
TransportedCargoStat< uint32 > supplied[NUM_CARGO]
Cargo statistics about supplied cargo.
static void SlSkipBytes(size_t length)
Read in bytes from the file/data structure but don't do anything with them, discarding them in effect...
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
TransportedCargoStat< uint16 > received[NUM_TE]
Cargo statistics about received cargotypes.