OpenTTD Source 20241224-master-gee860a5c8e
landscape.cpp File Reference

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 "company_func.h"
#include "company_gui.h"
#include "pathfinder/aystar.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 "table/strings.h"
#include "table/sprites.h"
#include "safeguards.h"
#include "table/genland.h"

Go to the source code of this file.

Data Structures

struct  River_UserData
 Parameters for river generation to pass as AyStar user data. More...
 

Macros

#define SET_MARK(x)   marks.insert(x)
 
#define IS_MARKED(x)   (marks.find(x) != marks.end())
 

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 (uint8_t table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS])
 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.
 
CommandCost CmdLandscapeClear (DoCommandFlag flags, TileIndex tile)
 Clear a piece of landscape.
 
std::tuple< CommandCost, MoneyCmdClearArea (DoCommandFlag 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, void *)
 Find the spring of a river.
 
static bool MakeLake (TileIndex tile, void *user_data)
 Make a connected lake; fill all tiles in the circular tile search that are connected.
 
static bool RiverMakeWider (TileIndex tile, void *data)
 Widen a river by expanding into adjacent tiles via circular tile search.
 
static bool FlowsDown (TileIndex begin, TileIndex end)
 Check whether a river at begin could (logically) flow down to end.
 
static AyStarStatus River_EndNodeCheck (const AyStar *aystar, const PathNode *current)
 
static int32_t River_CalculateG (AyStar *, AyStarNode *, PathNode *)
 
static int32_t River_CalculateH (AyStar *aystar, AyStarNode *current, PathNode *)
 
static void River_GetNeighbours (AyStar *aystar, PathNode *current)
 
static void River_FoundEndNode (AyStar *aystar, PathNode *current)
 
static void BuildRiver (TileIndex begin, TileIndex end, TileIndex spring, bool main_river)
 Actually build the river between the begin and end tiles using AyStar.
 
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 SnowLine_snow_line = nullptr
 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 }
 

Detailed Description

Functions related to the landscape (slopes etc.).

Definition in file landscape.cpp.

Function Documentation

◆ ApplyFoundationToSlope()

◆ BuildRiver()

static void BuildRiver ( TileIndex  begin,
TileIndex  end,
TileIndex  spring,
bool  main_river 
)
static

Actually build the river between the begin and end tiles using AyStar.

Parameters
beginThe begin of the river.
endThe end of the river.
springThe springing point of the river.
main_riverWhether the current river is a big river that others flow into.

Definition at line 1295 of file landscape.cpp.

References AyStar::AddStartNode(), INVALID_TRACKDIR, and AyStar::Main().

Referenced by FlowRiver().

◆ CalculateCoverageLine()

static uint CalculateCoverageLine ( uint  coverage,
uint  edge_multiplier 
)
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 closests 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.

Parameters
coverageA value between 0 and 100 indicating a percentage of landmass that should be covered.
edge_multiplierHow much effect neighbouring tiles that are of a lower height level have on the score.
Returns
The estimated best height to use to cover N% of the landmass.

Definition at line 1459 of file landscape.cpp.

References AddTileIndexDiffCWrap(), DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, IsValidTile(), Map::Iterate(), MAX_TILE_HEIGHT, Map::Size(), TileHeight(), and TileIndexDiffCByDiagDir().

Referenced by CalculateDesertLine(), and CalculateSnowLine().

◆ CalculateDesertLine()

static uint8_t CalculateDesertLine ( )
static

Calculate the line (in height) between desert and tropic.

Returns
The height of the line between desert and tropic.

Definition at line 1545 of file landscape.cpp.

References _settings_game, CalculateCoverageLine(), GameCreationSettings::desert_coverage, and GameSettings::game_creation.

Referenced by GenerateLandscape().

◆ CalculateSnowLine()

static void CalculateSnowLine ( )
static

◆ CallLandscapeTick()

void CallLandscapeTick ( )

Definition at line 1662 of file landscape.cpp.

◆ ChangeTileOwner()

void ChangeTileOwner ( TileIndex  tile,
Owner  old_owner,
Owner  new_owner 
)

Change the owner of a tile.

Parameters
tileTile to change
old_ownerCurrent owner of the tile
new_ownerNew owner of the tile

Definition at line 565 of file landscape.cpp.

References _tile_type_procs, and GetTileType().

Referenced by AfterLoadGame(), and ChangeOwnershipOfCompanyItems().

◆ CmdClearArea()

std::tuple< CommandCost, Money > CmdClearArea ( DoCommandFlag  flags,
TileIndex  tile,
TileIndex  start_tile,
bool  diagonal 
)

Clear a big piece of landscape.

Parameters
flagsof operation to conduct
tileend tile of area dragging
start_tilestart tile of area dragging
diagonalWhether to use the Orthogonal (false) or Diagonal (true) iterator.
Returns
the cost of this operation or an error

Definition at line 711 of file landscape.cpp.

References _current_company, _pause_mode, CommandCost::AddCost(), CompanyProperties::clear_limit, CMD_ERROR, TileIterator::Create(), CreateEffectVehicleAbove(), DC_AUTO, DC_BANKRUPT, DC_EXEC, DC_FORCE_CLEAR_TILE, EV_EXPLOSION_LARGE, EV_EXPLOSION_SMALL, EXPENSES_CONSTRUCTION, CommandCost::Failed(), GB(), GetAvailableMoneyForCommand(), CommandCost::GetCost(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), INVALID_TILE, PM_UNPAUSED, Map::Size(), TILE_SIZE, TileX(), and TileY().

◆ CmdLandscapeClear()

◆ CreateDesertOrRainForest()

static void CreateDesertOrRainForest ( uint  desert_tropic_line)
static

Definition at line 949 of file landscape.cpp.

◆ CreateRivers()

◆ DoClearSquare()

void DoClearSquare ( TileIndex  tile)

Definition at line 530 of file landscape.cpp.

◆ DrawFoundation()

◆ FindSpring()

static bool FindSpring ( TileIndex  tile,
void *   
)
static

Find the spring of a river.

Parameters
tileThe tile to consider for being the spring.
Returns
True iff it is suitable as a spring.

Definition at line 993 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().

◆ FlowRiver()

static std::tuple< bool, bool > FlowRiver ( TileIndex  spring,
TileIndex  begin,
uint  min_river_length 
)
static

Try to flow the river down from a given begin.

Parameters
springThe springing point of the river.
beginThe begin point we are looking from; somewhere down hill from the spring.
min_river_lengthThe minimum length for the river.
Returns
First element: True iff a river could/has been built, otherwise false; second element: River ends at sea.

Definition at line 1322 of file landscape.cpp.

References _settings_game, BuildRiver(), CircularTileSearch(), DIAGDIR_BEGIN, DIAGDIR_END, DistanceManhattan(), FlowRiver(), FlowsDown(), GameSettings::game_creation, GetTileZ(), GetTropicZone(), IsTileFlat(), IsValidTile(), IsWaterTile(), GameCreationSettings::landscape, MakeLake(), MakeRiverAndModifyDesertZoneAround(), RandomRange(), TileHeight(), TileOffsByDiagDir(), and TROPICZONE_DESERT.

Referenced by CreateRivers(), and FlowRiver().

◆ FlowsDown()

static bool FlowsDown ( TileIndex  begin,
TileIndex  end 
)
static

Check whether a river at begin could (logically) flow down to end.

Parameters
beginThe origin of the flow.
endThe destination of the flow.
Returns
True iff the water can be flowing down.

Definition at line 1199 of file landscape.cpp.

References DistanceManhattan(), GetTileSlopeZ(), IsInclinedSlope(), and SLOPE_FLAT.

Referenced by FlowRiver().

◆ GenerateLandscape()

◆ GenerateTerrain()

static void GenerateTerrain ( int  type,
uint  flag 
)
static

Definition at line 827 of file landscape.cpp.

◆ GetFoundationSlope()

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.

Parameters
tileThe tile of interest.
Returns
The slope on top of the foundation and the z of the foundation slope.

Definition at line 382 of file landscape.cpp.

References _tile_type_procs, ApplyFoundationToSlope(), GetTileSlopeZ(), and GetTileType().

Referenced by GetFoundationPixelSlope(), IsPossibleCrossing(), IsRoadAllowedHere(), and TileLoop_Water().

◆ GetPartialPixelZ()

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.

Parameters
xx coordinate (value from 0 to 15)
yy coordinate (value from 0 to 15)
cornersslope to examine
Returns
height of given point of given slope

Definition at line 228 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().

◆ GetSlopePixelZ()

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.

Parameters
xWorld X coordinate in tile "units".
yWorld Y coordinate in tile "units".
ground_vehicleWhether to get the Z coordinate of the ground vehicle, or the ground.
Returns
World Z coordinate at tile ground (vehicle) level, including slopes and foundations.

Definition at line 303 of file landscape.cpp.

References _tile_type_procs, GetTileType(), and TileVirtXY().

Referenced by AfterLoadGame(), AircraftController(), CheckGroundVehiclesAtCorrectZ(), CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), CmdBuildShip(), 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().

◆ GetSlopePixelZOnEdge()

void GetSlopePixelZOnEdge ( Slope  tileh,
DiagDirection  edge,
int &  z1,
int &  z2 
)

Determine the Z height of the corners of a specific tile edge.

Note
If a tile has a non-continuous halftile foundation, a corner can have different heights wrt. its edges.
Precondition
z1 and z2 must be initialized (typ. with TileZ). The corner heights just get added.
Parameters
tilehThe slope of the tile.
edgeThe edge of interest.
z1Gets incremented by the height of the first corner of the edge. (near corner wrt. the camera)
z2Gets incremented by the height of the second corner of the edge. (far corner wrt. the camera)

Definition at line 354 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().

◆ GetSlopePixelZOutsideMap()

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).

Parameters
xWorld X coordinate in tile "units", may be outside the map.
yWorld Y coordinate in tile "units", may be outside the map.
Returns
World Z coordinate at tile ground level, including slopes and foundations.

Definition at line 318 of file landscape.cpp.

References _tile_type_procs, GetSlopePixelZ(), INVALID_TILE, IsInsideBS(), MP_VOID, Map::SizeX(), Map::SizeY(), and TILE_SIZE.

Referenced by InverseRemapCoords2().

◆ GetSlopeZInCorner()

int GetSlopeZInCorner ( Slope  tileh,
Corner  corner 
)

Determine the Z height of a corner relative to TileZ.

Precondition
The slope must not be a halftile slope.
Parameters
tilehThe slope.
cornerThe corner.
Returns
Z position of corner relative to TileZ.

Definition at line 336 of file landscape.cpp.

References IsHalftileSlope(), SlopeWithOneCornerRaised(), and SteepSlope().

Referenced by GetSlopePixelZInCorner(), and TestAutoslopeOnRailTile().

◆ GetTileDesc()

void GetTileDesc ( TileIndex  tile,
TileDesc td 
)

Definition at line 570 of file landscape.cpp.

◆ GetTileTrackStatus()

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.

Parameters
tiletile to get info about
modetransport type
sub_modefor TRANSPORT_ROAD, roadtypes to check
sideside we are entering from, INVALID_DIAGDIR to return all trackbits
Returns
trackdirbits and other info depending on 'mode'

Definition at line 554 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().

◆ HasFoundationNE()

bool HasFoundationNE ( TileIndex  tile,
Slope  slope_here,
uint  z_here 
)

Definition at line 406 of file landscape.cpp.

◆ HasFoundationNW()

bool HasFoundationNW ( TileIndex  tile,
Slope  slope_here,
uint  z_here 
)

Definition at line 391 of file landscape.cpp.

◆ InitializeLandscape()

void InitializeLandscape ( )

Definition at line 809 of file landscape.cpp.

◆ InverseRemapCoords2()

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.

Parameters
xX viewport 2D coordinate.
yY viewport 2D coordinate.
clamp_to_mapClamp the coordinate outside of the map to the closest, non-void tile within the map.
[out]clampedWhether coordinates were clamped.
Returns
3D world coordinate of point visible at the given screen coordinate (3D perspective).
Note
Inverse of RemapCoords2 function. Smaller values may get rounded.
See also
InverseRemapCoords

Definition at line 111 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, and TILE_SIZE.

Referenced by ClampViewportToMap(), SmallMapWindow::DrawMapIndicators(), SmallMapWindow::SmallMapCenterOnCurrentPos(), and TranslateXYToTileCoord().

◆ MakeLake()

static bool MakeLake ( TileIndex  tile,
void *  user_data 
)
static

Make a connected lake; fill all tiles in the circular tile search that are connected.

Parameters
tileThe tile to consider for lake making.
user_dataThe height of the lake.
Returns
Always false, so it continues searching.

Definition at line 1029 of file landscape.cpp.

References _settings_game, DIAGDIR_BEGIN, DIAGDIR_END, GameSettings::game_creation, GetTropicZone(), IsTileFlat(), IsValidTile(), IsWaterTile(), GameCreationSettings::landscape, MakeRiverAndModifyDesertZoneAround(), TileHeight(), TileOffsByDiagDir(), and TROPICZONE_DESERT.

Referenced by FlowRiver().

◆ OnTick_Companies()

◆ OnTick_Industry()

void OnTick_Industry ( )

Definition at line 1238 of file industry_cmd.cpp.

◆ OnTick_LinkGraph()

◆ OnTick_Station()

void OnTick_Station ( )

Definition at line 4198 of file station_cmd.cpp.

◆ OnTick_Town()

void OnTick_Town ( )

Iterate through all towns and call their tick handler.

Definition at line 928 of file town_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Iterate(), and TownTickHandler().

◆ OnTick_Trees()

void OnTick_Trees ( )

Definition at line 832 of file tree_cmd.cpp.

◆ River_CalculateG()

static int32_t River_CalculateG ( AyStar ,
AyStarNode ,
PathNode  
)
static

Definition at line 1226 of file landscape.cpp.

◆ River_CalculateH()

static int32_t River_CalculateH ( AyStar aystar,
AyStarNode current,
PathNode  
)
static

Definition at line 1232 of file landscape.cpp.

◆ River_EndNodeCheck()

static AyStarStatus River_EndNodeCheck ( const AyStar aystar,
const PathNode current 
)
static

Definition at line 1220 of file landscape.cpp.

◆ River_FoundEndNode()

static void River_FoundEndNode ( AyStar aystar,
PathNode current 
)
static

Definition at line 1254 of file landscape.cpp.

◆ River_GetNeighbours()

static void River_GetNeighbours ( AyStar aystar,
PathNode current 
)
static

Definition at line 1238 of file landscape.cpp.

◆ RiverMakeWider()

static bool RiverMakeWider ( TileIndex  tile,
void *  data 
)
static

Widen a river by expanding into adjacent tiles via circular tile search.

Parameters
tileThe tile to try expanding the river into.
dataThe tile to try surrounding the river around.
Returns
Always false, so it continues searching.

Definition at line 1052 of file landscape.cpp.

References ChangeDiagDir(), ComplementSlope(), DC_AUTO, DC_EXEC, DIAGDIR_BEGIN, DIAGDIR_END, DIAGDIRDIFF_90LEFT, DIAGDIRDIFF_90RIGHT, DIAGDIRDIFF_BEGIN, DIAGDIRDIFF_END, DIAGDIRDIFF_REVERSE, DIAGDIRDIFF_SAME, GetInclinedSlopeDirection(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), IsInclinedSlope(), IsRiver(), IsSlopeWithOneCornerRaised(), IsSlopeWithThreeCornersRaised(), IsSteepSlope(), IsTileFlat(), IsValidTile(), IsWaterTile(), MakeRiverAndModifyDesertZoneAround(), ReverseDiagDir(), SLOPE_FLAT, and TileAddByDiagDir().

◆ RunTileLoop()

void RunTileLoop ( )

Gradually iterate over all tiles on the map, calling their TileLoopProcs once every TILE_UPDATE_FREQUENCY ticks.

Definition at line 769 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().

Variable Documentation

◆ _cur_tileloop_tile

TileIndex _cur_tileloop_tile

Definition at line 764 of file landscape.cpp.

◆ _genterrain_tbl_1

const uint8_t _genterrain_tbl_1[5] = { 10, 22, 33, 37, 4 }
static

Definition at line 824 of file landscape.cpp.

◆ _genterrain_tbl_2

const uint8_t _genterrain_tbl_2[5] = { 0, 0, 0, 0, 33 }
static

Definition at line 825 of file landscape.cpp.

◆ _slope_to_sprite_offset

const uint8_t _slope_to_sprite_offset[32]
extern
Initial value:
= {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0,
0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 17, 0, 15, 18, 0,
}

landscape slope => sprite

Referenced by SlopeToSpriteOffset().

◆ _tile_type_industry_procs

const TileTypeProcs _tile_type_industry_procs

Definition at line 56 of file landscape.cpp.

◆ _tile_type_object_procs

const TileTypeProcs _tile_type_object_procs

Definition at line 58 of file landscape.cpp.

◆ _tile_type_procs

const TileTypeProcs* const _tile_type_procs[16]
Initial value:
= {
&_tile_type_clear_procs,
&_tile_type_rail_procs,
&_tile_type_trees_procs,
&_tile_type_station_procs,
&_tile_type_water_procs,
&_tile_type_void_procs,
&_tile_type_industry_procs,
&_tile_type_tunnelbridge_procs,
&_tile_type_object_procs,
}
const TileTypeProcs _tile_type_town_procs
Tile callback functions for a town.
Definition landscape.cpp:51
const TileTypeProcs _tile_type_road_procs
Tile callback functions for road tiles.
Definition landscape.cpp:50

Tile callback functions for each type of tile.

See also
TileType

Definition at line 65 of file landscape.cpp.

Referenced by ChangeTileOwner(), CmdLandscapeClear(), CmdTerraformLand(), GetFoundationSlope(), GetSlopePixelZ(), GetSlopePixelZOutsideMap(), GetTileTrackStatus(), MayAnimateTile(), RunTileLoop(), VehicleEnterTile(), and ViewportAddLandscape().

◆ _tile_type_rail_procs

const TileTypeProcs _tile_type_rail_procs

Definition at line 49 of file landscape.cpp.

◆ _tile_type_road_procs

const TileTypeProcs _tile_type_road_procs

Tile callback functions for road tiles.

Definition at line 50 of file landscape.cpp.

◆ _tile_type_station_procs

const TileTypeProcs _tile_type_station_procs

Definition at line 53 of file landscape.cpp.

◆ _tile_type_town_procs

const TileTypeProcs _tile_type_town_procs

Tile callback functions for a town.

Definition at line 51 of file landscape.cpp.

◆ _tile_type_trees_procs

const TileTypeProcs _tile_type_trees_procs

Definition at line 52 of file landscape.cpp.

◆ _tile_type_tunnelbridge_procs

const TileTypeProcs _tile_type_tunnelbridge_procs

Definition at line 57 of file landscape.cpp.

◆ _tile_type_void_procs

const TileTypeProcs _tile_type_void_procs

Definition at line 55 of file landscape.cpp.

◆ _tile_type_water_procs

const TileTypeProcs _tile_type_water_procs

Definition at line 54 of file landscape.cpp.

◆ TILE_UPDATE_FREQUENCY

const uint TILE_UPDATE_FREQUENCY = 1 << TILE_UPDATE_FREQUENCY_LOG
static

How many ticks it takes between tile updates (has to be a power of 2).

Definition at line 86 of file landscape.cpp.

Referenced by CreateRivers(), and RunTileLoop().

◆ TILE_UPDATE_FREQUENCY_LOG

const uint TILE_UPDATE_FREQUENCY_LOG = 8
static

The logarithm of how many ticks it takes between tile updates (log base 2).

Definition at line 85 of file landscape.cpp.

Referenced by RunTileLoop().