# tile_map.h File Reference

Map writing/reading functions for tiles. More...

`#include "tile_type.h"`
`#include "slope_type.h"`
`#include "player_type.h"`
`#include "map_func.h"`
`#include "core/bitmath_func.hpp"`

Go to the source code of this file.

## Functions
static uint | TileHeight (TileIndex tile)
| Returns the height of a tile.
static void | SetTileHeight (TileIndex tile, uint height)
| Sets the height of a tile.
static uint | TilePixelHeight (TileIndex tile)
| Returns the height of a tile in pixels.
static TileType | GetTileType (TileIndex tile)
| Get the tiletype of a given tile.
static void | SetTileType (TileIndex tile, TileType type)
| Set the type of a tile.
static bool | IsTileType (TileIndex tile, TileType type)
| Checks if a tile is a give tiletype.
static bool | IsValidTile (TileIndex tile)
| Checks if a tile is valid.
static Owner | GetTileOwner (TileIndex tile)
| Returns the owner of a tile.
static void | SetTileOwner (TileIndex tile, Owner owner)
| Sets the owner of a tile.
static bool | IsTileOwner (TileIndex tile, Owner owner)
| Checks if a tile belongs to the given owner.
static void | SetTropicZone (TileIndex tile, TropicZone type)
| Set the tropic zone.
static TropicZone | GetTropicZone (TileIndex tile)
| Get the tropic zone.
Slope | GetTileSlope (TileIndex tile, uint *h)
uint | GetTileZ (TileIndex tile)
uint | GetTileMaxZ (TileIndex tile)

## Detailed Description

Map writing/reading functions for tiles.

Definition in file tile_map.h.

## Function Documentation

static Owner GetTileOwner | ( | TileIndex | tile | ) | `[inline, static]`

Returns the owner of a tile.

This function returns the owner of a tile. This cannot used for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY as no player owned any of these buildings.

Parameters:

  | tile | The tile to check

Returns:
  The owner of the tile

Precondition:
  IsValidTile(tile)

  The type of the tile must not be MP_HOUSE and MP_INDUSTRY

Definition at line 132 of file tile_map.h.

References _m, IsTileType(), IsValidTile(), Tile::m1, MP_HOUSE, and MP_INDUSTRY.

Referenced by CFollowTrackT< Ttr_type_, T90deg_turns_allowed_ >::CanEnterNewTile(), CmdBuildRoad(), CmdBuildTrainWaypoint(), CmdInsertOrder(), CmdRemoveFromRailroadStation(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), DisasterTick_Big_Ufo(), DisasterTick_Zeppeliner(), ExploreSegment(), GetSmallMapOwnerPixels(), IsTileOwner(), RemoveRoad(), RemoveTrainWaypoint(), and ShowDepotWindow().

static TileType GetTileType | ( | TileIndex | tile | ) | `[inline, static]`

Get the tiletype of a given tile.

Parameters:

  | tile | The tile to get the TileType

Returns:
  The tiletype of the tile

Precondition:
  tile < MapSize()

Definition at line 68 of file tile_map.h.

References _m, GB(), and MapSize().

Referenced by CanEnterTileOwnerCheck(), CanPlantTreesOnTile(), CleanUpRoadBits(), CmdBuildBridge(), CmdBuildRoad(), CmdBuildSingleRail(), CmdConvertRail(), CmdLandscapeClear(), CmdPlantTree(), CmdRemoveSingleRail(), CmdTerraformLand(), DoDryUp(), DoFloodTile(), DrawCatenary(), ExploreSegment(), GenerateDesertArea(), GenerateRockyArea(), GetAnyRoadBits(), GetFloodingBehaviour(), GetFoundationSlope(), GetNearbyTileInformation(), GetProductionAroundTiles(), GetRailTrackBitsUniversal(), GetSmallMapOwnerPixels(), GetTileRailType(), GetTileTrackStatus(), IsDepotTile(), IsTileType(), IsWateredTile(), NPFMarkTile(), PlantTreesOnTile(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_ >::QueryNewTileTrackStatus(), RemoveRoad(), SetWaterClassDependingOnSurroundings(), UpdateSignalsInBuffer(), and VehicleEnterTile().

static TropicZone GetTropicZone | ( | TileIndex | tile | ) | `[inline, static]`

Get the tropic zone.

Parameters:

  | tile | the tile to get the zone of

Precondition:
  tile < MapSize()

Returns:
  the zone type

Definition at line 191 of file tile_map.h.

References _m, GB(), and MapSize().

Referenced by GetRandomTreeType(), GetTerrainType(), PlaceTreesRandomly(), and UpdateTownGrowRate().

static bool IsTileOwner | ( | TileIndex | tile,
|  | Owner | owner |
| ) |  |  | `[inline, static]`

Checks if a tile belongs to the given owner.

Parameters:

  | tile | The tile to check
  | owner | The owner to check agains

Returns:
  True if a tile belongs the the given owner

Definition at line 168 of file tile_map.h.

References GetTileOwner().

Referenced by CanEnterTileOwnerCheck(), CmdBuildAircraft(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildRailVehicle(), CmdBuildRoadVeh(), CmdBuildShip(), CmdBuildSingleRail(), CmdDepotMassAutoReplace(), CmdPurchaseLandArea(), GrowTownAtRoad(), and RoadFindPathToDest().

static bool IsTileType | ( | TileIndex | tile,
|  | TileType | type |
| ) |  |  | `[inline, static]`

Checks if a tile is a give tiletype.

This function checks if a tile got the given tiletype.

Parameters:

  | tile | The tile to check
  | type | The type to check agains

Returns:
  true If the type matches agains the type of the tile

Definition at line 104 of file tile_map.h.

References GetTileType().

Referenced by AddClearCounter(), AddClearDensity(), AddTreeCount(), AddTreeCounter(), AddTreeGrowth(), AdjustTileh(), CanBuildHouseHere(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_ >::CanEnterNewTile(), CanEnterTile(), CanEnterTileOwnerCheck(), CheckFlatLandBelow(), CheckRailSlope(), CmdBuildCanal(), CmdBuildDock(), CmdBuildLongRoad(), CmdBuildRoad(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuildTown(), CmdBuildTrainWaypoint(), CmdPlantTree(), CmdRemoveFromRailroadStation(), CmdRemoveRoadStop(), CmdRemoveSingleSignal(), CmdRenameWaypoint(), CmdSignalTrackHelper(), CmdTurnRoadVeh(), CMSAForest(), CMSAMine(), CMSATree(), CMSAWater(), DeallocateSpecFromStation(), DecHouseProcessingTime(), DeleteLastWagon(), DisasterTick_Airplane(), DisasterTick_Big_Ufo(), DisasterTick_Helicopter(), DisasterTick_Zeppeliner(), DoFloodTile(), DrawCatenaryRailway(), FindStationsAroundIndustryTile(), FloodVehicles(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_ >::FollowTileExit(), GetAcceptanceAroundTiles(), GetAnyRoadTrackBits(), GetClearCounter(), GetClearDensity(), GetClearGround(), GetClosestWaterDistance(), GetCompanyHQSection(), GetCompanyHQSize(), GetFenceSE(), GetFenceSW(), GetHouseAnimationFrame(), GetHouseBuildingStage(), GetHouseConstructionTick(), GetHouseConstructionYear(), GetHouseProcessingTime(), GetHouseRandomBits(), GetHouseTriggers(), GetHouseType(), GetIndustryAnimationLoop(), GetIndustryAnimationState(), GetIndustryConstructionCounter(), GetIndustryConstructionStage(), GetIndustryGfx(), GetIndustryIDAtOffset(), GetIndustryIndex(), GetIndustryRandomBits(), GetIndustryTriggers(), GetIndustryType(), GetNearbyIndustryTileInformation(), GetNearbyTileInformation(), GetOtherTunnelBridgeEnd(), GetRailTileType(), GetTileOwner(), GetTownIndex(), GetTrainAcceleration(), GetTreeCount(), GetTreeCounter(), GetTreeDensity(), GetTreeGround(), GetTreeGrowth(), GetTreeType(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), GetUnmovableType(), GetWaypointByTile(), GrowTown(), GrowTownAtRoad(), GrowTownInTile(), GrowTownWithExtraHouse(), HasTunnelBridgeSnowOrDesert(), HouseGetVariable(), IncHouseConstructionTick(), IndustryGetVariable(), IsBridge(), IsBridgeTile(), IsCompanyHQ(), IsHangar(), IsHouseCompleted(), IsIndustryCompleted(), IsOwnedLand(), IsOwnedLandTile(), IsPossibleCrossing(), IsStatue(), IsStatueTile(), IsTileDepotType(), IsTransmitterTile(), IsTunnel(), IsTunnelTile(), IsValidTile(), LoadUnloadVehicle(), MakeHouseTile(), MakeSingleHouseBigger(), MarkTileDirtyIfCanalOrRiver(), MayHaveBridgeAbove(), ProcessTrainOrder(), RemoveRoad(), RemoveTrainWaypoint(), ResetIndustryConstructionStage(), RoadFindPathToDest(), SearchLumberMillTrees(), SetClearCounter(), SetClearGroundDensity(), SetFenceSE(), SetFenceSW(), SetHouseAnimationFrame(), SetHouseCompleted(), SetHouseProcessingTime(), SetHouseRandomBits(), SetHouseTriggers(), SetHouseType(), SetIndustryAnimationLoop(), SetIndustryAnimationState(), SetIndustryCompleted(), SetIndustryConstructionCounter(), SetIndustryConstructionStage(), SetIndustryGfx(), SetIndustryRandomBits(), SetIndustryTriggers(), SetTileOwner(), SetTownIndex(), SetTreeCount(), SetTreeCounter(), SetTreeGroundDensity(), SetTreeGrowth(), SetTunnelBridgeSnowOrDesert(), TileLoop_Water(), TrainCanLeaveTile(), UpdateHousesAndTowns(), and YapfFindNearestRoadDepot().

static bool IsValidTile | ( | TileIndex | tile | ) | `[inline, static]`

Checks if a tile is valid.

Parameters:

  | tile | The tile to check

Returns:
  True if the tile is on the map and not one of MP_VOID.

Definition at line 115 of file tile_map.h.

References IsTileType(), MapSize(), and MP_VOID.

Referenced by DisasterTick_Submarine(), DisasterTick_Zeppeliner(), DoCommand(), DoCommandP(), GetTileOwner(), NPFHash(), and SetTileOwner().

static void SetTileHeight | ( | TileIndex | tile,
|  | uint | height |
| ) |  |  | `[inline, static]`

Sets the height of a tile.

This function sets the height of the northern corner of a tile.

Parameters:

  | tile | The tile to change the height
  | height | The new height value of the tile

Precondition:
  tile < MapSize()

  heigth <= MAX_TILE_HEIGHT

Definition at line 41 of file tile_map.h.

References _m, MapSize(), MAX_TILE_HEIGHT, and SB().

Referenced by CmdTerraformLand(), FixSlopes(), FlatEmptyWorld(), GrayscaleToMapHeights(), MakeVoid(), and TgenSetTileHeight().

static void SetTileOwner | ( | TileIndex | tile,
|  | Owner | owner |
| ) |  |  | `[inline, static]`

Sets the owner of a tile.

This function sets the owner status of a tile. Note that you cannot set a owner for tiles of type MP_HOUSE, MP_VOID and MP_INDUSTRY.

Parameters:

  | tile | The tile to change the owner status.
  | owner | The new owner.

Precondition:
  IsValidTile(tile)

  The type of the tile must not be MP_HOUSE and MP_INDUSTRY

Definition at line 152 of file tile_map.h.

References _m, IsTileType(), IsValidTile(), Tile::m1, MP_HOUSE, and MP_INDUSTRY.

Referenced by GrowTownAtRoad(), MakeBridgeRamp(), MakeClear(), MakeField(), MakeRailTunnel(), MakeRoadTunnel(), MakeTree(), and MakeUnmovable().

static void SetTileType | ( | TileIndex | tile,
|  | TileType | type |
| ) |  |  | `[inline, static]`

Set the type of a tile.

This functions sets the type of a tile. If the type MP_VOID is selected the tile must be at the south-west or south-east edges of the map and vice versa.

Parameters:

  | tile | The tile to save the new type
  | type | The type to save

Precondition:
  tile < MapSize()

  type MP_VOID <=> tile is on the south-east or south-west edge.

Definition at line 86 of file tile_map.h.

References _m, MapMaxX(), MapMaxY(), MapSize(), MP_VOID, SB(), TileX(), and TileY().

Referenced by MakeBridgeRamp(), MakeClear(), MakeField(), MakeHouseTile(), MakeIndustry(), MakeRailTunnel(), MakeRoadTunnel(), MakeTree(), MakeUnmovable(), and MakeVoid().

static void SetTropicZone | ( | TileIndex | tile,
|  | TropicZone | type |
| ) |  |  | `[inline, static]`

Set the tropic zone.

Parameters:

  | tile | the tile to set the zone of
  | type | the new type

Precondition:
  tile < MapSize()

Definition at line 179 of file tile_map.h.

References _m, MapSize(), and SB().

Referenced by CmdPlantTree(), and GenerateDesertArea().

static uint TileHeight | ( | TileIndex | tile | ) | `[inline, static]`

Returns the height of a tile.

This function returns the height of the northern corner of a tile. This is saved in the global map-array. It does not take affect by any slope-data of the tile.

Parameters:

  | tile | The tile to get the height from

Returns:
  the height of the tile

Precondition:
  tile < MapSize()

Definition at line 25 of file tile_map.h.

References _m, GB(), and MapSize().

Referenced by CalcHeightdiff(), CheckIfCanLevelIndustryPlatform(), CmdBuildCanal(), CmdLevelLand(), CmdTerraformLand(), CommonRaiseLowerBigLand(), FixSlopes(), GetSmallMapContoursPixels(), TerraformGetHeightOfTile(), and TilePixelHeight().

static uint TilePixelHeight | ( | TileIndex | tile | ) | `[inline, static]`

Returns the height of a tile in pixels.

This function returns the height of the northern corner of a tile in pixels.

Parameters:

  | tile | The tile to get the height

Returns:
  The height of the tile in pixel

Definition at line 56 of file tile_map.h.

References TILE_HEIGHT, and TileHeight().

Referenced by UpdateTownGrowRate().