rail_map.h
author tron
Wed, 22 Mar 2006 19:04:04 +0000
changeset 3296 34064bbe27a5
parent 3273 3089ecca8e21
child 3355 e414a0b104a6
permissions -rw-r--r--
(svn r4027) Remove another call to FindLandscapeHeightByTile()
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
     1
/* $Id$ */
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
     2
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
     3
#ifndef RAIL_MAP_H
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
     4
#define RAIL_MAP_H
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
     5
3239
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
     6
#include "direction.h"
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
     7
#include "tile.h"
3239
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
     8
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
     9
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    10
typedef enum RailTileType {
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    11
	RAIL_TYPE_NORMAL         = 0x0,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    12
	RAIL_TYPE_SIGNALS        = 0x40,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    13
	RAIL_TYPE_UNUSED         = 0x80, /* XXX: Maybe this could become waypoints? */
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    14
	RAIL_TYPE_DEPOT_WAYPOINT = 0xC0, /* Is really depots and waypoints... */
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    15
	RAIL_TILE_TYPE_MASK      = 0xC0
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    16
} RailTileType;
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    17
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    18
static inline RailTileType GetRailTileType(TileIndex t)
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    19
{
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    20
	assert(IsTileType(t, MP_RAILWAY));
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    21
	return _m[t].m5 & RAIL_TILE_TYPE_MASK;
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    22
}
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    23
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    24
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    25
/** These specify the subtype when the main rail type is
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    26
 * RAIL_TYPE_DEPOT_WAYPOINT */
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    27
typedef enum RailTileSubtypes {
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    28
	RAIL_SUBTYPE_DEPOT    = 0x00,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    29
	RAIL_SUBTYPE_WAYPOINT = 0x04,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    30
	RAIL_SUBTYPE_MASK     = 0x3C
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    31
} RailTileSubtype;
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    32
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    33
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    34
typedef enum RailTypes {
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    35
	RAILTYPE_RAIL   = 0,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    36
	RAILTYPE_MONO   = 1,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    37
	RAILTYPE_MAGLEV = 2,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    38
	RAILTYPE_END,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    39
	INVALID_RAILTYPE = 0xFF
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    40
} RailType;
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    41
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    42
static inline RailType GetRailType(TileIndex t)
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    43
{
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    44
	return (RailType)GB(_m[t].m3, 0, 4);
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    45
}
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    46
3242
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    47
// TODO remove this by moving to the same bits as GetRailType()
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    48
static inline RailType GetRailTypeCrossing(TileIndex t)
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    49
{
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    50
	return (RailType)GB(_m[t].m4, 0, 4);
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    51
}
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    52
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    53
static inline RailType GetRailTypeOnBridge(TileIndex t)
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    54
{
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    55
	return (RailType)GB(_m[t].m3, 4, 4);
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    56
}
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    57
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    58
static inline void SetRailType(TileIndex t, RailType r)
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    59
{
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    60
	SB(_m[t].m3, 0, 4, r);
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    61
}
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    62
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    63
// TODO remove this by moving to the same bits as SetRailType()
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    64
static inline void SetRailTypeCrossing(TileIndex t, RailType r)
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    65
{
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    66
	SB(_m[t].m4, 0, 4, r);
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    67
}
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    68
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    69
static inline void SetRailTypeOnBridge(TileIndex t, RailType r)
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    70
{
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    71
	SB(_m[t].m3, 4, 4, r);
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    72
}
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
    73
3239
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    74
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    75
/** These are used to specify a single track.
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    76
 * Can be translated to a trackbit with TrackToTrackbit */
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    77
typedef enum Track {
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    78
	TRACK_X     = 0,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    79
	TRACK_Y     = 1,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    80
	TRACK_UPPER = 2,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    81
	TRACK_LOWER = 3,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    82
	TRACK_LEFT  = 4,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    83
	TRACK_RIGHT = 5,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    84
	TRACK_END,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    85
	INVALID_TRACK = 0xFF
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    86
} Track;
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    87
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    88
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    89
/** Bitfield corresponding to Track */
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    90
typedef enum TrackBits {
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    91
	TRACK_BIT_X     = 1U << TRACK_X,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    92
	TRACK_BIT_Y     = 1U << TRACK_Y,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    93
	TRACK_BIT_UPPER = 1U << TRACK_UPPER,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    94
	TRACK_BIT_LOWER = 1U << TRACK_LOWER,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    95
	TRACK_BIT_LEFT  = 1U << TRACK_LEFT,
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    96
	TRACK_BIT_RIGHT = 1U << TRACK_RIGHT,
3258
1c079364726d (svn r3946) Add short hand names for common track combinations
tron
parents: 3242
diff changeset
    97
	TRACK_BIT_CROSS = TRACK_BIT_X     | TRACK_BIT_Y,
1c079364726d (svn r3946) Add short hand names for common track combinations
tron
parents: 3242
diff changeset
    98
	TRACK_BIT_HORZ  = TRACK_BIT_UPPER | TRACK_BIT_LOWER,
1c079364726d (svn r3946) Add short hand names for common track combinations
tron
parents: 3242
diff changeset
    99
	TRACK_BIT_VERT  = TRACK_BIT_LEFT  | TRACK_BIT_RIGHT,
1c079364726d (svn r3946) Add short hand names for common track combinations
tron
parents: 3242
diff changeset
   100
	TRACK_BIT_3WAY_NE = TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT,
1c079364726d (svn r3946) Add short hand names for common track combinations
tron
parents: 3242
diff changeset
   101
	TRACK_BIT_3WAY_SE = TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT,
1c079364726d (svn r3946) Add short hand names for common track combinations
tron
parents: 3242
diff changeset
   102
	TRACK_BIT_3WAY_SW = TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_LEFT,
1c079364726d (svn r3946) Add short hand names for common track combinations
tron
parents: 3242
diff changeset
   103
	TRACK_BIT_3WAY_NW = TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_LEFT,
1c079364726d (svn r3946) Add short hand names for common track combinations
tron
parents: 3242
diff changeset
   104
	TRACK_BIT_ALL   = TRACK_BIT_CROSS | TRACK_BIT_HORZ | TRACK_BIT_VERT,
3239
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
   105
	TRACK_BIT_MASK  = 0x3FU
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
   106
} TrackBits;
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   107
3267
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3258
diff changeset
   108
static inline TrackBits GetTrackBits(TileIndex tile)
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3258
diff changeset
   109
{
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3258
diff changeset
   110
	return (TrackBits)GB(_m[tile].m5, 0, 6);
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3258
diff changeset
   111
}
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3258
diff changeset
   112
3273
3089ecca8e21 (svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents: 3267
diff changeset
   113
static inline void SetTrackBits(TileIndex t, TrackBits b)
3089ecca8e21 (svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents: 3267
diff changeset
   114
{
3089ecca8e21 (svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents: 3267
diff changeset
   115
	SB(_m[t].m5, 0, 6, b);
3089ecca8e21 (svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents: 3267
diff changeset
   116
}
3089ecca8e21 (svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents: 3267
diff changeset
   117
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   118
3185
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
   119
static inline DiagDirection GetRailDepotDirection(TileIndex t)
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
   120
{
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
   121
	return (DiagDirection)GB(_m[t].m5, 0, 2);
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
   122
}
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
   123
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
   124
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   125
static inline TrackBits GetRailWaypointBits(TileIndex t)
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   126
{
3239
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
   127
	return _m[t].m5 & 1 ? TRACK_BIT_Y : TRACK_BIT_X;
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   128
}
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   129
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   130
3238
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   131
typedef enum SignalType {
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   132
	SIGTYPE_NORMAL  = 0, // normal signal
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   133
	SIGTYPE_ENTRY   = 1, // presignal block entry
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   134
	SIGTYPE_EXIT    = 2, // presignal block exit
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   135
	SIGTYPE_COMBO   = 3  // presignal inter-block
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   136
} SignalType;
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   137
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   138
static inline SignalType GetSignalType(TileIndex t)
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   139
{
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   140
	assert(GetRailTileType(t) == RAIL_TYPE_SIGNALS);
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   141
	return (SignalType)GB(_m[t].m4, 0, 2);
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   142
}
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   143
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   144
static inline void SetSignalType(TileIndex t, SignalType s)
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   145
{
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   146
	assert(GetRailTileType(t) == RAIL_TYPE_SIGNALS);
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   147
	SB(_m[t].m4, 0, 2, s);
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   148
}
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   149
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   150
3237
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   151
typedef enum SignalVariant {
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   152
	SIG_ELECTRIC  = 0,
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   153
	SIG_SEMAPHORE = 1
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   154
} SignalVariant;
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   155
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   156
static inline SignalVariant GetSignalVariant(TileIndex t)
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   157
{
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   158
	return (SignalVariant)GB(_m[t].m4, 2, 1);
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   159
}
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   160
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   161
static inline void SetSignalVariant(TileIndex t, SignalVariant v)
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   162
{
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   163
	SB(_m[t].m4, 2, 1, v);
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   164
}
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   165
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   166
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   167
static inline void MakeRailNormal(TileIndex t, Owner o, TrackBits b, RailType r)
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   168
{
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   169
	SetTileType(t, MP_RAILWAY);
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   170
	SetTileOwner(t, o);
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   171
	_m[t].m2 = 0;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   172
	_m[t].m3 = r;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   173
	_m[t].m4 = 0;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   174
	_m[t].m5 = RAIL_TYPE_NORMAL | b;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   175
}
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   176
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   177
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   178
static inline void MakeRailDepot(TileIndex t, Owner o, DiagDirection d, RailType r)
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   179
{
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   180
	SetTileType(t, MP_RAILWAY);
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   181
	SetTileOwner(t, o);
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   182
	_m[t].m2 = 0;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   183
	_m[t].m3 = r;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   184
	_m[t].m4 = 0;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   185
	_m[t].m5 = RAIL_TYPE_DEPOT_WAYPOINT | RAIL_SUBTYPE_DEPOT | d;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   186
}
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   187
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   188
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   189
static inline void MakeRailWaypoint(TileIndex t, Owner o, Axis a, RailType r, uint index)
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   190
{
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   191
	SetTileType(t, MP_RAILWAY);
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   192
	SetTileOwner(t, o);
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   193
	_m[t].m2 = index;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   194
	_m[t].m3 = r;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   195
	_m[t].m4 = 0;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   196
	_m[t].m5 = RAIL_TYPE_DEPOT_WAYPOINT | RAIL_SUBTYPE_WAYPOINT | a;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   197
}
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   198
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   199
#endif