OpenTTD
|
Functions related to maps. More...
#include "core/math_func.hpp"
#include "tile_type.h"
#include "map_type.h"
#include "direction_func.h"
Go to the source code of this file.
Macros | |
#define | TILE_MASK(x) ((x) & _map_tile_mask) |
'Wraps' the given tile to it is within the map. | |
#define | TILE_ADD(x, y) ((x) + (y)) |
Adds to tiles together. | |
#define | TILE_ADDXY(tile, x, y) TILE_ADD(tile, TileDiffXY(x, y)) |
Adds a given offset to a tile. | |
#define | RandomTile() RandomTileSeed(Random()) |
Get a valid random tile. |
Typedefs | |
typedef int32 | TileIndexDiff |
An offset value between to tiles. | |
typedef bool | TestTileOnSearchProc (TileIndex tile, void *user_data) |
A callback function type for searching tiles. |
Functions | |
void | AllocateMap (uint size_x, uint size_y) |
(Re)allocates a map with the given dimension | |
static uint | MapLogX () |
Logarithm of the map size along the X side. | |
static uint | MapLogY () |
Logarithm of the map size along the y side. | |
static uint | MapSizeX () |
Get the size of the map along the X. | |
static uint | MapSizeY () |
Get the size of the map along the Y. | |
static uint | MapSize () |
Get the size of the map. | |
static uint | MapMaxX () |
Gets the maximum X coordinate within the map, including MP_VOID. | |
static uint | MapMaxY () |
Gets the maximum Y coordinate within the map, including MP_VOID. | |
static uint | ScaleByMapSize (uint n) |
Scales the given value by the map size, where the given value is for a 256 by 256 map. | |
static uint | ScaleByMapSize1D (uint n) |
Scales the given value by the maps circumference, where the given value is for a 256 by 256 map. | |
static TileIndex | TileXY (uint x, uint y) |
Returns the TileIndex of a coordinate. | |
static TileIndexDiff | TileDiffXY (int x, int y) |
Calculates an offset for the given coordinate(-offset). | |
static TileIndex | TileVirtXY (uint x, uint y) |
Get a tile from the virtual XY-coordinate. | |
static uint | TileX (TileIndex tile) |
Get the X component of a tile. | |
static uint | TileY (TileIndex tile) |
Get the Y component of a tile. | |
static TileIndexDiff | ToTileIndexDiff (TileIndexDiffC tidc) |
Return the offset between to tiles from a TileIndexDiffC struct. | |
TileIndex | TileAddWrap (TileIndex tile, int addx, int addy) |
This function checks if we add addx/addy to tile, if we do wrap around the edges. | |
static TileIndexDiffC | TileIndexDiffCByDiagDir (DiagDirection dir) |
Returns the TileIndexDiffC offset from a DiagDirection. | |
static TileIndexDiffC | TileIndexDiffCByDir (Direction dir) |
Returns the TileIndexDiffC offset from a Direction. | |
static TileIndex | AddTileIndexDiffCWrap (TileIndex tile, TileIndexDiffC diff) |
Add a TileIndexDiffC to a TileIndex and returns the new one. | |
static TileIndexDiffC | TileIndexToTileIndexDiffC (TileIndex tile_a, TileIndex tile_b) |
Returns the diff between two tiles. | |
uint | DistanceManhattan (TileIndex, TileIndex) |
also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads) | |
uint | DistanceSquare (TileIndex, TileIndex) |
euclidian- or L2-Norm squared | |
uint | DistanceMax (TileIndex, TileIndex) |
also known as L-Infinity-Norm | |
uint | DistanceMaxPlusManhattan (TileIndex, TileIndex) |
Max + Manhattan. | |
uint | DistanceFromEdge (TileIndex) |
shortest distance from any edge of the map | |
uint | DistanceFromEdgeDir (TileIndex, DiagDirection) |
distance from the map edge in given direction | |
static TileIndexDiff | TileOffsByDiagDir (DiagDirection dir) |
Convert a DiagDirection to a TileIndexDiff. | |
static TileIndexDiff | TileOffsByDir (Direction dir) |
Convert a Direction to a TileIndexDiff. | |
static TileIndex | TileAddByDiagDir (TileIndex tile, DiagDirection dir) |
Adds a DiagDir to a tile. | |
static DiagDirection | DiagdirBetweenTiles (TileIndex tile_from, TileIndex tile_to) |
Determines the DiagDirection to get from one tile to another. | |
bool | CircularTileSearch (TileIndex *tile, uint size, TestTileOnSearchProc proc, void *user_data) |
Function performing a search around a center tile and going outward, thus in circle. | |
bool | CircularTileSearch (TileIndex *tile, uint radius, uint w, uint h, TestTileOnSearchProc proc, void *user_data) |
Generalized circular search allowing for rectangles and a hole. | |
static TileIndex | RandomTileSeed (uint32 r) |
Get a random tile out of a given seed. | |
uint | GetClosestWaterDistance (TileIndex tile, bool water) |
Finds the distance for the closest tile with water/land given a tile. |
Variables | |
uint | _map_tile_mask |
_map_size - 1 (to mask the mapsize) | |
Tile * | _m |
Pointer to the tile-array. | |
TileExtended * | _me |
Pointer to the extended tile-array. |
Functions related to maps.
Definition in file map_func.h.
#define RandomTile | ( | ) | RandomTileSeed(Random()) |
Get a valid random tile.
Definition at line 425 of file map_func.h.
Referenced by CmdBuildIndustry(), CreateRivers(), DisasterTick_Big_Ufo(), DisasterTick_Ufo(), PlaceIndustry(), PlaceTreeGroups(), ReleaseDisastersTargetingVehicle(), and TryBuildTransmitter().
#define TILE_ADD | ( | x, | |
y | |||
) | ((x) + (y)) |
Adds to tiles together.
x | One tile |
y | Another tile to add |
Definition at line 246 of file map_func.h.
Referenced by CalcHeightdiff(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanEnterNewTile(), CircularTileSearch(), FindRailStationEnd(), FindStationsNearby(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::FollowTileExit(), Ship::GetOrderStationLocation(), GetOtherAqueductEnd(), GrowTown(), IsNeighborRoadTile(), NPFSaveTargetData(), OPFShipChooseTrack(), RemoveDock(), CYapfReserveTrack< Types >::ReserveRailStationPlatform(), SetRailStationPlatformReservation(), TileAddByDiagDir(), and CYapfReserveTrack< Types >::UnreserveSingleTrack().
#define TILE_ADDXY | ( | tile, | |
x, | |||
y | |||
) | TILE_ADD(tile, TileDiffXY(x, y)) |
Adds a given offset to a tile.
tile | The tile to add an offset on it |
x | The x offset to add to the tile |
y | The y offset to add to the tile |
Definition at line 260 of file map_func.h.
Referenced by AfterLoadGame(), CheckAllowRemoveRoad(), CheckNewIndustry_OilRefinery(), CheckNewIndustry_OilRig(), DrawWaterEdges(), FindStationsNearby(), OrthogonalTileArea::GetCenterTile(), GetOtherAqueductEnd(), CanalScopeResolver::GetVariable(), HeightmapCallback(), MakeTownHouseBigger(), and WatchedCargoCallback().
#define TILE_MASK | ( | x | ) | ((x) & _map_tile_mask) |
'Wraps' the given tile to it is within the map.
It does this by masking the 'high' bits of.
x | the tile to 'wrap' |
Definition at line 28 of file map_func.h.
Referenced by DisasterTick_Big_Ufo(), GetNearbyTile(), HouseScopeResolver::GetVariable(), RandomTileSeed(), and SetupFarmFieldFence().
typedef bool TestTileOnSearchProc(TileIndex tile, void *user_data) |
A callback function type for searching tiles.
tile | The tile to test |
user_data | additional data for the callback function to use |
Definition at line 404 of file map_func.h.
typedef int32 TileIndexDiff |
An offset value between to tiles.
This value is used for the difference between to tiles. It can be added to a tileindex to get the resulting tileindex of the start tile applied with this saved difference.
Definition at line 156 of file map_func.h.
|
inlinestatic |
Add a TileIndexDiffC to a TileIndex and returns the new one.
Returns tile + the diff given in diff. If the result tile would end up outside of the map, INVALID_TILE is returned instead.
tile | The base tile to add the offset on |
diff | The offset to add on the tile |
Definition at line 302 of file map_func.h.
References INVALID_TILE, MapSizeX(), MapSizeY(), TileX(), TileXY(), TileY(), TileIndexDiffC::x, and TileIndexDiffC::y.
void AllocateMap | ( | uint | size_x, |
uint | size_y | ||
) |
(Re)allocates a map with the given dimension
size_x | the width of the map along the NE/SW edge |
size_y | the 'height' of the map along the SE/NW edge |
Definition at line 41 of file map.cpp.
References _map_log_x, _map_log_y, _map_size, _map_size_x, _map_size_y, _map_tile_mask, DEBUG, error(), FindFirstBit(), free(), IsInsideMM(), MAX_MAP_SIZE, and MIN_MAP_SIZE.
bool CircularTileSearch | ( | TileIndex * | tile, |
uint | size, | ||
TestTileOnSearchProc | proc, | ||
void * | user_data | ||
) |
Function performing a search around a center tile and going outward, thus in circle.
Although it really is a square search... Every tile will be tested by means of the callback function proc, which will determine if yes or no the given tile meets criteria of search.
tile | to start the search from. Upon completion, it will return the tile matching the search |
size,: | number of tiles per side of the desired search area |
proc,: | callback testing function pointer. |
user_data | to be passed to the callback function. Depends on the implementation |
Definition at line 260 of file map.cpp.
References CircularTileSearch(), DIR_N, TILE_ADD, and TileOffsByDir().
Referenced by ChopLumberMillTrees(), CircularTileSearch(), CmdBuildCanal(), CreateRivers(), FindNearestGoodCoastalTownSpot(), FindStationsNearby(), FlowRiver(), GetDistanceFromNearbyHouse(), Station::RecomputeIndustriesNear(), TownActionBuildStatue(), and TryBuildTransmitter().
bool CircularTileSearch | ( | TileIndex * | tile, |
uint | radius, | ||
uint | w, | ||
uint | h, | ||
TestTileOnSearchProc | proc, | ||
void * | user_data | ||
) |
Generalized circular search allowing for rectangles and a hole.
Function performing a search around a center rectangle and going outward. The center rectangle is left out from the search. To do a rectangular search without a hole, set either h or w to zero. Every tile will be tested by means of the callback function proc, which will determine if yes or no the given tile meets criteria of search.
tile | to start the search from. Upon completion, it will return the tile matching the search. This tile should be directly north of the hole (if any). |
radius | How many tiles to search outwards. Note: This is a radius and thus different from the size parameter of the other CircularTileSearch function, which is a diameter. |
w | the width of the inner rectangle |
h | the height of the inner rectangle |
proc | callback testing function pointer. |
user_data | to be passed to the callback function. Depends on the implementation |
Definition at line 298 of file map.cpp.
References DIAGDIR_BEGIN, DIAGDIR_END, DIR_W, INVALID_TILE, MapSizeX(), MapSizeY(), TileX(), TileXY(), TileY(), TileIndexDiffC::x, and TileIndexDiffC::y.
|
inlinestatic |
Determines the DiagDirection to get from one tile to another.
The tiles do not necessarily have to be adjacent.
tile_from | Origin tile |
tile_to | Destination tile |
Definition at line 384 of file map_func.h.
References DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, INVALID_DIAGDIR, TileX(), and TileY().
Referenced by TrainController().
uint DistanceFromEdge | ( | TileIndex | tile | ) |
shortest distance from any edge of the map
shortest distance from any edge of the map
tile | the tile to get the distance from |
Definition at line 219 of file map.cpp.
References MapSizeX(), MapSizeY(), min(), TileX(), and TileY().
Referenced by CheckNewIndustry_OilRefinery(), CheckNewIndustry_OilRig(), GrayscaleToMapHeights(), GrowTownWithExtraHouse(), IsRoadAllowedHere(), and TownCanBePlacedHere().
uint DistanceFromEdgeDir | ( | TileIndex | tile, |
DiagDirection | dir | ||
) |
distance from the map edge in given direction
distance from the map edge in given direction
tile | the tile to get the distance from |
dir | the direction of interest |
Definition at line 236 of file map.cpp.
References _settings_game, GameSettings::construction, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, ConstructionSettings::freeform_edges, MapMaxX(), MapMaxY(), TileX(), and TileY().
Referenced by GetOtherAqueductEnd().
also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads)
also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads)
The Manhattan distance is the sum of the delta of both the X and Y component. Also known as L1-Norm
t0 | the start tile |
t1 | the end tile |
Definition at line 159 of file map.cpp.
References Delta(), TileX(), and TileY().
Referenced by AirportGetNearestTown(), CalcClosestTownFromTile(), CalcRaildirsDrawstyle(), CheckSubsidyDistance(), ClosestTownFromTile(), DeleteStaleLinks(), DeliverGoods(), FindDeletedWaypointCloseTo(), FindSubsidyPassengerRoute(), FlowRiver(), FlowsDown(), GetClosestDeletedStation(), GetClosestObject(), GetCountAndDistanceOfClosestInstance(), GetDistanceFromNearbyHouse(), GetMinimalAirportDistanceToTile(), GetOrderDistance(), IndustriesScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), IsCloseToTown(), CargoPayment::PayTransfer(), Station::RecomputeIndustriesNear(), VpSelectTilesWithMethod(), VpSetPresizeRange(), and YapfTrainCheckReverse().
also known as L-Infinity-Norm
also known as L-Infinity-Norm
Also known as L-Infinity-Norm.
t0 | the start tile |
t1 | the end tile |
Definition at line 191 of file map.cpp.
References Delta(), max(), TileX(), and TileY().
Referenced by CheckIfFarEnoughFromConflictingIndustry(), CheckIfIndustryIsAllowed(), and FindStationsNearby().
Max + Manhattan.
Max + Manhattan.
two times the biggest distance component and once the smallest component.
t0 | the start tile |
t1 | the end tile |
Definition at line 207 of file map.cpp.
References Delta(), TileX(), and TileY().
Referenced by DemandCalculator::CalcDemand(), and MultiCommodityFlow::Dijkstra().
euclidian- or L2-Norm squared
euclidian- or L2-Norm squared
The 'Square' distance is the square of the shortest (straight line) distance between the two tiles. Also known as euclidian- or L2-Norm squared.
t0 | the start tile |
t1 | the end tile |
Definition at line 176 of file map.cpp.
References TileX(), and TileY().
Referenced by CmdBuildBridge(), CmdBuildRoad(), CmdBuildTunnel(), FindNearestHangar(), GetOrderDistance(), GetTownRadiusGroup(), IndustriesScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), and UpdateTownGrowRate().
uint GetClosestWaterDistance | ( | TileIndex | tile, |
bool | water | ||
) |
Finds the distance for the closest tile with water/land given a tile.
tile | the tile to find the distance too |
water | whether to find water or land |
Definition at line 342 of file map.cpp.
References _settings_game, GameSettings::construction, DIAGDIR_BEGIN, DIAGDIR_END, ConstructionSettings::freeform_edges, HasTileWaterGround(), IsInsideMM(), IsTileType(), MapMaxX(), MapMaxY(), MapSize(), MP_VOID, MP_WATER, TileX(), TileXY(), and TileY().
Referenced by FindFurthestFromWater(), and IndustriesScopeResolver::GetVariable().
|
inlinestatic |
Logarithm of the map size along the X side.
Definition at line 53 of file map_func.h.
References _map_log_x.
Referenced by HeightMapGenerate(), RunTileLoop(), ScaleByMapSize(), ScaleByMapSize1D(), StartupIndustryDailyChanges(), TGPGetMaxHeight(), TileVirtXY(), TileXY(), TileY(), and ToTileIndexDiff().
|
inlinestatic |
Logarithm of the map size along the y side.
Definition at line 64 of file map_func.h.
References _map_log_y.
Referenced by HeightMapGenerate(), RunTileLoop(), ScaleByMapSize(), ScaleByMapSize1D(), StartupIndustryDailyChanges(), and TGPGetMaxHeight().
|
inlinestatic |
Gets the maximum X coordinate within the map, including MP_VOID.
Definition at line 104 of file map_func.h.
References MapSizeX().
Referenced by AfterLoadGame(), CalcRaildirsDrawstyle(), CheckIfCanLevelIndustryPlatform(), CheckIfFarEnoughFromConflictingIndustry(), CmdBuildTunnel(), CmdTerraformLand(), CreateEffectVehicleAbove(), DisasterTick_Aircraft(), DistanceFromEdgeDir(), SmallMapWindow::DrawSmallMapColumn(), Station::GetCatchmentRect(), GetClosestWaterDistance(), GetTileHeightBelowAircraft(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), GUIPlaceProcDragXY(), HandleCrashedAircraft(), HeightmapCallback(), IsCloseToTown(), IsTunnelInWay(), SetAircraftPosition(), SmallMapWindow::SetNewScroll(), SetSelectionTilesDirty(), SetWaterClassDependingOnSurroundings(), TerraformTileHeight(), TileAddWrap(), TileHeightOutsideMap(), TileX(), TranslateXYToTileCoord(), TryBuildLightHouse(), and DisasterVehicle::UpdatePosition().
|
inlinestatic |
Gets the maximum Y coordinate within the map, including MP_VOID.
Definition at line 113 of file map_func.h.
References MapSizeY().
Referenced by AfterLoadGame(), CalcRaildirsDrawstyle(), CheckIfCanLevelIndustryPlatform(), CheckIfFarEnoughFromConflictingIndustry(), CmdTerraformLand(), CreateEffectVehicleAbove(), DistanceFromEdgeDir(), SmallMapWindow::DrawSmallMapColumn(), Station::GetCatchmentRect(), GetClosestWaterDistance(), GetTileHeightBelowAircraft(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), GUIPlaceProcDragXY(), HandleCrashedAircraft(), IsCloseToTown(), IsTunnelInWay(), SetAircraftPosition(), SmallMapWindow::SetNewScroll(), SetSelectionTilesDirty(), SetWaterClassDependingOnSurroundings(), TerraformTileHeight(), TileAddWrap(), TileHeightOutsideMap(), TranslateXYToTileCoord(), TryBuildLightHouse(), and DisasterVehicle::UpdatePosition().
|
inlinestatic |
Get the size of the map.
Definition at line 94 of file map_func.h.
References _map_size.
Referenced by AfterLoadCompanyStats(), AfterLoadGame(), ChangeOwnershipOfCompanyItems(), OrthogonalTileArea::ClampToMap(), ClickChangeMaxHlCheat(), CmdBuildCanal(), CmdBuildLongRoad(), CmdClearArea(), CmdConvertRail(), CmdDeleteTown(), CmdLevelLand(), CmdPlantTree(), CmdRailTrackHelper(), CmdRemoveFromRailStation(), CmdRemoveFromRailWaypoint(), CmdRemoveLongRoad(), CmdSignalTrackHelper(), CmdTerraformLand(), DEF_CONSOLE_CMD(), DiagonalTileArea::DiagonalTileArea(), DoCommand(), DoCommandPInternal(), DrawStationCoverageAreaText(), FindStationsNearby(), GetClosestWaterDistance(), GetTileSlope(), GetTileType(), GetTropicZone(), GrowTownAtRoad(), GrowTownInTile(), IsInnerTile(), IsTileFlat(), IsValidTile(), DiagonalTileIterator::operator++(), OrthogonalTileArea::OrthogonalTileArea(), RebuildTownCaches(), SetDefaultRailGui(), SetTileHeight(), SetTileType(), SetTropicZone(), SetupScreenshotViewport(), TerraformTileHeight(), TileHeight(), TryBuildLightHouse(), UpdateHousesAndTowns(), UpdateNearestTownForRoadTiles(), and Town::~Town().
|
inlinestatic |
Get the size of the map along the X.
Definition at line 74 of file map_func.h.
References _map_size_x.
Referenced by _GenerateWorld(), AddTileIndexDiffCWrap(), AllocHeightMap(), CircularTileSearch(), OrthogonalTileArea::ClampToMap(), DEF_CONSOLE_CMD(), Disaster_Small_Ufo_Init(), DisasterTick_Aircraft(), DisasterTick_Big_Ufo_Destroyer(), DistanceFromEdge(), FindStationsAroundTiles(), FixSlopes(), FlatEmptyWorld(), GenerateLandscape(), GenerateWorld(), GetAcceptanceAroundTiles(), TileMatrix< uint32, 4 >::GetAreaForTile(), GetProductionAroundTiles(), GrayscaleToMapHeights(), MakeHeightmapScreenshot(), MapMaxX(), DiagonalTileIterator::operator++(), ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(), ScrollWindowTo(), ServerNetworkAdminSocketHandler::SendWelcome(), SetSelectionTilesDirty(), TerraformTileHeight(), TileDiffXY(), and ViewportAddLandscape().
|
inlinestatic |
Get the size of the map along the Y.
Definition at line 84 of file map_func.h.
References _map_size_y.
Referenced by _GenerateWorld(), AddTileIndexDiffCWrap(), AllocHeightMap(), CircularTileSearch(), OrthogonalTileArea::ClampToMap(), DEF_CONSOLE_CMD(), Disaster_Small_Ufo_Init(), DisasterTick_Zeppeliner(), DistanceFromEdge(), FindStationsAroundTiles(), FixSlopes(), FlatEmptyWorld(), GenerateLandscape(), GenerateWorld(), GetAcceptanceAroundTiles(), TileMatrix< uint32, 4 >::GetAreaForTile(), GetProductionAroundTiles(), GrayscaleToMapHeights(), MakeHeightmapScreenshot(), MapMaxY(), DiagonalTileIterator::operator++(), ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(), ScrollWindowTo(), ServerNetworkAdminSocketHandler::SendWelcome(), SetSelectionTilesDirty(), TerraformTileHeight(), and ViewportAddLandscape().
|
inlinestatic |
Get a random tile out of a given seed.
r | the random 'seed' |
Definition at line 414 of file map_func.h.
References TILE_MASK.
Referenced by PlaceTreesRandomly().
|
inlinestatic |
Scales the given value by the map size, where the given value is for a 256 by 256 map.
n | the value to scale |
Definition at line 124 of file map_func.h.
References CeilDiv(), MapLogX(), and MapLogY().
Referenced by CreateRivers(), GenerateLandscape(), GenerateTowns(), GenerateTrees(), GetNumberOfIndustries(), GetScaledIndustryGenerationProbability(), IndustryBuildData::MonthlyLoop(), and PlaceTreesRandomly().
|
inlinestatic |
Scales the given value by the maps circumference, where the given value is for a 256 by 256 map.
n | the value to scale |
Definition at line 138 of file map_func.h.
References CeilDiv(), MapLogX(), and MapLogY().
Referenced by GetScaledIndustryGenerationProbability(), and UpdateViewportPosition().
|
inlinestatic |
Adds a DiagDir to a tile.
tile | The current tile |
dir | The direction in which we want to step |
Definition at line 372 of file map_func.h.
References TILE_ADD, and TileOffsByDiagDir().
Referenced by CleanUpRoadBits(), ClearPathReservation(), CmdRemoveSingleSignal(), GrowTownAtRoad(), GrowTownInTile(), GrowTownWithBridge(), GrowTownWithExtraHouse(), MaskWireBits(), BuildDocksToolbarWindow::OnPlaceObject(), BuildDocksToolbarWindow::OnPlacePresize(), SetWaterClassDependingOnSurroundings(), TrainController(), and TryPathReserve().
This function checks if we add addx/addy to tile, if we do wrap around the edges.
For example, tile = (10,2) and addx = +3 and addy = -4. This function will now return INVALID_TILE, because the y is wrapped. This is needed in for example, farmland. When the tile is not wrapped, the result will be tile + TileDiffXY(addx, addy)
tile | the 'starting' point of the adding |
addx | the amount of tiles in the X direction to add |
addy | the amount of tiles in the Y direction to add |
Definition at line 116 of file map.cpp.
References _settings_game, GameSettings::construction, ConstructionSettings::freeform_edges, INVALID_TILE, MapMaxX(), MapMaxY(), TileX(), TileXY(), and TileY().
Referenced by CheckIfIndustryTilesAreFree(), CmdBuildRoadStop(), CmdRemoveRoadStop(), CountMapSquareAround(), DisasterTick_Big_Ufo_Destroyer(), FindSpring(), PlaceTreeAtSameHeight(), and PlaceTreeGroups().
|
inlinestatic |
Calculates an offset for the given coordinate(-offset).
This function calculate an offset value which can be added to an TileIndex. The coordinates can be negative.
x | The offset in x direction |
y | The offset in y direction |
Definition at line 181 of file map_func.h.
References MapSizeX().
Referenced by ChangeIndustryProduction(), CheckIfCanLevelIndustryPlatform(), CmdBuildBridge(), CmdBuildRailStation(), CmdBuildShipDepot(), CmdRemoveLongRoad(), CmdTerraformLand(), Disaster_CoalMine_Init(), GetHouseNorthPart(), GetNearbyTile(), GetOtherShipDepotTile(), Station::GetPlatformLength(), GetReferenceTile(), Airport::GetRotatedTileFromOffset(), GetStationAround(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), HouseScopeResolver::GetVariable(), GUIPlaceProcDragXY(), IsTileFlat(), MakeTownHouse(), Station::MarkTilesDirty(), NeighbourIsDesert(), OrthogonalTileIterator::operator++(), SetupFarmFieldFence(), TerraformAddDirtyTileAround(), and UpdateHousesAndTowns().
|
inlinestatic |
Returns the TileIndexDiffC offset from a DiagDirection.
dir | The given direction |
Definition at line 270 of file map_func.h.
References _tileoffs_by_diagdir, DIAGDIR_END, and IsValidDiagDirection().
|
inlinestatic |
Returns the TileIndexDiffC offset from a Direction.
dir | The given direction |
Definition at line 284 of file map_func.h.
References _tileoffs_by_dir, DIR_END, and IsValidDirection().
|
inlinestatic |
Returns the diff between two tiles.
tile_a | from tile |
tile_b | to tile |
Definition at line 318 of file map_func.h.
References TileX(), TileY(), TileIndexDiffC::x, and TileIndexDiffC::y.
Referenced by DoWatchedCargoCallback(), GetTownRoadGridElement(), TownLayoutAllows2x2HouseHere(), and TownLayoutAllowsHouseHere().
|
inlinestatic |
Convert a DiagDirection to a TileIndexDiff.
dir | The DiagDirection |
Definition at line 343 of file map_func.h.
References _tileoffs_by_diagdir, DIAGDIR_END, IsValidDiagDirection(), and ToTileIndexDiff().
Referenced by CanConnectToRoad(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanEnterNewTile(), CanFollowRoad(), CheckFree2x2Area(), RoadStop::Entry::CheckIntegrity(), CheckTownBuild2House(), CheckTownBuild2x2House(), RoadStop::ClearDriveThrough(), CmdBuildDock(), CmdBuildLongRoad(), CmdBuildRailStation(), CmdBuildRailWaypoint(), CmdBuildTunnel(), ConnectRoadToStructure(), Disaster_CoalMine_Init(), DisasterTick_Submarine(), DoBuildLock(), DoClearBridge(), DrawRailCatenaryRailway(), DrawTile_TunnelBridge(), ExploreSegment(), ExtendTrainReservation(), FixOwnerOfRailTrack(), FlowRiver(), FollowReservation(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::FollowTileExit(), FollowTrainReservation(), GetBridgeEnd(), GetOtherAqueductEnd(), GetOtherTunnelEnd(), Station::GetPlatformLength(), GetTrainForReservation(), GrowTownWithBridge(), CYapfCostRailT< Types >::IsAnyStationTileReserved(), IsNeighborRoadTile(), IsTunnelInWayDir(), MakeDock(), RoadStop::MakeDriveThrough(), MakeLake(), MakeLock(), MarkBridgeDirty(), NPFRoadVehicleChooseTrack(), NPFSaveTargetData(), NPFShipChooseTrack(), CYapfCostRoadT< Types >::OneTileCost(), OPFShipChooseTrack(), RoadStop::Entry::Rebuild(), RemoveDock(), RemoveLock(), CYapfReserveTrack< Types >::ReserveRailStationPlatform(), SetRailStationPlatformReservation(), TileAddByDiagDir(), TrainApproachingCrossing(), TrainApproachingCrossingTile(), TrainCheckIfLineEnds(), TryBuildLightHouse(), CYapfReserveTrack< Types >::UnreserveSingleTrack(), and UpdateSignalsInBuffer().
|
inlinestatic |
Convert a Direction to a TileIndexDiff.
dir | The direction to convert from |
Definition at line 357 of file map_func.h.
References _tileoffs_by_dir, DIR_END, IsValidDirection(), and ToTileIndexDiff().
Referenced by CircularTileSearch(), FindStationsNearby(), IsWateredTile(), MarkCanalsAndRiversAroundDirty(), and TileLoop_Water().
|
inlinestatic |
Get a tile from the virtual XY-coordinate.
x | The virtual x coordinate of the tile. |
y | The virtual y coordinate of the tile. |
Definition at line 196 of file map_func.h.
References MapLogX().
Referenced by AfterLoadGame(), AircraftController(), CalcRaildirsDrawstyle(), CheckTrainCollision(), DisasterTick_Aircraft(), DisasterVehicle::DisasterVehicle(), DrawStationCoverageAreaText(), DrawTileSelection(), FindNearestHangar(), GetNewVehiclePos(), GetTileHeightBelowAircraft(), HandleAutoSignalPlacement(), SignListWindow::OnClick(), SignWindow::OnClick(), BuildRoadToolbarWindow::OnHotkey(), BuildRailToolbarWindow::OnHotkey(), RemoveRoad(), SetSelectionTilesDirty(), ShowExtraViewPortWindowForTileUnderCursor(), DisasterVehicle::UpdatePosition(), UpdateStatusAfterSwap(), VpHandlePlaceSizingDrag(), VpSelectTilesWithMethod(), and YapfTrainCheckReverse().
|
inlinestatic |
Get the X component of a tile.
tile | the tile to get the X component of |
Definition at line 207 of file map_func.h.
References MapMaxX().
Referenced by OrthogonalTileArea::Add(), AyStar::AddStartNode(), AddTileIndexDiffCWrap(), AfterLoadGame(), AircraftController(), AircraftGetEntryPoint(), AlignTileToGrid(), TileMatrix< uint32, 4 >::AllocateStorage(), CalcClosestStationTile(), CalcHeightdiff(), CanExpandRailStation(), CcBuildIndustry(), CheckIfCanLevelIndustryPlatform(), CheckIfFarEnoughFromConflictingIndustry(), CircularTileSearch(), OrthogonalTileArea::ClampToMap(), CmdBuildAircraft(), CmdBuildBridge(), CmdBuildLongRoad(), CmdBuildObject(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), CmdBuildShip(), CmdBuildTunnel(), CmdClearArea(), CmdPlaceSign(), CmdRemoveLongRoad(), CmdTerraformLand(), OrthogonalTileArea::Contains(), DiagonalTileArea::Contains(), DiagdirBetweenTiles(), DiagonalTileArea::DiagonalTileArea(), Disaster_Small_Ufo_Init(), Disaster_Zeppeliner_Init(), DisasterTick_Aircraft(), DisasterTick_Big_Ufo(), DisasterTick_Ufo(), DistanceFromEdge(), DistanceFromEdgeDir(), DistanceManhattan(), DistanceMax(), DistanceMaxPlusManhattan(), DistanceSquare(), DoCommandP(), DrawTileSelection(), SmallMapWindow::DrawTowns(), FindIndustryToDeliver(), FindStationsAroundTiles(), FindStationsNearby(), TileMatrix< uint32, 4 >::Get(), GetAcceptanceAroundTiles(), TileMatrix< uint32, 4 >::GetAreaForTile(), GetClosestWaterDistance(), GetDriveableTrackdirBits(), GetOtherAqueductEnd(), GetPCPElevation(), GetProductionAroundTiles(), RailTypeScopeResolver::GetRandomBits(), GetRelativePosition(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), GetTLG(), GetTunnelBridgeLength(), HouseScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), GUIPlaceProcDragXY(), Town::InitializeLayout(), InitializeWindowViewport(), OrthogonalTileArea::Intersects(), IsCloseToTown(), IsInnerTile(), IsTileAlignedToGrid(), IsTunnelInWay(), MarkTileDirtyByTile(), NPFDistanceTrack(), NPFHash(), LandInfoWindow::OnInit(), OrthogonalTileArea::OrthogonalTileArea(), PerformStationTileSlopeCheck(), CYapfDestinationTileT< Types >::PfCalcEstimate(), CYapfDestinationTileOrStationRailT< Types >::PfCalcEstimate(), CYapfDestinationTileRoadT< Types >::PfCalcEstimate(), River_Hash(), ScrollMainWindowToTile(), ScrollWindowToTile(), SetupScreenshotViewport(), SetWaterClassDependingOnSurroundings(), ShowBuildBridgeWindow(), SwapDirection(), TerraformAddDirtyTileAround(), TerraformTileHeight(), TileAddWrap(), TileIndexToTileIndexDiffC(), TileStr(), UpdateTownCargoes(), UpdateTownCargoTotal(), Waypoint::UpdateVirtCoord(), Town::UpdateVirtCoord(), Station::UpdateVirtCoord(), VehicleFromPos(), VpSelectTilesWithMethod(), VpSetPresizeRange(), and VpStartPlaceSizing().
|
inlinestatic |
Returns the TileIndex of a coordinate.
x | The x coordinate of the tile |
y | The y coordinate of the tile |
Definition at line 165 of file map_func.h.
References MapLogX().
Referenced by _GenerateWorld(), OrthogonalTileArea::Add(), AddTileIndexDiffCWrap(), AfterLoadGame(), AlignTileToGrid(), TileMatrix< uint32, 4 >::AllocateStorage(), CalcClosestStationTile(), CanExpandRailStation(), CheckIfFarEnoughFromConflictingIndustry(), CheckSubsidised(), CircularTileSearch(), ClampXYToMap(), DEF_CONSOLE_CMD(), Disaster_Small_Ufo_Init(), SmallMapWindow::DrawSmallMapColumn(), FindStationsAroundTiles(), FixSlopes(), FlatEmptyWorld(), GenerateLandscape(), GenerateTerrainPerlin(), GenerateWorld(), GetAcceptanceAroundTiles(), TileMatrix< uint32, 4 >::GetAreaForTile(), GetClosestWaterDistance(), GetProductionAroundTiles(), GrayscaleToMapHeights(), HeightmapCallback(), IsCloseToTown(), DiagonalTileIterator::operator++(), OrthogonalTileArea::OrthogonalTileArea(), Station::RecomputeIndustriesNear(), StationRect::ScanForStationTiles(), SetSelectionTilesDirty(), SetupScreenshotViewport(), TerraformTileHeight(), TileAddWrap(), TileHeightOutsideMap(), TriggerWatchedCargoCallbacks(), TryBuildLightHouse(), UpdateStationAcceptance(), and ViewportAddLandscape().
|
inlinestatic |
Get the Y component of a tile.
tile | the tile to get the Y component of |
Definition at line 217 of file map_func.h.
References MapLogX().
Referenced by OrthogonalTileArea::Add(), AyStar::AddStartNode(), AddTileIndexDiffCWrap(), AfterLoadGame(), AircraftController(), AircraftGetEntryPoint(), AlignTileToGrid(), TileMatrix< uint32, 4 >::AllocateStorage(), CalcClosestStationTile(), CanExpandRailStation(), CcBuildIndustry(), CheckIfCanLevelIndustryPlatform(), CheckIfFarEnoughFromConflictingIndustry(), CircularTileSearch(), OrthogonalTileArea::ClampToMap(), CmdBuildAircraft(), CmdBuildBridge(), CmdBuildLongRoad(), CmdBuildObject(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), CmdBuildShip(), CmdBuildTunnel(), CmdClearArea(), CmdPlaceSign(), CmdRemoveLongRoad(), CmdTerraformLand(), OrthogonalTileArea::Contains(), DiagonalTileArea::Contains(), DiagdirBetweenTiles(), DiagonalTileArea::DiagonalTileArea(), Disaster_Helicopter_Init(), DisasterTick_Aircraft(), DisasterTick_Big_Ufo(), DisasterTick_Ufo(), DistanceFromEdge(), DistanceFromEdgeDir(), DistanceManhattan(), DistanceMax(), DistanceMaxPlusManhattan(), DistanceSquare(), DoCommandP(), DrawTileSelection(), SmallMapWindow::DrawTowns(), FindIndustryToDeliver(), FindStationsAroundTiles(), FindStationsNearby(), TileMatrix< uint32, 4 >::Get(), GetAcceptanceAroundTiles(), TileMatrix< uint32, 4 >::GetAreaForTile(), GetClosestWaterDistance(), GetDriveableTrackdirBits(), GetOtherAqueductEnd(), GetPCPElevation(), GetProductionAroundTiles(), RailTypeScopeResolver::GetRandomBits(), GetRelativePosition(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), GetTLG(), GetTunnelBridgeLength(), HouseScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), GUIPlaceProcDragXY(), Town::InitializeLayout(), InitializeWindowViewport(), OrthogonalTileArea::Intersects(), IsCloseToTown(), IsInnerTile(), IsTileAlignedToGrid(), IsTunnelInWay(), MarkTileDirtyByTile(), NPFDistanceTrack(), NPFHash(), LandInfoWindow::OnInit(), OrthogonalTileArea::OrthogonalTileArea(), PerformStationTileSlopeCheck(), CYapfDestinationTileT< Types >::PfCalcEstimate(), CYapfDestinationTileOrStationRailT< Types >::PfCalcEstimate(), CYapfDestinationTileRoadT< Types >::PfCalcEstimate(), River_Hash(), ScrollMainWindowToTile(), ScrollWindowToTile(), SetupScreenshotViewport(), SetWaterClassDependingOnSurroundings(), ShowBuildBridgeWindow(), SwapDirection(), TerraformAddDirtyTileAround(), TerraformTileHeight(), TileAddWrap(), TileIndexToTileIndexDiffC(), TileStr(), UpdateTownCargoes(), UpdateTownCargoTotal(), Waypoint::UpdateVirtCoord(), Town::UpdateVirtCoord(), Station::UpdateVirtCoord(), VehicleFromPos(), VpSelectTilesWithMethod(), VpSetPresizeRange(), and VpStartPlaceSizing().
|
inlinestatic |
Return the offset between to tiles from a TileIndexDiffC struct.
This function works like TileDiffXY(int, int) and returns the difference between two tiles.
tidc | The coordinate of the offset as TileIndexDiffC |
Definition at line 232 of file map_func.h.
References MapLogX(), TileIndexDiffC::x, and TileIndexDiffC::y.
Referenced by CalcHeightdiff(), CmdBuildDock(), CmdRailTrackHelper(), CmdSignalTrackHelper(), DoCreateNewIndustry(), Ship::GetOrderStationLocation(), Airport::GetRotatedTileFromOffset(), GrowTown(), AirportTileTableIterator::operator++(), RemoveDock(), TerraformTileHeight(), TileOffsByDiagDir(), and TileOffsByDir().
Tile* _m |
Pointer to the tile-array.
This variable points to the tile-array which contains the tiles of the map.
Definition at line 32 of file map.cpp.
Referenced by AddClearCounter(), AddClearDensity(), AddTreeCount(), AddTreeCounter(), AddTreeGrowth(), AfterLoadGame(), ClearSingleBridgeMiddle(), ClearSnow(), FixOldVehicles(), GetBridgeAxis(), GetCleanHouseType(), GetCleanIndustryGfx(), GetClearCounter(), GetClearDensity(), GetCrossingRoadAxis(), GetCustomStationSpecIndex(), GetDepotIndex(), GetDisallowedRoadDirections(), GetFence(), GetFieldType(), GetHouseAge(), GetHouseBuildingStage(), GetHouseConstructionTick(), GetHouseRandomBits(), GetHouseTriggers(), GetIndustryAnimationLoop(), GetIndustryConstructionCounter(), GetIndustryConstructionStage(), GetIndustryIndex(), GetIndustryIndexOfField(), GetIndustryRandomBits(), GetLockDirection(), GetLockPart(), GetObjectIndex(), GetObjectRandomBits(), GetPresentSignals(), GetRailDepotDirection(), GetRailReservationTrackBits(), GetRailTileType(), GetRailType(), GetRawClearGround(), GetRoadBits(), GetRoadDepotDirection(), GetRoadOwner(), GetRoadTileType(), GetShipDepotAxis(), GetShipDepotPart(), GetSignalStates(), GetStationGfx(), GetStationIndex(), GetStationTileRandomBits(), GetTileOwner(), GetTileType(), GetTownIndex(), GetTrackBits(), GetTreeCount(), GetTreeCounter(), GetTreeDensity(), GetTreeGround(), GetTreeGrowth(), GetTreeType(), GetTropicZone(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), GetWaterClass(), GetWaterTileRandomBits(), GetWaterTileType(), HasCrossingReservation(), HasDepotReservation(), HasTunnelBridgeReservation(), IncHouseConstructionTick(), IncrementHouseAge(), IsBridge(), IsBridgeAbove(), IsCrossingBarred(), IsCustomStationSpecIndex(), IsHouseCompleted(), IsIndustryCompleted(), IsSnowTile(), IsTunnel(), MakeBridgeRamp(), MakeClear(), MakeField(), MakeHouseTile(), MakeIndustry(), MakeLockTile(), MakeObject(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeSnow(), MakeStation(), MakeTree(), MakeVoid(), MakeWater(), MoveWaypointsToBaseStations(), ResetHouseAge(), ResetIndustryConstructionStage(), SetBridgeMiddle(), SetClearCounter(), SetClearDensity(), SetClearGroundDensity(), SetCrossingBarred(), SetCrossingReservation(), SetCustomStationSpecIndex(), SetDepotReservation(), SetDisallowedRoadDirections(), SetFence(), SetFieldType(), SetHasSignals(), SetHouseCompleted(), SetHouseRandomBits(), SetHouseTriggers(), SetHouseType(), SetIndustryAnimationLoop(), SetIndustryCompleted(), SetIndustryConstructionCounter(), SetIndustryConstructionStage(), SetIndustryGfx(), SetIndustryIndexOfField(), SetIndustryRandomBits(), SetPresentSignals(), SetRailType(), SetRoadBits(), SetRoadOwner(), SetSignalStates(), SetStationGfx(), SetStationTileRandomBits(), SetTileHeight(), SetTileOwner(), SetTileType(), SetTownIndex(), SetTrackBits(), SetTrackReservation(), SetTreeCounter(), SetTreeGroundDensity(), SetTreeGrowth(), SetTropicZone(), SetTunnelBridgeReservation(), SetWaterClass(), SetWaterClassDependingOnSurroundings(), TileHeight(), and CrashLog::WriteSavegame().
TileExtended* _me |
Pointer to the extended tile-array.
This variable points to the extended tile-array which contains the tiles of the map.
Definition at line 33 of file map.cpp.
Referenced by AfterLoadGame(), DecHouseProcessingTime(), GetAnimationFrame(), GetBridgeType(), GetCleanIndustryGfx(), GetFence(), GetHouseProcessingTime(), GetIndustryTriggers(), GetLiftDestination(), GetLiftPosition(), GetRoadOwner(), GetRoadside(), GetRoadTypes(), GetStationType(), HaltLift(), HasStationReservation(), HasTunnelBridgeSnowOrDesert(), IncreaseRoadWorksCounter(), IsOnSnow(), LiftHasDestination(), MakeBridgeRamp(), MakeClear(), MakeField(), MakeIndustry(), MakeLockTile(), MakeObject(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeVoid(), MakeWater(), MoveBuoysToWaypoints(), SetAnimationFrame(), SetFence(), SetHouseProcessingTime(), SetIndustryGfx(), SetIndustryTriggers(), SetLiftDestination(), SetLiftPosition(), SetRailStationReservation(), SetRoadOwner(), SetRoadside(), SetRoadTypes(), SetTunnelBridgeSnowOrDesert(), TerminateRoadWorks(), and ToggleSnow().