OpenTTD
|
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 bool | IsValidCorner (Corner corner) |
Rangecheck for Corner enumeration. | |
static bool | IsSteepSlope (Slope s) |
Checks if a slope is steep. | |
static bool | IsHalftileSlope (Slope s) |
Checks for non-continuous slope on halftile foundations. | |
static Slope | RemoveHalftileSlope (Slope s) |
Removes a halftile slope from a slope. | |
static Slope | ComplementSlope (Slope s) |
Return the complement of a slope. | |
static bool | IsSlopeWithOneCornerRaised (Slope s) |
Tests if a specific slope has exactly one corner raised. | |
static Slope | SlopeWithOneCornerRaised (Corner corner) |
Returns the slope with a specific corner raised. | |
static bool | HasSlopeHighestCorner (Slope s) |
Tests if a slope has a highest corner (i.e. | |
static Corner | GetHighestSlopeCorner (Slope s) |
Returns the highest corner of a slope (one corner raised or a steep slope). | |
static Corner | GetHalftileSlopeCorner (Slope s) |
Returns the leveled halftile of a halftile slope. | |
static int | GetSlopeMaxZ (Slope s) |
Returns the height of the highest corner of a slope relative to TileZ (= minimal height) | |
static int | GetSlopeMaxPixelZ (Slope s) |
Returns the height of the highest corner of a slope relative to TileZ (= minimal height) | |
static Corner | OppositeCorner (Corner corner) |
Returns the opposite corner. | |
static bool | IsSlopeWithThreeCornersRaised (Slope s) |
Tests if a specific slope has exactly three corners raised. | |
static Slope | SlopeWithThreeCornersRaised (Corner corner) |
Returns the slope with all except one corner raised. | |
static Slope | SteepSlope (Corner corner) |
Returns a specific steep slope. | |
static bool | IsInclinedSlope (Slope s) |
Tests if a specific slope is an inclined slope. | |
static DiagDirection | GetInclinedSlopeDirection (Slope s) |
Returns the direction of an inclined slope. | |
static Slope | InclinedSlope (DiagDirection dir) |
Returns the slope that is inclined in a specific direction. | |
static Slope | HalftileSlope (Slope s, Corner corner) |
Adds a halftile slope to a slope. | |
static bool | IsFoundation (Foundation f) |
Tests for FOUNDATION_NONE. | |
static bool | IsLeveledFoundation (Foundation f) |
Tests if the foundation is a leveled foundation. | |
static bool | IsInclinedFoundation (Foundation f) |
Tests if the foundation is an inclined foundation. | |
static bool | IsNonContinuousFoundation (Foundation f) |
Tests if a foundation is a non-continuous foundation, i.e. | |
static Corner | GetHalftileFoundationCorner (Foundation f) |
Returns the halftile corner of a halftile-foundation. | |
static bool | IsSpecialRailFoundation (Foundation f) |
Tests if a foundation is a special rail foundation for single horizontal/vertical track. | |
static Corner | GetRailFoundationCorner (Foundation f) |
Returns the track corner of a special rail foundation. | |
static Foundation | FlatteningFoundation (Slope s) |
Returns the foundation needed to flatten a slope. | |
static Foundation | InclinedFoundation (Axis axis) |
Returns the along a specific axis inclined foundation. | |
static Foundation | HalftileFoundation (Corner corner) |
Returns the halftile foundation for single horizontal/vertical track. | |
static Foundation | SpecialRailFoundation (Corner corner) |
Returns the special rail foundation for single horizontal/vertical track. | |
static uint | SlopeToSpriteOffset (Slope s) |
Returns the Sprite offset for a given Slope. |
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 78 of file slope_func.h.
References IsHalftileSlope(), IsSteepSlope(), and SLOPE_ELEVATED.
Referenced by CmdBuildTunnel(), DrawTrackBits(), DrawTrackDetails(), IsRoadAllowedHere(), IsSlopeWithThreeCornersRaised(), and SlopeWithThreeCornersRaised().
|
inlinestatic |
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 371 of file slope_func.h.
References FOUNDATION_LEVELED, FOUNDATION_NONE, and SLOPE_FLAT.
Referenced by GetBridgeFoundation(), and GetFoundation_Town().
|
inlinestatic |
Returns the halftile corner of a halftile-foundation.
f | The Foundation. |
Definition at line 335 of file slope_func.h.
References FOUNDATION_HALFTILE_N, FOUNDATION_HALFTILE_W, and IsInsideMM().
Referenced by ApplyFoundationToSlope(), DrawFoundation(), and DrawTrackBits().
Returns the leveled halftile of a halftile slope.
s | The Slope. |
Definition at line 150 of file slope_func.h.
References IsHalftileSlope().
Referenced by DrawAutorailSelection(), DrawRailCatenaryRailway(), DrawTileSelection(), DrawTileSelectionRect(), DrawTrackDetails(), GetPartialPixelZ(), and GetSlopePixelZOnEdge().
Returns the highest corner of a slope (one corner raised or a steep slope).
s | The Slope. |
Definition at line 128 of file slope_func.h.
References RemoveHalftileSlope(), SLOPE_E, SLOPE_N, SLOPE_S, SLOPE_STEEP_E, SLOPE_STEEP_N, SLOPE_STEEP_S, SLOPE_STEEP_W, and SLOPE_W.
Referenced by ApplyFoundationToSlope(), CheckRoadSlope(), DrawFoundation(), DrawTrackBits(), DrawTrackDetails(), FloodHalftile(), GetRailFoundation(), GetRoadFoundation(), and RemoveRoad().
|
inlinestatic |
Returns the direction of an inclined slope.
s | A Slope |
Definition at line 241 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 CmdBuildDock(), CmdBuildLock(), CmdBuildTunnel(), GetOtherAqueductEnd(), BuildDocksToolbarWindow::OnPlaceObject(), and BuildDocksToolbarWindow::OnPlacePresize().
|
inlinestatic |
Returns the track corner of a special rail foundation.
f | The Foundation. |
Definition at line 358 of file slope_func.h.
References FOUNDATION_RAIL_W, and IsSpecialRailFoundation().
Referenced by ApplyFoundationToSlope(), and DrawFoundation().
|
inlinestatic |
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
s | The Slope. |
Definition at line 175 of file slope_func.h.
References GetSlopeMaxZ(), and TILE_HEIGHT.
Referenced by GetPartialPixelZ().
|
inlinestatic |
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
s | The Slope. |
Definition at line 162 of file slope_func.h.
References IsSteepSlope(), and SLOPE_FLAT.
Referenced by AutoslopeCheckForEntranceEdge(), CheckBuildableTile(), and GetSlopeMaxPixelZ().
|
inlinestatic |
Returns the halftile foundation for single horizontal/vertical track.
corner | The Corner with the track. |
Definition at line 393 of file slope_func.h.
References FOUNDATION_HALFTILE_W, and IsValidCorner().
Referenced by DrawTrackBits(), and GetRailFoundation().
Adds a halftile slope to a slope.
Definition at line 276 of file slope_func.h.
References IsValidCorner(), and SLOPE_HALFTILE.
Referenced by ApplyFoundationToSlope().
|
inlinestatic |
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 115 of file slope_func.h.
References IsSlopeWithOneCornerRaised(), IsSteepSlope(), and RemoveHalftileSlope().
Referenced by GetBridgeFoundation().
|
inlinestatic |
Returns the along a specific axis inclined foundation.
axis | The Axis. |
Definition at line 382 of file slope_func.h.
References AXIS_X, FOUNDATION_INCLINED_X, and FOUNDATION_INCLINED_Y.
Referenced by GetBridgeFoundation().
|
inlinestatic |
Returns the slope that is inclined in a specific direction.
dir | A DiagDirection |
Definition at line 258 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(), and GrowTownWithBridge().
|
inlinestatic |
Tests for FOUNDATION_NONE.
f | Maybe a Foundation. |
Definition at line 289 of file slope_func.h.
References FOUNDATION_NONE.
Referenced by ApplyFoundationToSlope(), and DrawFoundation().
|
inlinestatic |
Checks for non-continuous slope on halftile foundations.
s | The given Slope. |
Definition at line 49 of file slope_func.h.
References SLOPE_HALFTILE.
Referenced by ComplementSlope(), DrawAutorailSelection(), DrawRailCatenaryRailway(), DrawTileSelection(), DrawTileSelectionRect(), DrawTrackDetails(), GetHalftileSlopeCorner(), GetPartialPixelZ(), GetSlopePixelZOnEdge(), GetSlopeZInCorner(), and IsSlopeWithThreeCornersRaised().
|
inlinestatic |
Tests if the foundation is an inclined foundation.
f | The Foundation. |
Definition at line 311 of file slope_func.h.
References FOUNDATION_INCLINED_X, and FOUNDATION_INCLINED_Y.
Referenced by DrawFoundation().
|
inlinestatic |
Tests if a specific slope is an inclined slope.
s | The Slope |
Definition at line 230 of file slope_func.h.
References SLOPE_NE, SLOPE_NW, SLOPE_SE, and SLOPE_SW.
Referenced by CmdBuildCanal(), and FlowsDown().
|
inlinestatic |
Tests if the foundation is a leveled foundation.
f | The Foundation. |
Definition at line 300 of file slope_func.h.
References FOUNDATION_LEVELED.
Referenced by ApplyFoundationToSlope(), and DrawFoundation().
|
inlinestatic |
Tests if a foundation is a non-continuous foundation, i.e.
halftile-foundation or FOUNDATION_STEEP_BOTH.
f | The Foundation. |
Definition at line 322 of file slope_func.h.
References FOUNDATION_HALFTILE_N, FOUNDATION_STEEP_BOTH, and IsInsideMM().
Referenced by ApplyFoundationToSlope(), DrawFoundation(), DrawTrackBits(), and FloodHalftile().
|
inlinestatic |
Tests if a specific slope has exactly one corner raised.
s | The Slope |
Definition at line 90 of file slope_func.h.
References SLOPE_E, SLOPE_N, SLOPE_S, and SLOPE_W.
Referenced by CanPlantTreesOnTile(), CheckRoadSlope(), CmdBuildSingleRail(), CmdPlantTree(), CmdRemoveSingleRail(), DoFloodTile(), FloodHalftile(), GetFloodingBehaviour(), GetRailFoundation(), GetRoadFoundation(), HasSlopeHighestCorner(), IsSlopeWithThreeCornersRaised(), and TestAutoslopeOnRailTile().
|
inlinestatic |
Tests if a specific slope has exactly three corners raised.
s | The Slope |
Definition at line 197 of file slope_func.h.
References ComplementSlope(), IsHalftileSlope(), IsSlopeWithOneCornerRaised(), and IsSteepSlope().
Referenced by FloodHalftile(), and GetRailFoundation().
|
inlinestatic |
Tests if a foundation is a special rail foundation for single horizontal/vertical track.
f | The Foundation. |
Definition at line 347 of file slope_func.h.
References FOUNDATION_RAIL_N, FOUNDATION_RAIL_W, and IsInsideMM().
Referenced by ApplyFoundationToSlope(), DrawFoundation(), and GetRailFoundationCorner().
|
inlinestatic |
Checks if a slope is steep.
s | The given Slope. |
Definition at line 38 of file slope_func.h.
References SLOPE_STEEP.
Referenced by ApplyFoundationToSlope(), CanBuildDepotByTileh(), CanBuildHouseHere(), CheckBuildableTile(), CheckRailSlope(), CheckRoadSlope(), CmdBuildRoad(), ComplementSlope(), DrawFoundation(), DrawRailCatenaryRailway(), DrawTileSelection(), DrawTileSelectionRect(), DrawTrackBits(), FloodHalftile(), GetRailFoundation(), GetRoadFoundation(), GetSlopeMaxZ(), HasSlopeHighestCorner(), IsSlopeWithThreeCornersRaised(), IsValidTileForWaypoint(), RemoveRoad(), and SearchTileForStatue().
|
inlinestatic |
Rangecheck for Corner enumeration.
corner | A Corner. |
Definition at line 26 of file slope_func.h.
References IsInsideMM().
Referenced by CornerToTrackBits(), DrawTrackBits(), HalftileFoundation(), HalftileSlope(), SlopeWithOneCornerRaised(), and SpecialRailFoundation().
Returns the opposite corner.
corner | A Corner. |
Definition at line 186 of file slope_func.h.
Referenced by ApplyFoundationToSlope(), DrawAutorailSelection(), DrawTileSelectionRect(), DrawTrackBits(), DrawTrackDetails(), FloodHalftile(), GetRailFoundation(), and SteepSlope().
Removes a halftile slope from a slope.
Non-halftile slopes remain unmodified.
s | A Slope. |
Definition at line 62 of file slope_func.h.
References SLOPE_HALFTILE_MASK.
Referenced by DrawAutorailSelection(), DrawTileSelection(), DrawTrackFence(), GetHighestSlopeCorner(), GetPartialPixelZ(), GetSlopePixelZOnEdge(), HasSlopeHighestCorner(), IsUphillTrackdir(), and TestAutoslopeOnRailTile().
|
inlinestatic |
Returns the Sprite offset for a given Slope.
s | The Slope to get the offset for. |
Definition at line 417 of file slope_func.h.
References _slope_to_sprite_offset.
Referenced by DrawTile_TunnelBridge(), DrawTileSelectionRect(), and DrawTrackBits().
Returns the slope with a specific corner raised.
corner | The Corner. |
Definition at line 101 of file slope_func.h.
References IsValidCorner().
Referenced by ApplyFoundationToSlope(), CheckRoadSlope(), DrawFoundation(), DrawTileSelectionRect(), GetRailFoundation(), GetRoadFoundation(), GetSlopePixelZOnEdge(), GetSlopeZInCorner(), RemoveRoad(), and SlopeWithThreeCornersRaised().
Returns the slope with all except one corner raised.
corner | The Corner. |
Definition at line 208 of file slope_func.h.
References ComplementSlope(), and SlopeWithOneCornerRaised().
Referenced by ApplyFoundationToSlope(), DrawAutorailSelection(), DrawFoundation(), DrawTrackBits(), GetRailFoundation(), and SteepSlope().
|
inlinestatic |
Returns the special rail foundation for single horizontal/vertical track.
corner | The Corner with the track. |
Definition at line 405 of file slope_func.h.
References FOUNDATION_RAIL_W, and IsValidCorner().
Referenced by GetRailFoundation().
Returns a specific steep slope.
corner | A Corner. |
Definition at line 219 of file slope_func.h.
References OppositeCorner(), SLOPE_STEEP, and SlopeWithThreeCornersRaised().
Referenced by GetSlopeZInCorner().