src/slope_type.h
author convert-repo
Mon, 07 Apr 2008 16:21:55 +0000
changeset 10076 dfd70e42c4ae
parent 9297 94a4efa5de6e
permissions -rw-r--r--
update tags
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
     1
/* $Id$ */
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
     2
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
     3
/**
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
     4
 * @file slope_type.h Definitions of a slope.
7805
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
     5
 * This file defines the enumeration and helper functions for handling
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
     6
 * the slope info of a tile.
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
     7
 */
6916
e87d54a598ea (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6574
diff changeset
     8
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
     9
#ifndef SLOPE_TYPE_H
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
    10
#define SLOPE_TYPE_H
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
    11
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
    12
#include "core/enum_type.hpp"
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    13
7805
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    14
/**
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    15
 * Enumeration of tile corners
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    16
 */
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    17
enum Corner {
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    18
	CORNER_W = 0,
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    19
	CORNER_S = 1,
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    20
	CORNER_E = 2,
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    21
	CORNER_N = 3,
8266
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    22
	CORNER_END,
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    23
	CORNER_INVALID = 0xFF
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    24
};
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    25
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
    26
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    27
/**
7805
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    28
 * Enumeration for the slope-type.
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    29
 *
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    30
 * This enumeration use the chars N,E,S,W corresponding the
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    31
 * direction north, east, south and west. The top corner of a tile
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    32
 * is the north-part of the tile. The whole slope is encoded with
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    33
 * 5 bits, 4 bits for each corner and 1 bit for a steep-flag.
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    34
 *
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    35
 * For halftile slopes an extra 3 bits are used to represent this
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    36
 * properly; 1 bit for a halftile-flag and 2 bits to encode which
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    37
 * extra side (corner) is leveled when the slope of the first 5
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    38
 * bits is applied. This means that there can only be one leveled
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    39
 * slope for steep slopes, which is logical because two leveled
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    40
 * slopes would mean that it is not a steep slope as halftile
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    41
 * slopes only span one height level.
7805
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    42
 */
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 5726
diff changeset
    43
enum Slope {
7805
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    44
	SLOPE_FLAT     = 0x00,                                  ///< a flat tile
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    45
	SLOPE_W        = 0x01,                                  ///< the west corner of the tile is raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    46
	SLOPE_S        = 0x02,                                  ///< the south corner of the tile is raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    47
	SLOPE_E        = 0x04,                                  ///< the east corner of the tile is raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    48
	SLOPE_N        = 0x08,                                  ///< the north corner of the tile is raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    49
	SLOPE_STEEP    = 0x10,                                  ///< indicates the slope is steep
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    50
	SLOPE_NW       = SLOPE_N | SLOPE_W,                     ///< north and west corner are raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    51
	SLOPE_SW       = SLOPE_S | SLOPE_W,                     ///< south and west corner are raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    52
	SLOPE_SE       = SLOPE_S | SLOPE_E,                     ///< south and east corner are raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    53
	SLOPE_NE       = SLOPE_N | SLOPE_E,                     ///< north and east corner are raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    54
	SLOPE_EW       = SLOPE_E | SLOPE_W,                     ///< east and west corner are raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    55
	SLOPE_NS       = SLOPE_N | SLOPE_S,                     ///< north and south corner are raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    56
	SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, ///< all corner are raised, similar to SLOPE_FLAT
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    57
	SLOPE_NWS      = SLOPE_N | SLOPE_W | SLOPE_S,           ///< north, west and south corner are raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    58
	SLOPE_WSE      = SLOPE_W | SLOPE_S | SLOPE_E,           ///< west, south and east corner are raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    59
	SLOPE_SEN      = SLOPE_S | SLOPE_E | SLOPE_N,           ///< south, east and north corner are raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    60
	SLOPE_ENW      = SLOPE_E | SLOPE_N | SLOPE_W,           ///< east, north and west corner are raised
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    61
	SLOPE_STEEP_W  = SLOPE_STEEP | SLOPE_NWS,               ///< a steep slope falling to east (from west)
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    62
	SLOPE_STEEP_S  = SLOPE_STEEP | SLOPE_WSE,               ///< a steep slope falling to north (from south)
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    63
	SLOPE_STEEP_E  = SLOPE_STEEP | SLOPE_SEN,               ///< a steep slope falling to west (from east)
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    64
	SLOPE_STEEP_N  = SLOPE_STEEP | SLOPE_ENW,               ///< a steep slope falling to south (from north)
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    65
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    66
	SLOPE_HALFTILE = 0x20,                                  ///< one halftile is leveled (non continuous slope)
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    67
	SLOPE_HALFTILE_MASK = 0xE0,                             ///< three bits used for halftile slopes
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    68
	SLOPE_HALFTILE_W = SLOPE_HALFTILE | (CORNER_W << 6),    ///< the west halftile is leveled (non continuous slope)
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    69
	SLOPE_HALFTILE_S = SLOPE_HALFTILE | (CORNER_S << 6),    ///< the south halftile is leveled (non continuous slope)
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    70
	SLOPE_HALFTILE_E = SLOPE_HALFTILE | (CORNER_E << 6),    ///< the east halftile is leveled (non continuous slope)
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    71
	SLOPE_HALFTILE_N = SLOPE_HALFTILE | (CORNER_N << 6),    ///< the north halftile is leveled (non continuous slope)
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
    72
};
9297
94a4efa5de6e (svn r12541) -Codechange: Declare Slope enum as bit set, and remove some (then) unneeded casts.
frosch
parents: 8604
diff changeset
    73
DECLARE_ENUM_AS_BIT_SET(Slope)
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
    74
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
    75
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
    76
/**
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
    77
 * Enumeration for Foundations.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
    78
 */
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
    79
enum Foundation {
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
    80
	FOUNDATION_NONE,             ///< The tile has no foundation, the slope remains unchanged.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
    81
	FOUNDATION_LEVELED,          ///< The tile is leveled up to a flat slope.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
    82
	FOUNDATION_INCLINED_X,       ///< The tile has an along X-axis inclined foundation.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
    83
	FOUNDATION_INCLINED_Y,       ///< The tile has an along Y-axis inclined foundation.
8266
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    84
	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.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    85
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
    86
	/* Halftile foundations */
8266
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    87
	FOUNDATION_STEEP_BOTH,       ///< The tile has a steep slope. The lowest corner is raised by a foundation and the upper halftile is leveled.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    88
	FOUNDATION_HALFTILE_W,       ///< Level west halftile non-continuously.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    89
	FOUNDATION_HALFTILE_S,       ///< Level south halftile non-continuously.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    90
	FOUNDATION_HALFTILE_E,       ///< Level east halftile non-continuously.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    91
	FOUNDATION_HALFTILE_N,       ///< Level north halftile non-continuously.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    92
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
    93
	/* Special anti-zig-zag foundations for single horizontal/vertical track */
8266
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    94
	FOUNDATION_RAIL_W,           ///< Foundation for TRACK_BIT_LEFT, but not a leveled foundation.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    95
	FOUNDATION_RAIL_S,           ///< Foundation for TRACK_BIT_LOWER, but not a leveled foundation.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    96
	FOUNDATION_RAIL_E,           ///< Foundation for TRACK_BIT_RIGHT, but not a leveled foundation.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
    97
	FOUNDATION_RAIL_N,           ///< Foundation for TRACK_BIT_UPPER, but not a leveled foundation.
8199
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
    98
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
    99
	FOUNDATION_INVALID = 0xFF    ///< Used inside "rail_cmd.cpp" to indicate invalid slope/track combination.
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   100
};
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   101
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
   102
#endif /* SLOPE_TYPE_H */