From 57920772e5205374d13bff8499676d7223079d2e Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Fri, 16 Feb 2024 16:27:32 +0000 Subject: [PATCH] Change: [Script] Improve some ScriptAirport return values for AT_OILRIG airport type Affected functions are: IsAirportInformationAvailable, GetAirportWidth, GetAirportHeight, GetAirportCoverageRadius, GetNumHangars, GetHangarOfAirport, GetNoiseLevelIncrease, GetNearestTown, GetMaintenanceCostFactor, GetMonthlyMaintenanceCost and GetAirportNumHelipads. Add AT_OILRIG to the AirportType enum even though it can't be built. Add an AirportTileTable for oilrig in AirportSpec definitions. --- regression/regression/result.txt | 10 +++++----- src/script/api/ai_changelog.hpp | 3 +++ src/script/api/game_changelog.hpp | 3 +++ src/script/api/script_airport.cpp | 9 +++++---- src/script/api/script_airport.hpp | 1 + src/station_type.h | 2 +- src/table/airport_defaults.h | 14 ++++++++++++-- 7 files changed, 30 insertions(+), 12 deletions(-) diff --git a/regression/regression/result.txt b/regression/regression/result.txt index 8eedd0d71e..e02ca0ad69 100644 --- a/regression/regression/result.txt +++ b/regression/regression/result.txt @@ -860,12 +860,12 @@ ERROR: IsEnd() is invalid as Begin() is never called GetAirportHeight(8): 2 GetAirportCoverageRadius(8): 4 GetAirportNumHelipads(8): 3 - IsAirportInformationAvailable(9): false + IsAirportInformationAvailable(9): true IsValidAirportType(9): false - GetAirportWidth(9): -1 - GetAirportHeight(9): -1 - GetAirportCoverageRadius(9): -1 - GetAirportNumHelipads(9): -1 + GetAirportWidth(9): 1 + GetAirportHeight(9): 1 + GetAirportCoverageRadius(9): 4 + GetAirportNumHelipads(9): 1 GetBankBalance(): 1999999790 GetPrice(): 5400 BuildAirport(): true diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp index e6b524a857..6601e964ff 100644 --- a/src/script/api/ai_changelog.hpp +++ b/src/script/api/ai_changelog.hpp @@ -17,6 +17,9 @@ * * This version is not yet released. The following changes are not set in stone yet. * + * API additions: + * \li AIAirport::AT_OILRIG + * * \b 14.0 * * API additions: diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index 8ebf05310c..647326ab1c 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -17,6 +17,9 @@ * * This version is not yet released. The following changes are not set in stone yet. * + * API additions: + * \li GSAirport::AT_OILRIG + * * \b 14.0 * * API additions: diff --git a/src/script/api/script_airport.cpp b/src/script/api/script_airport.cpp index 39fbee2e60..78abd256dd 100644 --- a/src/script/api/script_airport.cpp +++ b/src/script/api/script_airport.cpp @@ -24,7 +24,7 @@ /* static */ bool ScriptAirport::IsAirportInformationAvailable(AirportType type) { - return type >= 0 && type < (AirportType)NUM_AIRPORTS && AirportSpec::Get(type)->enabled; + return type == AT_OILRIG || (type >= 0 && type < (AirportType)NUM_AIRPORTS && AirportSpec::Get(type)->enabled); } /* static */ Money ScriptAirport::GetPrice(AirportType type) @@ -67,6 +67,7 @@ { if (!IsAirportInformationAvailable(type)) return -1; + if (type == AT_OILRIG && !_settings_game.station.serve_neutral_industries) return (uint)CA_NONE; return _settings_game.station.modified_catchment ? ::AirportSpec::Get(type)->catchment : (uint)CA_UNMODIFIED; } @@ -96,7 +97,7 @@ if (!::IsTileType(tile, MP_STATION)) return -1; const Station *st = ::Station::GetByTile(tile); - if (st->owner != ScriptObject::GetCompany() && ScriptCompanyMode::IsValid()) return -1; + if (st->owner != ScriptObject::GetCompany() && ScriptCompanyMode::IsValid() && st->owner != OWNER_NONE) return -1; if ((st->facilities & FACIL_AIRPORT) == 0) return -1; return st->airport.GetNumHangars(); @@ -110,7 +111,7 @@ if (GetNumHangars(tile) < 1) return INVALID_TILE; const Station *st = ::Station::GetByTile(tile); - if (st->owner != ScriptObject::GetCompany() && ScriptCompanyMode::IsValid()) return INVALID_TILE; + if (st->owner != ScriptObject::GetCompany() && ScriptCompanyMode::IsValid() && st->owner != OWNER_NONE) return INVALID_TILE; if ((st->facilities & FACIL_AIRPORT) == 0) return INVALID_TILE; return st->airport.GetHangarTile(0); @@ -142,7 +143,7 @@ return GetAirportNoiseLevelForDistance(as, dist); } - return 1; + return type == AT_OILRIG ? 0 : 1; } /* static */ TownID ScriptAirport::GetNearestTown(TileIndex tile, AirportType type) diff --git a/src/script/api/script_airport.hpp b/src/script/api/script_airport.hpp index e46658219a..1eb6183906 100644 --- a/src/script/api/script_airport.hpp +++ b/src/script/api/script_airport.hpp @@ -33,6 +33,7 @@ public: AT_HELIPORT = ::AT_HELIPORT, ///< The heliport. AT_HELISTATION = ::AT_HELISTATION, ///< The helistation. AT_HELIDEPOT = ::AT_HELIDEPOT, ///< The helidepot. + AT_OILRIG = ::AT_OILRIG, ///< The oil rig heliport. AT_INVALID = ::AT_INVALID, ///< Invalid airport. }; diff --git a/src/station_type.h b/src/station_type.h index 345e900536..6b8567f41e 100644 --- a/src/station_type.h +++ b/src/station_type.h @@ -73,7 +73,7 @@ DECLARE_ENUM_AS_BIT_SET(StationHadVehicleOfType) /** The different catchment areas used */ enum CatchmentArea { - CA_NONE = 0, ///< Catchment when the station has no facilities + CA_NONE = 0, ///< Catchment when the station has no facilities or with "serve neutral industries" enabled CA_BUS = 3, ///< Catchment for bus stops with "modified catchment" enabled CA_TRUCK = 3, ///< Catchment for truck stops with "modified catchment" enabled CA_TRAIN = 4, ///< Catchment for train stations with "modified catchment" enabled diff --git a/src/table/airport_defaults.h b/src/table/airport_defaults.h index 7305779412..464838a6d3 100644 --- a/src/table/airport_defaults.h +++ b/src/table/airport_defaults.h @@ -373,6 +373,16 @@ static const AirportTileTable * const _tile_table_helistation[] = { _tile_table_helistation_0, }; +/** Tiles for oilrig */ +static const AirportTileTable _tile_table_oilrig_0[] = { + MK(0, 0, APT_EMPTY), + MKEND +}; + +static const AirportTileTable * const _tile_table_oilrig[] = { + _tile_table_oilrig_0, +}; + static const Direction _default_airports_rotation[] = { DIR_N, }; @@ -396,7 +406,7 @@ static const Direction _default_airports_rotation[] = { /* The helidepot and helistation have ATP_TTDP_SMALL because they are at ground level */ extern const AirportSpec _origin_airport_specs[] = { - AS(country, 4, 3, 0, 1959, 4, 3, 7, ATP_TTDP_SMALL, APC_SMALL, STR_AIRPORT_SMALL, SPR_AIRPORT_PREVIEW_SMALL), + AS(country, 4, 3, CalendarTime::MIN_YEAR, 1959, 4, 3, 7, ATP_TTDP_SMALL, APC_SMALL, STR_AIRPORT_SMALL, SPR_AIRPORT_PREVIEW_SMALL), AS(city, 6, 6, 1955, CalendarTime::MAX_YEAR, 5, 5, 24, ATP_TTDP_LARGE, APC_LARGE, STR_AIRPORT_CITY, SPR_AIRPORT_PREVIEW_LARGE), AS_ND(heliport, 1, 1, 1963, CalendarTime::MAX_YEAR, 4, 1, 4, ATP_TTDP_HELIPORT, APC_HELIPORT, STR_AIRPORT_HELIPORT, SPR_AIRPORT_PREVIEW_HELIPORT), AS(metropolitan, 6, 6, 1980, CalendarTime::MAX_YEAR, 6, 8, 28, ATP_TTDP_LARGE, APC_LARGE, STR_AIRPORT_METRO, SPR_AIRPORT_PREVIEW_METROPOLITAN), @@ -405,7 +415,7 @@ extern const AirportSpec _origin_airport_specs[] = { AS(helidepot, 2, 2, 1976, CalendarTime::MAX_YEAR, 4, 2, 7, ATP_TTDP_SMALL, APC_HELIPORT, STR_AIRPORT_HELIDEPOT, SPR_AIRPORT_PREVIEW_HELIDEPOT), AS(intercontinental, 9, 11, 2002, CalendarTime::MAX_YEAR, 10, 25, 72, ATP_TTDP_LARGE, APC_HUB, STR_AIRPORT_INTERCONTINENTAL, SPR_AIRPORT_PREVIEW_INTERCONTINENTAL), AS(helistation, 4, 2, 1980, CalendarTime::MAX_YEAR, 4, 3, 14, ATP_TTDP_SMALL, APC_HELIPORT, STR_AIRPORT_HELISTATION, SPR_AIRPORT_PREVIEW_HELISTATION), - AS_GENERIC(&_airportfta_oilrig, nullptr, _default_airports_rotation, 0, nullptr, 0, 1, 1, 0, 4, 0, 0, 0, ATP_TTDP_OILRIG, APC_HELIPORT, STR_NULL, 0, false), + AS_GENERIC(&_airportfta_oilrig, _tile_table_oilrig, _default_airports_rotation, lengthof(_tile_table_oilrig), nullptr, 0, 1, 1, 0, 4, CalendarTime::MIN_YEAR, CalendarTime::MIN_YEAR, 0, ATP_TTDP_OILRIG, APC_HELIPORT, STR_NULL, 0, false), }; static_assert(NEW_AIRPORT_OFFSET == lengthof(_origin_airport_specs));