00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #include "../stdafx.h"
00013 #include "../void_map.h"
00014 #include "../signs_base.h"
00015 #include "../depot_base.h"
00016 #include "../window_func.h"
00017 #include "../fios.h"
00018 #include "../gamelog_internal.h"
00019 #include "../network/network.h"
00020 #include "../gfxinit.h"
00021 #include "../functions.h"
00022 #include "../industry.h"
00023 #include "../clear_map.h"
00024 #include "../vehicle_func.h"
00025 #include "../debug.h"
00026 #include "../string_func.h"
00027 #include "../date_func.h"
00028 #include "../roadveh.h"
00029 #include "../train.h"
00030 #include "../station_base.h"
00031 #include "../waypoint_base.h"
00032 #include "../roadstop_base.h"
00033 #include "../tunnelbridge_map.h"
00034 #include "../landscape.h"
00035 #include "../pathfinder/yapf/yapf_cache.h"
00036 #include "../elrail_func.h"
00037 #include "../signs_func.h"
00038 #include "../aircraft.h"
00039 #include "../unmovable_map.h"
00040 #include "../tree_map.h"
00041 #include "../company_func.h"
00042 #include "../road_cmd.h"
00043 #include "../ai/ai.hpp"
00044 #include "../ai/ai_gui.hpp"
00045 #include "../town.h"
00046 #include "../economy_base.h"
00047 #include "../animated_tile_func.h"
00048 #include "../subsidy_base.h"
00049 #include "../subsidy_func.h"
00050 #include "../company_base.h"
00051 #include "../newgrf.h"
00052 #include "../engine_base.h"
00053 #include "../engine_func.h"
00054
00055 #include "table/strings.h"
00056
00057 #include "saveload_internal.h"
00058
00059 #include <signal.h>
00060
00061 extern StringID _switch_mode_errorstr;
00062 extern Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY);
00063 extern void InitializeRailGUI();
00064
00075 void SetWaterClassDependingOnSurroundings(TileIndex t, bool include_invalid_water_class)
00076 {
00077
00078
00079 if (GetTileSlope(t, NULL) != SLOPE_FLAT) {
00080 if (include_invalid_water_class) {
00081 SetWaterClass(t, WATER_CLASS_INVALID);
00082 return;
00083 } else {
00084 NOT_REACHED();
00085 }
00086 }
00087
00088
00089 MarkTileDirtyByTile(t);
00090
00091 if (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1) {
00092
00093 SetWaterClass(t, WATER_CLASS_SEA);
00094 return;
00095 }
00096
00097 bool has_water = false;
00098 bool has_canal = false;
00099 bool has_river = false;
00100
00101 for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
00102 TileIndex neighbour = TileAddByDiagDir(t, dir);
00103 switch (GetTileType(neighbour)) {
00104 case MP_WATER:
00105
00106 if (IsCoast(neighbour)) {
00107 has_water = true;
00108 } else if (!IsLock(neighbour)) {
00109 switch (GetWaterClass(neighbour)) {
00110 case WATER_CLASS_SEA: has_water = true; break;
00111 case WATER_CLASS_CANAL: has_canal = true; break;
00112 case WATER_CLASS_RIVER: has_river = true; break;
00113 default: NOT_REACHED();
00114 }
00115 }
00116 break;
00117
00118 case MP_RAILWAY:
00119
00120 has_water |= (GetRailGroundType(neighbour) == RAIL_GROUND_WATER);
00121 break;
00122
00123 case MP_TREES:
00124
00125 has_water |= (GB(_m[neighbour].m2, 4, 2) == TREE_GROUND_SHORE);
00126 break;
00127
00128 default: break;
00129 }
00130 }
00131
00132 if (!has_water && !has_canal && !has_river && include_invalid_water_class) {
00133 SetWaterClass(t, WATER_CLASS_INVALID);
00134 return;
00135 }
00136
00137 if (has_river && !has_canal) {
00138 SetWaterClass(t, WATER_CLASS_RIVER);
00139 } else if (has_canal || !has_water) {
00140 SetWaterClass(t, WATER_CLASS_CANAL);
00141 } else {
00142 SetWaterClass(t, WATER_CLASS_SEA);
00143 }
00144 }
00145
00146 static void ConvertTownOwner()
00147 {
00148 for (TileIndex tile = 0; tile != MapSize(); tile++) {
00149 switch (GetTileType(tile)) {
00150 case MP_ROAD:
00151 if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m3, 7)) {
00152 _m[tile].m3 = OWNER_TOWN;
00153 }
00154
00155
00156 case MP_TUNNELBRIDGE:
00157 if (GetTileOwner(tile) & 0x80) SetTileOwner(tile, OWNER_TOWN);
00158 break;
00159
00160 default: break;
00161 }
00162 }
00163 }
00164
00165
00166 static void UpdateExclusiveRights()
00167 {
00168 Town *t;
00169
00170 FOR_ALL_TOWNS(t) {
00171 t->exclusivity = INVALID_COMPANY;
00172 }
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 }
00183
00184 static const byte convert_currency[] = {
00185 0, 1, 12, 8, 3,
00186 10, 14, 19, 4, 5,
00187 9, 11, 13, 6, 17,
00188 16, 22, 21, 7, 15,
00189 18, 2, 20,
00190 };
00191
00192
00193 static void UpdateCurrencies()
00194 {
00195 _settings_game.locale.currency = convert_currency[_settings_game.locale.currency];
00196 }
00197
00198
00199
00200
00201 static void UpdateVoidTiles()
00202 {
00203 uint i;
00204
00205 for (i = 0; i < MapMaxY(); ++i) MakeVoid(i * MapSizeX() + MapMaxX());
00206 for (i = 0; i < MapSizeX(); ++i) MakeVoid(MapSizeX() * MapMaxY() + i);
00207 }
00208
00209 static inline RailType UpdateRailType(RailType rt, RailType min)
00210 {
00211 return rt >= min ? (RailType)(rt + 1): rt;
00212 }
00213
00217 void UpdateAllVirtCoords()
00218 {
00219 UpdateAllStationVirtCoords();
00220 UpdateAllSignVirtCoords();
00221 UpdateAllTownVirtCoords();
00222 }
00223
00233 static void InitializeWindowsAndCaches()
00234 {
00235
00236 ResetWindowSystem();
00237 SetupColoursAndInitialWindow();
00238
00239
00240 UpdateAllVirtCoords();
00241 ResetViewportAfterLoadGame();
00242
00243 Company *c;
00244 FOR_ALL_COMPANIES(c) {
00245
00246
00247
00248 if (_file_to_saveload.filetype == FT_SCENARIO && c->inaugurated_year != MIN_YEAR) {
00249 c->inaugurated_year = _cur_year;
00250 }
00251 }
00252
00253 RecomputePrices();
00254
00255 SetCachedEngineCounts();
00256
00257 Station::RecomputeIndustriesNearForAll();
00258 RebuildSubsidisedSourceAndDestinationCache();
00259
00260
00261
00262
00263 UpdateAirportsNoise();
00264
00265 CheckTrainsLengths();
00266 ShowNewGRFError();
00267 ShowAIDebugWindowIfAIError();
00268 }
00269
00270 typedef void (CDECL *SignalHandlerPointer)(int);
00271 static SignalHandlerPointer _prev_segfault = NULL;
00272 static SignalHandlerPointer _prev_abort = NULL;
00273 static SignalHandlerPointer _prev_fpe = NULL;
00274
00275 static void CDECL HandleSavegameLoadCrash(int signum);
00276
00281 static void SetSignalHandlers()
00282 {
00283 _prev_segfault = signal(SIGSEGV, HandleSavegameLoadCrash);
00284 _prev_abort = signal(SIGABRT, HandleSavegameLoadCrash);
00285 _prev_fpe = signal(SIGFPE, HandleSavegameLoadCrash);
00286 }
00287
00291 static void ResetSignalHandlers()
00292 {
00293 signal(SIGSEGV, _prev_segfault);
00294 signal(SIGABRT, _prev_abort);
00295 signal(SIGFPE, _prev_fpe);
00296 }
00297
00303 static const GRFIdentifier *GetOverriddenIdentifier(const GRFConfig *c)
00304 {
00305 const LoggedAction *la = &_gamelog_action[_gamelog_actions - 1];
00306 if (la->at != GLAT_LOAD) return c;
00307
00308 const LoggedChange *lcend = &la->change[la->changes];
00309 for (const LoggedChange *lc = la->change; lc != lcend; lc++) {
00310 if (lc->ct == GLCT_GRFCOMPAT && lc->grfcompat.grfid == c->grfid) return &lc->grfcompat;
00311 }
00312
00313 return c;
00314 }
00315
00317 static bool _saveload_crash_with_missing_newgrfs = false;
00318
00324 bool SaveloadCrashWithMissingNewGRFs()
00325 {
00326 return _saveload_crash_with_missing_newgrfs;
00327 }
00328
00335 static void CDECL HandleSavegameLoadCrash(int signum)
00336 {
00337 ResetSignalHandlers();
00338
00339 char buffer[8192];
00340 char *p = buffer;
00341 p += seprintf(p, lastof(buffer),
00342 "Loading your savegame caused OpenTTD to crash.\n"
00343 "This is most likely caused by a missing NewGRF or a NewGRF that has been\n"
00344 "loaded as replacement for a missing NewGRF. OpenTTD cannot easily\n"
00345 "determine whether a replacement NewGRF is of a newer or older version.\n"
00346 "It will load a NewGRF with the same GRF ID as the missing NewGRF. This\n"
00347 "means that if the author makes incompatible NewGRFs with the same GRF ID\n"
00348 "OpenTTD cannot magically do the right thing. In most cases OpenTTD will\n"
00349 "load the savegame and not crash, but this is an exception.\n"
00350 "Please load the savegame with the appropriate NewGRFs. When loading a\n"
00351 "savegame still crashes when all NewGRFs are found you should file a\n"
00352 "bug report. The missing NewGRFs are:\n");
00353
00354 for (const GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
00355 if (HasBit(c->flags, GCF_COMPATIBLE)) {
00356 const GRFIdentifier *replaced = GetOverriddenIdentifier(c);
00357 char buf[40];
00358 md5sumToString(buf, lastof(buf), replaced->md5sum);
00359 p += seprintf(p, lastof(buffer), "NewGRF %08X (checksum %s) not found.\n Loaded NewGRF \"%s\" with same GRF ID instead.\n", BSWAP32(c->grfid), buf, c->filename);
00360 _saveload_crash_with_missing_newgrfs = true;
00361 }
00362 if (c->status == GCS_NOT_FOUND) {
00363 char buf[40];
00364 md5sumToString(buf, lastof(buf), c->md5sum);
00365 p += seprintf(p, lastof(buffer), "NewGRF %08X (%s) not found; checksum %s.\n", BSWAP32(c->grfid), c->filename, buf);
00366 _saveload_crash_with_missing_newgrfs = true;
00367 }
00368 }
00369
00370 ShowInfo(buffer);
00371
00372 SignalHandlerPointer call = NULL;
00373 switch (signum) {
00374 case SIGSEGV: call = _prev_segfault; break;
00375 case SIGABRT: call = _prev_abort; break;
00376 case SIGFPE: call = _prev_fpe; break;
00377 default: NOT_REACHED();
00378 }
00379 if (call != NULL) call(signum);
00380 }
00381
00387 static void FixOwnerOfRailTrack(TileIndex t)
00388 {
00389 assert(!Company::IsValidID(GetTileOwner(t)) && (IsLevelCrossingTile(t) || IsPlainRailTile(t)));
00390
00391
00392 Train *v = NULL, *w;
00393 FOR_ALL_TRAINS(w) {
00394 if (w->tile == t) {
00395 v = w;
00396 break;
00397 }
00398 }
00399
00400 if (v != NULL) {
00401
00402 SetTileOwner(t, v->owner);
00403 return;
00404 }
00405
00406
00407 for (DiagDirection dd = DIAGDIR_BEGIN; dd < DIAGDIR_END; dd++) {
00408 TileIndex tt = t + TileOffsByDiagDir(dd);
00409 if (GetTileTrackStatus(t, TRANSPORT_RAIL, 0, dd) != 0 &&
00410 GetTileTrackStatus(tt, TRANSPORT_RAIL, 0, ReverseDiagDir(dd)) != 0 &&
00411 Company::IsValidID(GetTileOwner(tt))) {
00412 SetTileOwner(t, GetTileOwner(tt));
00413 return;
00414 }
00415 }
00416
00417 if (IsLevelCrossingTile(t)) {
00418
00419 MakeRoadNormal(t, GetCrossingRoadBits(t), GetRoadTypes(t), GetTownIndex(t),
00420 GetRoadOwner(t, ROADTYPE_ROAD), GetRoadOwner(t, ROADTYPE_TRAM));
00421 return;
00422 }
00423
00424
00425 MakeClear(t, CLEAR_GRASS, 0);
00426 }
00427
00428 bool AfterLoadGame()
00429 {
00430 SetSignalHandlers();
00431
00432 TileIndex map_size = MapSize();
00433 Company *c;
00434
00435 if (CheckSavegameVersion(98)) GamelogOldver();
00436
00437 GamelogTestRevision();
00438 GamelogTestMode();
00439
00440 if (CheckSavegameVersion(98)) GamelogGRFAddList(_grfconfig);
00441
00442 if (CheckSavegameVersion(119)) {
00443 _pause_mode = (_pause_mode == 2) ? PM_PAUSED_NORMAL : PM_UNPAUSED;
00444 } else if (_network_dedicated && (_pause_mode & PM_PAUSED_ERROR) != 0) {
00445 DEBUG(net, 0, "The loading savegame was paused due to an error state.");
00446 DEBUG(net, 0, " The savegame cannot be used for multiplayer!");
00447
00448 ResetSignalHandlers();
00449 return false;
00450 } else if (!_networking || _network_server) {
00451
00452
00453
00454
00455
00456
00457
00458 _pause_mode &= ~PMB_PAUSED_NETWORK;
00459 }
00460
00461
00462 if (CheckSavegameVersion(2)) {
00463 Station *st;
00464 FOR_ALL_STATIONS(st) {
00465 if (st->train_station.tile != 0 && st->train_station.h == 0) {
00466 uint n = _savegame_type == SGT_OTTD ? 4 : 3;
00467 uint w = GB(st->train_station.w, n, n);
00468 uint h = GB(st->train_station.w, 0, n);
00469
00470 if (GetRailStationAxis(st->train_station.tile) != AXIS_X) Swap(w, h);
00471
00472 st->train_station.w = w;
00473 st->train_station.h = h;
00474
00475 assert(GetStationIndex(st->train_station.tile + TileDiffXY(w - 1, h - 1)) == st->index);
00476 }
00477 }
00478 }
00479
00480
00481 if (CheckSavegameVersionOldStyle(2, 1)) ConvertTownOwner();
00482
00483
00484 if (CheckSavegameVersionOldStyle(4, 1)) UpdateExclusiveRights();
00485
00486
00487 if (CheckSavegameVersionOldStyle(4, 2)) UpdateCurrencies();
00488
00489
00490
00491
00492
00493 if (CheckSavegameVersionOldStyle(4, 3)) {
00494 for (TileIndex t = 0; t < map_size; t++) {
00495 if (IsTileType(t, MP_WATER) && GetTileOwner(t) >= MAX_COMPANIES) {
00496 SetTileOwner(t, OWNER_WATER);
00497 }
00498 }
00499 }
00500
00501 if (CheckSavegameVersion(84)) {
00502 FOR_ALL_COMPANIES(c) {
00503 c->name = CopyFromOldName(c->name_1);
00504 if (c->name != NULL) c->name_1 = STR_SV_UNNAMED;
00505 c->president_name = CopyFromOldName(c->president_name_1);
00506 if (c->president_name != NULL) c->president_name_1 = SPECSTR_PRESIDENT_NAME;
00507 }
00508
00509 Station *st;
00510 FOR_ALL_STATIONS(st) {
00511 st->name = CopyFromOldName(st->string_id);
00512
00513 if (st->name != NULL) st->string_id = STR_SV_STNAME_FALLBACK;
00514 }
00515
00516 Town *t;
00517 FOR_ALL_TOWNS(t) {
00518 t->name = CopyFromOldName(t->townnametype);
00519 if (t->name != NULL) t->townnametype = SPECSTR_TOWNNAME_START + _settings_game.game_creation.town_name;
00520 }
00521 }
00522
00523
00524 ResetOldNames();
00525
00526 if (CheckSavegameVersion(106)) {
00527
00528 Station *st;
00529 FOR_ALL_STATIONS(st) {
00530 if (st->airport_tile == 0) st->airport_tile = INVALID_TILE;
00531 if (st->dock_tile == 0) st->dock_tile = INVALID_TILE;
00532 if (st->train_station.tile == 0) st->train_station.tile = INVALID_TILE;
00533 }
00534
00535
00536 Company *c;
00537 FOR_ALL_COMPANIES(c) {
00538 if (c->location_of_HQ == 0 || (CheckSavegameVersion(4) && c->location_of_HQ == 0xFFFF)) {
00539 c->location_of_HQ = INVALID_TILE;
00540 }
00541 }
00542 }
00543
00544
00545 if (_settings_game.vehicle.road_side) _settings_game.vehicle.road_side = 1;
00546
00547
00548 GRFListCompatibility gcf_res = IsGoodGRFConfigList();
00549 if (_networking && gcf_res != GLC_ALL_GOOD) {
00550 SetSaveLoadError(STR_NETWORK_ERROR_CLIENT_NEWGRF_MISMATCH);
00551
00552 ResetSignalHandlers();
00553 return false;
00554 }
00555
00556 switch (gcf_res) {
00557 case GLC_COMPATIBLE: _switch_mode_errorstr = STR_NEWGRF_COMPATIBLE_LOAD_WARNING; break;
00558 case GLC_NOT_FOUND: _switch_mode_errorstr = STR_NEWGRF_DISABLED_WARNING; _pause_mode = PM_PAUSED_ERROR; break;
00559 default: break;
00560 }
00561
00562
00563
00564 SetDate(_date);
00565
00566
00567 if (CheckSavegameVersion(95)) _settings_game.vehicle.dynamic_engines = 0;
00568
00569
00570 GfxLoadSprites();
00571 LoadStringWidthTable();
00572
00573
00574 CopyTempEngineData();
00575
00576
00577
00578 if (CheckSavegameVersionOldStyle(17, 1)) ConvertOldMultiheadToNew();
00579
00580
00581 ConnectMultiheadedTrains();
00582
00583
00584
00585
00586
00587
00588
00589 CargoPacket::AfterLoad();
00590
00591
00592 AfterLoadVehicles(true);
00593
00594
00595 {
00596 Company *c;
00597 FOR_ALL_COMPANIES(c) {
00598 if (c->is_ai && c->ai_instance == NULL) AI::StartNew(c->index);
00599 }
00600 }
00601
00602
00603 if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, UINT_MAX)) {
00604 SetSaveLoadError(STR_ERROR_NO_TOWN_IN_SCENARIO);
00605
00606 ResetSignalHandlers();
00607 return false;
00608 }
00609
00610
00611
00612
00613
00614 if (CheckSavegameVersion(87)) UpdateVoidTiles();
00615
00616
00617
00618
00619
00620 if (!Company::IsValidID(COMPANY_FIRST) && (!_networking || (_networking && _network_server && !_network_dedicated)))
00621 DoStartupNewCompany(false);
00622
00623
00624 CargoPayment *cp;
00625 FOR_ALL_CARGO_PAYMENTS(cp) {
00626 cp->front->cargo_payment = cp;
00627 cp->current_station = cp->front->last_station_visited;
00628 }
00629
00630 if (CheckSavegameVersion(72)) {
00631
00632 for (TileIndex t = 0; t < MapSize(); t++) {
00633 switch (GetTileType(t)) {
00634 default: break;
00635
00636 case MP_WATER:
00637 if (GetWaterTileType(t) == WATER_TILE_LOCK && GetTileOwner(t) == OWNER_WATER) SetTileOwner(t, OWNER_NONE);
00638 break;
00639
00640 case MP_STATION: {
00641 if (HasBit(_m[t].m6, 3)) SetBit(_m[t].m6, 2);
00642 StationGfx gfx = GetStationGfx(t);
00643 StationType st;
00644 if ( IsInsideMM(gfx, 0, 8)) {
00645 st = STATION_RAIL;
00646 SetStationGfx(t, gfx - 0);
00647 } else if (IsInsideMM(gfx, 8, 67)) {
00648 st = STATION_AIRPORT;
00649 SetStationGfx(t, gfx - 8);
00650 } else if (IsInsideMM(gfx, 67, 71)) {
00651 st = STATION_TRUCK;
00652 SetStationGfx(t, gfx - 67);
00653 } else if (IsInsideMM(gfx, 71, 75)) {
00654 st = STATION_BUS;
00655 SetStationGfx(t, gfx - 71);
00656 } else if (gfx == 75) {
00657 st = STATION_OILRIG;
00658 SetStationGfx(t, gfx - 75);
00659 } else if (IsInsideMM(gfx, 76, 82)) {
00660 st = STATION_DOCK;
00661 SetStationGfx(t, gfx - 76);
00662 } else if (gfx == 82) {
00663 st = STATION_BUOY;
00664 SetStationGfx(t, gfx - 82);
00665 } else if (IsInsideMM(gfx, 83, 168)) {
00666 st = STATION_AIRPORT;
00667 SetStationGfx(t, gfx - 83 + 67 - 8);
00668 } else if (IsInsideMM(gfx, 168, 170)) {
00669 st = STATION_TRUCK;
00670 SetStationGfx(t, gfx - 168 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
00671 } else if (IsInsideMM(gfx, 170, 172)) {
00672 st = STATION_BUS;
00673 SetStationGfx(t, gfx - 170 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
00674 } else {
00675
00676 ResetSignalHandlers();
00677 return false;
00678 }
00679 SB(_m[t].m6, 3, 3, st);
00680 } break;
00681 }
00682 }
00683 }
00684
00685 for (TileIndex t = 0; t < map_size; t++) {
00686 switch (GetTileType(t)) {
00687 case MP_STATION: {
00688 BaseStation *bst = BaseStation::GetByTile(t);
00689
00690
00691 bst->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
00692
00693
00694 if (!Station::IsExpected(bst)) break;
00695 Station *st = Station::From(bst);
00696
00697 switch (GetStationType(t)) {
00698 case STATION_TRUCK:
00699 case STATION_BUS:
00700 if (CheckSavegameVersion(6)) {
00701
00702
00703
00704 RoadStop *rs = new RoadStop(t);
00705 if (rs == NULL) error("Too many road stops in savegame");
00706
00707 RoadStop **head =
00708 IsTruckStop(t) ? &st->truck_stops : &st->bus_stops;
00709 *head = rs;
00710 }
00711 break;
00712
00713 case STATION_OILRIG: {
00714
00715
00716
00717
00718 TileIndex t1 = TILE_ADDXY(t, 0, 1);
00719 if (IsTileType(t1, MP_INDUSTRY) &&
00720 GetIndustryGfx(t1) == GFX_OILRIG_1) {
00721
00722
00723
00724
00725 Station::GetByTile(t)->airport_type = AT_OILRIG;
00726 } else {
00727 DeleteOilRig(t);
00728 }
00729 break;
00730 }
00731
00732 default: break;
00733 }
00734 break;
00735 }
00736
00737 default: break;
00738 }
00739 }
00740
00741
00742
00743 if (CheckSavegameVersionOldStyle(2, 2)) UpdateOldAircraft();
00744
00745
00746
00747
00748 if (CheckSavegameVersionOldStyle(6, 1)) {
00749 for (TileIndex t = 0; t < map_size; t++) {
00750 switch (GetTileType(t)) {
00751 case MP_HOUSE:
00752 _m[t].m4 = _m[t].m2;
00753 SetTownIndex(t, CalcClosestTownFromTile(t)->index);
00754 break;
00755
00756 case MP_ROAD:
00757 _m[t].m4 |= (_m[t].m2 << 4);
00758 if ((GB(_m[t].m5, 4, 2) == ROAD_TILE_CROSSING ? (Owner)_m[t].m3 : GetTileOwner(t)) == OWNER_TOWN) {
00759 SetTownIndex(t, CalcClosestTownFromTile(t)->index);
00760 } else {
00761 SetTownIndex(t, 0);
00762 }
00763 break;
00764
00765 default: break;
00766 }
00767 }
00768 }
00769
00770
00771 if (CheckSavegameVersion(111)) {
00772 _settings_game.construction.freeform_edges = false;
00773 }
00774
00775
00776
00777 if (CheckSavegameVersion(9)) {
00778 Town *t;
00779 FOR_ALL_TOWNS(t) UpdateTownMaxPass(t);
00780 }
00781
00782
00783
00784 if (CheckSavegameVersion(16)) {
00785 FOR_ALL_COMPANIES(c) {
00786 c->engine_renew_list = NULL;
00787 c->settings.engine_renew = false;
00788 c->settings.engine_renew_months = 6;
00789 c->settings.engine_renew_money = 100000;
00790 }
00791
00792
00793
00794
00795
00796
00797
00798 c = Company::GetIfValid(COMPANY_FIRST);
00799 if (!_network_dedicated && c != NULL) {
00800 c->settings = _settings_client.company;
00801 }
00802 }
00803
00804 if (CheckSavegameVersion(48)) {
00805 for (TileIndex t = 0; t < map_size; t++) {
00806 switch (GetTileType(t)) {
00807 case MP_RAILWAY:
00808 if (IsPlainRail(t)) {
00809
00810
00811 uint tmp = GB(_m[t].m4, 0, 4);
00812 SB(_m[t].m4, 0, 4, GB(_m[t].m2, 0, 4));
00813 SB(_m[t].m2, 0, 4, tmp);
00814 } else if (HasBit(_m[t].m5, 2)) {
00815
00816 ClrBit(_m[t].m5, 2);
00817 ClrBit(_m[t].m5, 6);
00818 }
00819 break;
00820
00821 case MP_ROAD:
00822
00823
00824 Swap(_m[t].m3, _m[t].m4);
00825 break;
00826
00827 default: break;
00828 }
00829 }
00830 }
00831
00832 if (CheckSavegameVersion(61)) {
00833
00834 bool old_bridge = CheckSavegameVersion(42);
00835 for (TileIndex t = 0; t < map_size; t++) {
00836 switch (GetTileType(t)) {
00837 case MP_ROAD:
00838 SB(_m[t].m5, 6, 2, GB(_m[t].m5, 4, 2));
00839 switch (GetRoadTileType(t)) {
00840 default: NOT_REACHED();
00841 case ROAD_TILE_NORMAL:
00842 SB(_m[t].m4, 0, 4, GB(_m[t].m5, 0, 4));
00843 SB(_m[t].m4, 4, 4, 0);
00844 SB(_m[t].m6, 2, 4, 0);
00845 break;
00846 case ROAD_TILE_CROSSING:
00847 SB(_m[t].m4, 5, 2, GB(_m[t].m5, 2, 2));
00848 break;
00849 case ROAD_TILE_DEPOT: break;
00850 }
00851 SetRoadTypes(t, ROADTYPES_ROAD);
00852 break;
00853
00854 case MP_STATION:
00855 if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD);
00856 break;
00857
00858 case MP_TUNNELBRIDGE:
00859
00860 if (old_bridge && IsBridge(t) && HasBit(_m[t].m5, 6)) break;
00861 if (((old_bridge && IsBridge(t)) ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) {
00862 SetRoadTypes(t, ROADTYPES_ROAD);
00863 }
00864 break;
00865
00866 default: break;
00867 }
00868 }
00869 }
00870
00871 if (CheckSavegameVersion(114)) {
00872 bool fix_roadtypes = !CheckSavegameVersion(61);
00873 bool old_bridge = CheckSavegameVersion(42);
00874
00875 for (TileIndex t = 0; t < map_size; t++) {
00876 switch (GetTileType(t)) {
00877 case MP_ROAD:
00878 if (fix_roadtypes) SetRoadTypes(t, (RoadTypes)GB(_me[t].m7, 5, 3));
00879 SB(_me[t].m7, 5, 1, GB(_m[t].m3, 7, 1));
00880 switch (GetRoadTileType(t)) {
00881 default: NOT_REACHED();
00882 case ROAD_TILE_NORMAL:
00883 SB(_me[t].m7, 0, 4, GB(_m[t].m3, 0, 4));
00884 SB(_m[t].m6, 3, 3, GB(_m[t].m3, 4, 3));
00885 SB(_m[t].m3, 0, 4, GB(_m[t].m4, 4, 4));
00886 SB(_m[t].m3, 4, 4, GB(_m[t].m5, 0, 4));
00887 SB(_m[t].m5, 0, 4, GB(_m[t].m4, 0, 4));
00888 break;
00889
00890 case ROAD_TILE_CROSSING:
00891 SB(_me[t].m7, 0, 5, GB(_m[t].m4, 0, 5));
00892 SB(_m[t].m6, 3, 3, GB(_m[t].m3, 4, 3));
00893 SB(_m[t].m3, 4, 4, GB(_m[t].m5, 0, 4));
00894 SB(_m[t].m5, 0, 1, GB(_m[t].m4, 6, 1));
00895 SB(_m[t].m5, 5, 1, GB(_m[t].m4, 5, 1));
00896 break;
00897
00898 case ROAD_TILE_DEPOT:
00899 break;
00900 }
00901 if (!IsRoadDepot(t) && !HasTownOwnedRoad(t)) {
00902 const Town *town = CalcClosestTownFromTile(t);
00903 if (town != NULL) SetTownIndex(t, town->index);
00904 }
00905 _m[t].m4 = 0;
00906 break;
00907
00908 case MP_STATION:
00909 if (!IsRoadStop(t)) break;
00910
00911 if (fix_roadtypes) SetRoadTypes(t, (RoadTypes)GB(_m[t].m3, 0, 3));
00912 SB(_me[t].m7, 0, 5, HasBit(_m[t].m6, 2) ? OWNER_TOWN : GetTileOwner(t));
00913 SB(_m[t].m3, 4, 4, _m[t].m1);
00914 _m[t].m4 = 0;
00915 break;
00916
00917 case MP_TUNNELBRIDGE:
00918 if (old_bridge && IsBridge(t) && HasBit(_m[t].m5, 6)) break;
00919 if (((old_bridge && IsBridge(t)) ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) {
00920 if (fix_roadtypes) SetRoadTypes(t, (RoadTypes)GB(_m[t].m3, 0, 3));
00921
00922 Owner o = GetTileOwner(t);
00923 SB(_me[t].m7, 0, 5, o);
00924 SB(_m[t].m3, 4, 4, o == OWNER_NONE ? OWNER_TOWN : o);
00925 }
00926 SB(_m[t].m6, 2, 4, GB(_m[t].m2, 4, 4));
00927 SB(_me[t].m7, 5, 1, GB(_m[t].m4, 7, 1));
00928
00929 _m[t].m2 = 0;
00930 _m[t].m4 = 0;
00931 break;
00932
00933 default: break;
00934 }
00935 }
00936 }
00937
00938 if (CheckSavegameVersion(42)) {
00939 Vehicle *v;
00940
00941 for (TileIndex t = 0; t < map_size; t++) {
00942 if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t);
00943 if (IsBridgeTile(t)) {
00944 if (HasBit(_m[t].m5, 6)) {
00945 Axis axis = (Axis)GB(_m[t].m5, 0, 1);
00946
00947 if (HasBit(_m[t].m5, 5)) {
00948 if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) {
00949 MakeRailNormal(
00950 t,
00951 GetTileOwner(t),
00952 axis == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X,
00953 GetRailType(t)
00954 );
00955 } else {
00956 TownID town = IsTileOwner(t, OWNER_TOWN) ? ClosestTownFromTile(t, UINT_MAX)->index : 0;
00957
00958 MakeRoadNormal(
00959 t,
00960 axis == AXIS_X ? ROAD_Y : ROAD_X,
00961 ROADTYPES_ROAD,
00962 town,
00963 GetTileOwner(t), OWNER_NONE
00964 );
00965 }
00966 } else {
00967 if (GB(_m[t].m5, 3, 2) == 0) {
00968 MakeClear(t, CLEAR_GRASS, 3);
00969 } else {
00970 if (GetTileSlope(t, NULL) != SLOPE_FLAT) {
00971 MakeShore(t);
00972 } else {
00973 if (GetTileOwner(t) == OWNER_WATER) {
00974 MakeSea(t);
00975 } else {
00976 MakeCanal(t, GetTileOwner(t), Random());
00977 }
00978 }
00979 }
00980 }
00981 SetBridgeMiddle(t, axis);
00982 } else {
00983 Axis axis = (Axis)GB(_m[t].m5, 0, 1);
00984 uint north_south = GB(_m[t].m5, 5, 1);
00985 DiagDirection dir = ReverseDiagDir(XYNSToDiagDir(axis, north_south));
00986 TransportType type = (TransportType)GB(_m[t].m5, 1, 2);
00987
00988 _m[t].m5 = 1 << 7 | type << 2 | dir;
00989 }
00990 }
00991 }
00992
00993 FOR_ALL_VEHICLES(v) {
00994 if (v->type != VEH_TRAIN && v->type != VEH_ROAD) continue;
00995 if (IsBridgeTile(v->tile)) {
00996 DiagDirection dir = GetTunnelBridgeDirection(v->tile);
00997
00998 if (dir != DirToDiagDir(v->direction)) continue;
00999 switch (dir) {
01000 default: NOT_REACHED();
01001 case DIAGDIR_NE: if ((v->x_pos & 0xF) != 0) continue; break;
01002 case DIAGDIR_SE: if ((v->y_pos & 0xF) != TILE_SIZE - 1) continue; break;
01003 case DIAGDIR_SW: if ((v->x_pos & 0xF) != TILE_SIZE - 1) continue; break;
01004 case DIAGDIR_NW: if ((v->y_pos & 0xF) != 0) continue; break;
01005 }
01006 } else if (v->z_pos > GetSlopeZ(v->x_pos, v->y_pos)) {
01007 v->tile = GetNorthernBridgeEnd(v->tile);
01008 } else {
01009 continue;
01010 }
01011 if (v->type == VEH_TRAIN) {
01012 Train::From(v)->track = TRACK_BIT_WORMHOLE;
01013 } else {
01014 RoadVehicle::From(v)->state = RVSB_WORMHOLE;
01015 }
01016 }
01017 }
01018
01019
01020 if (CheckSavegameVersion(24)) {
01021 RailType min_rail = RAILTYPE_ELECTRIC;
01022
01023 Train *v;
01024 FOR_ALL_TRAINS(v) {
01025 RailType rt = RailVehInfo(v->engine_type)->railtype;
01026
01027 v->railtype = rt;
01028 if (rt == RAILTYPE_ELECTRIC) min_rail = RAILTYPE_RAIL;
01029 }
01030
01031
01032 for (TileIndex t = 0; t < map_size; t++) {
01033 switch (GetTileType(t)) {
01034 case MP_RAILWAY:
01035 SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
01036 break;
01037
01038 case MP_ROAD:
01039 if (IsLevelCrossing(t)) {
01040 SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
01041 }
01042 break;
01043
01044 case MP_STATION:
01045 if (HasStationRail(t)) {
01046 SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
01047 }
01048 break;
01049
01050 case MP_TUNNELBRIDGE:
01051 if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) {
01052 SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
01053 }
01054 break;
01055
01056 default:
01057 break;
01058 }
01059 }
01060
01061 FOR_ALL_TRAINS(v) {
01062 if (v->IsFrontEngine() || v->IsFreeWagon()) v->ConsistChanged(true);
01063 }
01064
01065 }
01066
01067
01068
01069
01070 if (CheckSavegameVersionOldStyle(16, 1)) {
01071 FOR_ALL_COMPANIES(c) c->settings.renew_keep_length = false;
01072 }
01073
01074 if (CheckSavegameVersion(123)) {
01075
01076 MoveWaypointsToBaseStations();
01077
01078 MoveBuoysToWaypoints();
01079 }
01080
01081
01082
01083 if (CheckSavegameVersion(21) && !CheckSavegameVersion(15)) {
01084 for (TileIndex t = 0; t < map_size; t++) {
01085 switch (GetTileType(t)) {
01086 case MP_RAILWAY:
01087 if (HasSignals(t)) {
01088
01089 if (HasBit(_m[t].m2, 2)) SetSignalType(t, TRACK_X, SIGTYPE_COMBO);
01090
01091
01092 SetSignalVariant(t, TRACK_X, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC);
01093 ClrBit(_m[t].m2, 3);
01094 }
01095
01096
01097 if (!IsRailDepotTile(t)) {
01098 SB(_m[t].m4, 4, 4, 0);
01099 } else {
01100 ClrBit(_m[t].m3, 6);
01101 }
01102 break;
01103
01104 case MP_STATION:
01105 ClrBit(_m[t].m3, 6);
01106 break;
01107
01108 default: break;
01109 }
01110 }
01111 }
01112
01113 if (CheckSavegameVersion(25)) {
01114 RoadVehicle *rv;
01115 FOR_ALL_ROADVEHICLES(rv) {
01116 rv->vehstatus &= ~0x40;
01117 }
01118 }
01119
01120 if (CheckSavegameVersion(26)) {
01121 Station *st;
01122 FOR_ALL_STATIONS(st) {
01123 st->last_vehicle_type = VEH_INVALID;
01124 }
01125 }
01126
01127 YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK);
01128
01129 if (CheckSavegameVersion(34)) FOR_ALL_COMPANIES(c) ResetCompanyLivery(c);
01130
01131 FOR_ALL_COMPANIES(c) {
01132 c->avail_railtypes = GetCompanyRailtypes(c->index);
01133 c->avail_roadtypes = GetCompanyRoadtypes(c->index);
01134 }
01135
01136 if (!CheckSavegameVersion(27)) AfterLoadStations();
01137
01138
01139
01140 if (CheckSavegameVersion(31)) {
01141 Station *st;
01142 Waypoint *wp;
01143 Engine *e;
01144 Industry *i;
01145 Vehicle *v;
01146
01147 _date += DAYS_TILL_ORIGINAL_BASE_YEAR;
01148 _cur_year += ORIGINAL_BASE_YEAR;
01149
01150 FOR_ALL_STATIONS(st) st->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
01151 FOR_ALL_WAYPOINTS(wp) wp->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
01152 FOR_ALL_ENGINES(e) e->intro_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
01153 FOR_ALL_COMPANIES(c) c->inaugurated_year += ORIGINAL_BASE_YEAR;
01154 FOR_ALL_INDUSTRIES(i) i->last_prod_year += ORIGINAL_BASE_YEAR;
01155
01156 FOR_ALL_VEHICLES(v) {
01157 v->date_of_last_service += DAYS_TILL_ORIGINAL_BASE_YEAR;
01158 v->build_year += ORIGINAL_BASE_YEAR;
01159 }
01160 }
01161
01162
01163
01164
01165 if (CheckSavegameVersion(32)) {
01166 Industry *i;
01167
01168 for (TileIndex t = 0; t < map_size; t++) {
01169 if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_FIELDS)) {
01170
01171 MakeClear(t, CLEAR_GRASS, 3);
01172 } else if (IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)) {
01173
01174 SetFenceSE(t, 0);
01175 SetFenceSW(t, 0);
01176 }
01177 }
01178
01179 FOR_ALL_INDUSTRIES(i) {
01180 uint j;
01181
01182 if (GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_PLANT_ON_BUILT) {
01183 for (j = 0; j != 50; j++) PlantRandomFarmField(i);
01184 }
01185 }
01186 }
01187
01188
01189 if (CheckSavegameVersion(36)) {
01190 Order *order;
01191 Vehicle *v;
01192
01193 FOR_ALL_ORDERS(order) {
01194 order->SetRefit(CT_NO_REFIT);
01195 }
01196
01197 FOR_ALL_VEHICLES(v) {
01198 v->current_order.SetRefit(CT_NO_REFIT);
01199 }
01200 }
01201
01202
01203
01204 if (CheckSavegameVersion(38)) _settings_game.vehicle.disable_elrails = false;
01205
01206 SettingsDisableElrail(_settings_game.vehicle.disable_elrails);
01207 InitializeRailGUI();
01208
01209
01210
01211 if (CheckSavegameVersion(53)) {
01212 for (TileIndex t = 0; t < map_size; t++) {
01213 if (IsTileType(t, MP_HOUSE)) {
01214 if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) {
01215
01216
01217 SB(_m[t].m5, 3, 2, GB(_m[t].m3, 6, 2));
01218 SB(_m[t].m3, 6, 2, 0);
01219
01220
01221 SetHouseCompleted(t, false);
01222 } else {
01223
01224
01225 SB(_me[t].m7, 0, 1, HasBit(_m[t].m5, 7));
01226 ClrBit(_m[t].m5, 7);
01227
01228
01229
01230 ClrBit(_m[t].m1, 7);
01231
01232
01233
01234
01235 SetLiftPosition(t, GB(_m[t].m1, 0, 6 ));
01236
01237 _m[t].m1 = 0;
01238 _m[t].m3 = 0;
01239 SetHouseCompleted(t, true);
01240 }
01241 }
01242 }
01243 }
01244
01245
01246 UpdateHousesAndTowns();
01247
01248 if (CheckSavegameVersion(43)) {
01249 for (TileIndex t = 0; t < map_size; t++) {
01250 if (IsTileType(t, MP_INDUSTRY)) {
01251 switch (GetIndustryGfx(t)) {
01252 case GFX_POWERPLANT_SPARKS:
01253 SetIndustryAnimationState(t, GB(_m[t].m1, 2, 5));
01254 break;
01255
01256 case GFX_OILWELL_ANIMATED_1:
01257 case GFX_OILWELL_ANIMATED_2:
01258 case GFX_OILWELL_ANIMATED_3:
01259 SetIndustryAnimationState(t, GB(_m[t].m1, 0, 2));
01260 break;
01261
01262 case GFX_COAL_MINE_TOWER_ANIMATED:
01263 case GFX_COPPER_MINE_TOWER_ANIMATED:
01264 case GFX_GOLD_MINE_TOWER_ANIMATED:
01265 SetIndustryAnimationState(t, _m[t].m1);
01266 break;
01267
01268 default:
01269 break;
01270 }
01271 }
01272 }
01273 }
01274
01275 if (CheckSavegameVersion(45)) {
01276 Vehicle *v;
01277
01278
01279
01280
01281
01282 FOR_ALL_VEHICLES(v) {
01283 ClrBit(v->vehicle_flags, 2);
01284 }
01285 }
01286
01287
01288
01289 if (CheckSavegameVersion(46)) {
01290 Waypoint *wp;
01291 FOR_ALL_WAYPOINTS(wp) {
01292 if ((wp->facilities & FACIL_DOCK) != 0 && IsTileOwner(wp->xy, OWNER_NONE) && TileHeight(wp->xy) == 0) SetTileOwner(wp->xy, OWNER_WATER);
01293 }
01294 }
01295
01296 if (CheckSavegameVersion(50)) {
01297 Aircraft *v;
01298
01299 FOR_ALL_AIRCRAFT(v) {
01300 if (v->subtype <= AIR_AIRCRAFT) {
01301 const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type);
01302 v->cur_speed *= 129;
01303 v->cur_speed /= 10;
01304 v->max_speed = avi->max_speed;
01305 v->acceleration = avi->acceleration;
01306 }
01307 }
01308 }
01309
01310 if (CheckSavegameVersion(49)) FOR_ALL_COMPANIES(c) c->face = ConvertFromOldCompanyManagerFace(c->face);
01311
01312 if (CheckSavegameVersion(52)) {
01313 for (TileIndex t = 0; t < map_size; t++) {
01314 if (IsStatueTile(t)) {
01315 _m[t].m2 = CalcClosestTownFromTile(t)->index;
01316 }
01317 }
01318 }
01319
01320
01321
01322
01323 if (CheckSavegameVersion(56)) {
01324 Town *t;
01325
01326 FOR_ALL_TOWNS(t) {
01327 if (_settings_game.economy.larger_towns != 0 && (t->index % _settings_game.economy.larger_towns) == 0) {
01328 t->larger_town = true;
01329 }
01330 }
01331 }
01332
01333 if (CheckSavegameVersion(57)) {
01334 Vehicle *v;
01335
01336 FOR_ALL_VEHICLES(v) {
01337 if ((v->type != VEH_TRAIN || Train::From(v)->IsFrontEngine()) &&
01338 !(v->vehstatus & (VS_STOPPED | VS_CRASHED)) &&
01339 v->current_order.IsType(OT_LOADING)) {
01340 Station::Get(v->last_station_visited)->loading_vehicles.push_back(v);
01341
01342
01343
01344 ClrBit(v->vehicle_flags, VF_LOADING_FINISHED);
01345 }
01346 }
01347 } else if (CheckSavegameVersion(59)) {
01348
01349
01350 Station *st;
01351 FOR_ALL_STATIONS(st) {
01352 std::list<Vehicle *>::iterator iter;
01353 for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end();) {
01354 Vehicle *v = *iter;
01355 iter++;
01356 if (!v->current_order.IsType(OT_LOADING)) st->loading_vehicles.remove(v);
01357 }
01358 }
01359 }
01360
01361 if (CheckSavegameVersion(58)) {
01362
01363
01364 if (_settings_game.difficulty.number_industries > 0) {
01365 _settings_game.difficulty.number_industries++;
01366 }
01367
01368
01369 _settings_game.difficulty.number_towns++;
01370 }
01371
01372 if (CheckSavegameVersion(64)) {
01373
01374 for (TileIndex t = 0; t < map_size; t++) {
01375 if (IsTileType(t, MP_RAILWAY) && HasSignals(t)) {
01376 SetSignalStates(t, GB(_m[t].m2, 4, 4));
01377 SetSignalVariant(t, INVALID_TRACK, GetSignalVariant(t, TRACK_X));
01378 SetSignalType(t, INVALID_TRACK, GetSignalType(t, TRACK_X));
01379 ClrBit(_m[t].m2, 7);
01380 }
01381 }
01382 }
01383
01384 if (CheckSavegameVersion(69)) {
01385
01386 RoadVehicle *rv;
01387 FOR_ALL_ROADVEHICLES(rv) {
01388 if (rv->state == 250 || rv->state == 251) {
01389 SetBit(rv->state, 2);
01390 }
01391 }
01392 }
01393
01394 if (CheckSavegameVersion(70)) {
01395
01396 Industry *i;
01397 FOR_ALL_INDUSTRIES(i) i->founder = OWNER_NONE;
01398 }
01399
01400
01401
01402 if (CheckSavegameVersion(82)) {
01403 for (TileIndex t = 0; t < map_size; t++) {
01404 if (IsTileType(t, MP_WATER) &&
01405 GetWaterTileType(t) == WATER_TILE_CLEAR &&
01406 GetTileOwner(t) == OWNER_WATER &&
01407 TileHeight(t) != 0) {
01408 SetTileOwner(t, OWNER_NONE);
01409 }
01410 }
01411 }
01412
01413
01414
01415
01416
01417
01418
01419 if (CheckSavegameVersion(83)) {
01420 for (TileIndex t = 0; t < map_size; t++) {
01421 if (IsTileType(t, MP_WATER) && IsShipDepot(t)) {
01422 _m[t].m4 = (TileHeight(t) == 0) ? OWNER_WATER : OWNER_NONE;
01423 }
01424 }
01425 }
01426
01427 if (CheckSavegameVersion(74)) {
01428 Station *st;
01429 FOR_ALL_STATIONS(st) {
01430 for (CargoID c = 0; c < NUM_CARGO; c++) {
01431 st->goods[c].last_speed = 0;
01432 if (st->goods[c].cargo.Count() != 0) SetBit(st->goods[c].acceptance_pickup, GoodsEntry::PICKUP);
01433 }
01434 }
01435 }
01436
01437 if (CheckSavegameVersion(78)) {
01438 Industry *i;
01439 uint j;
01440 FOR_ALL_INDUSTRIES(i) {
01441 const IndustrySpec *indsp = GetIndustrySpec(i->type);
01442 for (j = 0; j < lengthof(i->produced_cargo); j++) {
01443 i->produced_cargo[j] = indsp->produced_cargo[j];
01444 }
01445 for (j = 0; j < lengthof(i->accepts_cargo); j++) {
01446 i->accepts_cargo[j] = indsp->accepts_cargo[j];
01447 }
01448 }
01449 }
01450
01451
01452
01453
01454
01455 if (CheckSavegameVersion(81)) {
01456 for (TileIndex t = 0; t < map_size; t++) {
01457 if (GetTileType(t) == MP_TREES) {
01458 TreeGround groundType = (TreeGround)GB(_m[t].m2, 4, 2);
01459 if (groundType != TREE_GROUND_SNOW_DESERT) SB(_m[t].m2, 6, 2, 3);
01460 }
01461 }
01462 }
01463
01464
01465 if (CheckSavegameVersion(93)) {
01466
01467 Order *order;
01468 FOR_ALL_ORDERS(order) order->ConvertFromOldSavegame();
01469
01470 Vehicle *v;
01471 FOR_ALL_VEHICLES(v) {
01472 if (v->orders.list != NULL && v->orders.list->GetFirstOrder() != NULL && v->orders.list->GetFirstOrder()->IsType(OT_NOTHING)) {
01473 v->orders.list->FreeChain();
01474 v->orders.list = NULL;
01475 }
01476
01477 v->current_order.ConvertFromOldSavegame();
01478 if (v->type == VEH_ROAD && v->IsPrimaryVehicle() && v->FirstShared() == v) {
01479 FOR_VEHICLE_ORDERS(v, order) order->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
01480 }
01481 }
01482 } else if (CheckSavegameVersion(94)) {
01483
01484 Order *order;
01485 FOR_ALL_ORDERS(order) {
01486 if ((order->GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
01487 order->SetUnloadType(OUFB_TRANSFER);
01488 order->SetLoadType(OLFB_NO_LOAD);
01489 }
01490 }
01491
01492 Vehicle *v;
01493 FOR_ALL_VEHICLES(v) {
01494 if ((v->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
01495 v->current_order.SetUnloadType(OUFB_TRANSFER);
01496 v->current_order.SetLoadType(OLFB_NO_LOAD);
01497 }
01498 }
01499 }
01500
01501 if (CheckSavegameVersion(84)) {
01502
01503
01504
01505
01506
01507
01508 FOR_ALL_COMPANIES(c) {
01509 for (uint i = 0; i < 4; i++) {
01510 CompanyID company = c->share_owners[i];
01511 if (company == INVALID_COMPANY) continue;
01512 if (!Company::IsValidID(company) || company == c->index) c->share_owners[i] = INVALID_COMPANY;
01513 }
01514 }
01515 }
01516
01517 if (CheckSavegameVersion(86)) {
01518 for (TileIndex t = 0; t < map_size; t++) {
01519
01520 if (IsTileType(t, MP_WATER)) {
01521 if (GetWaterClass(t) != WATER_CLASS_RIVER) {
01522 if (IsWater(t)) {
01523 Owner o = GetTileOwner(t);
01524 if (o == OWNER_WATER) {
01525 MakeSea(t);
01526 } else {
01527 MakeCanal(t, o, Random());
01528 }
01529 } else if (IsShipDepot(t)) {
01530 Owner o = (Owner)_m[t].m4;
01531 SetWaterClass(t, o == OWNER_WATER ? WATER_CLASS_SEA : WATER_CLASS_CANAL);
01532 }
01533 }
01534 }
01535 }
01536
01537
01538
01539
01540 for (TileIndex t = 0; t < map_size; t++) {
01541 if (GetTileSlope(t, NULL) != SLOPE_FLAT) continue;
01542
01543 if (IsTileType(t, MP_WATER) && IsLock(t)) SetWaterClassDependingOnSurroundings(t, false);
01544 if (IsTileType(t, MP_STATION) && (IsDock(t) || IsBuoy(t))) SetWaterClassDependingOnSurroundings(t, false);
01545 }
01546 }
01547
01548 if (CheckSavegameVersion(87)) {
01549 for (TileIndex t = 0; t < map_size; t++) {
01550
01551 if ((IsTileType(t, MP_WATER) || IsBuoyTile(t)) &&
01552 (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1)) {
01553
01554
01555 SetWaterClass(t, WATER_CLASS_SEA);
01556 }
01557
01558 if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
01559 Owner o = GetTileOwner(t);
01560 if (o < MAX_COMPANIES && !Company::IsValidID(o)) {
01561 _current_company = o;
01562 ChangeTileOwner(t, o, INVALID_OWNER);
01563 }
01564 if (IsBuoyTile(t)) {
01565
01566
01567 Waypoint::GetByTile(t)->owner = OWNER_NONE;
01568 }
01569 } else if (IsTileType(t, MP_ROAD)) {
01570
01571 for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
01572
01573 Owner o = GetRoadOwner(t, rt);
01574 if (o < MAX_COMPANIES && !Company::IsValidID(o)) SetRoadOwner(t, rt, OWNER_NONE);
01575 }
01576 if (IsLevelCrossing(t)) {
01577 if (!Company::IsValidID(GetTileOwner(t))) FixOwnerOfRailTrack(t);
01578 }
01579 } else if (IsPlainRailTile(t)) {
01580 if (!Company::IsValidID(GetTileOwner(t))) FixOwnerOfRailTrack(t);
01581 }
01582 }
01583
01584
01585 if (_settings_game.pf.yapf.rail_use_yapf || CheckSavegameVersion(28)) {
01586 _settings_game.pf.pathfinder_for_trains = VPF_YAPF;
01587 } else {
01588 _settings_game.pf.pathfinder_for_trains = VPF_NPF;
01589 }
01590
01591 if (_settings_game.pf.yapf.road_use_yapf || CheckSavegameVersion(28)) {
01592 _settings_game.pf.pathfinder_for_roadvehs = VPF_YAPF;
01593 } else {
01594 _settings_game.pf.pathfinder_for_roadvehs = VPF_NPF;
01595 }
01596
01597 if (_settings_game.pf.yapf.ship_use_yapf) {
01598 _settings_game.pf.pathfinder_for_ships = VPF_YAPF;
01599 } else {
01600 _settings_game.pf.pathfinder_for_ships = (_settings_game.pf.new_pathfinding_all ? VPF_NPF : VPF_OPF);
01601 }
01602 }
01603
01604 if (CheckSavegameVersion(88)) {
01605
01606 Vehicle *v;
01607 FOR_ALL_VEHICLES(v) {
01608 v->profit_this_year <<= 8;
01609 v->profit_last_year <<= 8;
01610 v->running_ticks = 0;
01611 }
01612 }
01613
01614 if (CheckSavegameVersion(91)) {
01615
01616 for (TileIndex t = 0; t < map_size; t++) {
01617 if (IsTileType(t, MP_HOUSE) && GetHouseType(t) >= NEW_HOUSE_OFFSET) {
01618 SetHouseAnimationFrame(t, GB(_m[t].m6, 3, 5));
01619 }
01620 }
01621 }
01622
01623 if (CheckSavegameVersion(62)) {
01624
01625
01626 RoadVehicle *v;
01627 FOR_ALL_ROADVEHICLES(v) {
01628 if (v->First() == v && HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM)) {
01629 if (_switch_mode_errorstr == INVALID_STRING_ID || _switch_mode_errorstr == STR_NEWGRF_COMPATIBLE_LOAD_WARNING) {
01630 _switch_mode_errorstr = STR_WARNING_LOADGAME_REMOVED_TRAMS;
01631 }
01632 delete v;
01633 }
01634 }
01635 }
01636
01637 if (CheckSavegameVersion(99)) {
01638 for (TileIndex t = 0; t < map_size; t++) {
01639
01640 if (IsTileType(t, MP_STATION) && IsOilRig(t)) {
01641 SetWaterClassDependingOnSurroundings(t, true);
01642 }
01643 if (IsTileType(t, MP_INDUSTRY)) {
01644 if ((GetIndustrySpec(GetIndustryType(t))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0) {
01645 SetWaterClassDependingOnSurroundings(t, true);
01646 } else {
01647 SetWaterClass(t, WATER_CLASS_INVALID);
01648 }
01649 }
01650
01651
01652 if (IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)) {
01653 _m[t].m5 = Clamp(_cur_year - (_m[t].m5 + ORIGINAL_BASE_YEAR), 0, 0xFF);
01654 }
01655 }
01656 }
01657
01658
01659
01660
01661 if (CheckSavegameVersion(100)) {
01662 for (TileIndex t = 0; t < map_size; t++) {
01663 switch (GetTileType(t)) {
01664 case MP_RAILWAY:
01665 if (HasSignals(t)) {
01666
01667 SetSignalVariant(t, TRACK_UPPER, HasBit(_m[t].m2, 2) ? SIG_SEMAPHORE : SIG_ELECTRIC);
01668 SetSignalVariant(t, TRACK_LOWER, HasBit(_m[t].m2, 6) ? SIG_SEMAPHORE : SIG_ELECTRIC);
01669 ClrBit(_m[t].m2, 2);
01670 ClrBit(_m[t].m2, 6);
01671 }
01672
01673
01674 if (IsRailDepot(t)) {
01675 SetDepotReservation(t, false);
01676 } else {
01677 SetTrackReservation(t, TRACK_BIT_NONE);
01678 }
01679 break;
01680
01681 case MP_ROAD:
01682 if (IsLevelCrossing(t)) SetCrossingReservation(t, false);
01683 break;
01684
01685 case MP_STATION:
01686 if (HasStationRail(t)) SetRailStationReservation(t, false);
01687 break;
01688
01689 case MP_TUNNELBRIDGE:
01690 if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) SetTunnelBridgeReservation(t, false);
01691 break;
01692
01693 default: break;
01694 }
01695 }
01696 }
01697
01698
01699 if (CheckSavegameVersion(101)) {
01700 const Train *t;
01701 FOR_ALL_TRAINS(t) {
01702 if (t->First() == t) t->ReserveTrackUnderConsist();
01703 }
01704 }
01705
01706 if (CheckSavegameVersion(102)) {
01707 for (TileIndex t = 0; t < map_size; t++) {
01708
01709 if (IsLevelCrossingTile(t)) UpdateLevelCrossing(t, false);
01710 }
01711 }
01712
01713 if (CheckSavegameVersion(103)) {
01714
01715 UpdateNearestTownForRoadTiles(false);
01716
01717
01718 Sign *si;
01719 FOR_ALL_SIGNS(si) {
01720 if (si->owner != OWNER_NONE && !Company::IsValidID(si->owner)) si->owner = OWNER_NONE;
01721 }
01722
01723
01724
01725 Station *st;
01726 FOR_ALL_STATIONS(st) {
01727 st->indtype = IT_INVALID;
01728 }
01729 }
01730
01731 if (CheckSavegameVersion(104)) {
01732 Aircraft *a;
01733 FOR_ALL_AIRCRAFT(a) {
01734
01735 if (!a->IsNormalAircraft()) {
01736 a->engine_type = a->First()->engine_type;
01737 }
01738 }
01739
01740
01741 Company *c;
01742 FOR_ALL_COMPANIES(c) {
01743 if (c->bankrupt_asked == 0xFF) c->bankrupt_asked = 0xFFFF;
01744 }
01745
01746 Engine *e;
01747 FOR_ALL_ENGINES(e) {
01748 if (e->company_avail == 0xFF) e->company_avail = 0xFFFF;
01749 }
01750
01751 Town *t;
01752 FOR_ALL_TOWNS(t) {
01753 if (t->have_ratings == 0xFF) t->have_ratings = 0xFFFF;
01754 for (uint i = 8; i != MAX_COMPANIES; i++) t->ratings[i] = RATING_INITIAL;
01755 }
01756 }
01757
01758 if (CheckSavegameVersion(112)) {
01759 for (TileIndex t = 0; t < map_size; t++) {
01760
01761
01762 if (IsTileType(t, MP_UNMOVABLE) && HasBit(_m[t].m5, 7)) {
01763
01764
01765 uint8 old_m5 = _m[t].m5;
01766 _m[t].m5 = UNMOVABLE_HQ;
01767 SetCompanyHQSize(t, GB(old_m5, 2, 3));
01768 SetCompanyHQSection(t, GB(old_m5, 0, 2));
01769 }
01770 }
01771 }
01772
01773 if (CheckSavegameVersion(113)) {
01774
01775 if (_settings_game.economy.town_layout == 0) {
01776 _settings_game.economy.allow_town_roads = false;
01777 _settings_game.economy.town_layout = TL_BETTER_ROADS;
01778 } else {
01779 _settings_game.economy.allow_town_roads = true;
01780 _settings_game.economy.town_layout = _settings_game.economy.town_layout - 1;
01781 }
01782
01783
01784
01785 Town *t;
01786 FOR_ALL_TOWNS(t) {
01787 if (_settings_game.economy.town_layout != TL_RANDOM) {
01788 t->layout = _settings_game.economy.town_layout;
01789 continue;
01790 }
01791
01792
01793 byte layout = TileHash(TileX(t->xy), TileY(t->xy)) % 6;
01794 switch (layout) {
01795 default: break;
01796 case 5: layout = 1; break;
01797 case 0: layout = 2; break;
01798 }
01799 t->layout = layout - 1;
01800 }
01801 }
01802
01803 if (CheckSavegameVersion(114)) {
01804
01805
01806
01807 Station *st;
01808 FOR_ALL_STATIONS(st) {
01809 if (!Company::IsValidID(st->owner)) st->owner = OWNER_NONE;
01810 }
01811 }
01812
01813
01814 if (CheckSavegameVersion(117)) {
01815 Order *o;
01816 FOR_ALL_ORDERS(o) {
01817 if (o->IsType(OT_GOTO_STATION)) o->SetStopLocation(OSL_PLATFORM_FAR_END);
01818 }
01819 }
01820
01821 if (CheckSavegameVersion(120)) {
01822 extern VehicleDefaultSettings _old_vds;
01823 Company *c;
01824 FOR_ALL_COMPANIES(c) {
01825 c->settings.vehicle = _old_vds;
01826 }
01827 }
01828
01829 if (CheckSavegameVersion(121)) {
01830
01831 Vehicle *v;
01832 FOR_ALL_DISASTERVEHICLES(v) {
01833 if (v->subtype == 2 && v->current_order.GetDestination() != 0) {
01834 const Vehicle *u = Vehicle::GetIfValid(v->dest_tile);
01835 if (u == NULL || u->type != VEH_ROAD || !RoadVehicle::From(u)->IsRoadVehFront()) {
01836 delete v;
01837 }
01838 }
01839 }
01840
01841
01842
01843
01844
01845
01846
01847 Station *st;
01848 FOR_ALL_STATIONS(st) {
01849 std::list<Vehicle *>::iterator iter;
01850 for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ++iter) {
01851 Vehicle *v = *iter;
01852 if (v->cargo_payment == NULL) v->cargo_payment = new CargoPayment(v);
01853 }
01854 }
01855 }
01856
01857 if (CheckSavegameVersion(122)) {
01858
01859
01860
01861 extern TileIndex *_animated_tile_list;
01862 extern uint _animated_tile_count;
01863
01864 for (uint i = 0; i < _animated_tile_count; ) {
01865
01866 bool remove = _tile_type_procs[GetTileType(_animated_tile_list[i])]->animate_tile_proc == NULL;
01867
01868
01869 for (uint j = 0; !remove && j < i; j++) {
01870 remove = _animated_tile_list[i] == _animated_tile_list[j];
01871 }
01872
01873 if (remove) {
01874 DeleteAnimatedTile(_animated_tile_list[i]);
01875 } else {
01876 i++;
01877 }
01878 }
01879 }
01880
01881 if (CheckSavegameVersion(124)) {
01882
01883 Waypoint *wp;
01884 FOR_ALL_WAYPOINTS(wp) {
01885 if (wp->facilities & FACIL_TRAIN) {
01886 wp->train_station.tile = wp->xy;
01887 wp->train_station.w = 1;
01888 wp->train_station.h = 1;
01889 } else {;
01890 wp->train_station.tile = INVALID_TILE;
01891 wp->train_station.w = 0;
01892 wp->train_station.h = 0;
01893 }
01894 }
01895 }
01896
01897 if (CheckSavegameVersion(125)) {
01898
01899 Subsidy *s;
01900 FOR_ALL_SUBSIDIES(s) {
01901 if (s->remaining < 12) {
01902
01903 s->remaining = 12 - s->remaining;
01904 s->awarded = INVALID_COMPANY;
01905 const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
01906 switch (cs->town_effect) {
01907 case TE_PASSENGERS:
01908 case TE_MAIL:
01909
01910 s->src_type = s->dst_type = ST_TOWN;
01911 if (Town::IsValidID(s->src) && Town::IsValidID(s->dst)) continue;
01912 break;
01913 case TE_GOODS:
01914 case TE_FOOD:
01915
01916 s->src_type = ST_INDUSTRY;
01917 s->dst_type = ST_TOWN;
01918 if (Industry::IsValidID(s->src) && Town::IsValidID(s->dst)) continue;
01919 break;
01920 default:
01921
01922 s->src_type = s->dst_type = ST_INDUSTRY;
01923 if (Industry::IsValidID(s->src) && Industry::IsValidID(s->dst)) continue;
01924 break;
01925 }
01926 } else {
01927
01928
01929
01930 s->remaining = 24 - s->remaining;
01931 const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
01932 switch (cs->town_effect) {
01933 case TE_PASSENGERS:
01934 case TE_MAIL: {
01935
01936 const Station *ss = Station::GetIfValid(s->src);
01937 const Station *sd = Station::GetIfValid(s->dst);
01938 if (ss != NULL && sd != NULL && ss->owner == sd->owner &&
01939 Company::IsValidID(ss->owner)) {
01940 s->src_type = s->dst_type = ST_TOWN;
01941 s->src = ss->town->index;
01942 s->dst = sd->town->index;
01943 s->awarded = ss->owner;
01944 continue;
01945 }
01946 break;
01947 }
01948 default:
01949 break;
01950 }
01951 }
01952
01953 delete s;
01954 }
01955 }
01956
01957 if (CheckSavegameVersion(126)) {
01958
01959
01960
01961
01962
01963
01964 uint64 aimed_inflation = (_economy.old_max_loan_unround << 16 | _economy.old_max_loan_unround_fract) / _settings_game.difficulty.max_loan;
01965
01966
01967 if (aimed_inflation > MAX_INFLATION) aimed_inflation = MAX_INFLATION;
01968
01969
01970 while (_economy.inflation_prices < aimed_inflation) {
01971 AddInflation(false);
01972 }
01973 }
01974
01975 if (CheckSavegameVersion(127)) {
01976 Station *st;
01977 FOR_ALL_STATIONS(st) UpdateStationAcceptance(st, false);
01978 }
01979
01980 if (CheckSavegameVersion(128)) {
01981 const Depot *d;
01982 FOR_ALL_DEPOTS(d) {
01983 _m[d->xy].m2 = d->index;
01984 if (IsTileType(d->xy, MP_WATER)) _m[GetOtherShipDepotTile(d->xy)].m2 = d->index;
01985 }
01986 }
01987
01988
01989
01990 if (CheckSavegameVersion(131)) {
01991 Train *t;
01992 FOR_ALL_TRAINS(t) {
01993 t->force_proceed = min<byte>(t->force_proceed, 1);
01994 }
01995 }
01996
01997
01998
01999 if (CheckSavegameVersion(135)) {
02000 for (TileIndex t = 0; t < map_size; t++) {
02001 if (IsTileType(t, MP_CLEAR)) {
02002 if (GetRawClearGround(t) == CLEAR_SNOW) {
02003 SetClearGroundDensity(t, CLEAR_GRASS, GetClearDensity(t));
02004 SetBit(_m[t].m3, 4);
02005 } else {
02006 ClrBit(_m[t].m3, 4);
02007 }
02008 }
02009 if (IsTileType(t, MP_TREES)) {
02010 uint density = GB(_m[t].m2, 6, 2);
02011 uint ground = GB(_m[t].m2, 4, 2);
02012 uint counter = GB(_m[t].m2, 0, 4);
02013 _m[t].m2 = ground << 6 | density << 4 | counter;
02014 }
02015 }
02016 }
02017
02018
02019 if (CheckSavegameVersion(136)) {
02020 Aircraft *a;
02021 FOR_ALL_AIRCRAFT(a) {
02022 a->turn_counter = a->current_order.IsType(OT_LOADING) ? 0 : a->load_unload_ticks;
02023 }
02024
02025 Train *t;
02026 FOR_ALL_TRAINS(t) {
02027 t->wait_counter = t->current_order.IsType(OT_LOADING) ? 0 : t->load_unload_ticks;
02028 }
02029 }
02030
02031
02032 if (CheckSavegameVersion(137)) {
02033 struct AirportTileConversion {
02034 byte old_start;
02035 byte num_frames;
02036 };
02037 static const AirportTileConversion atc[] = {
02038 {31, 12},
02039 {50, 4},
02040 {62, 2},
02041 {66, 12},
02042 {78, 12},
02043 {101, 10},
02044 {111, 8},
02045 {119, 15},
02046 {140, 4},
02047 };
02048 for (TileIndex t = 0; t < map_size; t++) {
02049 if (IsAirportTile(t)) {
02050 StationGfx old_gfx = GetStationGfx(t);
02051 byte offset = 0;
02052 for (uint i = 0; i < lengthof(atc); i++) {
02053 if (old_gfx < atc[i].old_start) {
02054 SetStationGfx(t, old_gfx - offset);
02055 break;
02056 }
02057 if (old_gfx < atc[i].old_start + atc[i].num_frames) {
02058 SetStationAnimationFrame(t, old_gfx - atc[i].old_start);
02059 SetStationGfx(t, atc[i].old_start - offset);
02060 break;
02061 }
02062 offset += atc[i].num_frames - 1;
02063 }
02064 }
02065 }
02066 }
02067
02068
02069 AfterLoadRoadStops();
02070 AfterLoadLabelMaps();
02071
02072 GamelogPrintDebug(1);
02073
02074 InitializeWindowsAndCaches();
02075
02076 ResetSignalHandlers();
02077 return true;
02078 }
02079
02086 void ReloadNewGRFData()
02087 {
02088
02089 GfxLoadSprites();
02090 LoadStringWidthTable();
02091 RecomputePrices();
02092
02093 ResetVehiclePosHash();
02094 AfterLoadVehicles(false);
02095 StartupEngines();
02096 SetCachedEngineCounts();
02097
02098 AfterLoadStations();
02099
02100 UpdateHousesAndTowns();
02101
02102 for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) InvalidateWindowData(WC_COMPANY_COLOUR, i);
02103
02104 MarkWholeScreenDirty();
02105 CheckTrainsLengths();
02106 }