OpenTTD Source: src/tile_map.cpp File Reference

OpenTTD Source 15.3

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
static std::tuple< Slope, int > | GetTileSlopeGivenHeight (int hnorth, int hwest, int heast, int hsouth)
| Get a tile's slope given the height of its four corners.
std::tuple< Slope, int > | GetTileSlopeZ (TileIndex tile)
| Return the slope of a given tile inside the map.
std::tuple< Slope, int > | GetTilePixelSlopeOutsideMap (int x, int y)
| Return the slope of a given tile, also for tiles outside the map (virtual "black" tiles).
bool | IsTileFlat (TileIndex tile, int *h)
| Check if a given tile is flat.
int | GetTileZ (TileIndex tile)
| Get bottom height of the tile.
int | GetTileMaxZ (TileIndex t)
| Get top height of the tile inside the map.

## Detailed Description

Global tile accessors.

Definition in file tile_map.cpp.

## Function Documentation

## ◆ 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 136 of file tile_map.cpp.

References Map::MaxX(), Map::MaxY(), TileHeight(), TileX(), TileXY(), and TileY().

Referenced by AfterLoadGame(), AutoslopeCheckForEntranceEdge(), CheckBuildHouseSameZ(), CmdBuildBridge(), CmdBuildObject(), CmdPlaceHouse(), DoBuildLock(), DoClearBridge(), DrawRailCatenaryRailway(), DrawRoadBits(), DrawRoadTypeCatenary(), FindSpring(), FloodVehicleProc(), GetOtherAqueductEnd(), GetTerrainType(), GetTileMaxPixelZ(), IsStationBridgeAboveOk(), RiverMakeWider(), ShipTestUpDownOnLock(), TownCanBePlacedHere(), and TryBuildTownHouse().

## ◆ GetTilePixelSlopeOutsideMap()

std::tuple< Slope, int > GetTilePixelSlopeOutsideMap | ( | int | x,
|  | int | y
| ) |  |

Return the slope of a given tile, also for tiles outside the map (virtual "black" tiles).

Parameters

  x | X coordinate of the tile to compute slope of, may be outside the map.
  y | Y coordinate of the tile to compute slope of, may be outside the map.
  h | If not `nullptr`, pointer to storage of z height.

Returns
  Slope of the tile, except for the HALFTILE part, and the z height of the tile.

Definition at line 78 of file tile_map.cpp.

References GetTileSlopeGivenHeight(), TILE_HEIGHT, and TileHeightOutsideMap().

Referenced by IsMapSurroundedByWater(), and ViewportAddLandscape().

## ◆ GetTileSlopeGivenHeight()

static std::tuple< Slope, int > GetTileSlopeGivenHeight | ( | int | hnorth,
|  | int | hwest,
|  | int | heast,
|  | int | hsouth
| ) |  |
| static

Get a tile's slope given the height 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.

Returns
  The slope and the lowest height of the four corners.

Definition at line 23 of file tile_map.cpp.

References SLOPE_E, SLOPE_FLAT, SLOPE_N, SLOPE_S, SLOPE_STEEP, and SLOPE_W.

Referenced by GetTilePixelSlopeOutsideMap(), and GetTileSlopeZ().

## ◆ GetTileSlopeZ()

std::tuple< Slope, int > GetTileSlopeZ | ( | TileIndex | tile | ) |

Return the slope of a given tile inside the map.

Parameters

  tile | Tile to compute slope of

Returns
  Slope of the tile, except for the HALFTILE part, and the z height

Definition at line 55 of file tile_map.cpp.

References GetTileSlopeGivenHeight(), Map::MaxX(), Map::MaxY(), TileHeight(), TileX(), TileXY(), and TileY().

Referenced by CheckBuildableTile(), CmdBuildBridge(), CmdBuildObject(), CmdBuildTunnel(), GetBridgeHeight(), GetFoundationSlope(), GetOtherAqueductEnd(), GetTilePixelSlope(), GetTileSlope(), and RiverFlowsDown().

## ◆ 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 116 of file tile_map.cpp.

References Map::MaxX(), Map::MaxY(), TileHeight(), TileX(), TileXY(), and TileY().

Referenced by AfterLoadGame(), AmbientSoundEffectCallback(), CheckNewIndustry_BubbleGen(), CheckNewIndustry_Farm(), CheckNewIndustry_Forest(), CmdBuildBridge(), FlowRiver(), GenerateStationName(), GetOtherTunnelEnd(), GetTerrainType(), GetTilePixelZ(), CanalScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), GrowTownWithTunnel(), IsTunnelInWayDir(), LandInfoWindow::OnInit(), PlaceTreeAtSameHeight(), PlaceTreesRandomly(), RiverMakeWider(), ShipTestUpDownOnLock(), TileLoopClearAlps(), and TownCanBePlacedHere().

## ◆ IsTileFlat()

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

Check if a given tile is flat.

Parameters

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

Returns
  Whether the tile is flat

Definition at line 95 of file tile_map.cpp.

References Map::MaxX(), Map::MaxY(), TileHeight(), TileX(), TileXY(), and TileY().

Referenced by AfterLoadGame(), CheckIfIndustryTilesAreFree(), CmdBuildBuoy(), CmdBuildDock(), CmdBuildObject(), CmdBuildShipDepot(), CountConnectedSeaTiles(), DoBuildLock(), FindNearestGoodCoastalTownSpot(), FindSpring(), FlowRiver(), GrowTown(), IsValidRiverTerminusTile(), IsWateredTile(), RiverMakeWider(), SetWaterClassDependingOnSurroundings(), TownCanBePlacedHere(), TryBuildLightHouse(), TryBuildTransmitter(), and TryMakeRiverTerminus().