src/slope_type.h
changeset 8604 8afdd9877afd
parent 8450 dce58137301f
child 9297 94a4efa5de6e
equal deleted inserted replaced
8603:88c5ce6a5215 8604:8afdd9877afd
       
     1 /* $Id$ */
       
     2 
       
     3 /**
       
     4  * @file slope_type.h Definitions of a slope.
       
     5  * This file defines the enumeration and helper functions for handling
       
     6  * the slope info of a tile.
       
     7  */
       
     8 
       
     9 #ifndef SLOPE_TYPE_H
       
    10 #define SLOPE_TYPE_H
       
    11 
       
    12 #include "core/enum_type.hpp"
       
    13 
       
    14 /**
       
    15  * Enumeration of tile corners
       
    16  */
       
    17 enum Corner {
       
    18 	CORNER_W = 0,
       
    19 	CORNER_S = 1,
       
    20 	CORNER_E = 2,
       
    21 	CORNER_N = 3,
       
    22 	CORNER_END,
       
    23 	CORNER_INVALID = 0xFF
       
    24 };
       
    25 
       
    26 
       
    27 /**
       
    28  * Enumeration for the slope-type.
       
    29  *
       
    30  * This enumeration use the chars N,E,S,W corresponding the
       
    31  * direction north, east, south and west. The top corner of a tile
       
    32  * is the north-part of the tile. The whole slope is encoded with
       
    33  * 5 bits, 4 bits for each corner and 1 bit for a steep-flag.
       
    34  *
       
    35  * For halftile slopes an extra 3 bits are used to represent this
       
    36  * properly; 1 bit for a halftile-flag and 2 bits to encode which
       
    37  * extra side (corner) is leveled when the slope of the first 5
       
    38  * bits is applied. This means that there can only be one leveled
       
    39  * slope for steep slopes, which is logical because two leveled
       
    40  * slopes would mean that it is not a steep slope as halftile
       
    41  * slopes only span one height level.
       
    42  */
       
    43 enum Slope {
       
    44 	SLOPE_FLAT     = 0x00,                                  ///< a flat tile
       
    45 	SLOPE_W        = 0x01,                                  ///< the west corner of the tile is raised
       
    46 	SLOPE_S        = 0x02,                                  ///< the south corner of the tile is raised
       
    47 	SLOPE_E        = 0x04,                                  ///< the east corner of the tile is raised
       
    48 	SLOPE_N        = 0x08,                                  ///< the north corner of the tile is raised
       
    49 	SLOPE_STEEP    = 0x10,                                  ///< indicates the slope is steep
       
    50 	SLOPE_NW       = SLOPE_N | SLOPE_W,                     ///< north and west corner are raised
       
    51 	SLOPE_SW       = SLOPE_S | SLOPE_W,                     ///< south and west corner are raised
       
    52 	SLOPE_SE       = SLOPE_S | SLOPE_E,                     ///< south and east corner are raised
       
    53 	SLOPE_NE       = SLOPE_N | SLOPE_E,                     ///< north and east corner are raised
       
    54 	SLOPE_EW       = SLOPE_E | SLOPE_W,                     ///< east and west corner are raised
       
    55 	SLOPE_NS       = SLOPE_N | SLOPE_S,                     ///< north and south corner are raised
       
    56 	SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, ///< all corner are raised, similar to SLOPE_FLAT
       
    57 	SLOPE_NWS      = SLOPE_N | SLOPE_W | SLOPE_S,           ///< north, west and south corner are raised
       
    58 	SLOPE_WSE      = SLOPE_W | SLOPE_S | SLOPE_E,           ///< west, south and east corner are raised
       
    59 	SLOPE_SEN      = SLOPE_S | SLOPE_E | SLOPE_N,           ///< south, east and north corner are raised
       
    60 	SLOPE_ENW      = SLOPE_E | SLOPE_N | SLOPE_W,           ///< east, north and west corner are raised
       
    61 	SLOPE_STEEP_W  = SLOPE_STEEP | SLOPE_NWS,               ///< a steep slope falling to east (from west)
       
    62 	SLOPE_STEEP_S  = SLOPE_STEEP | SLOPE_WSE,               ///< a steep slope falling to north (from south)
       
    63 	SLOPE_STEEP_E  = SLOPE_STEEP | SLOPE_SEN,               ///< a steep slope falling to west (from east)
       
    64 	SLOPE_STEEP_N  = SLOPE_STEEP | SLOPE_ENW,               ///< a steep slope falling to south (from north)
       
    65 
       
    66 	SLOPE_HALFTILE = 0x20,                                  ///< one halftile is leveled (non continuous slope)
       
    67 	SLOPE_HALFTILE_MASK = 0xE0,                             ///< three bits used for halftile slopes
       
    68 	SLOPE_HALFTILE_W = SLOPE_HALFTILE | (CORNER_W << 6),    ///< the west halftile is leveled (non continuous slope)
       
    69 	SLOPE_HALFTILE_S = SLOPE_HALFTILE | (CORNER_S << 6),    ///< the south halftile is leveled (non continuous slope)
       
    70 	SLOPE_HALFTILE_E = SLOPE_HALFTILE | (CORNER_E << 6),    ///< the east halftile is leveled (non continuous slope)
       
    71 	SLOPE_HALFTILE_N = SLOPE_HALFTILE | (CORNER_N << 6),    ///< the north halftile is leveled (non continuous slope)
       
    72 };
       
    73 
       
    74 
       
    75 /**
       
    76  * Enumeration for Foundations.
       
    77  */
       
    78 enum Foundation {
       
    79 	FOUNDATION_NONE,             ///< The tile has no foundation, the slope remains unchanged.
       
    80 	FOUNDATION_LEVELED,          ///< The tile is leveled up to a flat slope.
       
    81 	FOUNDATION_INCLINED_X,       ///< The tile has an along X-axis inclined foundation.
       
    82 	FOUNDATION_INCLINED_Y,       ///< The tile has an along Y-axis inclined foundation.
       
    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.
       
    84 
       
    85 	/* Halftile foundations */
       
    86 	FOUNDATION_STEEP_BOTH,       ///< The tile has a steep slope. The lowest corner is raised by a foundation and the upper halftile is leveled.
       
    87 	FOUNDATION_HALFTILE_W,       ///< Level west halftile non-continuously.
       
    88 	FOUNDATION_HALFTILE_S,       ///< Level south halftile non-continuously.
       
    89 	FOUNDATION_HALFTILE_E,       ///< Level east halftile non-continuously.
       
    90 	FOUNDATION_HALFTILE_N,       ///< Level north halftile non-continuously.
       
    91 
       
    92 	/* Special anti-zig-zag foundations for single horizontal/vertical track */
       
    93 	FOUNDATION_RAIL_W,           ///< Foundation for TRACK_BIT_LEFT, but not a leveled foundation.
       
    94 	FOUNDATION_RAIL_S,           ///< Foundation for TRACK_BIT_LOWER, but not a leveled foundation.
       
    95 	FOUNDATION_RAIL_E,           ///< Foundation for TRACK_BIT_RIGHT, but not a leveled foundation.
       
    96 	FOUNDATION_RAIL_N,           ///< Foundation for TRACK_BIT_UPPER, but not a leveled foundation.
       
    97 
       
    98 	FOUNDATION_INVALID = 0xFF    ///< Used inside "rail_cmd.cpp" to indicate invalid slope/track combination.
       
    99 };
       
   100 
       
   101 #endif /* SLOPE_TYPE_H */