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

OpenTTD Source 13.2.1

afterload.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 #include "../void_map.h"
12 #include "../signs_base.h"
13 #include "../depot_base.h"
14 #include "../fios.h"
15 #include "../gamelog_internal.h"
16 #include "../network/network.h"
17 #include "../network/network_func.h"
18 #include "../gfxinit.h"
19 #include "../viewport_func.h"
20 #include "../viewport_kdtree.h"
21 #include "../industry.h"
22 #include "../clear_map.h"
23 #include "../vehicle_func.h"
24 #include "../string_func.h"
25 #include "../date_func.h"
26 #include "../roadveh.h"
27 #include "../roadveh_cmd.h"
28 #include "../train.h"
29 #include "../station_base.h"
30 #include "../waypoint_base.h"
31 #include "../roadstop_base.h"
32 #include "../tunnelbridge_map.h"
33 #include "../pathfinder/yapf/yapf_cache.h"
34 #include "../elrail_func.h"
35 #include "../signs_func.h"
36 #include "../aircraft.h"
37 #include "../object_map.h"
38 #include "../object_base.h"
39 #include "../tree_map.h"
40 #include "../company_func.h"
41 #include "../road_cmd.h"
42 #include "../ai/ai.hpp"
43 #include "../ai/ai_gui.hpp"
44 #include "../game/game.hpp"
45 #include "../town.h"
46 #include "../economy_base.h"
47 #include "../animated_tile_func.h"
48 #include "../subsidy_base.h"
49 #include "../subsidy_func.h"
50 #include "../newgrf.h"
51 #include "../engine_func.h"
52 #include "../rail_gui.h"
53 #include "../core/backup_type.hpp"
54 #include "../smallmap_gui.h"
55 #include "../news_func.h"
56 #include "../order_backup.h"
57 #include "../error.h"
58 #include "../disaster_vehicle.h"
59 #include "../ship.h"
60 #include "../water.h"
61
62 #include "saveload_internal.h"
63
64 #include <signal.h>
65
66 #include "../safeguards.h"
67
68 extern Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY);
69
80 void SetWaterClassDependingOnSurroundings(TileIndex t, bool include_invalid_water_class)
81 {
82 /* If the slope is not flat, we always assume 'land' (if allowed). Also for one-corner-raised-shores.
83 * Note: Wrt. autosloping under industry tiles this is the most fool-proof behaviour. */
84 if (!IsTileFlat(t)) {
85 if (include_invalid_water_class) {
86 SetWaterClass(t, WATER_CLASS_INVALID);
87 return;
88 } else {
89 SlErrorCorrupt("Invalid water class for dry tile");
90 }
91 }
92
93 /* Mark tile dirty in all cases */
94 MarkTileDirtyByTile(t);
95
96 if (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1) {
97 /* tiles at map borders are always WATER_CLASS_SEA */
98 SetWaterClass(t, WATER_CLASS_SEA);
99 return;
100 }
101
102 bool has_water = false;
103 bool has_canal = false;
104 bool has_river = false;
105
106 for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
107 TileIndex neighbour = TileAddByDiagDir(t, dir);
108 switch (GetTileType(neighbour)) {
109 case MP_WATER:
110 /* clear water and shipdepots have already a WaterClass associated */
111 if (IsCoast(neighbour)) {
112 has_water = true;
113 } else if (!IsLock(neighbour)) {
114 switch (GetWaterClass(neighbour)) {
115 case WATER_CLASS_SEA: has_water = true; break;
116 case WATER_CLASS_CANAL: has_canal = true; break;
117 case WATER_CLASS_RIVER: has_river = true; break;
118 default: SlErrorCorrupt("Invalid water class for tile");
119 }
120 }
121 break;
122
123 case MP_RAILWAY:
124 /* Shore or flooded halftile */
125 has_water |= (GetRailGroundType(neighbour) == RAIL_GROUND_WATER);
126 break;
127
128 case MP_TREES:
129 /* trees on shore */
130 has_water |= (GB(_m[neighbour].m2, 4, 2) == TREE_GROUND_SHORE);
131 break;
132
133 default: break;
134 }
135 }
136
137 if (!has_water && !has_canal && !has_river && include_invalid_water_class) {
138 SetWaterClass(t, WATER_CLASS_INVALID);
139 return;
140 }
141
142 if (has_river && !has_canal) {
143 SetWaterClass(t, WATER_CLASS_RIVER);
144 } else if (has_canal || !has_water) {
145 SetWaterClass(t, WATER_CLASS_CANAL);
146 } else {
147 SetWaterClass(t, WATER_CLASS_SEA);
148 }
149 }
150
151 static void ConvertTownOwner()
152 {
153 for (TileIndex tile = 0; tile != MapSize(); tile++) {
154 switch (GetTileType(tile)) {
155 case MP_ROAD:
156 if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m3, 7)) {
157 _m[tile].m3 = OWNER_TOWN;
158 }
159 FALLTHROUGH;
160
161 case MP_TUNNELBRIDGE:
162 if (_m[tile].m1 & 0x80) SetTileOwner(tile, OWNER_TOWN);
163 break;
164
165 default: break;
166 }
167 }
168 }
169
170 /* since savegame version 4.1, exclusive transport rights are stored at towns */
171 static void UpdateExclusiveRights()
172 {
173 for (Town *t : Town::Iterate()) {
174 t->exclusivity = INVALID_COMPANY;
175 }
176
177 /* FIXME old exclusive rights status is not being imported (stored in s->blocked_months_obsolete)
178 * could be implemented this way:
179 * 1.) Go through all stations
180 * Build an array town_blocked[ town_id ][ company_id ]
181 * that stores if at least one station in that town is blocked for a company
182 * 2.) Go through that array, if you find a town that is not blocked for
183 * one company, but for all others, then give it exclusivity.
184 */
185 }
186
187 static const byte convert_currency[] = {
188 0, 1, 12, 8, 3,
189 10, 14, 19, 4, 5,
190 9, 11, 13, 6, 17,
191 16, 22, 21, 7, 15,
192 18, 2, 20,
193 };
194
195 /* since savegame version 4.2 the currencies are arranged differently */
196 static void UpdateCurrencies()
197 {
198 _settings_game.locale.currency = convert_currency[_settings_game.locale.currency];
199 }
200
201 /* Up to revision 1413 the invisible tiles at the southern border have not been
202 * MP_VOID, even though they should have. This is fixed by this function
203 */
204 static void UpdateVoidTiles()
205 {
206 for (uint x = 0; x < MapSizeX(); x++) MakeVoid(TileXY(x, MapMaxY()));
207 for (uint y = 0; y < MapSizeY(); y++) MakeVoid(TileXY(MapMaxX(), y));
208 }
209
210 static inline RailType UpdateRailType(RailType rt, RailType min)
211 {
212 return rt >= min ? (RailType)(rt + 1): rt;
213 }
214
218 void UpdateAllVirtCoords()
219 {
220 UpdateAllStationVirtCoords();
221 UpdateAllSignVirtCoords();
222 UpdateAllTownVirtCoords();
223 UpdateAllTextEffectVirtCoords();
224 RebuildViewportKdtree();
225 }
226
227 void ClearAllCachedNames()
228 {
229 ClearAllStationCachedNames();
230 ClearAllTownCachedNames();
231 ClearAllIndustryCachedNames();
232 }
233
243 static void InitializeWindowsAndCaches()
244 {
245 /* Initialize windows */
246 ResetWindowSystem();
247 SetupColoursAndInitialWindow();
248
249 /* Update coordinates of the signs. */
250 ClearAllCachedNames();
251 UpdateAllVirtCoords();
252 ResetViewportAfterLoadGame();
253
254 for (Company *c : Company::Iterate()) {
255 /* For each company, verify (while loading a scenario) that the inauguration date is the current year and set it
256 * accordingly if it is not the case. No need to set it on companies that are not been used already,
257 * thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */
258 if (_file_to_saveload.abstract_ftype == FT_SCENARIO && c->inaugurated_year != MIN_YEAR) {
259 c->inaugurated_year = _cur_year;
260 }
261 }
262
263 /* Count number of objects per type */
264 for (Object *o : Object::Iterate()) {
265 Object::IncTypeCount(o->type);
266 }
267
268 /* Identify owners of persistent storage arrays */
269 for (Industry *i : Industry::Iterate()) {
270 if (i->psa != nullptr) {
271 i->psa->feature = GSF_INDUSTRIES;
272 i->psa->tile = i->location.tile;
273 }
274 }
275 for (Station *s : Station::Iterate()) {
276 if (s->airport.psa != nullptr) {
277 s->airport.psa->feature = GSF_AIRPORTS;
278 s->airport.psa->tile = s->airport.tile;
279 }
280 }
281 for (Town *t : Town::Iterate()) {
282 for (std::list<PersistentStorage *>::iterator it = t->psa_list.begin(); it != t->psa_list.end(); ++it) {
283 (*it)->feature = GSF_FAKE_TOWNS;
284 (*it)->tile = t->xy;
285 }
286 }
287 for (RoadVehicle *rv : RoadVehicle::Iterate()) {
288 if (rv->IsFrontEngine()) {
289 rv->CargoChanged();
290 }
291 }
292
293 RecomputePrices();
294
295 GroupStatistics::UpdateAfterLoad();
296
297 RebuildSubsidisedSourceAndDestinationCache();
298
299 /* Towns have a noise controlled number of airports system
300 * So each airport's noise value must be added to the town->noise_reached value
301 * Reset each town's noise_reached value to '0' before. */
302 UpdateAirportsNoise();
303
304 CheckTrainsLengths();
305 ShowNewGRFError();
306
307 /* Rebuild the smallmap list of owners. */
308 BuildOwnerLegend();
309 }
310
311 typedef void (CDECL *SignalHandlerPointer)(int);
312 static SignalHandlerPointer _prev_segfault = nullptr;
313 static SignalHandlerPointer _prev_abort = nullptr;
314 static SignalHandlerPointer _prev_fpe = nullptr;
315
316 static void CDECL HandleSavegameLoadCrash(int signum);
317
322 static void SetSignalHandlers()
323 {
324 _prev_segfault = signal(SIGSEGV, HandleSavegameLoadCrash);
325 _prev_abort = signal(SIGABRT, HandleSavegameLoadCrash);
326 _prev_fpe = signal(SIGFPE, HandleSavegameLoadCrash);
327 }
328
332 static void ResetSignalHandlers()
333 {
334 signal(SIGSEGV, _prev_segfault);
335 signal(SIGABRT, _prev_abort);
336 signal(SIGFPE, _prev_fpe);
337 }
338
344 static const GRFIdentifier *GetOverriddenIdentifier(const GRFConfig *c)
345 {
346 const LoggedAction *la = &_gamelog_action[_gamelog_actions - 1];
347 if (la->at != GLAT_LOAD) return &c->ident;
348
349 const LoggedChange *lcend = &la->change[la->changes];
350 for (const LoggedChange *lc = la->change; lc != lcend; lc++) {
351 if (lc->ct == GLCT_GRFCOMPAT && lc->grfcompat.grfid == c->ident.grfid) return &lc->grfcompat;
352 }
353
354 return &c->ident;
355 }
356
358 static bool _saveload_crash_with_missing_newgrfs = false;
359
365 bool SaveloadCrashWithMissingNewGRFs()
366 {
367 return _saveload_crash_with_missing_newgrfs;
368 }
369
376 static void CDECL HandleSavegameLoadCrash(int signum)
377 {
378 ResetSignalHandlers();
379
380 char buffer[8192];
381 char *p = buffer;
382 p += seprintf(p, lastof(buffer), "Loading your savegame caused OpenTTD to crash.\n");
383
384 for (const GRFConfig *c = _grfconfig; !_saveload_crash_with_missing_newgrfs && c != nullptr; c = c->next) {
385 _saveload_crash_with_missing_newgrfs = HasBit(c->flags, GCF_COMPATIBLE) || c->status == GCS_NOT_FOUND;
386 }
387
388 if (_saveload_crash_with_missing_newgrfs) {
389 p += seprintf(p, lastof(buffer),
390 "This is most likely caused by a missing NewGRF or a NewGRF that\n"
391 "has been loaded as replacement for a missing NewGRF. OpenTTD\n"
392 "cannot easily determine whether a replacement NewGRF is of a newer\n"
393 "or older version.\n"
394 "It will load a NewGRF with the same GRF ID as the missing NewGRF.\n"
395 "This means that if the author makes incompatible NewGRFs with the\n"
396 "same GRF ID, OpenTTD cannot magically do the right thing. In most\n"
397 "cases, OpenTTD will load the savegame and not crash, but this is an\n"
398 "exception.\n"
399 "Please load the savegame with the appropriate NewGRFs installed.\n"
400 "The missing/compatible NewGRFs are:\n");
401
402 for (const GRFConfig *c = _grfconfig; c != nullptr; c = c->next) {
403 if (HasBit(c->flags, GCF_COMPATIBLE)) {
404 const GRFIdentifier *replaced = GetOverriddenIdentifier(c);
405 char original_md5[40];
406 char replaced_md5[40];
407 md5sumToString(original_md5, lastof(original_md5), c->original_md5sum);
408 md5sumToString(replaced_md5, lastof(replaced_md5), replaced->md5sum);
409 p += seprintf(p, lastof(buffer), "NewGRF %08X (checksum %s) not found.\n Loaded NewGRF \"%s\" (checksum %s) with same GRF ID instead.\n", BSWAP32(c->ident.grfid), original_md5, c->filename, replaced_md5);
410 }
411 if (c->status == GCS_NOT_FOUND) {
412 char buf[40];
413 md5sumToString(buf, lastof(buf), c->ident.md5sum);
414 p += seprintf(p, lastof(buffer), "NewGRF %08X (%s) not found; checksum %s.\n", BSWAP32(c->ident.grfid), c->filename, buf);
415 }
416 }
417 } else {
418 p += seprintf(p, lastof(buffer),
419 "This is probably caused by a corruption in the savegame.\n"
420 "Please file a bug report and attach this savegame.\n");
421 }
422
423 ShowInfo(buffer);
424
425 SignalHandlerPointer call = nullptr;
426 switch (signum) {
427 case SIGSEGV: call = _prev_segfault; break;
428 case SIGABRT: call = _prev_abort; break;
429 case SIGFPE: call = _prev_fpe; break;
430 default: NOT_REACHED();
431 }
432 if (call != nullptr) call(signum);
433 }
434
440 static void FixOwnerOfRailTrack(TileIndex t)
441 {
442 assert(!Company::IsValidID(GetTileOwner(t)) && (IsLevelCrossingTile(t) || IsPlainRailTile(t)));
443
444 /* remove leftover rail piece from crossing (from very old savegames) */
445 Train *v = nullptr;
446 for (Train *w : Train::Iterate()) {
447 if (w->tile == t) {
448 v = w;
449 break;
450 }
451 }
452
453 if (v != nullptr) {
454 /* when there is a train on crossing (it could happen in TTD), set owner of crossing to train owner */
455 SetTileOwner(t, v->owner);
456 return;
457 }
458
459 /* try to find any connected rail */
460 for (DiagDirection dd = DIAGDIR_BEGIN; dd < DIAGDIR_END; dd++) {
461 TileIndex tt = t + TileOffsByDiagDir(dd);
462 if (GetTileTrackStatus(t, TRANSPORT_RAIL, 0, dd) != 0 &&
463 GetTileTrackStatus(tt, TRANSPORT_RAIL, 0, ReverseDiagDir(dd)) != 0 &&
464 Company::IsValidID(GetTileOwner(tt))) {
465 SetTileOwner(t, GetTileOwner(tt));
466 return;
467 }
468 }
469
470 if (IsLevelCrossingTile(t)) {
471 /* else change the crossing to normal road (road vehicles won't care) */
472 Owner road = GetRoadOwner(t, RTT_ROAD);
473 Owner tram = GetRoadOwner(t, RTT_TRAM);
474 RoadBits bits = GetCrossingRoadBits(t);
475 bool hasroad = HasBit(_me[t].m7, 6);
476 bool hastram = HasBit(_me[t].m7, 7);
477
478 /* MakeRoadNormal */
479 SetTileType(t, MP_ROAD);
480 SetTileOwner(t, road);
481 _m[t].m3 = (hasroad ? bits : 0);
482 _m[t].m5 = (hastram ? bits : 0) | ROAD_TILE_NORMAL << 6;
483 SB(_me[t].m6, 2, 4, 0);
484 SetRoadOwner(t, RTT_TRAM, tram);
485 return;
486 }
487
488 /* if it's not a crossing, make it clean land */
489 MakeClear(t, CLEAR_GRASS, 0);
490 }
491
498 static uint FixVehicleInclination(Vehicle *v, Direction dir)
499 {
500 /* Compute place where this vehicle entered the tile */
501 int entry_x = v->x_pos;
502 int entry_y = v->y_pos;
503 switch (dir) {
504 case DIR_NE: entry_x |= TILE_UNIT_MASK; break;
505 case DIR_NW: entry_y |= TILE_UNIT_MASK; break;
506 case DIR_SW: entry_x &= ~TILE_UNIT_MASK; break;
507 case DIR_SE: entry_y &= ~TILE_UNIT_MASK; break;
508 case INVALID_DIR: break;
509 default: NOT_REACHED();
510 }
511 byte entry_z = GetSlopePixelZ(entry_x, entry_y);
512
513 /* Compute middle of the tile. */
514 int middle_x = (v->x_pos & ~TILE_UNIT_MASK) + TILE_SIZE / 2;
515 int middle_y = (v->y_pos & ~TILE_UNIT_MASK) + TILE_SIZE / 2;
516 byte middle_z = GetSlopePixelZ(middle_x, middle_y);
517
518 /* middle_z == entry_z, no height change. */
519 if (middle_z == entry_z) return 0;
520
521 /* middle_z < entry_z, we are going downwards. */
522 if (middle_z < entry_z) return 1U << GVF_GOINGDOWN_BIT;
523
524 /* middle_z > entry_z, we are going upwards. */
525 return 1U << GVF_GOINGUP_BIT;
526 }
527
534 static inline bool MayHaveBridgeAbove(TileIndex t)
535 {
536 return IsTileType(t, MP_CLEAR) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_ROAD) ||
537 IsTileType(t, MP_WATER) || IsTileType(t, MP_TUNNELBRIDGE) || IsTileType(t, MP_OBJECT);
538 }
539
543 static void StartScripts()
544 {
545 /* Script debug window requires AIs to be started before trying to start GameScript. */
546
547 /* Start the AIs. */
548 for (const Company *c : Company::Iterate()) {
549 if (Company::IsValidAiID(c->index)) AI::StartNew(c->index, false);
550 }
551
552 /* Start the GameScript. */
553 Game::StartNew();
554
555 ShowAIDebugWindowIfAIError();
556 }
557
563 bool AfterLoadGame()
564 {
565 SetSignalHandlers();
566
567 TileIndex map_size = MapSize();
568
569 extern TileIndex _cur_tileloop_tile; // From landscape.cpp.
570 /* The LFSR used in RunTileLoop iteration cannot have a zeroed state, make it non-zeroed. */
571 if (_cur_tileloop_tile == 0) _cur_tileloop_tile = 1;
572
573 if (IsSavegameVersionBefore(SLV_98)) GamelogOldver();
574
575 GamelogTestRevision();
576 GamelogTestMode();
577
578 RebuildTownKdtree();
579 RebuildStationKdtree();
580 /* This needs to be done even before conversion, because some conversions will destroy objects
581 * that otherwise won't exist in the tree. */
582 RebuildViewportKdtree();
583
584 if (IsSavegameVersionBefore(SLV_98)) GamelogGRFAddList(_grfconfig);
585
586 if (IsSavegameVersionBefore(SLV_119)) {
587 _pause_mode = (_pause_mode == 2) ? PM_PAUSED_NORMAL : PM_UNPAUSED;
588 } else if (_network_dedicated && (_pause_mode & PM_PAUSED_ERROR) != 0) {
589 Debug(net, 0, "The loading savegame was paused due to an error state");
590 Debug(net, 0, " This savegame cannot be used for multiplayer");
591 /* Restore the signals */
592 ResetSignalHandlers();
593 return false;
594 } else if (!_networking || _network_server) {
595 /* If we are in singleplayer mode, i.e. not networking, and loading the
596 * savegame or we are loading the savegame as network server we do
597 * not want to be bothered by being paused because of the automatic
598 * reason of a network server, e.g. joining clients or too few
599 * active clients. Note that resetting these values for a network
600 * client are very bad because then the client is going to execute
601 * the game loop when the server is not, i.e. it desyncs. */
602 _pause_mode &= ~PMB_PAUSED_NETWORK;
603 }
604
605 /* In very old versions, size of train stations was stored differently.
606 * They had swapped width and height if station was built along the Y axis.
607 * TTO and TTD used 3 bits for width/height, while OpenTTD used 4.
608 * Because the data stored by TTDPatch are unusable for rail stations > 7x7,
609 * recompute the width and height. Doing this unconditionally for all old
610 * savegames simplifies the code. */
611 if (IsSavegameVersionBefore(SLV_2)) {
612 for (Station *st : Station::Iterate()) {
613 st->train_station.w = st->train_station.h = 0;
614 }
615 for (TileIndex t = 0; t < map_size; t++) {
616 if (!IsTileType(t, MP_STATION)) continue;
617 if (_m[t].m5 > 7) continue; // is it a rail station tile?
618 Station *st = Station::Get(_m[t].m2);
619 assert(st->train_station.tile != 0);
620 int dx = TileX(t) - TileX(st->train_station.tile);
621 int dy = TileY(t) - TileY(st->train_station.tile);
622 assert(dx >= 0 && dy >= 0);
623 st->train_station.w = std::max<uint>(st->train_station.w, dx + 1);
624 st->train_station.h = std::max<uint>(st->train_station.h, dy + 1);
625 }
626 }
627
628 if (IsSavegameVersionBefore(SLV_194)) {
629 _settings_game.construction.map_height_limit = 15;
630
631 /* In old savegame versions, the heightlevel was coded in bits 0..3 of the type field */
632 for (TileIndex t = 0; t < map_size; t++) {
633 _m[t].height = GB(_m[t].type, 0, 4);
634 SB(_m[t].type, 0, 2, GB(_me[t].m6, 0, 2));
635 SB(_me[t].m6, 0, 2, 0);
636 if (MayHaveBridgeAbove(t)) {
637 SB(_m[t].type, 2, 2, GB(_me[t].m6, 6, 2));
638 SB(_me[t].m6, 6, 2, 0);
639 } else {
640 SB(_m[t].type, 2, 2, 0);
641 }
642 }
643 }
644
645 /* in version 2.1 of the savegame, town owner was unified. */
646 if (IsSavegameVersionBefore(SLV_2, 1)) ConvertTownOwner();
647
648 /* from version 4.1 of the savegame, exclusive rights are stored at towns */
649 if (IsSavegameVersionBefore(SLV_4, 1)) UpdateExclusiveRights();
650
651 /* from version 4.2 of the savegame, currencies are in a different order */
652 if (IsSavegameVersionBefore(SLV_4, 2)) UpdateCurrencies();
653
654 /* In old version there seems to be a problem that water is owned by
655 * OWNER_NONE, not OWNER_WATER.. I can't replicate it for the current
656 * (4.3) version, so I just check when versions are older, and then
657 * walk through the whole map.. */
658 if (IsSavegameVersionBefore(SLV_4, 3)) {
659 for (TileIndex t = 0; t < map_size; t++) {
660 if (IsTileType(t, MP_WATER) && GetTileOwner(t) >= MAX_COMPANIES) {
661 SetTileOwner(t, OWNER_WATER);
662 }
663 }
664 }
665
666 if (IsSavegameVersionBefore(SLV_84)) {
667 for (Company *c : Company::Iterate()) {
668 c->name = CopyFromOldName(c->name_1);
669 if (!c->name.empty()) c->name_1 = STR_SV_UNNAMED;
670 c->president_name = CopyFromOldName(c->president_name_1);
671 if (!c->president_name.empty()) c->president_name_1 = SPECSTR_PRESIDENT_NAME;
672 }
673
674 for (Station *st : Station::Iterate()) {
675 st->name = CopyFromOldName(st->string_id);
676 /* generating new name would be too much work for little effect, use the station name fallback */
677 if (!st->name.empty()) st->string_id = STR_SV_STNAME_FALLBACK;
678 }
679
680 for (Town *t : Town::Iterate()) {
681 t->name = CopyFromOldName(t->townnametype);
682 if (!t->name.empty()) t->townnametype = SPECSTR_TOWNNAME_START + _settings_game.game_creation.town_name;
683 }
684 }
685
686 /* From this point the old names array is cleared. */
687 ResetOldNames();
688
689 if (IsSavegameVersionBefore(SLV_106)) {
690 /* no station is determined by 'tile == INVALID_TILE' now (instead of '0') */
691 for (Station *st : Station::Iterate()) {
692 if (st->airport.tile == 0) st->airport.tile = INVALID_TILE;
693 if (st->train_station.tile == 0) st->train_station.tile = INVALID_TILE;
694 }
695
696 /* the same applies to Company::location_of_HQ */
697 for (Company *c : Company::Iterate()) {
698 if (c->location_of_HQ == 0 || (IsSavegameVersionBefore(SLV_4) && c->location_of_HQ == 0xFFFF)) {
699 c->location_of_HQ = INVALID_TILE;
700 }
701 }
702 }
703
704 /* convert road side to my format. */
705 if (_settings_game.vehicle.road_side) _settings_game.vehicle.road_side = 1;
706
707 /* Check if all NewGRFs are present, we are very strict in MP mode */
708 GRFListCompatibility gcf_res = IsGoodGRFConfigList(_grfconfig);
709 for (GRFConfig *c = _grfconfig; c != nullptr; c = c->next) {
710 if (c->status == GCS_NOT_FOUND) {
711 GamelogGRFRemove(c->ident.grfid);
712 } else if (HasBit(c->flags, GCF_COMPATIBLE)) {
713 GamelogGRFCompatible(&c->ident);
714 }
715 }
716
717 if (_networking && gcf_res != GLC_ALL_GOOD) {
718 SetSaveLoadError(STR_NETWORK_ERROR_CLIENT_NEWGRF_MISMATCH);
719 /* Restore the signals */
720 ResetSignalHandlers();
721 return false;
722 }
723
724 switch (gcf_res) {
725 case GLC_COMPATIBLE: ShowErrorMessage(STR_NEWGRF_COMPATIBLE_LOAD_WARNING, INVALID_STRING_ID, WL_CRITICAL); break;
726 case GLC_NOT_FOUND: ShowErrorMessage(STR_NEWGRF_DISABLED_WARNING, INVALID_STRING_ID, WL_CRITICAL); _pause_mode = PM_PAUSED_ERROR; break;
727 default: break;
728 }
729
730 /* The value of _date_fract got divided, so make sure that old games are converted correctly. */
731 if (IsSavegameVersionBefore(SLV_11, 1) || (IsSavegameVersionBefore(SLV_147) && _date_fract > DAY_TICKS)) _date_fract /= 885;
732
733 /* Update current year
734 * must be done before loading sprites as some newgrfs check it */
735 SetDate(_date, _date_fract);
736
737 /*
738 * Force the old behaviour for compatibility reasons with old savegames. As new
739 * settings can only be loaded from new savegames loading old savegames with new
740 * versions of OpenTTD will normally initialize settings newer than the savegame
741 * version with "new game" defaults which the player can define to their liking.
742 * For some settings we override that to keep the behaviour the same as when the
743 * game was saved.
744 *
745 * Note that there is no non-stop in here. This is because the setting could have
746 * either value in TTDPatch. To convert it properly the user has to make sure the
747 * right value has been chosen in the settings. Otherwise we will be converting
748 * it incorrectly in half of the times without a means to correct that.
749 */
750 if (IsSavegameVersionBefore(SLV_4, 2)) _settings_game.station.modified_catchment = false;
751 if (IsSavegameVersionBefore(SLV_6, 1)) _settings_game.pf.forbid_90_deg = false;
752 if (IsSavegameVersionBefore(SLV_21)) _settings_game.vehicle.train_acceleration_model = 0;
753 if (IsSavegameVersionBefore(SLV_90)) _settings_game.vehicle.plane_speed = 4;
754 if (IsSavegameVersionBefore(SLV_95)) _settings_game.vehicle.dynamic_engines = false;
755 if (IsSavegameVersionBefore(SLV_96)) _settings_game.economy.station_noise_level = false;
756 if (IsSavegameVersionBefore(SLV_133)) {
757 _settings_game.vehicle.train_slope_steepness = 3;
758 }
759 if (IsSavegameVersionBefore(SLV_134)) _settings_game.economy.feeder_payment_share = 75;
760 if (IsSavegameVersionBefore(SLV_138)) _settings_game.vehicle.plane_crashes = 2;
761 if (IsSavegameVersionBefore(SLV_139)) {
762 _settings_game.vehicle.roadveh_acceleration_model = 0;
763 _settings_game.vehicle.roadveh_slope_steepness = 7;
764 }
765 if (IsSavegameVersionBefore(SLV_143)) _settings_game.economy.allow_town_level_crossings = true;
766 if (IsSavegameVersionBefore(SLV_159)) {
767 _settings_game.vehicle.max_train_length = 50;
768 _settings_game.construction.max_bridge_length = 64;
769 _settings_game.construction.max_tunnel_length = 64;
770 }
771 if (IsSavegameVersionBefore(SLV_166)) _settings_game.economy.infrastructure_maintenance = false;
772 if (IsSavegameVersionBefore(SLV_183)) {
773 _settings_game.linkgraph.distribution_pax = DT_MANUAL;
774 _settings_game.linkgraph.distribution_mail = DT_MANUAL;
775 _settings_game.linkgraph.distribution_armoured = DT_MANUAL;
776 _settings_game.linkgraph.distribution_default = DT_MANUAL;
777 }
778
779 if (IsSavegameVersionBefore(SLV_ENDING_YEAR)) {
780 _settings_game.game_creation.ending_year = DEF_END_YEAR;
781 }
782
783 /* Load the sprites */
784 GfxLoadSprites();
785 LoadStringWidthTable();
786
787 /* Copy temporary data to Engine pool */
788 CopyTempEngineData();
789
790 /* Connect front and rear engines of multiheaded trains and converts
791 * subtype to the new format */
792 if (IsSavegameVersionBefore(SLV_17, 1)) ConvertOldMultiheadToNew();
793
794 /* Connect front and rear engines of multiheaded trains */
795 ConnectMultiheadedTrains();
796
797 /* Fix the CargoPackets *and* fix the caches of CargoLists.
798 * If this isn't done before Stations and especially Vehicles are
799 * running their AfterLoad we might get in trouble. In the case of
800 * vehicles we could give the wrong (cached) count of items in a
801 * vehicle which causes different results when getting their caches
802 * filled; and that could eventually lead to desyncs. */
803 CargoPacket::AfterLoad();
804
805 /* Oilrig was moved from id 15 to 9. We have to do this conversion
806 * here as AfterLoadVehicles can check it indirectly via the newgrf
807 * code. */
808 if (IsSavegameVersionBefore(SLV_139)) {
809 for (Station *st : Station::Iterate()) {
810 if (st->airport.tile != INVALID_TILE && st->airport.type == 15) {
811 st->airport.type = AT_OILRIG;
812 }
813 }
814 }
815
816 /* Update all vehicles */
817 AfterLoadVehicles(true);
818
819 /* make sure there is a town in the game */
820 if (_game_mode == GM_NORMAL && Town::GetNumItems() == 0) {
821 SetSaveLoadError(STR_ERROR_NO_TOWN_IN_SCENARIO);
822 /* Restore the signals */
823 ResetSignalHandlers();
824 return false;
825 }
826
827 /* The void tiles on the southern border used to belong to a wrong class (pre 4.3).
828 * This problem appears in savegame version 21 too, see r3455. But after loading the
829 * savegame and saving again, the buggy map array could be converted to new savegame
830 * version. It didn't show up before r12070. */
831 if (IsSavegameVersionBefore(SLV_87)) UpdateVoidTiles();
832
833 /* Fix the cache for cargo payments. */
834 for (CargoPayment *cp : CargoPayment::Iterate()) {
835 cp->front->cargo_payment = cp;
836 cp->current_station = cp->front->last_station_visited;
837 }
838
839 if (IsSavegameVersionBefore(SLV_72)) {
840 /* Locks in very old savegames had OWNER_WATER as owner */
841 for (TileIndex t = 0; t < MapSize(); t++) {
842 switch (GetTileType(t)) {
843 default: break;
844
845 case MP_WATER:
846 if (GetWaterTileType(t) == WATER_TILE_LOCK && GetTileOwner(t) == OWNER_WATER) SetTileOwner(t, OWNER_NONE);
847 break;
848
849 case MP_STATION: {
850 if (HasBit(_me[t].m6, 3)) SetBit(_me[t].m6, 2);
851 StationGfx gfx = GetStationGfx(t);
852 StationType st;
853 if ( IsInsideMM(gfx, 0, 8)) { // Rail station
854 st = STATION_RAIL;
855 SetStationGfx(t, gfx - 0);
856 } else if (IsInsideMM(gfx, 8, 67)) { // Airport
857 st = STATION_AIRPORT;
858 SetStationGfx(t, gfx - 8);
859 } else if (IsInsideMM(gfx, 67, 71)) { // Truck
860 st = STATION_TRUCK;
861 SetStationGfx(t, gfx - 67);
862 } else if (IsInsideMM(gfx, 71, 75)) { // Bus
863 st = STATION_BUS;
864 SetStationGfx(t, gfx - 71);
865 } else if (gfx == 75) { // Oil rig
866 st = STATION_OILRIG;
867 SetStationGfx(t, gfx - 75);
868 } else if (IsInsideMM(gfx, 76, 82)) { // Dock
869 st = STATION_DOCK;
870 SetStationGfx(t, gfx - 76);
871 } else if (gfx == 82) { // Buoy
872 st = STATION_BUOY;
873 SetStationGfx(t, gfx - 82);
874 } else if (IsInsideMM(gfx, 83, 168)) { // Extended airport
875 st = STATION_AIRPORT;
876 SetStationGfx(t, gfx - 83 + 67 - 8);
877 } else if (IsInsideMM(gfx, 168, 170)) { // Drive through truck
878 st = STATION_TRUCK;
879 SetStationGfx(t, gfx - 168 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
880 } else if (IsInsideMM(gfx, 170, 172)) { // Drive through bus
881 st = STATION_BUS;
882 SetStationGfx(t, gfx - 170 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
883 } else {
884 /* Restore the signals */
885 ResetSignalHandlers();
886 return false;
887 }
888 SB(_me[t].m6, 3, 3, st);
889 break;
890 }
891 }
892 }
893 }
894
895 for (TileIndex t = 0; t < map_size; t++) {
896 switch (GetTileType(t)) {
897 case MP_STATION: {
898 BaseStation *bst = BaseStation::GetByTile(t);
899
900 /* Sanity check */
901 if (!IsBuoy(t) && bst->owner != GetTileOwner(t)) SlErrorCorrupt("Wrong owner for station tile");
902
903 /* Set up station spread */
904 bst->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
905
906 /* Waypoints don't have road stops/oil rigs in the old format */
907 if (!Station::IsExpected(bst)) break;
908 Station *st = Station::From(bst);
909
910 switch (GetStationType(t)) {
911 case STATION_TRUCK:
912 case STATION_BUS:
913 if (IsSavegameVersionBefore(SLV_6)) {
914 /* Before version 5 you could not have more than 250 stations.
915 * Version 6 adds large maps, so you could only place 253*253
916 * road stops on a map (no freeform edges) = 64009. So, yes
917 * someone could in theory create such a full map to trigger
918 * this assertion, it's safe to assume that's only something
919 * theoretical and does not happen in normal games. */
920 assert(RoadStop::CanAllocateItem());
921
922 /* From this version on there can be multiple road stops of the
923 * same type per station. Convert the existing stops to the new
924 * internal data structure. */
925 RoadStop *rs = new RoadStop(t);
926
927 RoadStop **head =
928 IsTruckStop(t) ? &st->truck_stops : &st->bus_stops;
929 *head = rs;
930 }
931 break;
932
933 case STATION_OILRIG: {
934 /* The internal encoding of oil rigs was changed twice.
935 * It was 3 (till 2.2) and later 5 (till 5.1).
936 * DeleteOilRig asserts on the correct type, and
937 * setting it unconditionally does not hurt.
938 */
939 Station::GetByTile(t)->airport.type = AT_OILRIG;
940
941 /* Very old savegames sometimes have phantom oil rigs, i.e.
942 * an oil rig which got shut down, but not completely removed from
943 * the map
944 */
945 TileIndex t1 = TILE_ADDXY(t, 0, 1);
946 if (!IsTileType(t1, MP_INDUSTRY) || GetIndustryGfx(t1) != GFX_OILRIG_1) {
947 DeleteOilRig(t);
948 }
949 break;
950 }
951
952 default: break;
953 }
954 break;
955 }
956
957 default: break;
958 }
959 }
960
961 /* In version 6.1 we put the town index in the map-array. To do this, we need
962 * to use m2 (16bit big), so we need to clean m2, and that is where this is
963 * all about ;) */
964 if (IsSavegameVersionBefore(SLV_6, 1)) {
965 for (TileIndex t = 0; t < map_size; t++) {
966 switch (GetTileType(t)) {
967 case MP_HOUSE:
968 _m[t].m4 = _m[t].m2;
969 SetTownIndex(t, CalcClosestTownFromTile(t)->index);
970 break;
971
972 case MP_ROAD:
973 _m[t].m4 |= (_m[t].m2 << 4);
974 if ((GB(_m[t].m5, 4, 2) == ROAD_TILE_CROSSING ? (Owner)_m[t].m3 : GetTileOwner(t)) == OWNER_TOWN) {
975 SetTownIndex(t, CalcClosestTownFromTile(t)->index);
976 } else {
977 SetTownIndex(t, 0);
978 }
979 break;
980
981 default: break;
982 }
983 }
984 }
985
986 /* Force the freeform edges to false for old savegames. */
987 if (IsSavegameVersionBefore(SLV_111)) {
988 _settings_game.construction.freeform_edges = false;
989 }
990
991 /* From version 9.0, we update the max passengers of a town (was sometimes negative
992 * before that. */
993 if (IsSavegameVersionBefore(SLV_9)) {
994 for (Town *t : Town::Iterate()) UpdateTownMaxPass(t);
995 }
996
997 /* From version 16.0, we included autorenew on engines, which are now saved, but
998 * of course, we do need to initialize them for older savegames. */
999 if (IsSavegameVersionBefore(SLV_16)) {
1000 for (Company *c : Company::Iterate()) {
1001 c->engine_renew_list = nullptr;
1002 c->settings.engine_renew = false;
1003 c->settings.engine_renew_months = 6;
1004 c->settings.engine_renew_money = 100000;
1005 }
1006
1007 /* When loading a game, _local_company is not yet set to the correct value.
1008 * However, in a dedicated server we are a spectator, so nothing needs to
1009 * happen. In case we are not a dedicated server, the local company always
1010 * becomes the first available company, unless we are in the scenario editor
1011 * where all the companies are 'invalid'.
1012 */
1013 Company *c = Company::GetIfValid(GetFirstPlayableCompanyID());
1014 if (!_network_dedicated && c != nullptr) {
1015 c->settings = _settings_client.company;
1016 }
1017 }
1018
1019 if (IsSavegameVersionBefore(SLV_48)) {
1020 for (TileIndex t = 0; t < map_size; t++) {
1021 switch (GetTileType(t)) {
1022 case MP_RAILWAY:
1023 if (IsPlainRail(t)) {
1024 /* Swap ground type and signal type for plain rail tiles, so the
1025 * ground type uses the same bits as for depots and waypoints. */
1026 uint tmp = GB(_m[t].m4, 0, 4);
1027 SB(_m[t].m4, 0, 4, GB(_m[t].m2, 0, 4));
1028 SB(_m[t].m2, 0, 4, tmp);
1029 } else if (HasBit(_m[t].m5, 2)) {
1030 /* Split waypoint and depot rail type and remove the subtype. */
1031 ClrBit(_m[t].m5, 2);
1032 ClrBit(_m[t].m5, 6);
1033 }
1034 break;
1035
1036 case MP_ROAD:
1037 /* Swap m3 and m4, so the track type for rail crossings is the
1038 * same as for normal rail. */
1039 Swap(_m[t].m3, _m[t].m4);
1040 break;
1041
1042 default: break;
1043 }
1044 }
1045 }
1046
1047 if (IsSavegameVersionBefore(SLV_61)) {
1048 /* Added the RoadType */
1049 bool old_bridge = IsSavegameVersionBefore(SLV_42);
1050 for (TileIndex t = 0; t < map_size; t++) {
1051 switch (GetTileType(t)) {
1052 case MP_ROAD:
1053 SB(_m[t].m5, 6, 2, GB(_m[t].m5, 4, 2));
1054 switch (GetRoadTileType(t)) {
1055 default: SlErrorCorrupt("Invalid road tile type");
1056 case ROAD_TILE_NORMAL:
1057 SB(_m[t].m4, 0, 4, GB(_m[t].m5, 0, 4));
1058 SB(_m[t].m4, 4, 4, 0);
1059 SB(_me[t].m6, 2, 4, 0);
1060 break;
1061 case ROAD_TILE_CROSSING:
1062 SB(_m[t].m4, 5, 2, GB(_m[t].m5, 2, 2));
1063 break;
1064 case ROAD_TILE_DEPOT: break;
1065 }
1066 SB(_me[t].m7, 6, 2, 1); // Set pre-NRT road type bits for conversion later.
1067 break;
1068
1069 case MP_STATION:
1070 if (IsRoadStop(t)) SB(_me[t].m7, 6, 2, 1);
1071 break;
1072
1073 case MP_TUNNELBRIDGE:
1074 /* Middle part of "old" bridges */
1075 if (old_bridge && IsBridge(t) && HasBit(_m[t].m5, 6)) break;
1076 if (((old_bridge && IsBridge(t)) ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) {
1077 SB(_me[t].m7, 6, 2, 1); // Set pre-NRT road type bits for conversion later.
1078 }
1079 break;
1080
1081 default: break;
1082 }
1083 }
1084 }
1085
1086 if (IsSavegameVersionBefore(SLV_114)) {
1087 bool fix_roadtypes = !IsSavegameVersionBefore(SLV_61);
1088 bool old_bridge = IsSavegameVersionBefore(SLV_42);
1089
1090 for (TileIndex t = 0; t < map_size; t++) {
1091 switch (GetTileType(t)) {
1092 case MP_ROAD:
1093 if (fix_roadtypes) SB(_me[t].m7, 6, 2, (RoadTypes)GB(_me[t].m7, 5, 3));
1094 SB(_me[t].m7, 5, 1, GB(_m[t].m3, 7, 1)); // snow/desert
1095 switch (GetRoadTileType(t)) {
1096 default: SlErrorCorrupt("Invalid road tile type");
1097 case ROAD_TILE_NORMAL:
1098 SB(_me[t].m7, 0, 4, GB(_m[t].m3, 0, 4)); // road works
1099 SB(_me[t].m6, 3, 3, GB(_m[t].m3, 4, 3)); // ground
1100 SB(_m[t].m3, 0, 4, GB(_m[t].m4, 4, 4)); // tram bits
1101 SB(_m[t].m3, 4, 4, GB(_m[t].m5, 0, 4)); // tram owner
1102 SB(_m[t].m5, 0, 4, GB(_m[t].m4, 0, 4)); // road bits
1103 break;
1104
1105 case ROAD_TILE_CROSSING:
1106 SB(_me[t].m7, 0, 5, GB(_m[t].m4, 0, 5)); // road owner
1107 SB(_me[t].m6, 3, 3, GB(_m[t].m3, 4, 3)); // ground
1108 SB(_m[t].m3, 4, 4, GB(_m[t].m5, 0, 4)); // tram owner
1109 SB(_m[t].m5, 0, 1, GB(_m[t].m4, 6, 1)); // road axis
1110 SB(_m[t].m5, 5, 1, GB(_m[t].m4, 5, 1)); // crossing state
1111 break;
1112
1113 case ROAD_TILE_DEPOT:
1114 break;
1115 }
1116 if (!IsRoadDepot(t) && !HasTownOwnedRoad(t)) {
1117 const Town *town = CalcClosestTownFromTile(t);
1118 if (town != nullptr) SetTownIndex(t, town->index);
1119 }
1120 _m[t].m4 = 0;
1121 break;
1122
1123 case MP_STATION:
1124 if (!IsRoadStop(t)) break;
1125
1126 if (fix_roadtypes) SB(_me[t].m7, 6, 2, (RoadTypes)GB(_m[t].m3, 0, 3));
1127 SB(_me[t].m7, 0, 5, HasBit(_me[t].m6, 2) ? OWNER_TOWN : GetTileOwner(t));
1128 SB(_m[t].m3, 4, 4, _m[t].m1);
1129 _m[t].m4 = 0;
1130 break;
1131
1132 case MP_TUNNELBRIDGE:
1133 if (old_bridge && IsBridge(t) && HasBit(_m[t].m5, 6)) break;
1134 if (((old_bridge && IsBridge(t)) ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) {
1135 if (fix_roadtypes) SB(_me[t].m7, 6, 2, (RoadTypes)GB(_m[t].m3, 0, 3));
1136
1137 Owner o = GetTileOwner(t);
1138 SB(_me[t].m7, 0, 5, o); // road owner
1139 SB(_m[t].m3, 4, 4, o == OWNER_NONE ? OWNER_TOWN : o); // tram owner
1140 }
1141 SB(_me[t].m6, 2, 4, GB(_m[t].m2, 4, 4)); // bridge type
1142 SB(_me[t].m7, 5, 1, GB(_m[t].m4, 7, 1)); // snow/desert
1143
1144 _m[t].m2 = 0;
1145 _m[t].m4 = 0;
1146 break;
1147
1148 default: break;
1149 }
1150 }
1151 }
1152
1153 /* Railtype moved from m3 to m8 in version SLV_EXTEND_RAILTYPES. */
1154 if (IsSavegameVersionBefore(SLV_EXTEND_RAILTYPES)) {
1155 for (TileIndex t = 0; t < map_size; t++) {
1156 switch (GetTileType(t)) {
1157 case MP_RAILWAY:
1158 SetRailType(t, (RailType)GB(_m[t].m3, 0, 4));
1159 break;
1160
1161 case MP_ROAD:
1162 if (IsLevelCrossing(t)) {
1163 SetRailType(t, (RailType)GB(_m[t].m3, 0, 4));
1164 }
1165 break;
1166
1167 case MP_STATION:
1168 if (HasStationRail(t)) {
1169 SetRailType(t, (RailType)GB(_m[t].m3, 0, 4));
1170 }
1171 break;
1172
1173 case MP_TUNNELBRIDGE:
1174 if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) {
1175 SetRailType(t, (RailType)GB(_m[t].m3, 0, 4));
1176 }
1177 break;
1178
1179 default:
1180 break;
1181 }
1182 }
1183 }
1184
1185 if (IsSavegameVersionBefore(SLV_42)) {
1186 for (TileIndex t = 0; t < map_size; t++) {
1187 if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t);
1188 if (IsBridgeTile(t)) {
1189 if (HasBit(_m[t].m5, 6)) { // middle part
1190 Axis axis = (Axis)GB(_m[t].m5, 0, 1);
1191
1192 if (HasBit(_m[t].m5, 5)) { // transport route under bridge?
1193 if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) {
1194 MakeRailNormal(
1195 t,
1196 GetTileOwner(t),
1197 axis == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X,
1198 GetRailType(t)
1199 );
1200 } else {
1201 TownID town = IsTileOwner(t, OWNER_TOWN) ? ClosestTownFromTile(t, UINT_MAX)->index : 0;
1202
1203 /* MakeRoadNormal */
1204 SetTileType(t, MP_ROAD);
1205 _m[t].m2 = town;
1206 _m[t].m3 = 0;
1207 _m[t].m5 = (axis == AXIS_X ? ROAD_Y : ROAD_X) | ROAD_TILE_NORMAL << 6;
1208 SB(_me[t].m6, 2, 4, 0);
1209 _me[t].m7 = 1 << 6;
1210 SetRoadOwner(t, RTT_TRAM, OWNER_NONE);
1211 }
1212 } else {
1213 if (GB(_m[t].m5, 3, 2) == 0) {
1214 MakeClear(t, CLEAR_GRASS, 3);
1215 } else {
1216 if (!IsTileFlat(t)) {
1217 MakeShore(t);
1218 } else {
1219 if (GetTileOwner(t) == OWNER_WATER) {
1220 MakeSea(t);
1221 } else {
1222 MakeCanal(t, GetTileOwner(t), Random());
1223 }
1224 }
1225 }
1226 }
1227 SetBridgeMiddle(t, axis);
1228 } else { // ramp
1229 Axis axis = (Axis)GB(_m[t].m5, 0, 1);
1230 uint north_south = GB(_m[t].m5, 5, 1);
1231 DiagDirection dir = ReverseDiagDir(XYNSToDiagDir(axis, north_south));
1232 TransportType type = (TransportType)GB(_m[t].m5, 1, 2);
1233
1234 _m[t].m5 = 1 << 7 | type << 2 | dir;
1235 }
1236 }
1237 }
1238
1239 for (Vehicle* v : Vehicle::Iterate()) {
1240 if (!v->IsGroundVehicle()) continue;
1241 if (IsBridgeTile(v->tile)) {
1242 DiagDirection dir = GetTunnelBridgeDirection(v->tile);
1243
1244 if (dir != DirToDiagDir(v->direction)) continue;
1245 switch (dir) {
1246 default: SlErrorCorrupt("Invalid vehicle direction");
1247 case DIAGDIR_NE: if ((v->x_pos & 0xF) != 0) continue; break;
1248 case DIAGDIR_SE: if ((v->y_pos & 0xF) != TILE_SIZE - 1) continue; break;
1249 case DIAGDIR_SW: if ((v->x_pos & 0xF) != TILE_SIZE - 1) continue; break;
1250 case DIAGDIR_NW: if ((v->y_pos & 0xF) != 0) continue; break;
1251 }
1252 } else if (v->z_pos > GetSlopePixelZ(v->x_pos, v->y_pos)) {
1253 v->tile = GetNorthernBridgeEnd(v->tile);
1254 v->UpdatePosition();
1255 } else {
1256 continue;
1257 }
1258 if (v->type == VEH_TRAIN) {
1259 Train::From(v)->track = TRACK_BIT_WORMHOLE;
1260 } else {
1261 RoadVehicle::From(v)->state = RVSB_WORMHOLE;
1262 }
1263 }
1264 }
1265
1266 if (IsSavegameVersionBefore(SLV_ROAD_TYPES)) {
1267 /* Add road subtypes */
1268 for (TileIndex t = 0; t < map_size; t++) {
1269 bool has_road = false;
1270 switch (GetTileType(t)) {
1271 case MP_ROAD:
1272 has_road = true;
1273 break;
1274 case MP_STATION:
1275 has_road = IsRoadStop(t);
1276 break;
1277 case MP_TUNNELBRIDGE:
1278 has_road = GetTunnelBridgeTransportType(t) == TRANSPORT_ROAD;
1279 break;
1280 default:
1281 break;
1282 }
1283
1284 if (has_road) {
1285 RoadType road_rt = HasBit(_me[t].m7, 6) ? ROADTYPE_ROAD : INVALID_ROADTYPE;
1286 RoadType tram_rt = HasBit(_me[t].m7, 7) ? ROADTYPE_TRAM : INVALID_ROADTYPE;
1287
1288 assert(road_rt != INVALID_ROADTYPE || tram_rt != INVALID_ROADTYPE);
1289 SetRoadTypes(t, road_rt, tram_rt);
1290 SB(_me[t].m7, 6, 2, 0); // Clear pre-NRT road type bits.
1291 }
1292 }
1293 }
1294
1295 /* Elrails got added in rev 24 */
1296 if (IsSavegameVersionBefore(SLV_24)) {
1297 RailType min_rail = RAILTYPE_ELECTRIC;
1298
1299 for (Train *v : Train::Iterate()) {
1300 RailType rt = RailVehInfo(v->engine_type)->railtype;
1301
1302 v->railtype = rt;
1303 if (rt == RAILTYPE_ELECTRIC) min_rail = RAILTYPE_RAIL;
1304 }
1305
1306 /* .. so we convert the entire map from normal to elrail (so maintain "fairness") */
1307 for (TileIndex t = 0; t < map_size; t++) {
1308 switch (GetTileType(t)) {
1309 case MP_RAILWAY:
1310 SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
1311 break;
1312
1313 case MP_ROAD:
1314 if (IsLevelCrossing(t)) {
1315 SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
1316 }
1317 break;
1318
1319 case MP_STATION:
1320 if (HasStationRail(t)) {
1321 SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
1322 }
1323 break;
1324
1325 case MP_TUNNELBRIDGE:
1326 if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) {
1327 SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
1328 }
1329 break;
1330
1331 default:
1332 break;
1333 }
1334 }
1335
1336 for (Train *v : Train::Iterate()) {
1337 if (v->IsFrontEngine() || v->IsFreeWagon()) v->ConsistChanged(CCF_TRACK);
1338 }
1339
1340 }
1341
1342 /* In version 16.1 of the savegame a company can decide if trains, which get
1343 * replaced, shall keep their old length. In all prior versions, just default
1344 * to false */
1345 if (IsSavegameVersionBefore(SLV_16, 1)) {
1346 for (Company *c : Company::Iterate()) c->settings.renew_keep_length = false;
1347 }
1348
1349 if (IsSavegameVersionBefore(SLV_123)) {
1350 /* Waypoints became subclasses of stations ... */
1351 MoveWaypointsToBaseStations();
1352 /* ... and buoys were moved to waypoints. */
1353 MoveBuoysToWaypoints();
1354 }
1355
1356 /* From version 15, we moved a semaphore bit from bit 2 to bit 3 in m4, making
1357 * room for PBS. Now in version 21 move it back :P. */
1358 if (IsSavegameVersionBefore(SLV_21) && !IsSavegameVersionBefore(SLV_15)) {
1359 for (TileIndex t = 0; t < map_size; t++) {
1360 switch (GetTileType(t)) {
1361 case MP_RAILWAY:
1362 if (HasSignals(t)) {
1363 /* Original signal type/variant was stored in m4 but since saveload
1364 * version 48 they are in m2. The bits has been already moved to m2
1365 * (see the code somewhere above) so don't use m4, use m2 instead. */
1366
1367 /* convert PBS signals to combo-signals */
1368 if (HasBit(_m[t].m2, 2)) SB(_m[t].m2, 0, 2, SIGTYPE_COMBO);
1369
1370 /* move the signal variant back */
1371 SB(_m[t].m2, 2, 1, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC);
1372 ClrBit(_m[t].m2, 3);
1373 }
1374
1375 /* Clear PBS reservation on track */
1376 if (!IsRailDepotTile(t)) {
1377 SB(_m[t].m4, 4, 4, 0);
1378 } else {
1379 ClrBit(_m[t].m3, 6);
1380 }
1381 break;
1382
1383 case MP_STATION: // Clear PBS reservation on station
1384 ClrBit(_m[t].m3, 6);
1385 break;
1386
1387 default: break;
1388 }
1389 }
1390 }
1391
1392 if (IsSavegameVersionBefore(SLV_25)) {
1393 for (RoadVehicle *rv : RoadVehicle::Iterate()) {
1394 rv->vehstatus &= ~0x40;
1395 }
1396 }
1397
1398 if (IsSavegameVersionBefore(SLV_26)) {
1399 for (Station *st : Station::Iterate()) {
1400 st->last_vehicle_type = VEH_INVALID;
1401 }
1402 }
1403
1404 YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK);
1405
1406 if (IsSavegameVersionBefore(SLV_34)) {
1407 for (Company *c : Company::Iterate()) ResetCompanyLivery(c);
1408 }
1409
1410 for (Company *c : Company::Iterate()) {
1411 c->avail_railtypes = GetCompanyRailtypes(c->index);
1412 c->avail_roadtypes = GetCompanyRoadTypes(c->index);
1413 }
1414
1415 AfterLoadStations();
1416
1417 /* Time starts at 0 instead of 1920.
1418 * Account for this in older games by adding an offset */
1419 if (IsSavegameVersionBefore(SLV_31)) {
1420 _date += DAYS_TILL_ORIGINAL_BASE_YEAR;
1421 _cur_year += ORIGINAL_BASE_YEAR;
1422
1423 for (Station *st : Station::Iterate()) st->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
1424 for (Waypoint *wp : Waypoint::Iterate()) wp->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
1425 for (Engine *e : Engine::Iterate()) e->intro_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
1426 for (Company *c : Company::Iterate()) c->inaugurated_year += ORIGINAL_BASE_YEAR;
1427 for (Industry *i : Industry::Iterate()) i->last_prod_year += ORIGINAL_BASE_YEAR;
1428
1429 for (Vehicle *v : Vehicle::Iterate()) {
1430 v->date_of_last_service += DAYS_TILL_ORIGINAL_BASE_YEAR;
1431 v->build_year += ORIGINAL_BASE_YEAR;
1432 }
1433 }
1434
1435 /* From 32 on we save the industry who made the farmland.
1436 * To give this prettiness to old savegames, we remove all farmfields and
1437 * plant new ones. */
1438 if (IsSavegameVersionBefore(SLV_32)) {
1439 for (TileIndex t = 0; t < map_size; t++) {
1440 if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_FIELDS)) {
1441 /* remove fields */
1442 MakeClear(t, CLEAR_GRASS, 3);
1443 }
1444 }
1445
1446 for (Industry *i : Industry::Iterate()) {
1447 uint j;
1448
1449 if (GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_PLANT_ON_BUILT) {
1450 for (j = 0; j != 50; j++) PlantRandomFarmField(i);
1451 }
1452 }
1453 }
1454
1455 /* Setting no refit flags to all orders in savegames from before refit in orders were added */
1456 if (IsSavegameVersionBefore(SLV_36)) {
1457 for (Order *order : Order::Iterate()) {
1458 order->SetRefit(CT_NO_REFIT);
1459 }
1460
1461 for (Vehicle *v : Vehicle::Iterate()) {
1462 v->current_order.SetRefit(CT_NO_REFIT);
1463 }
1464 }
1465
1466 /* from version 38 we have optional elrails, since we cannot know the
1467 * preference of a user, let elrails enabled; it can be disabled manually */
1468 if (IsSavegameVersionBefore(SLV_38)) _settings_game.vehicle.disable_elrails = false;
1469 /* do the same as when elrails were enabled/disabled manually just now */
1470 SettingsDisableElrail(_settings_game.vehicle.disable_elrails);
1471 InitializeRailGUI();
1472
1473 /* From version 53, the map array was changed for house tiles to allow
1474 * space for newhouses grf features. A new byte, m7, was also added. */
1475 if (IsSavegameVersionBefore(SLV_53)) {
1476 for (TileIndex t = 0; t < map_size; t++) {
1477 if (IsTileType(t, MP_HOUSE)) {
1478 if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) {
1479 /* Move the construction stage from m3[7..6] to m5[5..4].
1480 * The construction counter does not have to move. */
1481 SB(_m[t].m5, 3, 2, GB(_m[t].m3, 6, 2));
1482 SB(_m[t].m3, 6, 2, 0);
1483
1484 /* The "house is completed" bit is now in m6[2]. */
1485 SetHouseCompleted(t, false);
1486 } else {
1487 /* The "lift has destination" bit has been moved from
1488 * m5[7] to m7[0]. */
1489 SB(_me[t].m7, 0, 1, HasBit(_m[t].m5, 7));
1490 ClrBit(_m[t].m5, 7);
1491
1492 /* The "lift is moving" bit has been removed, as it does
1493 * the same job as the "lift has destination" bit. */
1494 ClrBit(_m[t].m1, 7);
1495
1496 /* The position of the lift goes from m1[7..0] to m6[7..2],
1497 * making m1 totally free, now. The lift position does not
1498 * have to be a full byte since the maximum value is 36. */
1499 SetLiftPosition(t, GB(_m[t].m1, 0, 6 ));
1500
1501 _m[t].m1 = 0;
1502 _m[t].m3 = 0;
1503 SetHouseCompleted(t, true);
1504 }
1505 }
1506 }
1507 }
1508
1509 /* Check and update house and town values */
1510 UpdateHousesAndTowns();
1511
1512 if (IsSavegameVersionBefore(SLV_43)) {
1513 for (TileIndex t = 0; t < map_size; t++) {
1514 if (IsTileType(t, MP_INDUSTRY)) {
1515 switch (GetIndustryGfx(t)) {
1516 case GFX_POWERPLANT_SPARKS:
1517 _m[t].m3 = GB(_m[t].m1, 2, 5);
1518 break;
1519
1520 case GFX_OILWELL_ANIMATED_1:
1521 case GFX_OILWELL_ANIMATED_2:
1522 case GFX_OILWELL_ANIMATED_3:
1523 _m[t].m3 = GB(_m[t].m1, 0, 2);
1524 break;
1525
1526 case GFX_COAL_MINE_TOWER_ANIMATED:
1527 case GFX_COPPER_MINE_TOWER_ANIMATED:
1528 case GFX_GOLD_MINE_TOWER_ANIMATED:
1529 _m[t].m3 = _m[t].m1;
1530 break;
1531
1532 default: // No animation states to change
1533 break;
1534 }
1535 }
1536 }
1537 }
1538
1539 if (IsSavegameVersionBefore(SLV_45)) {
1540 /* Originally just the fact that some cargo had been paid for was
1541 * stored to stop people cheating and cashing in several times. This
1542 * wasn't enough though as it was cleared when the vehicle started
1543 * loading again, even if it didn't actually load anything, so now the
1544 * amount that has been paid is stored. */
1545 for (Vehicle *v : Vehicle::Iterate()) {
1546 ClrBit(v->vehicle_flags, 2);
1547 }
1548 }
1549
1550 /* Buoys do now store the owner of the previous water tile, which can never
1551 * be OWNER_NONE. So replace OWNER_NONE with OWNER_WATER. */
1552 if (IsSavegameVersionBefore(SLV_46)) {
1553 for (Waypoint *wp : Waypoint::Iterate()) {
1554 if ((wp->facilities & FACIL_DOCK) != 0 && IsTileOwner(wp->xy, OWNER_NONE) && TileHeight(wp->xy) == 0) SetTileOwner(wp->xy, OWNER_WATER);
1555 }
1556 }
1557
1558 if (IsSavegameVersionBefore(SLV_50)) {
1559 /* Aircraft units changed from 8 mph to 1 km-ish/h */
1560 for (Aircraft *v : Aircraft::Iterate()) {
1561 if (v->subtype <= AIR_AIRCRAFT) {
1562 const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type);
1563 v->cur_speed *= 128;
1564 v->cur_speed /= 10;
1565 v->acceleration = avi->acceleration;
1566 }
1567 }
1568 }
1569
1570 if (IsSavegameVersionBefore(SLV_49)) for (Company *c : Company::Iterate()) c->face = ConvertFromOldCompanyManagerFace(c->face);
1571
1572 if (IsSavegameVersionBefore(SLV_52)) {
1573 for (TileIndex t = 0; t < map_size; t++) {
1574 if (IsTileType(t, MP_OBJECT) && _m[t].m5 == OBJECT_STATUE) {
1575 _m[t].m2 = CalcClosestTownFromTile(t)->index;
1576 }
1577 }
1578 }
1579
1580 /* A setting containing the proportion of towns that grow twice as
1581 * fast was added in version 54. From version 56 this is now saved in the
1582 * town as cities can be built specifically in the scenario editor. */
1583 if (IsSavegameVersionBefore(SLV_56)) {
1584 for (Town *t : Town::Iterate()) {
1585 if (_settings_game.economy.larger_towns != 0 && (t->index % _settings_game.economy.larger_towns) == 0) {
1586 t->larger_town = true;
1587 }
1588 }
1589 }
1590
1591 if (IsSavegameVersionBefore(SLV_57)) {
1592 /* Added a FIFO queue of vehicles loading at stations */
1593 for (Vehicle *v : Vehicle::Iterate()) {
1594 if ((v->type != VEH_TRAIN || Train::From(v)->IsFrontEngine()) && // for all locs
1595 !(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed
1596 v->current_order.IsType(OT_LOADING)) { // loading
1597 Station::Get(v->last_station_visited)->loading_vehicles.push_back(v);
1598
1599 /* The loading finished flag is *only* set when actually completely
1600 * finished. Because the vehicle is loading, it is not finished. */
1601 ClrBit(v->vehicle_flags, VF_LOADING_FINISHED);
1602 }
1603 }
1604 } else if (IsSavegameVersionBefore(SLV_59)) {
1605 /* For some reason non-loading vehicles could be in the station's loading vehicle list */
1606
1607 for (Station *st : Station::Iterate()) {
1608 std::list<Vehicle *>::iterator iter;
1609 for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end();) {
1610 Vehicle *v = *iter;
1611 iter++;
1612 if (!v->current_order.IsType(OT_LOADING)) st->loading_vehicles.remove(v);
1613 }
1614 }
1615 }
1616
1617 if (IsSavegameVersionBefore(SLV_58)) {
1618 /* Setting difficulty industry_density other than zero get bumped to +1
1619 * since a new option (very low at position 1) has been added */
1620 if (_settings_game.difficulty.industry_density > 0) {
1621 _settings_game.difficulty.industry_density++;
1622 }
1623
1624 /* Same goes for number of towns, although no test is needed, just an increment */
1625 _settings_game.difficulty.number_towns++;
1626 }
1627
1628 if (IsSavegameVersionBefore(SLV_64)) {
1629 /* Since now we allow different signal types and variants on a single tile.
1630 * Move signal states to m4 to make room and clone the signal type/variant. */
1631 for (TileIndex t = 0; t < map_size; t++) {
1632 if (IsTileType(t, MP_RAILWAY) && HasSignals(t)) {
1633 /* move signal states */
1634 SetSignalStates(t, GB(_m[t].m2, 4, 4));
1635 SB(_m[t].m2, 4, 4, 0);
1636 /* clone signal type and variant */
1637 SB(_m[t].m2, 4, 3, GB(_m[t].m2, 0, 3));
1638 }
1639 }
1640 }
1641
1642 if (IsSavegameVersionBefore(SLV_69)) {
1643 /* In some old savegames a bit was cleared when it should not be cleared */
1644 for (RoadVehicle *rv : RoadVehicle::Iterate()) {
1645 if (rv->state == 250 || rv->state == 251) {
1646 SetBit(rv->state, 2);
1647 }
1648 }
1649 }
1650
1651 if (IsSavegameVersionBefore(SLV_70)) {
1652 /* Added variables to support newindustries */
1653 for (Industry *i : Industry::Iterate()) i->founder = OWNER_NONE;
1654 }
1655
1656 /* From version 82, old style canals (above sealevel (0), WATER owner) are no longer supported.
1657 Replace the owner for those by OWNER_NONE. */
1658 if (IsSavegameVersionBefore(SLV_82)) {
1659 for (TileIndex t = 0; t < map_size; t++) {
1660 if (IsTileType(t, MP_WATER) &&
1661 GetWaterTileType(t) == WATER_TILE_CLEAR &&
1662 GetTileOwner(t) == OWNER_WATER &&
1663 TileHeight(t) != 0) {
1664 SetTileOwner(t, OWNER_NONE);
1665 }
1666 }
1667 }
1668
1669 /*
1670 * Add the 'previous' owner to the ship depots so we can reset it with
1671 * the correct values when it gets destroyed. This prevents that
1672 * someone can remove canals owned by somebody else and it prevents
1673 * making floods using the removal of ship depots.
1674 */
1675 if (IsSavegameVersionBefore(SLV_83)) {
1676 for (TileIndex t = 0; t < map_size; t++) {
1677 if (IsShipDepotTile(t)) {
1678 _m[t].m4 = (TileHeight(t) == 0) ? OWNER_WATER : OWNER_NONE;
1679 }
1680 }
1681 }
1682
1683 if (IsSavegameVersionBefore(SLV_74)) {
1684 for (Station *st : Station::Iterate()) {
1685 for (CargoID c = 0; c < NUM_CARGO; c++) {
1686 st->goods[c].last_speed = 0;
1687 if (st->goods[c].cargo.AvailableCount() != 0) SetBit(st->goods[c].status, GoodsEntry::GES_RATING);
1688 }
1689 }
1690 }
1691
1692 if (IsSavegameVersionBefore(SLV_78)) {
1693 uint j;
1694 for (Industry * i : Industry::Iterate()) {
1695 const IndustrySpec *indsp = GetIndustrySpec(i->type);
1696 for (j = 0; j < lengthof(i->produced_cargo); j++) {
1697 i->produced_cargo[j] = indsp->produced_cargo[j];
1698 }
1699 for (j = 0; j < lengthof(i->accepts_cargo); j++) {
1700 i->accepts_cargo[j] = indsp->accepts_cargo[j];
1701 }
1702 }
1703 }
1704
1705 /* Before version 81, the density of grass was always stored as zero, and
1706 * grassy trees were always drawn fully grassy. Furthermore, trees on rough
1707 * land used to have zero density, now they have full density. Therefore,
1708 * make all grassy/rough land trees have a density of 3. */
1709 if (IsSavegameVersionBefore(SLV_81)) {
1710 for (TileIndex t = 0; t < map_size; t++) {
1711 if (GetTileType(t) == MP_TREES) {
1712 TreeGround groundType = (TreeGround)GB(_m[t].m2, 4, 2);
1713 if (groundType != TREE_GROUND_SNOW_DESERT) SB(_m[t].m2, 6, 2, 3);
1714 }
1715 }
1716 }
1717
1718
1719 if (IsSavegameVersionBefore(SLV_93)) {
1720 /* Rework of orders. */
1721 for (Order *order : Order::Iterate()) order->ConvertFromOldSavegame();
1722
1723 for (Vehicle *v : Vehicle::Iterate()) {
1724 if (v->orders != nullptr && v->orders->GetFirstOrder() != nullptr && v->orders->GetFirstOrder()->IsType(OT_NOTHING)) {
1725 v->orders->FreeChain();
1726 v->orders = nullptr;
1727 }
1728
1729 v->current_order.ConvertFromOldSavegame();
1730 if (v->type == VEH_ROAD && v->IsPrimaryVehicle() && v->FirstShared() == v) {
1731 for (Order *order : v->Orders()) order->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
1732 }
1733 }
1734 } else if (IsSavegameVersionBefore(SLV_94)) {
1735 /* Unload and transfer are now mutual exclusive. */
1736 for (Order *order : Order::Iterate()) {
1737 if ((order->GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
1738 order->SetUnloadType(OUFB_TRANSFER);
1739 order->SetLoadType(OLFB_NO_LOAD);
1740 }
1741 }
1742
1743 for (Vehicle *v : Vehicle::Iterate()) {
1744 if ((v->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
1745 v->current_order.SetUnloadType(OUFB_TRANSFER);
1746 v->current_order.SetLoadType(OLFB_NO_LOAD);
1747 }
1748 }
1749 }
1750
1751 if (IsSavegameVersionBefore(SLV_84)) {
1752 /* Set all share owners to INVALID_COMPANY for
1753 * 1) all inactive companies
1754 * (when inactive companies were stored in the savegame - TTD, TTDP and some
1755 * *really* old revisions of OTTD; else it is already set in InitializeCompanies())
1756 * 2) shares that are owned by inactive companies or self
1757 * (caused by cheating clients in earlier revisions) */
1758 for (Company *c : Company::Iterate()) {
1759 for (auto &share_owner : c->share_owners) {
1760 if (share_owner == INVALID_COMPANY) continue;
1761 if (!Company::IsValidID(share_owner) || share_owner == c->index) share_owner = INVALID_COMPANY;
1762 }
1763 }
1764 }
1765
1766 /* The water class was moved/unified. */
1767 if (IsSavegameVersionBefore(SLV_146)) {
1768 for (TileIndex t = 0; t < map_size; t++) {
1769 switch (GetTileType(t)) {
1770 case MP_STATION:
1771 switch (GetStationType(t)) {
1772 case STATION_OILRIG:
1773 case STATION_DOCK:
1774 case STATION_BUOY:
1775 SetWaterClass(t, (WaterClass)GB(_m[t].m3, 0, 2));
1776 SB(_m[t].m3, 0, 2, 0);
1777 break;
1778
1779 default:
1780 SetWaterClass(t, WATER_CLASS_INVALID);
1781 break;
1782 }
1783 break;
1784
1785 case MP_WATER:
1786 SetWaterClass(t, (WaterClass)GB(_m[t].m3, 0, 2));
1787 SB(_m[t].m3, 0, 2, 0);
1788 break;
1789
1790 case MP_OBJECT:
1791 SetWaterClass(t, WATER_CLASS_INVALID);
1792 break;
1793
1794 default:
1795 /* No water class. */
1796 break;
1797 }
1798 }
1799 }
1800
1801 if (IsSavegameVersionBefore(SLV_86)) {
1802 for (TileIndex t = 0; t < map_size; t++) {
1803 /* Move river flag and update canals to use water class */
1804 if (IsTileType(t, MP_WATER)) {
1805 if (GetWaterClass(t) != WATER_CLASS_RIVER) {
1806 if (IsWater(t)) {
1807 Owner o = GetTileOwner(t);
1808 if (o == OWNER_WATER) {
1809 MakeSea(t);
1810 } else {
1811 MakeCanal(t, o, Random());
1812 }
1813 } else if (IsShipDepot(t)) {
1814 Owner o = (Owner)_m[t].m4; // Original water owner
1815 SetWaterClass(t, o == OWNER_WATER ? WATER_CLASS_SEA : WATER_CLASS_CANAL);
1816 }
1817 }
1818 }
1819 }
1820
1821 /* Update locks, depots, docks and buoys to have a water class based
1822 * on its neighbouring tiles. Done after river and canal updates to
1823 * ensure neighbours are correct. */
1824 for (TileIndex t = 0; t < map_size; t++) {
1825 if (!IsTileFlat(t)) continue;
1826
1827 if (IsTileType(t, MP_WATER) && IsLock(t)) SetWaterClassDependingOnSurroundings(t, false);
1828 if (IsTileType(t, MP_STATION) && (IsDock(t) || IsBuoy(t))) SetWaterClassDependingOnSurroundings(t, false);
1829 }
1830 }
1831
1832 if (IsSavegameVersionBefore(SLV_87)) {
1833 for (TileIndex t = 0; t < map_size; t++) {
1834 /* skip oil rigs at borders! */
1835 if ((IsTileType(t, MP_WATER) || IsBuoyTile(t)) &&
1836 (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1)) {
1837 /* Some version 86 savegames have wrong water class at map borders (under buoy, or after removing buoy).
1838 * This conversion has to be done before buoys with invalid owner are removed. */
1839 SetWaterClass(t, WATER_CLASS_SEA);
1840 }
1841
1842 if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
1843 Owner o = GetTileOwner(t);
1844 if (o < MAX_COMPANIES && !Company::IsValidID(o)) {
1845 Backup<CompanyID> cur_company(_current_company, o, FILE_LINE);
1846 ChangeTileOwner(t, o, INVALID_OWNER);
1847 cur_company.Restore();
1848 }
1849 if (IsBuoyTile(t)) {
1850 /* reset buoy owner to OWNER_NONE in the station struct
1851 * (even if it is owned by active company) */
1852 Waypoint::GetByTile(t)->owner = OWNER_NONE;
1853 }
1854 } else if (IsTileType(t, MP_ROAD)) {
1855 /* works for all RoadTileType */
1856 for (RoadTramType rtt : _roadtramtypes) {
1857 /* update even non-existing road types to update tile owner too */
1858 Owner o = GetRoadOwner(t, rtt);
1859 if (o < MAX_COMPANIES && !Company::IsValidID(o)) SetRoadOwner(t, rtt, OWNER_NONE);
1860 }
1861 if (IsLevelCrossing(t)) {
1862 if (!Company::IsValidID(GetTileOwner(t))) FixOwnerOfRailTrack(t);
1863 }
1864 } else if (IsPlainRailTile(t)) {
1865 if (!Company::IsValidID(GetTileOwner(t))) FixOwnerOfRailTrack(t);
1866 }
1867 }
1868
1869 /* Convert old PF settings to new */
1870 if (_settings_game.pf.yapf.rail_use_yapf || IsSavegameVersionBefore(SLV_28)) {
1871 _settings_game.pf.pathfinder_for_trains = VPF_YAPF;
1872 } else {
1873 _settings_game.pf.pathfinder_for_trains = VPF_NPF;
1874 }
1875
1876 if (_settings_game.pf.yapf.road_use_yapf || IsSavegameVersionBefore(SLV_28)) {
1877 _settings_game.pf.pathfinder_for_roadvehs = VPF_YAPF;
1878 } else {
1879 _settings_game.pf.pathfinder_for_roadvehs = VPF_NPF;
1880 }
1881
1882 if (_settings_game.pf.yapf.ship_use_yapf) {
1883 _settings_game.pf.pathfinder_for_ships = VPF_YAPF;
1884 } else {
1885 _settings_game.pf.pathfinder_for_ships = VPF_NPF;
1886 }
1887 }
1888
1889 if (IsSavegameVersionBefore(SLV_88)) {
1890 /* Profits are now with 8 bit fract */
1891 for (Vehicle *v : Vehicle::Iterate()) {
1892 v->profit_this_year <<= 8;
1893 v->profit_last_year <<= 8;
1894 v->running_ticks = 0;
1895 }
1896 }
1897
1898 if (IsSavegameVersionBefore(SLV_91)) {
1899 /* Increase HouseAnimationFrame from 5 to 7 bits */
1900 for (TileIndex t = 0; t < map_size; t++) {
1901 if (IsTileType(t, MP_HOUSE) && GetHouseType(t) >= NEW_HOUSE_OFFSET) {
1902 SB(_me[t].m6, 2, 6, GB(_me[t].m6, 3, 5));
1903 SB(_m[t].m3, 5, 1, 0);
1904 }
1905 }
1906 }
1907
1908 if (IsSavegameVersionBefore(SLV_62)) {
1909 GroupStatistics::UpdateAfterLoad(); // Ensure statistics pool is initialised before trying to delete vehicles
1910 /* Remove all trams from savegames without tram support.
1911 * There would be trams without tram track under causing crashes sooner or later. */
1912 for (RoadVehicle *v : RoadVehicle::Iterate()) {
1913 if (v->First() == v && HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM)) {
1914 ShowErrorMessage(STR_WARNING_LOADGAME_REMOVED_TRAMS, INVALID_STRING_ID, WL_CRITICAL);
1915 delete v;
1916 }
1917 }
1918 }
1919
1920 if (IsSavegameVersionBefore(SLV_99)) {
1921 for (TileIndex t = 0; t < map_size; t++) {
1922 /* Set newly introduced WaterClass of industry tiles */
1923 if (IsTileType(t, MP_STATION) && IsOilRig(t)) {
1924 SetWaterClassDependingOnSurroundings(t, true);
1925 }
1926 if (IsTileType(t, MP_INDUSTRY)) {
1927 if ((GetIndustrySpec(GetIndustryType(t))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0) {
1928 SetWaterClassDependingOnSurroundings(t, true);
1929 } else {
1930 SetWaterClass(t, WATER_CLASS_INVALID);
1931 }
1932 }
1933
1934 /* Replace "house construction year" with "house age" */
1935 if (IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)) {
1936 _m[t].m5 = Clamp(_cur_year - (_m[t].m5 + ORIGINAL_BASE_YEAR), 0, 0xFF);
1937 }
1938 }
1939 }
1940
1941 /* Move the signal variant back up one bit for PBS. We don't convert the old PBS
1942 * format here, as an old layout wouldn't work properly anyway. To be safe, we
1943 * clear any possible PBS reservations as well. */
1944 if (IsSavegameVersionBefore(SLV_100)) {
1945 for (TileIndex t = 0; t < map_size; t++) {
1946 switch (GetTileType(t)) {
1947 case MP_RAILWAY:
1948 if (HasSignals(t)) {
1949 /* move the signal variant */
1950 SetSignalVariant(t, TRACK_UPPER, HasBit(_m[t].m2, 2) ? SIG_SEMAPHORE : SIG_ELECTRIC);
1951 SetSignalVariant(t, TRACK_LOWER, HasBit(_m[t].m2, 6) ? SIG_SEMAPHORE : SIG_ELECTRIC);
1952 ClrBit(_m[t].m2, 2);
1953 ClrBit(_m[t].m2, 6);
1954 }
1955
1956 /* Clear PBS reservation on track */
1957 if (IsRailDepot(t)) {
1958 SetDepotReservation(t, false);
1959 } else {
1960 SetTrackReservation(t, TRACK_BIT_NONE);
1961 }
1962 break;
1963
1964 case MP_ROAD: // Clear PBS reservation on crossing
1965 if (IsLevelCrossing(t)) SetCrossingReservation(t, false);
1966 break;
1967
1968 case MP_STATION: // Clear PBS reservation on station
1969 if (HasStationRail(t)) SetRailStationReservation(t, false);
1970 break;
1971
1972 case MP_TUNNELBRIDGE: // Clear PBS reservation on tunnels/bridges
1973 if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) SetTunnelBridgeReservation(t, false);
1974 break;
1975
1976 default: break;
1977 }
1978 }
1979 }
1980
1981 /* Reserve all tracks trains are currently on. */
1982 if (IsSavegameVersionBefore(SLV_101)) {
1983 for (const Train *t : Train::Iterate()) {
1984 if (t->First() == t) t->ReserveTrackUnderConsist();
1985 }
1986 }
1987
1988 if (IsSavegameVersionBefore(SLV_103)) {
1989 /* Non-town-owned roads now store the closest town */
1990 UpdateNearestTownForRoadTiles(false);
1991
1992 /* signs with invalid owner left from older savegames */
1993 for (Sign *si : Sign::Iterate()) {
1994 if (si->owner != OWNER_NONE && !Company::IsValidID(si->owner)) si->owner = OWNER_NONE;
1995 }
1996
1997 /* Station can get named based on an industry type, but the current ones
1998 * are not, so mark them as if they are not named by an industry. */
1999 for (Station *st : Station::Iterate()) {
2000 st->indtype = IT_INVALID;
2001 }
2002 }
2003
2004 if (IsSavegameVersionBefore(SLV_104)) {
2005 for (Aircraft *a : Aircraft::Iterate()) {
2006 /* Set engine_type of shadow and rotor */
2007 if (!a->IsNormalAircraft()) {
2008 a->engine_type = a->First()->engine_type;
2009 }
2010 }
2011
2012 /* More companies ... */
2013 for (Company *c : Company::Iterate()) {
2014 if (c->bankrupt_asked == 0xFF) c->bankrupt_asked = 0xFFFF;
2015 }
2016
2017 for (Engine *e : Engine::Iterate()) {
2018 if (e->company_avail == 0xFF) e->company_avail = 0xFFFF;
2019 }
2020
2021 for (Town *t : Town::Iterate()) {
2022 if (t->have_ratings == 0xFF) t->have_ratings = 0xFFFF;
2023 for (uint i = 8; i != MAX_COMPANIES; i++) t->ratings[i] = RATING_INITIAL;
2024 }
2025 }
2026
2027 if (IsSavegameVersionBefore(SLV_112)) {
2028 for (TileIndex t = 0; t < map_size; t++) {
2029 /* Check for HQ bit being set, instead of using map accessor,
2030 * since we've already changed it code-wise */
2031 if (IsTileType(t, MP_OBJECT) && HasBit(_m[t].m5, 7)) {
2032 /* Move size and part identification of HQ out of the m5 attribute,
2033 * on new locations */
2034 _m[t].m3 = GB(_m[t].m5, 0, 5);
2035 _m[t].m5 = OBJECT_HQ;
2036 }
2037 }
2038 }
2039 if (IsSavegameVersionBefore(SLV_144)) {
2040 for (TileIndex t = 0; t < map_size; t++) {
2041 if (!IsTileType(t, MP_OBJECT)) continue;
2042
2043 /* Reordering/generalisation of the object bits. */
2044 ObjectType type = _m[t].m5;
2045 SB(_me[t].m6, 2, 4, type == OBJECT_HQ ? GB(_m[t].m3, 2, 3) : 0);
2046 _m[t].m3 = type == OBJECT_HQ ? GB(_m[t].m3, 1, 1) | GB(_m[t].m3, 0, 1) << 4 : 0;
2047
2048 /* Make sure those bits are clear as well! */
2049 _m[t].m4 = 0;
2050 _me[t].m7 = 0;
2051 }
2052 }
2053
2054 if (IsSavegameVersionBefore(SLV_147) && Object::GetNumItems() == 0) {
2055 /* Make real objects for object tiles. */
2056 for (TileIndex t = 0; t < map_size; t++) {
2057 if (!IsTileType(t, MP_OBJECT)) continue;
2058
2059 if (Town::GetNumItems() == 0) {
2060 /* No towns, so remove all objects! */
2061 DoClearSquare(t);
2062 } else {
2063 uint offset = _m[t].m3;
2064
2065 /* Also move the animation state. */
2066 _m[t].m3 = GB(_me[t].m6, 2, 4);
2067 SB(_me[t].m6, 2, 4, 0);
2068
2069 if (offset == 0) {
2070 /* No offset, so make the object. */
2071 ObjectType type = _m[t].m5;
2072 int size = type == OBJECT_HQ ? 2 : 1;
2073
2074 if (!Object::CanAllocateItem()) {
2075 /* Nice... you managed to place 64k lighthouses and
2076 * antennae on the map... boohoo. */
2077 SlError(STR_ERROR_TOO_MANY_OBJECTS);
2078 }
2079
2080 Object *o = new Object();
2081 o->location.tile = t;
2082 o->location.w = size;
2083 o->location.h = size;
2084 o->build_date = _date;
2085 o->town = type == OBJECT_STATUE ? Town::Get(_m[t].m2) : CalcClosestTownFromTile(t, UINT_MAX);
2086 _m[t].m2 = o->index;
2087 Object::IncTypeCount(type);
2088 } else {
2089 /* We're at an offset, so get the ID from our "root". */
2090 TileIndex northern_tile = t - TileXY(GB(offset, 0, 4), GB(offset, 4, 4));
2091 assert(IsTileType(northern_tile, MP_OBJECT));
2092 _m[t].m2 = _m[northern_tile].m2;
2093 }
2094 }
2095 }
2096 }
2097
2098 if (IsSavegameVersionBefore(SLV_113)) {
2099 /* allow_town_roads is added, set it if town_layout wasn't TL_NO_ROADS */
2100 if (_settings_game.economy.town_layout == 0) { // was TL_NO_ROADS
2101 _settings_game.economy.allow_town_roads = false;
2102 _settings_game.economy.town_layout = TL_BETTER_ROADS;
2103 } else {
2104 _settings_game.economy.allow_town_roads = true;
2105 _settings_game.economy.town_layout = static_cast<TownLayout>(_settings_game.economy.town_layout - 1);
2106 }
2107
2108 /* Initialize layout of all towns. Older versions were using different
2109 * generator for random town layout, use it if needed. */
2110 for (Town *t : Town::Iterate()) {
2111 if (_settings_game.economy.town_layout != TL_RANDOM) {
2112 t->layout = _settings_game.economy.town_layout;
2113 continue;
2114 }
2115
2116 /* Use old layout randomizer code */
2117 byte layout = TileHash(TileX(t->xy), TileY(t->xy)) % 6;
2118 switch (layout) {
2119 default: break;
2120 case 5: layout = 1; break;
2121 case 0: layout = 2; break;
2122 }
2123 t->layout = static_cast<TownLayout>(layout - 1);
2124 }
2125 }
2126
2127 if (IsSavegameVersionBefore(SLV_114)) {
2128 /* There could be (deleted) stations with invalid owner, set owner to OWNER NONE.
2129 * The conversion affects oil rigs and buoys too, but it doesn't matter as
2130 * they have st->owner == OWNER_NONE already. */
2131 for (Station *st : Station::Iterate()) {
2132 if (!Company::IsValidID(st->owner)) st->owner = OWNER_NONE;
2133 }
2134 }
2135
2136 /* Trains could now stop in a specific location. */
2137 if (IsSavegameVersionBefore(SLV_117)) {
2138 for (Order *o : Order::Iterate()) {
2139 if (o->IsType(OT_GOTO_STATION)) o->SetStopLocation(OSL_PLATFORM_FAR_END);
2140 }
2141 }
2142
2143 if (IsSavegameVersionBefore(SLV_120)) {
2144 extern VehicleDefaultSettings _old_vds;
2145 for (Company *c : Company::Iterate()) {
2146 c->settings.vehicle = _old_vds;
2147 }
2148 }
2149
2150 if (IsSavegameVersionBefore(SLV_121)) {
2151 /* Delete small ufos heading for non-existing vehicles */
2152 for (Vehicle *v : DisasterVehicle::Iterate()) {
2153 if (v->subtype == 2 /* ST_SMALL_UFO */ && v->current_order.GetDestination() != 0) {
2154 const Vehicle *u = Vehicle::GetIfValid(v->dest_tile);
2155 if (u == nullptr || u->type != VEH_ROAD || !RoadVehicle::From(u)->IsFrontEngine()) {
2156 delete v;
2157 }
2158 }
2159 }
2160
2161 /* We didn't store cargo payment yet, so make them for vehicles that are
2162 * currently at a station and loading/unloading. If they don't get any
2163 * payment anymore they just removed in the next load/unload cycle.
2164 * However, some 0.7 versions might have cargo payment. For those we just
2165 * add cargopayment for the vehicles that don't have it.
2166 */
2167 for (Station *st : Station::Iterate()) {
2168 std::list<Vehicle *>::iterator iter;
2169 for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ++iter) {
2170 /* There are always as many CargoPayments as Vehicles. We need to make the
2171 * assert() in Pool::GetNew() happy by calling CanAllocateItem(). */
2172 static_assert(CargoPaymentPool::MAX_SIZE == VehiclePool::MAX_SIZE);
2173 assert(CargoPayment::CanAllocateItem());
2174 Vehicle *v = *iter;
2175 if (v->cargo_payment == nullptr) v->cargo_payment = new CargoPayment(v);
2176 }
2177 }
2178 }
2179
2180 if (IsSavegameVersionBefore(SLV_122)) {
2181 /* Animated tiles would sometimes not be actually animated or
2182 * in case of old savegames duplicate. */
2183
2184 extern std::vector<TileIndex> _animated_tiles;
2185
2186 for (auto tile = _animated_tiles.begin(); tile < _animated_tiles.end(); /* Nothing */) {
2187 /* Remove if tile is not animated */
2188 bool remove = _tile_type_procs[GetTileType(*tile)]->animate_tile_proc == nullptr;
2189
2190 /* and remove if duplicate */
2191 for (auto j = _animated_tiles.begin(); !remove && j < tile; j++) {
2192 remove = *tile == *j;
2193 }
2194
2195 if (remove) {
2196 tile = _animated_tiles.erase(tile);
2197 } else {
2198 tile++;
2199 }
2200 }
2201 }
2202
2203 if (IsSavegameVersionBefore(SLV_124) && !IsSavegameVersionBefore(SLV_1)) {
2204 /* The train station tile area was added, but for really old (TTDPatch) it's already valid. */
2205 for (Waypoint *wp : Waypoint::Iterate()) {
2206 if (wp->facilities & FACIL_TRAIN) {
2207 wp->train_station.tile = wp->xy;
2208 wp->train_station.w = 1;
2209 wp->train_station.h = 1;
2210 } else {
2211 wp->train_station.tile = INVALID_TILE;
2212 wp->train_station.w = 0;
2213 wp->train_station.h = 0;
2214 }
2215 }
2216 }
2217
2218 if (IsSavegameVersionBefore(SLV_125)) {
2219 /* Convert old subsidies */
2220 for (Subsidy *s : Subsidy::Iterate()) {
2221 if (s->remaining < 12) {
2222 /* Converting nonawarded subsidy */
2223 s->remaining = 12 - s->remaining; // convert "age" to "remaining"
2224 s->awarded = INVALID_COMPANY; // not awarded to anyone
2225 const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
2226 switch (cs->town_effect) {
2227 case TE_PASSENGERS:
2228 case TE_MAIL:
2229 /* Town -> Town */
2230 s->src_type = s->dst_type = ST_TOWN;
2231 if (Town::IsValidID(s->src) && Town::IsValidID(s->dst)) continue;
2232 break;
2233 case TE_GOODS:
2234 case TE_FOOD:
2235 /* Industry -> Town */
2236 s->src_type = ST_INDUSTRY;
2237 s->dst_type = ST_TOWN;
2238 if (Industry::IsValidID(s->src) && Town::IsValidID(s->dst)) continue;
2239 break;
2240 default:
2241 /* Industry -> Industry */
2242 s->src_type = s->dst_type = ST_INDUSTRY;
2243 if (Industry::IsValidID(s->src) && Industry::IsValidID(s->dst)) continue;
2244 break;
2245 }
2246 } else {
2247 /* Do our best for awarded subsidies. The original source or destination industry
2248 * can't be determined anymore for awarded subsidies, so invalidate them.
2249 * Town -> Town subsidies are converted using simple heuristic */
2250 s->remaining = 24 - s->remaining; // convert "age of awarded subsidy" to "remaining"
2251 const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
2252 switch (cs->town_effect) {
2253 case TE_PASSENGERS:
2254 case TE_MAIL: {
2255 /* Town -> Town */
2256 const Station *ss = Station::GetIfValid(s->src);
2257 const Station *sd = Station::GetIfValid(s->dst);
2258 if (ss != nullptr && sd != nullptr && ss->owner == sd->owner &&
2259 Company::IsValidID(ss->owner)) {
2260 s->src_type = s->dst_type = ST_TOWN;
2261 s->src = ss->town->index;
2262 s->dst = sd->town->index;
2263 s->awarded = ss->owner;
2264 continue;
2265 }
2266 break;
2267 }
2268 default:
2269 break;
2270 }
2271 }
2272 /* Awarded non-town subsidy or invalid source/destination, invalidate */
2273 delete s;
2274 }
2275 }
2276
2277 if (IsSavegameVersionBefore(SLV_126)) {
2278 /* Recompute inflation based on old unround loan limit
2279 * Note: Max loan is 500000. With an inflation of 4% across 170 years
2280 * that results in a max loan of about 0.7 * 2^31.
2281 * So taking the 16 bit fractional part into account there are plenty of bits left
2282 * for unmodified savegames ...
2283 */
2284 uint64 aimed_inflation = (_economy.old_max_loan_unround << 16 | _economy.old_max_loan_unround_fract) / _settings_game.difficulty.max_loan;
2285
2286 /* ... well, just clamp it then. */
2287 if (aimed_inflation > MAX_INFLATION) aimed_inflation = MAX_INFLATION;
2288
2289 /* Simulate the inflation, so we also get the payment inflation */
2290 while (_economy.inflation_prices < aimed_inflation) {
2291 if (AddInflation(false)) break;
2292 }
2293 }
2294
2295 if (IsSavegameVersionBefore(SLV_128)) {
2296 for (const Depot *d : Depot::Iterate()) {
2297 /* At some point, invalid depots were saved into the game (possibly those removed in the past?)
2298 * Remove them here, so they don't cause issues further down the line */
2299 if (!IsDepotTile(d->xy)) {
2300 Debug(sl, 0, "Removing invalid depot {} at {}, {}", d->index, TileX(d->xy), TileY(d->xy));
2301 delete d;
2302 d = nullptr;
2303 continue;
2304 }
2305 _m[d->xy].m2 = d->index;
2306 if (IsTileType(d->xy, MP_WATER)) _m[GetOtherShipDepotTile(d->xy)].m2 = d->index;
2307 }
2308 }
2309
2310 /* The behaviour of force_proceed has been changed. Now
2311 * it counts signals instead of some random time out. */
2312 if (IsSavegameVersionBefore(SLV_131)) {
2313 for (Train *t : Train::Iterate()) {
2314 if (t->force_proceed != TFP_NONE) {
2315 t->force_proceed = TFP_STUCK;
2316 }
2317 }
2318 }
2319
2320 /* The bits for the tree ground and tree density have
2321 * been swapped (m2 bits 7..6 and 5..4. */
2322 if (IsSavegameVersionBefore(SLV_135)) {
2323 for (TileIndex t = 0; t < map_size; t++) {
2324 if (IsTileType(t, MP_CLEAR)) {
2325 if (GetRawClearGround(t) == CLEAR_SNOW) {
2326 SetClearGroundDensity(t, CLEAR_GRASS, GetClearDensity(t));
2327 SetBit(_m[t].m3, 4);
2328 } else {
2329 ClrBit(_m[t].m3, 4);
2330 }
2331 }
2332 if (IsTileType(t, MP_TREES)) {
2333 uint density = GB(_m[t].m2, 6, 2);
2334 uint ground = GB(_m[t].m2, 4, 2);
2335 uint counter = GB(_m[t].m2, 0, 4);
2336 _m[t].m2 = ground << 6 | density << 4 | counter;
2337 }
2338 }
2339 }
2340
2341 /* Wait counter and load/unload ticks got split. */
2342 if (IsSavegameVersionBefore(SLV_136)) {
2343 for (Aircraft *a : Aircraft::Iterate()) {
2344 a->turn_counter = a->current_order.IsType(OT_LOADING) ? 0 : a->load_unload_ticks;
2345 }
2346
2347 for (Train *t : Train::Iterate()) {
2348 t->wait_counter = t->current_order.IsType(OT_LOADING) ? 0 : t->load_unload_ticks;
2349 }
2350 }
2351
2352 /* Airport tile animation uses animation frame instead of other graphics id */
2353 if (IsSavegameVersionBefore(SLV_137)) {
2354 struct AirportTileConversion {
2355 byte old_start;
2356 byte num_frames;
2357 };
2358 static const AirportTileConversion atc[] = {
2359 {31, 12}, // APT_RADAR_GRASS_FENCE_SW
2360 {50, 4}, // APT_GRASS_FENCE_NE_FLAG
2361 {62, 2}, // 1 unused tile
2362 {66, 12}, // APT_RADAR_FENCE_SW
2363 {78, 12}, // APT_RADAR_FENCE_NE
2364 {101, 10}, // 9 unused tiles
2365 {111, 8}, // 7 unused tiles
2366 {119, 15}, // 14 unused tiles (radar)
2367 {140, 4}, // APT_GRASS_FENCE_NE_FLAG_2
2368 };
2369 for (TileIndex t = 0; t < map_size; t++) {
2370 if (IsAirportTile(t)) {
2371 StationGfx old_gfx = GetStationGfx(t);
2372 byte offset = 0;
2373 for (uint i = 0; i < lengthof(atc); i++) {
2374 if (old_gfx < atc[i].old_start) {
2375 SetStationGfx(t, old_gfx - offset);
2376 break;
2377 }
2378 if (old_gfx < atc[i].old_start + atc[i].num_frames) {
2379 SetAnimationFrame(t, old_gfx - atc[i].old_start);
2380 SetStationGfx(t, atc[i].old_start - offset);
2381 break;
2382 }
2383 offset += atc[i].num_frames - 1;
2384 }
2385 }
2386 }
2387 }
2388
2389 if (IsSavegameVersionBefore(SLV_140)) {
2390 for (Station *st : Station::Iterate()) {
2391 if (st->airport.tile != INVALID_TILE) {
2392 st->airport.w = st->airport.GetSpec()->size_x;
2393 st->airport.h = st->airport.GetSpec()->size_y;
2394 }
2395 }
2396 }
2397
2398 if (IsSavegameVersionBefore(SLV_141)) {
2399 for (TileIndex t = 0; t < map_size; t++) {
2400 /* Reset tropic zone for VOID tiles, they shall not have any. */
2401 if (IsTileType(t, MP_VOID)) SetTropicZone(t, TROPICZONE_NORMAL);
2402 }
2403
2404 /* We need to properly number/name the depots.
2405 * The first step is making sure none of the depots uses the
2406 * 'default' names, after that we can assign the names. */
2407 for (Depot *d : Depot::Iterate()) d->town_cn = UINT16_MAX;
2408
2409 for (Depot* d : Depot::Iterate()) MakeDefaultName(d);
2410 }
2411
2412 if (IsSavegameVersionBefore(SLV_142)) {
2413 for (Depot *d : Depot::Iterate()) d->build_date = _date;
2414 }
2415
2416 /* In old versions it was possible to remove an airport while a plane was
2417 * taking off or landing. This gives all kind of problems when building
2418 * another airport in the same station so we don't allow that anymore.
2419 * For old savegames with such aircraft we just throw them in the air and
2420 * treat the aircraft like they were flying already. */
2421 if (IsSavegameVersionBefore(SLV_146)) {
2422 for (Aircraft *v : Aircraft::Iterate()) {
2423 if (!v->IsNormalAircraft()) continue;
2424 Station *st = GetTargetAirportIfValid(v);
2425 if (st == nullptr && v->state != FLYING) {
2426 v->state = FLYING;
2427 UpdateAircraftCache(v);
2428 AircraftNextAirportPos_and_Order(v);
2429 /* get aircraft back on running altitude */
2430 if ((v->vehstatus & VS_CRASHED) == 0) {
2431 GetAircraftFlightLevelBounds(v, &v->z_pos, nullptr);
2432 SetAircraftPosition(v, v->x_pos, v->y_pos, GetAircraftFlightLevel(v));
2433 }
2434 }
2435 }
2436 }
2437
2438 /* Move the animation frame to the same location (m7) for all objects. */
2439 if (IsSavegameVersionBefore(SLV_147)) {
2440 for (TileIndex t = 0; t < map_size; t++) {
2441 switch (GetTileType(t)) {
2442 case MP_HOUSE:
2443 if (GetHouseType(t) >= NEW_HOUSE_OFFSET) {
2444 uint per_proc = _me[t].m7;
2445 _me[t].m7 = GB(_me[t].m6, 2, 6) | (GB(_m[t].m3, 5, 1) << 6);
2446 SB(_m[t].m3, 5, 1, 0);
2447 SB(_me[t].m6, 2, 6, std::min(per_proc, 63U));
2448 }
2449 break;
2450
2451 case MP_INDUSTRY: {
2452 uint rand = _me[t].m7;
2453 _me[t].m7 = _m[t].m3;
2454 _m[t].m3 = rand;
2455 break;
2456 }
2457
2458 case MP_OBJECT:
2459 _me[t].m7 = _m[t].m3;
2460 _m[t].m3 = 0;
2461 break;
2462
2463 default:
2464 /* For stations/airports it's already at m7 */
2465 break;
2466 }
2467 }
2468 }
2469
2470 /* Add (random) colour to all objects. */
2471 if (IsSavegameVersionBefore(SLV_148)) {
2472 for (Object *o : Object::Iterate()) {
2473 Owner owner = GetTileOwner(o->location.tile);
2474 o->colour = (owner == OWNER_NONE) ? Random() & 0xF : Company::Get(owner)->livery->colour1;
2475 }
2476 }
2477
2478 if (IsSavegameVersionBefore(SLV_149)) {
2479 for (TileIndex t = 0; t < map_size; t++) {
2480 if (!IsTileType(t, MP_STATION)) continue;
2481 if (!IsBuoy(t) && !IsOilRig(t) && !(IsDock(t) && IsTileFlat(t))) {
2482 SetWaterClass(t, WATER_CLASS_INVALID);
2483 }
2484 }
2485
2486 /* Waypoints with custom name may have a non-unique town_cn,
2487 * renumber those. First set all affected waypoints to the
2488 * highest possible number to get them numbered in the
2489 * order they have in the pool. */
2490 for (Waypoint *wp : Waypoint::Iterate()) {
2491 if (!wp->name.empty()) wp->town_cn = UINT16_MAX;
2492 }
2493
2494 for (Waypoint* wp : Waypoint::Iterate()) {
2495 if (!wp->name.empty()) MakeDefaultName(wp);
2496 }
2497 }
2498
2499 if (IsSavegameVersionBefore(SLV_152)) {
2500 _industry_builder.Reset(); // Initialize industry build data.
2501
2502 /* The moment vehicles go from hidden to visible changed. This means
2503 * that vehicles don't always get visible anymore causing things to
2504 * get messed up just after loading the savegame. This fixes that. */
2505 for (Vehicle *v : Vehicle::Iterate()) {
2506 /* Not all vehicle types can be inside a tunnel. Furthermore,
2507 * testing IsTunnelTile() for invalid tiles causes a crash. */
2508 if (!v->IsGroundVehicle()) continue;
2509
2510 /* Is the vehicle in a tunnel? */
2511 if (!IsTunnelTile(v->tile)) continue;
2512
2513 /* Is the vehicle actually at a tunnel entrance/exit? */
2514 TileIndex vtile = TileVirtXY(v->x_pos, v->y_pos);
2515 if (!IsTunnelTile(vtile)) continue;
2516
2517 /* Are we actually in this tunnel? Or maybe a lower tunnel? */
2518 if (GetSlopePixelZ(v->x_pos, v->y_pos) != v->z_pos) continue;
2519
2520 /* What way are we going? */
2521 const DiagDirection dir = GetTunnelBridgeDirection(vtile);
2522 const DiagDirection vdir = DirToDiagDir(v->direction);
2523
2524 /* Have we passed the visibility "switch" state already? */
2525 byte pos = (DiagDirToAxis(vdir) == AXIS_X ? v->x_pos : v->y_pos) & TILE_UNIT_MASK;
2526 byte frame = (vdir == DIAGDIR_NE || vdir == DIAGDIR_NW) ? TILE_SIZE - 1 - pos : pos;
2527 extern const byte _tunnel_visibility_frame[DIAGDIR_END];
2528
2529 /* Should the vehicle be hidden or not? */
2530 bool hidden;
2531 if (dir == vdir) { // Entering tunnel
2532 hidden = frame >= _tunnel_visibility_frame[dir];
2533 v->tile = vtile;
2534 } else if (dir == ReverseDiagDir(vdir)) { // Leaving tunnel
2535 hidden = frame < TILE_SIZE - _tunnel_visibility_frame[dir];
2536 /* v->tile changes at the moment when the vehicle leaves the tunnel. */
2537 v->tile = hidden ? GetOtherTunnelBridgeEnd(vtile) : vtile;
2538 } else {
2539 /* We could get here in two cases:
2540 * - for road vehicles, it is reversing at the end of the tunnel
2541 * - it is crashed in the tunnel entry (both train or RV destroyed by UFO)
2542 * Whatever case it is, do not change anything and use the old values.
2543 * Especially changing RV's state would break its reversing in the middle. */
2544 continue;
2545 }
2546
2547 if (hidden) {
2548 v->vehstatus |= VS_HIDDEN;
2549
2550 switch (v->type) {
2551 case VEH_TRAIN: Train::From(v)->track = TRACK_BIT_WORMHOLE; break;
2552 case VEH_ROAD: RoadVehicle::From(v)->state = RVSB_WORMHOLE; break;
2553 default: NOT_REACHED();
2554 }
2555 } else {
2556 v->vehstatus &= ~VS_HIDDEN;
2557
2558 switch (v->type) {
2559 case VEH_TRAIN: Train::From(v)->track = DiagDirToDiagTrackBits(vdir); break;
2560 case VEH_ROAD: RoadVehicle::From(v)->state = DiagDirToDiagTrackdir(vdir); RoadVehicle::From(v)->frame = frame; break;
2561 default: NOT_REACHED();
2562 }
2563 }
2564 }
2565 }
2566
2567 if (IsSavegameVersionBefore(SLV_153)) {
2568 for (RoadVehicle *rv : RoadVehicle::Iterate()) {
2569 if (rv->state == RVSB_IN_DEPOT || rv->state == RVSB_WORMHOLE) continue;
2570
2571 bool loading = rv->current_order.IsType(OT_LOADING) || rv->current_order.IsType(OT_LEAVESTATION);
2572 if (HasBit(rv->state, RVS_IN_ROAD_STOP)) {
2573 extern const byte _road_stop_stop_frame[];
2574 SB(rv->state, RVS_ENTERED_STOP, 1, loading || rv->frame > _road_stop_stop_frame[rv->state - RVSB_IN_ROAD_STOP + (_settings_game.vehicle.road_side << RVS_DRIVE_SIDE)]);
2575 } else if (HasBit(rv->state, RVS_IN_DT_ROAD_STOP)) {
2576 SB(rv->state, RVS_ENTERED_STOP, 1, loading || rv->frame > RVC_DRIVE_THROUGH_STOP_FRAME);
2577 }
2578 }
2579 }
2580
2581 if (IsSavegameVersionBefore(SLV_156)) {
2582 /* The train's pathfinder lost flag got moved. */
2583 for (Train *t : Train::Iterate()) {
2584 if (!HasBit(t->flags, 5)) continue;
2585
2586 ClrBit(t->flags, 5);
2587 SetBit(t->vehicle_flags, VF_PATHFINDER_LOST);
2588 }
2589
2590 /* Introduced terraform/clear limits. */
2591 for (Company *c : Company::Iterate()) {
2592 c->terraform_limit = _settings_game.construction.terraform_frame_burst << 16;
2593 c->clear_limit = _settings_game.construction.clear_frame_burst << 16;
2594 }
2595 }
2596
2597 if (IsSavegameVersionBefore(SLV_158)) {
2598 for (Vehicle *v : Vehicle::Iterate()) {
2599 switch (v->type) {
2600 case VEH_TRAIN: {
2601 Train *t = Train::From(v);
2602
2603 /* Clear old GOINGUP / GOINGDOWN flags.
2604 * It was changed in savegame version 139, but savegame
2605 * version 158 doesn't use these bits, so it doesn't hurt
2606 * to clear them unconditionally. */
2607 ClrBit(t->flags, 1);
2608 ClrBit(t->flags, 2);
2609
2610 /* Clear both bits first. */
2611 ClrBit(t->gv_flags, GVF_GOINGUP_BIT);
2612 ClrBit(t->gv_flags, GVF_GOINGDOWN_BIT);
2613
2614 /* Crashed vehicles can't be going up/down. */
2615 if (t->vehstatus & VS_CRASHED) break;
2616
2617 /* Only X/Y tracks can be sloped. */
2618 if (t->track != TRACK_BIT_X && t->track != TRACK_BIT_Y) break;
2619
2620 t->gv_flags |= FixVehicleInclination(t, t->direction);
2621 break;
2622 }
2623 case VEH_ROAD: {
2624 RoadVehicle *rv = RoadVehicle::From(v);
2625 ClrBit(rv->gv_flags, GVF_GOINGUP_BIT);
2626 ClrBit(rv->gv_flags, GVF_GOINGDOWN_BIT);
2627
2628 /* Crashed vehicles can't be going up/down. */
2629 if (rv->vehstatus & VS_CRASHED) break;
2630
2631 if (rv->state == RVSB_IN_DEPOT || rv->state == RVSB_WORMHOLE) break;
2632
2633 TrackStatus ts = GetTileTrackStatus(rv->tile, TRANSPORT_ROAD, GetRoadTramType(rv->roadtype));
2634 TrackBits trackbits = TrackStatusToTrackBits(ts);
2635
2636 /* Only X/Y tracks can be sloped. */
2637 if (trackbits != TRACK_BIT_X && trackbits != TRACK_BIT_Y) break;
2638
2639 Direction dir = rv->direction;
2640
2641 /* Test if we are reversing. */
2642 Axis a = trackbits == TRACK_BIT_X ? AXIS_X : AXIS_Y;
2643 if (AxisToDirection(a) != dir &&
2644 AxisToDirection(a) != ReverseDir(dir)) {
2645 /* When reversing, the road vehicle is on the edge of the tile,
2646 * so it can be safely compared to the middle of the tile. */
2647 dir = INVALID_DIR;
2648 }
2649
2650 rv->gv_flags |= FixVehicleInclination(rv, dir);
2651 break;
2652 }
2653 case VEH_SHIP:
2654 break;
2655
2656 default:
2657 continue;
2658 }
2659
2660 if (IsBridgeTile(v->tile) && TileVirtXY(v->x_pos, v->y_pos) == v->tile) {
2661 /* In old versions, z_pos was 1 unit lower on bridge heads.
2662 * However, this invalid state could be converted to new savegames
2663 * by loading and saving the game in a new version. */
2664 v->z_pos = GetSlopePixelZ(v->x_pos, v->y_pos);
2665 DiagDirection dir = GetTunnelBridgeDirection(v->tile);
2666 if (v->type == VEH_TRAIN && !(v->vehstatus & VS_CRASHED) &&
2667 v->direction != DiagDirToDir(dir)) {
2668 /* If the train has left the bridge, it shouldn't have
2669 * track == TRACK_BIT_WORMHOLE - this could happen
2670 * when the train was reversed while on the last "tick"
2671 * on the ramp before leaving the ramp to the bridge. */
2672 Train::From(v)->track = DiagDirToDiagTrackBits(dir);
2673 }
2674 }
2675
2676 /* If the vehicle is really above v->tile (not in a wormhole),
2677 * it should have set v->z_pos correctly. */
2678 assert(v->tile != TileVirtXY(v->x_pos, v->y_pos) || v->z_pos == GetSlopePixelZ(v->x_pos, v->y_pos));
2679 }
2680
2681 /* Fill Vehicle::cur_real_order_index */
2682 for (Vehicle *v : Vehicle::Iterate()) {
2683 if (!v->IsPrimaryVehicle()) continue;
2684
2685 /* Older versions are less strict with indices being in range and fix them on the fly */
2686 if (v->cur_implicit_order_index >= v->GetNumOrders()) v->cur_implicit_order_index = 0;
2687
2688 v->cur_real_order_index = v->cur_implicit_order_index;
2689 v->UpdateRealOrderIndex();
2690 }
2691 }
2692
2693 if (IsSavegameVersionBefore(SLV_159)) {
2694 /* If the savegame is old (before version 100), then the value of 255
2695 * for these settings did not mean "disabled". As such everything
2696 * before then did reverse.
2697 * To simplify stuff we disable all turning around or we do not
2698 * disable anything at all. So, if some reversing was disabled we
2699 * will keep reversing disabled, otherwise it'll be turned on. */
2700 _settings_game.pf.reverse_at_signals = IsSavegameVersionBefore(SLV_100) || (_settings_game.pf.wait_oneway_signal != 255 && _settings_game.pf.wait_twoway_signal != 255 && _settings_game.pf.wait_for_pbs_path != 255);
2701
2702 for (Train *t : Train::Iterate()) {
2703 _settings_game.vehicle.max_train_length = std::max<uint8>(_settings_game.vehicle.max_train_length, CeilDiv(t->gcache.cached_total_length, TILE_SIZE));
2704 }
2705 }
2706
2707 if (IsSavegameVersionBefore(SLV_160)) {
2708 /* Setting difficulty industry_density other than zero get bumped to +1
2709 * since a new option (minimal at position 1) has been added */
2710 if (_settings_game.difficulty.industry_density > 0) {
2711 _settings_game.difficulty.industry_density++;
2712 }
2713 }
2714
2715 if (IsSavegameVersionBefore(SLV_161)) {
2716 /* Before savegame version 161, persistent storages were not stored in a pool. */
2717
2718 if (!IsSavegameVersionBefore(SLV_76)) {
2719 for (Industry *ind : Industry::Iterate()) {
2720 assert(ind->psa != nullptr);
2721
2722 /* Check if the old storage was empty. */
2723 bool is_empty = true;
2724 for (uint i = 0; i < sizeof(ind->psa->storage); i++) {
2725 if (ind->psa->GetValue(i) != 0) {
2726 is_empty = false;
2727 break;
2728 }
2729 }
2730
2731 if (!is_empty) {
2732 ind->psa->grfid = _industry_mngr.GetGRFID(ind->type);
2733 } else {
2734 delete ind->psa;
2735 ind->psa = nullptr;
2736 }
2737 }
2738 }
2739
2740 if (!IsSavegameVersionBefore(SLV_145)) {
2741 for (Station *st : Station::Iterate()) {
2742 if (!(st->facilities & FACIL_AIRPORT)) continue;
2743 assert(st->airport.psa != nullptr);
2744
2745 /* Check if the old storage was empty. */
2746 bool is_empty = true;
2747 for (uint i = 0; i < sizeof(st->airport.psa->storage); i++) {
2748 if (st->airport.psa->GetValue(i) != 0) {
2749 is_empty = false;
2750 break;
2751 }
2752 }
2753
2754 if (!is_empty) {
2755 st->airport.psa->grfid = _airport_mngr.GetGRFID(st->airport.type);
2756 } else {
2757 delete st->airport.psa;
2758 st->airport.psa = nullptr;
2759
2760 }
2761 }
2762 }
2763 }
2764
2765 /* This triggers only when old snow_lines were copied into the snow_line_height. */
2766 if (IsSavegameVersionBefore(SLV_164) && _settings_game.game_creation.snow_line_height >= MIN_SNOWLINE_HEIGHT * TILE_HEIGHT) {
2767 _settings_game.game_creation.snow_line_height /= TILE_HEIGHT;
2768 }
2769
2770 if (IsSavegameVersionBefore(SLV_164) && !IsSavegameVersionBefore(SLV_32)) {
2771 /* We store 4 fences in the field tiles instead of only SE and SW. */
2772 for (TileIndex t = 0; t < map_size; t++) {
2773 if (!IsTileType(t, MP_CLEAR) && !IsTileType(t, MP_TREES)) continue;
2774 if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_FIELDS)) continue;
2775 uint fence = GB(_m[t].m4, 5, 3);
2776 if (fence != 0 && IsTileType(TILE_ADDXY(t, 1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(t, 1, 0), CLEAR_FIELDS)) {
2777 SetFence(TILE_ADDXY(t, 1, 0), DIAGDIR_NE, fence);
2778 }
2779 fence = GB(_m[t].m4, 2, 3);
2780 if (fence != 0 && IsTileType(TILE_ADDXY(t, 0, 1), MP_CLEAR) && IsClearGround(TILE_ADDXY(t, 0, 1), CLEAR_FIELDS)) {
2781 SetFence(TILE_ADDXY(t, 0, 1), DIAGDIR_NW, fence);
2782 }
2783 SB(_m[t].m4, 2, 3, 0);
2784 SB(_m[t].m4, 5, 3, 0);
2785 }
2786 }
2787
2788 /* The center of train vehicles was changed, fix up spacing. */
2789 if (IsSavegameVersionBefore(SLV_164)) FixupTrainLengths();
2790
2791 if (IsSavegameVersionBefore(SLV_165)) {
2792 for (Town *t : Town::Iterate()) {
2793 /* Set the default cargo requirement for town growth */
2794 switch (_settings_game.game_creation.landscape) {
2795 case LT_ARCTIC:
2796 if (FindFirstCargoWithTownEffect(TE_FOOD) != nullptr) t->goal[TE_FOOD] = TOWN_GROWTH_WINTER;
2797 break;
2798
2799 case LT_TROPIC:
2800 if (FindFirstCargoWithTownEffect(TE_FOOD) != nullptr) t->goal[TE_FOOD] = TOWN_GROWTH_DESERT;
2801 if (FindFirstCargoWithTownEffect(TE_WATER) != nullptr) t->goal[TE_WATER] = TOWN_GROWTH_DESERT;
2802 break;
2803 }
2804 }
2805 }
2806
2807 if (IsSavegameVersionBefore(SLV_165)) {
2808 /* Adjust zoom level to account for new levels */
2809 _saved_scrollpos_zoom = static_cast<ZoomLevel>(_saved_scrollpos_zoom + ZOOM_LVL_SHIFT);
2810 _saved_scrollpos_x *= ZOOM_LVL_BASE;
2811 _saved_scrollpos_y *= ZOOM_LVL_BASE;
2812 }
2813
2814 /* When any NewGRF has been changed the availability of some vehicles might
2815 * have been changed too. e->company_avail must be set to 0 in that case
2816 * which is done by StartupEngines(). */
2817 if (gcf_res != GLC_ALL_GOOD) StartupEngines();
2818
2819 /* The road owner of standard road stops was not properly accounted for. */
2820 if (IsSavegameVersionBefore(SLV_172)) {
2821 for (TileIndex t = 0; t < map_size; t++) {
2822 if (!IsStandardRoadStopTile(t)) continue;
2823 Owner o = GetTileOwner(t);
2824 SetRoadOwner(t, RTT_ROAD, o);
2825 SetRoadOwner(t, RTT_TRAM, o);
2826 }
2827 }
2828
2829 if (IsSavegameVersionBefore(SLV_175)) {
2830 /* Introduced tree planting limit. */
2831 for (Company *c : Company::Iterate()) c->tree_limit = _settings_game.construction.tree_frame_burst << 16;
2832 }
2833
2834 if (IsSavegameVersionBefore(SLV_177)) {
2835 /* Fix too high inflation rates */
2836 if (_economy.inflation_prices > MAX_INFLATION) _economy.inflation_prices = MAX_INFLATION;
2837 if (_economy.inflation_payment > MAX_INFLATION) _economy.inflation_payment = MAX_INFLATION;
2838
2839 /* We have to convert the quarters of bankruptcy into months of bankruptcy */
2840 for (Company *c : Company::Iterate()) {
2841 c->months_of_bankruptcy = 3 * c->months_of_bankruptcy;
2842 }
2843 }
2844
2845 if (IsSavegameVersionBefore(SLV_178)) {
2846 extern uint8 _old_diff_level;
2847 /* Initialise script settings profile */
2848 _settings_game.script.settings_profile = IsInsideMM(_old_diff_level, SP_BEGIN, SP_END) ? _old_diff_level : (uint)SP_MEDIUM;
2849 }
2850
2851 if (IsSavegameVersionBefore(SLV_182)) {
2852 /* Aircraft acceleration variable was bonkers */
2853 for (Aircraft *v : Aircraft::Iterate()) {
2854 if (v->subtype <= AIR_AIRCRAFT) {
2855 const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type);
2856 v->acceleration = avi->acceleration;
2857 }
2858 }
2859
2860 /* Blocked tiles could be reserved due to a bug, which causes
2861 * other places to assert upon e.g. station reconstruction. */
2862 for (TileIndex t = 0; t < map_size; t++) {
2863 if (HasStationTileRail(t) && IsStationTileBlocked(t)) {
2864 SetRailStationReservation(t, false);
2865 }
2866 }
2867 }
2868
2869 if (IsSavegameVersionBefore(SLV_184)) {
2870 /* The global units configuration is split up in multiple configurations. */
2871 extern uint8 _old_units;
2872 _settings_game.locale.units_velocity = Clamp(_old_units, 0, 2);
2873 _settings_game.locale.units_power = Clamp(_old_units, 0, 2);
2874 _settings_game.locale.units_weight = Clamp(_old_units, 1, 2);
2875 _settings_game.locale.units_volume = Clamp(_old_units, 1, 2);
2876 _settings_game.locale.units_force = 2;
2877 _settings_game.locale.units_height = Clamp(_old_units, 0, 2);
2878 }
2879
2880 if (IsSavegameVersionBefore(SLV_186)) {
2881 /* Move ObjectType from map to pool */
2882 for (TileIndex t = 0; t < map_size; t++) {
2883 if (IsTileType(t, MP_OBJECT)) {
2884 Object *o = Object::Get(_m[t].m2);
2885 o->type = _m[t].m5;
2886 _m[t].m5 = 0; // zero upper bits of (now bigger) ObjectID
2887 }
2888 }
2889 }
2890
2891 /* In version 2.2 of the savegame, we have new airports, so status of all aircraft is reset.
2892 * This has to be called after all map array updates */
2893 if (IsSavegameVersionBefore(SLV_2, 2)) UpdateOldAircraft();
2894
2895 if (IsSavegameVersionBefore(SLV_188)) {
2896 /* Fix articulated road vehicles.
2897 * Some curves were shorter than other curves.
2898 * Now they have the same length, but that means that trailing articulated parts will
2899 * take longer to go through the curve than the parts in front which already left the courve.
2900 * So, make articulated parts catch up. */
2901 bool roadside = _settings_game.vehicle.road_side == 1;
2902 std::vector<uint> skip_frames;
2903 for (RoadVehicle *v : RoadVehicle::Iterate()) {
2904 if (!v->IsFrontEngine()) continue;
2905 skip_frames.clear();
2906 TileIndex prev_tile = v->tile;
2907 uint prev_tile_skip = 0;
2908 uint cur_skip = 0;
2909 for (RoadVehicle *u = v; u != nullptr; u = u->Next()) {
2910 if (u->tile != prev_tile) {
2911 prev_tile_skip = cur_skip;
2912 prev_tile = u->tile;
2913 } else {
2914 cur_skip = prev_tile_skip;
2915 }
2916
2917 uint &this_skip = skip_frames.emplace_back(prev_tile_skip);
2918
2919 /* The following 3 curves now take longer than before */
2920 switch (u->state) {
2921 case 2:
2922 cur_skip++;
2923 if (u->frame <= (roadside ? 9 : 5)) this_skip = cur_skip;
2924 break;
2925
2926 case 4:
2927 cur_skip++;
2928 if (u->frame <= (roadside ? 5 : 9)) this_skip = cur_skip;
2929 break;
2930
2931 case 5:
2932 cur_skip++;
2933 if (u->frame <= (roadside ? 4 : 2)) this_skip = cur_skip;
2934 break;
2935
2936 default:
2937 break;
2938 }
2939 }
2940 while (cur_skip > skip_frames[0]) {
2941 RoadVehicle *u = v;
2942 RoadVehicle *prev = nullptr;
2943 for (uint sf : skip_frames) {
2944 extern bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev);
2945 if (sf >= cur_skip) IndividualRoadVehicleController(u, prev);
2946
2947 prev = u;
2948 u = u->Next();
2949 }
2950 cur_skip--;
2951 }
2952 }
2953 }
2954
2955 if (IsSavegameVersionBefore(SLV_190)) {
2956 for (Order *order : Order::Iterate()) {
2957 order->SetTravelTimetabled(order->GetTravelTime() > 0);
2958 order->SetWaitTimetabled(order->GetWaitTime() > 0);
2959 }
2960 for (OrderList *orderlist : OrderList::Iterate()) {
2961 orderlist->RecalculateTimetableDuration();
2962 }
2963 }
2964
2965 /*
2966 * Only keep order-backups for network clients (and when replaying).
2967 * If we are a network server or not networking, then we just loaded a previously
2968 * saved-by-server savegame. There are no clients with a backup, so clear it.
2969 * Furthermore before savegame version SLV_192 the actual content was always corrupt.
2970 */
2971 if (!_networking || _network_server || IsSavegameVersionBefore(SLV_192)) {
2972 #ifndef DEBUG_DUMP_COMMANDS
2973 /* Note: We cannot use CleanPool since that skips part of the destructor
2974 * and then leaks un-reachable Orders in the order pool. */
2975 for (OrderBackup *ob : OrderBackup::Iterate()) {
2976 delete ob;
2977 }
2978 #endif
2979 }
2980
2981 if (IsSavegameVersionBefore(SLV_198)) {
2982 /* Convert towns growth_rate and grow_counter to ticks */
2983 for (Town *t : Town::Iterate()) {
2984 /* 0x8000 = TOWN_GROWTH_RATE_CUSTOM previously */
2985 if (t->growth_rate & 0x8000) SetBit(t->flags, TOWN_CUSTOM_GROWTH);
2986 if (t->growth_rate != TOWN_GROWTH_RATE_NONE) {
2987 t->growth_rate = TownTicksToGameTicks(t->growth_rate & ~0x8000);
2988 }
2989 /* Add t->index % TOWN_GROWTH_TICKS to spread growth across ticks. */
2990 t->grow_counter = TownTicksToGameTicks(t->grow_counter) + t->index % TOWN_GROWTH_TICKS;
2991 }
2992 }
2993
2994 if (IsSavegameVersionBefore(SLV_EXTEND_INDUSTRY_CARGO_SLOTS)) {
2995 /* Make sure added industry cargo slots are cleared */
2996 for (Industry *i : Industry::Iterate()) {
2997 for (size_t ci = 2; ci < lengthof(i->produced_cargo); ci++) {
2998 i->produced_cargo[ci] = CT_INVALID;
2999 i->produced_cargo_waiting[ci] = 0;
3000 i->production_rate[ci] = 0;
3001 i->last_month_production[ci] = 0;
3002 i->last_month_transported[ci] = 0;
3003 i->last_month_pct_transported[ci] = 0;
3004 i->this_month_production[ci] = 0;
3005 i->this_month_transported[ci] = 0;
3006 }
3007 for (size_t ci = 3; ci < lengthof(i->accepts_cargo); ci++) {
3008 i->accepts_cargo[ci] = CT_INVALID;
3009 i->incoming_cargo_waiting[ci] = 0;
3010 }
3011 /* Make sure last_cargo_accepted_at is copied to elements for every valid input cargo.
3012 * The loading routine should put the original singular value into the first array element. */
3013 for (size_t ci = 0; ci < lengthof(i->accepts_cargo); ci++) {
3014 if (i->accepts_cargo[ci] != CT_INVALID) {
3015 i->last_cargo_accepted_at[ci] = i->last_cargo_accepted_at[0];
3016 } else {
3017 i->last_cargo_accepted_at[ci] = 0;
3018 }
3019 }
3020 }
3021 }
3022
3023 if (IsSavegameVersionBefore(SLV_SHIPS_STOP_IN_LOCKS)) {
3024 /* Move ships from lock slope to upper or lower position. */
3025 for (Ship *s : Ship::Iterate()) {
3026 /* Suitable tile? */
3027 if (!IsTileType(s->tile, MP_WATER) || !IsLock(s->tile) || GetLockPart(s->tile) != LOCK_PART_MIDDLE) continue;
3028
3029 /* We don't need to adjust position when at the tile centre */
3030 int x = s->x_pos & 0xF;
3031 int y = s->y_pos & 0xF;
3032 if (x == 8 && y == 8) continue;
3033
3034 /* Test if ship is on the second half of the tile */
3035 bool second_half;
3036 DiagDirection shipdiagdir = DirToDiagDir(s->direction);
3037 switch (shipdiagdir) {
3038 default: NOT_REACHED();
3039 case DIAGDIR_NE: second_half = x < 8; break;
3040 case DIAGDIR_NW: second_half = y < 8; break;
3041 case DIAGDIR_SW: second_half = x > 8; break;
3042 case DIAGDIR_SE: second_half = y > 8; break;
3043 }
3044
3045 DiagDirection slopediagdir = GetInclinedSlopeDirection(GetTileSlope(s->tile));
3046
3047 /* Heading up slope == passed half way */
3048 if ((shipdiagdir == slopediagdir) == second_half) {
3049 /* On top half of lock */
3050 s->z_pos = GetTileMaxZ(s->tile) * (int)TILE_HEIGHT;
3051 } else {
3052 /* On lower half of lock */
3053 s->z_pos = GetTileZ(s->tile) * (int)TILE_HEIGHT;
3054 }
3055 }
3056 }
3057
3058 if (IsSavegameVersionBefore(SLV_TOWN_CARGOGEN)) {
3059 /* Ensure the original cargo generation mode is used */
3060 _settings_game.economy.town_cargogen_mode = TCGM_ORIGINAL;
3061 }
3062
3063 if (IsSavegameVersionBefore(SLV_SERVE_NEUTRAL_INDUSTRIES)) {
3064 /* Ensure the original neutral industry/station behaviour is used */
3065 _settings_game.station.serve_neutral_industries = true;
3066
3067 /* Link oil rigs to their industry and back. */
3068 for (Station *st : Station::Iterate()) {
3069 if (IsTileType(st->xy, MP_STATION) && IsOilRig(st->xy)) {
3070 /* Industry tile is always adjacent during construction by TileDiffXY(0, 1) */
3071 st->industry = Industry::GetByTile(st->xy + TileDiffXY(0, 1));
3072 st->industry->neutral_station = st;
3073 }
3074 }
3075 } else {
3076 /* Link neutral station back to industry, as this is not saved. */
3077 for (Industry *ind : Industry::Iterate()) if (ind->neutral_station != nullptr) ind->neutral_station->industry = ind;
3078 }
3079
3080 if (IsSavegameVersionBefore(SLV_TREES_WATER_CLASS)) {
3081 /* Update water class for trees. */
3082 for (TileIndex t = 0; t < map_size; t++) {
3083 if (IsTileType(t, MP_TREES)) SetWaterClass(t, GetTreeGround(t) == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID);
3084 }
3085 }
3086
3087 /* Update structures for multitile docks */
3088 if (IsSavegameVersionBefore(SLV_MULTITILE_DOCKS)) {
3089 for (TileIndex t = 0; t < map_size; t++) {
3090 /* Clear docking tile flag from relevant tiles as it
3091 * was not previously cleared. */
3092 if (IsTileType(t, MP_WATER) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE)) {
3093 SetDockingTile(t, false);
3094 }
3095 /* Add docks and oilrigs to Station::ship_station. */
3096 if (IsTileType(t, MP_STATION)) {
3097 if (IsDock(t) || IsOilRig(t)) Station::GetByTile(t)->ship_station.Add(t);
3098 }
3099 }
3100 }
3101
3102 if (IsSavegameVersionBefore(SLV_REPAIR_OBJECT_DOCKING_TILES)) {
3103 /* Placing objects on docking tiles was not updating adjacent station's docking tiles. */
3104 for (Station *st : Station::Iterate()) {
3105 if (st->ship_station.tile != INVALID_TILE) UpdateStationDockingTiles(st);
3106 }
3107 }
3108
3109 if (IsSavegameVersionBeforeOrAt(SLV_ENDING_YEAR)) {
3110 /* Reset roadtype/streetcartype info for non-road bridges. */
3111 for (TileIndex t = 0; t < map_size; t++) {
3112 if (IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) != TRANSPORT_ROAD) {
3113 SetRoadTypes(t, INVALID_ROADTYPE, INVALID_ROADTYPE);
3114 }
3115 }
3116 }
3117
3118 /* Make sure all industries exclusive supplier/consumer set correctly. */
3119 if (IsSavegameVersionBefore(SLV_GS_INDUSTRY_CONTROL)) {
3120 for (Industry *i : Industry::Iterate()) {
3121 i->exclusive_supplier = INVALID_OWNER;
3122 i->exclusive_consumer = INVALID_OWNER;
3123 }
3124 }
3125
3126 if (IsSavegameVersionBefore(SLV_GROUP_REPLACE_WAGON_REMOVAL)) {
3127 /* Propagate wagon removal flag for compatibility */
3128 /* Temporary bitmask of company wagon removal setting */
3129 uint16 wagon_removal = 0;
3130 for (const Company *c : Company::Iterate()) {
3131 if (c->settings.renew_keep_length) SetBit(wagon_removal, c->index);
3132 }
3133 for (Group *g : Group::Iterate()) {
3134 if (g->flags != 0) {
3135 /* Convert old replace_protection value to flag. */
3136 g->flags = 0;
3137 SetBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION);
3138 }
3139 if (HasBit(wagon_removal, g->owner)) SetBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL);
3140 }
3141 }
3142
3143 /* Use current order time to approximate last loading time */
3144 if (IsSavegameVersionBefore(SLV_LAST_LOADING_TICK)) {
3145 for (Vehicle *v : Vehicle::Iterate()) {
3146 v->last_loading_tick = std::max(_tick_counter, static_cast<uint64>(v->current_order_time)) - v->current_order_time;
3147 }
3148 }
3149
3150 /* Road stops is 'only' updating some caches, but they are needed for PF calls in SLV_MULTITRACK_LEVEL_CROSSINGS teleporting. */
3151 AfterLoadRoadStops();
3152
3153 /* Road vehicles stopped on multitrack level crossings need teleporting to a depot
3154 * to avoid crashing into the side of the train they're waiting for. */
3155 if (IsSavegameVersionBefore(SLV_MULTITRACK_LEVEL_CROSSINGS)) {
3156 /* Teleport road vehicles to the nearest depot. */
3157 for (RoadVehicle *rv : RoadVehicle::Iterate()) {
3158 /* Ignore trailers of articulated vehicles. */
3159 if (rv->IsArticulatedPart()) continue;
3160
3161 /* Ignore moving vehicles. */
3162 if (rv->cur_speed > 0) continue;
3163
3164 /* Ignore crashed vehicles. */
3165 if (rv->vehstatus & VS_CRASHED) continue;
3166
3167 /* Ignore vehicles not on level crossings. */
3168 TileIndex cur_tile = rv->tile;
3169 if (!IsLevelCrossingTile(cur_tile)) continue;
3170
3171 TileIndex location;
3172 DestinationID destination;
3173 bool reverse = true;
3174
3175 /* Try to find a depot with a distance limit of 512 tiles (Manhattan distance). */
3176 if (rv->FindClosestDepot(&location, &destination, &reverse) && DistanceManhattan(rv->tile, location) < 512u) {
3177 /* Teleport all parts of articulated vehicles. */
3178 for (RoadVehicle *u = rv; u != nullptr; u = u->Next()) {
3179 u->tile = location;
3180 int x = TileX(location) * TILE_SIZE + TILE_SIZE / 2;
3181 int y = TileY(location) * TILE_SIZE + TILE_SIZE / 2;
3182 u->x_pos = x;
3183 u->y_pos = y;
3184 u->z_pos = GetSlopePixelZ(x, y);
3185
3186 u->vehstatus |= VS_HIDDEN;
3187 u->state = RVSB_IN_DEPOT;
3188 u->UpdatePosition();
3189 }
3190 RoadVehLeaveDepot(rv, false);
3191 }
3192 }
3193
3194 /* Refresh all level crossings to bar adjacent crossing tiles, if needed. */
3195 for (TileIndex tile = 0; tile < MapSize(); tile++) {
3196 if (IsLevelCrossingTile(tile)) UpdateLevelCrossing(tile, false);
3197 }
3198 }
3199
3200 /* Compute station catchment areas. This is needed here in case UpdateStationAcceptance is called below. */
3201 Station::RecomputeCatchmentForAll();
3202
3203 /* Station acceptance is some kind of cache */
3204 if (IsSavegameVersionBefore(SLV_127)) {
3205 for (Station *st : Station::Iterate()) UpdateStationAcceptance(st, false);
3206 }
3207
3208 AfterLoadLabelMaps();
3209 AfterLoadCompanyStats();
3210 AfterLoadStoryBook();
3211
3212 GamelogPrintDebug(1);
3213
3214 InitializeWindowsAndCaches();
3215 /* Restore the signals */
3216 ResetSignalHandlers();
3217
3218 AfterLoadLinkGraphs();
3219
3220 /* Start the scripts. This MUST happen after everything else except
3221 * starting a new company. */
3222 StartScripts();
3223
3224 /* If Load Scenario / New (Scenario) Game is used,
3225 * a company does not exist yet. So create one here.
3226 * 1 exception: network-games. Those can have 0 companies
3227 * But this exception is not true for non-dedicated network servers! */
3228 if (!_networking || (_networking && _network_server && !_network_dedicated)) {
3229 CompanyID first_human_company = GetFirstPlayableCompanyID();
3230 if (!Company::IsValidID(first_human_company)) {
3231 Company *c = DoStartupNewCompany(false, first_human_company);
3232 c->settings = _settings_client.company;
3233 }
3234 }
3235
3236 return true;
3237 }
3238
3247 void ReloadNewGRFData()
3248 {
3249 /* reload grf data */
3250 GfxLoadSprites();
3251 LoadStringWidthTable();
3252 RecomputePrices();
3253 /* reload vehicles */
3254 ResetVehicleHash();
3255 AfterLoadVehicles(false);
3256 StartupEngines();
3257 GroupStatistics::UpdateAfterLoad();
3258 /* update station graphics */
3259 AfterLoadStations();
3260 /* Update company statistics. */
3261 AfterLoadCompanyStats();
3262 /* Check and update house and town values */
3263 UpdateHousesAndTowns();
3264 /* Delete news referring to no longer existing entities */
3265 DeleteInvalidEngineNews();
3266 /* Update livery selection windows */
3267 for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) InvalidateWindowData(WC_COMPANY_COLOUR, i);
3268 /* Update company infrastructure counts. */
3269 InvalidateWindowClassesData(WC_COMPANY_INFRASTRUCTURE);
3270 /* redraw the whole screen */
3271 MarkWholeScreenDirty();
3272 CheckTrainsLengths();
3273 }
LoadStringWidthTable
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
Definition: gfx.cpp:1446
SLV_131
@ SLV_131
131 18481
Definition: saveload.h:204
RoadVehicle
Buses, trucks and trams belong to this class.
Definition: roadveh.h:107
MP_CLEAR
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
Definition: tile_type.h:48
MP_HOUSE
@ MP_HOUSE
A house by a town.
Definition: tile_type.h:51
IsTileFlat
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
Definition: tile_map.cpp:100
IsTunnelTile
static bool IsTunnelTile(TileIndex t)
Is this a tunnel (entrance)?
Definition: tunnel_map.h:34
TRACK_BIT_WORMHOLE
@ TRACK_BIT_WORMHOLE
Bitflag for a wormhole (used for tunnels)
Definition: track_type.h:55
DIAGDIR_SE
@ DIAGDIR_SE
Southeast.
Definition: direction_type.h:80
HasTownOwnedRoad
static bool HasTownOwnedRoad(TileIndex t)
Checks if given tile has town owned road.
Definition: road_map.h:280
BuildOwnerLegend
void BuildOwnerLegend()
Completes the array for the owned property legend.
Definition: smallmap_gui.cpp:326
CLEAR_SNOW
@ CLEAR_SNOW
0-3
Definition: clear_map.h:24
SLV_186
@ SLV_186
186 25833 Objects storage
Definition: saveload.h:270
SLV_69
@ SLV_69
69 10319
Definition: saveload.h:129
RoadVehicle::state
byte state
Definition: roadveh.h:109
Economy::inflation_prices
uint64 inflation_prices
Cumulated inflation of prices since game start; 16 bit fractional part.
Definition: economy_type.h:36
InvalidateWindowData
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Definition: window.cpp:3254
DIR_SW
@ DIR_SW
Southwest.
Definition: direction_type.h:31
IsInsideMM
static constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Definition: math_func.hpp:230
AfterLoadGame
bool AfterLoadGame()
Perform a (large) amount of savegame conversion magic in order to load older savegames and to fill th...
Definition: afterload.cpp:563
SLV_144
@ SLV_144
144 20334
Definition: saveload.h:219
AXIS_Y
@ AXIS_Y
The y axis.
Definition: direction_type.h:127
TRACK_BIT_NONE
@ TRACK_BIT_NONE
No track.
Definition: track_type.h:39
PathfinderSettings::wait_for_pbs_path
byte wait_for_pbs_path
how long to wait for a path reservation.
Definition: settings_type.h:469
AircraftNextAirportPos_and_Order
void AircraftNextAirportPos_and_Order(Aircraft *v)
set the right pos when heading to other airports after takeoff
Definition: aircraft_cmd.cpp:1435
AxisToDirection
static Direction AxisToDirection(Axis a)
Converts an Axis to a Direction.
Definition: direction_func.h:249
OUFB_UNLOAD
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
Definition: order_type.h:54
StationGfx
byte StationGfx
Copy from station_map.h.
Definition: newgrf_airport.h:20
SetSaveLoadError
void SetSaveLoadError(StringID str)
Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friend...
Definition: saveload.cpp:2938
VehicleSettings::roadveh_slope_steepness
uint8 roadveh_slope_steepness
Steepness of hills for road vehicles when using realistic acceleration.
Definition: settings_type.h:492
FT_SCENARIO
@ FT_SCENARIO
old or new scenario
Definition: fileio_type.h:19
PathfinderSettings::pathfinder_for_roadvehs
uint8 pathfinder_for_roadvehs
the pathfinder to use for roadvehicles
Definition: settings_type.h:457
Order::IsType
bool IsType(OrderType type) const
Check whether this order is of the given type.
Definition: order_base.h:71
Pool::PoolItem<&_town_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
SLV_43
@ SLV_43
43 7642
Definition: saveload.h:98
SLV_114
@ SLV_114
114 15601
Definition: saveload.h:183
TileOffsByDiagDir
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:341
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:24
GameSettings::station
StationSettings station
settings related to station management
Definition: settings_type.h:598
MIN_SNOWLINE_HEIGHT
static const uint MIN_SNOWLINE_HEIGHT
Minimum snowline height.
Definition: tile_type.h:32
GetOtherShipDepotTile
static TileIndex GetOtherShipDepotTile(TileIndex t)
Get the other tile of the ship depot.
Definition: water_map.h:283
Vehicle::y_pos
int32 y_pos
y coordinate.
Definition: vehicle_base.h:284
IsRoadStop
static bool IsRoadStop(TileIndex t)
Is the station at t a road station?
Definition: station_map.h:202
GetTileMaxZ
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
Definition: tile_map.cpp:141
SLV_62
@ SLV_62
62 9905
Definition: saveload.h:121
GF_REPLACE_PROTECTION
@ GF_REPLACE_PROTECTION
If set to true, the global autoreplace has no effect on the group.
Definition: group.h:68
SLV_TREES_WATER_CLASS
@ SLV_TREES_WATER_CLASS
213 PR#7405 WaterClass update for tree tiles.
Definition: saveload.h:303
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
Economy::inflation_payment
uint64 inflation_payment
Cumulated inflation of cargo payment since game start; 16 bit fractional part.
Definition: economy_type.h:37
VehicleSettings::train_acceleration_model
uint8 train_acceleration_model
realistic acceleration for trains
Definition: settings_type.h:489
Vehicle::x_pos
int32 x_pos
x coordinate.
Definition: vehicle_base.h:283
HandleSavegameLoadCrash
static void CDECL HandleSavegameLoadCrash(int signum)
Signal handler used to give a user a more useful report for crashes during the savegame loading proce...
Definition: afterload.cpp:376
GetIndustryGfx
static IndustryGfx GetIndustryGfx(TileIndex t)
Get the industry graphics ID for the given industry tile.
Definition: industry_map.h:137
GLAT_LOAD
@ GLAT_LOAD
Game loaded.
Definition: gamelog.h:18
DIR_SE
@ DIR_SE
Southeast.
Definition: direction_type.h:29
YapfNotifyTrackLayoutChange
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.
Definition: yapf_rail.cpp:644
_tile_type_procs
const TileTypeProcs *const _tile_type_procs[16]
Tile callback functions for each type of tile.
Definition: landscape.cpp:64
SLV_ROAD_TYPES
@ SLV_ROAD_TYPES
214 PR#6811 NewGRF road types.
Definition: saveload.h:304
GLC_COMPATIBLE
@ GLC_COMPATIBLE
Compatible (eg. the same ID, but different checksum) GRF found in at least one case.
Definition: newgrf_config.h:54
EconomySettings::town_layout
TownLayout town_layout
select town layout,
Definition: settings_type.h:526
SLV_133
@ SLV_133
133 18674
Definition: saveload.h:206
PathfinderSettings::forbid_90_deg
bool forbid_90_deg
forbid trains to make 90 deg turns
Definition: settings_type.h:462
Pool::PoolItem<&_company_pool >::GetIfValid
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:348
SP_END
@ SP_END
End of setting profiles.
Definition: settings_type.h:43
InitializeWindowsAndCaches
static void InitializeWindowsAndCaches()
Initialization of the windows and several kinds of caches.
Definition: afterload.cpp:243
SLV_106
@ SLV_106
106 14919
Definition: saveload.h:174
ClosestTownFromTile
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
Definition: town_cmd.cpp:3594
ScriptSettings::settings_profile
uint8 settings_profile
difficulty profile to set initial settings of scripts, esp. random AIs
Definition: settings_type.h:379
ROAD_TILE_CROSSING
@ ROAD_TILE_CROSSING
Level crossing.
Definition: road_map.h:24
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:328
Backup
Class to backup a specific variable and restore it later.
Definition: backup_type.hpp:21
AfterLoadRoadStops
void AfterLoadRoadStops()
(Re)building of road stop caches after loading a savegame.
Definition: station_sl.cpp:131
TE_GOODS
@ TE_GOODS
Cargo behaves goods/candy-like.
Definition: cargotype.h:31
SetTileType
static void SetTileType(TileIndex tile, TileType type)
Set the type of a tile.
Definition: tile_map.h:131
SLV_32
@ SLV_32
32 6001
Definition: saveload.h:85
_cur_year
Year _cur_year
Current year, starting at 0.
Definition: date.cpp:26
SpecializedVehicle::Next
T * Next() const
Get next vehicle in the chain.
Definition: vehicle_base.h:1098
SetWaterClassDependingOnSurroundings
void SetWaterClassDependingOnSurroundings(TileIndex t, bool include_invalid_water_class)
Makes a tile canal or water depending on the surroundings.
Definition: afterload.cpp:80
OUFB_TRANSFER
@ OUFB_TRANSFER
Transfer all cargo onto the platform.
Definition: order_type.h:55
BaseStation::town
Town * town
The town this station is associated with.
Definition: base_station_base.h:61
WC_COMPANY_COLOUR
@ WC_COMPANY_COLOUR
Company colour selection; Window numbers:
Definition: window_type.h:223
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:125
CargoSpec::town_effect
TownEffect town_effect
The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
Definition: cargotype.h:68
Station
Station data structure.
Definition: station_base.h:454
BaseStation::GetByTile
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
Definition: base_station_base.h:154
SLV_178
@ SLV_178
178 24789
Definition: saveload.h:260
SLV_124
@ SLV_124
124 16993
Definition: saveload.h:195
IsHouseCompleted
static bool IsHouseCompleted(TileIndex t)
Get the completion of this house.
Definition: town_map.h:145
SetTrackReservation
static void SetTrackReservation(TileIndex t, TrackBits b)
Sets the reserved track bits of the tile.
Definition: rail_map.h:209
_date_fract
DateFract _date_fract
Fractional part of the day.
Definition: date.cpp:29
SLV_112
@ SLV_112
112 15290
Definition: saveload.h:181
IsAirportTile
static bool IsAirportTile(TileIndex t)
Is this tile a station tile and an airport tile?
Definition: station_map.h:167
SLV_GROUP_REPLACE_WAGON_REMOVAL
@ SLV_GROUP_REPLACE_WAGON_REMOVAL
291 PR#7441 Per-group wagon removal flag.
Definition: saveload.h:333
DIR_NW
@ DIR_NW
Northwest.
Definition: direction_type.h:33
_network_server
bool _network_server
network-server is active
Definition: network.cpp:59
Object::location
TileArea location
Location of the object.
Definition: object_base.h:26
SLV_49
@ SLV_49
49 8969
Definition: saveload.h:105
DifficultySettings::max_loan
uint32 max_loan
the maximum initial loan
Definition: settings_type.h:81
TRACK_LOWER
@ TRACK_LOWER
Track in the lower corner of the tile (south)
Definition: track_type.h:24
SLV_146
@ SLV_146
146 20446
Definition: saveload.h:222
SLV_198
@ SLV_198
198 PR#6763 Switch town growth rate and counter to actual game ticks
Definition: saveload.h:285
DiagDirToAxis
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
Definition: direction_func.h:214
SLV_117
@ SLV_117
117 16037
Definition: saveload.h:187
MakeSea
static void MakeSea(TileIndex t)
Make a sea tile.
Definition: water_map.h:425
GetIndustryType
IndustryType GetIndustryType(TileIndex tile)
Retrieve the type for this industry.
Definition: industry_cmd.cpp:106
SIG_SEMAPHORE
@ SIG_SEMAPHORE
Old-fashioned semaphore signal.
Definition: signal_type.h:18
SetRailStationReservation
static void SetRailStationReservation(TileIndex t, bool b)
Set the reservation state of the rail station.
Definition: station_map.h:405
ConstructionSettings::map_height_limit
uint8 map_height_limit
the maximum allowed heightlevel
Definition: settings_type.h:342
_gamelog_actions
uint _gamelog_actions
number of actions
Definition: gamelog.cpp:36
Vehicle::vehstatus
byte vehstatus
Status.
Definition: vehicle_base.h:332
TL_RANDOM
@ TL_RANDOM
Random town layout.
Definition: town_type.h:87
DIAGDIR_END
@ DIAGDIR_END
Used for iterations.
Definition: direction_type.h:83
MakeClear
static void MakeClear(TileIndex t, ClearGround g, uint density)
Make a clear tile.
Definition: clear_map.h:259
VPF_YAPF
@ VPF_YAPF
Yet Another PathFinder.
Definition: vehicle_type.h:61
TOWN_GROWTH_TICKS
static const int TOWN_GROWTH_TICKS
cycle duration for towns trying to grow. (this originates from the size of the town array in TTD
Definition: date_type.h:38
SLV_96
@ SLV_96
96 13226
Definition: saveload.h:162
_old_vds
VehicleDefaultSettings _old_vds
Used for loading default vehicles settings from old savegames.
Definition: settings.cpp:56
TREE_GROUND_SHORE
@ TREE_GROUND_SHORE
shore
Definition: tree_map.h:56
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
RVSB_IN_ROAD_STOP
@ RVSB_IN_ROAD_STOP
The vehicle is in a road stop.
Definition: roadveh.h:50
CargoSpec::Get
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
Definition: cargotype.h:118
SLV_166
@ SLV_166
166 23415
Definition: saveload.h:246
LinkGraphSettings::distribution_mail
DistributionType distribution_mail
distribution type for mail
Definition: settings_type.h:540
SLV_56
@ SLV_56
56 9667
Definition: saveload.h:114
EconomySettings::larger_towns
uint8 larger_towns
the number of cities to build. These start off larger and grow twice as fast
Definition: settings_type.h:524
SLV_84
@ SLV_84
84 11822
Definition: saveload.h:147
SLV_93
@ SLV_93
93 12648
Definition: saveload.h:158
SetDate
void SetDate(Date date, DateFract fract)
Set the date.
Definition: date.cpp:37
SLV_52
@ SLV_52
52 9066
Definition: saveload.h:109
DT_MANUAL
@ DT_MANUAL
Manual distribution. No link graph calculations are run.
Definition: linkgraph_type.h:25
GameSettings::difficulty
DifficultySettings difficulty
settings related to the difficulty
Definition: settings_type.h:586
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
GetTileZ
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
Definition: tile_map.cpp:121
INVALID_TILE
static constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:108
CLEAR_GRASS
@ CLEAR_GRASS
0-3
Definition: clear_map.h:20
_me
TileExtended * _me
Extended Tiles of the map.
Definition: map.cpp:31
ShowAIDebugWindowIfAIError
void ShowAIDebugWindowIfAIError()
Open the AI debug window if one of the AI scripts has crashed.
Definition: ai_gui.cpp:1492
SLV_119
@ SLV_119
119 16242
Definition: saveload.h:189
LocaleSettings::units_volume
byte units_volume
unit system for volume
Definition: settings_type.h:240
SLV_SHIPS_STOP_IN_LOCKS
@ SLV_SHIPS_STOP_IN_LOCKS
206 PR#7150 Ship/lock movement changes.
Definition: saveload.h:295
IsClearGround
static bool IsClearGround(TileIndex t, ClearGround ct)
Set the type of clear tile.
Definition: clear_map.h:71
DiagDirToDiagTrackdir
static Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
Definition: track_func.h:536
ClrBit
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
Definition: bitmath_func.hpp:151
TileIndex
The index/ID of a Tile.
Definition: tile_type.h:85
Waypoint
Representation of a waypoint.
Definition: waypoint_base.h:16
MP_RAILWAY
@ MP_RAILWAY
A railway.
Definition: tile_type.h:49
Tile::m2
uint16 m2
Primarily used for indices to towns, industries and stations.
Definition: map_type.h:20
IsStandardRoadStopTile
static bool IsStandardRoadStopTile(TileIndex t)
Is tile t a standard (non-drive through) road stop station?
Definition: station_map.h:223
SLV_87
@ SLV_87
87 12129
Definition: saveload.h:151
SetStationGfx
static void SetStationGfx(TileIndex t, StationGfx gfx)
Set the station graphics of this tile.
Definition: station_map.h:80
SetCrossingReservation
static void SetCrossingReservation(TileIndex t, bool b)
Set the reservation state of the rail crossing.
Definition: road_map.h:393
SetRoadOwner
static void SetRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
Definition: road_map.h:251
OBJECT_STATUE
static const ObjectType OBJECT_STATUE
Statue in towns.
Definition: object_type.h:18
SLV_88
@ SLV_88
88 12134
Definition: saveload.h:152
IsDriveThroughStopTile
static bool IsDriveThroughStopTile(TileIndex t)
Is tile t a drive through road stop station?
Definition: station_map.h:233
VF_LOADING_FINISHED
@ VF_LOADING_FINISHED
Vehicle has finished loading.
Definition: vehicle_base.h:46
GameCreationSettings::town_name
byte town_name
the town name generator used for town names
Definition: settings_type.h:327
TILE_SIZE
static const uint TILE_SIZE
Tile size in world coordinates.
Definition: tile_type.h:15
SLV_78
@ SLV_78
78 11176
Definition: saveload.h:140
GCS_NOT_FOUND
@ GCS_NOT_FOUND
GRF file was not found in the local cache.
Definition: newgrf_config.h:37
UpdateOldAircraft
void UpdateOldAircraft()
need to be called to load aircraft from old version
Definition: vehicle_sl.cpp:164
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:19
SpecializedStation< Station, false >::Get
static Station * Get(size_t index)
Gets station with given index.
Definition: base_station_base.h:218
SLV_138
@ SLV_138
138 18942 1.0.x
Definition: saveload.h:212
GRFConfig::ident
GRFIdentifier ident
grfid and md5sum to uniquely identify newgrfs
Definition: newgrf_config.h:163
EconomySettings::feeder_payment_share
uint8 feeder_payment_share
percentage of leg payment to virtually pay in feeder systems
Definition: settings_type.h:515
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:53
HasSignals
static bool HasSignals(TileIndex t)
Checks if a rail tile has signals.
Definition: rail_map.h:72
SLV_104
@ SLV_104
104 14735
Definition: saveload.h:171
TCGM_ORIGINAL
@ TCGM_ORIGINAL
Original algorithm (quadratic cargo by population)
Definition: town_type.h:105
CargoSpec
Specification of a cargo type.
Definition: cargotype.h:57
IsCoast
static bool IsCoast(TileIndex t)
Is it a coast tile?
Definition: water_map.h:206
LoggedAction::at
GamelogActionType at
Type of action.
Definition: gamelog_internal.h:83
MP_INDUSTRY
@ MP_INDUSTRY
Part of an industry.
Definition: tile_type.h:56
GetCompanyRoadTypes
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
Definition: road.cpp:188
ORIGINAL_BASE_YEAR
static const Year ORIGINAL_BASE_YEAR
The minimum starting year/base year of the original TTD.
Definition: date_type.h:50
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:215
PMB_PAUSED_NETWORK
@ PMB_PAUSED_NETWORK
Pause mode bits when paused for network reasons.
Definition: openttd.h:71
OrthogonalTileArea::Add
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
Definition: tilearea.cpp:43
SLV_SERVE_NEUTRAL_INDUSTRIES
@ SLV_SERVE_NEUTRAL_INDUSTRIES
210 PR#7234 Company stations can serve industries with attached neutral stations.
Definition: saveload.h:300
SLV_15
@ SLV_15
15.0 2499
Definition: saveload.h:63
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition: direction_type.h:82
TownLayout
TownLayout
Town Layouts.
Definition: town_type.h:80
GetCrossingRoadBits
static RoadBits GetCrossingRoadBits(TileIndex tile)
Get the road bits of a level crossing.
Definition: road_map.h:348
IsSavegameVersionBeforeOrAt
static bool IsSavegameVersionBeforeOrAt(SaveLoadVersion major)
Checks whether the savegame is below or at major.
Definition: saveload.h:1044
MayHaveBridgeAbove
static bool MayHaveBridgeAbove(TileIndex t)
Checks for the possibility that a bridge may be on this tile These are in fact all the tile types on ...
Definition: afterload.cpp:534
RoadVehicle::roadtype
RoadType roadtype
Roadtype of this vehicle.
Definition: roadveh.h:117
VehicleSettings::road_side
byte road_side
the side of the road vehicles drive on
Definition: settings_type.h:504
SetRoadTypes
static void SetRoadTypes(TileIndex t, RoadType road_rt, RoadType tram_rt)
Set the present road types of a tile.
Definition: road_map.h:619
SLV_LAST_LOADING_TICK
@ SLV_LAST_LOADING_TICK
301 PR#9693 Store tick of last loading for vehicles.
Definition: saveload.h:345
_animated_tiles
std::vector< TileIndex > _animated_tiles
The table/list with animated tiles.
Definition: animated_tile.cpp:20
Engine
Definition: engine_base.h:36
SLV_113
@ SLV_113
113 15340
Definition: saveload.h:182
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:224
Industry
Defines the internal data of a functional industry.
Definition: industry.h:66
FindFirstCargoWithTownEffect
const CargoSpec * FindFirstCargoWithTownEffect(TownEffect effect)
Determines the first cargo with a certain town effect.
Definition: town_cmd.cpp:2801
Vehicle::owner
Owner owner
Which company owns the vehicle?
Definition: vehicle_base.h:288
SetSignalHandlers
static void SetSignalHandlers()
Replaces signal handlers of SIGSEGV and SIGABRT and stores pointers to original handlers in memory.
Definition: afterload.cpp:322
StartupEngines
void StartupEngines()
Start/initialise all our engines.
Definition: engine.cpp:719
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
SLV_175
@ SLV_175
175 24136
Definition: saveload.h:257
SLV_83
@ SLV_83
83 11589
Definition: saveload.h:146
SLV_76
@ SLV_76
76 11139
Definition: saveload.h:138
SLV_53
@ SLV_53
53 9316
Definition: saveload.h:110
BaseStation::owner
Owner owner
The owner of this station.
Definition: base_station_base.h:62
GRFIdentifier::md5sum
uint8 md5sum[16]
MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF)
Definition: newgrf_config.h:85
Tile::m1
byte m1
Primarily used for ownership information.
Definition: map_type.h:21
IsTruckStop
static bool IsTruckStop(TileIndex t)
Is the station at t a truck stop?
Definition: station_map.h:180
AIR_AIRCRAFT
@ AIR_AIRCRAFT
an airplane
Definition: aircraft.h:32
MP_ROAD
@ MP_ROAD
A tile with road (or tram tracks)
Definition: tile_type.h:50
IsRailDepot
static bool IsRailDepot(TileIndex t)
Is this rail tile a rail depot?
Definition: rail_map.h:95
WATER_CLASS_INVALID
@ WATER_CLASS_INVALID
Used for industry tiles on land (also for oilrig if newgrf says so).
Definition: water_map.h:51
_saveload_crash_with_missing_newgrfs
static bool _saveload_crash_with_missing_newgrfs
Was the saveload crash because of missing NewGRFs?
Definition: afterload.cpp:358
GetTargetAirportIfValid
Station * GetTargetAirportIfValid(const Aircraft *v)
Returns aircraft's target station if v->target_airport is a valid station with airport.
Definition: aircraft_cmd.cpp:2129
SLV_100
@ SLV_100
100 13952
Definition: saveload.h:167
SLV_141
@ SLV_141
141 19799
Definition: saveload.h:216
SLV_172
@ SLV_172
172 23947
Definition: saveload.h:253
SetFence
static void SetFence(TileIndex t, DiagDirection side, uint h)
Sets the type of fence (and whether there is one) for the given border.
Definition: clear_map.h:240
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:27
IsLevelCrossing
static bool IsLevelCrossing(TileIndex t)
Return whether a tile is a level crossing.
Definition: road_map.h:85
Object::IncTypeCount
static void IncTypeCount(ObjectType type)
Increment the count of objects for this type.
Definition: object_base.h:43
GRFIdentifier::grfid
uint32 grfid
GRF ID (defined by Action 0x08)
Definition: newgrf_config.h:84
ShowNewGRFError
void ShowNewGRFError()
Show the first NewGRF error we can find.
Definition: newgrf_gui.cpp:44
GCF_COMPATIBLE
@ GCF_COMPATIBLE
GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
Definition: newgrf_config.h:26
ST_TOWN
@ ST_TOWN
Source/destination is a town.
Definition: cargo_type.h:149
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:205
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
Definition: error_gui.cpp:377
GetLockPart
static byte GetLockPart(TileIndex t)
Get the part of a lock.
Definition: water_map.h:331
IsDepotTile
static bool IsDepotTile(TileIndex tile)
Is the given tile a tile with a depot on it?
Definition: depot_map.h:41
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:587
GetTileTrackStatus
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
Definition: landscape.cpp:601
RAILTYPE_ELECTRIC
@ RAILTYPE_ELECTRIC
Electric rails.
Definition: rail_type.h:30
SpecializedStation< Station, false >::Iterate
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
Definition: base_station_base.h:269
SLV_61
@ SLV_61
61 9892
Definition: saveload.h:120
GamelogGRFRemove
void GamelogGRFRemove(uint32 grfid)
Logs removal of a GRF.
Definition: gamelog.cpp:604
SP_MEDIUM
@ SP_MEDIUM
Medium difficulty.
Definition: settings_type.h:40
RATING_INITIAL
@ RATING_INITIAL
initial rating
Definition: town_type.h:44
Aircraft
Aircraft, helicopters, rotors and their shadows belong to this class.
Definition: aircraft.h:74
PM_UNPAUSED
@ PM_UNPAUSED
A normal unpaused game.
Definition: openttd.h:61
GVF_GOINGDOWN_BIT
@ GVF_GOINGDOWN_BIT
Vehicle is currently going downhill. (Cached track information for acceleration)
Definition: ground_vehicle.hpp:53
ROAD_X
@ ROAD_X
Full road along the x-axis (south-west + north-east)
Definition: road_type.h:56
MapSizeX
static uint MapSizeX()
Get the size of the map along the X.
Definition: map_func.h:72
INDUSTRYBEH_PLANT_ON_BUILT
@ INDUSTRYBEH_PLANT_ON_BUILT
Fields are planted around when built (all farms)
Definition: industrytype.h:69
PathfinderSettings::wait_oneway_signal
byte wait_oneway_signal
waitingtime in days before a oneway signal
Definition: settings_type.h:465
ChangeTileOwner
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
Change the owner of a tile.
Definition: landscape.cpp:612
RVS_DRIVE_SIDE
@ RVS_DRIVE_SIDE
Only used when retrieving move data.
Definition: roadveh.h:45
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
SLV_98
@ SLV_98
98 13375
Definition: saveload.h:164
Pool::MAX_SIZE
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
Definition: pool_type.hpp:85
YAPFSettings::rail_use_yapf
bool rail_use_yapf
use YAPF for rail
Definition: settings_type.h:419
StationType
StationType
Station types.
Definition: station_type.h:32
COMPANY_FIRST
@ COMPANY_FIRST
First company, same as owner.
Definition: company_type.h:22
Group
Group data.
Definition: group.h:74
SLV_EXTEND_INDUSTRY_CARGO_SLOTS
@ SLV_EXTEND_INDUSTRY_CARGO_SLOTS
202 PR#6867 Increase industry cargo slots to 16 in, 16 out
Definition: saveload.h:290
SLV_160
@ SLV_160
160 21974 1.1.x
Definition: saveload.h:239
YAPFSettings::ship_use_yapf
bool ship_use_yapf
use YAPF for ships
Definition: settings_type.h:417
ROAD_TILE_NORMAL
@ ROAD_TILE_NORMAL
Normal road.
Definition: road_map.h:23
ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
Definition: order_type.h:74
ROAD_Y
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
Definition: road_type.h:57
GRFIdentifier
Basic data to distinguish a GRF.
Definition: newgrf_config.h:83
VehicleSettings::plane_crashes
uint8 plane_crashes
number of plane crashes, 0 = none, 1 = reduced, 2 = normal
Definition: settings_type.h:505
FileToSaveLoad::abstract_ftype
AbstractFileType abstract_ftype
Abstract type of file (scenario, heightmap, etc).
Definition: saveload.h:362
GameSettings::pf
PathfinderSettings pf
settings for all pathfinders
Definition: settings_type.h:593
DistanceManhattan
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
Definition: map.cpp:157
DIAGDIR_SW
@ DIAGDIR_SW
Southwest.
Definition: direction_type.h:81
UpdateAllTownVirtCoords
void UpdateAllTownVirtCoords()
Update the virtual coords needed to draw the town sign for all towns.
Definition: town_cmd.cpp:419
ConstructionSettings::terraform_frame_burst
uint16 terraform_frame_burst
how many tile heights may, over a short period, be terraformed?
Definition: settings_type.h:359
SLV_135
@ SLV_135
135 18719
Definition: saveload.h:209
VS_HIDDEN
@ VS_HIDDEN
Vehicle is not visible.
Definition: vehicle_base.h:34
GetRawClearGround
static ClearGround GetRawClearGround(TileIndex t)
Get the type of clear tile but never return CLEAR_SNOW.
Definition: clear_map.h:47
PathfinderSettings::wait_twoway_signal
byte wait_twoway_signal
waitingtime in days before a twoway signal
Definition: settings_type.h:466
EconomySettings::station_noise_level
bool station_noise_level
build new airports when the town noise level is still within accepted limits
Definition: settings_type.h:530
TILE_UNIT_MASK
static const uint TILE_UNIT_MASK
For masking in/out the inner-tile world coordinate units.
Definition: tile_type.h:16
TRANSPORT_RAIL
@ TRANSPORT_RAIL
Transport by train.
Definition: transport_type.h:27
SLV_161
@ SLV_161
161 22567
Definition: saveload.h:240
DirToDiagDir
static DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
Definition: direction_func.h:166
StationSettings::serve_neutral_industries
bool serve_neutral_industries
company stations can serve industries with attached neutral stations
Definition: settings_type.h:559
Subsidy
Struct about subsidies, offered and awarded.
Definition: subsidy_base.h:22
SLV_156
@ SLV_156
156 21728
Definition: saveload.h:234
_tunnel_visibility_frame
const byte _tunnel_visibility_frame[DIAGDIR_END]
Frame when a vehicle should be hidden in a tunnel with a certain direction.
MapSize
static uint MapSize()
Get the size of the map.
Definition: map_func.h:92
GetClearDensity
static uint GetClearDensity(TileIndex t)
Get the density of a non-field clear tile.
Definition: clear_map.h:83
TL_BETTER_ROADS
@ TL_BETTER_ROADS
Extended original algorithm (min. 2 distance between roads)
Definition: town_type.h:83
IsGoodGRFConfigList
GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
Check if all GRFs in the GRF config from a savegame can be loaded.
Definition: newgrf_config.cpp:513
LoggedAction::changes
uint32 changes
Number of changes in this action.
Definition: gamelog_internal.h:82
SLV_111
@ SLV_111
111 15190
Definition: saveload.h:180
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
IsBridgeTile
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
Definition: bridge_map.h:35
_road_stop_stop_frame
const byte _road_stop_stop_frame[]
Table of road stop stop frames, when to stop at a road stop.
SLV_123
@ SLV_123
123 16909
Definition: saveload.h:194
WaterClass
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
Definition: water_map.h:47
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:28
HasStationRail
static bool HasStationRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
Definition: station_map.h:135
SetTropicZone
static void SetTropicZone(TileIndex tile, TropicZone type)
Set the tropic zone.
Definition: tile_map.h:225
TileHeight
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
Definition: tile_map.h:29
SIG_ELECTRIC
@ SIG_ELECTRIC
Light signal.
Definition: signal_type.h:17
GRFConfig
Information about GRF, used in the game and (part of it) in savegames.
Definition: newgrf_config.h:155
VehicleSettings::train_slope_steepness
uint8 train_slope_steepness
Steepness of hills for trains when using realistic acceleration.
Definition: settings_type.h:491
BaseStation::train_station
TileArea train_station
Tile area the train 'station' part covers.
Definition: base_station_base.h:74
Industry::GetByTile
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
Definition: industry.h:144
SLV_164
@ SLV_164
164 23290
Definition: saveload.h:243
WATER_TILE_CLEAR
@ WATER_TILE_CLEAR
Plain water.
Definition: water_map.h:40
GSF_FAKE_TOWNS
@ GSF_FAKE_TOWNS
Fake town GrfSpecFeature for NewGRF debugging (parent scope)
Definition: newgrf.h:89
SLV_31
@ SLV_31
31 5999
Definition: saveload.h:84
CalcClosestTownFromTile
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
Definition: town_cmd.cpp:3576
Station::RecomputeCatchmentForAll
static void RecomputeCatchmentForAll()
Recomputes catchment of all stations.
Definition: station.cpp:497
MIN_YEAR
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
Definition: date_type.h:84
XYNSToDiagDir
static DiagDirection XYNSToDiagDir(Axis xy, uint ns)
Convert an axis and a flag for north/south into a DiagDirection.
Definition: direction_func.h:261
GVF_GOINGUP_BIT
@ GVF_GOINGUP_BIT
Vehicle is currently going uphill. (Cached track information for acceleration)
Definition: ground_vehicle.hpp:52
BaseStation::rect
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
Definition: base_station_base.h:75
NEW_HOUSE_OFFSET
static const HouseID NEW_HOUSE_OFFSET
Offset for new houses.
Definition: house.h:28
SLV_MULTITILE_DOCKS
@ SLV_MULTITILE_DOCKS
216 PR#7380 Multiple docks per station.
Definition: saveload.h:307
Vehicle::tile
TileIndex tile
Current tile index.
Definition: vehicle_base.h:245
SetBridgeMiddle
static void SetBridgeMiddle(TileIndex t, Axis a)
Set that there is a bridge over the given axis.
Definition: bridge_map.h:114
GetOverriddenIdentifier
static const GRFIdentifier * GetOverriddenIdentifier(const GRFConfig *c)
Try to find the overridden GRF identifier of the given GRF.
Definition: afterload.cpp:344
GameSettings::script
ScriptSettings script
settings for scripts
Definition: settings_type.h:590
ConstructionSettings::tree_frame_burst
uint16 tree_frame_burst
how many trees may, over a short period, be planted?
Definition: settings_type.h:363
TOWN_GROWTH_DESERT
static const uint TOWN_GROWTH_DESERT
The town needs the cargo for growth when on desert (any amount)
Definition: town.h:32
TrackStatusToTrackBits
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
Definition: track_func.h:362
SLV_11
@ SLV_11
11.0 2033 11.1 2041
Definition: saveload.h:57
ObjectType
uint16 ObjectType
Types of objects.
Definition: object_type.h:14
MP_OBJECT
@ MP_OBJECT
Contains objects such as transmitters and owned land.
Definition: tile_type.h:58
TransportType
TransportType
Available types of transport.
Definition: transport_type.h:19
VS_CRASHED
@ VS_CRASHED
Vehicle is crashed.
Definition: vehicle_base.h:41
SB
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Definition: bitmath_func.hpp:58
SpecializedStation< Station, false >::IsExpected
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
Definition: base_station_base.h:199
IsBuoy
static bool IsBuoy(TileIndex t)
Is tile t a buoy tile?
Definition: station_map.h:306
IndustrySpec::accepts_cargo
CargoID accepts_cargo[INDUSTRY_NUM_INPUTS]
16 accepted cargoes.
Definition: industrytype.h:121
INVALID_OWNER
@ INVALID_OWNER
An invalid owner.
Definition: company_type.h:29
OrthogonalTileArea::w
uint16 w
The width of the area.
Definition: tilearea_type.h:20
MP_WATER
@ MP_WATER
Water tile.
Definition: tile_type.h:54
UpdateAirportsNoise
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
Definition: station_cmd.cpp:2186
CargoPayment
Helper class to perform the cargo payment.
Definition: economy_base.h:24
GetStationType
static StationType GetStationType(TileIndex t)
Get the station type of this tile.
Definition: station_map.h:44
SLV_126
@ SLV_126
126 17433
Definition: saveload.h:198
AI::StartNew
static void StartNew(CompanyID company, bool rerandomise_ai=true)
Start a new AI company.
Definition: ai_core.cpp:36
AfterLoadStoryBook
void AfterLoadStoryBook()
Called after load to trash broken pages.
Definition: story_sl.cpp:20
SLV_86
@ SLV_86
86 12042
Definition: saveload.h:150
Vehicle::current_order
Order current_order
The current order (+ status, like: loading)
Definition: vehicle_base.h:333
CopyFromOldName
std::string CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
Definition: strings_sl.cpp:60
TRACK_UPPER
@ TRACK_UPPER
Track in the upper corner of the tile (north)
Definition: track_type.h:23
INDUSTRYBEH_BUILT_ONWATER
@ INDUSTRYBEH_BUILT_ONWATER
is built on water (oil rig)
Definition: industrytype.h:65
AfterLoadCompanyStats
void AfterLoadCompanyStats()
Rebuilding of company statistics after loading a savegame.
Definition: company_sl.cpp:96
WATER_CLASS_CANAL
@ WATER_CLASS_CANAL
Canal.
Definition: water_map.h:49
MakeVoid
static void MakeVoid(TileIndex t)
Make a nice void tile ;)
Definition: void_map.h:19
GetNorthernBridgeEnd
TileIndex GetNorthernBridgeEnd(TileIndex t)
Finds the northern end of a bridge starting at a middle tile.
Definition: bridge_map.cpp:39
Object
An object, such as transmitter, on the map.
Definition: object_base.h:23
Station::airport
Airport airport
Tile area the airport covers.
Definition: station_base.h:468
ST_INDUSTRY
@ ST_INDUSTRY
Source/destination is an industry.
Definition: cargo_type.h:148
SLV_158
@ SLV_158
158 21933
Definition: saveload.h:236
IsShipDepot
static bool IsShipDepot(TileIndex t)
Is it a water tile with a ship depot on it?
Definition: water_map.h:227
_pause_mode
PauseMode _pause_mode
The current pause mode.
Definition: gfx.cpp:50
DIR_NE
@ DIR_NE
Northeast.
Definition: direction_type.h:27
RoadTypes
RoadTypes
The different roadtypes we support, but then a bitmask of them.
Definition: road_type.h:36
Vehicle::IsFrontEngine
bool IsFrontEngine() const
Check if the vehicle is a front engine.
Definition: vehicle_base.h:913
LOCK_PART_MIDDLE
@ LOCK_PART_MIDDLE
Middle part of a lock.
Definition: water_map.h:76
SetSignalStates
static void SetSignalStates(TileIndex tile, uint state)
Set the states of the signals (Along/AgainstTrackDir)
Definition: rail_map.h:352
SaveloadCrashWithMissingNewGRFs
bool SaveloadCrashWithMissingNewGRFs()
Did loading the savegame cause a crash? If so, were NewGRFs missing?
Definition: afterload.cpp:365
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:54
SLV_46
@ SLV_46
46 8705
Definition: saveload.h:102
SLV_94
@ SLV_94
94 12816
Definition: saveload.h:159
RVS_ENTERED_STOP
@ RVS_ENTERED_STOP
Only set when a vehicle has entered the stop.
Definition: roadveh.h:44
GetAircraftFlightLevelBounds
void GetAircraftFlightLevelBounds(const Vehicle *v, int *min, int *max)
Get the 'flight level' bounds, in pixels from 'z_pos' 0 for a particular vehicle for normal flight si...
Definition: aircraft_cmd.cpp:717
CompanyProperties::settings
CompanySettings settings
settings specific for each company
Definition: company_base.h:106
SLV_74
@ SLV_74
74 11030
Definition: saveload.h:135
SetAircraftPosition
void SetAircraftPosition(Aircraft *v, int x, int y, int z)
Set aircraft position.
Definition: aircraft_cmd.cpp:521
SLV_TOWN_CARGOGEN
@ SLV_TOWN_CARGOGEN
208 PR#6965 New algorithms for town building cargo generation.
Definition: saveload.h:297
GameSettings::economy
EconomySettings economy
settings to change the economy
Definition: settings_type.h:596
VS_STOPPED
@ VS_STOPPED
Vehicle is stopped by the player.
Definition: vehicle_base.h:35
SLV_128
@ SLV_128
128 18281
Definition: saveload.h:200
Object::type
ObjectType type
Type of the object.
Definition: object_base.h:24
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
TRACK_BIT_X
@ TRACK_BIT_X
X-axis track.
Definition: track_type.h:40
GetRoadTileType
static RoadTileType GetRoadTileType(TileIndex t)
Get the type of the road tile.
Definition: road_map.h:52
HasStationTileRail
static bool HasStationTileRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
Definition: station_map.h:146
GameCreationSettings::snow_line_height
byte snow_line_height
the configured snow line height (deduced from "snow_coverage")
Definition: settings_type.h:319
IsRailDepotTile
static bool IsRailDepotTile(TileIndex t)
Is this tile rail tile and a rail depot?
Definition: rail_map.h:105
SetDockingTile
static void SetDockingTile(TileIndex t, bool b)
Set the docking tile state of a tile.
Definition: water_map.h:366
Company::IsValidAiID
static bool IsValidAiID(size_t index)
Is this company a valid company, controlled by the computer (a NoAI program)?
Definition: company_base.h:137
Train
'Train' is either a loco or a wagon.
Definition: train.h:89
VEH_INVALID
@ VEH_INVALID
Non-existing type of vehicle.
Definition: vehicle_type.h:35
DiagDirToDir
static Direction DiagDirToDir(DiagDirection dir)
Convert a DiagDirection to a Direction.
Definition: direction_func.h:182
ConstructionSettings::freeform_edges
bool freeform_edges
allow terraforming the tiles at the map edges
Definition: settings_type.h:354
MoveWaypointsToBaseStations
void MoveWaypointsToBaseStations()
Perform all steps to upgrade from the old waypoints to the new version that uses station.
Definition: waypoint_sl.cpp:66
GetTileSlope
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
Definition: tile_map.cpp:59
ReverseDiagDir
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Definition: direction_func.h:118
TileAddByDiagDir
static TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
Definition: map_func.h:382
SetLiftPosition
static void SetLiftPosition(TileIndex t, byte pos)
Set the position of the lift on this animated house.
Definition: town_map.h:135
CopyTempEngineData
void CopyTempEngineData()
Copy data from temporary engine array into the real engine pool.
Definition: engine_sl.cpp:122
IsBridge
static bool IsBridge(TileIndex t)
Checks if this is a bridge, instead of a tunnel.
Definition: bridge_map.h:24
SLV_82
@ SLV_82
82 11410
Definition: saveload.h:145
SLV_183
@ SLV_183
183 25363 Cargodist
Definition: saveload.h:266
IsTileOwner
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
Definition: tile_map.h:214
DifficultySettings::industry_density
byte industry_density
The industry density.
Definition: settings_type.h:80
SLV_120
@ SLV_120
120 16439
Definition: saveload.h:191
IsSavegameVersionBefore
static bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
Definition: saveload.h:1030
SLV_45
@ SLV_45
45 8501
Definition: saveload.h:101
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:58
TileHash
static uint TileHash(uint x, uint y)
Calculate a hash value from a tile position.
Definition: tile_map.h:316
SLV_90
@ SLV_90
90 12293
Definition: saveload.h:155
ROADTYPE_ROAD
@ ROADTYPE_ROAD
Basic road type.
Definition: road_type.h:24
RVS_IN_ROAD_STOP
@ RVS_IN_ROAD_STOP
The vehicle is in a road stop.
Definition: roadveh.h:46
MP_TUNNELBRIDGE
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Definition: tile_type.h:57
UpdateAllSignVirtCoords
void UpdateAllSignVirtCoords()
Update the coordinates of all signs.
Definition: signs.cpp:59
SLV_REPAIR_OBJECT_DOCKING_TILES
@ SLV_REPAIR_OBJECT_DOCKING_TILES
299 PR#9594 v12.0 Fixing issue with docking tiles overlapping objects.
Definition: saveload.h:342
SLV_125
@ SLV_125
125 17113
Definition: saveload.h:197
VehicleDefaultSettings
Default settings for vehicles.
Definition: settings_type.h:567
GamelogTestRevision
void GamelogTestRevision()
Finds out if current revision is different than last revision stored in the savegame.
Definition: gamelog.cpp:503
IsRoadDepot
static bool IsRoadDepot(TileIndex t)
Return whether a tile is a road depot.
Definition: road_map.h:106
GameSettings::linkgraph
LinkGraphSettings linkgraph
settings for link graph calculations
Definition: settings_type.h:597
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:77
LocaleSettings::units_weight
byte units_weight
unit system for weight
Definition: settings_type.h:239
MapSizeY
static uint MapSizeY()
Get the size of the map along the Y.
Definition: map_func.h:82
WATER_CLASS_RIVER
@ WATER_CLASS_RIVER
River.
Definition: water_map.h:50
FACIL_DOCK
@ FACIL_DOCK
Station with a dock.
Definition: station_type.h:57
MoveBuoysToWaypoints
void MoveBuoysToWaypoints()
Perform all steps to upgrade from the old station buoys to the new version that uses waypoints.
Definition: station_sl.cpp:43
SpecializedStation< Station, false >::From
static Station * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
Definition: base_station_base.h:247
SLV_25
@ SLV_25
25 4259
Definition: saveload.h:77
_network_dedicated
bool _network_dedicated
are we a dedicated server?
Definition: network.cpp:61
SIGTYPE_COMBO
@ SIGTYPE_COMBO
presignal inter-block
Definition: signal_type.h:27
SLV_182
@ SLV_182
182 25115 FS#5492, r25259, r25296 Goal status
Definition: saveload.h:265
SLV_50
@ SLV_50
50 8973
Definition: saveload.h:107
SLV_17
@ SLV_17
17.0 3212 17.1 3218
Definition: saveload.h:66
LoggedAction::change
LoggedChange * change
First logged change in this action.
Definition: gamelog_internal.h:81
FixupTrainLengths
void FixupTrainLengths()
Fixup old train spacing.
Definition: vehicle_sl.cpp:488
Station::truck_stops
RoadStop * truck_stops
All the truck stops.
Definition: station_base.h:465
SLV_145
@ SLV_145
145 20376
Definition: saveload.h:221
VPF_NPF
@ VPF_NPF
New PathFinder.
Definition: vehicle_type.h:60
IndustrySpec
Defines the data structure for constructing industry.
Definition: industrytype.h:107
StartScripts
static void StartScripts()
Start the scripts.
Definition: afterload.cpp:543
BSWAP32
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
Definition: bitmath_func.hpp:390
CargoPacket::AfterLoad
static void AfterLoad()
Savegame conversion for cargopackets.
Definition: cargopacket_sl.cpp:23
UpdateNearestTownForRoadTiles
void UpdateNearestTownForRoadTiles(bool invalidate)
Updates cached nearest town for all road tiles.
Definition: road_cmd.cpp:1873
SLV_42
@ SLV_42
42 7573
Definition: saveload.h:97
WATER_CLASS_SEA
@ WATER_CLASS_SEA
Sea.
Definition: water_map.h:48
GLCT_GRFCOMPAT
@ GLCT_GRFCOMPAT
Loading compatible GRF.
Definition: gamelog_internal.h:23
GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET
static const int GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET
The offset for the drive through parts.
Definition: station_map.h:36
SLV_136
@ SLV_136
136 18764
Definition: saveload.h:210
SLV_28
@ SLV_28
28 4987
Definition: saveload.h:80
SLV_64
@ SLV_64
64 10006
Definition: saveload.h:123
_gamelog_action
LoggedAction * _gamelog_action
first logged action
Definition: gamelog.cpp:35
IsTileType
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
GameCreationSettings::ending_year
Year ending_year
scoring end date
Definition: settings_type.h:314
SLV_2
@ SLV_2
2.0 0.3.0 2.1 0.3.1, 0.3.2
Definition: saveload.h:38
SetDepotReservation
static void SetDepotReservation(TileIndex t, bool b)
Set the reservation state of the depot.
Definition: rail_map.h:270
EconomySettings::town_cargogen_mode
TownCargoGenMode town_cargogen_mode
algorithm for generating cargo from houses,
Definition: settings_type.h:527
SLV_142
@ SLV_142
142 20003
Definition: saveload.h:217
GetTunnelBridgeDirection
static DiagDirection GetTunnelBridgeDirection(TileIndex t)
Get the direction pointing to the other end.
Definition: tunnelbridge_map.h:26
SLV_59
@ SLV_59
59 9779
Definition: saveload.h:117
GetTileOwner
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
Definition: tile_map.h:178
SLV_139
@ SLV_139
139 19346
Definition: saveload.h:213
RAIL_GROUND_WATER
@ RAIL_GROUND_WATER
Grass with a fence and shore or water on the free halftile.
Definition: rail_map.h:499
Vehicle::direction
Direction direction
facing
Definition: vehicle_base.h:286
LocaleSettings::units_force
byte units_force
unit system for force
Definition: settings_type.h:241
OrthogonalTileArea::h
uint16 h
The height of the area.
Definition: tilearea_type.h:21
MP_TREES
@ MP_TREES
Tile got trees.
Definition: tile_type.h:52
UpdateAircraftCache
void UpdateAircraftCache(Aircraft *v, bool update_range=false)
Update cached values of an aircraft.
Definition: aircraft_cmd.cpp:590
SlError
void NORETURN SlError(StringID string, const char *extra_msg)
Error handler.
Definition: saveload.cpp:333
PathfinderSettings::pathfinder_for_trains
uint8 pathfinder_for_trains
the pathfinder to use for trains
Definition: settings_type.h:456
RAILTYPE_RAIL
@ RAILTYPE_RAIL
Standard non-electric rails.
Definition: rail_type.h:29
ConstructionSettings::max_bridge_length
uint16 max_bridge_length
maximum length of bridges
Definition: settings_type.h:345
YAPFSettings::road_use_yapf
bool road_use_yapf
use YAPF for road
Definition: settings_type.h:418
TOWN_GROWTH_WINTER
static const uint TOWN_GROWTH_WINTER
The town only needs this cargo in the winter (any amount)
Definition: town.h:31
EconomySettings::infrastructure_maintenance
bool infrastructure_maintenance
enable monthly maintenance fee for owner infrastructure
Definition: settings_type.h:533
ReverseDir
static Direction ReverseDir(Direction d)
Return the reverse of a direction.
Definition: direction_func.h:54
IndustryBuildData::Reset
void Reset()
Completely reset the industry build data.
Definition: industry_cmd.cpp:2307
IsStationTileBlocked
bool IsStationTileBlocked(TileIndex tile)
Check whether a rail station tile is NOT traversable.
Definition: newgrf_station.cpp:857
EconomySettings::allow_town_level_crossings
bool allow_town_level_crossings
towns are allowed to build level crossings
Definition: settings_type.h:532
MakeDefaultName
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
Definition: town.h:245
IsBuoyTile
static bool IsBuoyTile(TileIndex t)
Is tile t a buoy tile?
Definition: station_map.h:316
Ship
All ships have this type.
Definition: ship.h:26
AfterLoadVehicles
void AfterLoadVehicles(bool part_of_load)
Called after load to update coordinates.
Definition: vehicle_sl.cpp:242
_current_company
CompanyID _current_company
Company currently doing an action.
Definition: company_cmd.cpp:47
TreeGround
TreeGround
Enumeration for ground types of tiles with trees.
Definition: tree_map.h:52
Tile::m5
byte m5
General purpose.
Definition: map_type.h:24
SLV_16
@ SLV_16
16.0 2817 16.1 3155
Definition: saveload.h:64
VehicleSettings::dynamic_engines
bool dynamic_engines
enable dynamic allocation of engine data
Definition: settings_type.h:501
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
GamelogPrintDebug
void GamelogPrintDebug(int level)
Prints gamelog to debug output.
Definition: gamelog.cpp:369
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
ConnectMultiheadedTrains
void ConnectMultiheadedTrains()
Link front and rear multiheaded engines to each other This is done when loading a savegame.
Definition: vehicle_sl.cpp:34
GetWaterClass
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
Definition: water_map.h:117
OSL_PLATFORM_FAR_END
@ OSL_PLATFORM_FAR_END
Stop at the far end of the platform.
Definition: order_type.h:86
MapMaxY
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
Definition: map_func.h:111
SLV_127
@ SLV_127
127 17439
Definition: saveload.h:199
LocaleSettings::currency
byte currency
currency we currently use
Definition: settings_type.h:236
MP_VOID
@ MP_VOID
Invisible tiles at the SW and SE border.
Definition: tile_type.h:55
SLV_GS_INDUSTRY_CONTROL
@ SLV_GS_INDUSTRY_CONTROL
287 PR#7912 and PR#8115 GS industry control.
Definition: saveload.h:328
SLV_6
@ SLV_6
6.0 1721 6.1 1768
Definition: saveload.h:50
RebuildSubsidisedSourceAndDestinationCache
void RebuildSubsidisedSourceAndDestinationCache()
Perform a full rebuild of the subsidies cache.
Definition: subsidy.cpp:132
Pool::PoolItem<&_town_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition: pool_type.hpp:367
MAX_INFLATION
static const uint64 MAX_INFLATION
Maximum inflation (including fractional part) without causing overflows in int64 price computations.
Definition: economy_type.h:210
IsPlainRail
static bool IsPlainRail(TileIndex t)
Returns whether this is plain rails, with or without signals.
Definition: rail_map.h:49
TileXY
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
Definition: map_func.h:163
ClearBridgeMiddle
static void ClearBridgeMiddle(TileIndex t)
Removes bridges from the given, that is bridges along the X and Y axis.
Definition: bridge_map.h:103
Backup::Restore
void Restore()
Restore the variable.
Definition: backup_type.hpp:112
FACIL_TRAIN
@ FACIL_TRAIN
Station with train station.
Definition: station_type.h:53
GetWaterTileType
static WaterTileType GetWaterTileType(TileIndex t)
Get the water tile type at a tile.
Definition: water_map.h:88
SpecializedVehicle< Train, Type >::From
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Definition: vehicle_base.h:1183
GamelogGRFCompatible
void GamelogGRFCompatible(const GRFIdentifier *newg)
Logs loading compatible GRF (the same ID, but different MD5 hash)
Definition: gamelog.cpp:635
GetStationGfx
static StationGfx GetStationGfx(TileIndex t)
Get the station graphics of this tile.
Definition: station_map.h:68
LocaleSettings::units_power
byte units_power
unit system for power
Definition: settings_type.h:238
VehicleSettings::roadveh_acceleration_model
uint8 roadveh_acceleration_model
realistic acceleration for road vehicles
Definition: settings_type.h:490
SlErrorCorrupt
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
Definition: saveload.cpp:365
SLV_36
@ SLV_36
36 6624
Definition: saveload.h:90
DeleteInvalidEngineNews
void DeleteInvalidEngineNews()
Remove engine announcements for invalid engines.
Definition: news_gui.cpp:971
AfterLoadLinkGraphs
void AfterLoadLinkGraphs()
Spawn the threads for running link graph calculations.
Definition: linkgraph_sl.cpp:219
ROAD_TILE_DEPOT
@ ROAD_TILE_DEPOT
Depot (one entrance)
Definition: road_map.h:25
SetHouseCompleted
static void SetHouseCompleted(TileIndex t, bool status)
Mark this house as been completed.
Definition: town_map.h:156
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:19
LocaleSettings::units_height
byte units_height
unit system for height
Definition: settings_type.h:242
SLV_91
@ SLV_91
91 12347
Definition: saveload.h:156
SLV_24
@ SLV_24
24 4150
Definition: saveload.h:75
PathfinderSettings::pathfinder_for_ships
uint8 pathfinder_for_ships
the pathfinder to use for ships
Definition: settings_type.h:458
SLV_MULTITRACK_LEVEL_CROSSINGS
@ SLV_MULTITRACK_LEVEL_CROSSINGS
302 PR#9931 v13.0 Multi-track level crossings.
Definition: saveload.h:346
InvalidateWindowClassesData
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Definition: window.cpp:3271
_file_to_saveload
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition: saveload.cpp:63
SLV_81
@ SLV_81
81 11244
Definition: saveload.h:144
OrderList
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Definition: order_base.h:260
UpdateAllVirtCoords
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
Definition: afterload.cpp:218
GRFConfig::next
struct GRFConfig * next
NOSAVE: Next item in the linked list.
Definition: newgrf_config.h:183
SetTunnelBridgeReservation
static void SetTunnelBridgeReservation(TileIndex t, bool b)
Set the reservation state of the rail tunnel/bridge.
Definition: tunnelbridge_map.h:104
Vehicle::cargo_payment
CargoPayment * cargo_payment
The cargo payment we're currently in.
Definition: vehicle_base.h:258
SetTownIndex
static void SetTownIndex(TileIndex t, TownID index)
Set the town index for a road or house tile.
Definition: town_map.h:34
MarkTileDirtyByTile
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Definition: viewport.cpp:1998
OWNER_NONE
@ OWNER_NONE
The tile has no ownership.
Definition: company_type.h:25
PM_PAUSED_NORMAL
@ PM_PAUSED_NORMAL
A game normally paused.
Definition: openttd.h:62
MakeShore
static void MakeShore(TileIndex t)
Helper function to make a coast tile.
Definition: water_map.h:386
GetCompanyRailtypes
RailTypes GetCompanyRailtypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
Definition: rail.cpp:251
SLV_194
@ SLV_194
194 26881 v1.5
Definition: saveload.h:280
TileDiffXY
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition: map_func.h:179
GetRailType
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
Definition: rail_map.h:115
SLV_149
@ SLV_149
149 20832
Definition: saveload.h:225
MP_STATION
@ MP_STATION
A tile of a station.
Definition: tile_type.h:53
SLV_134
@ SLV_134
134 18703
Definition: saveload.h:207
WC_COMPANY_INFRASTRUCTURE
@ WC_COMPANY_INFRASTRUCTURE
Company infrastructure overview; Window numbers:
Definition: window_type.h:569
NUM_CARGO
@ NUM_CARGO
Maximal number of cargo types in a game.
Definition: cargo_type.h:65
SpecializedStation< Station, false >::GetByTile
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
Definition: base_station_base.h:237
SLV_122
@ SLV_122
122 16855
Definition: saveload.h:193
Pool::PoolItem<&_roadstop_pool >::CanAllocateItem
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
Definition: pool_type.hpp:307
VehicleSettings::disable_elrails
bool disable_elrails
when true, the elrails are disabled
Definition: settings_type.h:494
Sign
Definition: signs_base.h:22
GetFirstPlayableCompanyID
CompanyID GetFirstPlayableCompanyID()
Get the index of the first available company.
Definition: company_cmd.cpp:1226
IsLock
static bool IsLock(TileIndex t)
Is there a lock on a given water tile?
Definition: water_map.h:308
SLV_184
@ SLV_184
184 25508 Unit localisation split
Definition: saveload.h:267
DIAGDIR_BEGIN
@ DIAGDIR_BEGIN
Used for iterations.
Definition: direction_type.h:78
SLV_38
@ SLV_38
38 7195
Definition: saveload.h:92
GamelogGRFAddList
void GamelogGRFAddList(const GRFConfig *newg)
Logs adding of list of GRFs.
Definition: gamelog.cpp:681
seprintf
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:554
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
Economy::old_max_loan_unround
Money old_max_loan_unround
Old: Unrounded max loan.
Definition: economy_type.h:40
RecomputePrices
void RecomputePrices()
Computes all prices, payments and maximum loan.
Definition: economy.cpp:758
GroundVehicle::gv_flags
uint16 gv_flags
Definition: ground_vehicle.hpp:81
TE_MAIL
@ TE_MAIL
Cargo behaves mail-like.
Definition: cargotype.h:30
PathfinderSettings::reverse_at_signals
bool reverse_at_signals
whether to reverse at signals at all
Definition: settings_type.h:464
SLV_147
@ SLV_147
147 20621
Definition: saveload.h:223
GfxLoadSprites
void GfxLoadSprites()
Initialise and load all the sprites.
Definition: gfxinit.cpp:344
BaseStation
Base class for all station-ish types.
Definition: base_station_base.h:52
SLV_165
@ SLV_165
165 23304
Definition: saveload.h:245
FixOwnerOfRailTrack
static void FixOwnerOfRailTrack(TileIndex t)
Tries to change owner of this rail tile to a valid owner.
Definition: afterload.cpp:440
RoadBits
RoadBits
Enumeration for the road parts on a tile.
Definition: road_type.h:50
LoggedChange::grfcompat
GRFIdentifier grfcompat
ID and new md5sum of changed GRF.
Definition: gamelog_internal.h:57
SLV_ENDING_YEAR
@ SLV_ENDING_YEAR
218 PR#7747 v1.10 Configurable ending year.
Definition: saveload.h:309
ConstructionSettings::clear_frame_burst
uint16 clear_frame_burst
how many tiles may, over a short period, be cleared?
Definition: settings_type.h:361
SpecializedVehicle< RoadVehicle, Type >::Iterate
static Pool::IterateWrapper< RoadVehicle > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
Definition: vehicle_base.h:1252
IsLevelCrossingTile
static bool IsLevelCrossingTile(TileIndex t)
Return whether a tile is a level crossing tile.
Definition: road_map.h:95
MapMaxX
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
Definition: map_func.h:102
SLV_148
@ SLV_148
148 20659
Definition: saveload.h:224
AXIS_X
@ AXIS_X
The X axis.
Definition: direction_type.h:126
UpdateLevelCrossing
void UpdateLevelCrossing(TileIndex tile, bool sound=true, bool force_bar=false)
Update a level crossing to barred or open (crossing may include multiple adjacent tiles).
Definition: train_cmd.cpp:1753
GetTreeGround
static TreeGround GetTreeGround(TileIndex t)
Returns the groundtype for tree tiles.
Definition: tree_map.h:88
TILE_ADDXY
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
Definition: map_func.h:258
DEF_END_YEAR
static const Year DEF_END_YEAR
The default scoring end year.
Definition: date_type.h:89
UpdateHousesAndTowns
void UpdateHousesAndTowns()
Check and update town and house values.
Definition: town_sl.cpp:67
SLV_188
@ SLV_188
188 26169 v1.4 FS#5831 Unify RV travel time
Definition: saveload.h:272
SLV_99
@ SLV_99
99 13838
Definition: saveload.h:165
TrackBits
TrackBits
Bitfield corresponding to Track.
Definition: track_type.h:38
_grfconfig
GRFConfig * _grfconfig
First item in list of current GRF set up.
Definition: newgrf_config.cpp:171
SLV_21
@ SLV_21
21 3472 0.4.x
Definition: saveload.h:72
saveload_internal.h
IndustrySpec::behaviour
IndustryBehaviour behaviour
How this industry will behave, and how others entities can use it.
Definition: industrytype.h:125
Debug
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
Definition: debug.h:37
Depot
Definition: depot_base.h:19
MakeCanal
static void MakeCanal(TileIndex t, Owner o, uint8 random_bits)
Make a canal tile.
Definition: water_map.h:446
SetBit
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
TE_WATER
@ TE_WATER
Cargo behaves water-like.
Definition: cargotype.h:32
FixVehicleInclination
static uint FixVehicleInclination(Vehicle *v, Direction dir)
Fixes inclination of a vehicle.
Definition: afterload.cpp:498
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
Town
Town data structure.
Definition: town.h:50
RVSB_WORMHOLE
@ RVSB_WORMHOLE
The vehicle is in a tunnel and/or bridge.
Definition: roadveh.h:40
DiagDirToDiagTrackBits
static TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir.
Definition: track_func.h:523
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1767
IsDock
static bool IsDock(TileIndex t)
Is tile t a dock tile?
Definition: station_map.h:285
PathfinderSettings::yapf
YAPFSettings yapf
pathfinder settings for the yet another pathfinder
Definition: settings_type.h:473
VF_PATHFINDER_LOST
@ VF_PATHFINDER_LOST
Vehicle's pathfinder is lost.
Definition: vehicle_base.h:53
SpecializedStation< Station, false >::GetIfValid
static Station * GetIfValid(size_t index)
Returns station if the index is a valid index for this station type.
Definition: base_station_base.h:227
GameSettings::locale
LocaleSettings locale
settings related to used currency/unit system in the current game
Definition: settings_type.h:599
TILE_HEIGHT
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
Definition: tile_type.h:18
Airport::type
byte type
Type of this airport,.
Definition: station_base.h:306
SLV_103
@ SLV_103
103 14598
Definition: saveload.h:170
IsOilRig
static bool IsOilRig(TileIndex t)
Is tile t part of an oilrig?
Definition: station_map.h:274
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
ROADTYPE_TRAM
@ ROADTYPE_TRAM
Trams.
Definition: road_type.h:25
IsPlainRailTile
static bool IsPlainRailTile(TileIndex t)
Checks whether the tile is a rail tile or rail tile with signals.
Definition: rail_map.h:60
TileExtended::m7
byte m7
Primarily used for newgrf support.
Definition: map_type.h:35
CheckTrainsLengths
void CheckTrainsLengths()
Checks if lengths of all rail vehicles are valid.
Definition: train_cmd.cpp:74
INVALID_COMPANY
@ INVALID_COMPANY
An invalid company.
Definition: company_type.h:30
TRANSPORT_ROAD
@ TRANSPORT_ROAD
Transport by road vehicle.
Definition: transport_type.h:28
SLV_101
@ SLV_101
101 14233
Definition: saveload.h:168
GamelogOldver
void GamelogOldver()
Logs loading from savegame without gamelog.
Definition: gamelog.cpp:469
VehicleSettings::plane_speed
uint8 plane_speed
divisor for speed of aircraft
Definition: settings_type.h:499
GamelogTestMode
void GamelogTestMode()
Finds last stored game mode or landscape.
Definition: gamelog.cpp:526
VehicleSettings::max_train_length
uint8 max_train_length
maximum length for trains
Definition: settings_type.h:487
GetRoadOwner
static Owner GetRoadOwner(TileIndex t, RoadTramType rtt)
Get the owner of a specific road type.
Definition: road_map.h:234
InitializeRailGUI
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
Definition: rail_gui.cpp:2225
GetOtherTunnelBridgeEnd
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
Definition: tunnelbridge_map.h:78
OverrideManagerBase::GetGRFID
uint32 GetGRFID(uint16 entity_id) const
Gives the GRFID of the file the entity belongs to.
Definition: newgrf_commons.cpp:156
_industry_builder
IndustryBuildData _industry_builder
In-game manager of industries.
Definition: industry_cmd.cpp:67
Station::bus_stops
RoadStop * bus_stops
All the road stops.
Definition: station_base.h:463
RVS_IN_DT_ROAD_STOP
@ RVS_IN_DT_ROAD_STOP
The vehicle is in a drive-through road stop.
Definition: roadveh.h:47
ResetWindowSystem
void ResetWindowSystem()
Reset the windowing system, by means of shutting it down followed by re-initialization.
Definition: window.cpp:1873
SetTileOwner
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
Definition: tile_map.h:198
EF_ROAD_TRAM
@ EF_ROAD_TRAM
Road vehicle is a tram/light rail vehicle.
Definition: engine_type.h:167
TREE_GROUND_SNOW_DESERT
@ TREE_GROUND_SNOW_DESERT
a desert or snow tile, depend on landscape
Definition: tree_map.h:55
CeilDiv
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition: math_func.hpp:280
TRACK_BIT_Y
@ TRACK_BIT_Y
Y-axis track.
Definition: track_type.h:41
ClientSettings::company
CompanySettings company
default values for per-company settings
Definition: settings_type.h:606
SLV_58
@ SLV_58
58 9762
Definition: saveload.h:116
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:588
CCF_TRACK
@ CCF_TRACK
Valid changes while vehicle is driving, and possibly changing tracks.
Definition: train.h:48
GameSettings::vehicle
VehicleSettings vehicle
options for vehicles
Definition: settings_type.h:595
SLV_192
@ SLV_192
192 26700 FS#6066 Fix saving of order backups
Definition: saveload.h:278
SLV_70
@ SLV_70
70 10541
Definition: saveload.h:131
GetIndustrySpec
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
Definition: industry_cmd.cpp:123
OrderBackup
Data for backing up an order of a vehicle so it can be restored after a vehicle is rebuilt in the sam...
Definition: order_backup.h:36
TFP_NONE
@ TFP_NONE
Normal operation.
Definition: train.h:38
md5sumToString
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
Definition: string.cpp:572
GetTileType
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Definition: tile_map.h:96
TFP_STUCK
@ TFP_STUCK
Proceed till next signal, but ignore being stuck till then. This includes force leaving depots.
Definition: train.h:39
TE_FOOD
@ TE_FOOD
Cargo behaves food/fizzy-drinks-like.
Definition: cargotype.h:33
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:326
SLV_121
@ SLV_121
121 16694
Definition: saveload.h:192
LocaleSettings::units_velocity
byte units_velocity
unit system for velocity
Definition: settings_type.h:237
LinkGraphSettings::distribution_armoured
DistributionType distribution_armoured
distribution type for armoured cargo class
Definition: settings_type.h:541
RoadStop
A Stop for a Road Vehicle.
Definition: roadstop_base.h:22
BaseVehicle::type
VehicleType type
Type of vehicle.
Definition: vehicle_type.h:52
SetWaterClass
static void SetWaterClass(TileIndex t, WaterClass wc)
Set the water class at a tile.
Definition: water_map.h:129
TROPICZONE_NORMAL
@ TROPICZONE_NORMAL
Normal tropiczone.
Definition: tile_type.h:77
SLV_95
@ SLV_95
95 12924
Definition: saveload.h:161
FACIL_AIRPORT
@ FACIL_AIRPORT
Station with an airport.
Definition: station_type.h:56
IsWater
static bool IsWater(TileIndex t)
Is it a plain water tile?
Definition: water_map.h:152
GLC_ALL_GOOD
@ GLC_ALL_GOOD
All GRF needed by game are present.
Definition: newgrf_config.h:53
ConvertFromOldCompanyManagerFace
CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face)
Converts an old company manager's face format to the new company manager's face format.
Definition: company_sl.cpp:45
WATER_TILE_LOCK
@ WATER_TILE_LOCK
Water lock.
Definition: water_map.h:42
Swap
static void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:241
INVALID_DIR
@ INVALID_DIR
Flag for an invalid direction.
Definition: direction_type.h:35
Tile::m3
byte m3
General purpose.
Definition: map_type.h:22
LoggedChange
Contains information about one logged change.
Definition: gamelog_internal.h:36
AircraftVehicleInfo
Information about a aircraft vehicle.
Definition: engine_type.h:99
Economy::old_max_loan_unround_fract
uint16 old_max_loan_unround_fract
Old: Fraction of the unrounded max loan.
Definition: economy_type.h:41
CT_INVALID
@ CT_INVALID
Invalid cargo type.
Definition: cargo_type.h:69
_tick_counter
uint64 _tick_counter
Ever incrementing tick counter for setting off various events.
Definition: date.cpp:30
OBJECT_HQ
static const ObjectType OBJECT_HQ
HeadQuarter of a player.
Definition: object_type.h:20
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
GF_REPLACE_WAGON_REMOVAL
@ GF_REPLACE_WAGON_REMOVAL
If set, autoreplace will perform wagon removal on vehicles in this group.
Definition: group.h:69
SetAnimationFrame
static void SetAnimationFrame(TileIndex t, byte frame)
Set a new animation frame.
Definition: tile_map.h:262
ResetOldNames
void ResetOldNames()
Free the memory of the old names array.
Definition: strings_sl.cpp:101
GetTunnelBridgeTransportType
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
Definition: tunnelbridge_map.h:39
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:79
TOWN_HOUSE_COMPLETED
static const byte TOWN_HOUSE_COMPLETED
Simple value that indicates the house has reached the final stage of construction.
Definition: house.h:23
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
IsShipDepotTile
static bool IsShipDepotTile(TileIndex t)
Is it a ship depot tile?
Definition: water_map.h:237
PM_PAUSED_ERROR
@ PM_PAUSED_ERROR
A game paused because a (critical) error.
Definition: openttd.h:65
Company
Definition: company_base.h:117
ConstructionSettings::max_tunnel_length
uint16 max_tunnel_length
maximum length of tunnels
Definition: settings_type.h:347
CLEAR_FIELDS
@ CLEAR_FIELDS
3
Definition: clear_map.h:23
RVSB_IN_DEPOT
@ RVSB_IN_DEPOT
The vehicle is in a depot.
Definition: roadveh.h:39
SLV_153
@ SLV_153
153 21263
Definition: saveload.h:230
DifficultySettings::number_towns
byte number_towns
the amount of towns
Definition: settings_type.h:79
CT_NO_REFIT
@ CT_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
Definition: cargo_type.h:68
SLV_140
@ SLV_140
140 19382
Definition: saveload.h:215
Tile::height
byte height
The height of the northern corner.
Definition: map_type.h:19
SLV_26
@ SLV_26
26 4466
Definition: saveload.h:78
UpdateAllStationVirtCoords
void UpdateAllStationVirtCoords()
Update the virtual coords needed to draw the station sign for all stations.
Definition: station_cmd.cpp:450
OWNER_WATER
@ OWNER_WATER
The tile/execution is done by "water".
Definition: company_type.h:26
AddInflation
bool AddInflation(bool check_year)
Add monthly inflation.
Definition: economy.cpp:720
SLV_9
@ SLV_9
9.0 1909
Definition: saveload.h:54
TOWN_CUSTOM_GROWTH
@ TOWN_CUSTOM_GROWTH
Growth rate is controlled by GS.
Definition: town.h:191
ResetSignalHandlers
static void ResetSignalHandlers()
Resets signal handlers back to original handlers.
Definition: afterload.cpp:332
ReloadNewGRFData
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Definition: afterload.cpp:3247
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:402
EconomySettings::allow_town_roads
bool allow_town_roads
towns are allowed to build roads (always allowed when generating world / in SE)
Definition: settings_type.h:528
Object::build_date
Date build_date
Date of construction.
Definition: object_base.h:27
ConvertOldMultiheadToNew
void ConvertOldMultiheadToNew()
Converts all trains to the new subtype format introduced in savegame 16.2 It also links multiheaded e...
Definition: vehicle_sl.cpp:112
GLC_NOT_FOUND
@ GLC_NOT_FOUND
At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE)
Definition: newgrf_config.h:55
Order
Definition: order_base.h:36
Object::town
Town * town
Town the object is built in.
Definition: object_base.h:25
GoodsEntry::GES_RATING
@ GES_RATING
This indicates whether a cargo has a rating at the station.
Definition: station_base.h:184
SetRailType
static void SetRailType(TileIndex t, RailType r)
Sets the rail type of the given tile.
Definition: rail_map.h:125
Tile::m4
byte m4
General purpose.
Definition: map_type.h:23
GRFListCompatibility
GRFListCompatibility
Status of post-gameload GRF compatibility check.
Definition: newgrf_config.h:52
DAY_TICKS
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
Definition: date_type.h:28
_m
Tile * _m
Tiles of the map.
Definition: map.cpp:30
TOWN_GROWTH_RATE_NONE
static const uint16 TOWN_GROWTH_RATE_NONE
Special value for Town::growth_rate to disable town growth.
Definition: town.h:33
Station::ship_station
TileArea ship_station
Tile area the ship 'station' part covers.
Definition: station_base.h:469
Game::StartNew
static void StartNew()
Start up a new GameScript.
Definition: game_core.cpp:72
SLV_137
@ SLV_137
137 18912
Definition: saveload.h:211
LinkGraphSettings::distribution_pax
DistributionType distribution_pax
distribution type for passengers
Definition: settings_type.h:539
SLV_143
@ SLV_143
143 20048
Definition: saveload.h:218
SLV_34
@ SLV_34
34 6455
Definition: saveload.h:87
SLV_57
@ SLV_57
57 9691
Definition: saveload.h:115
SLV_72
@ SLV_72
72 10601
Definition: saveload.h:133
SLV_152
@ SLV_152
152 21171
Definition: saveload.h:229
FLYING
@ FLYING
Vehicle is flying in the air.
Definition: airport.h:75
OWNER_TOWN
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
Definition: company_type.h:24
LoggedAction
Contains information about one logged action that caused at least one logged change.
Definition: gamelog_internal.h:80
AT_OILRIG
@ AT_OILRIG
Oilrig airport.
Definition: airport.h:38
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
ResetCompanyLivery
void ResetCompanyLivery(Company *c)
Reset the livery schemes to the company's primary colour.
Definition: company_cmd.cpp:519
WL_CRITICAL
@ WL_CRITICAL
Critical errors, the MessageBox is shown in all cases.
Definition: error.h:25
TE_PASSENGERS
@ TE_PASSENGERS
Cargo behaves passenger-like.
Definition: cargotype.h:29
SLV_1
@ SLV_1
1.0 0.1.x, 0.2.x
Definition: saveload.h:37
SLV_190
@ SLV_190
190 26547 Separate order travel and wait times
Definition: saveload.h:275
GroupStatistics::UpdateAfterLoad
static void UpdateAfterLoad()
Update all caches after loading a game, changing NewGRF, etc.
Definition: group_cmd.cpp:100
DAYS_TILL_ORIGINAL_BASE_YEAR
#define DAYS_TILL_ORIGINAL_BASE_YEAR
The offset in days from the '_date == 0' till 'ConvertYMDToDate(ORIGINAL_BASE_YEAR,...
Definition: date_type.h:81
GetInclinedSlopeDirection
static DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
Definition: slope_func.h:239
SetupColoursAndInitialWindow
void SetupColoursAndInitialWindow()
Initialise the default colours (remaps and the likes), and load the main windows.
Definition: main_gui.cpp:538
SettingsDisableElrail
void SettingsDisableElrail(int32 new_value)
_settings_game.disable_elrail callback
Definition: elrail.cpp:596
OLFB_NO_LOAD
@ OLFB_NO_LOAD
Do not load anything.
Definition: order_type.h:66
LinkGraphSettings::distribution_default
DistributionType distribution_default
distribution type for all other goods
Definition: settings_type.h:542
UpdateStationAcceptance
void UpdateStationAcceptance(Station *st, bool show_msg)
Update the acceptance for a station.
Definition: station_cmd.cpp:588
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:558
TileVirtXY
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition: map_func.h:194
SLV_48
@ SLV_48
48 8935
Definition: saveload.h:104
SLV_159
@ SLV_159
159 21962
Definition: saveload.h:237
SLV_177
@ SLV_177
177 24619
Definition: saveload.h:259
SetClearGroundDensity
static void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
Sets ground type and density in one go, also sets the counter to 0.
Definition: clear_map.h:158
SLV_EXTEND_RAILTYPES
@ SLV_EXTEND_RAILTYPES
200 PR#6805 Extend railtypes to 64, adding uint16 to map array.
Definition: saveload.h:288
DoStartupNewCompany
Company * DoStartupNewCompany(bool is_ai, CompanyID company=INVALID_COMPANY)
Create a new company and sets all company variables default values.
Definition: company_cmd.cpp:543
INVALID_TRACK
@ INVALID_TRACK
Flag for an invalid track.
Definition: track_type.h:28