OpenTTD Source
1.11.2
|
#include "slope_type.h"
#include "map_func.h"
#include "core/bitmath_func.hpp"
#include "settings_type.h"
Go to the source code of this file.
Functions | |
static uint | TileHeight (TileIndex tile) |
Returns the height of a tile. More... | |
static uint | TileHeightOutsideMap (int x, int y) |
Returns the height of a tile, also for tiles outside the map (virtual "black" tiles). More... | |
static void | SetTileHeight (TileIndex tile, uint height) |
Sets the height of a tile. More... | |
static uint | TilePixelHeight (TileIndex tile) |
Returns the height of a tile in pixels. More... | |
static uint | TilePixelHeightOutsideMap (int x, int y) |
Returns the height of a tile in pixels, also for tiles outside the map (virtual "black" tiles). More... | |
static TileType | GetTileType (TileIndex tile) |
Get the tiletype of a given tile. More... | |
static bool | IsInnerTile (TileIndex tile) |
Check if a tile is within the map (not a border) More... | |
static void | SetTileType (TileIndex tile, TileType type) |
Set the type of a tile. More... | |
static bool | IsTileType (TileIndex tile, TileType type) |
Checks if a tile is a given tiletype. More... | |
static bool | IsValidTile (TileIndex tile) |
Checks if a tile is valid. More... | |
static Owner | GetTileOwner (TileIndex tile) |
Returns the owner of a tile. More... | |
static void | SetTileOwner (TileIndex tile, Owner owner) |
Sets the owner of a tile. More... | |
static bool | IsTileOwner (TileIndex tile, Owner owner) |
Checks if a tile belongs to the given owner. More... | |
static void | SetTropicZone (TileIndex tile, TropicZone type) |
Set the tropic zone. More... | |
static TropicZone | GetTropicZone (TileIndex tile) |
Get the tropic zone. More... | |
static byte | GetAnimationFrame (TileIndex t) |
Get the current animation frame. More... | |
static void | SetAnimationFrame (TileIndex t, byte frame) |
Set a new animation frame. More... | |
Slope | GetTileSlope (TileIndex tile, int *h=nullptr) |
Return the slope of a given tile inside the map. More... | |
int | GetTileZ (TileIndex tile) |
Get bottom height of the tile. More... | |
int | GetTileMaxZ (TileIndex tile) |
Get top height of the tile inside the map. More... | |
bool | IsTileFlat (TileIndex tile, int *h=nullptr) |
Check if a given tile is flat. More... | |
static Slope | GetTilePixelSlope (TileIndex tile, int *h) |
Return the slope of a given tile. 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... | |
static int | GetTilePixelZ (TileIndex tile) |
Get bottom height of the tile. More... | |
static int | GetTileMaxPixelZ (TileIndex tile) |
Get top height of the tile. More... | |
static uint | TileHash (uint x, uint y) |
Calculate a hash value from a tile position. More... | |
static uint | TileHash2Bit (uint x, uint y) |
Get the last two bits of the TileHash from a tile position. More... | |
Map writing/reading functions for tiles.
Definition in file tile_map.h.
|
inlinestatic |
Get the current animation frame.
t | the tile |
Definition at line 250 of file tile_map.h.
References _me, IsTileType(), TileExtended::m7, MP_HOUSE, MP_INDUSTRY, MP_OBJECT, and MP_STATION.
Referenced by AnimationBase< IndustryAnimationBase, IndustryTileSpec, Industry, int, GetSimpleIndustryCallback >::AnimateTile(), IndustryTileScopeResolver::GetVariable(), AirportTileScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), and IncreaseAnimationStage().
|
inlinestatic |
Get top height of the tile.
tile | Tile to compute height of |
Definition at line 304 of file tile_map.h.
References GetTileMaxZ(), and TILE_HEIGHT.
Referenced by EnsureNoVehicleOnGround().
int GetTileMaxZ | ( | TileIndex | t | ) |
Get top height of the tile inside the map.
t | Tile to compute height of |
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(), and ShipTestUpDownOnLock().
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.
tile | The tile to check |
Definition at line 178 of file tile_map.h.
References _m, GB(), IsTileType(), IsValidTile(), MP_HOUSE, and MP_INDUSTRY.
Referenced by AfterLoadCompanyStats(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanEnterNewTile(), CheckTileOwnership(), CmdConvertRail(), FixOwnerOfRailTrack(), GetMinimapOwner(), GetTrainForReservation(), ObjectScopeResolver::GetVariable(), IsTileOwner(), MakeBuoy(), MakeLock(), MoveBuoysToWaypoints(), RemoveLock(), and UpdateObjectColours().
Return the slope of a given tile.
tile | Tile to compute slope of |
h | If not nullptr , pointer to storage of z height |
Definition at line 280 of file tile_map.h.
References GetTileSlope(), and TILE_HEIGHT.
Referenced by GetNearbyTileInformation().
Slope GetTilePixelSlopeOutsideMap | ( | int | x, |
int | y, | ||
int * | h | ||
) |
Return the slope of a given tile, also for tiles outside the map (virtual "black" tiles).
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. |
Definition at line 82 of file tile_map.cpp.
|
inlinestatic |
Get bottom height of the tile.
tile | Tile to compute height of |
Definition at line 294 of file tile_map.h.
References GetTileZ(), and TILE_HEIGHT.
Return the slope of a given tile inside the map.
tile | Tile to compute slope of |
h | If not nullptr , pointer to storage of z height |
Definition at line 59 of file tile_map.cpp.
References GetTileSlopeGivenHeight(), MapMaxX(), MapMaxY(), TileHeight(), TileX(), TileXY(), and TileY().
Referenced by BuildTownHouse(), CanBuildHouseHere(), CanPlantTreesOnTile(), CheckBuildableTile(), CheckIfIndustryTilesAreFree(), CmdBuildLock(), CmdBuildRoadDepot(), CmdBuildTrainDepot(), FlowsDown(), GetBridgeHeight(), GetFloodingBehaviour(), GetFoundationSlope(), GetOtherAqueductEnd(), GetTilePixelSlope(), StationScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), GrowTownWithBridge(), GrowTownWithTunnel(), BuildDocksToolbarWindow::OnPlacePresize(), PerformStationTileSlopeCheck(), SearchTileForStatue(), ShipTestUpDownOnLock(), and CYapfCostBase::stSlopeCost().
Get the tiletype of a given tile.
tile | The tile to get the TileType |
Definition at line 96 of file tile_map.h.
References _m, GB(), and MapSize().
Referenced by AfterLoadCompanyStats(), CanEnterTileOwnerCheck(), CanFollowRoad(), CanPlantTreesOnTile(), ChangeTileOwner(), CheckIfFarEnoughFromConflictingIndustry(), CleanUpRoadBits(), ClosestTownFromTile(), CmdConvertRail(), DrawRailCatenary(), GetAnyRoadBits(), GetDepotVehicleType(), GetFloodingBehaviour(), GetFoundationSlope(), GetGrfSpecFeature(), GetMinimapOwner(), GetNearbyTileInformation(), GetRailTrackBitsUniversal(), GetReservedTrackbits(), SmallMapWindow::GetTileColours(), GetTileRailType(), GetTileTrackStatus(), GrowTownWithExtraHouse(), Depot::IsOfType(), IsSuitableForFarmField(), IsTileType(), IsWateredTile(), MayHaveRoad(), CYapfCostRoadT< Types >::OneTileCost(), CYapfCostRailT< Types >::OneTileCost(), PlantTreesOnTile(), SetWaterClassDependingOnSurroundings(), TryReserveRailTrack(), UnreserveRailTrack(), UpdateSignalsInBuffer(), and Town::~Town().
int GetTileZ | ( | TileIndex | tile | ) |
Get bottom height of the tile.
tile | Tile to compute height of |
Definition at line 121 of file tile_map.cpp.
References MapMaxX(), MapMaxY(), TileHeight(), TileX(), TileXY(), and TileY().
Referenced by CheckNewIndustry_BubbleGen(), GetOtherTunnelEnd(), GetTilePixelZ(), CanalScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), GrowTownWithTunnel(), IsTunnelInWayDir(), ShipTestUpDownOnLock(), and TileLoopClearAlps().
|
inlinestatic |
Get the tropic zone.
tile | the tile to get the zone of |
Definition at line 238 of file tile_map.h.
References _m, GB(), and MapSize().
Referenced by CheckNewIndustry_Lumbermill(), CheckNewIndustry_Plantation(), CheckNewIndustry_Water(), NeighbourIsNormal(), and RiverModifyDesertZone().
|
inlinestatic |
Check if a tile is within the map (not a border)
tile | The tile to check |
Definition at line 109 of file tile_map.h.
References MapSize().
Referenced by SetTileType(), and TgenSetTileHeight().
bool IsTileFlat | ( | TileIndex | tile, |
int * | h | ||
) |
Check if a given tile is flat.
tile | Tile to check |
h | If not nullptr , pointer to storage of z height (only if 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(), SetWaterClassDependingOnSurroundings(), TownCanBePlacedHere(), and TryBuildTransmitter().
Checks if a tile belongs to the given owner.
tile | The tile to check |
owner | The owner to check against |
Definition at line 214 of file tile_map.h.
References GetTileOwner().
Referenced by CanEnterTileOwnerCheck(), CmdBuildVehicle(), CmdDepotMassAutoReplace(), DoClearBridge(), DoClearTunnel(), GetOrderCmdFromTile(), and TestTownOwnsBridge().
Checks if a tile is a given tiletype.
This function checks if a tile has the given tiletype.
tile | The tile to check |
type | The type to check against |
Definition at line 150 of file tile_map.h.
References GetTileType().
Referenced by AddClearCounter(), AddClearDensity(), AddTreeCount(), AddTreeCounter(), AddTreeGrowth(), AdjustTileh(), AmbientSoundEffectCallback(), Vehicle::BeginLoading(), CanEnterTile(), CanEnterTileOwnerCheck(), Station::CatchmentCoversTown(), CheckFlatLandRailStation(), CheckFlatLandRoadStop(), CheckForDockingTile(), CheckSubsidised(), ClearPathReservation(), CmdBuildLongRoad(), CmdTerraformLand(), CMSAMine(), CMSATree(), CMSAWater(), Train::Crash(), DecHouseProcessingTime(), DeleteLastWagon(), DoClearTownHouseHelper(), DoFloodTile(), DoTriggerIndustryTile(), DrawRoadCatenary(), ExtendTrainReservation(), FindFurthestFromWater(), FindNearestEmptyLand(), FindNearIndustryName(), FindRailStationEnd(), FindSubsidyCargoDestination(), FindSubsidyTownCargoRoute(), FollowReservation(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::FollowTileExit(), FollowTrainReservation(), ForAllStationsAroundTiles(), FreeTrainTrackReservation(), GetAcceptanceAroundTiles(), GetAnimationFrame(), GetAxisForNewWaypoint(), GetCleanHouseType(), GetCleanIndustryGfx(), GetClearCounter(), GetClearDensity(), GetDockOffset(), GetEffectiveWaterClass(), GetHouseAge(), GetHouseBuildingStage(), GetHouseConstructionTick(), GetHouseProcessingTime(), GetHouseRandomBits(), GetHouseTriggers(), GetIndustryAnimationLoop(), GetIndustryConstructionCounter(), GetIndustryConstructionStage(), GetIndustryGfx(), GetIndustryIndex(), GetIndustryRandomBits(), GetIndustryTriggers(), GetIndustryType(), GetMinimapOwner(), GetNearbyAirportTileInformation(), GetNearbyIndustryTileInformation(), GetNearbyObjectTileInformation(), GetNearbyTileInformation(), GetObjectIDAtOffset(), GetObjectIndex(), GetObjectRandomBits(), GetObjectType(), GetOrderCmdFromTile(), GetOtherTunnelBridgeEnd(), GetProductionAroundTiles(), GetRailTileType(), CanalScopeResolver::GetRandomBits(), HouseScopeResolver::GetRandomBits(), ObjectScopeResolver::GetRandomBits(), GetRawClearGround(), GetRoadTileType(), GetStationGfx(), GetStationIndex(), StationFinder::GetStations(), GetStationTileRandomBits(), GetStationType(), GetTileCatchmentRadius(), GetTileHighlightType(), GetTileOwner(), GetTownIndex(), GetTrainForReservation(), GetTreeCount(), GetTreeCounter(), GetTreeDensity(), GetTreeGround(), GetTreeGrowth(), GetTreeType(), HouseScopeResolver::GetTriggers(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), CanalScopeResolver::GetVariable(), IndustryTileScopeResolver::GetVariable(), HouseScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), GetWaterTileRandomBits(), GetWaterTileType(), HasOnewaySignalBlockingTrackdir(), HasPbsSignalOnTrackdir(), HasStationTileRail(), HasTileWaterClass(), HasTunnelBridgeReservation(), HasTunnelBridgeSnowOrDesert(), IncHouseConstructionTick(), IncrementHouseAge(), IsAirportTile(), IsBridge(), IsBridgeTile(), IsBuoyTile(), IsCoastTile(), IsDockingTile(), IsDockTile(), RoadStop::IsDriveThroughRoadStopContinuation(), IsHangar(), IsHangarTile(), IsHouseCompleted(), IsIndustryCompleted(), IsLevelCrossingTile(), IsNormalRoadTile(), IsObjectTypeTile(), IsPlainRailTile(), IsPossibleCrossing(), IsRailDepotTile(), IsRailStationTile(), IsRailWaypointTile(), IsRoadDepotTile(), IsRoadStop(), IsRoadStopTile(), IsSafeWaitingPosition(), IsShipDepotTile(), IsShipDestinationTile(), IsSnowTile(), IsTileForestIndustry(), IsTunnel(), IsTunnelTile(), IsValidTile(), IsValidTileForWaypoint(), IsWaitingPositionFree(), IsWaterTile(), MakeHouseTile(), MakeSingleHouseBigger(), MarkTileDirtyIfCanalOrRiver(), MayHaveBridgeAbove(), MoveBuoysToWaypoints(), Station::RecomputeCatchment(), ResetHouseAge(), ResetIndustryConstructionStage(), RoadTypesAllowHouseHere(), StationRect::ScanForStationTiles(), SearchLumberMillTrees(), SearchNearbyHouseClass(), SearchNearbyHouseGRFID(), SearchNearbyHouseID(), SearchTileForStatue(), SetAnimationFrame(), SetClearCounter(), SetClearDensity(), SetClearGroundDensity(), SetDockingTile(), SetHouseCompleted(), SetHouseProcessingTime(), SetHouseRandomBits(), SetHouseTriggers(), SetHouseType(), SetIndustryAnimationLoop(), SetIndustryCompleted(), SetIndustryConstructionCounter(), SetIndustryConstructionStage(), SetIndustryGfx(), SetIndustryRandomBits(), SetIndustryTriggers(), SetStationGfx(), SetStationTileRandomBits(), SetTileOwner(), SetTownIndex(), SetTreeCounter(), SetTreeGroundDensity(), SetTreeGrowth(), SetTropicZone(), SetTunnelBridgeReservation(), SetTunnelBridgeSnowOrDesert(), SetupFarmFieldFence(), ShipTestUpDownOnLock(), TestTownOwnsBridge(), Industry::TileBelongsToIndustry(), TileLoop_Water(), TownCanBePlacedHere(), TrainCanLeaveTile(), TriggerWatchedCargoCallbacks(), TryBuildTransmitter(), UpdateHousesAndTowns(), UpdateNearestTownForRoadTiles(), UpdateStatusAfterSwap(), and WatchedCargoCallback().
|
inlinestatic |
Checks if a tile is valid.
tile | The tile to check |
Definition at line 161 of file tile_map.h.
References IsTileType(), MapSize(), and MP_VOID.
Referenced by CalculateCoverageLine(), CanConnectToRoad(), CanFollowRoad(), CheckForDockingTile(), CheckIfIndustryTilesAreFree(), CleanUpRoadBits(), ClearDockingTilesCheckingNeighbours(), CmdBuildBridge(), CmdStoryPageButton(), DisasterTick_Submarine(), DoCommand(), DoTriggerIndustryTile(), DrawTileSelectionRect(), FindDockLandPart(), GetOtherAqueductEnd(), IndustryTileScopeResolver::GetRandomBits(), HouseScopeResolver::GetRandomBits(), ObjectScopeResolver::GetRandomBits(), GetTileOwner(), IndustryTileScopeResolver::GetTriggers(), HouseScopeResolver::GetTriggers(), ObjectScopeResolver::GetVariable(), GrowTownWithBridge(), GrowTownWithTunnel(), GoalListWindow::HandleClick(), IsNeighborRoadTile(), IsShipDestinationTile(), IsTunnelInWayDir(), MakeLake(), MarkTileDirtyIfCanalOrRiver(), NeighbourIsNormal(), RoadTypesAllowHouseHere(), SetTileOwner(), TileLoop_Water(), and VerifyElementContentParameters().
|
inlinestatic |
Set a new animation frame.
t | the tile |
frame | the new frame number |
Definition at line 262 of file tile_map.h.
References _me, IsTileType(), TileExtended::m7, MP_HOUSE, MP_INDUSTRY, MP_OBJECT, and MP_STATION.
Referenced by AnimationBase< IndustryAnimationBase, IndustryTileSpec, Industry, int, GetSimpleIndustryCallback >::ChangeAnimationFrame(), IncreaseAnimationStage(), and MakeHouseTile().
|
inlinestatic |
Sets the height of a tile.
This function sets the height of the northern corner of a tile.
tile | The tile to change the height |
height | The new height value of the tile |
Definition at line 57 of file tile_map.h.
References _m, Tile::height, MapSize(), and MAX_TILE_HEIGHT.
Referenced by FlatEmptyWorld(), MakeVoid(), and TgenSetTileHeight().
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.
tile | The tile to change the owner status. |
owner | The new owner. |
Definition at line 198 of file tile_map.h.
References _m, IsTileType(), IsValidTile(), MP_HOUSE, MP_INDUSTRY, and SB().
Referenced by FixOwnerOfRailTrack(), MakeBridgeRamp(), MakeClear(), MakeField(), MakeLockTile(), MakeObject(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeWater(), and SetTunnelBridgeOwner().
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.
tile | The tile to save the new type |
type | The type to save |
Definition at line 131 of file tile_map.h.
References _m, IsInnerTile(), MapSize(), MP_VOID, and SB().
Referenced by MakeBridgeRamp(), MakeClear(), MakeField(), MakeHouseTile(), MakeIndustry(), MakeLockTile(), MakeObject(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeVoid(), and MakeWater().
|
inlinestatic |
Set the tropic zone.
tile | the tile to set the zone of |
type | the new type |
Definition at line 225 of file tile_map.h.
References _m, IsTileType(), MapSize(), MP_VOID, SB(), and TROPICZONE_NORMAL.
Referenced by RiverModifyDesertZone().
|
inlinestatic |
Calculate a hash value from a tile position.
x | The X coordinate |
y | The Y coordinate |
Definition at line 316 of file tile_map.h.
Referenced by Town::InitializeLayout(), and River_Hash().
|
inlinestatic |
Get the last two bits of the TileHash from a tile position.
x | The X coordinate |
y | The Y coordinate |
Definition at line 334 of file tile_map.h.
Referenced by HouseScopeResolver::GetVariable().
|
inlinestatic |
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.
tile | The tile to get the height from |
Definition at line 29 of file tile_map.h.
References _m, Tile::height, and MapSize().
Referenced by CalculateCoverageLine(), CheckIfCanLevelIndustryPlatform(), ClickChangeMaxHlCheat(), CmdLevelLand(), CmdTerraformLand(), FlowRiver(), GetTileHeightBelowAircraft(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), IsTileFlat(), MakeHeightmapScreenshot(), MakeLake(), MarkBridgeDirty(), MarkTileDirtyByTile(), TerraformGetHeightOfTile(), and TilePixelHeight().
|
inlinestatic |
Returns the height of a tile, also for tiles outside the map (virtual "black" tiles).
x | X coordinate of the tile, may be outside the map. |
y | Y coordinate of the tile, may be outside the map. |
Definition at line 42 of file tile_map.h.
|
inlinestatic |
Returns the height of a tile in pixels.
This function returns the height of the northern corner of a tile in pixels.
tile | The tile to get the height |
Definition at line 72 of file tile_map.h.
References TILE_HEIGHT, and TileHeight().
|
inlinestatic |
Returns the height of a tile in pixels, also for tiles outside the map (virtual "black" tiles).
x | X coordinate of the tile, may be outside the map. |
y | Y coordinate of the tile, may be outside the map. |
Definition at line 84 of file tile_map.h.
Referenced by GetViewportY().