OpenTTD Source: src/slope_type.h File Reference

OpenTTD Source 15.3

Macros | Enumerations | Variables
slope_type.h File Reference

Definitions of a slope. More...

`#include "core/enum_type.hpp"`

Go to the source code of this file.

## Macros
#define | M(x) (1U << (x))
| Helper for creating a bitset of slopes.

## Enumerations
enum | Corner : uint8_t { CORNER_W = 0 , CORNER_S = 1 , CORNER_E = 2 , CORNER_N = 3 , CORNER_END , CORNER_INVALID = 0xFF }
| Enumeration of tile corners. More...
enum | Slope : uint8_t { SLOPE_FLAT = 0x00 , SLOPE_W = 0x01 , SLOPE_S = 0x02 , SLOPE_E = 0x04 , SLOPE_N = 0x08 , SLOPE_STEEP = 0x10 , SLOPE_NW = SLOPE_N | SLOPE_W , SLOPE_SW = SLOPE_S | SLOPE_W , SLOPE_SE = SLOPE_S | SLOPE_E , SLOPE_NE = SLOPE_N | SLOPE_E , SLOPE_EW = SLOPE_E | SLOPE_W , SLOPE_NS = SLOPE_N | SLOPE_S , SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W , SLOPE_NWS = SLOPE_N | SLOPE_W | SLOPE_S , SLOPE_WSE = SLOPE_W | SLOPE_S | SLOPE_E , SLOPE_SEN = SLOPE_S | SLOPE_E | SLOPE_N , SLOPE_ENW = SLOPE_E | SLOPE_N | SLOPE_W , SLOPE_STEEP_W = SLOPE_STEEP | SLOPE_NWS , SLOPE_STEEP_S = SLOPE_STEEP | SLOPE_WSE , SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN , SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW , SLOPE_HALFTILE = 0x20 , SLOPE_HALFTILE_MASK = 0xE0 , SLOPE_HALFTILE_W = SLOPE_HALFTILE | (CORNER_W << 6) , SLOPE_HALFTILE_S = SLOPE_HALFTILE | (CORNER_S << 6) , SLOPE_HALFTILE_E = SLOPE_HALFTILE | (CORNER_E << 6) , SLOPE_HALFTILE_N = SLOPE_HALFTILE | (CORNER_N << 6) }
| Enumeration for the slope-type. More...
enum | Foundation : uint8_t { FOUNDATION_NONE , FOUNDATION_LEVELED , FOUNDATION_INCLINED_X , FOUNDATION_INCLINED_Y , FOUNDATION_STEEP_LOWER , FOUNDATION_STEEP_BOTH , FOUNDATION_HALFTILE_W , FOUNDATION_HALFTILE_S , FOUNDATION_HALFTILE_E , FOUNDATION_HALFTILE_N , FOUNDATION_RAIL_W , FOUNDATION_RAIL_S , FOUNDATION_RAIL_E , FOUNDATION_RAIL_N , FOUNDATION_INVALID = 0xFF }
| Enumeration for Foundations. More...

## Variables
static const uint32_t | VALID_LEVEL_CROSSING_SLOPES = M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT)
| Constant bitset with safe slopes for building a level crossing.

## Detailed Description

Definitions of a slope.

This file defines the enumeration and helper functions for handling the slope info of a tile.

Definition in file slope_type.h.

## Macro Definition Documentation

## ◆ M

#define M | ( |  | x | ) | (1U << (x))

Helper for creating a bitset of slopes.

Parameters

  x | The slope to convert into a bitset.

Definition at line 84 of file slope_type.h.

## Enumeration Type Documentation

## ◆ Corner

enum Corner : uint8_t

Enumeration of tile corners.

Definition at line 22 of file slope_type.h.

## ◆ Foundation

enum Foundation : uint8_t

Enumeration for Foundations.

Enumerator
FOUNDATION_NONE | The tile has no foundation, the slope remains unchanged.
FOUNDATION_LEVELED | The tile is leveled up to a flat slope.
FOUNDATION_INCLINED_X | The tile has an along X-axis inclined foundation.
FOUNDATION_INCLINED_Y | The tile has an along Y-axis inclined foundation.
FOUNDATION_STEEP_LOWER | The tile has a steep slope. The lowest corner is raised by a foundation to allow building railroad on the lower halftile.
FOUNDATION_STEEP_BOTH | The tile has a steep slope. The lowest corner is raised by a foundation and the upper halftile is leveled.
FOUNDATION_HALFTILE_W | Level west halftile non-continuously.
FOUNDATION_HALFTILE_S | Level south halftile non-continuously.
FOUNDATION_HALFTILE_E | Level east halftile non-continuously.
FOUNDATION_HALFTILE_N | Level north halftile non-continuously.
FOUNDATION_RAIL_W | Foundation for TRACK_BIT_LEFT, but not a leveled foundation.
FOUNDATION_RAIL_S | Foundation for TRACK_BIT_LOWER, but not a leveled foundation.
FOUNDATION_RAIL_E | Foundation for TRACK_BIT_RIGHT, but not a leveled foundation.
FOUNDATION_RAIL_N | Foundation for TRACK_BIT_UPPER, but not a leveled foundation.
FOUNDATION_INVALID | Used inside "rail_cmd.cpp" to indicate invalid slope/track combination.

Definition at line 93 of file slope_type.h.

## ◆ Slope

enum Slope : uint8_t

Enumeration for the slope-type.

This enumeration use the chars N,E,S,W corresponding the direction north, east, south and west. The top corner of a tile is the north-part of the tile. The whole slope is encoded with 5 bits, 4 bits for each corner and 1 bit for a steep-flag.

For halftile slopes an extra 3 bits are used to represent this properly; 1 bit for a halftile-flag and 2 bits to encode which extra side (corner) is leveled when the slope of the first 5 bits is applied. This means that there can only be one leveled slope for steep slopes, which is logical because two leveled slopes would mean that it is not a steep slope as halftile slopes only span one height level.

Enumerator
SLOPE_FLAT | a flat tile
SLOPE_W | the west corner of the tile is raised
SLOPE_S | the south corner of the tile is raised
SLOPE_E | the east corner of the tile is raised
SLOPE_N | the north corner of the tile is raised
SLOPE_STEEP | indicates the slope is steep
SLOPE_NW | north and west corner are raised
SLOPE_SW | south and west corner are raised
SLOPE_SE | south and east corner are raised
SLOPE_NE | north and east corner are raised
SLOPE_EW | east and west corner are raised
SLOPE_NS | north and south corner are raised
SLOPE_ELEVATED | bit mask containing all 'simple' slopes
SLOPE_NWS | north, west and south corner are raised
SLOPE_WSE | west, south and east corner are raised
SLOPE_SEN | south, east and north corner are raised
SLOPE_ENW | east, north and west corner are raised
SLOPE_STEEP_W | a steep slope falling to east (from west)
SLOPE_STEEP_S | a steep slope falling to north (from south)
SLOPE_STEEP_E | a steep slope falling to west (from east)
SLOPE_STEEP_N | a steep slope falling to south (from north)
SLOPE_HALFTILE | one halftile is leveled (non continuous slope)
SLOPE_HALFTILE_MASK | three bits used for halftile slopes
SLOPE_HALFTILE_W | the west halftile is leveled (non continuous slope)
SLOPE_HALFTILE_S | the south halftile is leveled (non continuous slope)
SLOPE_HALFTILE_E | the east halftile is leveled (non continuous slope)
SLOPE_HALFTILE_N | the north halftile is leveled (non continuous slope)

Definition at line 48 of file slope_type.h.

## Variable Documentation

## ◆ VALID_LEVEL_CROSSING_SLOPES

const uint32_t VALID_LEVEL_CROSSING_SLOPES = M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT)
| static

Constant bitset with safe slopes for building a level crossing.

Definition at line 86 of file slope_type.h.

Referenced by CmdBuildRoad(), and CmdBuildSingleRail().