OpenTTD

Functions
tile_map.cpp File Reference

Global tile accessors. More...

`#include "stdafx.h"`
`#include "tile_map.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Functions
uint | TileHeightOutsideMap (int x, int y)
| Returns the tile height for a coordinate outside map. More...
static Slope | GetTileSlopeGivenHeight (int hnorth, int hwest, int heast, int hsouth, int *h)
| Get a tile's slope given the heigh of its four corners. More...
Slope | GetTileSlope (TileIndex tile, int *h)
| Return the slope of a given tile inside the map. More...
Slope | GetTilePixelSlopeOutsideMap (int x, int y, int *h)
| Return the slope of a given tile outside the map. More...
bool | IsTileFlat (TileIndex tile, int *h)
| Check if a given tile is flat. More...
int | GetTileZ (TileIndex tile)
| Get bottom height of the tile. More...
int | GetTilePixelZOutsideMap (int x, int y)
| Get bottom height of the tile outside map. More...
int | GetTileMaxZ (TileIndex t)
| Get top height of the tile inside the map. More...
int | GetTileMaxPixelZOutsideMap (int x, int y)
| Get top height of the tile outside the map. More...

## Detailed Description

Global tile accessors.

Definition in file tile_map.cpp.

## Function Documentation

## ◆ GetTileMaxPixelZOutsideMap()

int GetTileMaxPixelZOutsideMap | ( | int | x,
|  | int | y
| ) |  |

Get top height of the tile outside the map.

See also
  Detailed description in header.

Parameters

  tile | Tile outside to compute height of.

Returns
  Maximum height of the tile.

Definition at line 235 of file tile_map.cpp.

Referenced by GetTileMaxPixelZ().

## ◆ GetTileMaxZ()

int GetTileMaxZ | ( | TileIndex | t | ) |

Get top height of the tile inside the map.

Parameters

  t | Tile to compute height of

Returns
  Maximum height of the tile

Definition at line 215 of file tile_map.cpp.

References MapMaxX(), MapMaxY(), TileDiffXY(), TileHeight(), TileHeightOutsideMap(), TileX(), and TileY().

Referenced by AutoslopeCheckForEntranceEdge(), BuildTownHouse(), CheckBuildHouseSameZ(), FloodVehicleProc(), GetOtherAqueductEnd(), and GetTileMaxPixelZ().

## ◆ GetTilePixelSlopeOutsideMap()

Slope GetTilePixelSlopeOutsideMap | ( | int | x,
|  | int | y,
|  | int * | h
| ) |  |

Return the slope of a given tile outside the map.

Parameters

  tile | Tile outside the map to compute slope of.
  h | If not `NULL`, pointer to storage of z height.

Returns
  Slope of the tile outside map, except for the HALFTILE part.

Definition at line 141 of file tile_map.cpp.

Referenced by GetTilePixelSlope().

## ◆ GetTilePixelZOutsideMap()

int GetTilePixelZOutsideMap | ( | int | x,
|  | int | y
| ) |  |

Get bottom height of the tile outside map.

Parameters

  tile | Tile outside the map to compute height of.

Returns
  Minimum height of the tile outside the map.

Definition at line 200 of file tile_map.cpp.

Referenced by GetTilePixelZ().

## ◆ GetTileSlope()

Slope GetTileSlope | ( | TileIndex | tile,
|  | int * | h
| ) |  |

Return the slope of a given tile inside the map.

Parameters

  tile | Tile to compute slope of
  h | If not `NULL`, pointer to storage of z height

Returns
  Slope of the tile, except for the HALFTILE part

Definition at line 115 of file tile_map.cpp.

Referenced by BuildTownHouse(), CanBuildHouseHere(), CanPlantTreesOnTile(), CheckBuildableTile(), CheckIfIndustryTilesAreFree(), CmdBuildLock(), CmdBuildRoadDepot(), CmdBuildTrainDepot(), GetBridgeHeight(), GetFloodingBehaviour(), GetFoundationSlope(), GetOtherAqueductEnd(), GetTilePixelSlope(), StationScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), IsRoadAllowedHere(), BuildDocksToolbarWindow::OnPlacePresize(), PerformStationTileSlopeCheck(), SearchTileForStatue(), and CYapfCostBase::stSlopeCost().

## ◆ GetTileSlopeGivenHeight()

static Slope GetTileSlopeGivenHeight | ( | int | hnorth,
|  | int | hwest,
|  | int | heast,
|  | int | hsouth,
|  | int * | h
| ) |  |
| static

Get a tile's slope given the heigh of its four corners.

Parameters

  | hnorth | The height at the northern corner in the same unit as TileHeight.
  | hwest | The height at the western corner in the same unit as TileHeight.
  | heast | The height at the eastern corner in the same unit as TileHeight.
  | hsouth | The height at the southern corner in the same unit as TileHeight.
  [out] | h | The lowest height of the four corners.

Returns
  The slope.

Definition at line 80 of file tile_map.cpp.

References max(), min(), SLOPE_E, SLOPE_FLAT, SLOPE_N, SLOPE_S, SLOPE_STEEP, and SLOPE_W.

## ◆ GetTileZ()

int GetTileZ | ( | TileIndex | tile | ) |

Get bottom height of the tile.

Parameters

  tile | Tile to compute height of

Returns
  Minimum height of the tile

Definition at line 182 of file tile_map.cpp.

References MapMaxX(), MapMaxY(), min(), TileDiffXY(), TileHeight(), TileX(), and TileY().

Referenced by CheckNewIndustry_BubbleGen(), GetOtherTunnelEnd(), GetTilePixelZ(), CanalScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), and TileLoopClearAlps().

## ◆ IsTileFlat()

bool IsTileFlat | ( | TileIndex | tile,
|  | int * | h
| ) |  |

Check if a given tile is flat.

Parameters

  tile | Tile to check
  h | If not `NULL`, pointer to storage of z height (only if tile is flat)

Returns
  Whether the tile is flat

Definition at line 159 of file tile_map.cpp.

Referenced by CheckIfIndustryTilesAreFree(), CmdBuildBuoy(), CmdBuildShipDepot(), FindFurthestFromWater(), FindSpring(), SetWaterClassDependingOnSurroundings(), TownCanBePlacedHere(), and TryBuildTransmitter().

## ◆ TileHeightOutsideMap()

uint TileHeightOutsideMap | ( | int | x,
|  | int | y
| ) |  |

Returns the tile height for a coordinate outside map.

Such a height is needed for painting the area outside map using completely black tiles. The idea is descending to heightlevel 0 as fast as possible.

Parameters

  x | The X-coordinate (same unit as TileX).
  y | The Y-coordinate (same unit as TileY).

Returns
  The height in the same unit as TileHeight.

Definition at line 25 of file tile_map.cpp.

Referenced by GetTileMaxZ().