# ai_tile.hpp

Go to the documentation of this file.

    00001 /* $Id$ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef AI_TILE_HPP
    00013 #define AI_TILE_HPP
    00014
    00015 #include "ai_abstractlist.hpp"
    00016 #include "ai_error.hpp"
    00017 #include "ai_company.hpp"
    00018
    00022 class AITile : public AIObject {
    00023 public:
    00024   static const char *GetClassName() { return "AITile"; }
    00025
    00029   enum ErrorMessages {
    00030
    00032     ERR_TILE_BASE = AIError::ERR_CAT_TILE << AIError::ERR_CAT_BIT_SIZE,
    00033
    00035     ERR_TILE_TOO_HIGH,                     // [STR_ERROR_ALREADY_AT_SEA_LEVEL]
    00036
    00038     ERR_TILE_TOO_LOW,                      // [STR_ERROR_ALREADY_AT_SEA_LEVEL]
    00039
    00041     ERR_AREA_ALREADY_FLAT,                 // [STR_ERROR_ALREADY_LEVELLED]
    00042
    00044     ERR_EXCAVATION_WOULD_DAMAGE,           // [STR_ERROR_EXCAVATION_WOULD_DAMAGE]
    00045   };
    00046
    00050   enum Corner {
    00051     CORNER_W       = 0,
    00052     CORNER_S       = 1,
    00053     CORNER_E       = 2,
    00054     CORNER_N       = 3,
    00055
    00056     CORNER_INVALID = 0xFF,
    00057   };
    00058
    00066   enum Slope {
    00067     /* Values are important, as they represent the internal state of the game. */
    00068     SLOPE_FLAT     = 0x00,
    00069     SLOPE_W        = 1 << CORNER_W,
    00070     SLOPE_S        = 1 << CORNER_S,
    00071     SLOPE_E        = 1 << CORNER_E,
    00072     SLOPE_N        = 1 << CORNER_N,
    00073     SLOPE_STEEP    = 0x10,
    00074     SLOPE_NW       = SLOPE_N | SLOPE_W,
    00075     SLOPE_SW       = SLOPE_S | SLOPE_W,
    00076     SLOPE_SE       = SLOPE_S | SLOPE_E,
    00077     SLOPE_NE       = SLOPE_N | SLOPE_E,
    00078     SLOPE_EW       = SLOPE_E | SLOPE_W,
    00079     SLOPE_NS       = SLOPE_N | SLOPE_S,
    00080     SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W,
    00081     SLOPE_NWS      = SLOPE_N | SLOPE_W | SLOPE_S,
    00082     SLOPE_WSE      = SLOPE_W | SLOPE_S | SLOPE_E,
    00083     SLOPE_SEN      = SLOPE_S | SLOPE_E | SLOPE_N,
    00084     SLOPE_ENW      = SLOPE_E | SLOPE_N | SLOPE_W,
    00085     SLOPE_STEEP_W  = SLOPE_STEEP | SLOPE_NWS,
    00086     SLOPE_STEEP_S  = SLOPE_STEEP | SLOPE_WSE,
    00087     SLOPE_STEEP_E  = SLOPE_STEEP | SLOPE_SEN,
    00088     SLOPE_STEEP_N  = SLOPE_STEEP | SLOPE_ENW,
    00089
    00090     SLOPE_INVALID  = 0xFFFF,
    00091   };
    00092
    00096   enum TransportType {
    00097     /* Values are important, as they represent the internal state of the game. */
    00098     TRANSPORT_RAIL    =  0,
    00099     TRANSPORT_ROAD    =  1,
    00100     TRANSPORT_WATER   =  2,
    00101     TRANSPORT_AIR     =  3,
    00102
    00103     TRANSPORT_INVALID = -1,
    00104   };
    00105
    00117   static bool IsBuildable(TileIndex tile);
    00118
    00128   static bool IsBuildableRectangle(TileIndex tile, uint width, uint height);
    00129
    00136   static bool IsWaterTile(TileIndex tile);
    00137
    00145   static bool IsCoastTile(TileIndex tile);
    00146
    00153   static bool IsStationTile(TileIndex tile);
    00154
    00162   static bool IsSteepSlope(Slope slope);
    00163
    00172   static bool IsHalftileSlope(Slope slope);
    00173
    00180   static bool HasTreeOnTile(TileIndex tile);
    00181
    00188   static bool IsFarmTile(TileIndex tile);
    00189
    00196   static bool IsRockTile(TileIndex tile);
    00197
    00204   static bool IsRoughTile(TileIndex tile);
    00205
    00212   static bool IsSnowTile(TileIndex tile);
    00213
    00220   static bool IsDesertTile(TileIndex tile);
    00221
    00229   static Slope GetSlope(TileIndex tile);
    00230
    00240   static Slope GetComplementSlope(Slope slope);
    00241
    00249   static int32 GetMinHeight(TileIndex tile);
    00250
    00258   static int32 GetMaxHeight(TileIndex tile);
    00259
    00268   static int32 GetCornerHeight(TileIndex tile, Corner corner);
    00269
    00277   static AICompany::CompanyID GetOwner(TileIndex tile);
    00278
    00291   static bool HasTransportType(TileIndex tile, TransportType transport_type);
    00292
    00308   static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
    00309
    00326   static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
    00327
    00334   static int32 GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to);
    00335
    00342   static int32 GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to);
    00343
    00358   static bool RaiseTile(TileIndex tile, int32 slope);
    00359
    00374   static bool LowerTile(TileIndex tile, int32 slope);
    00375
    00392   static bool LevelTiles(TileIndex start_tile, TileIndex end_tile);
    00393
    00401   static bool DemolishTile(TileIndex tile);
    00402
    00409   static bool PlantTree(TileIndex tile);
    00410
    00421   static bool PlantTreeRectangle(TileIndex tile, uint width, uint height);
    00422
    00430   static bool IsWithinTownInfluence(TileIndex tile, TownID town_id);
    00431
    00438   static TownID GetClosestTown(TileIndex tile);
    00439 };
    00440
    00441 #endif /* AI_TILE_HPP */