src/ai/api/ai_airport.cpp
branchnoai
changeset 9670 820b77e19bb3
parent 9654 b836eb5c521f
child 9722 ebf0ece7d8f6
equal deleted inserted replaced
9669:366771e15a2c 9670:820b77e19bb3
     1 /* $Id$ */
     1 /* $Id$ */
     2 
     2 
     3 #include "ai_airport.hpp"
     3 #include "ai_airport.hpp"
     4 #include "../../command.h"
     4 #include "../../command.h"
       
     5 #include "../../variables.h"
     5 #include "../../station_map.h"
     6 #include "../../station_map.h"
     6 
     7 
     7 
     8 
     8 bool AIAirport::IsHangarTile(TileIndex tile)
     9 /* static */ bool AIAirport::IsHangarTile(TileIndex tile)
     9 {
    10 {
    10 	/* Outside of the map */
    11 	/* Outside of the map */
    11 	if (tile >= ::MapSize()) return false;
    12 	if (tile >= ::MapSize()) return false;
    12 
    13 
    13 	return ::IsTileType(tile, MP_STATION) && ::IsHangar(tile);
    14 	return ::IsTileType(tile, MP_STATION) && ::IsHangar(tile);
    14 }
    15 }
    15 
    16 
    16 bool AIAirport::IsAirportTile(TileIndex tile)
    17 /* static */ bool AIAirport::IsAirportTile(TileIndex tile)
    17 {
    18 {
    18 	/* Outside of the map */
    19 	/* Outside of the map */
    19 	if (tile >= ::MapSize()) return false;
    20 	if (tile >= ::MapSize()) return false;
    20 
    21 
    21 	return ::IsTileType(tile, MP_STATION) && ::IsAirport(tile);
    22 	return ::IsTileType(tile, MP_STATION) && ::IsAirport(tile);
    22 }
    23 }
    23 
    24 
    24 bool AIAirport::AiportAvailable(AirportType type)
    25 /* static */ bool AIAirport::AiportAvailable(AirportType type)
    25 {
    26 {
    26 	/* Small airport is always available */
    27 	if (type > AT_HELISTATION) return 0;
    27 	if (type == AT_SMALL) return true;
       
    28 	/* The rest has to be looked up */
       
    29 	return HASBIT(::GetValidAirports(), type);
    28 	return HASBIT(::GetValidAirports(), type);
       
    29 }
       
    30 
       
    31 /* static */ int32 AIAirport::GetAirportWidth(AirportType type)
       
    32 {
       
    33 	if (type > AT_HELISTATION) return 0;
       
    34 	return GetAirport(type)->size_x;
       
    35 }
       
    36 
       
    37 /* static */ int32 AIAirport::GetAirportHeight(AirportType type)
       
    38 {
       
    39 	if (type > AT_HELISTATION) return 0;
       
    40 	return GetAirport(type)->size_y;
       
    41 }
       
    42 
       
    43 /* static */ int32 AIAirport::GetAirportCoverageRadius(AirportType type)
       
    44 {
       
    45 	if (type > AT_HELISTATION) return 0;
       
    46 	return _patches.modified_catchment ? GetAirport(type)->catchment : 4;
    30 }
    47 }
    31 
    48 
    32 bool AIAirport::BuildAirport(TileIndex tile, AirportType type)
    49 bool AIAirport::BuildAirport(TileIndex tile, AirportType type)
    33 {
    50 {
    34 	/* Outside of the map */
    51 	/* Outside of the map */
    35 	if (tile >= ::MapSize()) return false;
    52 	if (tile >= ::MapSize()) return false;
       
    53 	if (type > AT_HELISTATION) return 0;
    36 
    54 
    37 	return this->DoCommand(tile, type, 0, CMD_BUILD_AIRPORT);
    55 	return this->DoCommand(tile, type, 0, CMD_BUILD_AIRPORT);
    38 }
    56 }
    39 
    57 
    40 bool AIAirport::RemoveAirport(TileIndex tile)
    58 bool AIAirport::RemoveAirport(TileIndex tile)