OpenTTD Source: src/tile_map.cpp File Reference

OpenTTD Source 13.1

Functions
tile_map.cpp File Reference
`#include "stdafx.h"`
`#include "tile_map.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Functions
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, also for tiles outside the map (virtual "black" tiles). 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 | GetTileMaxZ (TileIndex t)
| Get top height of the tile inside the map. More...

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

References MapMaxX(), MapMaxY(), TileHeight(), TileX(), TileXY(), and TileY().

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

## ◆ GetTilePixelSlopeOutsideMap()

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

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.

Definition at line 82 of file tile_map.cpp.

## ◆ 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 `nullptr`, pointer to storage of z height

Returns
  Slope of the tile, except for the HALFTILE part

Definition at line 59 of file tile_map.cpp.

References GetTileSlopeGivenHeight(), MapMaxX(), MapMaxY(), TileHeight(), TileX(), TileXY(), and TileY().

Referenced by BuildTownHouse(), CanBuildHouseHere(), CanPlantTreesOnTile(), CheckBuildableTile(), CheckIfIndustryTileSlopes(), CmdBuildLock(), CmdBuildRoadDepot(), CmdBuildTrainDepot(), FlowsDown(), GetBridgeHeight(), GetFloodingBehaviour(), GetFoundationSlope(), GetOtherAqueductEnd(), GetTilePixelSlope(), StationScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), GrowTownWithBridge(), GrowTownWithTunnel(), BuildDocksToolbarWindow::OnPlacePresize(), PerformStationTileSlopeCheck(), RedundantBridgeExistsNearby(), RiverMakeWider(), SearchTileForStatue(), ShipTestUpDownOnLock(), 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 24 of file tile_map.cpp.

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

Referenced by GetTileSlope().

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

References MapMaxX(), MapMaxY(), TileHeight(), TileX(), TileXY(), and TileY().

Referenced by CheckNewIndustry_BubbleGen(), FlowRiver(), GetOtherTunnelEnd(), GetTilePixelZ(), CanalScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), GrowTownWithTunnel(), IsTunnelInWayDir(), RiverMakeWider(), ShipTestUpDownOnLock(), and TileLoopClearAlps().

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

References MapMaxX(), MapMaxY(), TileHeight(), TileX(), TileXY(), and TileY().

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