truelight@9617: /* $Id$ */ truelight@9617: truelight@9617: /** @file ai_tile.cpp handles the functions of the AITile class */ truelight@9617: truelight@9617: #include "ai_tile.hpp" rubidium@9723: #include "../../tile_map.h" rubidium@9723: #include "../../map_func.h" truelight@9617: #include "../../variables.h" truelight@9617: #include "../../station.h" rubidium@9723: #include "../../command_type.h" rubidium@9724: #include "../../settings_type.h" truelight@9617: truebrain@9737: /* static */ bool AITile::IsBuildable(TileIndex tile) truelight@9617: { truelight@9617: /* Outside of the map */ rubidium@9620: if (tile >= ::MapSize()) return false; truelight@9617: truelight@9617: switch (::GetTileType(tile)) { glx@9728: default: return true; truelight@9617: case MP_VOID: truelight@9617: case MP_HOUSE: truelight@9617: case MP_STATION: truelight@9617: case MP_INDUSTRY: truelight@9697: case MP_UNMOVABLE: glx@9728: case MP_WATER: return false; truelight@9617: } truelight@9617: } truelight@9617: truebrain@9737: /* static */ bool AITile::IsWater(TileIndex tile) truelight@9698: { truelight@9698: /* Outside of the map */ truelight@9698: if (tile >= ::MapSize()) return false; truelight@9698: truelight@9698: return ::GetTileType(tile) == MP_WATER; truelight@9698: } truelight@9698: truebrain@9737: /* static */ int32 AITile::GetSlope(TileIndex tile) truelight@9617: { truelight@9617: /* Outside of the map */ rubidium@9620: if (tile >= ::MapSize()) return 0; truelight@9617: truelight@9700: return ::GetTileSlope(tile, NULL); truelight@9700: } truelight@9700: truebrain@9737: /* static */ int32 AITile::GetHeight(TileIndex tile) truelight@9700: { truelight@9700: /* Outside of the map */ truelight@9700: if (tile >= ::MapSize()) return 0; truelight@9700: truelight@9700: return ::TileHeight(tile); truelight@9617: } truelight@9617: truebrain@9737: /* static */ int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius) truelight@9617: { truelight@9617: /* Outside of the map */ glx@9728: if (tile >= ::MapSize()) return 0; truelight@9617: truelight@9617: AcceptedCargo accepts; truebrain@9736: ::GetAcceptanceAroundTiles(accepts, tile, width, height, _patches.modified_catchment ? radius : (uint)CA_UNMODIFIED); truelight@9617: return accepts[cargo_type]; truelight@9617: } truelight@9708: truebrain@9737: /* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius) glx@9729: { glx@9729: /* Outside of the map */ glx@9729: if (tile >= ::MapSize()) return 0; glx@9729: glx@9729: AcceptedCargo produced; truebrain@9736: ::GetProductionAroundTiles(produced, tile, width, height, _patches.modified_catchment ? radius : (uint)CA_UNMODIFIED); glx@9729: return produced[cargo_type]; glx@9729: } glx@9729: truebrain@9737: /* static */ bool AITile::RaiseTile(TileIndex tile, int32 slope) truelight@9708: { truelight@9708: /* Outside of the map */ glx@9728: if (tile >= ::MapSize()) return false; truelight@9708: truebrain@9737: return AIObject::DoCommand(tile, slope, 1, CMD_TERRAFORM_LAND); truelight@9708: } truelight@9708: truebrain@9737: /* static */ bool AITile::LowerTile(TileIndex tile, int32 slope) truelight@9708: { truelight@9708: /* Outside of the map */ glx@9728: if (tile >= ::MapSize()) return false; truelight@9708: truebrain@9737: return AIObject::DoCommand(tile, slope, 0, CMD_TERRAFORM_LAND); truelight@9708: }