Changeset - r11853:cdcc1e5aa2fb
[Not reviewed]
master
0 5 0
yexo - 16 years ago 2009-05-07 21:30:18
yexo@openttd.org
(svn r16252) -Add [NoAI]: AIAirport::GetPrice, returning the building cost of an airport
5 files changed with 19 insertions and 0 deletions:
0 comments (0 inline, 0 general)
bin/ai/regression/regression.nut
Show inline comments
 
@@ -217,12 +217,13 @@ function Regression::Airport()
 
		print("  GetAirportWidth(" + i + "):          " + AIAirport.GetAirportWidth(i));
 
		print("  GetAirportHeight(" + i + "):         " + AIAirport.GetAirportHeight(i));
 
		print("  GetAirportCoverageRadius(" + i + "): " + AIAirport.GetAirportCoverageRadius(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));
 
	print("  IsAirportTile():      " + AIAirport.IsAirportTile(32116));
 
	print("  GetAirportType():     " + AIAirport.GetAirportType(32119));
 
	print("  GetHangarOfAirport(): " + AIAirport.GetHangarOfAirport(32116));
 
	print("  IsHangarTile():       " + AIAirport.IsHangarTile(32119));
bin/ai/regression/regression.txt
Show inline comments
 
@@ -617,12 +617,13 @@
 
  GetAirportCoverageRadius(8): -1
 
  IsValidAirportType(9):       false
 
  GetAirportWidth(9):          -1
 
  GetAirportHeight(9):         -1
 
  GetAirportCoverageRadius(9): -1
 
  GetBankBalance():     100000
 
  GetPrice():           84
 
  BuildAirport():       true
 
  IsHangarTile():       false
 
  IsAirportTile():      true
 
  GetAirportType():     0
 
  GetHangarOfAirport(): 32119
 
  IsHangarTile():       true
src/ai/api/ai_airport.cpp
Show inline comments
 
@@ -5,18 +5,27 @@
 
#include "ai_airport.hpp"
 
#include "ai_station.hpp"
 
#include "../../station_map.h"
 
#include "../../company_func.h"
 
#include "../../command_type.h"
 
#include "../../town.h"
 
#include "../../economy_func.h"
 

	
 
/* static */ bool AIAirport::IsValidAirportType(AirportType type)
 
{
 
	return type >= AT_SMALL && type <= AT_HELISTATION && HasBit(::GetValidAirports(), type);
 
}
 

	
 
/* static */ Money AIAirport::GetPrice(AirportType type)
 
{
 
	if (!IsValidAirportType(type)) return -1;
 

	
 
	const AirportFTAClass *afc = ::GetAirport(type);
 
	return _price.build_airport * afc->size_x * afc->size_y;
 
}
 

	
 
/* static */ bool AIAirport::IsHangarTile(TileIndex tile)
 
{
 
	if (!::IsValidTile(tile)) return false;
 

	
 
	return ::IsTileType(tile, MP_STATION) && ::IsHangar(tile);
 
}
src/ai/api/ai_airport.hpp
Show inline comments
 
@@ -51,12 +51,19 @@ public:
 
	 * @param type The AirportType to check.
 
	 * @return True if and only if the AirportType is valid and available.
 
	 */
 
	static bool IsValidAirportType(AirportType type);
 

	
 
	/**
 
	 * Get the cost to build this AirportType.
 
	 * @param type The AirportType to check.
 
	 * @return The cost of building this AirportType.
 
	 */
 
	static Money GetPrice(AirportType type);
 

	
 
	/**
 
	 * Checks whether the given tile is actually a tile with a hangar.
 
	 * @param tile The tile to check.
 
	 * @pre AIMap::IsValidTile(tile).
 
	 * @return True if and only if the tile has a hangar.
 
	 */
 
	static bool IsHangarTile(TileIndex tile);
src/ai/api/ai_airport.hpp.sq
Show inline comments
 
@@ -36,12 +36,13 @@ void SQAIAirport_Register(Squirrel *engi
 
	SQAIAirport.DefSQConst(engine, AIAirport::PT_HELICOPTER,    "PT_HELICOPTER");
 
	SQAIAirport.DefSQConst(engine, AIAirport::PT_SMALL_PLANE,   "PT_SMALL_PLANE");
 
	SQAIAirport.DefSQConst(engine, AIAirport::PT_BIG_PLANE,     "PT_BIG_PLANE");
 
	SQAIAirport.DefSQConst(engine, AIAirport::PT_INVALID,       "PT_INVALID");
 

	
 
	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::IsValidAirportType,       "IsValidAirportType",       2, ".i");
 
	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetPrice,                 "GetPrice",                 2, ".i");
 
	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::IsHangarTile,             "IsHangarTile",             2, ".i");
 
	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::IsAirportTile,            "IsAirportTile",            2, ".i");
 
	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetAirportWidth,          "GetAirportWidth",          2, ".i");
 
	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetAirportHeight,         "GetAirportHeight",         2, ".i");
 
	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetAirportCoverageRadius, "GetAirportCoverageRadius", 2, ".i");
 
	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetNumHangars,            "GetNumHangars",            2, ".i");
0 comments (0 inline, 0 general)