Class that handles all tile related functions. More...
#include <script_tile.hpp>
Public Types | |
enum | ErrorMessages { ERR_TILE_BASE = ScriptError::ERR_CAT_TILE << ScriptError::ERR_CAT_BIT_SIZE, ERR_TILE_TOO_HIGH, ERR_TILE_TOO_LOW, ERR_AREA_ALREADY_FLAT, ERR_EXCAVATION_WOULD_DAMAGE } |
Error messages related to modifying tiles. More... | |
enum | Corner { CORNER_W = 0, CORNER_S = 1, CORNER_E = 2, CORNER_N = 3, CORNER_INVALID = 0xFF } |
Enumeration for corners of tiles. More... | |
enum | Slope { SLOPE_FLAT = 0x00, SLOPE_W = 1 << CORNER_W, SLOPE_S = 1 << CORNER_S, SLOPE_E = 1 << CORNER_E, SLOPE_N = 1 << CORNER_N, SLOPE_STEEP = 0x10, SLOPE_NW = SLOPE_N | SLOPE_W, SLOPE_SW = SLOPE_S | SLOPE_W, SLOPE_SE = SLOPE_S | SLOPE_E, SLOPE_NE = SLOPE_N | SLOPE_E, SLOPE_EW = SLOPE_E | SLOPE_W, SLOPE_NS = SLOPE_N | SLOPE_S, SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, SLOPE_NWS = SLOPE_N | SLOPE_W | SLOPE_S, SLOPE_WSE = SLOPE_W | SLOPE_S | SLOPE_E, SLOPE_SEN = SLOPE_S | SLOPE_E | SLOPE_N, SLOPE_ENW = SLOPE_E | SLOPE_N | SLOPE_W, SLOPE_STEEP_W = SLOPE_STEEP | SLOPE_NWS, SLOPE_STEEP_S = SLOPE_STEEP | SLOPE_WSE, SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN, SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW, SLOPE_INVALID = 0xFFFF } |
Enumeration for the slope-type. More... | |
enum | TransportType { TRANSPORT_RAIL = 0, TRANSPORT_ROAD = 1, TRANSPORT_WATER = 2, TRANSPORT_AIR = 3, TRANSPORT_INVALID = -1 } |
The different transport types a tile can have. More... | |
enum | BuildType { BT_FOUNDATION, BT_TERRAFORM, BT_BUILD_TREES, BT_CLEAR_GRASS, BT_CLEAR_ROUGH, BT_CLEAR_ROCKY, BT_CLEAR_FIELDS, BT_CLEAR_HOUSE } |
Get the base cost for building/clearing several things. More... | |
Static Public Member Functions | |
static bool | IsBuildable (TileIndex tile) |
Check if this tile is buildable, i.e. | |
static bool | IsBuildableRectangle (TileIndex tile, uint width, uint height) |
Check if this tile is buildable in a rectangle around a tile, with the entry in the list as top-left. | |
static bool | IsWaterTile (TileIndex tile) |
Checks whether the given tile is actually a water tile. | |
static bool | IsCoastTile (TileIndex tile) |
Checks whether the given tile is actually a coast tile. | |
static bool | IsStationTile (TileIndex tile) |
Checks whether the given tile is a station tile of any station. | |
static bool | IsSteepSlope (Slope slope) |
Check if a tile has a steep slope. | |
static bool | IsHalftileSlope (Slope slope) |
Check if a tile has a halftile slope. | |
static bool | HasTreeOnTile (TileIndex tile) |
Check if the tile has any tree on it. | |
static bool | IsFarmTile (TileIndex tile) |
Check if the tile is a farmland tile. | |
static bool | IsRockTile (TileIndex tile) |
Check if the tile is a rock tile. | |
static bool | IsRoughTile (TileIndex tile) |
Check if the tile is a rough tile. | |
static bool | IsSnowTile (TileIndex tile) |
Check if the tile is a snow tile. | |
static bool | IsDesertTile (TileIndex tile) |
Check if the tile is a desert tile. | |
static Slope | GetSlope (TileIndex tile) |
Get the slope of a tile. | |
static Slope | GetComplementSlope (Slope slope) |
Get the complement of the slope. | |
static int32 | GetMinHeight (TileIndex tile) |
Get the minimal height on a tile. | |
static int32 | GetMaxHeight (TileIndex tile) |
Get the maximal height on a tile. | |
static int32 | GetCornerHeight (TileIndex tile, Corner corner) |
Get the height of a certain corner of a tile. | |
static ScriptCompany::CompanyID | GetOwner (TileIndex tile) |
Get the owner of the tile. | |
static bool | HasTransportType (TileIndex tile, TransportType transport_type) |
Checks whether the given tile contains parts suitable for the given TransportType. | |
static int32 | GetCargoAcceptance (TileIndex tile, CargoID cargo_type, int width, int height, int radius) |
Check how much cargo this tile accepts. | |
static int32 | GetCargoProduction (TileIndex tile, CargoID cargo_type, int width, int height, int radius) |
Checks how many producers in the radius produces this cargo. | |
static int32 | GetDistanceManhattanToTile (TileIndex tile_from, TileIndex tile_to) |
Get the manhattan distance from the tile to the tile. | |
static int32 | GetDistanceSquareToTile (TileIndex tile_from, TileIndex tile_to) |
Get the square distance from the tile to the tile. | |
static bool | RaiseTile (TileIndex tile, int32 slope) |
Raise the given corners of the tile. | |
static bool | LowerTile (TileIndex tile, int32 slope) |
Lower the given corners of the tile. | |
static bool | LevelTiles (TileIndex start_tile, TileIndex end_tile) |
Level all tiles in the rectangle between start_tile and end_tile so they are at the same height. | |
static bool | DemolishTile (TileIndex tile) |
Destroy everything on the given tile. | |
static bool | PlantTree (TileIndex tile) |
Create a random tree on a tile. | |
static bool | PlantTreeRectangle (TileIndex tile, uint width, uint height) |
Create a random tree on a rectangle of tiles. | |
static bool | IsWithinTownInfluence (TileIndex tile, TownID town_id) |
Find out if this tile is within the rating influence of a town. | |
static TownID | GetTownAuthority (TileIndex tile) |
Find the town which has authority for the tile. | |
static TownID | GetClosestTown (TileIndex tile) |
Find the town that is closest to a tile. | |
static Money | GetBuildCost (BuildType build_type) |
Get the baseprice of building/clearing various tile-related things. |
Class that handles all tile related functions.
ai
Definition at line 22 of file script_tile.hpp.
Get the base cost for building/clearing several things.
Definition at line 107 of file script_tile.hpp.
enum ScriptTile::Corner |
Enumeration for corners of tiles.
CORNER_W |
West corner. |
CORNER_S |
South corner. |
CORNER_E |
East corner. |
CORNER_N |
North corner. |
Definition at line 48 of file script_tile.hpp.
Error messages related to modifying tiles.
ERR_TILE_BASE |
Base for tile related errors. |
ERR_TILE_TOO_HIGH |
Tile can't be raised any higher. |
ERR_TILE_TOO_LOW |
Tile can't be lowered any lower. |
ERR_AREA_ALREADY_FLAT |
The area was already flat. |
ERR_EXCAVATION_WOULD_DAMAGE |
There is a tunnel underneed. |
Definition at line 27 of file script_tile.hpp.
enum ScriptTile::Slope |
Enumeration for the slope-type.
This enumeration use the chars N, E, S, W corresponding the direction North, East, South and West. The top corner of a tile is the north-part of the tile.
Definition at line 64 of file script_tile.hpp.
bool ScriptTile::DemolishTile | ( | TileIndex | tile | ) | [static] |
Destroy everything on the given tile.
tile | The tile to demolish. |
ScriptError::ERR_AREA_NOT_CLEAR |
Definition at line 242 of file script_tile.cpp.
References CMD_LANDSCAPE_CLEAR, ScriptObject::DoCommand(), EnforcePrecondition, and IsValidTile().
Get the baseprice of building/clearing various tile-related things.
build_type | the type to build |
Definition at line 285 of file script_tile.cpp.
References BT_BUILD_TREES, BT_CLEAR_FIELDS, BT_CLEAR_GRASS, BT_CLEAR_HOUSE, BT_CLEAR_ROCKY, BT_CLEAR_ROUGH, BT_FOUNDATION, BT_TERRAFORM, and GetPrice().
int32 ScriptTile::GetCargoAcceptance | ( | TileIndex | tile, | |
CargoID | cargo_type, | |||
int | width, | |||
int | height, | |||
int | radius | |||
) | [static] |
Check how much cargo this tile accepts.
It creates a radius around the tile, and adds up all acceptance of this cargo.
tile | The tile to check on. | |
cargo_type | The cargo to check the acceptance of. | |
width | The width of the station. | |
height | The height of the station. | |
radius | The radius of the station. |
Definition at line 194 of file script_tile.cpp.
References _settings_game, CA_UNMODIFIED, GetAcceptanceAroundTiles(), ScriptCargo::IsValidCargo(), IsValidTile(), StationSettings::modified_catchment, and GameSettings::station.
int32 ScriptTile::GetCargoProduction | ( | TileIndex | tile, | |
CargoID | cargo_type, | |||
int | width, | |||
int | height, | |||
int | radius | |||
) | [static] |
Checks how many producers in the radius produces this cargo.
It creates a radius around the tile, and counts all producer of this cargo.
tile | The tile to check on. | |
cargo_type | The cargo to check the production of. | |
width | The width of the station. | |
height | The height of the station. | |
radius | The radius of the station. |
Definition at line 202 of file script_tile.cpp.
References _settings_game, CA_UNMODIFIED, GetProductionAroundTiles(), ScriptCargo::IsValidCargo(), IsValidTile(), StationSettings::modified_catchment, and GameSettings::station.
Find the town that is closest to a tile.
Stations you build at this tile will belong to this town.
tile | The tile to check. |
Definition at line 278 of file script_tile.cpp.
References ClosestTownFromTile(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, and IsValidTile().
ScriptTile::Slope ScriptTile::GetComplementSlope | ( | Slope | slope | ) | [static] |
Get the complement of the slope.
slope | The slope to get the complement of. |
Definition at line 148 of file script_tile.cpp.
References ComplementSlope(), and SLOPE_ELEVATED.
Get the height of a certain corner of a tile.
The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
tile | The tile to check on. | |
corner | The corner to query. |
Definition at line 169 of file script_tile.cpp.
References GetSlopeZInCorner(), GetTileSlope(), IsValidCorner(), and IsValidTile().
Get the manhattan distance from the tile to the tile.
tile_from | The tile to get the distance to. | |
tile_to | The tile to get the distance to. |
Definition at line 210 of file script_tile.cpp.
References DistanceManhattan().
Get the square distance from the tile to the tile.
tile_from | The tile to get the distance to. | |
tile_to | The tile to get the distance to. |
Definition at line 215 of file script_tile.cpp.
References DistanceSquare().
int32 ScriptTile::GetMaxHeight | ( | TileIndex | tile | ) | [static] |
Get the maximal height on a tile.
The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
tile | The tile to check on. |
Definition at line 162 of file script_tile.cpp.
References GetTileMaxZ(), and IsValidTile().
int32 ScriptTile::GetMinHeight | ( | TileIndex | tile | ) | [static] |
Get the minimal height on a tile.
The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
tile | The tile to check on. |
Definition at line 155 of file script_tile.cpp.
References GetTileZ(), and IsValidTile().
ScriptCompany::CompanyID ScriptTile::GetOwner | ( | TileIndex | tile | ) | [static] |
Get the owner of the tile.
tile | The tile to get the owner from. |
Definition at line 178 of file script_tile.cpp.
References GetTileOwner(), IsTileType(), IsValidTile(), MP_HOUSE, MP_INDUSTRY, and ScriptCompany::ResolveCompanyID().
ScriptTile::Slope ScriptTile::GetSlope | ( | TileIndex | tile | ) | [static] |
Get the slope of a tile.
This is the slope of the bare tile. A possible foundation on the tile does not influence this slope.
tile | The tile to check on. |
Definition at line 141 of file script_tile.cpp.
References GetTileSlope(), and IsValidTile().
Referenced by ScriptRoad::CanBuildConnectedRoadPartsHere().
Find the town which has authority for the tile.
The rating of your company in this town will be checked and affected when building stations, trees etc.
tile | The tile to check. |
Definition at line 271 of file script_tile.cpp.
References _settings_game, ClosestTownFromTile(), EconomySettings::dist_local_authority, GameSettings::economy, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, and IsValidTile().
bool ScriptTile::HasTransportType | ( | TileIndex | tile, | |
TransportType | transport_type | |||
) | [static] |
Checks whether the given tile contains parts suitable for the given TransportType.
tile | The tile to check. | |
transport_type | The TransportType to check against. |
Definition at line 187 of file script_tile.cpp.
References GetTileTrackStatus(), IsValidTile(), and TrackStatusToTrackdirBits().
Referenced by ScriptRail::GetRailType().
bool ScriptTile::HasTreeOnTile | ( | TileIndex | tile | ) | [static] |
Check if the tile has any tree on it.
tile | The tile to check on. |
Definition at line 99 of file script_tile.cpp.
References IsTileType(), IsValidTile(), and MP_TREES.
bool ScriptTile::IsBuildable | ( | TileIndex | tile | ) | [static] |
Check if this tile is buildable, i.e.
no things on it that needs demolishing.
tile | The tile to check on. |
Definition at line 26 of file script_tile.cpp.
References _current_company, GetRoadBits(), GetRoadTileType(), GetRoadTypes(), GetTileType(), HasExactlyOneBit(), IsCoast(), IsRoadOwner(), IsValidTile(), MP_CLEAR, MP_ROAD, MP_TREES, MP_WATER, OWNER_TOWN, ROAD_TILE_NORMAL, ROADTYPE_ROAD, and ROADTYPES_ROAD.
Referenced by IsBuildableRectangle().
bool ScriptTile::IsBuildableRectangle | ( | TileIndex | tile, | |
uint | width, | |||
uint | height | |||
) | [static] |
Check if this tile is buildable in a rectangle around a tile, with the entry in the list as top-left.
tile | The tile to check on. | |
width | The width of the rectangle. | |
height | The height of the rectangle. |
Definition at line 47 of file script_tile.cpp.
References ScriptMap::GetTileIndex(), ScriptMap::GetTileX(), ScriptMap::GetTileY(), and IsBuildable().
bool ScriptTile::IsCoastTile | ( | TileIndex | tile | ) | [static] |
Checks whether the given tile is actually a coast tile.
tile | The tile to check. |
Definition at line 70 of file script_tile.cpp.
References GetTreeGround(), IsCoast(), IsTileType(), IsValidTile(), and MP_WATER.
bool ScriptTile::IsDesertTile | ( | TileIndex | tile | ) | [static] |
Check if the tile is a desert tile.
tile | The tile to check on. |
Definition at line 134 of file script_tile.cpp.
References CLEAR_DESERT, IsClearGround(), IsTileType(), IsValidTile(), and MP_CLEAR.
bool ScriptTile::IsFarmTile | ( | TileIndex | tile | ) | [static] |
Check if the tile is a farmland tile.
tile | The tile to check on. |
Definition at line 106 of file script_tile.cpp.
References CLEAR_FIELDS, IsClearGround(), IsTileType(), IsValidTile(), and MP_CLEAR.
bool ScriptTile::IsHalftileSlope | ( | Slope | slope | ) | [static] |
Check if a tile has a halftile slope.
Halftile slopes appear on top of halftile foundations. E.g. the slope you get when building a horizontal railtrack on the top of a SLOPE_N or SLOPE_STEEP_N.
slope | The slope to check on. |
Definition at line 92 of file script_tile.cpp.
References SLOPE_ELEVATED, SLOPE_HALFTILE_MASK, and SLOPE_STEEP.
bool ScriptTile::IsRockTile | ( | TileIndex | tile | ) | [static] |
Check if the tile is a rock tile.
tile | The tile to check on. |
Definition at line 113 of file script_tile.cpp.
References CLEAR_ROCKS, GetRawClearGround(), IsTileType(), IsValidTile(), and MP_CLEAR.
bool ScriptTile::IsRoughTile | ( | TileIndex | tile | ) | [static] |
Check if the tile is a rough tile.
tile | The tile to check on. |
Definition at line 120 of file script_tile.cpp.
References CLEAR_ROUGH, GetRawClearGround(), IsTileType(), IsValidTile(), and MP_CLEAR.
bool ScriptTile::IsSnowTile | ( | TileIndex | tile | ) | [static] |
Check if the tile is a snow tile.
tile | The tile to check on. |
Definition at line 127 of file script_tile.cpp.
References IsTileType(), IsValidTile(), and MP_CLEAR.
bool ScriptTile::IsStationTile | ( | TileIndex | tile | ) | [static] |
Checks whether the given tile is a station tile of any station.
tile | The tile to check. |
Definition at line 78 of file script_tile.cpp.
References IsTileType(), IsValidTile(), and MP_STATION.
Referenced by ScriptAirport::GetAirportType().
bool ScriptTile::IsSteepSlope | ( | Slope | slope | ) | [static] |
Check if a tile has a steep slope.
Steep slopes are slopes with a height difference of 2 across one diagonal of the tile.
slope | The slope to check on. |
Definition at line 85 of file script_tile.cpp.
References SLOPE_ELEVATED, SLOPE_HALFTILE_MASK, and SLOPE_STEEP.
bool ScriptTile::IsWaterTile | ( | TileIndex | tile | ) | [static] |
Checks whether the given tile is actually a water tile.
tile | The tile to check on. |
Definition at line 63 of file script_tile.cpp.
References IsCoast(), IsTileType(), IsValidTile(), and MP_WATER.
Find out if this tile is within the rating influence of a town.
If a station sign would be on this tile, the servicing quality of the station would influence the rating of the town.
tile | The tile to check. | |
town_id | The town to check. |
Definition at line 266 of file script_tile.cpp.
Level all tiles in the rectangle between start_tile and end_tile so they are at the same height.
All tiles will be raised or lowered until they are at height ScriptTile::GetHeight(start_tile).
start_tile | One corner of the rectangle to level. | |
end_tile | The opposite corner of the rectangle. |
Definition at line 234 of file script_tile.cpp.
References CMD_LEVEL_LAND, ScriptObject::DoCommand(), EnforcePrecondition, LM_LEVEL, and MapSize().
bool ScriptTile::LowerTile | ( | TileIndex | tile, | |
int32 | slope | |||
) | [static] |
Lower the given corners of the tile.
The corners can be combined, for example: SLOPE_N | SLOPE_W (= SLOPE_NW) will lower the west and the north corner.
tile | The tile to lower. | |
slope | Corners to lower (SLOPE_xxx). |
ScriptError::ERR_AREA_NOT_CLEAR | ||
ScriptError::ERR_TOO_CLOSE_TO_EDGE | ||
ScriptTile::ERR_TILE_TOO_LOW |
Definition at line 227 of file script_tile.cpp.
References CMD_TERRAFORM_LAND, ScriptObject::DoCommand(), EnforcePrecondition, and MapSize().
bool ScriptTile::PlantTree | ( | TileIndex | tile | ) | [static] |
Create a random tree on a tile.
tile | The tile to build a tree on. |
Definition at line 249 of file script_tile.cpp.
References CMD_PLANT_TREE, ScriptObject::DoCommand(), EnforcePrecondition, IsValidTile(), and TREE_INVALID.
bool ScriptTile::PlantTreeRectangle | ( | TileIndex | tile, | |
uint | width, | |||
uint | height | |||
) | [static] |
Create a random tree on a rectangle of tiles.
tile | The top left tile of the rectangle. | |
width | The width of the rectangle. | |
height | The height of the rectangle. |
Definition at line 256 of file script_tile.cpp.
References CMD_PLANT_TREE, ScriptObject::DoCommand(), EnforcePrecondition, IsValidTile(), TileDiffXY(), and TREE_INVALID.
bool ScriptTile::RaiseTile | ( | TileIndex | tile, | |
int32 | slope | |||
) | [static] |
Raise the given corners of the tile.
The corners can be combined, for example: SLOPE_N | SLOPE_W (= SLOPE_NW) will raise the west and the north corner.
tile | The tile to raise. | |
slope | Corners to raise (SLOPE_xxx). |
ScriptError::ERR_AREA_NOT_CLEAR | ||
ScriptError::ERR_TOO_CLOSE_TO_EDGE | ||
ScriptTile::ERR_TILE_TOO_HIGH |
Definition at line 220 of file script_tile.cpp.
References CMD_TERRAFORM_LAND, ScriptObject::DoCommand(), EnforcePrecondition, and MapSize().