|
OpenTTD Source 20260311-master-g511d3794ce
|
Functions related to OTTD's landscape. More...
Go to the source code of this file.
Data Structures | |
| struct | SnowLine |
| Structure describing the height of the snow line each day of the year. More... | |
Functions | |
| bool | IsSnowLineSet () |
| Has a snow line table already been loaded. | |
| void | SetSnowLine (std::unique_ptr< SnowLine > &&snow_line) |
| Set a variable snow line, as loaded from a newgrf file. | |
| uint8_t | GetSnowLine () |
| Get the current snow line, either variable or static. | |
| uint8_t | HighestSnowLine () |
| Get the highest possible snow line height, either variable or static. | |
| uint8_t | LowestSnowLine () |
| Get the lowest possible snow line height, either variable or static. | |
| void | ClearSnowLine () |
| Clear the variable snow line table and free the memory. | |
| bool | IsMapSurroundedByWater () |
| Check if all tiles on the map edge should be considered water borders. | |
| int | GetSlopeZInCorner (Slope tileh, Corner corner) |
| Determine the Z height of a corner relative to TileZ. | |
| std::tuple< Slope, int > | GetFoundationSlope (TileIndex tile) |
| Get slope of a tile on top of a (possible) foundation If a tile does not have a foundation, the function returns the same as GetTileSlope. | |
| uint | GetPartialPixelZ (int x, int y, Slope corners) |
| Determines height at given coordinate of a slope. | |
| int | GetSlopePixelZ (int x, int y, bool ground_vehicle=false) |
Return world Z coordinate of a given point of a tile. | |
| int | GetSlopePixelZOutsideMap (int x, int y) |
Return world z coordinate of a given point of a tile, also for tiles outside the map (virtual "black" tiles). | |
| void | GetSlopePixelZOnEdge (Slope tileh, DiagDirection edge, int &z1, int &z2) |
| Determine the Z height of the corners of a specific tile edge. | |
| int | GetSlopePixelZInCorner (Slope tileh, Corner corner) |
| Determine the Z height of a corner relative to TileZ. | |
| std::tuple< Slope, int > | GetFoundationPixelSlope (TileIndex tile) |
| Get slope of a tile on top of a (possible) foundation If a tile does not have a foundation, the function returns the same as GetTilePixelSlope. | |
| Point | RemapCoords (int x, int y, int z) |
| Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap. | |
| Point | RemapCoords2 (int x, int y) |
| Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap. | |
| Point | InverseRemapCoords (int x, int y) |
| Map 2D viewport or smallmap coordinate to 3D world or tile coordinate. | |
| Point | InverseRemapCoords2 (int x, int y, bool clamp_to_map=false, bool *clamped=nullptr) |
| Map 2D viewport or smallmap coordinate to 3D world or tile coordinate. | |
| uint | ApplyFoundationToSlope (Foundation f, Slope &s) |
| Applies a foundation to a slope. | |
| uint | ApplyPixelFoundationToSlope (Foundation f, Slope &s) |
| Applies a foundation to a slope. | |
| void | DrawFoundation (TileInfo *ti, Foundation f) |
| Draw foundation f at tile ti. | |
| bool | HasFoundationNW (TileIndex tile, Slope slope_here, uint z_here) |
| bool | HasFoundationNE (TileIndex tile, Slope slope_here, uint z_here) |
| void | DoClearSquare (TileIndex tile) |
| void | RunTileLoop () |
| Gradually iterate over all tiles on the map, calling their TileLoopProcs once every TILE_UPDATE_FREQUENCY ticks. | |
| void | InitializeLandscape () |
| bool | GenerateLandscape (uint8_t mode) |
Variables | |
| static const uint | SNOW_LINE_MONTHS = 12 |
| Number of months in the snow line table. | |
| static const uint | SNOW_LINE_DAYS = 32 |
| Number of days in each month in the snow line table. | |
Functions related to OTTD's landscape.
Definition in file landscape.h.
| uint ApplyFoundationToSlope | ( | Foundation | f, |
| Slope & | s ) |
Applies a foundation to a slope.
| f | The Foundation. |
| s | The Slope to modify. |
Definition at line 180 of file landscape.cpp.
References FOUNDATION_INCLINED_X, FOUNDATION_INCLINED_Y, FOUNDATION_STEEP_BOTH, FOUNDATION_STEEP_LOWER, GetHalftileFoundationCorner(), GetHighestSlopeCorner(), GetRailFoundationCorner(), HalftileSlope(), IsFoundation(), IsLeveledFoundation(), IsNonContinuousFoundation(), IsSpecialRailFoundation(), IsSteepSlope(), OppositeCorner(), SLOPE_FLAT, SLOPE_NE, SLOPE_NW, SLOPE_SE, SLOPE_SW, SlopeWithOneCornerRaised(), and SlopeWithThreeCornersRaised().
Referenced by ApplyPixelFoundationToSlope(), CheckBridgeSlope(), DrawRailCatenaryRailway(), FloodHalftile(), GetBridgeHeight(), GetFoundationSlope(), HasBridgeFlatRamp(), TerraformTile_Road(), and TestAutoslopeOnRailTile().
|
inline |
Applies a foundation to a slope.
| f | The Foundation. |
| s | The Slope to modify. |
Definition at line 128 of file landscape.h.
References ApplyFoundationToSlope(), and TILE_HEIGHT.
Referenced by DrawFoundation(), GetSlopePixelZ_Rail(), GetSlopePixelZ_Road(), and GetSlopePixelZ_TunnelBridge().
| void DoClearSquare | ( | TileIndex | tile | ) |
Definition at line 542 of file landscape.cpp.
| void DrawFoundation | ( | TileInfo * | ti, |
| Foundation | f ) |
Draw foundation f at tile ti.
Updates ti.
| ti | Tile to draw foundation on |
| f | Foundation to draw |
Definition at line 435 of file landscape.cpp.
References AddSortableSpriteToDraw(), ApplyPixelFoundationToSlope(), SpriteBounds::extent, FOUNDATION_INCLINED_X, FOUNDATION_INCLINED_Y, FOUNDATION_STEEP_BOTH, FOUNDATION_STEEP_LOWER, GetFoundationPixelSlope(), GetHalftileFoundationCorner(), GetHighestSlopeCorner(), GetRailFoundationCorner(), IsFoundation(), IsInclinedFoundation(), IsLeveledFoundation(), IsNonContinuousFoundation(), IsSpecialRailFoundation(), IsSteepSlope(), OffsetGroundSprite(), Point, SLOPE_EW, SLOPE_NE, SLOPE_NS, SLOPE_STEEP, SLOPE_SW, SlopeWithOneCornerRaised(), SlopeWithThreeCornersRaised(), SPR_HALFTILE_FOUNDATION_BASE, TileInfo::tile, TILE_HEIGHT, TILE_SIZE, TileInfo::tileh, Coord2D< T >::x, Coord3D< T >::x, Coord2D< T >::y, Coord3D< T >::y, and Coord3D< T >::z.
Referenced by DrawRoadBits(), DrawTile_Industry(), DrawTile_Object(), DrawTile_Rail(), DrawTile_Road(), DrawTile_Station(), DrawTile_Town(), DrawTile_TunnelBridge(), and DrawTrackBits().
| bool GenerateLandscape | ( | uint8_t | mode | ) |
< Loading a heightmap
< Terragenesis generator
< Original generator
< Extra steps needed for tropic landscape
< Extra steps for other landscapes
Definition at line 1618 of file landscape.cpp.
References _file_to_saveload, _settings_game, Arctic, CalculateDesertLine(), CalculateSnowLine(), Clamp(), CreateRivers(), CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY, FixSlopes(), GB(), GenerateTerrainPerlin(), GWM_HEIGHTMAP, GWP_LANDSCAPE, IncreaseGeneratingWorldProgress(), LG_TERRAGENESIS, LoadHeightmap(), MakeVoid(), MarkWholeScreenDirty(), Map::ScaleBySize(), SetGeneratingWorldProgress(), Map::SizeX(), Map::SizeY(), TileXY(), and Tropic.
Referenced by _GenerateWorld().
Get slope of a tile on top of a (possible) foundation If a tile does not have a foundation, the function returns the same as GetTilePixelSlope.
| tile | The tile of interest. |
Definition at line 67 of file landscape.h.
References GetFoundationSlope(), and TILE_HEIGHT.
Referenced by DrawCustomStationFoundations(), and DrawFoundation().
Get slope of a tile on top of a (possible) foundation If a tile does not have a foundation, the function returns the same as GetTileSlope.
| tile | The tile of interest. |
Definition at line 392 of file landscape.cpp.
References _tile_type_procs, ApplyFoundationToSlope(), GetTileSlopeZ(), and GetTileType().
Referenced by GetFoundationPixelSlope(), IsPossibleCrossing(), IsRoadAllowedHere(), TileLoop_Road(), and TileLoop_Water().
| uint GetPartialPixelZ | ( | int | x, |
| int | y, | ||
| Slope | corners ) |
Determines height at given coordinate of a slope.
At the northern corner (0, 0) the result is always a multiple of TILE_HEIGHT. When the height is a fractional Z, then the height is rounded down. For example, when at the height is 0 at x = 0 and the height is 8 at x = 16 (actually x = 0 of the next tile), then height is 0 at x = 1, 1 at x = 2, and 7 at x = 15.
| x | x coordinate (value from 0 to 15) |
| y | y coordinate (value from 0 to 15) |
| corners | slope to examine |
Definition at line 238 of file landscape.cpp.
References GetHalftileSlopeCorner(), GetSlopeMaxPixelZ(), IsHalftileSlope(), RemoveHalftileSlope(), SLOPE_E, SLOPE_ELEVATED, SLOPE_ENW, SLOPE_EW, SLOPE_FLAT, SLOPE_N, SLOPE_NE, SLOPE_NS, SLOPE_NW, SLOPE_NWS, SLOPE_S, SLOPE_SE, SLOPE_SEN, SLOPE_STEEP_E, SLOPE_STEEP_N, SLOPE_STEEP_S, SLOPE_STEEP_W, SLOPE_SW, SLOPE_W, SLOPE_WSE, TILE_HEIGHT, and TILE_SIZE.
Referenced by DrawRoadBits(), GetSlopePixelZ_Clear(), GetSlopePixelZ_Object(), GetSlopePixelZ_Rail(), GetSlopePixelZ_Road(), GetSlopePixelZ_Trees(), GetSlopePixelZ_TunnelBridge(), GetSlopePixelZ_Void(), and GetSlopePixelZ_Water().
| int GetSlopePixelZ | ( | int | x, |
| int | y, | ||
| bool | ground_vehicle ) |
Return world Z coordinate of a given point of a tile.
Normally this is the Z of the ground/foundation at the given location, but in some cases the ground/foundation can differ from the Z coordinate that the (ground) vehicle passing over it would take. For example when entering a tunnel or bridge.
| x | World X coordinate in tile "units". |
| y | World Y coordinate in tile "units". |
| ground_vehicle | Whether to get the Z coordinate of the ground vehicle, or the ground. |
Definition at line 313 of file landscape.cpp.
References _tile_type_procs, GetTileType(), and TileVirtXY().
Referenced by AfterLoadGame(), AircraftController(), CheckGroundVehiclesAtCorrectZ(), CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), CmdBuildShip(), CmdMoveSign(), CmdPlaceSign(), CreateEffectVehicleAbove(), DisasterTick_Big_Ufo(), DisasterTick_Zeppeliner(), DrawRailCatenaryRailway(), DrawRoadDetail(), FixVehicleInclination(), GetPCPElevation(), GetSafeSlopeZ(), GetSlopePixelZOutsideMap(), HandleCrashedAircraft(), InitializeWindowViewport(), CommandHelperBase::InternalPostResult(), InverseRemapCoords2(), RemapCoords2(), ScrollWindowTo(), SetAircraftPosition(), DisasterVehicle::UpdatePosition(), GroundVehicle< T, Type >::UpdateZPosition(), GroundVehicle< T, Type >::UpdateZPositionAndInclination(), and VehicleEnterTile_TunnelBridge().
Determine the Z height of a corner relative to TileZ.
| tileh | The slope. |
| corner | The corner. |
Definition at line 55 of file landscape.h.
References GetSlopeZInCorner(), and TILE_HEIGHT.
Referenced by DrawRoadTypeCatenary(), and DrawTrackFence().
| void GetSlopePixelZOnEdge | ( | Slope | tileh, |
| DiagDirection | edge, | ||
| int & | z1, | ||
| int & | z2 ) |
Determine the Z height of the corners of a specific tile edge.
| tileh | The slope of the tile. |
| edge | The edge of interest. |
| z1 | Gets incremented by the height of the first corner of the edge. (near corner wrt. the camera) |
| z2 | Gets incremented by the height of the second corner of the edge. (far corner wrt. the camera) |
Definition at line 364 of file landscape.cpp.
References GetHalftileSlopeCorner(), IsHalftileSlope(), RemoveHalftileSlope(), SLOPE_E, SLOPE_N, SLOPE_S, SLOPE_STEEP_E, SLOPE_STEEP_N, SLOPE_STEEP_S, SLOPE_STEEP_W, SLOPE_W, SlopeWithOneCornerRaised(), and TILE_HEIGHT.
Referenced by DrawBridgePillars().
| int GetSlopePixelZOutsideMap | ( | int | x, |
| int | y ) |
Return world z coordinate of a given point of a tile, also for tiles outside the map (virtual "black" tiles).
| x | World X coordinate in tile "units", may be outside the map. |
| y | World Y coordinate in tile "units", may be outside the map. |
Definition at line 328 of file landscape.cpp.
References _tile_type_procs, GetSlopePixelZ(), INVALID_TILE, IsInsideBS(), Map::SizeX(), Map::SizeY(), TILE_SIZE, and Void.
Referenced by InverseRemapCoords2().
Determine the Z height of a corner relative to TileZ.
| tileh | The slope. |
| corner | The corner. |
Definition at line 346 of file landscape.cpp.
References IsHalftileSlope(), SlopeWithOneCornerRaised(), and SteepSlope().
Referenced by GetSlopePixelZInCorner(), TerraformTile_Rail(), and TestAutoslopeOnRailTile().
Definition at line 416 of file landscape.cpp.
Definition at line 401 of file landscape.cpp.
| void InitializeLandscape | ( | ) |
Definition at line 844 of file landscape.cpp.
|
inline |
Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
Function assumes z == 0. For other values of z, add z to y before the call.
| x | X coordinate of the 2D coordinate. |
| y | Y coordinate of the 2D coordinate. |
Definition at line 111 of file landscape.h.
References Point.
Referenced by InverseRemapCoords2(), SmallMapWindow::SetNewScroll(), and ViewportAddLandscape().
| Point InverseRemapCoords2 | ( | int | x, |
| int | y, | ||
| bool | clamp_to_map, | ||
| bool * | clamped ) |
Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
Function takes into account height of tiles and foundations.
| x | X viewport 2D coordinate. | |
| y | Y viewport 2D coordinate. | |
| clamp_to_map | Clamp the coordinate outside of the map to the closest, non-void tile within the map. | |
| [out] | clamped | Whether coordinates were clamped. |
Definition at line 121 of file landscape.cpp.
References _settings_game, CeilDiv(), Clamp(), GetSlopePixelZ(), GetSlopePixelZOutsideMap(), InverseRemapCoords(), Map::MaxX(), Map::MaxY(), Point, TILE_HEIGHT, TILE_PIXELS, TILE_SIZE, Coord2D< T >::x, and Coord2D< T >::y.
Referenced by ClampViewportToMap(), SmallMapWindow::DrawMapIndicators(), SmallMapWindow::SmallMapCenterOnCurrentPos(), and TranslateXYToTileCoord().
| bool IsMapSurroundedByWater | ( | ) |
Check if all tiles on the map edge should be considered water borders.
Definition at line 653 of file landscape.cpp.
References GetTilePixelSlopeOutsideMap(), Map::SizeX(), Map::SizeY(), and SLOPE_FLAT.
Referenced by LoadHeightmap().
|
inline |
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
| x | X world or tile coordinate (runs in SW direction in the 2D view). |
| y | Y world or tile coordinate (runs in SE direction in the 2D view). |
| z | Z world or tile coordinate (runs in N direction in the 2D view). |
Definition at line 81 of file landscape.h.
References Point, Coord2D< T >::x, and Coord2D< T >::y.
Referenced by AddCombinedSprite(), AddSortableSpriteToDraw(), AddTileSpriteToDraw(), CcStartStopVehicle(), DrawCommonTileSeqInGUI(), DrawGroundSpriteAt(), DrawHouseInGUI(), MarkTileDirtyByTile(), IntroGameViewportCommand::PositionForViewport(), SelectGameWindow::ReadIntroGameViewportCommand(), RemapCoords2(), SetSelectionTilesDirty(), SetupScreenshotViewport(), ShowCostOrIncomeAnimation(), ShowFeederIncomeAnimation(), ShowFillingPercent(), Vehicle::UpdateBoundingBoxCoordinates(), Sign::UpdateVirtCoord(), and ViewportDrawBoundingBoxes().
|
inline |
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
Same as RemapCoords, except the Z coordinate is read from the map.
| x | X world or tile coordinate (runs in SW direction in the 2D view). |
| y | Y world or tile coordinate (runs in SE direction in the 2D view). |
Definition at line 97 of file landscape.h.
References GetSlopePixelZ(), Point, and RemapCoords().
Referenced by ClampViewportToMap(), Station::UpdateVirtCoord(), Town::UpdateVirtCoord(), and Waypoint::UpdateVirtCoord().
| void RunTileLoop | ( | ) |
Gradually iterate over all tiles on the map, calling their TileLoopProcs once every TILE_UPDATE_FREQUENCY ticks.
Definition at line 804 of file landscape.cpp.
References _tile_type_procs, TimerGameTick::counter, GetTileType(), lengthof, Map::LogX(), Map::LogY(), MAX_MAP_SIZE_BITS, MIN_MAP_SIZE_BITS, PFE_GL_LANDSCAPE, TILE_UPDATE_FREQUENCY, and TILE_UPDATE_FREQUENCY_LOG.
Referenced by _GenerateWorld(), CreateRivers(), and StateGameLoop().
|
static |
Number of days in each month in the snow line table.
Definition at line 17 of file landscape.h.
Referenced by GlobalVarChangeInfo().
|
static |
Number of months in the snow line table.
Definition at line 16 of file landscape.h.
Referenced by GlobalVarChangeInfo().