Functions

# tile_map.h File Reference

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

`#include "slope_type.h"`
`#include "map_func.h"`
`#include "core/bitmath_func.hpp"`
`#include "core/math_func.hpp"`
`#include "settings_type.h"`

Go to the source code of this file.

## Functions
static bool | AllowMoreHeightlevels ()
| Returns wether more than 16 height levels are allowed.
static uint | GetMaxTileHeight ()
| Returns the maximum heightlevel of a tile based on AllowMoreHeightlevels().
static uint | GetMaxSnowlineHeight ()
| Returns the maximum snowline height based on AllowMoreHeightlevels().
static uint | GetMaxTreelineHeight ()
| This function returns the maximum treeline height based on AllowMoreHeightlevels().
static uint | TileHeight (TileIndex tile)
| This function returns the height of the northern corner of a tile based on AllowMoreHeightlevels().
static uint | TileHeightOutsideMap (int x, int y)
| For a detailed description why we need this see discussion in GetTileMaxZOutsideMap in map_func.h.
static void | SetTileHeight (TileIndex tile, uint height)
| This function sets the height of the northern corner of a tile based on AllowMoreHeightlevels().
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.
static byte | GetAnimationFrame (TileIndex t)
| Get the current animation frame.
static void | SetAnimationFrame (TileIndex t, byte frame)
| Set a new animation frame.
Slope | GetTileSlope (TileIndex tile, uint *h)
| Return the slope of a given tile inside the map.
Slope | GetTileSlopeOutsideMap (int x, int y, uint *h)
| Return the slope of a given tile outside the map.
uint | GetTileZ (TileIndex tile)
| Get bottom height of the tile inside the map.
uint | GetTileZOutsideMap (int x, int y)
| Get bottom height of the tile outside the map.
uint | GetTileMaxZ (TileIndex tile)
| Get top height of the tile inside the map.
uint | GetTileMaxZOutsideMap (int x, int y)
| Returns TileMaxZ for points outside map.
static uint | TileHash (uint x, uint y)
| Calculate a hash value from a tile position.
static uint | TileHash2Bit (uint x, uint y)
| Get the last two bits of the TileHash from a tile position.

## Detailed Description

Map writing/reading functions for tiles.

Definition in file tile_map.h.

## Function Documentation

static bool AllowMoreHeightlevels | ( |  | ) | `[inline, static]`

Returns wether more than 16 height levels are allowed.

Basically, this returns the setting of the configuration variable allow_more_heightlevels. To avoid having to change multiple occurrences of the config variable in case some additional condition would get necessary, I introduced this function.

Returns:
  wether more than 16 height levels are allowed, based on allow_more_heightlevels and game mode.

Definition at line 31 of file tile_map.h.

References _settings_game, ConstructionSettings::allow_more_heightlevels, and GameSettings::construction.

Referenced by AfterLoadGame(), AllocateMap(), BuildLandLegend(), BuildOwnerLegend(), SmallMapWindow::DrawWidget(), GetMaxScrollOutsideMap(), GetMaxSnowlineHeight(), GetMaxTileHeight(), GetMaxTreelineHeight(), GetSmallMapContoursPixels(), GetSmallMapIndustriesPixels(), GetSmallMapOwnerPixels(), GetSmallMapRoutesPixels(), GetSmallMapStuckRoutesPixels(), GetSmallMapVehiclesPixels(), GrayscaleToMapHeights(), HeightMapNormalize(), SmallMapWindow::OnInit(), SmallMapWindow::OnPaint(), SetTileHeight(), TileHeight(), and CreateScenarioWindow::UpdateWidgetSize().

static byte GetAnimationFrame | ( | TileIndex | t | ) | `[inline, static]`

Get the current animation frame.

Parameters:

  | t | the tile

Precondition:
  IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION)

Returns:
  frame number

Definition at line 330 of file tile_map.h.

References _me, IsTileType(), TileExtended::m7, MP_HOUSE, MP_INDUSTRY, MP_OBJECT, and MP_STATION.

Referenced by AnimationBase< HouseAnimationBase, HouseSpec, Town, GetSimpleHouseCallback >::AnimateTile(), HouseGetVariable(), IncreaseAnimationStage(), IndustryGetVariable(), and ObjectGetVariable().

static uint GetMaxSnowlineHeight | ( |  | ) | `[inline, static]`

Returns the maximum snowline height based on AllowMoreHeightlevels().

This deduplicates a few if else statements in the code therefore it is usefull to have it here.

Returns:
  MAX_SNOWLINE_HEIGHT_EXTENDED or MAX_SNOWLINE_HEIGHT_OLD based on AllowMoreHeightlevels().

Definition at line 57 of file tile_map.h.

References AllowMoreHeightlevels(), MAX_SNOWLINE_HEIGHT_EXTENDED, and MAX_SNOWLINE_HEIGHT_OLD.

static uint GetMaxTileHeight | ( |  | ) | `[inline, static]`

Returns the maximum heightlevel of a tile based on AllowMoreHeightlevels().

This deduplicates a few if else statements in the code therefore it is usefull to have it here.

Returns:
  MAX_TILE_HEIGHT_EXTENDED or MAX_TILE_HEIGHT_OLD based on AllowMoreHeightlevels().

Definition at line 42 of file tile_map.h.

References AllowMoreHeightlevels(), MAX_TILE_HEIGHT_EXTENDED, and MAX_TILE_HEIGHT_OLD.

Referenced by CmdLevelLand(), CommonRaiseLowerBigLand(), FixSlopes(), GenerateTerrainPerlin(), CreateScenarioWindow::OnClick(), CreateScenarioWindow::OnPaint(), CreateScenarioWindow::OnQueryTextFinished(), SetTileHeight(), TerraformTileHeight(), TGPGetMaxAllowedHeight(), and TranslateXYToTileCoord().

static uint GetMaxTreelineHeight | ( |  | ) | `[inline, static]`

This function returns the maximum treeline height based on AllowMoreHeightlevels().

This deduplicates a few if else statements in the code therefore it is usefull to have it here.

Returns:
  MAX_TREELINE_HEIGHT_EXTENDED or MAX_TREELINE_HEIGHT_OLD based on AllowMoreHeightlevels().

Definition at line 72 of file tile_map.h.

References AllowMoreHeightlevels(), MAX_TREELINE_HEIGHT_EXTENDED, and MAX_TREELINE_HEIGHT_OLD.

uint 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 130 of file tile_map.cpp.

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

Referenced by AutoslopeCheckForEntranceEdge(), BuildTownHouse(), CheckBuildHouseSameZ(), CmdBuildBridge(), CmdBuildObject(), DoClearBridge(), DrawCatenary(), DrawCatenaryRailway(), DrawRoadBits(), DrawTramCatenary(), EnsureNoVehicleOnGround(), FloodVehicleProc(), AITile::GetMaxHeight(), GetOtherAqueductEnd(), GetTerrainType(), IsTunnelInWayDir(), and VpSelectTilesWithMethod().

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

Returns TileMaxZ for points outside map.

i.e. < 0 or > MapMax.

Example for the southeast corner: Consider point (x, MapMaxY()). It's west corner has height h1, its north corner has height h2. It's south and east corners are somewhere outside in the black.

Now, in terms of GetTileMaxZOutsideMap, any point (x, y) with x from above and y > MapMaxY() has west height h1 and north height h2. In order words, we continue the map into the black area.

Defining the height of the south corner of tile (MapMaxX(), MapMaxY()) as h3, all corners of all points (x,y) with x > MapMaxX and y > MapMaxY (south of the map) have height h3. For other areas outside the map respectively.

This function is needed for painting the black area properly, since the edges of map now can have height > 0.

Parameters:

  | x | any x coordinate.
  | y | any y coordinate.

Returns:
  For points p inside the map GetTileMaxZ(p) (i.e. the usual value) is returned. For points outside the map see description above.

Returns TileMaxZ for points outside map.

See also:
  Detailed description in header.

Parameters:

  | tile | Tile outside to compute height of.

Returns:
  Maximum height of the tile.

Definition at line 150 of file tile_map.cpp.

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

Referenced by GetViewportY().

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 company 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 258 of file tile_map.h.

References _m, GB(), IsTileType(), IsValidTile(), MP_HOUSE, and MP_INDUSTRY.

Referenced by AddSignalDependency(), AfterLoadCompanyStats(), AfterLoadGame(), AIDepotList::AIDepotList(), CheckAllowRemoveTunnelBridge(), CheckRemoveSignal(), CheckTileOwnership(), CmdBuildAircraft(), CmdBuildBridge(), CmdBuildObject(), CmdBuildRailVehicle(), CmdBuildRailWaypoint(), CmdBuildRoad(), CmdBuildRoadVehicle(), CmdBuildShip(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuildTrafficLights(), CmdConvertRail(), CmdDepotMassAutoReplace(), CmdInsertOrder(), CmdInsertSignalInstruction(), CmdModifySignalInstruction(), CmdRemoveSignalInstruction(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), CmdRemoveTrafficLights(), CmdRenameDepot(), CmdSetSignalSpeedLimit(), DeleteVisibleTrain(), DisasterTick_Big_Ufo(), DisasterTick_Zeppeliner(), DoClearBridge(), DoClearTunnel(), DrawTile_Road(), DrawWaterDepot(), ExploreSegment(), FixOwnerOfRailTrack(), AITile::GetOwner(), GetSmallMapOwnerPixels(), GetTrainForReservation(), IsInfraTileUsageAllowed(), IsTileOwner(), IsValidTileForWaypoint(), MakeBuoy(), MakeLock(), MoveBuoysToWaypoints(), MoveWaypointsToBaseStations(), ObjectGetVariable(), DepotWindow::OnClick(), OrderDestinationIsAllowed(), PayDailyTrackSharingFee(), ReallyClearObjectTile(), RemoveBuoy(), RemoveFromRailBaseStation(), RemoveLock(), RemoveRailStation(), RemoveRoad(), UpdateAllBlockSignals(), UpdateObjectColours(), VehiclePositionIsAllowed(), and Depot::~Depot().

Slope GetTileSlope | ( | TileIndex | tile,
|  | uint * | 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 59 of file tile_map.cpp.

References _settings_game, GameSettings::construction, ConstructionSettings::freeform_edges, GetTileSlopeGivenHeight(), MapMaxX(), MapMaxY(), MapSize(), TILE_HEIGHT, TileDiffXY(), TileHeight(), TileX(), and TileY().

Referenced by AfterLoadGame(), BuildTownHouse(), CanBuildHouseHere(), CanPlantTreesOnTile(), CheckBuildableTile(), CheckIfIndustryTilesAreFree(), CmdBuildBridge(), CmdBuildBuoy(), CmdBuildCanal(), CmdBuildDock(), CmdBuildLock(), CmdBuildObject(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdPlantTree(), CmdRemoveSingleRail(), DoBuildLock(), DoFloodTile(), DrawCatenaryRailway(), FindFurthestFromWater(), FloodHalftile(), GetBridgeHeight(), AITile::GetCornerHeight(), GetFloodingBehaviour(), GetFoundationSlope(), GetNearbyTileInformation(), GetOtherAqueductEnd(), AITunnel::GetOtherTunnelEnd(), AITile::GetSlope(), GetTownRoadGridElement(), GrowTown(), GrowTownWithBridge(), IsCrossableWater(), IsRoadAllowedHere(), IsTunnelInWayDir(), IsValidTileForWaypoint(), IsWateredTile(), ObjectGetVariable(), BuildDocksToolbarWindow::OnPlaceObject(), BuildDocksToolbarWindow::OnPlacePresize(), PerformIndustryTileSlopeCheck(), RemoveRoad(), SearchTileForStatue(), SetWaterClassDependingOnSurroundings(), CYapfCostBase::stSlopeCost(), and TownCanBePlacedHere().

Slope GetTileSlopeOutsideMap | ( | int | x,
|  | int | y,
|  | uint * | 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 83 of file tile_map.cpp.

References GetTileSlopeGivenHeight(), and TileHeightOutsideMap().

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 193 of file tile_map.h.

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

Referenced by AfterLoadCompanyStats(), AfterLoadGame(), AIVehicleList_Depot::AIVehicleList_Depot(), CanEnterTileOwnerCheck(), CanPlantTreesOnTile(), ChangeTileOwner(), CheckCanTerraformSurroundingTiles(), CleanUpRoadBits(), ClosestTownFromTile(), CmdBuildBridge(), CmdBuildRoad(), CmdBuildSingleRail(), CmdBuildVehicle(), CmdConvertRail(), CmdDeleteTown(), CmdLandscapeClear(), CmdPlantTree(), CmdRemoveSingleRail(), CmdRenameDepot(), CmdTerraformLand(), CopyPaste::CopyArea(), DoDryUp(), DoFloodTile(), DrawCatenary(), ExploreSegment(), GenerateRockyArea(), GetAnyRoadBits(), GetFloodingBehaviour(), GetFoundationSlope(), GetGrfSpecFeature(), GetNearbyTileInformation(), GetOrderTypeByTile(), GetRailTrackBitsUniversal(), GetReservedTrackbits(), GetTerrainType(), GetTileRailType(), GetTileTrackStatus(), GrowTownWithExtraHouse(), AITile::IsBuildable(), Depot::IsOfType(), IsTileType(), IsWateredTile(), NeighbourHasReachableRoad(), NPFMarkTile(), CYapfCostRailT< Types >::OneTileCost(), PlantTreesOnTile(), RemoveRoad(), SetWaterClassDependingOnSurroundings(), TryReserveRailTrack(), UnreserveRailTrack(), UpdateSignalsInBuffer(), VehicleEnterTile(), Depot::~Depot(), and Town::~Town().

uint GetTileZ | ( | TileIndex | tile | ) |

Get bottom height of the tile inside the map.

Parameters:

  | tile | Tile to compute height of

Returns:
  Minimum height of the tile

Definition at line 98 of file tile_map.cpp.

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

Referenced by CheckNewIndustry_BubbleGen(), CheckNewIndustry_Farm(), CheckNewIndustry_Forest(), DrawCatenaryOnTunnel(), AITile::GetMinHeight(), GetOtherTunnelEnd(), GetTerrainType(), IsCrossableWater(), IsTunnelInWayDir(), IsWaterCrossingTunnel(), MarkTileDirtyByTile(), LandInfoWindow::OnInit(), PlaceTreeAtSameHeight(), PlaceTreesRandomly(), and TileLoopClearAlps().

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

Get bottom height of the tile outside the map.

Parameters:

  | tile | Tile outside the map to compute height of.

Returns:
  Minimum height of the tile outside map.

Definition at line 115 of file tile_map.cpp.

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

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 318 of file tile_map.h.

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

Referenced by CheckNewIndustry_Lumbermill(), CheckNewIndustry_Plantation(), CheckNewIndustry_Water(), CmdPlantTree(), TownViewWindow::DrawWidget(), TownViewWindow::GetDesiredInfoHeight(), GetRandomTreeType(), GetTerrainType(), NeighbourIsDesert(), 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 294 of file tile_map.h.

References GetTileOwner().

Referenced by AfterLoadGame(), BuildObject(), CheckVehicleControlAllowed(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildObject(), CmdBuildTrafficLights(), CmdDeleteTown(), CmdInsertSignalInstruction(), CmdModifySignalInstruction(), CmdRemoveSignalInstruction(), CmdRemoveTrafficLights(), CmdSetSignalSpeedLimit(), CopyPaste::CopyArea(), DoClearBridge(), DoClearTunnel(), IsVehicleControlAllowed(), and Town::~Town().

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 230 of file tile_map.h.

References GetTileType().

Referenced by AddClearCounter(), AddClearDensity(), AddNearbyStation(), AddTreeCount(), AddTreeCounter(), AddTreeGrowth(), AdjustTileh(), AfterLoadGame(), AIDepotList::AIDepotList(), AITileList_IndustryAccepting::AITileList_IndustryAccepting(), AITileList_IndustryProducing::AITileList_IndustryProducing(), AITileList_StationType::AITileList_StationType(), Vehicle::BeginLoading(), CanBuildHouseHere(), CanEnterTile(), CheckFlatLandRailStation(), CheckFlatLandRoadStop(), CheckIfIndustryTilesAreFree(), CheckNextTrainTile(), CheckSubsidised(), ClearPathReservation(), ClrBitTunnelBridgeExit(), ClrBitTunnelBridgeSignal(), CmdBuildCanal(), CmdBuildDock(), CmdBuildLongRoad(), CmdBuildObject(), CmdBuildRailWaypoint(), CmdBuildRoad(), CmdBuildRoadStop(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuildTrafficLights(), CmdPlantTree(), CmdRemoveRoadStop(), CmdRemoveSingleSignal(), CmdRemoveTrafficLights(), CmdReverseTrainDirection(), CmdSignalTrackHelper(), CmdTerraformLand(), CmdTurnRoadVeh(), CMSAForest(), CMSAMine(), CMSATree(), CMSAWater(), Train::Crash(), DecHouseProcessingTime(), DeleteLastWagon(), DeleteVisibleTrain(), DisasterTick_Aircraft(), DoClearTownHouseHelper(), DoFloodTile(), DrawCatenaryRailway(), DrawTrafficLights(), ExtendTrainReservation(), FindFurthestFromWater(), FindIndustryToDeliver(), FindNearestEmptyLand(), FindNearIndustryName(), FindRailStationEnd(), FindStationsAroundTiles(), FindStationsNearby(), FixOldVehicles(), FollowReservation(), FollowTrainReservation(), FreeTrainTrackReservation(), GetAnimationFrame(), GetAxisForNewWaypoint(), GetCleanHouseType(), GetCleanIndustryGfx(), GetClearCounter(), GetClearDensity(), GetClosestWaterDistance(), AIIndustry::GetDockLocation(), GetDockOffset(), GetFenceSE(), GetFenceSW(), AIAirport::GetHangarOfAirport(), AIIndustry::GetHeliportLocation(), GetHouseAge(), GetHouseBuildingStage(), GetHouseConstructionTick(), GetHouseProcessingTime(), GetHouseRandomBits(), GetHouseTriggers(), GetIndustryAnimationLoop(), GetIndustryConstructionCounter(), GetIndustryConstructionStage(), GetIndustryGfx(), AIIndustry::GetIndustryID(), GetIndustryIDAtOffset(), GetIndustryIndex(), GetIndustryRandomBits(), GetIndustryTriggers(), GetIndustryType(), GetNearbyAirportTileInformation(), GetNearbyIndustryTileInformation(), GetNearbyObjectTileInformation(), GetNearbyTileInformation(), AIAirport::GetNumHangars(), GetObjectIDAtOffset(), GetObjectIndex(), GetObjectRandomBits(), GetObjectType(), GetOtherTunnelBridgeEnd(), AITile::GetOwner(), GetRailTileType(), GetRawClearGround(), GetRoadOwner(), GetRoadTileType(), AIRail::GetSignalType(), GetStationAround(), GetStationGfx(), AIStation::GetStationID(), GetStationIndex(), GetStationTileRandomBits(), GetStationType(), GetTileOwner(), GetTownIndex(), GetTrainForReservation(), GetTreeCount(), GetTreeCounter(), GetTreeDensity(), GetTreeGround(), GetTreeGrowth(), GetTreeType(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), GetWaterTileRandomBits(), GetWaterTileType(), GrowTown(), GrowTownAtRoad(), GrowTownInTile(), HasOnewaySignalBlockingTrackdir(), HasPbsSignalOnTrackdir(), HasStationTileRail(), HasTileWaterClass(), HasTrafficLights(), AITile::HasTreeOnTile(), HasTunnelBridgeReservation(), HasTunnelBridgeSnowOrDesert(), HasWormholeSignals(), HouseGetVariable(), IncHouseConstructionTick(), IncrementHouseAge(), IndustryGetVariable(), AIOrder::InsertOrder(), IsAirportTile(), AIAirport::IsAirportTile(), IsBridge(), IsBridgeTile(), IsBuoyTile(), AIMarine::IsBuoyTile(), AIMarine::IsCanalTile(), IsCoastTile(), AITile::IsCoastTile(), IsCompanyHQ(), AITile::IsDesertTile(), IsDockTile(), AIMarine::IsDockTile(), RoadStop::IsDriveThroughRoadStopContinuation(), AITile::IsFarmTile(), IsHangar(), IsHangarTile(), AIAirport::IsHangarTile(), IsHouseCompleted(), IsIndustryCompleted(), IsLevelCrossingTile(), AIMarine::IsLockTile(), IsNormalRoadTile(), IsOwnedLand(), IsOwnedLandTile(), IsPlainRailTile(), IsPossibleCrossing(), IsRailDepotTile(), IsRailStationTile(), AIRail::IsRailTile(), IsRailWaypointTile(), IsRoadDepotTile(), AIRoad::IsRoadDepotTile(), IsRoadStop(), IsRoadStopTile(), AIRoad::IsRoadTile(), AITile::IsRockTile(), AITile::IsRoughTile(), IsSafeWaitingPosition(), IsShipDepotTile(), IsSnowTile(), AITile::IsSnowTile(), AITile::IsStationTile(), IsStatue(), IsStatueTile(), IsTransmitterTile(), IsTunnel(), IsTunnelBridgeEntrance(), IsTunnelBridgeExit(), IsTunnelBridgeWithSignGreen(), IsTunnelInWayDir(), IsTunnelTile(), IsValidTile(), IsValidTileForWaypoint(), IsWaitingPositionFree(), AIMarine::IsWaterDepotTile(), IsWateredTile(), IsWaterTile(), AITile::IsWaterTile(), Vehicle::LeaveStation(), LoadUnloadVehicle(), MakeHouseTile(), MakeSingleHouseBigger(), MarkTileDirtyIfCanalOrRiver(), MayHaveBridgeAbove(), MoveBuoysToWaypoints(), MoveWaypointsToBaseStations(), ObjectGetVariable(), CYapfCostRailT< Types >::PfCalcCost(), ProcessOrders(), RemoveRoad(), AIRoad::RemoveRoadDepot(), AIRoad::RemoveRoadStation(), ResetHouseAge(), ResetIndustryConstructionStage(), RoadFindPathToDest(), StationRect::ScanForStationTiles(), SearchLumberMillTrees(), SearchNearbyHouseClass(), SearchNearbyHouseGRFID(), SearchNearbyHouseID(), SearchTileForStatue(), SetAnimationFrame(), SetBitTunnelBridgeExit(), SetBitTunnelBridgeSignal(), SetClearCounter(), SetClearDensity(), SetClearGroundDensity(), SetDefaultRailGui(), SetFenceSE(), SetFenceSW(), SetHouseCompleted(), SetHouseProcessingTime(), SetHouseRandomBits(), SetHouseTriggers(), SetHouseType(), SetIndustryAnimationLoop(), SetIndustryCompleted(), SetIndustryConstructionCounter(), SetIndustryConstructionStage(), SetIndustryGfx(), SetIndustryRandomBits(), SetIndustryTriggers(), SetRoadTypes(), SetStationGfx(), SetStationTileRandomBits(), SetTileOwner(), SetTownIndex(), SetTreeCounter(), SetTreeGroundDensity(), SetTreeGrowth(), SetTropicZone(), SetTunnelBridgeReservation(), SetTunnelBridgeSnowOrDesert(), TileLoop_Water(), TownCanBePlacedHere(), TrainCanLeaveTile(), UpdateAllBlockSignals(), UpdateHousesAndTowns(), UpdateLevelCrossing(), UpdateNearestTownForRoadTiles(), and UpdateStatusAfterSwap().

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 241 of file tile_map.h.

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

Referenced by AIRoad::_BuildRoadInternal(), AIRoad::_BuildRoadStationInternal(), AITileList::AddRectangle(), AITileList::AddTile(), AITileList_IndustryAccepting::AITileList_IndustryAccepting(), AITileList_IndustryProducing::AITileList_IndustryProducing(), AIRoad::AreRoadTilesConnected(), AIMarine::AreWaterTilesConnected(), AIAirport::BuildAirport(), AIBridge::BuildBridge(), AIMarine::BuildBuoy(), AIMarine::BuildCanal(), AICompany::BuildCompanyHQ(), AIMarine::BuildDock(), AIMarine::BuildLock(), AIRail::BuildNewGRFRailStation(), AIRail::BuildRail(), AIRail::BuildRailDepot(), AIRail::BuildRailStation(), AIRail::BuildRailTrack(), AIRail::BuildRailWaypoint(), AIRoad::BuildRoadDepot(), AISign::BuildSign(), AITunnel::BuildTunnel(), AIMarine::BuildWaterDepot(), AIRoad::CanBuildConnectedRoadPartsHere(), CheckIfIndustryTilesAreFree(), CleanUpRoadBits(), CmdBuildBridge(), CmdBuildRoadStop(), CmdBuildTunnel(), CmdModifySignalInstruction(), CmdRemoveRoadStop(), AIRail::ConvertRailType(), AITile::DemolishTile(), Disaster_CoalMine_Init(), DisasterTick_Big_Ufo(), DisasterTick_Submarine(), DisasterTick_Zeppeliner(), DoCommand(), DoCommandPInternal(), DrawTileSelectionRect(), AITile::GetCargoAcceptance(), AITile::GetCargoProduction(), AITile::GetClosestTown(), AITile::GetCornerHeight(), AIAirport::GetHangarOfAirport(), AIIndustry::GetIndustryID(), AITile::GetMaxHeight(), AITile::GetMinHeight(), AIAirport::GetNearestTown(), AIRoad::GetNeighbourRoadCount(), AIAirport::GetNoiseLevelIncrease(), AIAirport::GetNumHangars(), GetOrderTypeByTile(), GetOtherAqueductEnd(), AIBridge::GetOtherBridgeEnd(), AITunnel::GetOtherTunnelEnd(), AITile::GetOwner(), AITile::GetSlope(), AIStation::GetStationID(), GetTileOwner(), GrowTownInTile(), AITile::HasTransportType(), AITile::HasTreeOnTile(), AIAirport::IsAirportTile(), AIBridge::IsBridgeTile(), AITile::IsBuildable(), AIMarine::IsBuoyTile(), AIMarine::IsCanalTile(), AITile::IsCoastTile(), IsCrossableWater(), AITile::IsDesertTile(), AIMarine::IsDockTile(), AIRoad::IsDriveThroughRoadStationTile(), AITile::IsFarmTile(), AIAirport::IsHangarTile(), AIRail::IsLevelCrossingTile(), AIMarine::IsLockTile(), IsNeighborRoadTile(), AIRail::IsRailDepotTile(), AIRail::IsRailStationTile(), AIRail::IsRailTile(), AIRail::IsRailWaypointTile(), AIRoad::IsRoadDepotTile(), AIRoad::IsRoadStationTile(), AIRoad::IsRoadTile(), AITile::IsRockTile(), AITile::IsRoughTile(), AITile::IsSnowTile(), AITile::IsStationTile(), IsTunnelInWayDir(), AITunnel::IsTunnelTile(), IsWaterCrossingTunnel(), AIMarine::IsWaterDepotTile(), AITile::IsWaterTile(), NPFHash(), ObjectGetVariable(), AITile::PlantTree(), AITile::PlantTreeRectangle(), AIAirport::RemoveAirport(), AIMarine::RemoveBuoy(), AIMarine::RemoveCanal(), AIMarine::RemoveDock(), AIMarine::RemoveLock(), AIRail::RemoveRail(), AIRail::RemoveRailStationTileRectangle(), AIRail::RemoveRailTrack(), AIRail::RemoveRailWaypointTileRectangle(), AITileList::RemoveRectangle(), AIRoad::RemoveRoad(), AIRoad::RemoveRoadDepot(), AIRoad::RemoveRoadFull(), AIRoad::RemoveRoadStation(), AITileList::RemoveTile(), AIMarine::RemoveWaterDepot(), and SetTileOwner().

static void SetAnimationFrame | ( | TileIndex | t,
|  | byte | frame |
| ) |  |  | `[inline, static]`

Set a new animation frame.

Parameters:

  | t | the tile
  | frame | the new frame number

Precondition:
  IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION)

Definition at line 342 of file tile_map.h.

References _me, IsTileType(), TileExtended::m7, MP_HOUSE, MP_INDUSTRY, MP_OBJECT, and MP_STATION.

Referenced by AfterLoadGame(), AnimationBase< HouseAnimationBase, HouseSpec, Town, GetSimpleHouseCallback >::AnimateTile(), AnimationBase< HouseAnimationBase, HouseSpec, Town, GetSimpleHouseCallback >::ChangeAnimationFrame(), CmdBuildRailStation(), IncreaseAnimationStage(), and MakeHouseTile().

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

This function sets the height of the northern corner of a tile based on AllowMoreHeightlevels().

Parameters:

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

Precondition:
  tile < MapSize()
  heigth <= GetMaxTileHeight()

Definition at line 157 of file tile_map.h.

References _m, _map_heightdata, AllowMoreHeightlevels(), GetMaxTileHeight(), MapSize(), 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 278 of file tile_map.h.

References _m, IsTileType(), IsValidTile(), MP_HOUSE, MP_INDUSTRY, and SB().

Referenced by AfterLoadGame(), FixOwnerOfRailTrack(), MakeBridgeRamp(), MakeClear(), MakeField(), MakeLockTile(), MakeObject(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeWater(), and RemoveRoad().

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 211 of file tile_map.h.

References _m, _settings_game, GameSettings::construction, ConstructionSettings::freeform_edges, MapMaxX(), MapMaxY(), MapSize(), MP_VOID, SB(), TileX(), and TileY().

Referenced by MakeBridgeRamp(), MakeClear(), MakeField(), MakeHouseTile(), MakeIndustry(), MakeLockTile(), MakeObject(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeVoid(), and MakeWater().

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 305 of file tile_map.h.

References _m, IsTileType(), MapSize(), MP_VOID, SB(), and TROPICZONE_NORMAL.

Referenced by AfterLoadGame(), CmdPlantTree(), and GenerateDesertArea().

static uint TileHash | ( | uint | x,
|  | uint | y |
| ) |  |  | `[inline, static]`

Calculate a hash value from a tile position.

Parameters:

  | x | The X coordinate
  | y | The Y coordinate

Returns:
  The hash of the tile

Definition at line 391 of file tile_map.h.

Referenced by AfterLoadGame(), Town::InitializeLayout(), and TileHash2Bit().

static uint TileHash2Bit | ( | uint | x,
|  | uint | y |
| ) |  |  | `[inline, static]`

Get the last two bits of the TileHash from a tile position.

See also:
  TileHash()

Parameters:

  | x | The X coordinate
  | y | The Y coordinate

Returns:
  The last two bits from hash of the tile

Definition at line 409 of file tile_map.h.

References GB(), and TileHash().

Referenced by DrawTile_Town(), and HouseGetVariable().

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

This function returns the height of the northern corner of a tile based on AllowMoreHeightlevels().

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 90 of file tile_map.h.

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

Referenced by AfterLoadGame(), CalcHeightdiff(), CanPlantTreesOnTile(), CheckCanTerraformSurroundingTiles(), CheckIfCanLevelIndustryPlatform(), CheckNewIndustry_OilRig(), CmdBuildBridge(), CmdBuildCanal(), CmdLevelLand(), CmdPlantTree(), CmdTerraformLand(), CommonRaiseLowerBigLand(), CopyPaste::CopyArea(), FixSlopes(), GetSmallMapContoursPixels(), GetSmallMapIndustriesPixels(), GetSmallMapOwnerPixels(), GetTileHeightBelowAircraft(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), HeightmapCallback(), CopyPaste::internal_PasteArea(), MakeWorldScreenshot(), LandInfoWindow::OnInit(), CopyPaste::PasteLandscape(), TerraformGetHeightOfTile(), TileHeightOutsideMap(), 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 181 of file tile_map.h.

References TILE_HEIGHT, and TileHeight().

Referenced by TownViewWindow::DrawWidget(), TownViewWindow::GetDesiredInfoHeight(), and UpdateTownGrowRate().