OpenTTD Source 20241224-master-gee860a5c8e
|
Size related data of the map. More...
#include <map_func.h>
Data Structures | |
struct | IterateWrapper |
struct | Iterator |
Iterator to iterate all Tiles. More... | |
Static Public Member Functions | |
static void | Allocate (uint size_x, uint size_y) |
(Re)allocates a map with the given dimension | |
static debug_inline uint | LogX () |
Logarithm of the map size along the X side. | |
static uint | LogY () |
Logarithm of the map size along the y side. | |
static debug_inline uint | SizeX () |
Get the size of the map along the X. | |
static uint | SizeY () |
Get the size of the map along the Y. | |
static debug_inline uint | Size () |
Get the size of the map. | |
static debug_inline uint | MaxX () |
Gets the maximum X coordinate within the map, including MP_VOID. | |
static uint | MaxY () |
Gets the maximum Y coordinate within the map, including MP_VOID. | |
static TileIndex | WrapToMap (TileIndex tile) |
'Wraps' the given "tile" so it is within the map. | |
static uint | ScaleBySize (uint n) |
Scales the given value by the map size, where the given value is for a 256 by 256 map. | |
static uint | ScaleBySize1D (uint n) |
Scales the given value by the maps circumference, where the given value is for a 256 by 256 map. | |
static bool | IsInitialized () |
Check whether the map has been initialized, as to not try to save the map during crashlog when the map is not there yet. | |
static IterateWrapper | Iterate () |
Returns an iterable ensemble of all Tiles. | |
Static Private Attributes | |
static uint | log_x |
2^_map_log_x == _map_size_x | |
static uint | log_y |
2^_map_log_y == _map_size_y | |
static uint | size_x |
Size of the map along the X. | |
static uint | size_y |
Size of the map along the Y. | |
static uint | size |
The number of tiles on the map. | |
static uint | tile_mask |
_map_size - 1 (to mask the mapsize) | |
Size related data of the map.
Definition at line 206 of file map_func.h.
|
static |
(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 36 of file map.cpp.
References AllocateWaterRegions(), Tile::base_tiles, Debug, Tile::extended_tiles, FindFirstBit(), free(), IsInsideMM(), log_x, log_y, MAX_MAP_SIZE, MIN_MAP_SIZE, size, size_x, size_y, and tile_mask.
Referenced by MAPSChunkHandler::Load().
|
inlinestatic |
Check whether the map has been initialized, as to not try to save the map during crashlog when the map is not there yet.
Definition at line 354 of file map_func.h.
References Tile::base_tiles.
Referenced by CrashLog::WriteSavegame().
|
inlinestatic |
Returns an iterable ensemble of all Tiles.
Definition at line 363 of file map_func.h.
Referenced by AfterLoadGame(), CalculateCoverageLine(), ChangeOwnershipOfCompanyItems(), ClickChangeMaxHlCheat(), CmdDeleteTown(), ConvertRailTypes(), ConvertRoadTypes(), GetClosestWaterDistance(), MakeHeightmapScreenshot(), MoveWaypointsToBaseStations(), RebuildTownCaches(), SetDefaultRailGui(), UpdateHousesAndTowns(), UpdateNearestTownForRoadTiles(), and Town::~Town().
|
inlinestatic |
Logarithm of the map size along the X side.
Definition at line 251 of file map_func.h.
References log_x.
Referenced by HeightMapGenerate(), RunTileLoop(), ScaleBySize(), ScaleBySize1D(), StartupIndustryDailyChanges(), TGPGetMaxHeight(), TileVirtXY(), TileXY(), and TileY().
|
inlinestatic |
Logarithm of the map size along the y side.
Definition at line 261 of file map_func.h.
References log_y.
Referenced by HeightMapGenerate(), RunTileLoop(), ScaleBySize(), ScaleBySize1D(), StartupIndustryDailyChanges(), and TGPGetMaxHeight().
|
inlinestatic |
Gets the maximum X coordinate within the map, including MP_VOID.
Definition at line 297 of file map_func.h.
References SizeX().
Referenced by AfterLoadGame(), CalcRaildirsDrawstyle(), CheckIfCanLevelIndustryPlatform(), CmdBuildTunnel(), CreateEffectVehicleAbove(), DisasterTick_Aircraft(), DistanceFromEdgeDir(), SmallMapWindow::DrawSmallMapColumn(), FindStationsAroundSelection(), Station::GetCatchmentRect(), GetClosestWaterDistance(), GetTileHeightBelowAircraft(), GetTileMaxZ(), GetTileSlopeZ(), GetTileZ(), GUIPlaceProcDragXY(), HandleCrashedAircraft(), HeightmapCallback(), InverseRemapCoords2(), IsInnerTile(), IsTileFlat(), IsTunnelInWay(), LoadTownData(), BuildObjectWindow::OnPlaceMouseUp(), TerraformToolbarWindow::OnPlaceMouseUp(), SetAircraftPosition(), SmallMapWindow::SetNewScroll(), SetSelectionTilesDirty(), SetWaterClassDependingOnSurroundings(), TerraformTileHeight(), TileAddWrap(), TileHeightOutsideMap(), TileX(), TryBuildLightHouse(), and DisasterVehicle::UpdatePosition().
|
inlinestatic |
Gets the maximum Y coordinate within the map, including MP_VOID.
Definition at line 306 of file map_func.h.
References SizeY().
Referenced by AfterLoadGame(), CalcRaildirsDrawstyle(), CheckIfCanLevelIndustryPlatform(), CreateEffectVehicleAbove(), DistanceFromEdgeDir(), SmallMapWindow::DrawSmallMapColumn(), FindStationsAroundSelection(), Station::GetCatchmentRect(), GetClosestWaterDistance(), GetTileHeightBelowAircraft(), GetTileMaxZ(), GetTileSlopeZ(), GetTileZ(), GUIPlaceProcDragXY(), HandleCrashedAircraft(), InverseRemapCoords2(), IsInnerTile(), IsTileFlat(), IsTunnelInWay(), LoadTownData(), BuildObjectWindow::OnPlaceMouseUp(), TerraformToolbarWindow::OnPlaceMouseUp(), SetAircraftPosition(), SmallMapWindow::SetNewScroll(), SetSelectionTilesDirty(), SetWaterClassDependingOnSurroundings(), TerraformTileHeight(), TileAddWrap(), TileHeightOutsideMap(), TryBuildLightHouse(), and DisasterVehicle::UpdatePosition().
|
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 328 of file map_func.h.
References CeilDiv(), LogX(), and LogY().
Referenced by CreateRivers(), DecrementTreeCounter(), IndustryBuildData::EconomyMonthlyLoop(), GenerateLandscape(), GenerateTowns(), GenerateTrees(), GetNumberOfIndustries(), GetScaledIndustryGenerationProbability(), 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 341 of file map_func.h.
References CeilDiv(), LogX(), and LogY().
Referenced by ClampSmoothScroll(), and GetScaledIndustryGenerationProbability().
|
inlinestatic |
Get the size of the map.
Definition at line 288 of file map_func.h.
References size.
Referenced by CalculateCoverageLine(), OrthogonalTileArea::ClampToMap(), CmdBuildCanal(), CmdBuildLongRoad(), CmdBuildObjectArea(), CmdClearArea(), CmdConvertRail(), CmdConvertRoad(), CmdLevelLand(), CmdPlantTree(), CmdRailTrackHelper(), CmdRemoveFromRailStation(), CmdRemoveFromRailWaypoint(), CmdRemoveFromRoadWaypoint(), CmdRemoveLongRoad(), CmdSignalTrackHelper(), CmdTerraformLand(), DEF_CONSOLE_CMD(), DiagonalTileArea::DiagonalTileArea(), CommandHelper< Tcmd, Tret(*)(DoCommandFlag, Targs...), true >::Do(), DrawStationCoverageAreaText(), DrawTile_Road(), FindStationsNearby(), GetTileType(), GetTropicZone(), GrowTownAtRoad(), GrowTownInTile(), IsInnerTile(), IsValidTile(), MAPTChunkHandler::Load(), MAPHChunkHandler::Load(), MAPOChunkHandler::Load(), MAP2ChunkHandler::Load(), M3LOChunkHandler::Load(), M3HIChunkHandler::Load(), MAP5ChunkHandler::Load(), MAPEChunkHandler::Load(), MAP7ChunkHandler::Load(), MAP8ChunkHandler::Load(), MarkDirtyAdjacentLevelCrossingTiles(), DiagonalTileIterator::operator++(), OrthogonalTileArea::OrthogonalTileArea(), MAPTChunkHandler::Save(), MAPHChunkHandler::Save(), MAPOChunkHandler::Save(), MAP2ChunkHandler::Save(), M3LOChunkHandler::Save(), M3HIChunkHandler::Save(), MAP5ChunkHandler::Save(), MAPEChunkHandler::Save(), MAP7ChunkHandler::Save(), MAP8ChunkHandler::Save(), SetTileHeight(), SetTileType(), SetTropicZone(), SetupScreenshotViewport(), TerraformTileHeight(), TileHeight(), TryBuildLightHouse(), UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(), and UpdateLevelCrossing().
|
inlinestatic |
Get the size of the map along the X.
Definition at line 270 of file map_func.h.
References size_x.
Referenced by _GenerateWorld(), AddTileIndexDiffCWrap(), AllocHeightMap(), CheckScaledDistanceFromEdge(), CircularTileSearch(), OrthogonalTileArea::ClampToMap(), DEF_CONSOLE_CMD(), Disaster_Small_Ufo_Init(), DisasterTick_Aircraft(), DisasterTick_Big_Ufo_Destroyer(), DistanceFromEdge(), OrthogonalTileArea::Expand(), FixSlopes(), FlatEmptyWorld(), ForAllStationsRadius(), GenerateLandscape(), GenerateTerrainPerlin(), GenerateWorld(), GetSlopePixelZOutsideMap(), GrayscaleToMapHeights(), AirportSpec::IsWithinMapBounds(), MakeHeightmapScreenshot(), MakeMinimapWorldScreenshot(), MakeScreenshotWithConfirm(), MaxX(), DiagonalTileIterator::operator++(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(), MAPSChunkHandler::Save(), ScrollWindowTo(), ServerNetworkAdminSocketHandler::SendWelcome(), SetSelectionTilesDirty(), TileDiffXY(), and ViewportAddLandscape().
|
inlinestatic |
Get the size of the map along the Y.
Definition at line 279 of file map_func.h.
References size_y.
Referenced by _GenerateWorld(), AddTileIndexDiffCWrap(), AllocHeightMap(), CheckScaledDistanceFromEdge(), CircularTileSearch(), OrthogonalTileArea::ClampToMap(), DEF_CONSOLE_CMD(), Disaster_Small_Ufo_Init(), DisasterTick_Zeppeliner(), DistanceFromEdge(), OrthogonalTileArea::Expand(), FixSlopes(), FlatEmptyWorld(), ForAllStationsRadius(), GenerateLandscape(), GenerateTerrainPerlin(), GenerateWorld(), GetSlopePixelZOutsideMap(), GrayscaleToMapHeights(), AirportSpec::IsWithinMapBounds(), MakeHeightmapScreenshot(), MakeMinimapWorldScreenshot(), MakeScreenshotWithConfirm(), MaxY(), DiagonalTileIterator::operator++(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(), MAPSChunkHandler::Save(), ScrollWindowTo(), ServerNetworkAdminSocketHandler::SendWelcome(), SetSelectionTilesDirty(), and ViewportAddLandscape().
'Wraps' the given "tile" so it is within the map.
It does this by masking the 'high' bits of.
tile | the tile to 'wrap' |
Definition at line 317 of file map_func.h.
References tile_mask.
Referenced by GetNearbyTile(), HouseScopeResolver::GetVariable(), RandomTileSeed(), and SetupFarmFieldFence().
|
staticprivate |
2^_map_log_x == _map_size_x
Definition at line 236 of file map_func.h.
Referenced by Allocate(), and LogX().
|
staticprivate |
2^_map_log_y == _map_size_y
Definition at line 237 of file map_func.h.
Referenced by Allocate(), and LogY().
|
staticprivate |
The number of tiles on the map.
Definition at line 240 of file map_func.h.
Referenced by Allocate(), MultiMap< Tkey, Tvalue, Tcompare >::MapSize(), and Size().
|
staticprivate |
Size of the map along the X.
Definition at line 238 of file map_func.h.
Referenced by Allocate(), and SizeX().
|
staticprivate |
Size of the map along the Y.
Definition at line 239 of file map_func.h.
Referenced by Allocate(), and SizeY().
|
staticprivate |
_map_size - 1 (to mask the mapsize)
Definition at line 241 of file map_func.h.
Referenced by Allocate(), and WrapToMap().