mirror of https://github.com/OpenTTD/OpenTTD
(svn r21282) -Codechange: Rename CheckSavegameVersionOldStyle() to IsSavegameVersionBefore().
parent
2974141641
commit
edef25d30c
|
@ -485,19 +485,19 @@ bool AfterLoadGame()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* in version 2.1 of the savegame, town owner was unified. */
|
/* in version 2.1 of the savegame, town owner was unified. */
|
||||||
if (CheckSavegameVersionOldStyle(2, 1)) ConvertTownOwner();
|
if (IsSavegameVersionBefore(2, 1)) ConvertTownOwner();
|
||||||
|
|
||||||
/* from version 4.1 of the savegame, exclusive rights are stored at towns */
|
/* from version 4.1 of the savegame, exclusive rights are stored at towns */
|
||||||
if (CheckSavegameVersionOldStyle(4, 1)) UpdateExclusiveRights();
|
if (IsSavegameVersionBefore(4, 1)) UpdateExclusiveRights();
|
||||||
|
|
||||||
/* from version 4.2 of the savegame, currencies are in a different order */
|
/* from version 4.2 of the savegame, currencies are in a different order */
|
||||||
if (CheckSavegameVersionOldStyle(4, 2)) UpdateCurrencies();
|
if (IsSavegameVersionBefore(4, 2)) UpdateCurrencies();
|
||||||
|
|
||||||
/* In old version there seems to be a problem that water is owned by
|
/* In old version there seems to be a problem that water is owned by
|
||||||
* OWNER_NONE, not OWNER_WATER.. I can't replicate it for the current
|
* OWNER_NONE, not OWNER_WATER.. I can't replicate it for the current
|
||||||
* (4.3) version, so I just check when versions are older, and then
|
* (4.3) version, so I just check when versions are older, and then
|
||||||
* walk through the whole map.. */
|
* walk through the whole map.. */
|
||||||
if (CheckSavegameVersionOldStyle(4, 3)) {
|
if (IsSavegameVersionBefore(4, 3)) {
|
||||||
for (TileIndex t = 0; t < map_size; t++) {
|
for (TileIndex t = 0; t < map_size; t++) {
|
||||||
if (IsTileType(t, MP_WATER) && GetTileOwner(t) >= MAX_COMPANIES) {
|
if (IsTileType(t, MP_WATER) && GetTileOwner(t) >= MAX_COMPANIES) {
|
||||||
SetTileOwner(t, OWNER_WATER);
|
SetTileOwner(t, OWNER_WATER);
|
||||||
|
@ -576,7 +576,7 @@ bool AfterLoadGame()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The value of _date_fract got divided, so make sure that old games are converted correctly. */
|
/* The value of _date_fract got divided, so make sure that old games are converted correctly. */
|
||||||
if (CheckSavegameVersionOldStyle(11, 1) || (CheckSavegameVersion(147) && _date_fract > DAY_TICKS)) _date_fract /= 885;
|
if (IsSavegameVersionBefore(11, 1) || (CheckSavegameVersion(147) && _date_fract > DAY_TICKS)) _date_fract /= 885;
|
||||||
|
|
||||||
/* Update current year
|
/* Update current year
|
||||||
* must be done before loading sprites as some newgrfs check it */
|
* must be done before loading sprites as some newgrfs check it */
|
||||||
|
@ -594,7 +594,7 @@ bool AfterLoadGame()
|
||||||
|
|
||||||
/* Connect front and rear engines of multiheaded trains and converts
|
/* Connect front and rear engines of multiheaded trains and converts
|
||||||
* subtype to the new format */
|
* subtype to the new format */
|
||||||
if (CheckSavegameVersionOldStyle(17, 1)) ConvertOldMultiheadToNew();
|
if (IsSavegameVersionBefore(17, 1)) ConvertOldMultiheadToNew();
|
||||||
|
|
||||||
/* Connect front and rear engines of multiheaded trains */
|
/* Connect front and rear engines of multiheaded trains */
|
||||||
ConnectMultiheadedTrains();
|
ConnectMultiheadedTrains();
|
||||||
|
@ -773,12 +773,12 @@ bool AfterLoadGame()
|
||||||
|
|
||||||
/* In version 2.2 of the savegame, we have new airports, so status of all aircraft is reset.
|
/* In version 2.2 of the savegame, we have new airports, so status of all aircraft is reset.
|
||||||
* This has to be called after the oilrig airport_type update above ^^^ ! */
|
* This has to be called after the oilrig airport_type update above ^^^ ! */
|
||||||
if (CheckSavegameVersionOldStyle(2, 2)) UpdateOldAircraft();
|
if (IsSavegameVersionBefore(2, 2)) UpdateOldAircraft();
|
||||||
|
|
||||||
/* In version 6.1 we put the town index in the map-array. To do this, we need
|
/* In version 6.1 we put the town index in the map-array. To do this, we need
|
||||||
* to use m2 (16bit big), so we need to clean m2, and that is where this is
|
* to use m2 (16bit big), so we need to clean m2, and that is where this is
|
||||||
* all about ;) */
|
* all about ;) */
|
||||||
if (CheckSavegameVersionOldStyle(6, 1)) {
|
if (IsSavegameVersionBefore(6, 1)) {
|
||||||
for (TileIndex t = 0; t < map_size; t++) {
|
for (TileIndex t = 0; t < map_size; t++) {
|
||||||
switch (GetTileType(t)) {
|
switch (GetTileType(t)) {
|
||||||
case MP_HOUSE:
|
case MP_HOUSE:
|
||||||
|
@ -1101,7 +1101,7 @@ bool AfterLoadGame()
|
||||||
/* In version 16.1 of the savegame a company can decide if trains, which get
|
/* In version 16.1 of the savegame a company can decide if trains, which get
|
||||||
* replaced, shall keep their old length. In all prior versions, just default
|
* replaced, shall keep their old length. In all prior versions, just default
|
||||||
* to false */
|
* to false */
|
||||||
if (CheckSavegameVersionOldStyle(16, 1)) {
|
if (IsSavegameVersionBefore(16, 1)) {
|
||||||
Company *c;
|
Company *c;
|
||||||
FOR_ALL_COMPANIES(c) c->settings.renew_keep_length = false;
|
FOR_ALL_COMPANIES(c) c->settings.renew_keep_length = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ static void Save_ORDR()
|
||||||
|
|
||||||
static void Load_ORDR()
|
static void Load_ORDR()
|
||||||
{
|
{
|
||||||
if (CheckSavegameVersionOldStyle(5, 2)) {
|
if (IsSavegameVersionBefore(5, 2)) {
|
||||||
/* Version older than 5.2 did not have a ->next pointer. Convert them
|
/* Version older than 5.2 did not have a ->next pointer. Convert them
|
||||||
* (in the old days, the orderlist was 5000 items big) */
|
* (in the old days, the orderlist was 5000 items big) */
|
||||||
size_t len = SlGetFieldLength();
|
size_t len = SlGetFieldLength();
|
||||||
|
@ -148,7 +148,7 @@ static void Load_ORDR()
|
||||||
}
|
}
|
||||||
|
|
||||||
free(orders);
|
free(orders);
|
||||||
} else if (CheckSavegameVersionOldStyle(5, 2)) {
|
} else if (IsSavegameVersionBefore(5, 2)) {
|
||||||
len /= sizeof(uint32);
|
len /= sizeof(uint32);
|
||||||
uint32 *orders = MallocT<uint32>(len + 1);
|
uint32 *orders = MallocT<uint32>(len + 1);
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ static void Load_ORDR()
|
||||||
static void Ptrs_ORDR()
|
static void Ptrs_ORDR()
|
||||||
{
|
{
|
||||||
/* Orders from old savegames have pointers corrected in Load_ORDR */
|
/* Orders from old savegames have pointers corrected in Load_ORDR */
|
||||||
if (CheckSavegameVersionOldStyle(5, 2)) return;
|
if (IsSavegameVersionBefore(5, 2)) return;
|
||||||
|
|
||||||
Order *o;
|
Order *o;
|
||||||
|
|
||||||
|
|
|
@ -1141,7 +1141,7 @@ static void *IntToReference(size_t index, SLRefType rt)
|
||||||
|
|
||||||
/* After version 4.3 REF_VEHICLE_OLD is saved as REF_VEHICLE,
|
/* After version 4.3 REF_VEHICLE_OLD is saved as REF_VEHICLE,
|
||||||
* and should be loaded like that */
|
* and should be loaded like that */
|
||||||
if (rt == REF_VEHICLE_OLD && !CheckSavegameVersionOldStyle(4, 4)) {
|
if (rt == REF_VEHICLE_OLD && !IsSavegameVersionBefore(4, 4)) {
|
||||||
rt = REF_VEHICLE;
|
rt = REF_VEHICLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1160,7 +1160,7 @@ static void *IntToReference(size_t index, SLRefType rt)
|
||||||
case REF_ORDER:
|
case REF_ORDER:
|
||||||
if (Order::IsValidID(index)) return Order::Get(index);
|
if (Order::IsValidID(index)) return Order::Get(index);
|
||||||
/* in old versions, invalid order was used to mark end of order list */
|
/* in old versions, invalid order was used to mark end of order list */
|
||||||
if (CheckSavegameVersionOldStyle(5, 2)) return NULL;
|
if (IsSavegameVersionBefore(5, 2)) return NULL;
|
||||||
SlErrorCorrupt("Referencing invalid Order");
|
SlErrorCorrupt("Referencing invalid Order");
|
||||||
|
|
||||||
case REF_VEHICLE_OLD:
|
case REF_VEHICLE_OLD:
|
||||||
|
|
|
@ -453,7 +453,7 @@ typedef SaveLoad SaveLoadGlobVarList;
|
||||||
* @param minor Minor number of the version to check against.
|
* @param minor Minor number of the version to check against.
|
||||||
* @return Savegame version is less than the \a major version, or has equal \a major version and a smaller \a minor version.
|
* @return Savegame version is less than the \a major version, or has equal \a major version and a smaller \a minor version.
|
||||||
*/
|
*/
|
||||||
static inline bool CheckSavegameVersionOldStyle(uint16 major, byte minor)
|
static inline bool IsSavegameVersionBefore(uint16 major, byte minor)
|
||||||
{
|
{
|
||||||
extern uint16 _sl_version;
|
extern uint16 _sl_version;
|
||||||
extern byte _sl_minor_version;
|
extern byte _sl_minor_version;
|
||||||
|
|
|
@ -50,7 +50,7 @@ static void Load_SIGN()
|
||||||
* - we can't use IsValidCompany() now, so this is fixed in AfterLoadGame()
|
* - 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).
|
* 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) */
|
* - so set owner to OWNER_NONE if needed (signs from pre-version 6.1 would be lost) */
|
||||||
if (CheckSavegameVersionOldStyle(6, 1) || (CheckSavegameVersion(83) && si->owner == INVALID_OWNER)) {
|
if (IsSavegameVersionBefore(6, 1) || (CheckSavegameVersion(83) && si->owner == INVALID_OWNER)) {
|
||||||
si->owner = OWNER_NONE;
|
si->owner = OWNER_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,7 +275,7 @@ void AfterLoadVehicles(bool part_of_load)
|
||||||
} else {
|
} else {
|
||||||
v->orders.list = mapping[v->orders.old];
|
v->orders.list = mapping[v->orders.old];
|
||||||
/* For old games (case a) we must create the shared vehicle chain */
|
/* For old games (case a) we must create the shared vehicle chain */
|
||||||
if (CheckSavegameVersionOldStyle(5, 2)) {
|
if (IsSavegameVersionBefore(5, 2)) {
|
||||||
v->AddToShared(v->orders.list->GetFirstSharedVehicle());
|
v->AddToShared(v->orders.list->GetFirstSharedVehicle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ void AfterLoadVehicles(bool part_of_load)
|
||||||
}
|
}
|
||||||
/* trains weren't stopping gradually in old OTTD versions (and TTO/TTD)
|
/* trains weren't stopping gradually in old OTTD versions (and TTO/TTD)
|
||||||
* other vehicle types didn't have zero speed while stopped (even in 'recent' OTTD versions) */
|
* other vehicle types didn't have zero speed while stopped (even in 'recent' OTTD versions) */
|
||||||
if ((v->vehstatus & VS_STOPPED) && (v->type != VEH_TRAIN || CheckSavegameVersionOldStyle(2, 1))) {
|
if ((v->vehstatus & VS_STOPPED) && (v->type != VEH_TRAIN || IsSavegameVersionBefore(2, 1))) {
|
||||||
v->cur_speed = 0;
|
v->cur_speed = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue