Skip to content

Commit

Permalink
Fix: adding huge airports broke old savegames
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Apr 5, 2020
1 parent ed199b6 commit dc10a34
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/airport.h
Expand Up @@ -35,9 +35,9 @@ enum AirportTypes {
AT_HELIDEPOT = 6, ///< Heli depot.
AT_INTERCON = 7, ///< Intercontinental airport.
AT_HELISTATION = 8, ///< Heli station airport.
AT_INTERCONTINENTAL2 = 9, ///< Intercontinental airport 2.
AT_CIRCLE = 10, ///< Circle airport.
AT_OILRIG = 11, ///< Oilrig airport.
AT_OILRIG = 9, ///< Oilrig airport.
AT_INTERCONTINENTAL2 = 10, ///< Intercontinental airport 2.
AT_CIRCLE = 11, ///< Circle airport.
NEW_AIRPORT_OFFSET = 12, ///< Number of the first newgrf airport.
NUM_AIRPORTS = 128, ///< Maximal number of airports.
NUM_AIRPORTS_PER_GRF = 128,
Expand Down
19 changes: 16 additions & 3 deletions src/saveload/afterload.cpp
Expand Up @@ -880,7 +880,18 @@ bool AfterLoadGame()
}
}
}

if(SlXvIsFeaturePresent(XSLFI_HUGE_AIRPORTS, 1, 1)) {
/* This version of the JGR huge airports patch shifted the IDs of the airports, which caused other problems. */
for (Station *st : Station::Iterate()) {
if (st->airport.tile == INVALID_TILE) continue;
if (st->airport.type == 11) { /* oil rig */
st->airport.type = AT_OILRIG; /* Shift ID */
} else if(st->airport.type == 9) /* intercontinental 2 */
st->airport.type = AT_INTERCONTINENTAL2;
else if(st->airport.type == 10) /* circle */
st->airport.type = AT_CIRCLE;
}
}
if (SlXvIsFeaturePresent(XSLFI_SPRINGPP)) {
/*
* Reject huge airports
Expand Down Expand Up @@ -909,10 +920,12 @@ bool AfterLoadGame()
}
}

if (SlXvIsFeaturePresent(XSLFI_SPRINGPP, 1, 1)) {
if (SlXvIsFeaturePresent(XSLFI_HUGE_AIRPORTS, 1, 1) || SlXvIsFeaturePresent(XSLFI_SPRINGPP, 1, 1)) {
/*
* Reject helicopters aproaching oil rigs using the wrong aircraft movement data
* Annoyingly SpringPP v2.0.102 has a bug where it uses the same ID for AT_INTERCONTINENTAL2 and AT_OILRIG
* Annoyingly SpringPP v2.0.102 has a bug where it uses the same ID for AT_INTERCONTINENTAL2 and AT_OILRIG.
* The initial commit of the huge airports patch also had a bug where IDs had been swapped,
* which caused issues with old savegames loaded in that version.
* Do this here as AfterLoadVehicles can also check it indirectly via the newgrf code.
*/
for (Aircraft *v : Aircraft::Iterate()) {
Expand Down
2 changes: 1 addition & 1 deletion src/saveload/extended_ver_sl.cpp
Expand Up @@ -113,7 +113,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_FLOW_STAT_FLAGS, XSCF_NULL, 1, 1, "flow_stat_flags", nullptr, nullptr, nullptr },
{ XSLFI_SPEED_RESTRICTION, XSCF_NULL, 1, 1, "speed_restriction", nullptr, nullptr, "VESR" },
{ XSLFI_STATION_GOODS_EXTRA, XSCF_NULL, 1, 1, "station_goods_extra", nullptr, nullptr, nullptr },
{ XSLFI_HUGE_AIRPORTS, XSCF_NULL, 1, 1, "huge_airports", nullptr, nullptr, nullptr },
{ XSLFI_HUGE_AIRPORTS, XSCF_NULL, 2, 2, "huge_airports", nullptr, nullptr, nullptr },
{ XSLFI_TRIP_HISTORY, XSCF_NULL, 1, 1, "trip_history", nullptr, nullptr, nullptr },
{ XSLFI_NULL, XSCF_NULL, 0, 0, nullptr, nullptr, nullptr, nullptr },// This is the end marker
};
Expand Down
4 changes: 2 additions & 2 deletions src/table/airport_defaults.h
Expand Up @@ -773,9 +773,9 @@ extern const AirportSpec _origin_airport_specs[] = {
AS(helidepot, 2, 2, 1976, MAX_YEAR, 4, 2, 7, ATP_TTDP_SMALL, APC_HELIPORT, STR_AIRPORT_HELIDEPOT, SPR_AIRPORT_PREVIEW_HELIDEPOT),
AS(intercontinental, 9, 11, 2002, MAX_YEAR, 10, 25, 72, ATP_TTDP_LARGE, APC_HUB, STR_AIRPORT_INTERCONTINENTAL, SPR_AIRPORT_PREVIEW_INTERCONTINENTAL),
AS(helistation, 4, 2, 1980, MAX_YEAR, 4, 3, 14, ATP_TTDP_SMALL, APC_HELIPORT, STR_AIRPORT_HELISTATION, SPR_AIRPORT_PREVIEW_HELISTATION),
AS(intercontinental2,12,10, 2005, MAX_YEAR, 11, 30, 80, ATP_TTDP_LARGE, APC_HUGE, STR_AIRPORT_INTERCONTINENTAL2, 0),
AS_C(circle, 15,15, 2015, MAX_YEAR, 15, 50,150, 30, ATP_TTDP_LARGE,APC_HUGE, STR_AIRPORT_CIRCLE, 0),
AS_GENERIC(&_airportfta_oilrig, nullptr, _default_airports_rotation, 0, nullptr, 0, 1, 1, 0, 4, 0, 0, 0, 0, ATP_TTDP_OILRIG, APC_HELIPORT, STR_NULL, 0, false),
AS(intercontinental2,12,10, 2005, MAX_YEAR, 11, 30, 80, ATP_TTDP_LARGE, APC_HUGE, STR_AIRPORT_INTERCONTINENTAL2, 0),
AS_C(circle, 15,15, 2015, MAX_YEAR, 15, 50,150, 30, ATP_TTDP_LARGE,APC_HUGE, STR_AIRPORT_CIRCLE, 0)
};

assert_compile(NEW_AIRPORT_OFFSET == lengthof(_origin_airport_specs));
Expand Down

0 comments on commit dc10a34

Please sign in to comment.