# ai_tile.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_tile.hpp 17080 2009-08-05 23:57:41Z rubidium $ */
    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
    00034     ERR_AREA_ALREADY_FLAT,                 // [STR_ALREADY_LEVELLED]
    00035
    00037     ERR_EXCAVATION_WOULD_DAMAGE,           // [STR_1002_EXCAVATION_WOULD_DAMAGE]
    00038   };
    00039
    00043   enum Corner {
    00044     CORNER_W       = 0,
    00045     CORNER_S       = 1,
    00046     CORNER_E       = 2,
    00047     CORNER_N       = 3,
    00048
    00049     CORNER_INVALID = 0xFF,
    00050   };
    00051
    00059   enum Slope {
    00060     /* Values are important, as they represent the internal state of the game. */
    00061     SLOPE_FLAT     = 0x00,
    00062     SLOPE_W        = 1 << CORNER_W,
    00063     SLOPE_S        = 1 << CORNER_S,
    00064     SLOPE_E        = 1 << CORNER_E,
    00065     SLOPE_N        = 1 << CORNER_N,
    00066     SLOPE_STEEP    = 0x10,
    00067     SLOPE_NW       = SLOPE_N | SLOPE_W,
    00068     SLOPE_SW       = SLOPE_S | SLOPE_W,
    00069     SLOPE_SE       = SLOPE_S | SLOPE_E,
    00070     SLOPE_NE       = SLOPE_N | SLOPE_E,
    00071     SLOPE_EW       = SLOPE_E | SLOPE_W,
    00072     SLOPE_NS       = SLOPE_N | SLOPE_S,
    00073     SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W,
    00074     SLOPE_NWS      = SLOPE_N | SLOPE_W | SLOPE_S,
    00075     SLOPE_WSE      = SLOPE_W | SLOPE_S | SLOPE_E,
    00076     SLOPE_SEN      = SLOPE_S | SLOPE_E | SLOPE_N,
    00077     SLOPE_ENW      = SLOPE_E | SLOPE_N | SLOPE_W,
    00078     SLOPE_STEEP_W  = SLOPE_STEEP | SLOPE_NWS,
    00079     SLOPE_STEEP_S  = SLOPE_STEEP | SLOPE_WSE,
    00080     SLOPE_STEEP_E  = SLOPE_STEEP | SLOPE_SEN,
    00081     SLOPE_STEEP_N  = SLOPE_STEEP | SLOPE_ENW,
    00082
    00083     SLOPE_INVALID  = 0xFFFF,
    00084   };
    00085
    00089   enum TransportType {
    00090     /* Values are important, as they represent the internal state of the game. */
    00091     TRANSPORT_RAIL    =  0,
    00092     TRANSPORT_ROAD    =  1,
    00093     TRANSPORT_WATER   =  2,
    00094     TRANSPORT_AIR     =  3,
    00095
    00096     TRANSPORT_INVALID = -1,
    00097   };
    00098
    00110   static bool IsBuildable(TileIndex tile);
    00111
    00121   static bool IsBuildableRectangle(TileIndex tile, uint width, uint height);
    00122
    00129   static bool IsWaterTile(TileIndex tile);
    00130
    00138   static bool IsCoastTile(TileIndex tile);
    00139
    00146   static bool IsStationTile(TileIndex tile);
    00147
    00155   static bool IsSteepSlope(Slope slope);
    00156
    00165   static bool IsHalftileSlope(Slope slope);
    00166
    00173   static bool HasTreeOnTile(TileIndex tile);
    00174
    00181   static bool IsFarmTile(TileIndex tile);
    00182
    00189   static bool IsRockTile(TileIndex tile);
    00190
    00197   static bool IsRoughTile(TileIndex tile);
    00198
    00205   static bool IsSnowTile(TileIndex tile);
    00206
    00213   static bool IsDesertTile(TileIndex tile);
    00214
    00222   static Slope GetSlope(TileIndex tile);
    00223
    00233   static Slope GetComplementSlope(Slope slope);
    00234
    00243   static int32 GetHeight(TileIndex tile);
    00244
    00252   static int32 GetMinHeight(TileIndex tile);
    00253
    00261   static int32 GetMaxHeight(TileIndex tile);
    00262
    00271   static int32 GetCornerHeight(TileIndex tile, Corner corner);
    00272
    00280   static AICompany::CompanyID GetOwner(TileIndex tile);
    00281
    00294   static bool HasTransportType(TileIndex tile, TransportType transport_type);
    00295
    00311   static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
    00312
    00329   static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
    00330
    00337   static int32 GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to);
    00338
    00345   static int32 GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to);
    00346
    00361   static bool RaiseTile(TileIndex tile, int32 slope);
    00362
    00377   static bool LowerTile(TileIndex tile, int32 slope);
    00378
    00395   static bool LevelTiles(TileIndex start_tile, TileIndex end_tile);
    00396
    00404   static bool DemolishTile(TileIndex tile);
    00405
    00412   static bool PlantTree(TileIndex tile);
    00413
    00424   static bool PlantTreeRectangle(TileIndex tile, uint width, uint height);
    00425
    00433   static bool IsWithinTownInfluence(TileIndex tile, TownID town_id);
    00434
    00441   static TownID GetClosestTown(TileIndex tile);
    00442 };
    00443
    00444 #endif /* AI_TILE_HPP */