OpenTTD Source
20241120-master-g6d3adc6169
|
Functions related to slopes. More...
#include "core/math_func.hpp"
#include "slope_type.h"
#include "direction_type.h"
#include "tile_type.h"
Go to the source code of this file.
Functions | |
static constexpr bool | IsValidCorner (Corner corner) |
Rangecheck for Corner enumeration. More... | |
static constexpr bool | IsSteepSlope (Slope s) |
Checks if a slope is steep. More... | |
static constexpr bool | IsHalftileSlope (Slope s) |
Checks for non-continuous slope on halftile foundations. More... | |
static constexpr Slope | RemoveHalftileSlope (Slope s) |
Removes a halftile slope from a slope. More... | |
Slope | ComplementSlope (Slope s) |
Return the complement of a slope. More... | |
bool | IsSlopeWithOneCornerRaised (Slope s) |
Tests if a specific slope has exactly one corner raised. More... | |
Slope | SlopeWithOneCornerRaised (Corner corner) |
Returns the slope with a specific corner raised. More... | |
bool | HasSlopeHighestCorner (Slope s) |
Tests if a slope has a highest corner (i.e. More... | |
Corner | GetHighestSlopeCorner (Slope s) |
Returns the highest corner of a slope (one corner raised or a steep slope). More... | |
static constexpr Corner | GetHalftileSlopeCorner (Slope s) |
Returns the leveled halftile of a halftile slope. More... | |
static constexpr int | GetSlopeMaxZ (Slope s) |
Returns the height of the highest corner of a slope relative to TileZ (= minimal height) More... | |
static constexpr int | GetSlopeMaxPixelZ (Slope s) |
Returns the height of the highest corner of a slope relative to TileZ (= minimal height) More... | |
Corner | OppositeCorner (Corner corner) |
Returns the opposite corner. More... | |
bool | IsSlopeWithThreeCornersRaised (Slope s) |
Tests if a specific slope has exactly three corners raised. More... | |
Slope | SlopeWithThreeCornersRaised (Corner corner) |
Returns the slope with all except one corner raised. More... | |
Slope | SteepSlope (Corner corner) |
Returns a specific steep slope. More... | |
bool | IsInclinedSlope (Slope s) |
Tests if a specific slope is an inclined slope. More... | |
DiagDirection | GetInclinedSlopeDirection (Slope s) |
Returns the direction of an inclined slope. More... | |
Slope | InclinedSlope (DiagDirection dir) |
Returns the slope that is inclined in a specific direction. More... | |
static constexpr Slope | HalftileSlope (Slope s, Corner corner) |
Adds a halftile slope to a slope. More... | |
bool | IsFoundation (Foundation f) |
Tests for FOUNDATION_NONE. More... | |
bool | IsLeveledFoundation (Foundation f) |
Tests if the foundation is a leveled foundation. More... | |
bool | IsInclinedFoundation (Foundation f) |
Tests if the foundation is an inclined foundation. More... | |
bool | IsNonContinuousFoundation (Foundation f) |
Tests if a foundation is a non-continuous foundation, i.e. More... | |
Corner | GetHalftileFoundationCorner (Foundation f) |
Returns the halftile corner of a halftile-foundation. More... | |
bool | IsSpecialRailFoundation (Foundation f) |
Tests if a foundation is a special rail foundation for single horizontal/vertical track. More... | |
Corner | GetRailFoundationCorner (Foundation f) |
Returns the track corner of a special rail foundation. More... | |
Foundation | FlatteningFoundation (Slope s) |
Returns the foundation needed to flatten a slope. More... | |
Foundation | InclinedFoundation (Axis axis) |
Returns the along a specific axis inclined foundation. More... | |
Foundation | HalftileFoundation (Corner corner) |
Returns the halftile foundation for single horizontal/vertical track. More... | |
Foundation | SpecialRailFoundation (Corner corner) |
Returns the special rail foundation for single horizontal/vertical track. More... | |
uint | SlopeToSpriteOffset (Slope s) |
Returns the Sprite offset for a given Slope. More... | |
Functions related to slopes.
Definition in file slope_func.h.
Return the complement of a slope.
This method returns the complement of a slope. The complement of a slope is a slope with raised corner which aren't raised in the given slope.
s | The Slope to get the complement. |
Definition at line 76 of file slope_func.h.
References IsHalftileSlope(), IsSteepSlope(), and SLOPE_ELEVATED.
Referenced by IsRoadAllowedHere(), IsSlopeWithThreeCornersRaised(), RiverMakeWider(), and SlopeWithThreeCornersRaised().
|
inline |
Returns the foundation needed to flatten a slope.
The returned foundation is either FOUNDATION_NONE if the tile was already flat, or FOUNDATION_LEVELED.
s | The current Slope. |
Definition at line 369 of file slope_func.h.
References FOUNDATION_LEVELED, FOUNDATION_NONE, and SLOPE_FLAT.
Referenced by GetBridgeFoundation().
|
inline |
Returns the halftile corner of a halftile-foundation.
f | The Foundation. |
Definition at line 333 of file slope_func.h.
References FOUNDATION_HALFTILE_N, FOUNDATION_HALFTILE_W, and IsInsideMM().
Referenced by ApplyFoundationToSlope().
Returns the leveled halftile of a halftile slope.
s | The Slope. |
Definition at line 148 of file slope_func.h.
References IsHalftileSlope().
Referenced by DrawAutorailSelection(), DrawTileSelectionRect(), and GetSlopePixelZOnEdge().
Returns the highest corner of a slope (one corner raised or a steep slope).
s | The Slope. |
Definition at line 126 of file slope_func.h.
References RemoveHalftileSlope(), SLOPE_STEEP_W, and SLOPE_W.
Referenced by ApplyFoundationToSlope(), CheckRoadSlope(), GetRailFoundation(), and GetRoadFoundation().
|
inline |
Returns the direction of an inclined slope.
s | A Slope |
Definition at line 239 of file slope_func.h.
References DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, INVALID_DIAGDIR, SLOPE_NE, SLOPE_NW, SLOPE_SE, and SLOPE_SW.
Referenced by CmdBuildLock(), GetOtherAqueductEnd(), RiverMakeWider(), and ShipTestUpDownOnLock().
|
inline |
Returns the track corner of a special rail foundation.
f | The Foundation. |
Definition at line 356 of file slope_func.h.
References FOUNDATION_RAIL_W, and IsSpecialRailFoundation().
Referenced by ApplyFoundationToSlope().
|
inlinestaticconstexpr |
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
s | The Slope. |
Definition at line 173 of file slope_func.h.
References GetSlopeMaxZ(), and TILE_HEIGHT.
|
inlinestaticconstexpr |
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
s | The Slope. |
Definition at line 160 of file slope_func.h.
References IsSteepSlope(), and SLOPE_FLAT.
Referenced by AutoslopeCheckForEntranceEdge(), CheckBuildableTile(), and GetSlopeMaxPixelZ().
|
inline |
Returns the halftile foundation for single horizontal/vertical track.
corner | The Corner with the track. |
Definition at line 391 of file slope_func.h.
References FOUNDATION_HALFTILE_W, and IsValidCorner().
Referenced by GetRailFoundation().
Adds a halftile slope to a slope.
Definition at line 274 of file slope_func.h.
References IsValidCorner(), and SLOPE_HALFTILE.
Referenced by ApplyFoundationToSlope().
|
inline |
Tests if a slope has a highest corner (i.e.
one corner raised or a steep slope).
Note: A halftile slope is ignored.
s | The Slope. |
Definition at line 113 of file slope_func.h.
References IsSlopeWithOneCornerRaised(), IsSteepSlope(), and RemoveHalftileSlope().
Referenced by GetBridgeFoundation().
|
inline |
Returns the along a specific axis inclined foundation.
axis | The Axis. |
Definition at line 380 of file slope_func.h.
References AXIS_X, FOUNDATION_INCLINED_X, and FOUNDATION_INCLINED_Y.
Referenced by GetBridgeFoundation().
|
inline |
Returns the slope that is inclined in a specific direction.
dir | A DiagDirection |
Definition at line 256 of file slope_func.h.
References DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, SLOPE_NE, SLOPE_NW, SLOPE_SE, and SLOPE_SW.
Referenced by AdjustTileh(), CanBuildDepotByTileh(), GrowTownWithBridge(), GrowTownWithTunnel(), and RedundantBridgeExistsNearby().
|
inline |
Tests for FOUNDATION_NONE.
f | Maybe a Foundation. |
Definition at line 287 of file slope_func.h.
References FOUNDATION_NONE.
Referenced by ApplyFoundationToSlope(), and DrawFoundation().
|
inlinestaticconstexpr |
Checks for non-continuous slope on halftile foundations.
s | The given Slope. |
Definition at line 47 of file slope_func.h.
References SLOPE_HALFTILE.
Referenced by ComplementSlope(), DrawAutorailSelection(), DrawTileSelectionRect(), DrawTrackDetails(), GetHalftileSlopeCorner(), GetSlopePixelZOnEdge(), GetSlopeZInCorner(), and IsSlopeWithThreeCornersRaised().
|
inline |
Tests if the foundation is an inclined foundation.
f | The Foundation. |
Definition at line 309 of file slope_func.h.
References FOUNDATION_INCLINED_X, and FOUNDATION_INCLINED_Y.
|
inline |
Tests if a specific slope is an inclined slope.
s | The Slope |
Definition at line 228 of file slope_func.h.
References SLOPE_NE, SLOPE_NW, SLOPE_SE, and SLOPE_SW.
Referenced by FlowsDown(), and RiverMakeWider().
|
inline |
Tests if the foundation is a leveled foundation.
f | The Foundation. |
Definition at line 298 of file slope_func.h.
References FOUNDATION_LEVELED.
Referenced by ApplyFoundationToSlope().
|
inline |
Tests if a foundation is a non-continuous foundation, i.e.
halftile-foundation or FOUNDATION_STEEP_BOTH.
f | The Foundation. |
Definition at line 320 of file slope_func.h.
References FOUNDATION_HALFTILE_N, FOUNDATION_STEEP_BOTH, and IsInsideMM().
Referenced by ApplyFoundationToSlope().
|
inline |
Tests if a specific slope has exactly one corner raised.
s | The Slope |
Definition at line 88 of file slope_func.h.
References SLOPE_E, SLOPE_N, SLOPE_S, and SLOPE_W.
Referenced by CanPlantTreesOnTile(), DoFloodTile(), GetFloodingBehaviour(), GetRoadFoundation(), GrowTownWithTunnel(), HasSlopeHighestCorner(), IsSlopeWithThreeCornersRaised(), and RiverMakeWider().
|
inline |
Tests if a specific slope has exactly three corners raised.
s | The Slope |
Definition at line 195 of file slope_func.h.
References ComplementSlope(), IsHalftileSlope(), IsSlopeWithOneCornerRaised(), and IsSteepSlope().
Referenced by RiverMakeWider().
|
inline |
Tests if a foundation is a special rail foundation for single horizontal/vertical track.
f | The Foundation. |
Definition at line 345 of file slope_func.h.
References FOUNDATION_RAIL_N, FOUNDATION_RAIL_W, and IsInsideMM().
Referenced by ApplyFoundationToSlope(), and GetRailFoundationCorner().
|
inlinestaticconstexpr |
Checks if a slope is steep.
s | The given Slope. |
Definition at line 36 of file slope_func.h.
References SLOPE_STEEP.
Referenced by ApplyFoundationToSlope(), CanBuildDepotByTileh(), CanBuildHouseHere(), CheckBuildableTile(), CheckRailSlope(), CheckRoadSlope(), ComplementSlope(), GetRailFoundation(), GetRoadFoundation(), GetSlopeMaxZ(), GrowTownWithTunnel(), HasSlopeHighestCorner(), IsSlopeWithThreeCornersRaised(), RiverMakeWider(), and SearchTileForStatue().
|
inlinestaticconstexpr |
Rangecheck for Corner enumeration.
corner | A Corner. |
Definition at line 24 of file slope_func.h.
References IsInsideMM().
Referenced by HalftileFoundation(), HalftileSlope(), SlopeWithOneCornerRaised(), and SpecialRailFoundation().
Returns the opposite corner.
corner | A Corner. |
Definition at line 184 of file slope_func.h.
Referenced by ApplyFoundationToSlope(), DrawAutorailSelection(), and SteepSlope().
Removes a halftile slope from a slope.
Non-halftile slopes remain unmodified.
s | A Slope. |
Definition at line 60 of file slope_func.h.
References SLOPE_HALFTILE_MASK.
Referenced by DrawAutorailSelection(), GetHighestSlopeCorner(), GetSlopePixelZOnEdge(), and HasSlopeHighestCorner().
|
inline |
Returns the Sprite offset for a given Slope.
s | The Slope to get the offset for. |
Definition at line 415 of file slope_func.h.
References _slope_to_sprite_offset.
Returns the slope with a specific corner raised.
corner | The Corner. |
Definition at line 99 of file slope_func.h.
References IsValidCorner().
Referenced by CheckRoadSlope(), GetRoadFoundation(), GetSlopePixelZOnEdge(), GetSlopeZInCorner(), and SlopeWithThreeCornersRaised().
Returns the slope with all except one corner raised.
corner | The Corner. |
Definition at line 206 of file slope_func.h.
References ComplementSlope(), and SlopeWithOneCornerRaised().
Referenced by ApplyFoundationToSlope(), DrawAutorailSelection(), and SteepSlope().
|
inline |
Returns the special rail foundation for single horizontal/vertical track.
corner | The Corner with the track. |
Definition at line 403 of file slope_func.h.
References FOUNDATION_RAIL_W, and IsValidCorner().
Returns a specific steep slope.
corner | A Corner. |
Definition at line 217 of file slope_func.h.
References OppositeCorner(), SLOPE_STEEP, and SlopeWithThreeCornersRaised().
Referenced by GetSlopeZInCorner().