diff options
author | alberth <alberth@openttd.org> | 2010-11-21 12:47:04 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-11-21 12:47:04 +0000 |
commit | 3e27739287dd52e80535c6fd583bb7db41859850 (patch) | |
tree | f87985fe2c203f381575ac8f78068643e18529c9 /src/saveload | |
parent | 5f8afaadb7e82b351a26fd5590c6b1e8d148b23b (diff) | |
download | openttd-3e27739287dd52e80535c6fd583bb7db41859850.tar.xz |
(svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/afterload.cpp | 196 | ||||
-rw-r--r-- | src/saveload/animated_tile_sl.cpp | 4 | ||||
-rw-r--r-- | src/saveload/autoreplace_sl.cpp | 4 | ||||
-rw-r--r-- | src/saveload/cargopacket_sl.cpp | 6 | ||||
-rw-r--r-- | src/saveload/company_sl.cpp | 6 | ||||
-rw-r--r-- | src/saveload/depot_sl.cpp | 4 | ||||
-rw-r--r-- | src/saveload/economy_sl.cpp | 8 | ||||
-rw-r--r-- | src/saveload/map_sl.cpp | 4 | ||||
-rw-r--r-- | src/saveload/misc_sl.cpp | 2 | ||||
-rw-r--r-- | src/saveload/newgrf_sl.cpp | 2 | ||||
-rw-r--r-- | src/saveload/object_sl.cpp | 2 | ||||
-rw-r--r-- | src/saveload/order_sl.cpp | 6 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 12 | ||||
-rw-r--r-- | src/saveload/saveload.h | 11 | ||||
-rw-r--r-- | src/saveload/signs_sl.cpp | 2 | ||||
-rw-r--r-- | src/saveload/station_sl.cpp | 12 | ||||
-rw-r--r-- | src/saveload/strings_sl.cpp | 2 | ||||
-rw-r--r-- | src/saveload/vehicle_sl.cpp | 12 | ||||
-rw-r--r-- | src/saveload/waypoint_sl.cpp | 10 |
19 files changed, 147 insertions, 158 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index b3e446eb4..982c3254a 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -439,14 +439,14 @@ bool AfterLoadGame() TileIndex map_size = MapSize(); - if (CheckSavegameVersion(98)) GamelogOldver(); + if (IsSavegameVersionBefore(98)) GamelogOldver(); GamelogTestRevision(); GamelogTestMode(); - if (CheckSavegameVersion(98)) GamelogGRFAddList(_grfconfig); + if (IsSavegameVersionBefore(98)) GamelogGRFAddList(_grfconfig); - if (CheckSavegameVersion(119)) { + if (IsSavegameVersionBefore(119)) { _pause_mode = (_pause_mode == 2) ? PM_PAUSED_NORMAL : PM_UNPAUSED; } else if (_network_dedicated && (_pause_mode & PM_PAUSED_ERROR) != 0) { DEBUG(net, 0, "The loading savegame was paused due to an error state."); @@ -466,7 +466,7 @@ bool AfterLoadGame() } /* in very old versions, size of train stations was stored differently */ - if (CheckSavegameVersion(2)) { + if (IsSavegameVersionBefore(2)) { Station *st; FOR_ALL_STATIONS(st) { if (st->train_station.tile != 0 && st->train_station.h == 0) { @@ -505,7 +505,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(84)) { + if (IsSavegameVersionBefore(84)) { Company *c; FOR_ALL_COMPANIES(c) { c->name = CopyFromOldName(c->name_1); @@ -531,7 +531,7 @@ bool AfterLoadGame() /* From this point the old names array is cleared. */ ResetOldNames(); - if (CheckSavegameVersion(106)) { + if (IsSavegameVersionBefore(106)) { /* no station is determined by 'tile == INVALID_TILE' now (instead of '0') */ Station *st; FOR_ALL_STATIONS(st) { @@ -543,7 +543,7 @@ bool AfterLoadGame() /* the same applies to Company::location_of_HQ */ Company *c; FOR_ALL_COMPANIES(c) { - if (c->location_of_HQ == 0 || (CheckSavegameVersion(4) && c->location_of_HQ == 0xFFFF)) { + if (c->location_of_HQ == 0 || (IsSavegameVersionBefore(4) && c->location_of_HQ == 0xFFFF)) { c->location_of_HQ = INVALID_TILE; } } @@ -576,14 +576,14 @@ bool AfterLoadGame() } /* The value of _date_fract got divided, so make sure that old games are converted correctly. */ - if (IsSavegameVersionBefore(11, 1) || (CheckSavegameVersion(147) && _date_fract > DAY_TICKS)) _date_fract /= 885; + if (IsSavegameVersionBefore(11, 1) || (IsSavegameVersionBefore(147) && _date_fract > DAY_TICKS)) _date_fract /= 885; /* Update current year * must be done before loading sprites as some newgrfs check it */ SetDate(_date, _date_fract); /* Force dynamic engines off when loading older savegames */ - if (CheckSavegameVersion(95)) _settings_game.vehicle.dynamic_engines = 0; + if (IsSavegameVersionBefore(95)) _settings_game.vehicle.dynamic_engines = 0; /* Load the sprites */ GfxLoadSprites(); @@ -610,7 +610,7 @@ bool AfterLoadGame() /* Oilrig was moved from id 15 to 9. We have to do this conversion * here as AfterLoadVehicles can check it indirectly via the newgrf * code. */ - if (CheckSavegameVersion(139)) { + if (IsSavegameVersionBefore(139)) { Station *st; FOR_ALL_STATIONS(st) { if (st->airport.tile != INVALID_TILE && st->airport.type == 15) { @@ -642,7 +642,7 @@ bool AfterLoadGame() * This problem appears in savegame version 21 too, see r3455. But after loading the * savegame and saving again, the buggy map array could be converted to new savegame * version. It didn't show up before r12070. */ - if (CheckSavegameVersion(87)) UpdateVoidTiles(); + if (IsSavegameVersionBefore(87)) UpdateVoidTiles(); /* If Load Scenario / New (Scenario) Game is used, * a company does not exist yet. So create one here. @@ -659,7 +659,7 @@ bool AfterLoadGame() cp->current_station = cp->front->last_station_visited; } - if (CheckSavegameVersion(72)) { + if (IsSavegameVersionBefore(72)) { /* Locks in very old savegames had OWNER_WATER as owner */ for (TileIndex t = 0; t < MapSize(); t++) { switch (GetTileType(t)) { @@ -730,7 +730,7 @@ bool AfterLoadGame() switch (GetStationType(t)) { case STATION_TRUCK: case STATION_BUS: - if (CheckSavegameVersion(6)) { + if (IsSavegameVersionBefore(6)) { /* From this version on there can be multiple road stops of the * same type per station. Convert the existing stops to the new * internal data structure. */ @@ -801,20 +801,20 @@ bool AfterLoadGame() } /* Force the freeform edges to false for old savegames. */ - if (CheckSavegameVersion(111)) { + if (IsSavegameVersionBefore(111)) { _settings_game.construction.freeform_edges = false; } /* From version 9.0, we update the max passengers of a town (was sometimes negative * before that. */ - if (CheckSavegameVersion(9)) { + if (IsSavegameVersionBefore(9)) { Town *t; FOR_ALL_TOWNS(t) UpdateTownMaxPass(t); } /* From version 16.0, we included autorenew on engines, which are now saved, but * of course, we do need to initialize them for older savegames. */ - if (CheckSavegameVersion(16)) { + if (IsSavegameVersionBefore(16)) { Company *c; FOR_ALL_COMPANIES(c) { c->engine_renew_list = NULL; @@ -835,7 +835,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(48)) { + if (IsSavegameVersionBefore(48)) { for (TileIndex t = 0; t < map_size; t++) { switch (GetTileType(t)) { case MP_RAILWAY: @@ -863,9 +863,9 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(61)) { + if (IsSavegameVersionBefore(61)) { /* Added the RoadType */ - bool old_bridge = CheckSavegameVersion(42); + bool old_bridge = IsSavegameVersionBefore(42); for (TileIndex t = 0; t < map_size; t++) { switch (GetTileType(t)) { case MP_ROAD: @@ -902,9 +902,9 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(114)) { - bool fix_roadtypes = !CheckSavegameVersion(61); - bool old_bridge = CheckSavegameVersion(42); + if (IsSavegameVersionBefore(114)) { + bool fix_roadtypes = !IsSavegameVersionBefore(61); + bool old_bridge = IsSavegameVersionBefore(42); for (TileIndex t = 0; t < map_size; t++) { switch (GetTileType(t)) { @@ -969,7 +969,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(42)) { + if (IsSavegameVersionBefore(42)) { Vehicle *v; for (TileIndex t = 0; t < map_size; t++) { @@ -1051,7 +1051,7 @@ bool AfterLoadGame() } /* Elrails got added in rev 24 */ - if (CheckSavegameVersion(24)) { + if (IsSavegameVersionBefore(24)) { RailType min_rail = RAILTYPE_ELECTRIC; Train *v; @@ -1106,7 +1106,7 @@ bool AfterLoadGame() FOR_ALL_COMPANIES(c) c->settings.renew_keep_length = false; } - if (CheckSavegameVersion(123)) { + if (IsSavegameVersionBefore(123)) { /* Waypoints became subclasses of stations ... */ MoveWaypointsToBaseStations(); /* ... and buoys were moved to waypoints. */ @@ -1115,7 +1115,7 @@ bool AfterLoadGame() /* From version 15, we moved a semaphore bit from bit 2 to bit 3 in m4, making * room for PBS. Now in version 21 move it back :P. */ - if (CheckSavegameVersion(21) && !CheckSavegameVersion(15)) { + if (IsSavegameVersionBefore(21) && !IsSavegameVersionBefore(15)) { for (TileIndex t = 0; t < map_size; t++) { switch (GetTileType(t)) { case MP_RAILWAY: @@ -1145,14 +1145,14 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(25)) { + if (IsSavegameVersionBefore(25)) { RoadVehicle *rv; FOR_ALL_ROADVEHICLES(rv) { rv->vehstatus &= ~0x40; } } - if (CheckSavegameVersion(26)) { + if (IsSavegameVersionBefore(26)) { Station *st; FOR_ALL_STATIONS(st) { st->last_vehicle_type = VEH_INVALID; @@ -1161,7 +1161,7 @@ bool AfterLoadGame() YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK); - if (CheckSavegameVersion(34)) { + if (IsSavegameVersionBefore(34)) { Company *c; FOR_ALL_COMPANIES(c) ResetCompanyLivery(c); } @@ -1172,11 +1172,11 @@ bool AfterLoadGame() c->avail_roadtypes = GetCompanyRoadtypes(c->index); } - if (!CheckSavegameVersion(27)) AfterLoadStations(); + if (!IsSavegameVersionBefore(27)) AfterLoadStations(); /* Time starts at 0 instead of 1920. * Account for this in older games by adding an offset */ - if (CheckSavegameVersion(31)) { + if (IsSavegameVersionBefore(31)) { Station *st; Waypoint *wp; Engine *e; @@ -1201,7 +1201,7 @@ bool AfterLoadGame() /* From 32 on we save the industry who made the farmland. * To give this prettyness to old savegames, we remove all farmfields and * plant new ones. */ - if (CheckSavegameVersion(32)) { + if (IsSavegameVersionBefore(32)) { Industry *i; for (TileIndex t = 0; t < map_size; t++) { @@ -1225,7 +1225,7 @@ bool AfterLoadGame() } /* Setting no refit flags to all orders in savegames from before refit in orders were added */ - if (CheckSavegameVersion(36)) { + if (IsSavegameVersionBefore(36)) { Order *order; Vehicle *v; @@ -1240,14 +1240,14 @@ bool AfterLoadGame() /* from version 38 we have optional elrails, since we cannot know the * preference of a user, let elrails enabled; it can be disabled manually */ - if (CheckSavegameVersion(38)) _settings_game.vehicle.disable_elrails = false; + if (IsSavegameVersionBefore(38)) _settings_game.vehicle.disable_elrails = false; /* do the same as when elrails were enabled/disabled manually just now */ SettingsDisableElrail(_settings_game.vehicle.disable_elrails); InitializeRailGUI(); /* From version 53, the map array was changed for house tiles to allow * space for newhouses grf features. A new byte, m7, was also added. */ - if (CheckSavegameVersion(53)) { + if (IsSavegameVersionBefore(53)) { for (TileIndex t = 0; t < map_size; t++) { if (IsTileType(t, MP_HOUSE)) { if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) { @@ -1284,7 +1284,7 @@ bool AfterLoadGame() /* Check and update house and town values */ UpdateHousesAndTowns(); - if (CheckSavegameVersion(43)) { + if (IsSavegameVersionBefore(43)) { for (TileIndex t = 0; t < map_size; t++) { if (IsTileType(t, MP_INDUSTRY)) { switch (GetIndustryGfx(t)) { @@ -1311,7 +1311,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(45)) { + if (IsSavegameVersionBefore(45)) { Vehicle *v; /* Originally just the fact that some cargo had been paid for was * stored to stop people cheating and cashing in several times. This @@ -1325,14 +1325,14 @@ bool AfterLoadGame() /* Buoys do now store the owner of the previous water tile, which can never * be OWNER_NONE. So replace OWNER_NONE with OWNER_WATER. */ - if (CheckSavegameVersion(46)) { + if (IsSavegameVersionBefore(46)) { Waypoint *wp; FOR_ALL_WAYPOINTS(wp) { if ((wp->facilities & FACIL_DOCK) != 0 && IsTileOwner(wp->xy, OWNER_NONE) && TileHeight(wp->xy) == 0) SetTileOwner(wp->xy, OWNER_WATER); } } - if (CheckSavegameVersion(50)) { + if (IsSavegameVersionBefore(50)) { Aircraft *v; /* Aircraft units changed from 8 mph to 1 km-ish/h */ FOR_ALL_AIRCRAFT(v) { @@ -1345,9 +1345,9 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(49)) FOR_ALL_COMPANIES(c) c->face = ConvertFromOldCompanyManagerFace(c->face); + if (IsSavegameVersionBefore(49)) FOR_ALL_COMPANIES(c) c->face = ConvertFromOldCompanyManagerFace(c->face); - if (CheckSavegameVersion(52)) { + if (IsSavegameVersionBefore(52)) { for (TileIndex t = 0; t < map_size; t++) { if (IsStatueTile(t)) { _m[t].m2 = CalcClosestTownFromTile(t)->index; @@ -1358,7 +1358,7 @@ bool AfterLoadGame() /* A setting containing the proportion of towns that grow twice as * fast was added in version 54. From version 56 this is now saved in the * town as cities can be built specifically in the scenario editor. */ - if (CheckSavegameVersion(56)) { + if (IsSavegameVersionBefore(56)) { Town *t; FOR_ALL_TOWNS(t) { @@ -1368,7 +1368,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(57)) { + if (IsSavegameVersionBefore(57)) { Vehicle *v; /* Added a FIFO queue of vehicles loading at stations */ FOR_ALL_VEHICLES(v) { @@ -1382,7 +1382,7 @@ bool AfterLoadGame() ClrBit(v->vehicle_flags, VF_LOADING_FINISHED); } } - } else if (CheckSavegameVersion(59)) { + } else if (IsSavegameVersionBefore(59)) { /* For some reason non-loading vehicles could be in the station's loading vehicle list */ Station *st; @@ -1396,7 +1396,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(58)) { + if (IsSavegameVersionBefore(58)) { /* Setting difficulty number_industries other than zero get bumped to +1 * since a new option (very low at position1) has been added */ if (_settings_game.difficulty.number_industries > 0) { @@ -1407,7 +1407,7 @@ bool AfterLoadGame() _settings_game.difficulty.number_towns++; } - if (CheckSavegameVersion(64)) { + if (IsSavegameVersionBefore(64)) { /* copy the signal type/variant and move signal states bits */ for (TileIndex t = 0; t < map_size; t++) { if (IsTileType(t, MP_RAILWAY) && HasSignals(t)) { @@ -1419,7 +1419,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(69)) { + if (IsSavegameVersionBefore(69)) { /* In some old savegames a bit was cleared when it should not be cleared */ RoadVehicle *rv; FOR_ALL_ROADVEHICLES(rv) { @@ -1429,7 +1429,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(70)) { + if (IsSavegameVersionBefore(70)) { /* Added variables to support newindustries */ Industry *i; FOR_ALL_INDUSTRIES(i) i->founder = OWNER_NONE; @@ -1437,7 +1437,7 @@ bool AfterLoadGame() /* From version 82, old style canals (above sealevel (0), WATER owner) are no longer supported. Replace the owner for those by OWNER_NONE. */ - if (CheckSavegameVersion(82)) { + if (IsSavegameVersionBefore(82)) { for (TileIndex t = 0; t < map_size; t++) { if (IsTileType(t, MP_WATER) && GetWaterTileType(t) == WATER_TILE_CLEAR && @@ -1454,7 +1454,7 @@ bool AfterLoadGame() * someone can remove canals owned by somebody else and it prevents * making floods using the removal of ship depots. */ - if (CheckSavegameVersion(83)) { + if (IsSavegameVersionBefore(83)) { for (TileIndex t = 0; t < map_size; t++) { if (IsTileType(t, MP_WATER) && IsShipDepot(t)) { _m[t].m4 = (TileHeight(t) == 0) ? OWNER_WATER : OWNER_NONE; @@ -1462,7 +1462,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(74)) { + if (IsSavegameVersionBefore(74)) { Station *st; FOR_ALL_STATIONS(st) { for (CargoID c = 0; c < NUM_CARGO; c++) { @@ -1472,7 +1472,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(78)) { + if (IsSavegameVersionBefore(78)) { Industry *i; uint j; FOR_ALL_INDUSTRIES(i) { @@ -1490,7 +1490,7 @@ bool AfterLoadGame() * grassy trees were always drawn fully grassy. Furthermore, trees on rough * land used to have zero density, now they have full density. Therefore, * make all grassy/rough land trees have a density of 3. */ - if (CheckSavegameVersion(81)) { + if (IsSavegameVersionBefore(81)) { for (TileIndex t = 0; t < map_size; t++) { if (GetTileType(t) == MP_TREES) { TreeGround groundType = (TreeGround)GB(_m[t].m2, 4, 2); @@ -1500,7 +1500,7 @@ bool AfterLoadGame() } - if (CheckSavegameVersion(93)) { + if (IsSavegameVersionBefore(93)) { /* Rework of orders. */ Order *order; FOR_ALL_ORDERS(order) order->ConvertFromOldSavegame(); @@ -1517,7 +1517,7 @@ bool AfterLoadGame() FOR_VEHICLE_ORDERS(v, order) order->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); } } - } else if (CheckSavegameVersion(94)) { + } else if (IsSavegameVersionBefore(94)) { /* Unload and transfer are now mutual exclusive. */ Order *order; FOR_ALL_ORDERS(order) { @@ -1536,7 +1536,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(84)) { + if (IsSavegameVersionBefore(84)) { /* Set all share owners to INVALID_COMPANY for * 1) all inactive companies * (when inactive companies were stored in the savegame - TTD, TTDP and some @@ -1553,7 +1553,7 @@ bool AfterLoadGame() } /* The water class was moved/unified. */ - if (CheckSavegameVersion(146)) { + if (IsSavegameVersionBefore(146)) { for (TileIndex t = 0; t < map_size; t++) { switch (GetTileType(t)) { case MP_STATION: @@ -1587,7 +1587,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(86)) { + if (IsSavegameVersionBefore(86)) { for (TileIndex t = 0; t < map_size; t++) { /* Move river flag and update canals to use water class */ if (IsTileType(t, MP_WATER)) { @@ -1618,7 +1618,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(87)) { + if (IsSavegameVersionBefore(87)) { for (TileIndex t = 0; t < map_size; t++) { /* skip oil rigs at borders! */ if ((IsTileType(t, MP_WATER) || IsBuoyTile(t)) && @@ -1656,13 +1656,13 @@ bool AfterLoadGame() } /* Convert old PF settings to new */ - if (_settings_game.pf.yapf.rail_use_yapf || CheckSavegameVersion(28)) { + if (_settings_game.pf.yapf.rail_use_yapf || IsSavegameVersionBefore(28)) { _settings_game.pf.pathfinder_for_trains = VPF_YAPF; } else { _settings_game.pf.pathfinder_for_trains = VPF_NPF; } - if (_settings_game.pf.yapf.road_use_yapf || CheckSavegameVersion(28)) { + if (_settings_game.pf.yapf.road_use_yapf || IsSavegameVersionBefore(28)) { _settings_game.pf.pathfinder_for_roadvehs = VPF_YAPF; } else { _settings_game.pf.pathfinder_for_roadvehs = VPF_NPF; @@ -1675,7 +1675,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(88)) { + if (IsSavegameVersionBefore(88)) { /* Profits are now with 8 bit fract */ Vehicle *v; FOR_ALL_VEHICLES(v) { @@ -1685,7 +1685,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(91)) { + if (IsSavegameVersionBefore(91)) { /* Increase HouseAnimationFrame from 5 to 7 bits */ for (TileIndex t = 0; t < map_size; t++) { if (IsTileType(t, MP_HOUSE) && GetHouseType(t) >= NEW_HOUSE_OFFSET) { @@ -1695,7 +1695,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(62)) { + if (IsSavegameVersionBefore(62)) { /* Remove all trams from savegames without tram support. * There would be trams without tram track under causing crashes sooner or later. */ RoadVehicle *v; @@ -1709,7 +1709,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(99)) { + if (IsSavegameVersionBefore(99)) { for (TileIndex t = 0; t < map_size; t++) { /* Set newly introduced WaterClass of industry tiles */ if (IsTileType(t, MP_STATION) && IsOilRig(t)) { @@ -1733,7 +1733,7 @@ bool AfterLoadGame() /* Move the signal variant back up one bit for PBS. We don't convert the old PBS * format here, as an old layout wouldn't work properly anyway. To be safe, we * clear any possible PBS reservations as well. */ - if (CheckSavegameVersion(100)) { + if (IsSavegameVersionBefore(100)) { for (TileIndex t = 0; t < map_size; t++) { switch (GetTileType(t)) { case MP_RAILWAY: @@ -1771,21 +1771,21 @@ bool AfterLoadGame() } /* Reserve all tracks trains are currently on. */ - if (CheckSavegameVersion(101)) { + if (IsSavegameVersionBefore(101)) { const Train *t; FOR_ALL_TRAINS(t) { if (t->First() == t) t->ReserveTrackUnderConsist(); } } - if (CheckSavegameVersion(102)) { + if (IsSavegameVersionBefore(102)) { for (TileIndex t = 0; t < map_size; t++) { /* Now all crossings should be in correct state */ if (IsLevelCrossingTile(t)) UpdateLevelCrossing(t, false); } } - if (CheckSavegameVersion(103)) { + if (IsSavegameVersionBefore(103)) { /* Non-town-owned roads now store the closest town */ UpdateNearestTownForRoadTiles(false); @@ -1803,7 +1803,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(104)) { + if (IsSavegameVersionBefore(104)) { Aircraft *a; FOR_ALL_AIRCRAFT(a) { /* Set engine_type of shadow and rotor */ @@ -1830,7 +1830,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(112)) { + if (IsSavegameVersionBefore(112)) { for (TileIndex t = 0; t < map_size; t++) { /* Check for HQ bit being set, instead of using map accessor, * since we've already changed it code-wise */ @@ -1842,7 +1842,7 @@ bool AfterLoadGame() } } } - if (CheckSavegameVersion(144)) { + if (IsSavegameVersionBefore(144)) { for (TileIndex t = 0; t < map_size; t++) { if (!IsTileType(t, MP_OBJECT)) continue; @@ -1857,7 +1857,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(147) && Object::GetNumItems() == 0) { + if (IsSavegameVersionBefore(147) && Object::GetNumItems() == 0) { /* Make real objects for object tiles. */ for (TileIndex t = 0; t < map_size; t++) { if (!IsTileType(t, MP_OBJECT)) continue; @@ -1895,7 +1895,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(113)) { + if (IsSavegameVersionBefore(113)) { /* allow_town_roads is added, set it if town_layout wasn't TL_NO_ROADS */ if (_settings_game.economy.town_layout == 0) { // was TL_NO_ROADS _settings_game.economy.allow_town_roads = false; @@ -1925,7 +1925,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(114)) { + if (IsSavegameVersionBefore(114)) { /* There could be (deleted) stations with invalid owner, set owner to OWNER NONE. * The conversion affects oil rigs and buoys too, but it doesn't matter as * they have st->owner == OWNER_NONE already. */ @@ -1936,14 +1936,14 @@ bool AfterLoadGame() } /* Trains could now stop in a specific location. */ - if (CheckSavegameVersion(117)) { + if (IsSavegameVersionBefore(117)) { Order *o; FOR_ALL_ORDERS(o) { if (o->IsType(OT_GOTO_STATION)) o->SetStopLocation(OSL_PLATFORM_FAR_END); } } - if (CheckSavegameVersion(120)) { + if (IsSavegameVersionBefore(120)) { extern VehicleDefaultSettings _old_vds; Company *c; FOR_ALL_COMPANIES(c) { @@ -1951,7 +1951,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(121)) { + if (IsSavegameVersionBefore(121)) { /* Delete small ufos heading for non-existing vehicles */ Vehicle *v; FOR_ALL_DISASTERVEHICLES(v) { @@ -1979,7 +1979,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(122)) { + if (IsSavegameVersionBefore(122)) { /* Animated tiles would sometimes not be actually animated or * in case of old savegames duplicate. */ @@ -2003,7 +2003,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(124)) { + if (IsSavegameVersionBefore(124)) { /* The train station tile area was added */ Waypoint *wp; FOR_ALL_WAYPOINTS(wp) { @@ -2019,7 +2019,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(125)) { + if (IsSavegameVersionBefore(125)) { /* Convert old subsidies */ Subsidy *s; FOR_ALL_SUBSIDIES(s) { @@ -2079,7 +2079,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(126)) { + if (IsSavegameVersionBefore(126)) { /* Recompute inflation based on old unround loan limit * Note: Max loan is 500000. With an inflation of 4% across 170 years * that results in a max loan of about 0.7 * 2^31. @@ -2097,12 +2097,12 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(127)) { + if (IsSavegameVersionBefore(127)) { Station *st; FOR_ALL_STATIONS(st) UpdateStationAcceptance(st, false); } - if (CheckSavegameVersion(128)) { + if (IsSavegameVersionBefore(128)) { const Depot *d; FOR_ALL_DEPOTS(d) { _m[d->xy].m2 = d->index; @@ -2112,7 +2112,7 @@ bool AfterLoadGame() /* The behaviour of force_proceed has been changed. Now * it counts signals instead of some random time out. */ - if (CheckSavegameVersion(131)) { + if (IsSavegameVersionBefore(131)) { Train *t; FOR_ALL_TRAINS(t) { if (t->force_proceed != TFP_NONE) { @@ -2123,7 +2123,7 @@ bool AfterLoadGame() /* The bits for the tree ground and tree density have * been swapped (m2 bits 7..6 and 5..4. */ - if (CheckSavegameVersion(135)) { + if (IsSavegameVersionBefore(135)) { for (TileIndex t = 0; t < map_size; t++) { if (IsTileType(t, MP_CLEAR)) { if (GetRawClearGround(t) == CLEAR_SNOW) { @@ -2143,7 +2143,7 @@ bool AfterLoadGame() } /* Wait counter and load/unload ticks got split. */ - if (CheckSavegameVersion(136)) { + if (IsSavegameVersionBefore(136)) { Aircraft *a; FOR_ALL_AIRCRAFT(a) { a->turn_counter = a->current_order.IsType(OT_LOADING) ? 0 : a->load_unload_ticks; @@ -2156,7 +2156,7 @@ bool AfterLoadGame() } /* Airport tile animation uses animation frame instead of other graphics id */ - if (CheckSavegameVersion(137)) { + if (IsSavegameVersionBefore(137)) { struct AirportTileConversion { byte old_start; byte num_frames; @@ -2192,7 +2192,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(139)) { + if (IsSavegameVersionBefore(139)) { Train *t; FOR_ALL_TRAINS(t) { /* Copy old GOINGUP / GOINGDOWN flags. */ @@ -2206,7 +2206,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(140)) { + if (IsSavegameVersionBefore(140)) { Station *st; FOR_ALL_STATIONS(st) { if (st->airport.tile != INVALID_TILE) { @@ -2216,7 +2216,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(141)) { + if (IsSavegameVersionBefore(141)) { for (TileIndex t = 0; t < map_size; t++) { /* Reset tropic zone for VOID tiles, they shall not have any. */ if (IsTileType(t, MP_VOID)) SetTropicZone(t, TROPICZONE_NORMAL); @@ -2231,7 +2231,7 @@ bool AfterLoadGame() FOR_ALL_DEPOTS(d) MakeDefaultName(d); } - if (CheckSavegameVersion(142)) { + if (IsSavegameVersionBefore(142)) { Depot *d; FOR_ALL_DEPOTS(d) d->build_date = _date; } @@ -2241,7 +2241,7 @@ bool AfterLoadGame() * another airport in the same station so we don't allow that anymore. * For old savegames with such aircraft we just throw them in the air and * treat the aircraft like they were flying already. */ - if (CheckSavegameVersion(146)) { + if (IsSavegameVersionBefore(146)) { Aircraft *v; FOR_ALL_AIRCRAFT(v) { if (!v->IsNormalAircraft()) continue; @@ -2257,7 +2257,7 @@ bool AfterLoadGame() } /* Move the animation frame to the same location (m7) for all objects. */ - if (CheckSavegameVersion(147)) { + if (IsSavegameVersionBefore(147)) { for (TileIndex t = 0; t < map_size; t++) { switch (GetTileType(t)) { case MP_HOUSE: @@ -2289,7 +2289,7 @@ bool AfterLoadGame() } /* Add (random) colour to all objects. */ - if (CheckSavegameVersion(148)) { + if (IsSavegameVersionBefore(148)) { Object *o; FOR_ALL_OBJECTS(o) { Owner owner = GetTileOwner(o->location.tile); @@ -2297,7 +2297,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(149)) { + if (IsSavegameVersionBefore(149)) { for (TileIndex t = 0; t < map_size; t++) { if (!IsTileType(t, MP_STATION)) continue; if (!IsBuoy(t) && !IsOilRig(t) && !(IsDock(t) && GetTileSlope(t, NULL) == SLOPE_FLAT)) { @@ -2319,7 +2319,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(152)) { + if (IsSavegameVersionBefore(152)) { _industry_builder.Reset(); // Initialize industry build data. /* The moment vehicles go from hidden to visible changed. This means @@ -2377,7 +2377,7 @@ bool AfterLoadGame() } } - if (CheckSavegameVersion(153)) { + if (IsSavegameVersionBefore(153)) { RoadVehicle *rv; FOR_ALL_ROADVEHICLES(rv) { bool loading = rv->current_order.IsType(OT_LOADING) || rv->current_order.IsType(OT_LEAVESTATION); diff --git a/src/saveload/animated_tile_sl.cpp b/src/saveload/animated_tile_sl.cpp index bd4623207..2ccd42cb5 100644 --- a/src/saveload/animated_tile_sl.cpp +++ b/src/saveload/animated_tile_sl.cpp @@ -34,9 +34,9 @@ static void Save_ANIT() static void Load_ANIT() { /* Before version 80 we did NOT have a variable length animated tile table */ - if (CheckSavegameVersion(80)) { + if (IsSavegameVersionBefore(80)) { /* In pre version 6, we has 16bit per tile, now we have 32bit per tile, convert it ;) */ - SlArray(_animated_tile_list, 256, CheckSavegameVersion(6) ? (SLE_FILE_U16 | SLE_VAR_U32) : SLE_UINT32); + SlArray(_animated_tile_list, 256, IsSavegameVersionBefore(6) ? (SLE_FILE_U16 | SLE_VAR_U32) : SLE_UINT32); for (_animated_tile_count = 0; _animated_tile_count < 256; _animated_tile_count++) { if (_animated_tile_list[_animated_tile_count] == 0) break; diff --git a/src/saveload/autoreplace_sl.cpp b/src/saveload/autoreplace_sl.cpp index 6f370b0a1..96fff7728 100644 --- a/src/saveload/autoreplace_sl.cpp +++ b/src/saveload/autoreplace_sl.cpp @@ -42,9 +42,9 @@ static void Load_ERNW() SlObject(er, _engine_renew_desc); /* Advanced vehicle lists, ungrouped vehicles got added */ - if (CheckSavegameVersion(60)) { + if (IsSavegameVersionBefore(60)) { er->group_id = ALL_GROUP; - } else if (CheckSavegameVersion(71)) { + } else if (IsSavegameVersionBefore(71)) { if (er->group_id == DEFAULT_GROUP) er->group_id = ALL_GROUP; } } diff --git a/src/saveload/cargopacket_sl.cpp b/src/saveload/cargopacket_sl.cpp index de3e35fbd..eafe5346b 100644 --- a/src/saveload/cargopacket_sl.cpp +++ b/src/saveload/cargopacket_sl.cpp @@ -17,7 +17,7 @@ /* static */ void CargoPacket::AfterLoad() { - if (CheckSavegameVersion(44)) { + if (IsSavegameVersionBefore(44)) { Vehicle *v; /* If we remove a station while cargo from it is still enroute, payment calculation will assume * 0, 0 to be the source of the cargo, resulting in very high payments usually. v->source_xy @@ -54,7 +54,7 @@ } } - if (CheckSavegameVersion(120)) { + if (IsSavegameVersionBefore(120)) { /* CargoPacket's source should be either INVALID_STATION or a valid station */ CargoPacket *cp; FOR_ALL_CARGOPACKETS(cp) { @@ -62,7 +62,7 @@ } } - if (!CheckSavegameVersion(68)) { + if (!IsSavegameVersionBefore(68)) { /* Only since version 68 we have cargo packets. Savegames from before used * 'new CargoPacket' + cargolist.Append so their caches are already * correct and do not need rebuilding. */ diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index b238ad818..6f2195ba0 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -266,7 +266,7 @@ static void SaveLoad_PLYR_common(Company *c, CompanyProperties *cprops) } /* Keep backwards compatible for savegames, so load the old AI block */ - if (CheckSavegameVersion(107) && cprops->is_ai) { + if (IsSavegameVersionBefore(107) && cprops->is_ai) { CompanyOldAI old_ai; char nothing; @@ -285,7 +285,7 @@ static void SaveLoad_PLYR_common(Company *c, CompanyProperties *cprops) } /* Write each livery entry. */ - int num_liveries = CheckSavegameVersion(63) ? LS_END - 4 : (CheckSavegameVersion(85) ? LS_END - 2: LS_END); + int num_liveries = IsSavegameVersionBefore(63) ? LS_END - 4 : (IsSavegameVersionBefore(85) ? LS_END - 2: LS_END); if (c != NULL) { for (i = 0; i < num_liveries; i++) { SlObject(&c->livery[i], _company_livery_desc); @@ -345,7 +345,7 @@ static void Check_PLYR() SaveLoad_PLYR_common(NULL, cprops); /* We do not load old custom names */ - if (CheckSavegameVersion(84)) + if (IsSavegameVersionBefore(84)) { if (GB(cprops->name_1, 11, 5) == 15) { cprops->name_1 = STR_GAME_SAVELOAD_NOT_AVAILABLE; diff --git a/src/saveload/depot_sl.cpp b/src/saveload/depot_sl.cpp index 9b8fd224a..0d62d74cd 100644 --- a/src/saveload/depot_sl.cpp +++ b/src/saveload/depot_sl.cpp @@ -47,7 +47,7 @@ static void Load_DEPT() SlObject(depot, _depot_desc); /* Set the town 'pointer' so we can restore it later. */ - if (CheckSavegameVersion(141)) depot->town = (Town *)(size_t)_town_index; + if (IsSavegameVersionBefore(141)) depot->town = (Town *)(size_t)_town_index; } } @@ -57,7 +57,7 @@ static void Ptrs_DEPT() FOR_ALL_DEPOTS(depot) { SlObject(depot, _depot_desc); - if (CheckSavegameVersion(141)) depot->town = Town::Get((size_t)depot->town); + if (IsSavegameVersionBefore(141)) depot->town = Town::Get((size_t)depot->town); } } diff --git a/src/saveload/economy_sl.cpp b/src/saveload/economy_sl.cpp index cff98c5a5..9bdad61a9 100644 --- a/src/saveload/economy_sl.cpp +++ b/src/saveload/economy_sl.cpp @@ -19,7 +19,7 @@ static void Load_PRIC() { /* Old games store 49 base prices, very old games store them as int32 */ - int vt = CheckSavegameVersion(65) ? SLE_FILE_I32 : SLE_FILE_I64; + int vt = IsSavegameVersionBefore(65) ? SLE_FILE_I32 : SLE_FILE_I64; SlArray(NULL, 49, vt | SLE_VAR_NULL); SlArray(NULL, 49, SLE_FILE_U16 | SLE_VAR_NULL); } @@ -27,8 +27,8 @@ static void Load_PRIC() /** Cargo payment rates in pre 126 savegames */ static void Load_CAPR() { - uint num_cargo = CheckSavegameVersion(55) ? 12 : NUM_CARGO; - int vt = CheckSavegameVersion(65) ? SLE_FILE_I32 : SLE_FILE_I64; + uint num_cargo = IsSavegameVersionBefore(55) ? 12 : NUM_CARGO; + int vt = IsSavegameVersionBefore(65) ? SLE_FILE_I32 : SLE_FILE_I64; SlArray(NULL, num_cargo, vt | SLE_VAR_NULL); SlArray(NULL, num_cargo, SLE_FILE_U16 | SLE_VAR_NULL); } @@ -59,7 +59,7 @@ static void Save_ECMY() static void Load_ECMY() { SlObject(&_economy, _economy_desc); - StartupIndustryDailyChanges(CheckSavegameVersion(102)); // old savegames will need to be initialized + StartupIndustryDailyChanges(IsSavegameVersionBefore(102)); // old savegames will need to be initialized } static const SaveLoad _cargopayment_desc[] = { diff --git a/src/saveload/map_sl.cpp b/src/saveload/map_sl.cpp index 34b1098b0..7088a4406 100644 --- a/src/saveload/map_sl.cpp +++ b/src/saveload/map_sl.cpp @@ -101,7 +101,7 @@ static void Load_MAP2() for (TileIndex i = 0; i != size;) { SlArray(buf, MAP_SL_BUF_SIZE, /* In those versions the m2 was 8 bits */ - CheckSavegameVersion(5) ? SLE_FILE_U8 | SLE_VAR_U16 : SLE_UINT16 + IsSavegameVersionBefore(5) ? SLE_FILE_U8 | SLE_VAR_U16 : SLE_UINT16 ); for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m2 = buf[j]; } @@ -193,7 +193,7 @@ static void Load_MAP6() SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; TileIndex size = MapSize(); - if (CheckSavegameVersion(42)) { + if (IsSavegameVersionBefore(42)) { for (TileIndex i = 0; i != size;) { /* 1024, otherwise we overflow on 64x64 maps! */ SlArray(buf, 1024, SLE_UINT8); diff --git a/src/saveload/misc_sl.cpp b/src/saveload/misc_sl.cpp index b73207b38..4415d67d6 100644 --- a/src/saveload/misc_sl.cpp +++ b/src/saveload/misc_sl.cpp @@ -122,7 +122,7 @@ static void SaveLoad_DATE() static void Check_DATE() { SlGlobList(_date_check_desc); - if (CheckSavegameVersion(31)) { + if (IsSavegameVersionBefore(31)) { _load_check_data.current_date += DAYS_TILL_ORIGINAL_BASE_YEAR; } } diff --git a/src/saveload/newgrf_sl.cpp b/src/saveload/newgrf_sl.cpp index bba77d77a..2966bd08c 100644 --- a/src/saveload/newgrf_sl.cpp +++ b/src/saveload/newgrf_sl.cpp @@ -78,7 +78,7 @@ static void Load_NGRF_common(GRFConfig *&grfconfig) while (SlIterateArray() != -1) { GRFConfig *c = new GRFConfig(); SlObject(c, _grfconfig_desc); - if (CheckSavegameVersion(101)) c->SetSuitablePalette(); + if (IsSavegameVersionBefore(101)) c->SetSuitablePalette(); AppendToGRFConfigList(&grfconfig, c); } } diff --git a/src/saveload/object_sl.cpp b/src/saveload/object_sl.cpp index b1e2200cd..c79da592d 100644 --- a/src/saveload/object_sl.cpp +++ b/src/saveload/object_sl.cpp @@ -52,7 +52,7 @@ static void Ptrs_OBJS() Object *o; FOR_ALL_OBJECTS(o) { SlObject(o, _object_desc); - if (CheckSavegameVersion(148) && !IsTileType(o->location.tile, MP_OBJECT)) { + if (IsSavegameVersionBefore(148) && !IsTileType(o->location.tile, MP_OBJECT)) { /* Due to a small bug stale objects could remain. */ delete o; } else { diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp index 28be21b42..31c6c9fb8 100644 --- a/src/saveload/order_sl.cpp +++ b/src/saveload/order_sl.cpp @@ -23,7 +23,7 @@ void Order::ConvertFromOldSavegame() this->flags = 0; /* First handle non-stop - use value from savegame if possible, else use value from config file */ - if (_settings_client.gui.sg_new_nonstop || (CheckSavegameVersion(22) && _settings_client.gui.new_nonstop)) { + if (_settings_client.gui.sg_new_nonstop || (IsSavegameVersionBefore(22) && _settings_client.gui.new_nonstop)) { /* OFB_NON_STOP */ this->SetNonStopType((old_flags & 8) ? ONSF_NO_STOP_AT_ANY_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); } else { @@ -44,7 +44,7 @@ void Order::ConvertFromOldSavegame() this->SetLoadType(OLF_LOAD_IF_POSSIBLE); } else { /* old OTTD versions stored full_load_any in config file - assume it was enabled when loading */ - this->SetLoadType(_settings_client.gui.sg_full_load_any || CheckSavegameVersion(22) ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD); + this->SetLoadType(_settings_client.gui.sg_full_load_any || IsSavegameVersionBefore(22) ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD); } if (this->IsType(OT_GOTO_STATION)) this->SetStopLocation(OSL_PLATFORM_FAR_END); @@ -134,7 +134,7 @@ static void Load_ORDR() * (in the old days, the orderlist was 5000 items big) */ size_t len = SlGetFieldLength(); - if (CheckSavegameVersion(5)) { + if (IsSavegameVersionBefore(5)) { /* Pre-version 5 had another layout for orders * (uint16 instead of uint32) */ len /= sizeof(uint16); diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index b57537fec..90e50b40f 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -686,7 +686,7 @@ static inline byte SlCalcConvFileLen(VarType conv) /** Return the size in bytes of a reference (pointer) */ static inline size_t SlCalcRefLen() { - return CheckSavegameVersion(69) ? 2 : 4; + return IsSavegameVersionBefore(69) ? 2 : 4; } void SlSetArrayIndex(uint index) @@ -1200,7 +1200,7 @@ static inline size_t SlCalcListLen(const void *list) { std::list<void *> *l = (std::list<void *> *) list; - int type_size = CheckSavegameVersion(69) ? 2 : 4; + int type_size = IsSavegameVersionBefore(69) ? 2 : 4; /* Each entry is saved as type_size bytes, plus type_size bytes are used for the length * of the list */ return l->size() * type_size + type_size; @@ -1237,11 +1237,11 @@ static void SlList(void *list, SLRefType conv) } case SLA_LOAD_CHECK: case SLA_LOAD: { - size_t length = CheckSavegameVersion(69) ? SlReadUint16() : SlReadUint32(); + size_t length = IsSavegameVersionBefore(69) ? SlReadUint16() : SlReadUint32(); /* Load each reference and push to the end of the list */ for (size_t i = 0; i < length; i++) { - size_t data = CheckSavegameVersion(69) ? SlReadUint16() : SlReadUint32(); + size_t data = IsSavegameVersionBefore(69) ? SlReadUint16() : SlReadUint32(); l->push_back((void *)data); } break; @@ -1359,7 +1359,7 @@ bool SlObjectMember(void *ptr, const SaveLoad *sld) break; case SLA_LOAD_CHECK: case SLA_LOAD: - *(size_t *)ptr = CheckSavegameVersion(69) ? SlReadUint16() : SlReadUint32(); + *(size_t *)ptr = IsSavegameVersionBefore(69) ? SlReadUint16() : SlReadUint32(); break; case SLA_PTRS: *(void **)ptr = IntToReference(*(size_t *)ptr, (SLRefType)conv); @@ -2463,7 +2463,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb, boo GamelogReset(); - if (CheckSavegameVersion(4)) { + if (IsSavegameVersionBefore(4)) { /* * NewGRFs were introduced between 0.3,4 and 0.3.5, which both * shared savegame version 4. Anything before that 'obviously' diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index 8e16f5369..ddf6b6dc5 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -461,17 +461,6 @@ static inline bool IsSavegameVersionBefore(uint16 major, byte minor = 0) } /** - * Checks if the savegame is below \a version. - * @param version First version that is too large. - * @return Savegame version equal or larger than \a version. - */ -static inline bool CheckSavegameVersion(uint16 version) -{ - extern uint16 _sl_version; - return _sl_version < version; -} - -/** * Checks if some version from/to combination falls within the range of the * active savegame version. * @param version_from Lowest version number that falls within the range. diff --git a/src/saveload/signs_sl.cpp b/src/saveload/signs_sl.cpp index f2a4bebbc..8aeceddc7 100644 --- a/src/saveload/signs_sl.cpp +++ b/src/saveload/signs_sl.cpp @@ -50,7 +50,7 @@ static void Load_SIGN() * - we can't use IsValidCompany() now, so this is fixed in AfterLoadGame() * All signs that were saved are valid (including those with just 'Sign' and INVALID_OWNER). * - so set owner to OWNER_NONE if needed (signs from pre-version 6.1 would be lost) */ - if (IsSavegameVersionBefore(6, 1) || (CheckSavegameVersion(83) && si->owner == INVALID_OWNER)) { + if (IsSavegameVersionBefore(6, 1) || (IsSavegameVersionBefore(83) && si->owner == INVALID_OWNER)) { si->owner = OWNER_NONE; } } diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index 1be9b417e..9e4872402 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -258,15 +258,15 @@ static void Load_STNS() _waiting_acceptance = 0; - uint num_cargo = CheckSavegameVersion(55) ? 12 : NUM_CARGO; + uint num_cargo = IsSavegameVersionBefore(55) ? 12 : NUM_CARGO; for (CargoID i = 0; i < num_cargo; i++) { GoodsEntry *ge = &st->goods[i]; SlObject(ge, GetGoodsDesc()); - if (CheckSavegameVersion(68)) { + if (IsSavegameVersionBefore(68)) { SB(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15)); if (GB(_waiting_acceptance, 0, 12) != 0) { /* In old versions, enroute_from used 0xFF as INVALID_STATION */ - StationID source = (CheckSavegameVersion(7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source; + StationID source = (IsSavegameVersionBefore(7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source; /* Don't construct the packet with station here, because that'll fail with old savegames */ ge->cargo.Append(new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, source, _cargo_source_xy, _cargo_source_xy, _cargo_feeder_share)); @@ -288,11 +288,11 @@ static void Load_STNS() static void Ptrs_STNS() { /* Don't run when savegame version is higher than or equal to 123. */ - if (!CheckSavegameVersion(123)) return; + if (!IsSavegameVersionBefore(123)) return; Station *st; FOR_ALL_STATIONS(st) { - if (!CheckSavegameVersion(68)) { + if (!IsSavegameVersionBefore(68)) { for (CargoID i = 0; i < NUM_CARGO; i++) { GoodsEntry *ge = &st->goods[i]; SlObject(ge, GetGoodsDesc()); @@ -432,7 +432,7 @@ static void Load_STNN() static void Ptrs_STNN() { /* Don't run when savegame version lower than 123. */ - if (CheckSavegameVersion(123)) return; + if (IsSavegameVersionBefore(123)) return; Station *st; FOR_ALL_STATIONS(st) { diff --git a/src/saveload/strings_sl.cpp b/src/saveload/strings_sl.cpp index 83ed2537b..beb39e965 100644 --- a/src/saveload/strings_sl.cpp +++ b/src/saveload/strings_sl.cpp @@ -56,7 +56,7 @@ char *CopyFromOldName(StringID id) /* Is this name an (old) custom name? */ if (GB(id, 11, 5) != 15) return NULL; - if (CheckSavegameVersion(37)) { + if (IsSavegameVersionBefore(37)) { /* Old names were 24/32 characters long, so 128 characters should be * plenty to allow for expansion when converted to UTF-8. */ char tmp[128]; diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index 6962a4f85..c081ba2bc 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -268,7 +268,7 @@ void AfterLoadVehicles(bool part_of_load) FOR_ALL_VEHICLES(v) { if (v->orders.old != NULL) { - if (CheckSavegameVersion(105)) { // Pre-105 didn't save an OrderList + if (IsSavegameVersionBefore(105)) { // Pre-105 didn't save an OrderList if (mapping[v->orders.old] == NULL) { /* This adds the whole shared vehicle chain for case b */ v->orders.list = mapping[v->orders.old] = new OrderList(v->orders.old, v); @@ -297,7 +297,7 @@ void AfterLoadVehicles(bool part_of_load) } } - if (CheckSavegameVersion(105)) { + if (IsSavegameVersionBefore(105)) { /* Before 105 there was no order for shared orders, thus it messed up horribly */ FOR_ALL_VEHICLES(v) { if (v->First() != v || v->orders.list != NULL || v->previous_shared != NULL || v->next_shared == NULL) continue; @@ -344,7 +344,7 @@ void AfterLoadVehicles(bool part_of_load) } /* Stop non-front engines */ - if (CheckSavegameVersion(112)) { + if (IsSavegameVersionBefore(112)) { FOR_ALL_VEHICLES(v) { if (v->type == VEH_TRAIN) { Train *t = Train::From(v); @@ -739,11 +739,11 @@ void Load_VEHS() } /* Old savegames used 'last_station_visited = 0xFF' */ - if (CheckSavegameVersion(5) && v->last_station_visited == 0xFF) { + if (IsSavegameVersionBefore(5) && v->last_station_visited == 0xFF) { v->last_station_visited = INVALID_STATION; } - if (CheckSavegameVersion(5)) { + if (IsSavegameVersionBefore(5)) { /* Convert the current_order.type (which is a mix of type and flags, because * in those versions, they both were 4 bits big) to type and flags */ v->current_order.flags = GB(v->current_order.type, 4, 4); @@ -751,7 +751,7 @@ void Load_VEHS() } /* Advanced vehicle lists got added */ - if (CheckSavegameVersion(60)) v->group_id = DEFAULT_GROUP; + if (IsSavegameVersionBefore(60)) v->group_id = DEFAULT_GROUP; } } diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp index 5dac5d8e4..3dce9e3d5 100644 --- a/src/saveload/waypoint_sl.cpp +++ b/src/saveload/waypoint_sl.cpp @@ -68,7 +68,7 @@ void MoveWaypointsToBaseStations() * waypoints to make way for storing the index in m2. The custom graphics * id which was stored in m4 is now saved as a grf/id reference in the * waypoint struct. */ - if (CheckSavegameVersion(17)) { + if (IsSavegameVersionBefore(17)) { for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) { if (wp->delete_ctr != 0) continue; // The waypoint was deleted @@ -108,7 +108,7 @@ void MoveWaypointsToBaseStations() TileIndex t = wp->xy; if (IsTileType(t, MP_RAILWAY) && GetRailTileType(t) == 2 /* RAIL_TILE_WAYPOINT */ && _m[t].m2 == wp->index) { /* The tile might've been reserved! */ - bool reserved = !CheckSavegameVersion(100) && HasBit(_m[t].m5, 4); + bool reserved = !IsSavegameVersionBefore(100) && HasBit(_m[t].m5, 4); /* The tile really has our waypoint, so reassign the map array */ MakeRailWaypoint(t, GetTileOwner(t), new_wp->index, (Axis)GB(_m[t].m5, 0, 1), 0, GetRailType(t)); @@ -185,10 +185,10 @@ static void Ptrs_WAYP() for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) { SlObject(wp, _old_waypoint_desc); - if (CheckSavegameVersion(12)) { + if (IsSavegameVersionBefore(12)) { wp->town_cn = (wp->string_id & 0xC000) == 0xC000 ? (wp->string_id >> 8) & 0x3F : 0; wp->town = ClosestTownFromTile(wp->xy, UINT_MAX); - } else if (CheckSavegameVersion(122)) { + } else if (IsSavegameVersionBefore(122)) { /* Only for versions 12 .. 122 */ if (!Town::IsValidID(wp->town_index)) { /* Upon a corrupted waypoint we'll likely get here. The next step will be to @@ -201,7 +201,7 @@ static void Ptrs_WAYP() } wp->town = Town::Get(wp->town_index); } - if (CheckSavegameVersion(84)) { + if (IsSavegameVersionBefore(84)) { wp->name = CopyFromOldName(wp->string_id); } } |