Files
@ r28036:ac5b608a034a
Branch filter:
Location: cpp/openttd-patchpack/source/src/saveload/town_sl.cpp - annotation
r28036:ac5b608a034a
13.4 KiB
text/x-c
Update: Translations from eints
czech: 18 changes by vladoschreiner
german: 27 changes by Wuzzy2
czech: 18 changes by vladoschreiner
german: 27 changes by Wuzzy2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r25753:722d782a707d r25753:722d782a707d r25753:722d782a707d r25753:722d782a707d r25753:722d782a707d r10571:99cb9a95b4cf r12239:4ede50b8e95b r15915:c6bb7afcdb7b r19277:88e0224d53d6 r22547:90170a724532 r24301:7ff717a1243f r10571:99cb9a95b4cf r21383:942c32fb8b0e r21383:942c32fb8b0e r24301:7ff717a1243f r24301:7ff717a1243f r10571:99cb9a95b4cf r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r23435:0f8f3f8f40ec r19277:88e0224d53d6 r19277:88e0224d53d6 r23973:490b8210dd15 r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r26787:a51c38e4aac5 r19277:88e0224d53d6 r19277:88e0224d53d6 r19279:d7fabdafbecb r23973:490b8210dd15 r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r19944:25a78576fb5e r23973:490b8210dd15 r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r19277:88e0224d53d6 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r26787:a51c38e4aac5 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r15914:d0a68c65cbc5 r12241:f31db06a63d4 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r15914:d0a68c65cbc5 r10571:99cb9a95b4cf r15914:d0a68c65cbc5 r26787:a51c38e4aac5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15915:c6bb7afcdb7b r15914:d0a68c65cbc5 r15915:c6bb7afcdb7b r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r15914:d0a68c65cbc5 r19277:88e0224d53d6 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r27737:728d55b97775 r27737:728d55b97775 r27737:728d55b97775 r27737:728d55b97775 r25675:dd16e878a118 r25753:722d782a707d r25675:dd16e878a118 r25693:311303f64840 r25693:311303f64840 r25693:311303f64840 r25693:311303f64840 r25693:311303f64840 r25693:311303f64840 r25693:311303f64840 r25693:311303f64840 r25693:311303f64840 r25693:311303f64840 r25693:311303f64840 r25693:311303f64840 r25675:dd16e878a118 r25675:dd16e878a118 r28001:3cbf0e1a68f8 r28001:3cbf0e1a68f8 r28001:3cbf0e1a68f8 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25693:311303f64840 r26722:ffa941789896 r25753:722d782a707d r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r27737:728d55b97775 r27737:728d55b97775 r27737:728d55b97775 r27737:728d55b97775 r25675:dd16e878a118 r25753:722d782a707d r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r28001:3cbf0e1a68f8 r28001:3cbf0e1a68f8 r28001:3cbf0e1a68f8 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25693:311303f64840 r25693:311303f64840 r25753:722d782a707d r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25753:722d782a707d r25675:dd16e878a118 r27942:f7389062d120 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25753:722d782a707d r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r25675:dd16e878a118 r10571:99cb9a95b4cf r23264:b36243874b4a r23264:b36243874b4a r10571:99cb9a95b4cf r23264:b36243874b4a r10571:99cb9a95b4cf r10571:99cb9a95b4cf r24214:a65c412aafcc r10571:99cb9a95b4cf r12208:4a6d754234c5 r23264:b36243874b4a r23264:b36243874b4a r10571:99cb9a95b4cf r23264:b36243874b4a r23264:b36243874b4a r23264:b36243874b4a r23264:b36243874b4a r23264:b36243874b4a r23264:b36243874b4a r10571:99cb9a95b4cf r23264:b36243874b4a r25753:722d782a707d r23264:b36243874b4a r25753:722d782a707d r23264:b36243874b4a r25753:722d782a707d r23264:b36243874b4a r25753:722d782a707d r23264:b36243874b4a r25753:722d782a707d r23264:b36243874b4a r25753:722d782a707d r23264:b36243874b4a r25753:722d782a707d r23264:b36243874b4a r23264:b36243874b4a r10571:99cb9a95b4cf r23264:b36243874b4a r23264:b36243874b4a r23264:b36243874b4a r23264:b36243874b4a r10571:99cb9a95b4cf r23264:b36243874b4a r18446:7b57061bbb9d r24214:a65c412aafcc r18768:3747fd5dec42 r23264:b36243874b4a r25753:722d782a707d r23264:b36243874b4a r25753:722d782a707d r23264:b36243874b4a r23264:b36243874b4a r23264:b36243874b4a r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r23264:b36243874b4a r23264:b36243874b4a r10571:99cb9a95b4cf r23264:b36243874b4a r23264:b36243874b4a r10571:99cb9a95b4cf r25611:85dc1dbf8554 r17773:70894fef31f4 r25751:3154638283de r25751:3154638283de r25751:3154638283de r18444:c1e881f954d6 r18444:c1e881f954d6 r25775:274657b41228 r25775:274657b41228 r25773:457e167f3c9e r25753:722d782a707d r25773:457e167f3c9e r25774:14ee6e7f4ecc r10571:99cb9a95b4cf r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r10571:99cb9a95b4cf r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r18123:6e1679aee681 r10571:99cb9a95b4cf r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r10571:99cb9a95b4cf r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r17773:70894fef31f4 r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r17773:70894fef31f4 r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r17773:70894fef31f4 r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25772:5ba83ce3a853 r25772:5ba83ce3a853 r25772:5ba83ce3a853 r10571:99cb9a95b4cf r25596:7bf7822e5659 r25596:7bf7822e5659 | /*
* This file is part of OpenTTD.
* 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.
* 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.
* 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/>.
*/
/** @file town_sl.cpp Code handling saving and loading of towns and houses */
#include "../stdafx.h"
#include "saveload.h"
#include "compat/town_sl_compat.h"
#include "newgrf_sl.h"
#include "../newgrf_house.h"
#include "../town.h"
#include "../landscape.h"
#include "../subsidy_func.h"
#include "../strings_func.h"
#include "../tilematrix_type.hpp"
#include "../safeguards.h"
typedef TileMatrix<CargoTypes, 4> AcceptanceMatrix;
/**
* Rebuild all the cached variables of towns.
*/
void RebuildTownCaches()
{
InitializeBuildingCounts();
RebuildTownKdtree();
/* Reset town population and num_houses */
for (Town *town : Town::Iterate()) {
town->cache.population = 0;
town->cache.num_houses = 0;
}
for (TileIndex t = 0; t < Map::Size(); t++) {
if (!IsTileType(t, MP_HOUSE)) continue;
HouseID house_id = GetHouseType(t);
Town *town = Town::GetByTile(t);
IncreaseBuildingCount(town, house_id);
if (IsHouseCompleted(t)) town->cache.population += HouseSpec::Get(house_id)->population;
/* Increase the number of houses for every house, but only once. */
if (GetHouseNorthPart(house_id) == 0) town->cache.num_houses++;
}
/* Update the population and num_house dependent values */
for (Town *town : Town::Iterate()) {
UpdateTownRadius(town);
}
}
/**
* Check and update town and house values.
*
* Checked are the HouseIDs. Updated are the
* town population the number of houses per
* town, the town radius and the max passengers
* of the town.
*/
void UpdateHousesAndTowns()
{
for (TileIndex t = 0; t < Map::Size(); t++) {
if (!IsTileType(t, MP_HOUSE)) continue;
HouseID house_id = GetCleanHouseType(t);
if (!HouseSpec::Get(house_id)->enabled && house_id >= NEW_HOUSE_OFFSET) {
/* The specs for this type of house are not available any more, so
* replace it with the substitute original house type. */
house_id = _house_mngr.GetSubstituteID(house_id);
SetHouseType(t, house_id);
}
}
/* Check for cases when a NewGRF has set a wrong house substitute type. */
for (TileIndex t = 0; t < Map::Size(); t++) {
if (!IsTileType(t, MP_HOUSE)) continue;
HouseID house_type = GetCleanHouseType(t);
TileIndex north_tile = t + GetHouseNorthPart(house_type); // modifies 'house_type'!
if (t == north_tile) {
const HouseSpec *hs = HouseSpec::Get(house_type);
bool valid_house = true;
if (hs->building_flags & TILE_SIZE_2x1) {
TileIndex tile = t + TileDiffXY(1, 0);
if (!IsTileType(tile, MP_HOUSE) || GetCleanHouseType(tile) != house_type + 1) valid_house = false;
} else if (hs->building_flags & TILE_SIZE_1x2) {
TileIndex tile = t + TileDiffXY(0, 1);
if (!IsTileType(tile, MP_HOUSE) || GetCleanHouseType(tile) != house_type + 1) valid_house = false;
} else if (hs->building_flags & TILE_SIZE_2x2) {
TileIndex tile = t + TileDiffXY(0, 1);
if (!IsTileType(tile, MP_HOUSE) || GetCleanHouseType(tile) != house_type + 1) valid_house = false;
tile = t + TileDiffXY(1, 0);
if (!IsTileType(tile, MP_HOUSE) || GetCleanHouseType(tile) != house_type + 2) valid_house = false;
tile = t + TileDiffXY(1, 1);
if (!IsTileType(tile, MP_HOUSE) || GetCleanHouseType(tile) != house_type + 3) valid_house = false;
}
/* If not all tiles of this house are present remove the house.
* The other tiles will get removed later in this loop because
* their north tile is not the correct type anymore. */
if (!valid_house) DoClearSquare(t);
} else if (!IsTileType(north_tile, MP_HOUSE) || GetCleanHouseType(north_tile) != house_type) {
/* This tile should be part of a multi-tile building but the
* north tile of this house isn't on the map. */
DoClearSquare(t);
}
}
RebuildTownCaches();
}
class SlTownSupplied : public DefaultSaveLoadHandler<SlTownSupplied, Town> {
public:
inline static const SaveLoad description[] = {
SLE_CONDVAR(TransportedCargoStat<uint32_t>, old_max, SLE_UINT32, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint32_t>, new_max, SLE_UINT32, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint32_t>, old_act, SLE_UINT32, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint32_t>, new_act, SLE_UINT32, SLV_165, SL_MAX_VERSION),
};
inline const static SaveLoadCompatTable compat_description = _town_supplied_sl_compat;
/**
* Get the number of cargoes used by this savegame version.
* @return The number of cargoes used by this savegame version.
*/
size_t GetNumCargo() const
{
if (IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES)) return 32;
if (IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH)) return NUM_CARGO;
/* Read from the savegame how long the list is. */
return SlGetStructListLength(NUM_CARGO);
}
void Save(Town *t) const override
{
SlSetStructListLength(std::size(t->supplied));
for (auto &supplied : t->supplied) {
SlObject(&supplied, this->GetDescription());
}
}
void Load(Town *t) const override
{
size_t num_cargo = this->GetNumCargo();
for (size_t i = 0; i < num_cargo; i++) {
SlObject(&t->supplied[i], this->GetLoadDescription());
}
}
};
class SlTownReceived : public DefaultSaveLoadHandler<SlTownReceived, Town> {
public:
inline static const SaveLoad description[] = {
SLE_CONDVAR(TransportedCargoStat<uint16_t>, old_max, SLE_UINT16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16_t>, new_max, SLE_UINT16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16_t>, old_act, SLE_UINT16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16_t>, new_act, SLE_UINT16, SLV_165, SL_MAX_VERSION),
};
inline const static SaveLoadCompatTable compat_description = _town_received_sl_compat;
void Save(Town *t) const override
{
SlSetStructListLength(std::size(t->received));
for (auto &received : t->received) {
SlObject(&received, this->GetDescription());
}
}
void Load(Town *t) const override
{
size_t length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? (size_t)TE_END : SlGetStructListLength(TE_END);
for (size_t i = 0; i < length; i++) {
SlObject(&t->received[i], this->GetLoadDescription());
}
}
};
class SlTownAcceptanceMatrix : public DefaultSaveLoadHandler<SlTownAcceptanceMatrix, Town> {
public:
inline static const SaveLoad description[] = {
SLE_VAR(AcceptanceMatrix, area.tile, SLE_UINT32),
SLE_VAR(AcceptanceMatrix, area.w, SLE_UINT16),
SLE_VAR(AcceptanceMatrix, area.h, SLE_UINT16),
};
inline const static SaveLoadCompatTable compat_description = _town_acceptance_matrix_sl_compat;
void Load(Town *) const override
{
/* Discard now unused acceptance matrix. */
AcceptanceMatrix dummy;
SlObject(&dummy, this->GetLoadDescription());
if (dummy.area.w != 0) {
uint arr_len = dummy.area.w / AcceptanceMatrix::GRID * dummy.area.h / AcceptanceMatrix::GRID;
SlSkipBytes(4 * arr_len);
}
}
};
static const SaveLoad _town_desc[] = {
SLE_CONDVAR(Town, xy, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
SLE_CONDVAR(Town, xy, SLE_UINT32, SLV_6, SL_MAX_VERSION),
SLE_CONDVAR(Town, townnamegrfid, SLE_UINT32, SLV_66, SL_MAX_VERSION),
SLE_VAR(Town, townnametype, SLE_UINT16),
SLE_VAR(Town, townnameparts, SLE_UINT32),
SLE_CONDSSTR(Town, name, SLE_STR | SLF_ALLOW_CONTROL, SLV_84, SL_MAX_VERSION),
SLE_VAR(Town, flags, SLE_UINT8),
SLE_CONDVAR(Town, statues, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_104),
SLE_CONDVAR(Town, statues, SLE_UINT16, SLV_104, SL_MAX_VERSION),
SLE_CONDVAR(Town, have_ratings, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_104),
SLE_CONDVAR(Town, have_ratings, SLE_UINT16, SLV_104, SL_MAX_VERSION),
SLE_CONDARR(Town, ratings, SLE_INT16, 8, SL_MIN_VERSION, SLV_104),
SLE_CONDARR(Town, ratings, SLE_INT16, MAX_COMPANIES, SLV_104, SL_MAX_VERSION),
SLE_CONDARR(Town, unwanted, SLE_INT8, 8, SLV_4, SLV_104),
SLE_CONDARR(Town, unwanted, SLE_INT8, MAX_COMPANIES, SLV_104, SL_MAX_VERSION),
SLE_CONDVAR(Town, supplied[CT_PASSENGERS].old_max, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
SLE_CONDVAR(Town, supplied[CT_PASSENGERS].old_max, SLE_UINT32, SLV_9, SLV_165),
SLE_CONDVAR(Town, supplied[CT_MAIL].old_max, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
SLE_CONDVAR(Town, supplied[CT_MAIL].old_max, SLE_UINT32, SLV_9, SLV_165),
SLE_CONDVAR(Town, supplied[CT_PASSENGERS].new_max, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
SLE_CONDVAR(Town, supplied[CT_PASSENGERS].new_max, SLE_UINT32, SLV_9, SLV_165),
SLE_CONDVAR(Town, supplied[CT_MAIL].new_max, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
SLE_CONDVAR(Town, supplied[CT_MAIL].new_max, SLE_UINT32, SLV_9, SLV_165),
SLE_CONDVAR(Town, supplied[CT_PASSENGERS].old_act, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
SLE_CONDVAR(Town, supplied[CT_PASSENGERS].old_act, SLE_UINT32, SLV_9, SLV_165),
SLE_CONDVAR(Town, supplied[CT_MAIL].old_act, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
SLE_CONDVAR(Town, supplied[CT_MAIL].old_act, SLE_UINT32, SLV_9, SLV_165),
SLE_CONDVAR(Town, supplied[CT_PASSENGERS].new_act, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
SLE_CONDVAR(Town, supplied[CT_PASSENGERS].new_act, SLE_UINT32, SLV_9, SLV_165),
SLE_CONDVAR(Town, supplied[CT_MAIL].new_act, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
SLE_CONDVAR(Town, supplied[CT_MAIL].new_act, SLE_UINT32, SLV_9, SLV_165),
SLE_CONDVAR(Town, received[TE_FOOD].old_act, SLE_UINT16, SL_MIN_VERSION, SLV_165),
SLE_CONDVAR(Town, received[TE_WATER].old_act, SLE_UINT16, SL_MIN_VERSION, SLV_165),
SLE_CONDVAR(Town, received[TE_FOOD].new_act, SLE_UINT16, SL_MIN_VERSION, SLV_165),
SLE_CONDVAR(Town, received[TE_WATER].new_act, SLE_UINT16, SL_MIN_VERSION, SLV_165),
SLE_CONDARR(Town, goal, SLE_UINT32, NUM_TE, SLV_165, SL_MAX_VERSION),
SLE_CONDSSTR(Town, text, SLE_STR | SLF_ALLOW_CONTROL, SLV_168, SL_MAX_VERSION),
SLE_CONDVAR(Town, time_until_rebuild, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_54),
SLE_CONDVAR(Town, time_until_rebuild, SLE_UINT16, SLV_54, SL_MAX_VERSION),
SLE_CONDVAR(Town, grow_counter, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_54),
SLE_CONDVAR(Town, grow_counter, SLE_UINT16, SLV_54, SL_MAX_VERSION),
SLE_CONDVAR(Town, growth_rate, SLE_FILE_U8 | SLE_VAR_I16, SL_MIN_VERSION, SLV_54),
SLE_CONDVAR(Town, growth_rate, SLE_FILE_I16 | SLE_VAR_U16, SLV_54, SLV_165),
SLE_CONDVAR(Town, growth_rate, SLE_UINT16, SLV_165, SL_MAX_VERSION),
SLE_VAR(Town, fund_buildings_months, SLE_UINT8),
SLE_VAR(Town, road_build_months, SLE_UINT8),
SLE_CONDVAR(Town, exclusivity, SLE_UINT8, SLV_2, SL_MAX_VERSION),
SLE_CONDVAR(Town, exclusive_counter, SLE_UINT8, SLV_2, SL_MAX_VERSION),
SLE_CONDVAR(Town, larger_town, SLE_BOOL, SLV_56, SL_MAX_VERSION),
SLE_CONDVAR(Town, layout, SLE_UINT8, SLV_113, SL_MAX_VERSION),
SLE_CONDREFLIST(Town, psa_list, REF_STORAGE, SLV_161, SL_MAX_VERSION),
SLEG_CONDSTRUCTLIST("supplied", SlTownSupplied, SLV_165, SL_MAX_VERSION),
SLEG_CONDSTRUCTLIST("received", SlTownReceived, SLV_165, SL_MAX_VERSION),
SLEG_CONDSTRUCTLIST("acceptance_matrix", SlTownAcceptanceMatrix, SLV_166, SLV_REMOVE_TOWN_CARGO_CACHE),
};
struct HIDSChunkHandler : NewGRFMappingChunkHandler {
HIDSChunkHandler() : NewGRFMappingChunkHandler('HIDS', _house_mngr) {}
};
struct CITYChunkHandler : ChunkHandler {
CITYChunkHandler() : ChunkHandler('CITY', CH_TABLE) {}
void Save() const override
{
SlTableHeader(_town_desc);
for (Town *t : Town::Iterate()) {
SlSetArrayIndex(t->index);
SlObject(t, _town_desc);
}
}
void Load() const override
{
const std::vector<SaveLoad> slt = SlCompatTableHeader(_town_desc, _town_sl_compat);
int index;
while ((index = SlIterateArray()) != -1) {
Town *t = new (index) Town();
SlObject(t, slt);
if (t->townnamegrfid == 0 && !IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1) && GetStringTab(t->townnametype) != TEXT_TAB_OLD_CUSTOM) {
SlErrorCorrupt("Invalid town name generator");
}
}
}
void FixPointers() const override
{
if (IsSavegameVersionBefore(SLV_161)) return;
for (Town *t : Town::Iterate()) {
SlObject(t, _town_desc);
}
}
};
static const HIDSChunkHandler HIDS;
static const CITYChunkHandler CITY;
static const ChunkHandlerRef town_chunk_handlers[] = {
HIDS,
CITY,
};
extern const ChunkHandlerTable _town_chunk_handlers(town_chunk_handlers);
|