# ai_tile.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_tile.hpp 18726 2010-01-04 21:10:20Z rubidium $ */
    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
    00146   static bool IsCoastTile(TileIndex tile);
    00147
    00154   static bool IsStationTile(TileIndex tile);
    00155
    00163   static bool IsSteepSlope(Slope slope);
    00164
    00173   static bool IsHalftileSlope(Slope slope);
    00174
    00181   static bool HasTreeOnTile(TileIndex tile);
    00182
    00189   static bool IsFarmTile(TileIndex tile);
    00190
    00197   static bool IsRockTile(TileIndex tile);
    00198
    00205   static bool IsRoughTile(TileIndex tile);
    00206
    00213   static bool IsSnowTile(TileIndex tile);
    00214
    00221   static bool IsDesertTile(TileIndex tile);
    00222
    00230   static Slope GetSlope(TileIndex tile);
    00231
    00241   static Slope GetComplementSlope(Slope slope);
    00242
    00250   static int32 GetMinHeight(TileIndex tile);
    00251
    00259   static int32 GetMaxHeight(TileIndex tile);
    00260
    00269   static int32 GetCornerHeight(TileIndex tile, Corner corner);
    00270
    00278   static AICompany::CompanyID GetOwner(TileIndex tile);
    00279
    00292   static bool HasTransportType(TileIndex tile, TransportType transport_type);
    00293
    00309   static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
    00310
    00325   static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
    00326
    00333   static int32 GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to);
    00334
    00341   static int32 GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to);
    00342
    00357   static bool RaiseTile(TileIndex tile, int32 slope);
    00358
    00373   static bool LowerTile(TileIndex tile, int32 slope);
    00374
    00391   static bool LevelTiles(TileIndex start_tile, TileIndex end_tile);
    00392
    00400   static bool DemolishTile(TileIndex tile);
    00401
    00408   static bool PlantTree(TileIndex tile);
    00409
    00420   static bool PlantTreeRectangle(TileIndex tile, uint width, uint height);
    00421
    00429   static bool IsWithinTownInfluence(TileIndex tile, TownID town_id);
    00430
    00437   static TownID GetClosestTown(TileIndex tile);
    00438 };
    00439
    00440 #endif /* AI_TILE_HPP */