Changeset - r28760:a88826ce6a33
[Not reviewed]
master
0 6 0
SamuXarick - 10 months ago 2024-02-14 20:38:32
43006711+SamuXarick@users.noreply.github.com
Add: [Script] GetAirportNumHelipads (#12085)

Adds a function for Scripts to get the number of helipads of an airport type.
6 files changed with 32 insertions and 3 deletions:
0 comments (0 inline, 0 general)
regression/regression/main.nut
Show inline comments
 
@@ -217,12 +217,13 @@ function Regression::Airport()
 
	for (local i = -1; i < 10; i++) {
 
		print("  IsAirportInformationAvailable(" + i + "): " + AIAirport.IsAirportInformationAvailable(i));
 
		print("  IsValidAirportType(" + i + "):            " + AIAirport.IsValidAirportType(i));
 
		print("  GetAirportWidth(" + i + "):               " + AIAirport.GetAirportWidth(i));
 
		print("  GetAirportHeight(" + i + "):              " + AIAirport.GetAirportHeight(i));
 
		print("  GetAirportCoverageRadius(" + i + "):      " + AIAirport.GetAirportCoverageRadius(i));
 
		print("  GetAirportNumHelipads(" + i + "):         " + AIAirport.GetAirportNumHelipads(i));
 
	}
 

	
 
	print("  GetBankBalance():     " + AICompany.GetBankBalance(AICompany.COMPANY_SELF));
 
	print("  GetPrice():           " + AIAirport.GetPrice(0));
 
	print("  BuildAirport():       " + AIAirport.BuildAirport(32116, 0, AIStation.STATION_JOIN_ADJACENT));
 
	print("  IsHangarTile():       " + AIAirport.IsHangarTile(32116));
regression/regression/result.txt
Show inline comments
 
@@ -802,62 +802,73 @@ ERROR: IsEnd() is invalid as Begin() is 
 
  GetAirportType():     254
 
  IsAirportInformationAvailable(-1): false
 
  IsValidAirportType(-1):            false
 
  GetAirportWidth(-1):               -1
 
  GetAirportHeight(-1):              -1
 
  GetAirportCoverageRadius(-1):      -1
 
  GetAirportNumHelipads(-1):         -1
 
  IsAirportInformationAvailable(0): true
 
  IsValidAirportType(0):            true
 
  GetAirportWidth(0):               4
 
  GetAirportHeight(0):              3
 
  GetAirportCoverageRadius(0):      4
 
  GetAirportNumHelipads(0):         0
 
  IsAirportInformationAvailable(1): true
 
  IsValidAirportType(1):            false
 
  GetAirportWidth(1):               6
 
  GetAirportHeight(1):              6
 
  GetAirportCoverageRadius(1):      5
 
  GetAirportNumHelipads(1):         0
 
  IsAirportInformationAvailable(2): true
 
  IsValidAirportType(2):            false
 
  GetAirportWidth(2):               1
 
  GetAirportHeight(2):              1
 
  GetAirportCoverageRadius(2):      4
 
  GetAirportNumHelipads(2):         1
 
  IsAirportInformationAvailable(3): true
 
  IsValidAirportType(3):            false
 
  GetAirportWidth(3):               6
 
  GetAirportHeight(3):              6
 
  GetAirportCoverageRadius(3):      6
 
  GetAirportNumHelipads(3):         0
 
  IsAirportInformationAvailable(4): true
 
  IsValidAirportType(4):            false
 
  GetAirportWidth(4):               7
 
  GetAirportHeight(4):              7
 
  GetAirportCoverageRadius(4):      8
 
  GetAirportNumHelipads(4):         2
 
  IsAirportInformationAvailable(5): true
 
  IsValidAirportType(5):            false
 
  GetAirportWidth(5):               5
 
  GetAirportHeight(5):              4
 
  GetAirportCoverageRadius(5):      4
 
  GetAirportNumHelipads(5):         2
 
  IsAirportInformationAvailable(6): true
 
  IsValidAirportType(6):            false
 
  GetAirportWidth(6):               2
 
  GetAirportHeight(6):              2
 
  GetAirportCoverageRadius(6):      4
 
  GetAirportNumHelipads(6):         1
 
  IsAirportInformationAvailable(7): true
 
  IsValidAirportType(7):            false
 
  GetAirportWidth(7):               9
 
  GetAirportHeight(7):              11
 
  GetAirportCoverageRadius(7):      10
 
  GetAirportNumHelipads(7):         2
 
  IsAirportInformationAvailable(8): true
 
  IsValidAirportType(8):            false
 
  GetAirportWidth(8):               4
 
  GetAirportHeight(8):              2
 
  GetAirportCoverageRadius(8):      4
 
  GetAirportNumHelipads(8):         3
 
  IsAirportInformationAvailable(9): false
 
  IsValidAirportType(9):            false
 
  GetAirportWidth(9):               -1
 
  GetAirportHeight(9):              -1
 
  GetAirportCoverageRadius(9):      -1
 
  GetAirportNumHelipads(9):         -1
 
  GetBankBalance():     1999999790
 
  GetPrice():           5400
 
  BuildAirport():       true
 
  IsHangarTile():       false
 
  IsAirportTile():      true
 
  GetAirportType():     0
 
@@ -9734,23 +9745,23 @@ ERROR: IsEnd() is invalid as Begin() is 
 
  -1          >  2147483647:   false
 
  -2147483648 >  2147483647:   false
 
   13725      > -2147483648:   true
 
--Valuate() with excessive CPU usage--
 
Your script made an error: excessive CPU usage in valuator function
 

	
 
*FUNCTION [unknown()] regression/main.nut line [2050]
 
*FUNCTION [unknown()] regression/main.nut line [2051]
 
*FUNCTION [Valuate()] NATIVE line [-1]
 
*FUNCTION [Start()] regression/main.nut line [2051]
 
*FUNCTION [Start()] regression/main.nut line [2052]
 

	
 
[id] 0
 
[this] TABLE
 
[Infinite] CLOSURE
 
[list] INSTANCE
 
[this] INSTANCE
 
Your script made an error: excessive CPU usage in valuator function
 

	
 
*FUNCTION [Start()] regression/main.nut line [2051]
 
*FUNCTION [Start()] regression/main.nut line [2052]
 

	
 
[Infinite] CLOSURE
 
[list] INSTANCE
 
[this] INSTANCE
 
ERROR: The script died unexpectedly.
src/script/api/ai_changelog.hpp
Show inline comments
 
@@ -19,12 +19,13 @@
 
 *
 
 * API additions:
 
 * \li AITimeMode
 
 * \li AITown::ROAD_LAYOUT_RANDOM
 
 * \li AIVehicle::IsPrimaryVehicle
 
 * \li AITileList_StationCoverage
 
 * \li AIAirport::GetAirportNumHelipads
 
 *
 
 * API removals:
 
 * \li AIError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore.
 
 * \li AIInfo::CONFIG_RANDOM, no longer used.
 
 *
 
 * Other changes:
src/script/api/game_changelog.hpp
Show inline comments
 
@@ -85,12 +85,13 @@
 
 * \li GSIndustry::SetProductionLevel
 
 * \li GSStoryPage::IsValidStoryPageElementType
 
 * \li GSStoryPage::IsValidStoryPageButtonColour
 
 * \li GSStoryPage::IsValidStoryPageButtonFlags
 
 * \li GSStoryPage::IsValidStoryPageButtonCursor
 
 * \li GSTileList_StationCoverage
 
 * \li GSAirport::GetAirportNumHelipads
 
 *
 
 * API removals:
 
 * \li GSError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore.
 
 * \li GSInfo::CONFIG_RANDOM, no longer used.
 
 *
 
 * Other changes:
src/script/api/script_airport.cpp
Show inline comments
 
@@ -167,6 +167,13 @@
 
/* static */ Money ScriptAirport::GetMonthlyMaintenanceCost(AirportType type)
 
{
 
	if (!IsAirportInformationAvailable(type)) return -1;
 

	
 
	return (int64_t)GetMaintenanceCostFactor(type) * _price[PR_INFRASTRUCTURE_AIRPORT] >> 3;
 
}
 

	
 
/* static */ SQInteger ScriptAirport::GetAirportNumHelipads(AirportType type)
 
{
 
	if (!IsAirportInformationAvailable(type)) return -1;
 

	
 
	return ::AirportSpec::Get(type)->fsm->num_helipads;
 
}
src/script/api/script_airport.hpp
Show inline comments
 
@@ -204,9 +204,17 @@ public:
 
	 * 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);
 

	
 
	/**
 
	 * Get the number of helipads of this airport type.
 
	 * @param type The airport type.
 
	 * @pre IsAirportInformationAvailable(type)
 
	 * @return Number of helipads of this type of airport. When 0 helicopters will go to normal terminals.
 
	 */
 
	static SQInteger GetAirportNumHelipads(AirportType type);
 
};
 

	
 
#endif /* SCRIPT_AIRPORT_HPP */
0 comments (0 inline, 0 general)