|
OpenTTD Source 20251213-master-g1091fa6071
|
Functions related to the landscape (slopes etc.). More...
#include "stdafx.h"#include "heightmap.h"#include "clear_map.h"#include "spritecache.h"#include "viewport_func.h"#include "command_func.h"#include "landscape.h"#include "void_map.h"#include "tgp.h"#include "genworld.h"#include "fios.h"#include "error_func.h"#include "timer/timer_game_calendar.h"#include "timer/timer_game_tick.h"#include "water.h"#include "effectvehicle_func.h"#include "landscape_type.h"#include "animated_tile_func.h"#include "core/random_func.hpp"#include "object_base.h"#include "tree_cmd.h"#include "company_func.h"#include "company_gui.h"#include "saveload/saveload.h"#include "framerate_type.h"#include "landscape_cmd.h"#include "terraform_cmd.h"#include "station_func.h"#include "pathfinder/water_regions.h"#include "pathfinder/yapf/yapf_river_builder.h"#include "table/strings.h"#include "table/sprites.h"#include <unordered_set>#include "safeguards.h"#include "table/genland.h"Go to the source code of this file.
Functions | |
| Point | InverseRemapCoords2 (int x, int y, bool clamp_to_map, bool *clamped) |
| 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 | GetPartialPixelZ (int x, int y, Slope corners) |
| Determines height at given coordinate of a slope. | |
| int | GetSlopePixelZ (int x, int y, bool ground_vehicle) |
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). | |
| int | GetSlopeZInCorner (Slope tileh, Corner corner) |
| Determine the Z height of a corner relative to TileZ. | |
| void | GetSlopePixelZOnEdge (Slope tileh, DiagDirection edge, int &z1, int &z2) |
| Determine the Z height of the corners of a specific tile edge. | |
| 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. | |
| bool | HasFoundationNW (TileIndex tile, Slope slope_here, uint z_here) |
| bool | HasFoundationNE (TileIndex tile, Slope slope_here, uint z_here) |
| void | DrawFoundation (TileInfo *ti, Foundation f) |
| Draw foundation f at tile ti. | |
| void | DoClearSquare (TileIndex tile) |
| TrackStatus | GetTileTrackStatus (TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side) |
| Returns information about trackdirs and signal states. | |
| void | ChangeTileOwner (TileIndex tile, Owner old_owner, Owner new_owner) |
| Change the owner of a tile. | |
| void | GetTileDesc (TileIndex tile, TileDesc &td) |
| 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. | |
| CommandCost | CmdLandscapeClear (DoCommandFlags flags, TileIndex tile) |
| Clear a piece of landscape. | |
| std::tuple< CommandCost, Money > | CmdClearArea (DoCommandFlags flags, TileIndex tile, TileIndex start_tile, bool diagonal) |
| Clear a big piece of landscape. | |
| void | RunTileLoop () |
| Gradually iterate over all tiles on the map, calling their TileLoopProcs once every TILE_UPDATE_FREQUENCY ticks. | |
| void | InitializeLandscape () |
| static void | GenerateTerrain (int type, uint flag) |
| static void | CreateDesertOrRainForest (uint desert_tropic_line) |
| static bool | FindSpring (TileIndex tile) |
| Find the spring of a river. | |
| static bool | IsValidRiverTerminusTile (TileIndex tile, uint height) |
| Is this a valid tile for the water feature at the end of a river? | |
| static void | MakeLake (TileIndex lake_centre, uint height_lake) |
| Make a lake centred on the given tile, of a random diameter. | |
| static void | MakeWetlands (TileIndex centre, uint height, uint river_length) |
| Make wetlands around the given tile. | |
| static bool | TryMakeRiverTerminus (TileIndex tile, TileIndex begin) |
| Try to end a river at a tile which is not the sea. | |
| void | RiverMakeWider (TileIndex tile, TileIndex origin_tile) |
| Widen a river by expanding into adjacent tiles via circular tile search. | |
| bool | RiverFlowsDown (TileIndex begin, TileIndex end) |
| Check whether a river at begin could (logically) flow down to end. | |
| static bool | CountConnectedSeaTiles (TileIndex tile, std::unordered_set< TileIndex > &sea, const uint limit) |
| Find the size of a patch of connected sea tiles. | |
| static std::tuple< bool, bool > | FlowRiver (TileIndex spring, TileIndex begin, uint min_river_length) |
| Try to flow the river down from a given begin. | |
| static void | CreateRivers () |
| Actually (try to) create some rivers. | |
| static uint | CalculateCoverageLine (uint coverage, uint edge_multiplier) |
| Calculate what height would be needed to cover N% of the landmass. | |
| static void | CalculateSnowLine () |
| Calculate the line from which snow begins. | |
| static uint8_t | CalculateDesertLine () |
| Calculate the line (in height) between desert and tropic. | |
| bool | GenerateLandscape (uint8_t mode) |
| void | OnTick_Town () |
| Iterate through all towns and call their tick handler. | |
| void | OnTick_Trees () |
| void | OnTick_Station () |
| void | OnTick_Industry () |
| void | OnTick_Companies () |
| Called every tick for updating some company info. | |
| void | OnTick_LinkGraph () |
| Spawn or join a link graph job or compress a link graph if any link graph is due to do so. | |
| void | CallLandscapeTick () |
Variables | |
| const TileTypeProcs | _tile_type_clear_procs |
| const TileTypeProcs | _tile_type_rail_procs |
| const TileTypeProcs | _tile_type_road_procs |
| Tile callback functions for road tiles. | |
| const TileTypeProcs | _tile_type_town_procs |
| Tile callback functions for a town. | |
| const TileTypeProcs | _tile_type_trees_procs |
| const TileTypeProcs | _tile_type_station_procs |
| const TileTypeProcs | _tile_type_water_procs |
| const TileTypeProcs | _tile_type_void_procs |
| const TileTypeProcs | _tile_type_industry_procs |
| const TileTypeProcs | _tile_type_tunnelbridge_procs |
| const TileTypeProcs | _tile_type_object_procs |
| const TileTypeProcs *const | _tile_type_procs [16] |
| Tile callback functions for each type of tile. | |
| const uint8_t | _slope_to_sprite_offset [32] |
| landscape slope => sprite | |
| static const uint | TILE_UPDATE_FREQUENCY_LOG = 8 |
| The logarithm of how many ticks it takes between tile updates (log base 2). | |
| static const uint | TILE_UPDATE_FREQUENCY = 1 << TILE_UPDATE_FREQUENCY_LOG |
| How many ticks it takes between tile updates (has to be a power of 2). | |
| static std::unique_ptr< SnowLine > | _snow_line |
| Description of the snow line throughout the year. | |
| TileIndex | _cur_tileloop_tile |
| static const uint8_t | _genterrain_tbl_1 [5] = { 10, 22, 33, 37, 4 } |
| static const uint8_t | _genterrain_tbl_2 [5] = { 0, 0, 0, 0, 33 } |
Functions related to the landscape (slopes etc.).
Definition in file landscape.cpp.
| uint ApplyFoundationToSlope | ( | Foundation | f, |
| Slope & | s | ||
| ) |
Applies a foundation to a slope.
| f | The Foundation. |
| s | The Slope to modify. |
Definition at line 173 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(), and TestAutoslopeOnRailTile().
|
static |
Calculate what height would be needed to cover N% of the landmass.
The function allows both snow and desert/tropic line to be calculated. It tries to find the closest height which covers N% of the landmass; it can be below or above it.
Tropic has a mechanism where water and tropic tiles in mountains grow inside the desert. To better approximate the requested coverage, this is taken into account via an edge histogram, which tells how many neighbouring tiles are lower than the tiles of that height. The multiplier indicates how severe this has to be taken into account.
| coverage | A value between 0 and 100 indicating a percentage of landmass that should be covered. |
| edge_multiplier | How much effect neighbouring tiles that are of a lower height level have on the score. |
Definition at line 1517 of file landscape.cpp.
References AddTileIndexDiffCWrap(), DIAGDIR_BEGIN, DIAGDIR_END, IsValidTile(), Map::Iterate(), MAX_TILE_HEIGHT, Map::Size(), TileHeight(), and TileIndexDiffCByDiagDir().
Referenced by CalculateDesertLine(), and CalculateSnowLine().
|
static |
Calculate the line (in height) between desert and tropic.
Definition at line 1596 of file landscape.cpp.
References _settings_game, CalculateCoverageLine(), GameCreationSettings::desert_coverage, and GameSettings::game_creation.
Referenced by GenerateLandscape().
|
static |
Calculate the line from which snow begins.
Definition at line 1586 of file landscape.cpp.
References _settings_game, CalculateCoverageLine(), GameSettings::game_creation, GameCreationSettings::snow_coverage, and GameCreationSettings::snow_line_height.
Referenced by GenerateLandscape().
| void CallLandscapeTick | ( | ) |
Definition at line 1713 of file landscape.cpp.
Change the owner of a tile.
| tile | Tile to change |
| old_owner | Current owner of the tile |
| new_owner | New owner of the tile |
Definition at line 570 of file landscape.cpp.
References _tile_type_procs, and GetTileType().
Referenced by AfterLoadGame(), and ChangeOwnershipOfCompanyItems().
| std::tuple< CommandCost, Money > CmdClearArea | ( | DoCommandFlags | flags, |
| TileIndex | tile, | ||
| TileIndex | start_tile, | ||
| bool | diagonal | ||
| ) |
Clear a big piece of landscape.
| flags | of operation to conduct |
| tile | end tile of area dragging |
| start_tile | start tile of area dragging |
| diagonal | Whether to use the Orthogonal (false) or Diagonal (true) iterator. |
Definition at line 736 of file landscape.cpp.
References _current_company, _pause_mode, CommandCost::AddCost(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Auto, Bankrupt, CompanyProperties::clear_limit, CMD_ERROR, TileIterator::Create(), CreateEffectVehicleAbove(), EV_EXPLOSION_LARGE, EV_EXPLOSION_SMALL, Execute, EXPENSES_CONSTRUCTION, CommandCost::Failed(), ForceClearTile, GB(), GetAvailableMoneyForCommand(), CommandCost::GetCost(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetIfValid(), INVALID_TILE, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::None(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), Map::Size(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TILE_SIZE, TileX(), and TileY().
| CommandCost CmdLandscapeClear | ( | DoCommandFlags | flags, |
| TileIndex | tile | ||
| ) |
Clear a piece of landscape.
| flags | of operation to conduct |
| tile | tile to clear |
Definition at line 678 of file landscape.cpp.
References _current_company, _tile_type_procs, CommandCost::AddCost(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Auto, Bankrupt, Canal, CompanyProperties::clear_limit, ClearNeighbourNonFloodingStates(), DirtyCompanyInfrastructureWindows(), Execute, EXPENSES_CONSTRUCTION, FindClearedObject(), ClearedObjectArea::first_tile, ForceClearTile, GB(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetIfValid(), GetTileOwner(), GetTileType(), GetWaterClass(), HasTileWaterClass(), IsCanal(), IsCoastTile(), IsTileOnWater(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), IsWaterTile(), NoWater, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
|
static |
Find the size of a patch of connected sea tiles.
| tile | The starting tile to search. |
| sea | The set of sea tiles found. |
| limit | How many tiles to find before cutting the search short. |
Definition at line 1336 of file landscape.cpp.
References CountConnectedSeaTiles(), DIAGDIR_BEGIN, DIAGDIR_END, DistanceFromEdge(), GetWaterClass(), IsTileFlat(), IsValidTile(), IsWaterTile(), Sea, and TileOffsByDiagDir().
Referenced by CountConnectedSeaTiles(), and FlowRiver().
|
static |
Definition at line 974 of file landscape.cpp.
|
static |
Actually (try to) create some rivers.
Definition at line 1451 of file landscape.cpp.
References _settings_game, GameCreationSettings::amount_of_rivers, FindSpring(), FlowRiver(), GameSettings::game_creation, GWP_RIVER, IncreaseGeneratingWorldProgress(), GameCreationSettings::min_river_length, RandomTile, RunTileLoop(), Map::ScaleBySize(), SetGeneratingWorldProgress(), and TILE_UPDATE_FREQUENCY.
Referenced by GenerateLandscape().
| void DoClearSquare | ( | TileIndex | tile | ) |
Definition at line 535 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 428 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(), 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, and Coord3D< T >::z.
Referenced by DrawRoadBits(), DrawTile_Road(), DrawTile_Town(), DrawTile_TunnelBridge(), and DrawTrackBits().
|
static |
Find the spring of a river.
| tile | The tile to consider for being the spring. |
Definition at line 1018 of file landscape.cpp.
References _settings_game, GameSettings::game_creation, GetTileMaxZ(), GetTropicZone(), INVALID_TILE, IsTileFlat(), IsWaterTile(), GameCreationSettings::landscape, TileAddWrap(), and TROPICZONE_RAINFOREST.
Referenced by CreateRivers().
|
static |
Try to flow the river down from a given begin.
| spring | The springing point of the river. |
| begin | The begin point we are looking from; somewhere down hill from the spring. |
| min_river_length | The minimum length for the river. |
Definition at line 1369 of file landscape.cpp.
References ComplementSlope(), CountConnectedSeaTiles(), DIAGDIR_BEGIN, DIAGDIR_END, DistanceManhattan(), Execute, FlowRiver(), GetTileSlope(), GetTileZ(), GetWaterClass(), IsTileFlat(), IsValidTile(), IsWaterTile(), RandomRange(), RiverFlowsDown(), Sea, Map::SizeX(), Map::SizeY(), SLOPE_ELEVATED, TileHeight(), TileOffsByDiagDir(), TryMakeRiverTerminus(), and YapfBuildRiver().
Referenced by CreateRivers(), and FlowRiver().
| 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 1602 of file landscape.cpp.
References _file_to_saveload, _settings_game, CalculateDesertLine(), CalculateSnowLine(), Clamp(), GameSettings::construction, CreateRivers(), CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY, FiosType::detailed, GameSettings::difficulty, FixSlopes(), ConstructionSettings::freeform_edges, FileToSaveLoad::ftype, GameSettings::game_creation, GB(), GenerateTerrainPerlin(), GWM_HEIGHTMAP, GWP_LANDSCAPE, IncreaseGeneratingWorldProgress(), GameCreationSettings::land_generator, GameCreationSettings::landscape, LG_TERRAGENESIS, LoadHeightmap(), MakeVoid(), MarkWholeScreenDirty(), FileToSaveLoad::name, DifficultySettings::quantity_sea_lakes, Random, Map::ScaleBySize(), SetGeneratingWorldProgress(), Map::SizeX(), Map::SizeY(), DifficultySettings::terrain_type, and TileXY().
Referenced by _GenerateWorld().
|
static |
Definition at line 852 of file landscape.cpp.
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 385 of file landscape.cpp.
References _tile_type_procs, ApplyFoundationToSlope(), GetTileSlopeZ(), and GetTileType().
Referenced by GetFoundationPixelSlope(), IsPossibleCrossing(), IsRoadAllowedHere(), 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 231 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 CheckPartialPixelZ(), CheckPartialPixelZSlopeAddition(), and DrawRoadBits().
| 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 306 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(), GetSaveSlopeZ(), GetSlopePixelZOutsideMap(), HandleCrashedAircraft(), InitializeWindowViewport(), CommandHelperBase::InternalPostResult(), InverseRemapCoords2(), RemapCoords2(), ScrollWindowTo(), SetAircraftPosition(), DisasterVehicle::UpdatePosition(), GroundVehicle< T, Type >::UpdateZPosition(), and GroundVehicle< T, Type >::UpdateZPositionAndInclination().
| 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 357 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 321 of file landscape.cpp.
References _tile_type_procs, GetSlopePixelZ(), INVALID_TILE, IsInsideBS(), MP_VOID, Map::SizeX(), Map::SizeY(), and TILE_SIZE.
Referenced by InverseRemapCoords2().
Determine the Z height of a corner relative to TileZ.
| tileh | The slope. |
| corner | The corner. |
Definition at line 339 of file landscape.cpp.
References IsHalftileSlope(), SlopeWithOneCornerRaised(), and SteepSlope().
Referenced by GetSlopePixelZInCorner(), and TestAutoslopeOnRailTile().
Definition at line 575 of file landscape.cpp.
| TrackStatus GetTileTrackStatus | ( | TileIndex | tile, |
| TransportType | mode, | ||
| uint | sub_mode, | ||
| DiagDirection | side | ||
| ) |
Returns information about trackdirs and signal states.
If there is any trackbit at 'side', return all trackdirbits. For TRANSPORT_ROAD, return no trackbits if there is no roadbit (of given subtype) at given side.
| tile | tile to get info about |
| mode | transport type |
| sub_mode | for TRANSPORT_ROAD, roadtypes to check |
| side | side we are entering from, INVALID_DIAGDIR to return all trackbits |
Definition at line 559 of file landscape.cpp.
References _tile_type_procs, TileTypeProcs::get_tile_track_status_proc, and GetTileType().
Referenced by AfterLoadGame(), CheckRoadBlockedForOvertaking(), CYapfFollowShipT< Types >::CheckShipReverse(), DisasterTick_Submarine(), FixOwnerOfRailTrack(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GenericPlaceSignals(), GetTrackdirBitsForRoad(), MaskWireBits(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::QueryNewTileTrackStatus(), RoadFindPathToDest(), RoadVehicle::TileMayHaveSlopedTrack(), TrainCheckIfLineEnds(), TrainController(), TryPathReserve(), TryReserveRailTrack(), UnreserveRailTrack(), and UpdateSignalsInBuffer().
Definition at line 409 of file landscape.cpp.
Definition at line 394 of file landscape.cpp.
| void InitializeLandscape | ( | ) |
Definition at line 834 of file landscape.cpp.
| 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 114 of file landscape.cpp.
References _settings_game, CeilDiv(), Clamp(), GameSettings::construction, ConstructionSettings::freeform_edges, GetSlopePixelZ(), GetSlopePixelZOutsideMap(), InverseRemapCoords(), ConstructionSettings::map_height_limit, Map::MaxX(), Map::MaxY(), 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 646 of file landscape.cpp.
References GetTilePixelSlopeOutsideMap(), Map::SizeX(), Map::SizeY(), and SLOPE_FLAT.
Referenced by LoadHeightmap().
|
static |
Is this a valid tile for the water feature at the end of a river?
| tile | The tile to check. |
| height | The height of the rest of the water feature, which must match. |
Definition at line 1054 of file landscape.cpp.
References _settings_game, GameSettings::game_creation, GetTropicZone(), IsTileFlat(), IsValidTile(), GameCreationSettings::landscape, TileHeight(), and TROPICZONE_DESERT.
Referenced by MakeLake(), and MakeWetlands().
|
static |
Make a lake centred on the given tile, of a random diameter.
| lake_centre | The middle tile of the lake. |
| height_lake | The height of the lake. |
Definition at line 1067 of file landscape.cpp.
References DIAGDIR_BEGIN, DIAGDIR_END, IsValidRiverTerminusTile(), IsWaterTile(), MakeRiverAndModifyDesertZoneAround(), RandomRange(), and TileOffsByDiagDir().
Referenced by TryMakeRiverTerminus().
|
static |
Make wetlands around the given tile.
| centre | The starting tile. |
| height | The height of the wetlands. |
| river_length | The length of the river. |
Definition at line 1093 of file landscape.cpp.
References _settings_game, Chance16(), CLEAR_ROUGH, DistanceSquare(), GameSettings::game_creation, IsTileType(), IsValidRiverTerminusTile(), MakeRiverAndModifyDesertZoneAround(), MP_CLEAR, PlaceTree(), Random, SetClearGroundDensity(), TP_NONE, and GameCreationSettings::tree_placer.
Referenced by TryMakeRiverTerminus().
| void OnTick_Companies | ( | ) |
Called every tick for updating some company info.
Definition at line 770 of file company_cmd.cpp.
References _cur_company_tick_index, _networking, _new_competitor_timeout, _settings_client, _settings_game, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), CompanyProperties::bankrupt_asked, AI::CanStartNew(), CCA_NEW_AI, DifficultySettings::competitors_interval, CRR_NONE, GameSettings::difficulty, GenerateCompanyName(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetNumItems(), HandleBankruptcyTakeover(), INVALID_CLIENT_ID, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Iterate(), NetworkSettings::max_companies, DifficultySettings::max_no_competitors, CompanyProperties::name_1, ClientSettings::network, OWNER_NONE, and Ticks::TICKS_PER_SECOND.
| void OnTick_Industry | ( | ) |
Definition at line 1233 of file industry_cmd.cpp.
| void OnTick_LinkGraph | ( | ) |
Spawn or join a link graph job or compress a link graph if any link graph is due to do so.
Definition at line 202 of file linkgraphschedule.cpp.
References _network_server, _networking, _settings_game, TimerGameEconomy::date, TimerGameEconomy::date_fract, LinkGraphSchedule::instance, LinkGraphSchedule::JoinNext(), GameSettings::linkgraph, PFE_GL_LINKGRAPH, LinkGraphSettings::recalc_interval, TimerGameConst< struct Economy >::SECONDS_PER_DAY, PerformanceMeasurer::SetInactive(), LinkGraphSchedule::SPAWN_JOIN_TICK, and LinkGraphSchedule::SpawnNext().
| void OnTick_Station | ( | ) |
Definition at line 4328 of file station_cmd.cpp.
| void OnTick_Town | ( | ) |
Iterate through all towns and call their tick handler.
Definition at line 940 of file town_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_town_pool >::Iterate(), and TownTickHandler().
| void OnTick_Trees | ( | ) |
Definition at line 967 of file tree_cmd.cpp.
Check whether a river at begin could (logically) flow down to end.
| begin | The origin of the flow. |
| end | The destination of the flow. |
Definition at line 1308 of file landscape.cpp.
References DistanceManhattan(), GetTileSlopeZ(), IsInclinedSlope(), and SLOPE_FLAT.
Referenced by FlowRiver().
Widen a river by expanding into adjacent tiles via circular tile search.
| tile | The tile to try expanding the river into. |
| origin_tile | The tile to try surrounding the river around. |
Definition at line 1165 of file landscape.cpp.
References Auto, ChangeDiagDir(), ComplementSlope(), DIAGDIR_BEGIN, DIAGDIR_END, DIAGDIRDIFF_90LEFT, DIAGDIRDIFF_90RIGHT, DIAGDIRDIFF_BEGIN, DIAGDIRDIFF_END, DIAGDIRDIFF_REVERSE, DIAGDIRDIFF_SAME, Execute, GetInclinedSlopeDirection(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), IsInclinedSlope(), IsRiver(), IsSlopeWithOneCornerRaised(), IsSlopeWithThreeCornersRaised(), IsSteepSlope(), IsTileFlat(), IsValidTile(), IsWaterTile(), MakeRiverAndModifyDesertZoneAround(), ReverseDiagDir(), SLOPE_FLAT, and TileAddByDiagDir().
| void RunTileLoop | ( | ) |
Gradually iterate over all tiles on the map, calling their TileLoopProcs once every TILE_UPDATE_FREQUENCY ticks.
Definition at line 794 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().
Try to end a river at a tile which is not the sea.
| tile | The tile to try ending the river at. |
| begin | The starting tile of the river. |
Definition at line 1130 of file landscape.cpp.
References _settings_game, Chance16(), DistanceManhattan(), GameSettings::game_creation, GetTropicZone(), IsTileFlat(), IsValidTile(), GameCreationSettings::landscape, MakeLake(), MakeWetlands(), TileHeight(), and TROPICZONE_DESERT.
Referenced by FlowRiver().
| TileIndex _cur_tileloop_tile |
Definition at line 789 of file landscape.cpp.
|
static |
Definition at line 849 of file landscape.cpp.
|
static |
Definition at line 850 of file landscape.cpp.
|
extern |
landscape slope => sprite
Referenced by SlopeToSpriteOffset().
| const TileTypeProcs _tile_type_industry_procs |
Definition at line 59 of file landscape.cpp.
| const TileTypeProcs _tile_type_object_procs |
Definition at line 61 of file landscape.cpp.
| const TileTypeProcs* const _tile_type_procs[16] |
Tile callback functions for each type of tile.
Definition at line 68 of file landscape.cpp.
Referenced by ChangeTileOwner(), CmdLandscapeClear(), CmdTerraformLand(), GetFoundationSlope(), GetSlopePixelZ(), GetSlopePixelZOutsideMap(), GetTileTrackStatus(), MayAnimateTile(), RunTileLoop(), VehicleEnterTile(), and ViewportAddLandscape().
| const TileTypeProcs _tile_type_rail_procs |
Definition at line 52 of file landscape.cpp.
| const TileTypeProcs _tile_type_road_procs |
Tile callback functions for road tiles.
Definition at line 53 of file landscape.cpp.
| const TileTypeProcs _tile_type_station_procs |
Definition at line 56 of file landscape.cpp.
| const TileTypeProcs _tile_type_town_procs |
Tile callback functions for a town.
Definition at line 54 of file landscape.cpp.
| const TileTypeProcs _tile_type_trees_procs |
Definition at line 55 of file landscape.cpp.
| const TileTypeProcs _tile_type_tunnelbridge_procs |
Definition at line 60 of file landscape.cpp.
| const TileTypeProcs _tile_type_void_procs |
Definition at line 58 of file landscape.cpp.
| const TileTypeProcs _tile_type_water_procs |
Definition at line 57 of file landscape.cpp.
|
static |
How many ticks it takes between tile updates (has to be a power of 2).
Definition at line 89 of file landscape.cpp.
Referenced by CreateRivers(), and RunTileLoop().
|
static |
The logarithm of how many ticks it takes between tile updates (log base 2).
Definition at line 88 of file landscape.cpp.
Referenced by RunTileLoop().