ai_tile.hpp

Go to the documentation of this file.
00001 /* $Id: ai_tile.hpp 20798 2010-09-13 13:36:36Z yexo $ */
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_list.hpp"
00016 #include "ai_error.hpp"
00017 #include "ai_company.hpp"
00018 
00022 class AITile : public AIObject {
00023 public:
00025   static const char *GetClassName() { return "AITile"; }
00026 
00030   enum ErrorMessages {
00031 
00033     ERR_TILE_BASE = AIError::ERR_CAT_TILE << AIError::ERR_CAT_BIT_SIZE,
00034 
00036     ERR_TILE_TOO_HIGH,                     // [STR_ERROR_ALREADY_AT_SEA_LEVEL]
00037 
00039     ERR_TILE_TOO_LOW,                      // [STR_ERROR_ALREADY_AT_SEA_LEVEL]
00040 
00042     ERR_AREA_ALREADY_FLAT,                 // [STR_ERROR_ALREADY_LEVELLED]
00043 
00045     ERR_EXCAVATION_WOULD_DAMAGE,           // [STR_ERROR_EXCAVATION_WOULD_DAMAGE]
00046   };
00047 
00051   enum Corner {
00052     CORNER_W       = 0,      
00053     CORNER_S       = 1,      
00054     CORNER_E       = 2,      
00055     CORNER_N       = 3,      
00056 
00057     CORNER_INVALID = 0xFF,
00058   };
00059 
00067   enum Slope {
00068     /* Values are important, as they represent the internal state of the game. */
00069     SLOPE_FLAT     = 0x00,                                  
00070     SLOPE_W        = 1 << CORNER_W,                         
00071     SLOPE_S        = 1 << CORNER_S,                         
00072     SLOPE_E        = 1 << CORNER_E,                         
00073     SLOPE_N        = 1 << CORNER_N,                         
00074     SLOPE_STEEP    = 0x10,                                  
00075     SLOPE_NW       = SLOPE_N | SLOPE_W,                     
00076     SLOPE_SW       = SLOPE_S | SLOPE_W,                     
00077     SLOPE_SE       = SLOPE_S | SLOPE_E,                     
00078     SLOPE_NE       = SLOPE_N | SLOPE_E,                     
00079     SLOPE_EW       = SLOPE_E | SLOPE_W,                     
00080     SLOPE_NS       = SLOPE_N | SLOPE_S,                     
00081     SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, 
00082     SLOPE_NWS      = SLOPE_N | SLOPE_W | SLOPE_S,           
00083     SLOPE_WSE      = SLOPE_W | SLOPE_S | SLOPE_E,           
00084     SLOPE_SEN      = SLOPE_S | SLOPE_E | SLOPE_N,           
00085     SLOPE_ENW      = SLOPE_E | SLOPE_N | SLOPE_W,           
00086     SLOPE_STEEP_W  = SLOPE_STEEP | SLOPE_NWS,               
00087     SLOPE_STEEP_S  = SLOPE_STEEP | SLOPE_WSE,               
00088     SLOPE_STEEP_E  = SLOPE_STEEP | SLOPE_SEN,               
00089     SLOPE_STEEP_N  = SLOPE_STEEP | SLOPE_ENW,               
00090 
00091     SLOPE_INVALID  = 0xFFFF,                                
00092   };
00093 
00097   enum TransportType {
00098     /* Values are important, as they represent the internal state of the game. */
00099     TRANSPORT_RAIL    =  0, 
00100     TRANSPORT_ROAD    =  1, 
00101     TRANSPORT_WATER   =  2, 
00102     TRANSPORT_AIR     =  3, 
00103 
00104     TRANSPORT_INVALID = -1, 
00105   };
00106 
00110   enum BuildType {
00111     BT_FOUNDATION,   
00112     BT_TERRAFORM,    
00113     BT_BUILD_TREES,  
00114     BT_CLEAR_GRASS,  
00115     BT_CLEAR_ROUGH,  
00116     BT_CLEAR_ROCKY,  
00117     BT_CLEAR_FIELDS, 
00118     BT_CLEAR_HOUSE,  
00119   };
00120 
00132   static bool IsBuildable(TileIndex tile);
00133 
00143   static bool IsBuildableRectangle(TileIndex tile, uint width, uint height);
00144 
00151   static bool IsWaterTile(TileIndex tile);
00152 
00161   static bool IsCoastTile(TileIndex tile);
00162 
00169   static bool IsStationTile(TileIndex tile);
00170 
00178   static bool IsSteepSlope(Slope slope);
00179 
00188   static bool IsHalftileSlope(Slope slope);
00189 
00196   static bool HasTreeOnTile(TileIndex tile);
00197 
00204   static bool IsFarmTile(TileIndex tile);
00205 
00212   static bool IsRockTile(TileIndex tile);
00213 
00220   static bool IsRoughTile(TileIndex tile);
00221 
00228   static bool IsSnowTile(TileIndex tile);
00229 
00236   static bool IsDesertTile(TileIndex tile);
00237 
00245   static Slope GetSlope(TileIndex tile);
00246 
00256   static Slope GetComplementSlope(Slope slope);
00257 
00265   static int32 GetMinHeight(TileIndex tile);
00266 
00274   static int32 GetMaxHeight(TileIndex tile);
00275 
00284   static int32 GetCornerHeight(TileIndex tile, Corner corner);
00285 
00293   static AICompany::CompanyID GetOwner(TileIndex tile);
00294 
00311   static bool HasTransportType(TileIndex tile, TransportType transport_type);
00312 
00328   static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
00329 
00344   static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
00345 
00352   static int32 GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to);
00353 
00360   static int32 GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to);
00361 
00376   static bool RaiseTile(TileIndex tile, int32 slope);
00377 
00392   static bool LowerTile(TileIndex tile, int32 slope);
00393 
00410   static bool LevelTiles(TileIndex start_tile, TileIndex end_tile);
00411 
00419   static bool DemolishTile(TileIndex tile);
00420 
00427   static bool PlantTree(TileIndex tile);
00428 
00439   static bool PlantTreeRectangle(TileIndex tile, uint width, uint height);
00440 
00448   static bool IsWithinTownInfluence(TileIndex tile, TownID town_id);
00449 
00456   static TownID GetClosestTown(TileIndex tile);
00457 
00463   static Money GetBuildCost(BuildType build_type);
00464 };
00465 
00466 #endif /* AI_TILE_HPP */

Generated on Sun Jan 9 16:01:51 2011 for OpenTTD by  doxygen 1.6.1