diff options
author | Samu <dj_samu@hotmail.com> | 2018-09-14 13:03:52 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2018-11-01 18:06:08 +0100 |
commit | 1e68b9b3e6487c8c95c5d8dac89c04ea06d1d9b5 (patch) | |
tree | ef4e425dd7241c0b230feba91dfba9b4267157c2 /src/script | |
parent | 4703cd433d18c8c6d144a0e279891cf039add6e1 (diff) | |
download | openttd-1e68b9b3e6487c8c95c5d8dac89c04ea06d1d9b5.tar.xz |
Add: AI/GS GetMonthlyMaintenanceCost (#6897)
API addition which allows AI/GS scripts to retrieve the monthly maintenance cost of an airport type.
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/ai/ai_airport.hpp.sq | 1 | ||||
-rw-r--r-- | src/script/api/ai_changelog.hpp | 2 | ||||
-rw-r--r-- | src/script/api/game/game_airport.hpp.sq | 1 | ||||
-rw-r--r-- | src/script/api/game_changelog.hpp | 1 | ||||
-rw-r--r-- | src/script/api/script_airport.cpp | 7 | ||||
-rw-r--r-- | src/script/api/script_airport.hpp | 8 |
6 files changed, 20 insertions, 0 deletions
diff --git a/src/script/api/ai/ai_airport.hpp.sq b/src/script/api/ai/ai_airport.hpp.sq index 63ee13098..89e7ba125 100644 --- a/src/script/api/ai/ai_airport.hpp.sq +++ b/src/script/api/ai/ai_airport.hpp.sq @@ -52,6 +52,7 @@ void SQAIAirport_Register(Squirrel *engine) SQAIAirport.DefSQStaticMethod(engine, &ScriptAirport::GetNoiseLevelIncrease, "GetNoiseLevelIncrease", 3, ".ii"); SQAIAirport.DefSQStaticMethod(engine, &ScriptAirport::GetNearestTown, "GetNearestTown", 3, ".ii"); SQAIAirport.DefSQStaticMethod(engine, &ScriptAirport::GetMaintenanceCostFactor, "GetMaintenanceCostFactor", 2, ".i"); + SQAIAirport.DefSQStaticMethod(engine, &ScriptAirport::GetMonthlyMaintenanceCost, "GetMonthlyMaintenanceCost", 2, ".i"); SQAIAirport.PostRegister(engine); } diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp index 25e8b3e37..ecb015ed4 100644 --- a/src/script/api/ai_changelog.hpp +++ b/src/script/api/ai_changelog.hpp @@ -18,6 +18,8 @@ * \b 1.9.0 * * 1.9.0 is not yet released. The following changes are not set in stone yet. + * API additions: + * \li AIAirport::GetMonthlyMaintenanceCost * * \b 1.8.0 * diff --git a/src/script/api/game/game_airport.hpp.sq b/src/script/api/game/game_airport.hpp.sq index cfa99ba37..d8f3a2a64 100644 --- a/src/script/api/game/game_airport.hpp.sq +++ b/src/script/api/game/game_airport.hpp.sq @@ -52,6 +52,7 @@ void SQGSAirport_Register(Squirrel *engine) SQGSAirport.DefSQStaticMethod(engine, &ScriptAirport::GetNoiseLevelIncrease, "GetNoiseLevelIncrease", 3, ".ii"); SQGSAirport.DefSQStaticMethod(engine, &ScriptAirport::GetNearestTown, "GetNearestTown", 3, ".ii"); SQGSAirport.DefSQStaticMethod(engine, &ScriptAirport::GetMaintenanceCostFactor, "GetMaintenanceCostFactor", 2, ".i"); + SQGSAirport.DefSQStaticMethod(engine, &ScriptAirport::GetMonthlyMaintenanceCost, "GetMonthlyMaintenanceCost", 2, ".i"); SQGSAirport.PostRegister(engine); } diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index 390c1f31f..7aad75b44 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -19,6 +19,7 @@ * * 1.9.0 is not yet released. The following changes are not set in stone yet. * API additions: + * \li GSAirport::GetMonthlyMaintenanceCost * \li GSClient * \li GSClientList * \li GSClientList_Company diff --git a/src/script/api/script_airport.cpp b/src/script/api/script_airport.cpp index edb912609..8e19d257d 100644 --- a/src/script/api/script_airport.cpp +++ b/src/script/api/script_airport.cpp @@ -163,3 +163,10 @@ return AirportSpec::Get(type)->maintenance_cost; } + +/* static */ Money ScriptAirport::GetMonthlyMaintenanceCost(AirportType type) +{ + if (!IsAirportInformationAvailable(type)) return -1; + + return (int64)GetMaintenanceCostFactor(type) * _price[PR_INFRASTRUCTURE_AIRPORT] >> 3; +} diff --git a/src/script/api/script_airport.hpp b/src/script/api/script_airport.hpp index e4c0a217d..6073a2bdd 100644 --- a/src/script/api/script_airport.hpp +++ b/src/script/api/script_airport.hpp @@ -201,6 +201,14 @@ public: * @return Maintenance cost factor of the airport type. */ static uint16 GetMaintenanceCostFactor(AirportType type); + + /** + * Get the monthly maintenance cost of an airport type. + * @param type The airport type to get the monthly maintenance cost of. + * @pre IsAirportInformationAvailable(type) + * @return Monthly maintenance cost of the airport type. + */ + static Money GetMonthlyMaintenanceCost(AirportType type); }; #endif /* SCRIPT_AIRPORT_HPP */ |