# ai_tile.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_tile.hpp 15190 2009-01-21 02:31:55Z Yexo $ */
    00002
    00005 #ifndef AI_TILE_HPP
    00006 #define AI_TILE_HPP
    00007
    00008 #include "ai_abstractlist.hpp"
    00009 #include "ai_error.hpp"
    00010 #include "ai_company.hpp"
    00011
    00015 class AITile : public AIObject {
    00016 public:
    00017   static const char *GetClassName() { return "AITile"; }
    00018
    00022   enum ErrorMessages {
    00023
    00025     ERR_TILE_BASE = AIError::ERR_CAT_TILE << AIError::ERR_CAT_BIT_SIZE,
    00026
    00028     ERR_TILE_TOO_HIGH,                     // [STR_1003_ALREADY_AT_SEA_LEVEL]
    00029
    00031     ERR_TILE_TOO_LOW,                      // [STR_1003_ALREADY_AT_SEA_LEVEL]
    00032   };
    00033
    00041   enum Slope {
    00042     /* Values are important, as they represent the internal state of the game. */
    00043     SLOPE_FLAT     = 0x00,
    00044     SLOPE_W        = 0x01,
    00045     SLOPE_S        = 0x02,
    00046     SLOPE_E        = 0x04,
    00047     SLOPE_N        = 0x08,
    00048     SLOPE_STEEP    = 0x10,
    00049     SLOPE_NW       = SLOPE_N | SLOPE_W,
    00050     SLOPE_SW       = SLOPE_S | SLOPE_W,
    00051     SLOPE_SE       = SLOPE_S | SLOPE_E,
    00052     SLOPE_NE       = SLOPE_N | SLOPE_E,
    00053     SLOPE_EW       = SLOPE_E | SLOPE_W,
    00054     SLOPE_NS       = SLOPE_N | SLOPE_S,
    00055     SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W,
    00056     SLOPE_NWS      = SLOPE_N | SLOPE_W | SLOPE_S,
    00057     SLOPE_WSE      = SLOPE_W | SLOPE_S | SLOPE_E,
    00058     SLOPE_SEN      = SLOPE_S | SLOPE_E | SLOPE_N,
    00059     SLOPE_ENW      = SLOPE_E | SLOPE_N | SLOPE_W,
    00060     SLOPE_STEEP_W  = SLOPE_STEEP | SLOPE_NWS,
    00061     SLOPE_STEEP_S  = SLOPE_STEEP | SLOPE_WSE,
    00062     SLOPE_STEEP_E  = SLOPE_STEEP | SLOPE_SEN,
    00063     SLOPE_STEEP_N  = SLOPE_STEEP | SLOPE_ENW,
    00064
    00065     SLOPE_INVALID  = 0xFF,
    00066   };
    00067
    00071   enum TransportType {
    00072     /* Values are important, as they represent the internal state of the game. */
    00073     TRANSPORT_RAIL    =  0,
    00074     TRANSPORT_ROAD    =  1,
    00075     TRANSPORT_WATER   =  2,
    00076     TRANSPORT_AIR     =  3,
    00077
    00078     TRANSPORT_INVALID = -1,
    00079   };
    00080
    00092   static bool IsBuildable(TileIndex tile);
    00093
    00103   static bool IsBuildableRectangle(TileIndex tile, uint width, uint height);
    00104
    00111   static bool IsWaterTile(TileIndex tile);
    00112
    00120   static bool IsCoastTile(TileIndex tile);
    00121
    00128   static bool IsStationTile(TileIndex tile);
    00129
    00136   static bool IsSteepSlope(Slope slope);
    00137
    00144   static bool IsHalftileSlope(Slope slope);
    00145
    00152   static bool HasTreeOnTile(TileIndex tile);
    00153
    00160   static bool IsFarmTile(TileIndex tile);
    00161
    00168   static bool IsRockTile(TileIndex tile);
    00169
    00176   static bool IsRoughTile(TileIndex tile);
    00177
    00184   static bool IsSnowTile(TileIndex tile);
    00185
    00192   static bool IsDesertTile(TileIndex tile);
    00193
    00200   static Slope GetSlope(TileIndex tile);
    00201
    00211   static Slope GetComplementSlope(Slope slope);
    00212
    00219   static int32 GetHeight(TileIndex tile);
    00220
    00228   static AICompany::CompanyID GetOwner(TileIndex tile);
    00229
    00242   static bool HasTransportType(TileIndex tile, TransportType transport_type);
    00243
    00256   static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius);
    00257
    00271   static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius);
    00272
    00279   static int32 GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to);
    00280
    00287   static int32 GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to);
    00288
    00300   static bool RaiseTile(TileIndex tile, int32 slope);
    00301
    00313   static bool LowerTile(TileIndex tile, int32 slope);
    00314
    00331   static bool LevelTiles(TileIndex start_tile, TileIndex end_tile);
    00332
    00340   static bool DemolishTile(TileIndex tile);
    00341
    00348   static bool PlantTree(TileIndex tile);
    00349
    00360   static bool PlantTreeRectangle(TileIndex tile, uint width, uint height);
    00361
    00369   static bool IsWithinTownInfluence(TileIndex tile, TownID town_id);
    00370
    00377   static TownID GetClosestTown(TileIndex tile);
    00378 };
    00379
    00380 #endif /* AI_TILE_HPP */