OpenTTD Source: src/direction_type.h File Reference

OpenTTD Source 1.11.0-RC1

Data Structures | Enumerations
direction_type.h File Reference
`#include "core/enum_type.hpp"`

Go to the source code of this file.

## Data Structures
struct | EnumPropsT< Direction >
| Allow incrementing of Direction variables. More...
struct | EnumPropsT< DiagDirection >
| Allow incrementing of DiagDirection variables. More...
struct | EnumPropsT< Axis >
| Helper information for extract tool. More...

## Enumerations
enum | Direction : byte { DIR_BEGIN = 0, DIR_N = 0, DIR_NE = 1, DIR_E = 2, DIR_SE = 3, DIR_S = 4, DIR_SW = 5, DIR_W = 6, DIR_NW = 7, DIR_END, INVALID_DIR = 0xFF }
| Defines the 8 directions on the map. More...
enum | DirDiff { DIRDIFF_SAME = 0, DIRDIFF_45RIGHT = 1, DIRDIFF_90RIGHT = 2, DIRDIFF_REVERSE = 4, DIRDIFF_90LEFT = 6, DIRDIFF_45LEFT = 7 }
| Enumeration for the difference between two directions. More...
enum | DiagDirection : byte { DIAGDIR_BEGIN = 0, DIAGDIR_NE = 0, DIAGDIR_SE = 1, DIAGDIR_SW = 2, DIAGDIR_NW = 3, DIAGDIR_END, INVALID_DIAGDIR = 0xFF }
| Enumeration for diagonal directions. More...
enum | DiagDirDiff { DIAGDIRDIFF_SAME = 0, DIAGDIRDIFF_90RIGHT = 1, DIAGDIRDIFF_REVERSE = 2, DIAGDIRDIFF_90LEFT = 3 }
| Enumeration for the difference between to DiagDirection. More...
enum | Axis { AXIS_X = 0, AXIS_Y = 1, AXIS_END, INVALID_AXIS = 0xFF }
| Allow incrementing of DiagDirDiff variables. More...

## Detailed Description

Different types to 'show' directions.

Definition in file direction_type.h.

## Enumeration Type Documentation

## ◆ Axis

enum Axis

Allow incrementing of DiagDirDiff variables.

Enumeration for the two axis X and Y

This enumeration represents the two axis X and Y in the game. The X axis is the one which goes align the north-west edge (and south-east edge). The Y axis must be so the one which goes align the north-east edge (and south-west) edge.

Enumerator
AXIS_X | The X axis.
AXIS_Y | The y axis.
AXIS_END | Used for iterations.
INVALID_AXIS | Flag for an invalid Axis.

Definition at line 123 of file direction_type.h.

## ◆ DiagDirDiff

enum DiagDirDiff

Enumeration for the difference between to DiagDirection.

As the DiagDirection only contains 4 possible directions the difference between two of these directions can only be in 4 ways. As the DirDiff enumeration the values can be added together and you will get the resulting difference (use modulo DIAGDIR_END).

See also
  DirDiff

Enumerator
DIAGDIRDIFF_SAME | Same directions.
DIAGDIRDIFF_90RIGHT | 90 degrees right
DIAGDIRDIFF_REVERSE | Reverse directions.
DIAGDIRDIFF_90LEFT | 90 degrees left

Definition at line 104 of file direction_type.h.

## ◆ DiagDirection

enum DiagDirection : byte

Enumeration for diagonal directions.

This enumeration is used for the 4 direction of the tile-edges.

Enumerator
DIAGDIR_BEGIN | Used for iterations.
DIAGDIR_NE | Northeast, upper right on your monitor.
DIAGDIR_SE | Southeast.
DIAGDIR_SW | Southwest.
DIAGDIR_NW | Northwest.
DIAGDIR_END | Used for iterations.
INVALID_DIAGDIR | Flag for an invalid DiagDirection.

Definition at line 77 of file direction_type.h.

## ◆ DirDiff

enum DirDiff

Enumeration for the difference between two directions.

This enumeration is used to mark differences between two directions. If you get one direction you can align a second direction in 8 different ways. This enumeration only contains 6 of these 8 differences, but the remaining two can be calculated by adding to differences together. This also means you can add two differences together and get the difference you really want to get. The difference of 45 degrees left + the difference of 45 degrees right results in the difference of 0 degrees.

Note
  To get this mentioned addition of direction you must use modulo DIR_END or use the ChangeDirDiff(DirDiff, DirDiff) function.

See also
  ChangeDirDiff(DirDiff, DirDiff)

Enumerator
DIRDIFF_SAME | Both directions faces to the same direction.
DIRDIFF_45RIGHT | Angle of 45 degrees right.
DIRDIFF_90RIGHT | Angle of 90 degrees right.
DIRDIFF_REVERSE | One direction is the opposite of the other one.
DIRDIFF_90LEFT | Angle of 90 degrees left.
DIRDIFF_45LEFT | Angle of 45 degrees left.

Definition at line 62 of file direction_type.h.

## ◆ Direction

enum Direction : byte

Defines the 8 directions on the map.

This enum defines 8 possible directions which are used for the vehicles in the game. The directions are aligned straight to the viewport, not to the map. So north points to the top of your viewport and not rotated by 45 degrees left or right to get a "north" used in you games.

Enumerator
DIR_BEGIN | Used to iterate.
DIR_N | North.
DIR_NE | Northeast.
DIR_E | East.
DIR_SE | Southeast.
DIR_S | South.
DIR_SW | Southwest.
DIR_W | West.
DIR_NW | Northwest.
DIR_END | Used to iterate.
INVALID_DIR | Flag for an invalid direction.

Definition at line 24 of file direction_type.h.