OpenTTD Source: src/saveload/town_sl.cpp Source File

OpenTTD Source 12.0-beta1

town_sl.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
7
10 #include "../stdafx.h"
11
12 #include "saveload.h"
13 #include "compat/town_sl_compat.h"
14
15 #include "newgrf_sl.h"
16 #include "../newgrf_house.h"
17 #include "../town.h"
18 #include "../landscape.h"
19 #include "../subsidy_func.h"
20 #include "../strings_func.h"
21 #include "../tilematrix_type.hpp"
22
23 #include "../safeguards.h"
24
25 typedef TileMatrix<CargoTypes, 4> AcceptanceMatrix;
26
30 void RebuildTownCaches()
31 {
32 InitializeBuildingCounts();
33 RebuildTownKdtree();
34
35 /* Reset town population and num_houses */
36 for (Town *town : Town::Iterate()) {
37 town->cache.population = 0;
38 town->cache.num_houses = 0;
39 }
40
41 for (TileIndex t = 0; t < MapSize(); t++) {
42 if (!IsTileType(t, MP_HOUSE)) continue;
43
44 HouseID house_id = GetHouseType(t);
45 Town *town = Town::GetByTile(t);
46 IncreaseBuildingCount(town, house_id);
47 if (IsHouseCompleted(t)) town->cache.population += HouseSpec::Get(house_id)->population;
48
49 /* Increase the number of houses for every house, but only once. */
50 if (GetHouseNorthPart(house_id) == 0) town->cache.num_houses++;
51 }
52
53 /* Update the population and num_house dependent values */
54 for (Town *town : Town::Iterate()) {
55 UpdateTownRadius(town);
56 }
57 }
58
67 void UpdateHousesAndTowns()
68 {
69 for (TileIndex t = 0; t < MapSize(); t++) {
70 if (!IsTileType(t, MP_HOUSE)) continue;
71
72 HouseID house_id = GetCleanHouseType(t);
73 if (!HouseSpec::Get(house_id)->enabled && house_id >= NEW_HOUSE_OFFSET) {
74 /* The specs for this type of house are not available any more, so
75 * replace it with the substitute original house type. */
76 house_id = _house_mngr.GetSubstituteID(house_id);
77 SetHouseType(t, house_id);
78 }
79 }
80
81 /* Check for cases when a NewGRF has set a wrong house substitute type. */
82 for (TileIndex t = 0; t < MapSize(); t++) {
83 if (!IsTileType(t, MP_HOUSE)) continue;
84
85 HouseID house_type = GetCleanHouseType(t);
86 TileIndex north_tile = t + GetHouseNorthPart(house_type); // modifies 'house_type'!
87 if (t == north_tile) {
88 const HouseSpec *hs = HouseSpec::Get(house_type);
89 bool valid_house = true;
90 if (hs->building_flags & TILE_SIZE_2x1) {
91 TileIndex tile = t + TileDiffXY(1, 0);
92 if (!IsTileType(tile, MP_HOUSE) || GetCleanHouseType(tile) != house_type + 1) valid_house = false;
93 } else if (hs->building_flags & TILE_SIZE_1x2) {
94 TileIndex tile = t + TileDiffXY(0, 1);
95 if (!IsTileType(tile, MP_HOUSE) || GetCleanHouseType(tile) != house_type + 1) valid_house = false;
96 } else if (hs->building_flags & TILE_SIZE_2x2) {
97 TileIndex tile = t + TileDiffXY(0, 1);
98 if (!IsTileType(tile, MP_HOUSE) || GetCleanHouseType(tile) != house_type + 1) valid_house = false;
99 tile = t + TileDiffXY(1, 0);
100 if (!IsTileType(tile, MP_HOUSE) || GetCleanHouseType(tile) != house_type + 2) valid_house = false;
101 tile = t + TileDiffXY(1, 1);
102 if (!IsTileType(tile, MP_HOUSE) || GetCleanHouseType(tile) != house_type + 3) valid_house = false;
103 }
104 /* If not all tiles of this house are present remove the house.
105 * The other tiles will get removed later in this loop because
106 * their north tile is not the correct type anymore. */
107 if (!valid_house) DoClearSquare(t);
108 } else if (!IsTileType(north_tile, MP_HOUSE) || GetCleanHouseType(north_tile) != house_type) {
109 /* This tile should be part of a multi-tile building but the
110 * north tile of this house isn't on the map. */
111 DoClearSquare(t);
112 }
113 }
114
115 RebuildTownCaches();
116 }
117
118 class SlTownSupplied : public DefaultSaveLoadHandler<SlTownSupplied, Town> {
119 public:
120 inline static const SaveLoad description[] = {
121 SLE_CONDVAR(TransportedCargoStat<uint32>, old_max, SLE_UINT32, SLV_165, SL_MAX_VERSION),
122 SLE_CONDVAR(TransportedCargoStat<uint32>, new_max, SLE_UINT32, SLV_165, SL_MAX_VERSION),
123 SLE_CONDVAR(TransportedCargoStat<uint32>, old_act, SLE_UINT32, SLV_165, SL_MAX_VERSION),
124 SLE_CONDVAR(TransportedCargoStat<uint32>, new_act, SLE_UINT32, SLV_165, SL_MAX_VERSION),
125 };
126 inline const static SaveLoadCompatTable compat_description = _town_supplied_sl_compat;
127
132 size_t GetNumCargo() const
133 {
134 if (IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES)) return 32;
135 if (IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH)) return NUM_CARGO;
136 /* Read from the savegame how long the list is. */
137 return SlGetStructListLength(NUM_CARGO);
138 }
139
140 void Save(Town *t) const override
141 {
142 SlSetStructListLength(NUM_CARGO);
143 for (CargoID i = 0; i < NUM_CARGO; i++) {
144 SlObject(&t->supplied[i], this->GetDescription());
145 }
146 }
147
148 void Load(Town *t) const override
149 {
150 size_t num_cargo = this->GetNumCargo();
151 for (CargoID i = 0; i < num_cargo; i++) {
152 SlObject(&t->supplied[i], this->GetLoadDescription());
153 }
154 }
155 };
156
157 class SlTownReceived : public DefaultSaveLoadHandler<SlTownReceived, Town> {
158 public:
159 inline static const SaveLoad description[] = {
160 SLE_CONDVAR(TransportedCargoStat<uint16>, old_max, SLE_UINT16, SLV_165, SL_MAX_VERSION),
161 SLE_CONDVAR(TransportedCargoStat<uint16>, new_max, SLE_UINT16, SLV_165, SL_MAX_VERSION),
162 SLE_CONDVAR(TransportedCargoStat<uint16>, old_act, SLE_UINT16, SLV_165, SL_MAX_VERSION),
163 SLE_CONDVAR(TransportedCargoStat<uint16>, new_act, SLE_UINT16, SLV_165, SL_MAX_VERSION),
164 };
165 inline const static SaveLoadCompatTable compat_description = _town_received_sl_compat;
166
167 void Save(Town *t) const override
168 {
169 SlSetStructListLength(NUM_TE);
170 for (size_t i = TE_BEGIN; i < TE_END; i++) {
171 SlObject(&t->received[i], this->GetDescription());
172 }
173 }
174
175 void Load(Town *t) const override
176 {
177 size_t length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? (size_t)TE_END : SlGetStructListLength(TE_END);
178 for (size_t i = 0; i < length; i++) {
179 SlObject(&t->received[i], this->GetLoadDescription());
180 }
181 }
182 };
183
184 class SlTownAcceptanceMatrix : public DefaultSaveLoadHandler<SlTownAcceptanceMatrix, Town> {
185 public:
186 inline static const SaveLoad description[] = {
187 SLE_VAR(AcceptanceMatrix, area.tile, SLE_UINT32),
188 SLE_VAR(AcceptanceMatrix, area.w, SLE_UINT16),
189 SLE_VAR(AcceptanceMatrix, area.h, SLE_UINT16),
190 };
191 inline const static SaveLoadCompatTable compat_description = _town_acceptance_matrix_sl_compat;
192
193 void Load(Town *t) const override
194 {
195 /* Discard now unused acceptance matrix. */
196 AcceptanceMatrix dummy;
197 SlObject(&dummy, this->GetLoadDescription());
198 if (dummy.area.w != 0) {
199 uint arr_len = dummy.area.w / AcceptanceMatrix::GRID * dummy.area.h / AcceptanceMatrix::GRID;
200 SlSkipBytes(4 * arr_len);
201 }
202 }
203 };
204
205 static const SaveLoad _town_desc[] = {
206 SLE_CONDVAR(Town, xy, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
207 SLE_CONDVAR(Town, xy, SLE_UINT32, SLV_6, SL_MAX_VERSION),
208
209 SLE_CONDVAR(Town, townnamegrfid, SLE_UINT32, SLV_66, SL_MAX_VERSION),
210 SLE_VAR(Town, townnametype, SLE_UINT16),
211 SLE_VAR(Town, townnameparts, SLE_UINT32),
212 SLE_CONDSSTR(Town, name, SLE_STR | SLF_ALLOW_CONTROL, SLV_84, SL_MAX_VERSION),
213
214 SLE_VAR(Town, flags, SLE_UINT8),
215 SLE_CONDVAR(Town, statues, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_104),
216 SLE_CONDVAR(Town, statues, SLE_UINT16, SLV_104, SL_MAX_VERSION),
217
218 SLE_CONDVAR(Town, have_ratings, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_104),
219 SLE_CONDVAR(Town, have_ratings, SLE_UINT16, SLV_104, SL_MAX_VERSION),
220 SLE_CONDARR(Town, ratings, SLE_INT16, 8, SL_MIN_VERSION, SLV_104),
221 SLE_CONDARR(Town, ratings, SLE_INT16, MAX_COMPANIES, SLV_104, SL_MAX_VERSION),
222 SLE_CONDARR(Town, unwanted, SLE_INT8, 8, SLV_4, SLV_104),
223 SLE_CONDARR(Town, unwanted, SLE_INT8, MAX_COMPANIES, SLV_104, SL_MAX_VERSION),
224
225 SLE_CONDVAR(Town, supplied[CT_PASSENGERS].old_max, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
226 SLE_CONDVAR(Town, supplied[CT_PASSENGERS].old_max, SLE_UINT32, SLV_9, SLV_165),
227 SLE_CONDVAR(Town, supplied[CT_MAIL].old_max, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
228 SLE_CONDVAR(Town, supplied[CT_MAIL].old_max, SLE_UINT32, SLV_9, SLV_165),
229 SLE_CONDVAR(Town, supplied[CT_PASSENGERS].new_max, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
230 SLE_CONDVAR(Town, supplied[CT_PASSENGERS].new_max, SLE_UINT32, SLV_9, SLV_165),
231 SLE_CONDVAR(Town, supplied[CT_MAIL].new_max, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
232 SLE_CONDVAR(Town, supplied[CT_MAIL].new_max, SLE_UINT32, SLV_9, SLV_165),
233 SLE_CONDVAR(Town, supplied[CT_PASSENGERS].old_act, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
234 SLE_CONDVAR(Town, supplied[CT_PASSENGERS].old_act, SLE_UINT32, SLV_9, SLV_165),
235 SLE_CONDVAR(Town, supplied[CT_MAIL].old_act, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
236 SLE_CONDVAR(Town, supplied[CT_MAIL].old_act, SLE_UINT32, SLV_9, SLV_165),
237 SLE_CONDVAR(Town, supplied[CT_PASSENGERS].new_act, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
238 SLE_CONDVAR(Town, supplied[CT_PASSENGERS].new_act, SLE_UINT32, SLV_9, SLV_165),
239 SLE_CONDVAR(Town, supplied[CT_MAIL].new_act, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
240 SLE_CONDVAR(Town, supplied[CT_MAIL].new_act, SLE_UINT32, SLV_9, SLV_165),
241
242 SLE_CONDVAR(Town, received[TE_FOOD].old_act, SLE_UINT16, SL_MIN_VERSION, SLV_165),
243 SLE_CONDVAR(Town, received[TE_WATER].old_act, SLE_UINT16, SL_MIN_VERSION, SLV_165),
244 SLE_CONDVAR(Town, received[TE_FOOD].new_act, SLE_UINT16, SL_MIN_VERSION, SLV_165),
245 SLE_CONDVAR(Town, received[TE_WATER].new_act, SLE_UINT16, SL_MIN_VERSION, SLV_165),
246
247 SLE_CONDARR(Town, goal, SLE_UINT32, NUM_TE, SLV_165, SL_MAX_VERSION),
248
249 SLE_CONDSSTR(Town, text, SLE_STR | SLF_ALLOW_CONTROL, SLV_168, SL_MAX_VERSION),
250
251 SLE_CONDVAR(Town, time_until_rebuild, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_54),
252 SLE_CONDVAR(Town, time_until_rebuild, SLE_UINT16, SLV_54, SL_MAX_VERSION),
253 SLE_CONDVAR(Town, grow_counter, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_54),
254 SLE_CONDVAR(Town, grow_counter, SLE_UINT16, SLV_54, SL_MAX_VERSION),
255 SLE_CONDVAR(Town, growth_rate, SLE_FILE_U8 | SLE_VAR_I16, SL_MIN_VERSION, SLV_54),
256 SLE_CONDVAR(Town, growth_rate, SLE_FILE_I16 | SLE_VAR_U16, SLV_54, SLV_165),
257 SLE_CONDVAR(Town, growth_rate, SLE_UINT16, SLV_165, SL_MAX_VERSION),
258
259 SLE_VAR(Town, fund_buildings_months, SLE_UINT8),
260 SLE_VAR(Town, road_build_months, SLE_UINT8),
261
262 SLE_CONDVAR(Town, exclusivity, SLE_UINT8, SLV_2, SL_MAX_VERSION),
263 SLE_CONDVAR(Town, exclusive_counter, SLE_UINT8, SLV_2, SL_MAX_VERSION),
264
265 SLE_CONDVAR(Town, larger_town, SLE_BOOL, SLV_56, SL_MAX_VERSION),
266 SLE_CONDVAR(Town, layout, SLE_UINT8, SLV_113, SL_MAX_VERSION),
267
268 SLE_CONDREFLIST(Town, psa_list, REF_STORAGE, SLV_161, SL_MAX_VERSION),
269
270 SLEG_CONDSTRUCTLIST("supplied", SlTownSupplied, SLV_165, SL_MAX_VERSION),
271 SLEG_CONDSTRUCTLIST("received", SlTownReceived, SLV_165, SL_MAX_VERSION),
272 SLEG_CONDSTRUCTLIST("acceptance_matrix", SlTownAcceptanceMatrix, SLV_166, SLV_REMOVE_TOWN_CARGO_CACHE),
273 };
274
275 struct HIDSChunkHandler : NewGRFMappingChunkHandler {
276 HIDSChunkHandler() : NewGRFMappingChunkHandler('HIDS', _house_mngr) {}
277 };
278
279 struct CITYChunkHandler : ChunkHandler {
280 CITYChunkHandler() : ChunkHandler('CITY', CH_TABLE) {}
281
282 void Save() const override
283 {
284 SlTableHeader(_town_desc);
285
286 for (Town *t : Town::Iterate()) {
287 SlSetArrayIndex(t->index);
288 SlObject(t, _town_desc);
289 }
290 }
291
292 void Load() const override
293 {
294 const std::vector<SaveLoad> slt = SlCompatTableHeader(_town_desc, _town_sl_compat);
295
296 int index;
297
298 while ((index = SlIterateArray()) != -1) {
299 Town *t = new (index) Town();
300 SlObject(t, slt);
301
302 if (t->townnamegrfid == 0 && !IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1) && GetStringTab(t->townnametype) != TEXT_TAB_OLD_CUSTOM) {
303 SlErrorCorrupt("Invalid town name generator");
304 }
305 }
306 }
307
308 void FixPointers() const override
309 {
310 if (IsSavegameVersionBefore(SLV_161)) return;
311
312 for (Town *t : Town::Iterate()) {
313 SlObject(t, _town_desc);
314 }
315 }
316 };
317
318 static const HIDSChunkHandler HIDS;
319 static const CITYChunkHandler CITY;
320 static const ChunkHandlerRef town_chunk_handlers[] = {
321 HIDS,
322 CITY,
323 };
324
325 extern const ChunkHandlerTable _town_chunk_handlers(town_chunk_handlers);
SlTownSupplied::GetNumCargo
size_t GetNumCargo() const
Get the number of cargoes used by this savegame version.
Definition: town_sl.cpp:132
TE_WATER
@ TE_WATER
Cargo behaves water-like.
Definition: cargotype.h:32
SLEG_CONDSTRUCTLIST
#define SLEG_CONDSTRUCTLIST(name, handler, from, to)
Storage of a list of structs in some savegame versions.
Definition: saveload.h:928
MP_HOUSE
@ MP_HOUSE
A house by a town.
Definition: tile_type.h:49
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
GetStringTab
static StringTab GetStringTab(StringID str)
Extract the StringTab from a StringID.
Definition: strings_func.h:23
DefaultSaveLoadHandler
Default handler for saving/loading an object to/from disk.
Definition: saveload.h:514
NewGRFMappingChunkHandler
Definition: newgrf_sl.h:15
SL_MIN_VERSION
@ SL_MIN_VERSION
First savegame version.
Definition: saveload.h:35
SLE_CONDSSTR
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
Definition: saveload.h:743
ChunkHandlerRef
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
Definition: saveload.h:442
IsHouseCompleted
static bool IsHouseCompleted(TileIndex t)
Get the completion of this house.
Definition: town_map.h:145
SLE_CONDARR
#define SLE_CONDARR(base, variable, type, length, from, to)
Storage of a fixed-size array of SL_VAR elements in some savegame versions.
Definition: saveload.h:722
TE_FOOD
@ TE_FOOD
Cargo behaves food/fizzy-drinks-like.
Definition: cargotype.h:33
UpdateHousesAndTowns
void UpdateHousesAndTowns()
Check and update town and house values.
Definition: town_sl.cpp:67
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
SLV_166
@ SLV_166
166 23415
Definition: saveload.h:246
SLE_CONDVAR
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition: saveload.h:701
GetHouseNorthPart
TileIndexDiff GetHouseNorthPart(HouseID &house)
Determines if a given HouseID is part of a multitile house.
Definition: town_cmd.cpp:2681
SLV_56
@ SLV_56
56 9667
Definition: saveload.h:114
SLV_84
@ SLV_84
84 11822
Definition: saveload.h:147
TileMatrix
A simple matrix that stores one value per N*N square of the map.
Definition: tilematrix_type.hpp:27
SLE_STR
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
Definition: saveload.h:797
SLV_66
@ SLV_66
66 10211
Definition: saveload.h:126
SaveLoadHandler::GetLoadDescription
SaveLoadTable GetLoadDescription() const
Get the description for how to load the chunk.
Definition: saveload.cpp:3436
saveload.h
CITYChunkHandler::Save
void Save() const override
Save the chunk.
Definition: town_sl.cpp:282
SLV_104
@ SLV_104
104 14735
Definition: saveload.h:171
SLV_113
@ SLV_113
113 15340
Definition: saveload.h:182
ChunkHandler
Handlers and description of chunk.
Definition: saveload.h:405
CITYChunkHandler
Definition: town_sl.cpp:279
TileMatrix::area
TileArea area
Area covered by the matrix.
Definition: tilematrix_type.hpp:66
_town_acceptance_matrix_sl_compat
const SaveLoadCompat _town_acceptance_matrix_sl_compat[]
Original field order for SlTownAcceptanceMatrix.
Definition: town_sl_compat.h:32
IsInsideMM
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
Definition: math_func.hpp:204
RebuildTownCaches
void RebuildTownCaches()
Rebuild all the cached variables of towns.
Definition: town_sl.cpp:30
GetHouseType
static HouseID GetHouseType(TileIndex t)
Get the type of this house, which is an index into the house spec array.
Definition: town_map.h:59
TownCache::population
uint32 population
Current population of people.
Definition: town.h:42
SLV_161
@ SLV_161
161 22567
Definition: saveload.h:240
SLF_ALLOW_CONTROL
@ SLF_ALLOW_CONTROL
Allow control codes in the strings.
Definition: saveload.h:624
MapSize
static uint MapSize()
Get the size of the map.
Definition: map_func.h:92
span
A trimmed down version of what std::span will be in C++20.
Definition: span_type.hpp:60
NEW_HOUSE_OFFSET
static const HouseID NEW_HOUSE_OFFSET
Offset for new houses.
Definition: house.h:28
NUM_TE
@ NUM_TE
Amount of town effects.
Definition: cargotype.h:35
SLV_REMOVE_TOWN_CARGO_CACHE
@ SLV_REMOVE_TOWN_CARGO_CACHE
219 PR#8258 Remove town cargo acceptance and production caches.
Definition: saveload.h:310
HouseSpec::building_flags
BuildingFlags building_flags
some flags that describe the house (size, stadium etc...)
Definition: house.h:109
TE_END
@ TE_END
End of town effects.
Definition: cargotype.h:34
OrthogonalTileArea::w
uint16 w
The width of the area.
Definition: tilearea_type.h:20
SLV_54
@ SLV_54
54 9613
Definition: saveload.h:111
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
SLV_EXTEND_CARGOTYPES
@ SLV_EXTEND_CARGOTYPES
199 PR#6802 Extend cargotypes to 64
Definition: saveload.h:286
REF_STORAGE
@ REF_STORAGE
Load/save a reference to a persistent storage.
Definition: saveload.h:543
SLV_168
@ SLV_168
168 23637
Definition: saveload.h:248
IsSavegameVersionBefore
static bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
Definition: saveload.h:1023
SlTownAcceptanceMatrix
Definition: town_sl.cpp:184
_town_supplied_sl_compat
const SaveLoadCompat _town_supplied_sl_compat[]
Original field order for SlTownSupplied.
Definition: town_sl_compat.h:16
CITYChunkHandler::Load
void Load() const override
Load the chunk.
Definition: town_sl.cpp:292
CITYChunkHandler::FixPointers
void FixPointers() const override
Fix the pointers.
Definition: town_sl.cpp:308
HouseSpec::population
byte population
population (Zero on other tiles in multi tile house.)
Definition: house.h:102
IsTileType
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
SlGetStructListLength
size_t SlGetStructListLength(size_t limit)
Get the length of this list; if it exceeds the limit, error out.
Definition: saveload.cpp:1825
SLV_2
@ SLV_2
2.0 0.3.0 2.1 0.3.1, 0.3.2
Definition: saveload.h:38
_town_sl_compat
const SaveLoadCompat _town_sl_compat[]
Original field order for town_desc.
Definition: town_sl_compat.h:39
OrthogonalTileArea::h
uint16 h
The height of the area.
Definition: tilearea_type.h:21
SL_MAX_VERSION
@ SL_MAX_VERSION
Highest possible saveload version.
Definition: saveload.h:341
HouseID
uint16 HouseID
OpenTTD ID of house types.
Definition: house_type.h:13
SLE_VAR
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Definition: saveload.h:771
Pool::PoolItem<&_town_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:386
_town_received_sl_compat
const SaveLoadCompat _town_received_sl_compat[]
Original field order for SlTownReceived.
Definition: town_sl_compat.h:24
SLV_6
@ SLV_6
6.0 1721 6.1 1768
Definition: saveload.h:50
SlErrorCorrupt
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
Definition: saveload.cpp:364
IncreaseBuildingCount
void IncreaseBuildingCount(Town *t, HouseID house_id)
IncreaseBuildingCount() Increase the count of a building when it has been added by a town.
Definition: newgrf_house.cpp:107
OverrideManagerBase::GetSubstituteID
uint16 GetSubstituteID(uint16 entity_id) const
Gives the substitute of the entity, as specified by the grf file.
Definition: newgrf_commons.cpp:166
HIDSChunkHandler
Definition: town_sl.cpp:275
TileDiffXY
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition: map_func.h:179
NUM_CARGO
@ NUM_CARGO
Maximal number of cargo types in a game.
Definition: cargo_type.h:65
Town::cache
TownCache cache
Container for all cacheable data.
Definition: town.h:53
SLV_165
@ SLV_165
165 23304
Definition: saveload.h:245
SLE_CONDREFLIST
#define SLE_CONDREFLIST(base, variable, type, from, to)
Storage of a list of SL_REF elements in some savegame versions.
Definition: saveload.h:753
town_sl_compat.h
Town
Town data structure.
Definition: town.h:50
GetCleanHouseType
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...
Definition: town_map.h:47
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
SLV_SAVELOAD_LIST_LENGTH
@ SLV_SAVELOAD_LIST_LENGTH
293 PR#9374 Consistency in list length with SL_STRUCT / SL_STRUCTLIST / SL_DEQUE / SL_REFLIST.
Definition: saveload.h:335
HouseSpec
Definition: house.h:98
TownCache::num_houses
uint32 num_houses
Amount of houses.
Definition: town.h:41
SlCompatTableHeader
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
Definition: saveload.cpp:2029
SlObject
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
Definition: saveload.cpp:1838
SlTableHeader
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
Definition: saveload.cpp:1891
SlSetStructListLength
void SlSetStructListLength(size_t length)
Set the length of this list.
Definition: saveload.cpp:1809
SLV_4
@ 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
Definition: saveload.h:41
SaveLoad
SaveLoad type struct.
Definition: saveload.h:652
newgrf_sl.h
SetHouseType
static void SetHouseType(TileIndex t, HouseID house_id)
Set the house type.
Definition: town_map.h:70
Town::supplied
TransportedCargoStat< uint32 > supplied[NUM_CARGO]
Cargo statistics about supplied cargo.
Definition: town.h:75
SLV_9
@ SLV_9
9.0 1909
Definition: saveload.h:54
SlTownReceived
Definition: town_sl.cpp:157
SlSkipBytes
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...
Definition: saveload.h:1140
SlIterateArray
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Definition: saveload.cpp:670
SlTownSupplied
Definition: town_sl.cpp:118
TransportedCargoStat< uint32 >
Town::received
TransportedCargoStat< uint16 > received[NUM_TE]
Cargo statistics about received cargotypes.
Definition: town.h:76