OpenTTD Source: Tile Class Reference

OpenTTD Source 15.3

Data Structures | Public Member Functions | Private Attributes | Static Private Attributes | Friends
Tile Class Reference

Wrapper class to abstract away the way the tiles are stored. More...

`#include <map_func.h>`

## Data Structures
struct | TileBase
| Data that is stored per tile. More...
struct | TileExtended
| Data that is stored per tile. More...

## Public Member Functions
| Tile (TileIndex tile)
| Create the tile wrapper for the given tile.
| Tile (uint tile)
| Create the tile wrapper for the given tile.
constexpr | operator TileIndex () const
| Implicit conversion to the TileIndex.
constexpr | operator uint () const
| Implicit conversion to the uint for bounds checking.
uint8_t & | type ()
| The type (bits 4..7), bridges (2..3), rainforest/desert (0..1)
uint8_t & | height ()
| The height of the northern corner.
uint8_t & | m1 ()
| Primarily used for ownership information.
uint16_t & | m2 ()
| Primarily used for indices to towns, industries and stations.
uint8_t & | m3 ()
| General purpose.
uint8_t & | m4 ()
| General purpose.
uint8_t & | m5 ()
| General purpose.
uint8_t & | m6 ()
| General purpose.
uint8_t & | m7 ()
| Primarily used for newgrf support.
uint16_t & | m8 ()
| General purpose.

## Private Attributes
TileIndex | tile
| The tile to access the map data for.

## Static Private Attributes
static std::unique_ptr< TileBase[]> | base_tiles
| Pointer to the tile-array.
static std::unique_ptr< TileExtended[]> | extended_tiles
| Pointer to the extended tile-array.

## Friends
struct | Map

## Detailed Description

Wrapper class to abstract away the way the tiles are stored.

It is intended to be used to access the "map" data of a single tile.

The wrapper is expected to be fully optimized away by the compiler, even with low optimization levels except when completely disabling it.

Definition at line 25 of file map_func.h.

## Constructor & Destructor Documentation

## ◆ Tile() [1/2]

Tile::Tile | ( | TileIndex | tile | ) |
| inline

Create the tile wrapper for the given tile.

Parameters

  tile | The tile to access the map for.

Definition at line 64 of file map_func.h.

## ◆ Tile() [2/2]

Tile::Tile | ( | uint | tile | ) |
| inline

Create the tile wrapper for the given tile.

Parameters

  tile | The tile to access the map for.

Definition at line 70 of file map_func.h.

## Member Function Documentation

## ◆ height()

uint8_t & Tile::height | ( |  | ) |
| inline

The height of the northern corner.

Look at docs/landscape.html for the exact meaning of the data.

Parameters

  tile | The tile to get the height for.

Returns
  reference to the byte holding the height.

Definition at line 101 of file map_func.h.

References base_tiles.

Referenced by MAPHChunkHandler::Load(), MAPHChunkHandler::Save(), SetTileHeight(), and TileHeight().

## ◆ m1()

uint8_t & Tile::m1 | ( |  | ) |
| inline

Primarily used for ownership information.

Look at docs/landscape.html for the exact meaning of the data.

Parameters

  tile | The tile to get the data for.

Returns
  reference to the byte holding the data.

Definition at line 113 of file map_func.h.

References base_tiles.

Referenced by GetHouseRandomBits(), GetIndustryConstructionCounter(), GetIndustryConstructionStage(), GetRoadOwner(), GetTileOwner(), GetWaterClass(), IsDockingTile(), IsIndustryCompleted(), MAPOChunkHandler::Load(), MakeClear(), MakeField(), MakeHouseTile(), MakeIndustry(), MakeVoid(), ResetIndustryConstructionStage(), MAPOChunkHandler::Save(), SetDockingTile(), SetHouseRandomBits(), SetIndustryCompleted(), SetIndustryConstructionCounter(), SetIndustryConstructionStage(), SetRoadOwner(), SetTileOwner(), and SetWaterClass().

## ◆ m2()

uint16_t & Tile::m2 | ( |  | ) |
| inline

Primarily used for indices to towns, industries and stations.

Look at docs/landscape.html for the exact meaning of the data.

Parameters

  tile | The tile to get the data for.

Returns
  reference to the uint16_t holding the data.

Definition at line 125 of file map_func.h.

References base_tiles.

Referenced by AfterLoadGame(), GetDepotIndex(), GetIndustryIndex(), GetIndustryIndexOfField(), GetObjectIndex(), GetRailReservationTrackBits(), GetStationIndex(), GetTownIndex(), GetTreeDensity(), GetTreeGround(), MAP2ChunkHandler::Load(), MakeBridgeRamp(), MakeClear(), MakeField(), MakeHouseTile(), MakeIndustry(), MakeLockTile(), MakeObject(), MakeRailDepot(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeVoid(), MakeWater(), MoveWaypointsToBaseStations(), MAP2ChunkHandler::Save(), SetIndustryIndexOfField(), SetTownIndex(), SetTrackReservation(), SetTreeGroundDensity(), and SetWaterClassDependingOnSurroundings().

## ◆ m3()

uint8_t & Tile::m3 | ( |  | ) |
| inline

General purpose.

Look at docs/landscape.html for the exact meaning of the data.

Parameters

  tile | The tile to get the data for.

Returns
  reference to the byte holding the data.

Definition at line 137 of file map_func.h.

References base_tiles.

Referenced by CanStationTileHavePylons(), CanStationTileHaveWires(), ClearSnow(), FixOwnerOfRailTrack(), GetFence(), GetFieldType(), GetHouseRandomTriggers(), GetIndustryRandomBits(), GetObjectRandomBits(), GetPresentSignals(), GetRoadBits(), GetRoadOwner(), GetRoadWaypointRoadside(), GetStationTileRandomBits(), GetTreeType(), IsHouseCompleted(), IsHouseProtected(), IsNonFloodingWaterTile(), IsSnowTile(), IsStationTileBlocked(), M3LOChunkHandler::Load(), MakeBridgeRamp(), MakeClear(), MakeField(), MakeHouseTile(), MakeLockTile(), MakeObject(), MakeRailDepot(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeSnow(), MakeStation(), MakeTree(), MakeVoid(), MakeWater(), MoveWaypointsToBaseStations(), M3LOChunkHandler::Save(), SetFence(), SetFieldType(), SetHouseCompleted(), SetHouseProtected(), SetHouseRandomTriggers(), SetIndustryRandomBits(), SetNonFloodingWaterTile(), SetPresentSignals(), SetRoadBits(), SetRoadOwner(), SetRoadWaypointRoadside(), SetStationTileBlocked(), SetStationTileHavePylons(), SetStationTileHaveWires(), and SetStationTileRandomBits().

## ◆ m4()

uint8_t & Tile::m4 | ( |  | ) |
| inline

General purpose.

Look at docs/landscape.html for the exact meaning of the data.

Parameters

  tile | The tile to get the data for.

Returns
  reference to the byte holding the data.

Definition at line 149 of file map_func.h.

References base_tiles.

Referenced by GetCustomStationSpecIndex(), GetFence(), GetIndustryAnimationLoop(), GetSignalStates(), GetWaterTileRandomBits(), IsCustomStationSpecIndex(), M3HIChunkHandler::Load(), MakeBridgeRamp(), MakeClear(), MakeField(), MakeIndustry(), MakeLockTile(), MakeObject(), MakeRailDepot(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeVoid(), MakeWater(), MoveWaypointsToBaseStations(), M3HIChunkHandler::Save(), SetCustomStationSpecIndex(), SetFence(), SetIndustryAnimationLoop(), SetRoadTypeRoad(), and SetSignalStates().

## ◆ m5()

uint8_t & Tile::m5 | ( |  | ) |
| inline

General purpose.

Look at docs/landscape.html for the exact meaning of the data.

Parameters

  tile | The tile to get the data for.

Returns
  reference to the byte holding the data.

Definition at line 161 of file map_func.h.

References base_tiles.

Referenced by AddClearCounter(), AddClearDensity(), AddTreeCount(), AddTreeGrowth(), FixOwnerOfRailTrack(), GetCleanIndustryGfx(), GetClearCounter(), GetClearDensity(), GetClearGround(), GetCrossingRoadAxis(), GetDisallowedRoadDirections(), GetHouseAge(), GetHouseBuildingStage(), GetHouseConstructionTick(), GetLockDirection(), GetLockPart(), GetObjectIndex(), GetRailDepotDirection(), GetRailTileType(), GetRoadBits(), GetRoadDepotDirection(), GetRoadTileType(), GetShipDepotAxis(), GetShipDepotPart(), GetStationGfx(), GetTrackBits(), GetTreeCount(), GetTreeGrowth(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), GetWaterTileType(), HasCrossingReservation(), HasDepotReservation(), HasTunnelBridgeReservation(), IncHouseConstructionTick(), IncrementHouseAge(), IsBridge(), IsCrossingBarred(), IsTunnel(), MAP5ChunkHandler::Load(), MakeBridgeRamp(), MakeHouseTile(), MakeLockTile(), MakeObject(), MakeRailDepot(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeVoid(), MakeWater(), MoveWaypointsToBaseStations(), ResetHouseAge(), MAP5ChunkHandler::Save(), SetClearCounter(), SetClearDensity(), SetClearGroundDensity(), SetCrossingBarred(), SetCrossingReservation(), SetDepotReservation(), SetDisallowedRoadDirections(), SetHasSignals(), SetIndustryGfx(), SetRailDepotExitDirection(), SetRoadBits(), SetRoadDepotExitDirection(), SetStationGfx(), SetTrackBits(), SetTreeGrowth(), SetTunnelBridgeReservation(), and SetWaterTileType().

## ◆ m6()

uint8_t & Tile::m6 | ( |  | ) |
| inline

General purpose.

Look at docs/landscape.html for the exact meaning of the data.

Parameters

  tile | The tile to get the data for.

Returns
  reference to the byte holding the data.

Definition at line 173 of file map_func.h.

References extended_tiles.

Referenced by DecHouseProcessingTime(), FixOwnerOfRailTrack(), GetAnimatedTileState(), GetBridgeType(), GetCleanIndustryGfx(), GetFence(), GetHouseProcessingTime(), GetIndustryRandomTriggers(), GetLiftPosition(), GetRoadside(), GetStationType(), HasStationReservation(), MAPEChunkHandler::Load(), MakeBridgeRamp(), MakeClear(), MakeField(), MakeIndustry(), MakeLockTile(), MakeObject(), MakeRailDepot(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeVoid(), MakeWater(), MoveBuoysToWaypoints(), MAPEChunkHandler::Save(), SetAnimatedTileState(), SetFence(), SetHouseProcessingTime(), SetIndustryGfx(), SetIndustryRandomTriggers(), SetLiftPosition(), SetRailStationReservation(), and SetRoadside().

## ◆ m7()

uint8_t & Tile::m7 | ( |  | ) |
| inline

Primarily used for newgrf support.

Look at docs/landscape.html for the exact meaning of the data.

Parameters

  tile | The tile to get the data for.

Returns
  reference to the byte holding the data.

Definition at line 185 of file map_func.h.

References extended_tiles.

Referenced by FixOwnerOfRailTrack(), GetAnimationFrame(), GetLiftDestination(), GetRoadOwner(), HaltLift(), HasTunnelBridgeSnowOrDesert(), IncreaseRoadWorksCounter(), IsOnSnowOrDesert(), LiftHasDestination(), MAP7ChunkHandler::Load(), MakeBridgeRamp(), MakeClear(), MakeField(), MakeIndustry(), MakeLockTile(), MakeObject(), MakeRailDepot(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeVoid(), MakeWater(), MAP7ChunkHandler::Save(), SetAnimationFrame(), SetLiftDestination(), SetRoadOwner(), SetTunnelBridgeSnowOrDesert(), TerminateRoadWorks(), and ToggleSnowOrDesert().

## ◆ m8()

uint16_t & Tile::m8 | ( |  | ) |
| inline

General purpose.

Look at docs/landscape.html for the exact meaning of the data.

Parameters

  tile | The tile to get the data for.

Returns
  reference to the uint16_t holding the data.

Definition at line 197 of file map_func.h.

References extended_tiles.

Referenced by GetCleanHouseType(), GetCustomRoadStopSpecIndex(), GetRailType(), IsCustomRoadStopSpecIndex(), IsRoadWaypointOnSnowOrDesert(), MAP8ChunkHandler::Load(), MakeBridgeRamp(), MakeClear(), MakeField(), MakeHouseTile(), MakeIndustry(), MakeLockTile(), MakeObject(), MakeRailDepot(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeVoid(), MakeWater(), MAP8ChunkHandler::Save(), SetCustomRoadStopSpecIndex(), SetHouseType(), SetRailType(), SetRoadTypeTram(), and ToggleRoadWaypointOnSnowOrDesert().

## ◆ operator TileIndex()

constexpr Tile::operator TileIndex | ( |  | ) | const
| inlineconstexpr

Implicit conversion to the TileIndex.

Definition at line 75 of file map_func.h.

References tile.

## ◆ operator uint()

constexpr Tile::operator uint | ( |  | ) | const
| inlineconstexpr

Implicit conversion to the uint for bounds checking.

Definition at line 80 of file map_func.h.

## ◆ type()

uint8_t & Tile::type | ( |  | ) |
| inline

The type (bits 4..7), bridges (2..3), rainforest/desert (0..1)

Look at docs/landscape.html for the exact meaning of the data.

Parameters

  tile | The tile to get the data for.

Returns
  reference to the byte holding the data.

Definition at line 89 of file map_func.h.

References base_tiles.

Referenced by ClearSingleBridgeMiddle(), GetBridgeAxis(), GetTileType(), GetTropicZone(), IsBridgeAbove(), MAPTChunkHandler::Load(), MAPTChunkHandler::Save(), SetBridgeMiddle(), SetTileType(), and SetTropicZone().

## Friends And Related Symbol Documentation

## ◆ Map

friend struct Map
| friend

Definition at line 27 of file map_func.h.

## Field Documentation

## ◆ base_tiles

std::unique_ptr< Tile::TileBase[]> Tile::base_tiles
| staticprivate

Pointer to the tile-array.

Base tiles of the map.

Definition at line 54 of file map_func.h.

Referenced by Map::Allocate(), height(), Map::IsInitialized(), m1(), m2(), m3(), m4(), m5(), and type().

## ◆ extended_tiles

std::unique_ptr< Tile::TileExtended[]> Tile::extended_tiles
| staticprivate

Pointer to the extended tile-array.

Extended tiles of the map.

Definition at line 55 of file map_func.h.

Referenced by Map::Allocate(), m6(), m7(), and m8().

## ◆ tile

TileIndex Tile::tile
| private

The tile to access the map data for.

Definition at line 57 of file map_func.h.

Referenced by operator TileIndex().

The documentation for this class was generated from the following files:

- src/map_func.h
- src/map.cpp