00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef SCRIPT_TILE_HPP
00013 #define SCRIPT_TILE_HPP
00014
00015 #include "script_error.hpp"
00016 #include "script_company.hpp"
00017
00022 class ScriptTile : public ScriptObject {
00023 public:
00027 enum ErrorMessages {
00028
00030 ERR_TILE_BASE = ScriptError::ERR_CAT_TILE << ScriptError::ERR_CAT_BIT_SIZE,
00031
00033 ERR_TILE_TOO_HIGH,
00034
00036 ERR_TILE_TOO_LOW,
00037
00039 ERR_AREA_ALREADY_FLAT,
00040
00042 ERR_EXCAVATION_WOULD_DAMAGE,
00043 };
00044
00048 enum Corner {
00049 CORNER_W = 0,
00050 CORNER_S = 1,
00051 CORNER_E = 2,
00052 CORNER_N = 3,
00053
00054 CORNER_INVALID = 0xFF,
00055 };
00056
00064 enum Slope {
00065
00066 SLOPE_FLAT = 0x00,
00067 SLOPE_W = 1 << CORNER_W,
00068 SLOPE_S = 1 << CORNER_S,
00069 SLOPE_E = 1 << CORNER_E,
00070 SLOPE_N = 1 << CORNER_N,
00071 SLOPE_STEEP = 0x10,
00072 SLOPE_NW = SLOPE_N | SLOPE_W,
00073 SLOPE_SW = SLOPE_S | SLOPE_W,
00074 SLOPE_SE = SLOPE_S | SLOPE_E,
00075 SLOPE_NE = SLOPE_N | SLOPE_E,
00076 SLOPE_EW = SLOPE_E | SLOPE_W,
00077 SLOPE_NS = SLOPE_N | SLOPE_S,
00078 SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W,
00079 SLOPE_NWS = SLOPE_N | SLOPE_W | SLOPE_S,
00080 SLOPE_WSE = SLOPE_W | SLOPE_S | SLOPE_E,
00081 SLOPE_SEN = SLOPE_S | SLOPE_E | SLOPE_N,
00082 SLOPE_ENW = SLOPE_E | SLOPE_N | SLOPE_W,
00083 SLOPE_STEEP_W = SLOPE_STEEP | SLOPE_NWS,
00084 SLOPE_STEEP_S = SLOPE_STEEP | SLOPE_WSE,
00085 SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN,
00086 SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW,
00087
00088 SLOPE_INVALID = 0xFFFF,
00089 };
00090
00094 enum TransportType {
00095
00096 TRANSPORT_RAIL = 0,
00097 TRANSPORT_ROAD = 1,
00098 TRANSPORT_WATER = 2,
00099 TRANSPORT_AIR = 3,
00100
00101 TRANSPORT_INVALID = -1,
00102 };
00103
00107 enum BuildType {
00108 BT_FOUNDATION,
00109 BT_TERRAFORM,
00110 BT_BUILD_TREES,
00111 BT_CLEAR_GRASS,
00112 BT_CLEAR_ROUGH,
00113 BT_CLEAR_ROCKY,
00114 BT_CLEAR_FIELDS,
00115 BT_CLEAR_HOUSE,
00116 };
00117
00129 static bool IsBuildable(TileIndex tile);
00130
00140 static bool IsBuildableRectangle(TileIndex tile, uint width, uint height);
00141
00148 static bool IsWaterTile(TileIndex tile);
00149
00158 static bool IsCoastTile(TileIndex tile);
00159
00166 static bool IsStationTile(TileIndex tile);
00167
00175 static bool IsSteepSlope(Slope slope);
00176
00185 static bool IsHalftileSlope(Slope slope);
00186
00193 static bool HasTreeOnTile(TileIndex tile);
00194
00201 static bool IsFarmTile(TileIndex tile);
00202
00209 static bool IsRockTile(TileIndex tile);
00210
00217 static bool IsRoughTile(TileIndex tile);
00218
00225 static bool IsSnowTile(TileIndex tile);
00226
00233 static bool IsDesertTile(TileIndex tile);
00234
00242 static Slope GetSlope(TileIndex tile);
00243
00253 static Slope GetComplementSlope(Slope slope);
00254
00262 static int32 GetMinHeight(TileIndex tile);
00263
00271 static int32 GetMaxHeight(TileIndex tile);
00272
00281 static int32 GetCornerHeight(TileIndex tile, Corner corner);
00282
00290 static ScriptCompany::CompanyID GetOwner(TileIndex tile);
00291
00308 static bool HasTransportType(TileIndex tile, TransportType transport_type);
00309
00326 static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
00327
00343 static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
00344
00351 static int32 GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to);
00352
00359 static int32 GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to);
00360
00375 static bool RaiseTile(TileIndex tile, int32 slope);
00376
00391 static bool LowerTile(TileIndex tile, int32 slope);
00392
00409 static bool LevelTiles(TileIndex start_tile, TileIndex end_tile);
00410
00418 static bool DemolishTile(TileIndex tile);
00419
00426 static bool PlantTree(TileIndex tile);
00427
00438 static bool PlantTreeRectangle(TileIndex tile, uint width, uint height);
00439
00448 static bool IsWithinTownInfluence(TileIndex tile, TownID town_id);
00449
00457 static TownID GetTownAuthority(TileIndex tile);
00458
00465 static TownID GetClosestTown(TileIndex tile);
00466
00472 static Money GetBuildCost(BuildType build_type);
00473 };
00474
00475 #endif