truelight@9691: /* $Id$ */ truelight@9691: truelight@9691: #include "ai_marine.hpp" truelight@9691: #include "../../command.h" truelight@9691: #include "../../variables.h" truelight@9691: #include "../../station_map.h" truelight@9691: #include "../../water_map.h" truelight@9691: truelight@9691: truelight@9691: /* static */ bool AIMarine::IsWaterDepotTile(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9691: return ::IsTileType(tile, MP_WATER) && ::GetWaterTileType(tile) == WATER_TILE_DEPOT; truelight@9691: } truelight@9691: truelight@9691: /* static */ bool AIMarine::IsDockTile(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9691: return ::IsTileType(tile, MP_STATION) && ::IsDock(tile); truelight@9691: } truelight@9691: truelight@9691: /* static */ bool AIMarine::IsBuoyTile(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9691: return ::IsTileType(tile, MP_STATION) && ::IsBuoy(tile); truelight@9691: } truelight@9691: truelight@9691: /* static */ bool AIMarine::IsLockTile(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9691: return ::IsTileType(tile, MP_WATER) && ::GetWaterTileType(tile) == WATER_TILE_LOCK; truelight@9691: } truelight@9691: truelight@9691: /* static */ bool AIMarine::IsCanalTile(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9691: return ::IsTileType(tile, MP_WATER) && ::IsCanal(tile); truelight@9691: } truelight@9691: truelight@9691: bool AIMarine::BuildWaterDepot(TileIndex tile, bool vertical) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9695: return this->DoCommand(tile, vertical, 0, CMD_BUILD_SHIP_DEPOT, false); truelight@9691: } truelight@9691: truelight@9691: bool AIMarine::BuildDock(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9695: return this->DoCommand(tile, 1, 0, CMD_BUILD_DOCK, false); truelight@9691: } truelight@9691: truelight@9691: bool AIMarine::BuildBuoy(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9695: return this->DoCommand(tile, 0, 0, CMD_BUILD_BUOY, false); truelight@9691: } truelight@9691: truelight@9691: bool AIMarine::BuildLock(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9695: return this->DoCommand(tile, 0, 0, CMD_BUILD_LOCK, false); truelight@9691: } truelight@9691: truelight@9691: bool AIMarine::BuildCanal(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9695: return this->DoCommand(tile, tile, 0, CMD_BUILD_CANAL, false); truelight@9691: } truelight@9691: truelight@9691: bool AIMarine::RemoveWaterDepot(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9691: /* Not a water depot tile */ truelight@9691: if (!IsWaterDepotTile(tile)) return false; truelight@9691: truelight@9695: return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); truelight@9691: } truelight@9691: truelight@9691: bool AIMarine::RemoveDock(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9691: /* Not a dock tile */ truelight@9691: if (!IsDockTile(tile)) return false; truelight@9691: truelight@9695: return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); truelight@9691: } truelight@9691: truelight@9691: bool AIMarine::RemoveBuoy(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9691: /* Not a buoy tile */ truelight@9691: if (!IsBuoyTile(tile)) return false; truelight@9691: truelight@9695: return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); truelight@9691: } truelight@9691: truelight@9691: bool AIMarine::RemoveLock(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9691: /* Not a lock tile */ truelight@9691: if (!IsLockTile(tile)) return false; truelight@9691: truelight@9695: return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); truelight@9691: } truelight@9691: truelight@9691: bool AIMarine::RemoveCanal(TileIndex tile) truelight@9691: { truelight@9691: /* Outside of the map */ truelight@9691: if (tile >= ::MapSize()) return false; truelight@9691: truelight@9691: /* Not a canal tile */ truelight@9691: if (!IsCanalTile(tile)) return false; truelight@9691: truelight@9695: return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); truelight@9691: }