rail.h
author celestar
Fri, 29 Dec 2006 10:13:35 +0000
branchcustombridgeheads
changeset 5592 fd60d4ecc921
parent 5116 2a33a74925c5
child 5598 166345600ba9
permissions -rw-r--r--
(svn r7608) [cbh] - Merge with trunk r7593:7607 because I need 7607 here
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2049
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2049
diff changeset
     2
2232
0c63dce21e30 (svn r2752) -Doc: Added some doxygen stuff to rail.h. I'm gonna mess around with this file and wanted to get rid of this first
celestar
parents: 2186
diff changeset
     3
/** @file rail.h */
0c63dce21e30 (svn r2752) -Doc: Added some doxygen stuff to rail.h. I'm gonna mess around with this file and wanted to get rid of this first
celestar
parents: 2186
diff changeset
     4
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
     5
#ifndef RAIL_H
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
     6
#define RAIL_H
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
     7
3147
0a09ce6d651a (svn r3767) Move all direction related enums and functions to a separate header
tron
parents: 3132
diff changeset
     8
#include "direction.h"
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
     9
#include "tile.h"
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    10
4041
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    11
typedef enum RailTypes {
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    12
	RAILTYPE_RAIL     = 0,
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    13
	RAILTYPE_ELECTRIC = 1,
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    14
	RAILTYPE_MONO     = 2,
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    15
	RAILTYPE_MAGLEV   = 3,
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    16
	RAILTYPE_END,
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    17
	INVALID_RAILTYPE  = 0xFF
4041
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    18
} RailType;
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    19
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    20
typedef byte RailTypeMask;
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    21
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    22
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    23
/** These are used to specify a single track.
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    24
 * Can be translated to a trackbit with TrackToTrackbit */
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    25
typedef enum Track {
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    26
	TRACK_X     = 0,
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    27
	TRACK_Y     = 1,
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    28
	TRACK_UPPER = 2,
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    29
	TRACK_LOWER = 3,
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    30
	TRACK_LEFT  = 4,
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    31
	TRACK_RIGHT = 5,
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    32
	TRACK_END,
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    33
	INVALID_TRACK = 0xFF
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    34
} Track;
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    35
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    36
4158
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    37
/** Convert an Axis to the corresponding Track
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    38
 * AXIS_X -> TRACK_X
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    39
 * AXIS_Y -> TRACK_Y
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    40
 * Uses the fact that they share the same internal encoding
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    41
 */
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    42
static inline Track AxisToTrack(Axis a)
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    43
{
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    44
	return (Track)a;
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    45
}
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    46
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    47
4041
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    48
/** Bitfield corresponding to Track */
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    49
typedef enum TrackBits {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    50
	TRACK_BIT_NONE    = 0U,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    51
	TRACK_BIT_X       = 1U << TRACK_X,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    52
	TRACK_BIT_Y       = 1U << TRACK_Y,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    53
	TRACK_BIT_UPPER   = 1U << TRACK_UPPER,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    54
	TRACK_BIT_LOWER   = 1U << TRACK_LOWER,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    55
	TRACK_BIT_LEFT    = 1U << TRACK_LEFT,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    56
	TRACK_BIT_RIGHT   = 1U << TRACK_RIGHT,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    57
	TRACK_BIT_CROSS   = TRACK_BIT_X     | TRACK_BIT_Y,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    58
	TRACK_BIT_HORZ    = TRACK_BIT_UPPER | TRACK_BIT_LOWER,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    59
	TRACK_BIT_VERT    = TRACK_BIT_LEFT  | TRACK_BIT_RIGHT,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    60
	TRACK_BIT_3WAY_NE = TRACK_BIT_X     | TRACK_BIT_UPPER | TRACK_BIT_RIGHT,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    61
	TRACK_BIT_3WAY_SE = TRACK_BIT_Y     | TRACK_BIT_LOWER | TRACK_BIT_RIGHT,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    62
	TRACK_BIT_3WAY_SW = TRACK_BIT_X     | TRACK_BIT_LOWER | TRACK_BIT_LEFT,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    63
	TRACK_BIT_3WAY_NW = TRACK_BIT_Y     | TRACK_BIT_UPPER | TRACK_BIT_LEFT,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    64
	TRACK_BIT_ALL     = TRACK_BIT_CROSS | TRACK_BIT_HORZ  | TRACK_BIT_VERT,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    65
	TRACK_BIT_MASK    = 0x3FU
4041
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    66
} TrackBits;
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    67
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
    68
4158
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    69
/**
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    70
 * Maps a Track to the corresponding TrackBits value
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    71
 */
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    72
static inline TrackBits TrackToTrackBits(Track track)
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    73
{
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    74
	return (TrackBits)(1 << track);
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    75
}
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    76
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    77
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    78
static inline TrackBits AxisToTrackBits(Axis a)
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    79
{
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    80
	return TrackToTrackBits(AxisToTrack(a));
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    81
}
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    82
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
    83
2232
0c63dce21e30 (svn r2752) -Doc: Added some doxygen stuff to rail.h. I'm gonna mess around with this file and wanted to get rid of this first
celestar
parents: 2186
diff changeset
    84
/** These are a combination of tracks and directions. Values are 0-5 in one
4549
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4434
diff changeset
    85
 * direction (corresponding to the Track enum) and 8-13 in the other direction. */
1944
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
    86
typedef enum Trackdirs {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    87
	TRACKDIR_X_NE     =  0,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    88
	TRACKDIR_Y_SE     =  1,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    89
	TRACKDIR_UPPER_E  =  2,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    90
	TRACKDIR_LOWER_E  =  3,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    91
	TRACKDIR_LEFT_S   =  4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    92
	TRACKDIR_RIGHT_S  =  5,
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
    93
	/* Note the two missing values here. This enables trackdir -> track
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
    94
	 * conversion by doing (trackdir & 7) */
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    95
	TRACKDIR_X_SW     =  8,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
    96
	TRACKDIR_Y_NW     =  9,
2548
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2536
diff changeset
    97
	TRACKDIR_UPPER_W  = 10,
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2536
diff changeset
    98
	TRACKDIR_LOWER_W  = 11,
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2536
diff changeset
    99
	TRACKDIR_LEFT_N   = 12,
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2536
diff changeset
   100
	TRACKDIR_RIGHT_N  = 13,
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2536
diff changeset
   101
	TRACKDIR_END,
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2536
diff changeset
   102
	INVALID_TRACKDIR  = 0xFF,
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   103
} Trackdir;
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   104
2232
0c63dce21e30 (svn r2752) -Doc: Added some doxygen stuff to rail.h. I'm gonna mess around with this file and wanted to get rid of this first
celestar
parents: 2186
diff changeset
   105
/** These are a combination of tracks and directions. Values are 0-5 in one
4549
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4434
diff changeset
   106
 * direction (corresponding to the Track enum) and 8-13 in the other direction. */
1944
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   107
typedef enum TrackdirBits {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
   108
	TRACKDIR_BIT_NONE     = 0x0000,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
   109
	TRACKDIR_BIT_X_NE     = 0x0001,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
   110
	TRACKDIR_BIT_Y_SE     = 0x0002,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
   111
	TRACKDIR_BIT_UPPER_E  = 0x0004,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
   112
	TRACKDIR_BIT_LOWER_E  = 0x0008,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
   113
	TRACKDIR_BIT_LEFT_S   = 0x0010,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
   114
	TRACKDIR_BIT_RIGHT_S  = 0x0020,
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   115
	/* Again, note the two missing values here. This enables trackdir -> track conversion by doing (trackdir & 0xFF) */
3102
fde95020fc8e (svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents: 2989
diff changeset
   116
	TRACKDIR_BIT_X_SW     = 0x0100,
fde95020fc8e (svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents: 2989
diff changeset
   117
	TRACKDIR_BIT_Y_NW     = 0x0200,
2548
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2536
diff changeset
   118
	TRACKDIR_BIT_UPPER_W  = 0x0400,
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2536
diff changeset
   119
	TRACKDIR_BIT_LOWER_W  = 0x0800,
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2536
diff changeset
   120
	TRACKDIR_BIT_LEFT_N   = 0x1000,
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2536
diff changeset
   121
	TRACKDIR_BIT_RIGHT_N  = 0x2000,
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4344
diff changeset
   122
	TRACKDIR_BIT_MASK     = 0x3F3F,
2548
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2536
diff changeset
   123
	INVALID_TRACKDIR_BIT  = 0xFFFF,
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   124
} TrackdirBits;
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   125
2233
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   126
/** This struct contains all the info that is needed to draw and construct tracks.
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   127
 */
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   128
typedef struct RailtypeInfo {
2274
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   129
	/** Struct containing the main sprites. @note not all sprites are listed, but only
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   130
	 *  the ones used directly in the code */
2233
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   131
	struct {
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   132
		SpriteID track_y;      ///< single piece of rail in Y direction, with ground
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   133
		SpriteID track_ns;     ///< two pieces of rail in North and South corner (East-West direction)
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   134
		SpriteID ground;       ///< ground sprite for a 3-way switch
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   135
		SpriteID single_y;     ///< single piece of rail in Y direction, without ground
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   136
		SpriteID single_x;     ///< single piece of rail in X direction
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   137
		SpriteID single_n;     ///< single piece of rail in the northern corner
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   138
		SpriteID single_s;     ///< single piece of rail in the southern corner
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   139
		SpriteID single_e;     ///< single piece of rail in the eastern corner
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   140
		SpriteID single_w;     ///< single piece of rail in the western corner
2511
0a81d9ca79bc (svn r3037) Don't deduce the sprites for tunnels and level crossings from magic numbers, but fetch them from the central rail info array. This is a preparation step for electrified rails
tron
parents: 2472
diff changeset
   141
		SpriteID crossing;     ///< level crossing, rail in X direction
0a81d9ca79bc (svn r3037) Don't deduce the sprites for tunnels and level crossings from magic numbers, but fetch them from the central rail info array. This is a preparation step for electrified rails
tron
parents: 2472
diff changeset
   142
		SpriteID tunnel;       ///< tunnel sprites base
2233
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   143
	} base_sprites;
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   144
2274
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   145
	/** struct containing the sprites for the rail GUI. @note only sprites referred to
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   146
	 * directly in the code are listed */
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   147
	struct {
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   148
		SpriteID build_ns_rail;      ///< button for building single rail in N-S direction
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   149
		SpriteID build_x_rail;       ///< button for building single rail in X direction
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   150
		SpriteID build_ew_rail;      ///< button for building single rail in E-W direction
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   151
		SpriteID build_y_rail;       ///< button for building single rail in Y direction
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   152
		SpriteID auto_rail;          ///< button for the autorail construction
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   153
		SpriteID build_depot;        ///< button for building depots
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   154
		SpriteID build_tunnel;       ///< button for building a tunnel
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   155
		SpriteID convert_rail;       ///< button for converting rail
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   156
	} gui_sprites;
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   157
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   158
	struct {
2514
8887b1f005c7 (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
   159
		CursorID rail_ns;
8887b1f005c7 (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
   160
		CursorID rail_swne;
8887b1f005c7 (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
   161
		CursorID rail_ew;
8887b1f005c7 (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
   162
		CursorID rail_nwse;
8887b1f005c7 (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
   163
		CursorID autorail;
8887b1f005c7 (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
   164
		CursorID depot;
8887b1f005c7 (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
   165
		CursorID tunnel;
8887b1f005c7 (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
   166
		CursorID convert;
8887b1f005c7 (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
   167
	} cursor;
8887b1f005c7 (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
   168
8887b1f005c7 (svn r3040) Don't deduce the cursor sprites when building rails from magic numbers, but fetch them from the central rail info array.
tron
parents: 2511
diff changeset
   169
	struct {
2274
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   170
		StringID toolbar_caption;
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   171
	} strings;
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
   172
2233
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   173
	/** sprite number difference between a piece of track on a snowy ground and the corresponding one on normal ground */
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   174
	SpriteID snow_offset;
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   175
3355
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   176
	/** bitmask to the OTHER railtypes on which an engine of THIS railtype generates power */
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   177
	RailTypeMask powered_railtypes;
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   178
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   179
	/** bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel */
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   180
	RailTypeMask compatible_railtypes;
2254
72f8883ff3ac (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
   181
72f8883ff3ac (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
   182
	/**
72f8883ff3ac (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
   183
	 * Offset between the current railtype and normal rail. This means that:<p>
72f8883ff3ac (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
   184
	 * 1) All the sprites in a railset MUST be in the same order. This order
72f8883ff3ac (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
   185
	 *    is determined by normal rail. Check sprites 1005 and following for this order<p>
72f8883ff3ac (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
   186
	 * 2) The position where the railtype is loaded must always be the same, otherwise
72f8883ff3ac (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
   187
	 *    the offset will fail.<p>
72f8883ff3ac (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
   188
	 * @note: Something more flexible might be desirable in the future.
72f8883ff3ac (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
   189
	 */
72f8883ff3ac (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
   190
	SpriteID total_offset;
2536
8c4e298f4886 (svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents: 2520
diff changeset
   191
8c4e298f4886 (svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents: 2520
diff changeset
   192
	/**
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   193
	 * Bridge offset
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   194
	 */
2536
8c4e298f4886 (svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents: 2520
diff changeset
   195
	SpriteID bridge_offset;
3503
425903b204fa (svn r4354) [Elrail][NewGRF] Codechange: Drawing of custom waypoints with custom ground sprites used the index of the rail type as an offset. With the introduction of elrails this offset is incorrect, so instead there is now a lookup table within the RailTypeInfo struct to explicitly list the offset.
peter1138
parents: 3500
diff changeset
   196
425903b204fa (svn r4354) [Elrail][NewGRF] Codechange: Drawing of custom waypoints with custom ground sprites used the index of the rail type as an offset. With the introduction of elrails this offset is incorrect, so instead there is now a lookup table within the RailTypeInfo struct to explicitly list the offset.
peter1138
parents: 3500
diff changeset
   197
	/**
425903b204fa (svn r4354) [Elrail][NewGRF] Codechange: Drawing of custom waypoints with custom ground sprites used the index of the rail type as an offset. With the introduction of elrails this offset is incorrect, so instead there is now a lookup table within the RailTypeInfo struct to explicitly list the offset.
peter1138
parents: 3500
diff changeset
   198
	 * Offset to add to ground sprite when drawing custom waypoints / stations
425903b204fa (svn r4354) [Elrail][NewGRF] Codechange: Drawing of custom waypoints with custom ground sprites used the index of the rail type as an offset. With the introduction of elrails this offset is incorrect, so instead there is now a lookup table within the RailTypeInfo struct to explicitly list the offset.
peter1138
parents: 3500
diff changeset
   199
	 */
425903b204fa (svn r4354) [Elrail][NewGRF] Codechange: Drawing of custom waypoints with custom ground sprites used the index of the rail type as an offset. With the introduction of elrails this offset is incorrect, so instead there is now a lookup table within the RailTypeInfo struct to explicitly list the offset.
peter1138
parents: 3500
diff changeset
   200
	byte custom_ground_offset;
2233
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   201
} RailtypeInfo;
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   202
3890
f8f13a91446a (svn r4946) "Feature": Add a cheat that allows running electric engines on normal rail
celestar
parents: 3792
diff changeset
   203
extern RailtypeInfo _railtypes[RAILTYPE_END];
2233
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   204
2008
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   205
// these are the maximums used for updating signal blocks, and checking if a depot is in a pbs block
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   206
enum {
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   207
	NUM_SSD_ENTRY = 256, // max amount of blocks
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4281
diff changeset
   208
	NUM_SSD_STACK =  32, // max amount of blocks to check recursively
2008
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   209
};
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   210
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   211
/**
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   212
 * Maps a Trackdir to the corresponding TrackdirBits value
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   213
 */
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   214
static inline TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir) { return (TrackdirBits)(1 << trackdir); }
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   215
2232
0c63dce21e30 (svn r2752) -Doc: Added some doxygen stuff to rail.h. I'm gonna mess around with this file and wanted to get rid of this first
celestar
parents: 2186
diff changeset
   216
/**
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   217
 * These functions check the validity of Tracks and Trackdirs. assert against
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   218
 * them when convenient.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   219
 */
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   220
static inline bool IsValidTrack(Track track) { return track < TRACK_END; }
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   221
static inline bool IsValidTrackdir(Trackdir trackdir) { return (TrackdirToTrackdirBits(trackdir) & TRACKDIR_BIT_MASK) != 0; }
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   222
2232
0c63dce21e30 (svn r2752) -Doc: Added some doxygen stuff to rail.h. I'm gonna mess around with this file and wanted to get rid of this first
celestar
parents: 2186
diff changeset
   223
/**
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   224
 * Functions to map tracks to the corresponding bits in the signal
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   225
 * presence/status bytes in the map. You should not use these directly, but
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   226
 * wrapper functions below instead. XXX: Which are these?
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   227
 */
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   228
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   229
/**
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   230
 * Maps a trackdir to the bit that stores its status in the map arrays, in the
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   231
 * direction along with the trackdir.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   232
 */
1947
9ee32f167208 (svn r2453) * CodeChange: Declared the lookup arrays in rail.h as extern, so the linker will complain if they are not defined (ie when rail.c is not included).
matthijs
parents: 1944
diff changeset
   233
extern const byte _signal_along_trackdir[TRACKDIR_END];
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   234
static inline byte SignalAlongTrackdir(Trackdir trackdir) {return _signal_along_trackdir[trackdir];}
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   235
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   236
/**
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   237
 * Maps a trackdir to the bit that stores its status in the map arrays, in the
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   238
 * direction against the trackdir.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   239
 */
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   240
static inline byte SignalAgainstTrackdir(Trackdir trackdir) {
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   241
	extern const byte _signal_against_trackdir[TRACKDIR_END];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   242
	return _signal_against_trackdir[trackdir];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   243
}
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   244
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   245
/**
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   246
 * Maps a Track to the bits that store the status of the two signals that can
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   247
 * be present on the given track.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   248
 */
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   249
static inline byte SignalOnTrack(Track track) {
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   250
	extern const byte _signal_on_track[TRACK_END];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   251
	return _signal_on_track[track];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   252
}
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   253
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   254
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   255
/*
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   256
 * Functions describing logical relations between Tracks, TrackBits, Trackdirs
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   257
 * TrackdirBits, Direction and DiagDirections.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   258
 *
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   259
 * TODO: Add #unndefs or something similar to remove the arrays used below
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   260
 * from the global scope and expose direct uses of them.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   261
 */
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   262
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   263
/**
1944
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   264
 * Maps a trackdir to the reverse trackdir.
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   265
 */
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   266
static inline Trackdir ReverseTrackdir(Trackdir trackdir) {
3500
70b8e368e43c (svn r4351) Simplify ReverseTrackdir() to use a simple arithmetic operation instead of a table lookup
tron
parents: 3498
diff changeset
   267
	return (Trackdir)(trackdir ^ 8);
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   268
}
1944
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   269
2782
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   270
/**
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   271
 * Returns the Track that a given Trackdir represents
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   272
 */
1944
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   273
static inline Track TrackdirToTrack(Trackdir trackdir) { return (Track)(trackdir & 0x7); }
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   274
2782
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   275
/**
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   276
 * Returns a Trackdir for the given Track. Since every Track corresponds to
1944
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   277
 * two Trackdirs, we choose the one which points between NE and S.
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   278
 * Note that the actual implementation is quite futile, but this might change
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   279
 * in the future.
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   280
 */
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   281
static inline Trackdir TrackToTrackdir(Track track) { return (Trackdir)track; }
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   282
2782
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   283
/**
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   284
 * Returns a TrackdirBit mask that contains the two TrackdirBits that
1944
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   285
 * correspond with the given Track (one for each direction).
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   286
 */
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   287
static inline TrackdirBits TrackToTrackdirBits(Track track)
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   288
{
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   289
	Trackdir td = TrackToTrackdir(track);
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   290
	return (TrackdirBits)(TrackdirToTrackdirBits(td) | TrackdirToTrackdirBits(ReverseTrackdir(td)));
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   291
}
1944
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   292
012fa5e69118 (svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents: 1942
diff changeset
   293
/**
2782
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   294
 * Discards all directional information from the given TrackdirBits. Any
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   295
 * Track which is present in either direction will be present in the result.
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   296
 */
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   297
static inline TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   298
{
4281
55f66f81239d (svn r5911) -Fix [FS#215]: Discard upper bits of TrackdirBitsToTrackBits result.
matthijs
parents: 4158
diff changeset
   299
	return (TrackBits)((bits | (bits >> 8)) & TRACK_BIT_MASK);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   300
}
2782
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   301
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   302
/**
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   303
 * Maps a trackdir to the trackdir that you will end up on if you go straight
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   304
 * ahead. This will be the same trackdir for diagonal trackdirs, but a
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   305
 * different (alternating) one for straight trackdirs
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   306
 */
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   307
static inline Trackdir NextTrackdir(Trackdir trackdir)
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   308
{
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   309
	extern const Trackdir _next_trackdir[TRACKDIR_END];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   310
	return _next_trackdir[trackdir];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   311
}
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   312
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   313
/**
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   314
 * Maps a track to all tracks that make 90 deg turns with it.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   315
 */
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   316
static inline TrackBits TrackCrossesTracks(Track track)
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   317
{
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   318
	extern const TrackBits _track_crosses_tracks[TRACK_END];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   319
	return _track_crosses_tracks[track];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   320
}
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   321
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   322
/**
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   323
 * Maps a trackdir to the (4-way) direction the tile is exited when following
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   324
 * that trackdir.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   325
 */
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   326
static inline DiagDirection TrackdirToExitdir(Trackdir trackdir)
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   327
{
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   328
	extern const DiagDirection _trackdir_to_exitdir[TRACKDIR_END];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   329
	return _trackdir_to_exitdir[trackdir];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   330
}
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   331
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   332
/**
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   333
 * Maps a track and an (4-way) dir to the trackdir that represents the track
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   334
 * with the exit in the given direction.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   335
 */
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   336
static inline Trackdir TrackExitdirToTrackdir(Track track, DiagDirection diagdir)
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   337
{
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   338
	extern const Trackdir _track_exitdir_to_trackdir[TRACK_END][DIAGDIR_END];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   339
	return _track_exitdir_to_trackdir[track][diagdir];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   340
}
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   341
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   342
/**
2008
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   343
 * Maps a track and an (4-way) dir to the trackdir that represents the track
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   344
 * with the exit in the given direction.
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   345
 */
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   346
static inline Trackdir TrackEnterdirToTrackdir(Track track, DiagDirection diagdir)
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   347
{
2008
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   348
	extern const Trackdir _track_enterdir_to_trackdir[TRACK_END][DIAGDIR_END];
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   349
	return _track_enterdir_to_trackdir[track][diagdir];
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   350
}
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   351
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   352
/**
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   353
 * Maps a track and a full (8-way) direction to the trackdir that represents
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   354
 * the track running in the given direction.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   355
 */
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   356
static inline Trackdir TrackDirectionToTrackdir(Track track, Direction dir)
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   357
{
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   358
	extern const Trackdir _track_direction_to_trackdir[TRACK_END][DIR_END];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   359
	return _track_direction_to_trackdir[track][dir];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   360
}
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   361
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   362
/**
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   363
 * Maps a (4-way) direction to the diagonal trackdir that runs in that
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   364
 * direction.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   365
 */
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   366
static inline Trackdir DiagdirToDiagTrackdir(DiagDirection diagdir)
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   367
{
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   368
	extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   369
	return _dir_to_diag_trackdir[diagdir];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   370
}
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   371
2782
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   372
extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END];
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   373
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   374
/**
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   375
 * Returns all trackdirs that can be reached when entering a tile from a given
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   376
 * (diagonal) direction. This will obviously include 90 degree turns, since no
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   377
 * information is available about the exact angle of entering */
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   378
static inline TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir) { return _exitdir_reaches_trackdirs[diagdir]; }
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   379
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   380
/**
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   381
 * Returns all tracks that can be reached when entering a tile from a given
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   382
 * (diagonal) direction. This will obviously include 90 degree turns, since no
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   383
 * information is available about the exact angle of entering */
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   384
static inline TrackBits DiagdirReachesTracks(DiagDirection diagdir) { return TrackdirBitsToTrackBits(DiagdirReachesTrackdirs(diagdir)); }
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   385
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   386
/**
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   387
 * Maps a trackdir to the trackdirs that can be reached from it (ie, when
2782
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   388
 * entering the next tile. This will include 90 degree turns!
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   389
 */
2782
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   390
static inline TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir) { return _exitdir_reaches_trackdirs[TrackdirToExitdir(trackdir)]; }
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   391
/* Note that there is no direct table for this function (there used to be),
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   392
 * but it uses two simpeler tables to achieve the result */
2782
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   393
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   394
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   395
/**
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   396
 * Maps a trackdir to all trackdirs that make 90 deg turns with it.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   397
 */
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   398
static inline TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir) {
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   399
	extern const TrackdirBits _track_crosses_trackdirs[TRACKDIR_END];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   400
	return _track_crosses_trackdirs[TrackdirToTrack(trackdir)];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
   401
}
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   402
2008
c9d6585c96c8 (svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents: 2006
diff changeset
   403
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   404
/* Checks if a given Track is diagonal */
3102
fde95020fc8e (svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents: 2989
diff changeset
   405
static inline bool IsDiagonalTrack(Track track) { return (track == TRACK_X) || (track == TRACK_Y); }
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   406
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   407
/* Checks if a given Trackdir is diagonal. */
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   408
static inline bool IsDiagonalTrackdir(Trackdir trackdir) { return IsDiagonalTrack(TrackdirToTrack(trackdir)); }
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
   409
1967
c57192f4c121 (svn r2473) - Add: VehicleMayEnterTile(), which checks if the tile owner of a tile is correct for a vehicle to enter it. Based upon glx's code.
matthijs
parents: 1950
diff changeset
   410
c57192f4c121 (svn r2473) - Add: VehicleMayEnterTile(), which checks if the tile owner of a tile is correct for a vehicle to enter it. Based upon glx's code.
matthijs
parents: 1950
diff changeset
   411
/**
2233
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   412
 * Returns a pointer to the Railtype information for a given railtype
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   413
 * @param railtype the rail type which the information is requested for
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   414
 * @return The pointer to the RailtypeInfo
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   415
 */
2236
55f4d7353f52 (svn r2756) Renamed railtypes into _railtypes
ludde
parents: 2233
diff changeset
   416
static inline const RailtypeInfo *GetRailTypeInfo(RailType railtype)
2233
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   417
{
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   418
	assert(railtype < RAILTYPE_END);
2236
55f4d7353f52 (svn r2756) Renamed railtypes into _railtypes
ludde
parents: 2233
diff changeset
   419
	return &_railtypes[railtype];
2233
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   420
}
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   421
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   422
/**
2006
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   423
 * Checks if an engine of the given RailType can drive on a tile with a given
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   424
 * RailType. This would normally just be an equality check, but for electric
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   425
 * rails (which also support non-electric engines).
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   426
 * @return Whether the engine can drive on this tile.
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   427
 * @param  enginetype The RailType of the engine we are considering.
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   428
 * @param  tiletype   The RailType of the tile we are considering.
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   429
 */
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   430
static inline bool IsCompatibleRail(RailType enginetype, RailType tiletype)
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   431
{
2233
146e2e405ec1 (svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents: 2232
diff changeset
   432
	return HASBIT(GetRailTypeInfo(enginetype)->compatible_railtypes, tiletype);
2006
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   433
}
324916f22a8a (svn r2514) - Codechange: [NPF] Move the checking of railtype into a funciton IsCompatibleRail().
matthijs
parents: 2001
diff changeset
   434
3355
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   435
static inline bool HasPowerOnRail(RailType enginetype, RailType tiletype)
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   436
{
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   437
	return HASBIT(GetRailTypeInfo(enginetype)->powered_railtypes, tiletype);
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   438
}
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   439
2782
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   440
/**
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   441
 * Checks if the given tracks overlap, ie form a crossing. Basically this
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   442
 * means when there is more than one track on the tile, exept when there are
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   443
 * two parallel tracks.
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   444
 * @param  bits The tracks present.
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   445
 * @return Whether the tracks present overlap in any way.
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   446
 */
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   447
static inline bool TracksOverlap(TrackBits bits)
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   448
{
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   449
	/* With no, or only one track, there is no overlap */
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   450
	if (bits == 0 || KILL_FIRST_BIT(bits) == 0) return false;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   451
	/* We know that there are at least two tracks present. When there are more
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   452
	 * than 2 tracks, they will surely overlap. When there are two, they will
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4041
diff changeset
   453
	 * always overlap unless they are lower & upper or right & left. */
3258
94a915e7485f (svn r3946) Add short hand names for common track combinations
tron
parents: 3253
diff changeset
   454
	return bits != TRACK_BIT_HORZ && bits != TRACK_BIT_VERT;
2782
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   455
}
b8453c2cb0ed (svn r3329) - Doc: Some documentation cleanups.
matthijs
parents: 2548
diff changeset
   456
2520
75eb66d6e371 (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2514
diff changeset
   457
void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
75eb66d6e371 (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2514
diff changeset
   458
void DrawDefaultWaypointSprite(int x, int y, RailType railtype);
3355
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   459
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   460
/**
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   461
 * Draws overhead wires and pylons for electric railways.
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   462
 * @param ti The TileInfo struct of the tile being drawn
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   463
 * @see DrawCatenaryRailway
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   464
 */
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   465
void DrawCatenary(const TileInfo *ti);
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3267
diff changeset
   466
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3575
diff changeset
   467
uint GetRailFoundation(Slope tileh, TrackBits bits);
5116
2a33a74925c5 (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 4549
diff changeset
   468
2a33a74925c5 (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 4549
diff changeset
   469
int32 SettingsDisableElrail(int32 p1); ///< _patches.disable_elrail callback
2a33a74925c5 (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 4549
diff changeset
   470
2536
8c4e298f4886 (svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents: 2520
diff changeset
   471
#endif /* RAIL_H */