author | KUDr |
Sat, 21 Apr 2007 08:23:57 +0000 | |
branch | cpp_gui |
changeset 6308 | 646711c5feaa |
parent 6307 | f40e88cff863 |
child 9625 | 3301b1b3889c |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6307 | 3 |
/** @file rail.cpp */ |
4 |
||
1948
e5f34b543a3c
(svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents:
1944
diff
changeset
|
5 |
#include "stdafx.h" |
e5f34b543a3c
(svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents:
1944
diff
changeset
|
6 |
#include "openttd.h" |
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3232
diff
changeset
|
7 |
#include "bridge_map.h" |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
8 |
#include "rail.h" |
3442
c494e7246d7b
(svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents:
3258
diff
changeset
|
9 |
#include "station_map.h" |
3184
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3147
diff
changeset
|
10 |
#include "tunnel_map.h" |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
11 |
|
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
|
12 |
/* XXX: Below 3 tables store duplicate data. Maybe remove some? */ |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
13 |
/* 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
|
14 |
* direction along with the trackdir */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
15 |
extern const byte _signal_along_trackdir[] = { |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
16 |
0x80, 0x80, 0x80, 0x20, 0x40, 0x10, 0, 0, |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
17 |
0x40, 0x40, 0x40, 0x10, 0x80, 0x20 |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
18 |
}; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
19 |
|
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
20 |
/* 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
|
21 |
* direction against the trackdir */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
22 |
extern const byte _signal_against_trackdir[] = { |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
23 |
0x40, 0x40, 0x40, 0x10, 0x80, 0x20, 0, 0, |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
24 |
0x80, 0x80, 0x80, 0x20, 0x40, 0x10 |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
25 |
}; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
26 |
|
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
27 |
/* 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
|
28 |
* be present on the given track */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
29 |
extern const byte _signal_on_track[] = { |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
30 |
0xC0, 0xC0, 0xC0, 0x30, 0xC0, 0x30 |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
31 |
}; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
32 |
|
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
33 |
/* Maps a diagonal direction to the all trackdirs that are connected to any |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
34 |
* track entering in this direction (including those making 90 degree turns) |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
35 |
*/ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
36 |
extern const TrackdirBits _exitdir_reaches_trackdirs[] = { |
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:
2548
diff
changeset
|
37 |
TRACKDIR_BIT_X_NE | TRACKDIR_BIT_LOWER_E | TRACKDIR_BIT_LEFT_N, /* DIAGDIR_NE */ |
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:
2548
diff
changeset
|
38 |
TRACKDIR_BIT_Y_SE | TRACKDIR_BIT_LEFT_S | TRACKDIR_BIT_UPPER_E, /* DIAGDIR_SE */ |
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:
2548
diff
changeset
|
39 |
TRACKDIR_BIT_X_SW | TRACKDIR_BIT_UPPER_W | TRACKDIR_BIT_RIGHT_S, /* DIAGDIR_SW */ |
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:
2548
diff
changeset
|
40 |
TRACKDIR_BIT_Y_NW | TRACKDIR_BIT_RIGHT_N | TRACKDIR_BIT_LOWER_W /* DIAGDIR_NW */ |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
41 |
}; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
42 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
43 |
extern const Trackdir _next_trackdir[] = { |
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:
2548
diff
changeset
|
44 |
TRACKDIR_X_NE, TRACKDIR_Y_SE, TRACKDIR_LOWER_E, TRACKDIR_UPPER_E, TRACKDIR_RIGHT_S, TRACKDIR_LEFT_S, INVALID_TRACKDIR, INVALID_TRACKDIR, |
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:
2548
diff
changeset
|
45 |
TRACKDIR_X_SW, TRACKDIR_Y_NW, TRACKDIR_LOWER_W, TRACKDIR_UPPER_W, TRACKDIR_RIGHT_N, TRACKDIR_LEFT_N |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
46 |
}; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
47 |
|
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
48 |
/* Maps a trackdir to all trackdirs that make 90 deg turns with it. */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
49 |
extern const TrackdirBits _track_crosses_trackdirs[] = { |
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:
2548
diff
changeset
|
50 |
TRACKDIR_BIT_Y_SE | TRACKDIR_BIT_Y_NW, /* TRACK_X */ |
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:
2548
diff
changeset
|
51 |
TRACKDIR_BIT_X_NE | TRACKDIR_BIT_X_SW, /* TRACK_Y */ |
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
|
52 |
TRACKDIR_BIT_RIGHT_N | TRACKDIR_BIT_RIGHT_S | TRACKDIR_BIT_LEFT_N | TRACKDIR_BIT_LEFT_S, /* TRACK_UPPER */ |
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
|
53 |
TRACKDIR_BIT_RIGHT_N | TRACKDIR_BIT_RIGHT_S | TRACKDIR_BIT_LEFT_N | TRACKDIR_BIT_LEFT_S, /* TRACK_LOWER */ |
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
|
54 |
TRACKDIR_BIT_UPPER_W | TRACKDIR_BIT_UPPER_E | TRACKDIR_BIT_LOWER_W | TRACKDIR_BIT_LOWER_E, /* TRACK_LEFT */ |
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
|
55 |
TRACKDIR_BIT_UPPER_W | TRACKDIR_BIT_UPPER_E | TRACKDIR_BIT_LOWER_W | TRACKDIR_BIT_LOWER_E /* TRACK_RIGHT */ |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
56 |
}; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
57 |
|
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
58 |
/* Maps a track to all tracks that make 90 deg turns with it. */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
59 |
extern const TrackBits _track_crosses_tracks[] = { |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3242
diff
changeset
|
60 |
TRACK_BIT_Y, /* TRACK_X */ |
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3242
diff
changeset
|
61 |
TRACK_BIT_X, /* TRACK_Y */ |
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3242
diff
changeset
|
62 |
TRACK_BIT_VERT, /* TRACK_UPPER */ |
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3242
diff
changeset
|
63 |
TRACK_BIT_VERT, /* TRACK_LOWER */ |
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3242
diff
changeset
|
64 |
TRACK_BIT_HORZ, /* TRACK_LEFT */ |
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3242
diff
changeset
|
65 |
TRACK_BIT_HORZ /* TRACK_RIGHT */ |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
66 |
}; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
67 |
|
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
68 |
/* 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
|
69 |
* that trackdir */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
70 |
extern const DiagDirection _trackdir_to_exitdir[] = { |
6308 | 71 |
DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_NE, |
72 |
DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE, |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
73 |
}; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
74 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
75 |
extern const Trackdir _track_exitdir_to_trackdir[][DIAGDIR_END] = { |
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:
2548
diff
changeset
|
76 |
{TRACKDIR_X_NE, INVALID_TRACKDIR, TRACKDIR_X_SW, INVALID_TRACKDIR}, |
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:
2548
diff
changeset
|
77 |
{INVALID_TRACKDIR, TRACKDIR_Y_SE, INVALID_TRACKDIR, TRACKDIR_Y_NW}, |
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
|
78 |
{TRACKDIR_UPPER_E, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_UPPER_W}, |
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
|
79 |
{INVALID_TRACKDIR, TRACKDIR_LOWER_E, TRACKDIR_LOWER_W, INVALID_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
|
80 |
{INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_LEFT_S, TRACKDIR_LEFT_N}, |
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
|
81 |
{TRACKDIR_RIGHT_N, TRACKDIR_RIGHT_S, INVALID_TRACKDIR, INVALID_TRACKDIR} |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
82 |
}; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
83 |
|
6307 | 84 |
extern const Trackdir _track_enterdir_to_trackdir[][DIAGDIR_END] = { |
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:
2548
diff
changeset
|
85 |
{TRACKDIR_X_NE, INVALID_TRACKDIR, TRACKDIR_X_SW, INVALID_TRACKDIR}, |
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:
2548
diff
changeset
|
86 |
{INVALID_TRACKDIR, TRACKDIR_Y_SE, INVALID_TRACKDIR, TRACKDIR_Y_NW}, |
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
|
87 |
{INVALID_TRACKDIR, TRACKDIR_UPPER_E, TRACKDIR_UPPER_W, INVALID_TRACKDIR}, |
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
|
88 |
{TRACKDIR_LOWER_E, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_LOWER_W}, |
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
|
89 |
{TRACKDIR_LEFT_N, TRACKDIR_LEFT_S, INVALID_TRACKDIR, INVALID_TRACKDIR}, |
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
|
90 |
{INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_RIGHT_S, TRACKDIR_RIGHT_N} |
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
|
91 |
}; |
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
|
92 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
93 |
extern const Trackdir _track_direction_to_trackdir[][DIR_END] = { |
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:
2548
diff
changeset
|
94 |
{INVALID_TRACKDIR, TRACKDIR_X_NE, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_X_SW, INVALID_TRACKDIR, INVALID_TRACKDIR}, |
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:
2548
diff
changeset
|
95 |
{INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_Y_SE, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_Y_NW}, |
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
|
96 |
{INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_UPPER_E, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_UPPER_W, INVALID_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
|
97 |
{INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_LOWER_E, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_LOWER_W, INVALID_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
|
98 |
{TRACKDIR_LEFT_N, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_LEFT_S, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_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
|
99 |
{TRACKDIR_RIGHT_N, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_RIGHT_S, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR} |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
100 |
}; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
101 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
102 |
extern const Trackdir _dir_to_diag_trackdir[] = { |
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:
2548
diff
changeset
|
103 |
TRACKDIR_X_NE, TRACKDIR_Y_SE, TRACKDIR_X_SW, TRACKDIR_Y_NW, |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
104 |
}; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
105 |
|
1950
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
106 |
|
6268
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
5838
diff
changeset
|
107 |
RailType GetTileRailType(TileIndex tile) |
1950
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
108 |
{ |
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
109 |
switch (GetTileType(tile)) { |
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
110 |
case MP_RAILWAY: |
3242
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
111 |
return GetRailType(tile); |
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
112 |
|
1950
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
113 |
case MP_STREET: |
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
114 |
/* rail/road crossing */ |
6285
187e3ef04cc9
(svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents:
6268
diff
changeset
|
115 |
if (IsLevelCrossing(tile)) return GetRailType(tile); |
1950
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
116 |
break; |
3242
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
117 |
|
1950
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
118 |
case MP_STATION: |
3442
c494e7246d7b
(svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents:
3258
diff
changeset
|
119 |
if (IsRailwayStationTile(tile)) return GetRailType(tile); |
1950
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
120 |
break; |
3242
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
121 |
|
1950
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
122 |
case MP_TUNNELBRIDGE: |
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3232
diff
changeset
|
123 |
if (IsTunnel(tile)) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
3977
diff
changeset
|
124 |
if (GetTunnelTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile); |
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3232
diff
changeset
|
125 |
} else { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
3977
diff
changeset
|
126 |
if (GetBridgeTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile); |
3184
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3147
diff
changeset
|
127 |
} |
1950
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
128 |
break; |
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3232
diff
changeset
|
129 |
|
1950
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
130 |
default: |
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
131 |
break; |
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
132 |
} |
3242
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
133 |
return INVALID_RAILTYPE; |
1950
6e4d384034d9
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
134 |
} |