From 279eac6e573e5ea402635a6d91b9f9b058bebf98 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 17 Aug 2015 21:41:05 +0100 Subject: [PATCH] Reject SpringPP games with huge airports or helis approaching oil rigs. Huge airports are not supported. Annoyingly SpringPP has a bug where it uses the same ID for AT_INTERCONTINENTAL2 and AT_OILRIG. Consequently any aircraft approaching an oil rig in an SPP game will be using the wrong aircraft movement data, and this will go badly wrong as soon as the game is unpaused. --- src/lang/english.txt | 3 +++ src/saveload/afterload.cpp | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/lang/english.txt b/src/lang/english.txt index 2c12835f9d..0d0e602c60 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -4527,6 +4527,9 @@ STR_GAME_SAVELOAD_ERROR_DATA_INTEGRITY_CHECK_FAILED :Data integrity STR_GAME_SAVELOAD_NOT_AVAILABLE : STR_WARNING_LOADGAME_REMOVED_TRAMS :{WHITE}Game was saved in version without tram support. All trams have been removed +STR_GAME_SAVELOAD_ERROR_HUGE_AIRPORTS_PRESENT :Savegame uses huge airports +STR_GAME_SAVELOAD_ERROR_HELI_OILRIG_BUG :Savegame has a helicopter on approach to a buggy oil rig + # Map generation messages STR_ERROR_COULD_NOT_CREATE_TOWN :{WHITE}Map generation aborted...{}... no suitable town locations STR_ERROR_NO_TOWN_IN_SCENARIO :{WHITE}... there is no town in this scenario diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 0b0f78b0e5..1c054364be 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -3076,6 +3076,45 @@ bool AfterLoadGame() DEBUG(sl, 3, "New inflation prices: %f", _economy.inflation_prices / 65536.0); } + if (SlXvIsFeaturePresent(XSLFI_SPRINGPP)) { + /* + * Reject huge airports and helicopters aproaching oil rigs using the wrong aircraft movement data + * Annoyingly SpringPP has a bug where it uses the same ID for AT_INTERCONTINENTAL2 and AT_OILRIG + */ + Station *st; + FOR_ALL_STATIONS(st) { + if (st->airport.tile == INVALID_TILE) continue; + StringID err = INVALID_STRING_ID; + if (st->airport.type == 9) { + if (st->dock_tile != INVALID_TILE && IsOilRig(st->dock_tile)) { + /* this airport is probably an oil rig, not a huge airport */ + } else { + err = STR_GAME_SAVELOAD_ERROR_HUGE_AIRPORTS_PRESENT; + } + st->airport.type = AT_OILRIG; + } else if (st->airport.type == 10) { + err = STR_GAME_SAVELOAD_ERROR_HUGE_AIRPORTS_PRESENT; + } + if (err != INVALID_STRING_ID) { + SetSaveLoadError(err); + /* Restore the signals */ + ResetSignalHandlers(); + return false; + } + } + Aircraft *v; + FOR_ALL_AIRCRAFT(v) { + Station *st = GetTargetAirportIfValid(v); + if (st != NULL && st->dock_tile != INVALID_TILE && IsOilRig(st->dock_tile)) { + /* aircraft is on approach to an oil rig, bail out now */ + SetSaveLoadError(STR_GAME_SAVELOAD_ERROR_HELI_OILRIG_BUG); + /* Restore the signals */ + ResetSignalHandlers(); + return false; + } + } + } + /* Station acceptance is some kind of cache */ if (IsSavegameVersionBefore(127)) { Station *st;