src/slope_type.h
author peter1138
Tue, 22 Jan 2008 07:27:06 +0000
changeset 8374 7a1b6c89cb89
parent 8108 b42a0e5c67ef
child 8801 8c4b104b39ac
permissions -rw-r--r--
(svn r11940) -Codechange: Store short filename once per open file instead of once per sprite cache entry. Not all file types need this, but most of the time no sprite cache entry needed it either.
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
     1
/* $Id$ */
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
     2
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 7954
diff changeset
     3
/**
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 7954
diff changeset
     4
 * @file slope_type.h Definitions of a slope.
7309
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
     5
 * This file defines the enumeration and helper functions for handling
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
     6
 * the slope info of a tile.
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
     7
 */
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6248
diff changeset
     8
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 7954
diff changeset
     9
#ifndef SLOPE_TYPE_H
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 7954
diff changeset
    10
#define SLOPE_TYPE_H
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 7954
diff changeset
    11
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 7954
diff changeset
    12
#include "core/enum_type.hpp"
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    13
7309
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    14
/**
7764
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    15
 * Enumeration of tile corners
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    16
 */
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    17
enum Corner {
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    18
	CORNER_W = 0,
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    19
	CORNER_S = 1,
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    20
	CORNER_E = 2,
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    21
	CORNER_N = 3,
7770
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    22
	CORNER_END,
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    23
	CORNER_INVALID = 0xFF
7764
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    24
};
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    25
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 7954
diff changeset
    26
7764
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    27
/**
7309
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    28
 * Enumeration for the slope-type.
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    29
 *
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    30
 * This enumeration use the chars N,E,S,W corresponding the
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    31
 * direction north, east, south and west. The top corner of a tile
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    32
 * is the north-part of the tile. The whole slope is encoded with
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    33
 * 5 bits, 4 bits for each corner and 1 bit for a steep-flag.
7764
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    34
 *
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    35
 * For halftile slopes an extra 3 bits are used to represent this
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    36
 * properly; 1 bit for a halftile-flag and 2 bits to encode which
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    37
 * extra side (corner) is leveled when the slope of the first 5
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    38
 * bits is applied. This means that there can only be one leveled
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    39
 * slope for steep slopes, which is logical because two leveled
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    40
 * slopes would mean that it is not a steep slope as halftile
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    41
 * slopes only span one height level.
7309
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    42
 */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 5475
diff changeset
    43
enum Slope {
7309
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    44
	SLOPE_FLAT     = 0x00,                                  ///< a flat tile
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    45
	SLOPE_W        = 0x01,                                  ///< the west corner of the tile is raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    46
	SLOPE_S        = 0x02,                                  ///< the south corner of the tile is raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    47
	SLOPE_E        = 0x04,                                  ///< the east corner of the tile is raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    48
	SLOPE_N        = 0x08,                                  ///< the north corner of the tile is raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    49
	SLOPE_STEEP    = 0x10,                                  ///< indicates the slope is steep
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    50
	SLOPE_NW       = SLOPE_N | SLOPE_W,                     ///< north and west corner are raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    51
	SLOPE_SW       = SLOPE_S | SLOPE_W,                     ///< south and west corner are raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    52
	SLOPE_SE       = SLOPE_S | SLOPE_E,                     ///< south and east corner are raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    53
	SLOPE_NE       = SLOPE_N | SLOPE_E,                     ///< north and east corner are raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    54
	SLOPE_EW       = SLOPE_E | SLOPE_W,                     ///< east and west corner are raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    55
	SLOPE_NS       = SLOPE_N | SLOPE_S,                     ///< north and south corner are raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    56
	SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, ///< all corner are raised, similar to SLOPE_FLAT
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    57
	SLOPE_NWS      = SLOPE_N | SLOPE_W | SLOPE_S,           ///< north, west and south corner are raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    58
	SLOPE_WSE      = SLOPE_W | SLOPE_S | SLOPE_E,           ///< west, south and east corner are raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    59
	SLOPE_SEN      = SLOPE_S | SLOPE_E | SLOPE_N,           ///< south, east and north corner are raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    60
	SLOPE_ENW      = SLOPE_E | SLOPE_N | SLOPE_W,           ///< east, north and west corner are raised
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    61
	SLOPE_STEEP_W  = SLOPE_STEEP | SLOPE_NWS,               ///< a steep slope falling to east (from west)
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    62
	SLOPE_STEEP_S  = SLOPE_STEEP | SLOPE_WSE,               ///< a steep slope falling to north (from south)
223e01a82942 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6420
diff changeset
    63
	SLOPE_STEEP_E  = SLOPE_STEEP | SLOPE_SEN,               ///< a steep slope falling to west (from east)
7764
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    64
	SLOPE_STEEP_N  = SLOPE_STEEP | SLOPE_ENW,               ///< a steep slope falling to south (from north)
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    65
7764
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    66
	SLOPE_HALFTILE = 0x20,                                  ///< one halftile is leveled (non continuous slope)
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    67
	SLOPE_HALFTILE_MASK = 0xE0,                             ///< three bits used for halftile slopes
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    68
	SLOPE_HALFTILE_W = SLOPE_HALFTILE | (CORNER_W << 6),    ///< the west halftile is leveled (non continuous slope)
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    69
	SLOPE_HALFTILE_S = SLOPE_HALFTILE | (CORNER_S << 6),    ///< the south halftile is leveled (non continuous slope)
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    70
	SLOPE_HALFTILE_E = SLOPE_HALFTILE | (CORNER_E << 6),    ///< the east halftile is leveled (non continuous slope)
e594296e90f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 7703
diff changeset
    71
	SLOPE_HALFTILE_N = SLOPE_HALFTILE | (CORNER_N << 6),    ///< the north halftile is leveled (non continuous slope)
7678
8917067dde87 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 7582
diff changeset
    72
};
8917067dde87 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 7582
diff changeset
    73
7335
141c6b86ec1f (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: 7309
diff changeset
    74
141c6b86ec1f (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: 7309
diff changeset
    75
/**
141c6b86ec1f (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: 7309
diff changeset
    76
 * Enumeration for Foundations.
141c6b86ec1f (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: 7309
diff changeset
    77
 */
141c6b86ec1f (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: 7309
diff changeset
    78
enum Foundation {
141c6b86ec1f (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: 7309
diff changeset
    79
	FOUNDATION_NONE,             ///< The tile has no foundation, the slope remains unchanged.
141c6b86ec1f (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: 7309
diff changeset
    80
	FOUNDATION_LEVELED,          ///< The tile is leveled up to a flat slope.
141c6b86ec1f (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: 7309
diff changeset
    81
	FOUNDATION_INCLINED_X,       ///< The tile has an along X-axis inclined foundation.
141c6b86ec1f (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: 7309
diff changeset
    82
	FOUNDATION_INCLINED_Y,       ///< The tile has an along Y-axis inclined foundation.
7770
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    83
	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.
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    84
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 7954
diff changeset
    85
	/* Halftile foundations */
7770
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    86
	FOUNDATION_STEEP_BOTH,       ///< The tile has a steep slope. The lowest corner is raised by a foundation and the upper halftile is leveled.
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    87
	FOUNDATION_HALFTILE_W,       ///< Level west halftile non-continuously.
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    88
	FOUNDATION_HALFTILE_S,       ///< Level south halftile non-continuously.
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    89
	FOUNDATION_HALFTILE_E,       ///< Level east halftile non-continuously.
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    90
	FOUNDATION_HALFTILE_N,       ///< Level north halftile non-continuously.
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    91
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 7954
diff changeset
    92
	/* Special anti-zig-zag foundations for single horizontal/vertical track */
7770
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    93
	FOUNDATION_RAIL_W,           ///< Foundation for TRACK_BIT_LEFT, but not a leveled foundation.
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    94
	FOUNDATION_RAIL_S,           ///< Foundation for TRACK_BIT_LOWER, but not a leveled foundation.
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    95
	FOUNDATION_RAIL_E,           ///< Foundation for TRACK_BIT_RIGHT, but not a leveled foundation.
320d260ff1a1 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 7764
diff changeset
    96
	FOUNDATION_RAIL_N,           ///< Foundation for TRACK_BIT_UPPER, but not a leveled foundation.
7703
6178606d419a (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 7678
diff changeset
    97
6178606d419a (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 7678
diff changeset
    98
	FOUNDATION_INVALID = 0xFF    ///< Used inside "rail_cmd.cpp" to indicate invalid slope/track combination.
7335
141c6b86ec1f (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: 7309
diff changeset
    99
};
141c6b86ec1f (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: 7309
diff changeset
   100
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 7954
diff changeset
   101
#endif /* SLOPE_TYPE_H */