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