Class that handles all map related functions. More...
#include <script_map.hpp>
Static Public Member Functions | |
static bool | IsValidTile (TileIndex tile) |
Checks whether the given tile is valid. | |
static TileIndex | GetMapSize () |
Gets the number of tiles in the map. | |
static uint32 | GetMapSizeX () |
Gets the amount of tiles along the SW and NE border. | |
static uint32 | GetMapSizeY () |
Gets the amount of tiles along the SE and NW border. | |
static int32 | GetTileX (TileIndex tile) |
Gets the place along the SW/NE border (X-value). | |
static int32 | GetTileY (TileIndex tile) |
Gets the place along the SE/NW border (Y-value). | |
static TileIndex | GetTileIndex (uint32 x, uint32 y) |
Gets the TileIndex given a x,y-coordinate. | |
static int32 | DistanceManhattan (TileIndex tile_from, TileIndex tile_to) |
Calculates the Manhattan distance; the difference of the X and Y added together. | |
static int32 | DistanceMax (TileIndex tile_from, TileIndex tile_to) |
Calculates the distance between two tiles via 1D calculation. | |
static int32 | DistanceSquare (TileIndex tile_from, TileIndex tile_to) |
The squared distance between the two tiles. | |
static int32 | DistanceFromEdge (TileIndex tile) |
Calculates the shortest distance to the edge. | |
Static Public Attributes | |
static const int | TILE_INVALID = (int)INVALID_TILE |
Invalid TileIndex. |
Class that handles all map related functions.
ai
Definition at line 22 of file script_map.hpp.
int32 ScriptMap::DistanceFromEdge | ( | TileIndex | tile | ) | [static] |
Calculates the shortest distance to the edge.
tile | From where the distance has to be calculated. |
Definition at line 71 of file script_map.cpp.
References IsValidTile().
Calculates the Manhattan distance; the difference of the X and Y added together.
tile_from | The start tile. | |
tile_to | The destination tile. |
Definition at line 53 of file script_map.cpp.
References IsValidTile().
Referenced by ScriptRail::AreTilesConnected(), ScriptRail::BuildSignal(), ScriptRail::GetSignalType(), and ScriptRail::RemoveSignal().
Calculates the distance between two tiles via 1D calculation.
This means the distance between X or the distance between Y, depending on which one is bigger.
tile_from | The start tile. | |
tile_to | The destination tile. |
Definition at line 59 of file script_map.cpp.
References IsValidTile().
The squared distance between the two tiles.
This is the distance is the length of the shortest straight line between both points.
tile_from | The start tile. | |
tile_to | The destination tile. |
Definition at line 65 of file script_map.cpp.
References IsValidTile().
TileIndex ScriptMap::GetMapSize | ( | ) | [static] |
Gets the number of tiles in the map.
Definition at line 21 of file script_map.cpp.
References MapSize().
uint32 ScriptMap::GetMapSizeX | ( | ) | [static] |
Gets the amount of tiles along the SW and NE border.
Definition at line 26 of file script_map.cpp.
References MapSizeX().
uint32 ScriptMap::GetMapSizeY | ( | ) | [static] |
Gets the amount of tiles along the SE and NW border.
Definition at line 31 of file script_map.cpp.
References MapSizeY().
TileIndex ScriptMap::GetTileIndex | ( | uint32 | x, | |
uint32 | y | |||
) | [static] |
Gets the TileIndex given a x,y-coordinate.
x | The X coordinate. | |
y | The Y coordinate. |
Definition at line 48 of file script_map.cpp.
References TileXY().
Referenced by ScriptTile::IsBuildableRectangle().
int32 ScriptMap::GetTileX | ( | TileIndex | tile | ) | [static] |
Gets the place along the SW/NE border (X-value).
tile | The tile to get the X-value of. |
Definition at line 36 of file script_map.cpp.
References IsValidTile(), and TileX().
Referenced by ScriptTile::IsBuildableRectangle().
int32 ScriptMap::GetTileY | ( | TileIndex | tile | ) | [static] |
Gets the place along the SE/NW border (Y-value).
tile | The tile to get the Y-value of. |
Definition at line 42 of file script_map.cpp.
References IsValidTile(), and TileY().
Referenced by ScriptTile::IsBuildableRectangle().
bool ScriptMap::IsValidTile | ( | TileIndex | tile | ) | [static] |
Checks whether the given tile is valid.
tile | The tile to check. |
Definition at line 16 of file script_map.cpp.
Referenced by ScriptIndustryType::BuildIndustry(), DistanceFromEdge(), DistanceManhattan(), DistanceMax(), DistanceSquare(), GetTileX(), GetTileY(), ScriptRoad::HasRoadType(), and ScriptVehicleList_Depot::ScriptVehicleList_Depot().