author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9413 | 7042a8ec3fa8 |
child 10002 | 87148ad75853 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
9070
diff
changeset
|
3 |
/** @file rail.cpp Implementation of rail specific functions. */ |
6393
e1e4939d19b5
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents:
6172
diff
changeset
|
4 |
|
1948
d95a69e8c560
(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" |
d95a69e8c560
(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
a2791a480b71
(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
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
8 |
#include "rail.h" |
3442
41d828e2d5ab
(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
118a520164e4
(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" |
8083
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
7730
diff
changeset
|
11 |
#include "tunnelbridge_map.h" |
8236
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
12 |
#include "settings_type.h" |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
13 |
#include "date_func.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8237
diff
changeset
|
14 |
#include "player_func.h" |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8237
diff
changeset
|
15 |
#include "player_base.h" |
8786
1823ff88a054
(svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
rubidium
parents:
8653
diff
changeset
|
16 |
#include "engine_func.h" |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9065
diff
changeset
|
17 |
#include "engine_base.h" |
8083
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
7730
diff
changeset
|
18 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
19 |
|
1944
dd9cba5fab2a
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1942
diff
changeset
|
20 |
/* XXX: Below 3 tables store duplicate data. Maybe remove some? */ |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
21 |
/* Maps a trackdir to the bit that stores its status in the map arrays, in the |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
22 |
* direction along with the trackdir */ |
8161
59b7bb15cb21
(svn r11723) -Feature: add initial support for Intel C Compiler on linux
skidd13
parents:
8088
diff
changeset
|
23 |
extern const byte _signal_along_trackdir[TRACKDIR_END] = { |
6753
c1013c837417
(svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents:
6491
diff
changeset
|
24 |
0x8, 0x8, 0x8, 0x2, 0x4, 0x1, 0, 0, |
c1013c837417
(svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents:
6491
diff
changeset
|
25 |
0x4, 0x4, 0x4, 0x1, 0x8, 0x2 |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
26 |
}; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
27 |
|
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
28 |
/* Maps a trackdir to the bit that stores its status in the map arrays, in the |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
29 |
* direction against the trackdir */ |
8161
59b7bb15cb21
(svn r11723) -Feature: add initial support for Intel C Compiler on linux
skidd13
parents:
8088
diff
changeset
|
30 |
extern const byte _signal_against_trackdir[TRACKDIR_END] = { |
6753
c1013c837417
(svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents:
6491
diff
changeset
|
31 |
0x4, 0x4, 0x4, 0x1, 0x8, 0x2, 0, 0, |
c1013c837417
(svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents:
6491
diff
changeset
|
32 |
0x8, 0x8, 0x8, 0x2, 0x4, 0x1 |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
33 |
}; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
34 |
|
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
35 |
/* Maps a Track to the bits that store the status of the two signals that can |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
36 |
* be present on the given track */ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
37 |
extern const byte _signal_on_track[] = { |
6753
c1013c837417
(svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents:
6491
diff
changeset
|
38 |
0xC, 0xC, 0xC, 0x3, 0xC, 0x3 |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
39 |
}; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
40 |
|
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
41 |
/* Maps a diagonal direction to the all trackdirs that are connected to any |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
42 |
* track entering in this direction (including those making 90 degree turns) |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
43 |
*/ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
44 |
extern const TrackdirBits _exitdir_reaches_trackdirs[] = { |
3102
f9ca4379db9d
(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_BIT_X_NE | TRACKDIR_BIT_LOWER_E | TRACKDIR_BIT_LEFT_N, /* DIAGDIR_NE */ |
f9ca4379db9d
(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
|
46 |
TRACKDIR_BIT_Y_SE | TRACKDIR_BIT_LEFT_S | TRACKDIR_BIT_UPPER_E, /* DIAGDIR_SE */ |
f9ca4379db9d
(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
|
47 |
TRACKDIR_BIT_X_SW | TRACKDIR_BIT_UPPER_W | TRACKDIR_BIT_RIGHT_S, /* DIAGDIR_SW */ |
f9ca4379db9d
(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
|
48 |
TRACKDIR_BIT_Y_NW | TRACKDIR_BIT_RIGHT_N | TRACKDIR_BIT_LOWER_W /* DIAGDIR_NW */ |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
49 |
}; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
50 |
|
8161
59b7bb15cb21
(svn r11723) -Feature: add initial support for Intel C Compiler on linux
skidd13
parents:
8088
diff
changeset
|
51 |
extern const Trackdir _next_trackdir[TRACKDIR_END] = { |
3102
f9ca4379db9d
(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
|
52 |
TRACKDIR_X_NE, TRACKDIR_Y_SE, TRACKDIR_LOWER_E, TRACKDIR_UPPER_E, TRACKDIR_RIGHT_S, TRACKDIR_LEFT_S, INVALID_TRACKDIR, INVALID_TRACKDIR, |
f9ca4379db9d
(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
|
53 |
TRACKDIR_X_SW, TRACKDIR_Y_NW, TRACKDIR_LOWER_W, TRACKDIR_UPPER_W, TRACKDIR_RIGHT_N, TRACKDIR_LEFT_N |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
54 |
}; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
55 |
|
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
56 |
/* Maps a trackdir to all trackdirs that make 90 deg turns with it. */ |
8161
59b7bb15cb21
(svn r11723) -Feature: add initial support for Intel C Compiler on linux
skidd13
parents:
8088
diff
changeset
|
57 |
extern const TrackdirBits _track_crosses_trackdirs[TRACKDIR_END] = { |
3102
f9ca4379db9d
(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
|
58 |
TRACKDIR_BIT_Y_SE | TRACKDIR_BIT_Y_NW, /* TRACK_X */ |
f9ca4379db9d
(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
|
59 |
TRACKDIR_BIT_X_NE | TRACKDIR_BIT_X_SW, /* TRACK_Y */ |
1944
dd9cba5fab2a
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1942
diff
changeset
|
60 |
TRACKDIR_BIT_RIGHT_N | TRACKDIR_BIT_RIGHT_S | TRACKDIR_BIT_LEFT_N | TRACKDIR_BIT_LEFT_S, /* TRACK_UPPER */ |
dd9cba5fab2a
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1942
diff
changeset
|
61 |
TRACKDIR_BIT_RIGHT_N | TRACKDIR_BIT_RIGHT_S | TRACKDIR_BIT_LEFT_N | TRACKDIR_BIT_LEFT_S, /* TRACK_LOWER */ |
dd9cba5fab2a
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1942
diff
changeset
|
62 |
TRACKDIR_BIT_UPPER_W | TRACKDIR_BIT_UPPER_E | TRACKDIR_BIT_LOWER_W | TRACKDIR_BIT_LOWER_E, /* TRACK_LEFT */ |
dd9cba5fab2a
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1942
diff
changeset
|
63 |
TRACKDIR_BIT_UPPER_W | TRACKDIR_BIT_UPPER_E | TRACKDIR_BIT_LOWER_W | TRACKDIR_BIT_LOWER_E /* TRACK_RIGHT */ |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
64 |
}; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
65 |
|
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
66 |
/* Maps a track to all tracks that make 90 deg turns with it. */ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
67 |
extern const TrackBits _track_crosses_tracks[] = { |
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3242
diff
changeset
|
68 |
TRACK_BIT_Y, /* TRACK_X */ |
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3242
diff
changeset
|
69 |
TRACK_BIT_X, /* TRACK_Y */ |
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3242
diff
changeset
|
70 |
TRACK_BIT_VERT, /* TRACK_UPPER */ |
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3242
diff
changeset
|
71 |
TRACK_BIT_VERT, /* TRACK_LOWER */ |
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3242
diff
changeset
|
72 |
TRACK_BIT_HORZ, /* TRACK_LEFT */ |
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3242
diff
changeset
|
73 |
TRACK_BIT_HORZ /* TRACK_RIGHT */ |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
74 |
}; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
75 |
|
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
76 |
/* Maps a trackdir to the (4-way) direction the tile is exited when following |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
77 |
* that trackdir */ |
8161
59b7bb15cb21
(svn r11723) -Feature: add initial support for Intel C Compiler on linux
skidd13
parents:
8088
diff
changeset
|
78 |
extern const DiagDirection _trackdir_to_exitdir[TRACKDIR_END] = { |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6420
diff
changeset
|
79 |
DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_NE, |
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6420
diff
changeset
|
80 |
DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE, |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
81 |
}; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
82 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
83 |
extern const Trackdir _track_exitdir_to_trackdir[][DIAGDIR_END] = { |
3102
f9ca4379db9d
(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
|
84 |
{TRACKDIR_X_NE, INVALID_TRACKDIR, TRACKDIR_X_SW, INVALID_TRACKDIR}, |
f9ca4379db9d
(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 |
{INVALID_TRACKDIR, TRACKDIR_Y_SE, INVALID_TRACKDIR, TRACKDIR_Y_NW}, |
1944
dd9cba5fab2a
(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 |
{TRACKDIR_UPPER_E, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_UPPER_W}, |
dd9cba5fab2a
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1942
diff
changeset
|
87 |
{INVALID_TRACKDIR, TRACKDIR_LOWER_E, TRACKDIR_LOWER_W, INVALID_TRACKDIR}, |
dd9cba5fab2a
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1942
diff
changeset
|
88 |
{INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_LEFT_S, TRACKDIR_LEFT_N}, |
dd9cba5fab2a
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1942
diff
changeset
|
89 |
{TRACKDIR_RIGHT_N, TRACKDIR_RIGHT_S, INVALID_TRACKDIR, INVALID_TRACKDIR} |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
90 |
}; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
91 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6393
diff
changeset
|
92 |
extern const Trackdir _track_enterdir_to_trackdir[][DIAGDIR_END] = { |
3102
f9ca4379db9d
(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
|
93 |
{TRACKDIR_X_NE, INVALID_TRACKDIR, TRACKDIR_X_SW, INVALID_TRACKDIR}, |
f9ca4379db9d
(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_Y_SE, INVALID_TRACKDIR, TRACKDIR_Y_NW}, |
2008
cdb444f6d43c
(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
|
95 |
{INVALID_TRACKDIR, TRACKDIR_UPPER_E, TRACKDIR_UPPER_W, INVALID_TRACKDIR}, |
cdb444f6d43c
(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
|
96 |
{TRACKDIR_LOWER_E, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_LOWER_W}, |
cdb444f6d43c
(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
|
97 |
{TRACKDIR_LEFT_N, TRACKDIR_LEFT_S, INVALID_TRACKDIR, INVALID_TRACKDIR}, |
cdb444f6d43c
(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
|
98 |
{INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_RIGHT_S, TRACKDIR_RIGHT_N} |
cdb444f6d43c
(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
|
99 |
}; |
cdb444f6d43c
(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
|
100 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
101 |
extern const Trackdir _track_direction_to_trackdir[][DIR_END] = { |
3102
f9ca4379db9d
(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
|
102 |
{INVALID_TRACKDIR, TRACKDIR_X_NE, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_X_SW, INVALID_TRACKDIR, INVALID_TRACKDIR}, |
f9ca4379db9d
(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 |
{INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_Y_SE, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_Y_NW}, |
1944
dd9cba5fab2a
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1942
diff
changeset
|
104 |
{INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_UPPER_E, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_UPPER_W, INVALID_TRACKDIR}, |
dd9cba5fab2a
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1942
diff
changeset
|
105 |
{INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_LOWER_E, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_LOWER_W, INVALID_TRACKDIR}, |
dd9cba5fab2a
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1942
diff
changeset
|
106 |
{TRACKDIR_LEFT_N, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_LEFT_S, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR}, |
dd9cba5fab2a
(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 |
{TRACKDIR_RIGHT_N, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_RIGHT_S, INVALID_TRACKDIR, INVALID_TRACKDIR, INVALID_TRACKDIR} |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
108 |
}; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
109 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
110 |
extern const Trackdir _dir_to_diag_trackdir[] = { |
3102
f9ca4379db9d
(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
|
111 |
TRACKDIR_X_NE, TRACKDIR_Y_SE, TRACKDIR_X_SW, TRACKDIR_Y_NW, |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
112 |
}; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff
changeset
|
113 |
|
7703
6178606d419a
(svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents:
7370
diff
changeset
|
114 |
extern const TrackBits _corner_to_trackbits[] = { |
6178606d419a
(svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents:
7370
diff
changeset
|
115 |
TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_RIGHT, TRACK_BIT_UPPER, |
6178606d419a
(svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents:
7370
diff
changeset
|
116 |
}; |
6178606d419a
(svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents:
7370
diff
changeset
|
117 |
|
8653
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
118 |
extern const TrackdirBits _uphill_trackdirs[] = { |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
119 |
TRACKDIR_BIT_NONE , ///< 0 SLOPE_FLAT |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
120 |
TRACKDIR_BIT_X_SW | TRACKDIR_BIT_Y_NW, ///< 1 SLOPE_W -> inclined for diagonal track |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
121 |
TRACKDIR_BIT_X_SW | TRACKDIR_BIT_Y_SE, ///< 2 SLOPE_S -> inclined for diagonal track |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
122 |
TRACKDIR_BIT_X_SW , ///< 3 SLOPE_SW |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
123 |
TRACKDIR_BIT_X_NE | TRACKDIR_BIT_Y_SE, ///< 4 SLOPE_E -> inclined for diagonal track |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
124 |
TRACKDIR_BIT_NONE , ///< 5 SLOPE_EW |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
125 |
TRACKDIR_BIT_Y_SE , ///< 6 SLOPE_SE |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
126 |
TRACKDIR_BIT_NONE , ///< 7 SLOPE_WSE -> leveled |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
127 |
TRACKDIR_BIT_X_NE | TRACKDIR_BIT_Y_NW, ///< 8 SLOPE_N -> inclined for diagonal track |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
128 |
TRACKDIR_BIT_Y_NW , ///< 9 SLOPE_NW |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
129 |
TRACKDIR_BIT_NONE , ///< 10 SLOPE_NS |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
130 |
TRACKDIR_BIT_NONE , ///< 11 SLOPE_NWS -> leveled |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
131 |
TRACKDIR_BIT_X_NE , ///< 12 SLOPE_NE |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
132 |
TRACKDIR_BIT_NONE , ///< 13 SLOPE_ENW -> leveled |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
133 |
TRACKDIR_BIT_NONE , ///< 14 SLOPE_SEN -> leveled |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
134 |
TRACKDIR_BIT_NONE , ///< 15 invalid |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
135 |
TRACKDIR_BIT_NONE , ///< 16 invalid |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
136 |
TRACKDIR_BIT_NONE , ///< 17 invalid |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
137 |
TRACKDIR_BIT_NONE , ///< 18 invalid |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
138 |
TRACKDIR_BIT_NONE , ///< 19 invalid |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
139 |
TRACKDIR_BIT_NONE , ///< 20 invalid |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
140 |
TRACKDIR_BIT_NONE , ///< 21 invalid |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
141 |
TRACKDIR_BIT_NONE , ///< 22 invalid |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
142 |
TRACKDIR_BIT_X_SW | TRACKDIR_BIT_Y_SE, ///< 23 SLOPE_STEEP_S -> inclined for diagonal track |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
143 |
TRACKDIR_BIT_NONE , ///< 24 invalid |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
144 |
TRACKDIR_BIT_NONE , ///< 25 invalid |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
145 |
TRACKDIR_BIT_NONE , ///< 26 invalid |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
146 |
TRACKDIR_BIT_X_SW | TRACKDIR_BIT_Y_NW, ///< 27 SLOPE_STEEP_W -> inclined for diagonal track |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
147 |
TRACKDIR_BIT_NONE , ///< 28 invalid |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
148 |
TRACKDIR_BIT_X_NE | TRACKDIR_BIT_Y_NW, ///< 29 SLOPE_STEEP_N -> inclined for diagonal track |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
149 |
TRACKDIR_BIT_X_NE | TRACKDIR_BIT_Y_SE, ///< 30 SLOPE_STEEP_E -> inclined for diagonal track |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
150 |
}; |
527a6273a0a8
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents:
8387
diff
changeset
|
151 |
|
7730
4293ba29ce21
(svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents:
7703
diff
changeset
|
152 |
/* The default multiplier for the cost of building different types of railway |
4293ba29ce21
(svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents:
7703
diff
changeset
|
153 |
* track, which will be divided by 8. Can be changed by newgrf files. */ |
4293ba29ce21
(svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents:
7703
diff
changeset
|
154 |
const int _default_railtype_cost_multiplier[RAILTYPE_END] = { |
4293ba29ce21
(svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents:
7703
diff
changeset
|
155 |
8, 12, 16, 24, |
4293ba29ce21
(svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents:
7703
diff
changeset
|
156 |
}; |
4293ba29ce21
(svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents:
7703
diff
changeset
|
157 |
int _railtype_cost_multiplier[RAILTYPE_END]; |
1950
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
158 |
|
6154 | 159 |
RailType GetTileRailType(TileIndex tile) |
1950
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
160 |
{ |
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
161 |
switch (GetTileType(tile)) { |
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
162 |
case MP_RAILWAY: |
3242
4c32bf21153b
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
163 |
return GetRailType(tile); |
4c32bf21153b
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
164 |
|
7370
41adc721b1fa
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
6753
diff
changeset
|
165 |
case MP_ROAD: |
1950
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
166 |
/* rail/road crossing */ |
6172
e6d7a5b3d63f
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6154
diff
changeset
|
167 |
if (IsLevelCrossing(tile)) return GetRailType(tile); |
1950
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
168 |
break; |
3242
4c32bf21153b
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
169 |
|
1950
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
170 |
case MP_STATION: |
3442
41d828e2d5ab
(svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents:
3258
diff
changeset
|
171 |
if (IsRailwayStationTile(tile)) return GetRailType(tile); |
1950
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
172 |
break; |
3242
4c32bf21153b
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
173 |
|
1950
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
174 |
case MP_TUNNELBRIDGE: |
8088
92fca5b09665
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8083
diff
changeset
|
175 |
if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile); |
1950
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
176 |
break; |
3234
a2791a480b71
(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
|
177 |
|
1950
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
178 |
default: |
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
179 |
break; |
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
180 |
} |
3242
4c32bf21153b
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
181 |
return INVALID_RAILTYPE; |
1950
aeb6067adc30
(svn r2456) * Prettyfied npf.c using enums and wrappers from rail.h.
matthijs
parents:
1948
diff
changeset
|
182 |
} |
8236
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
183 |
|
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
184 |
bool HasRailtypeAvail(const PlayerID p, const RailType railtype) |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
185 |
{ |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
186 |
return HasBit(GetPlayer(p)->avail_railtypes, railtype); |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
187 |
} |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
188 |
|
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
189 |
bool ValParamRailtype(const RailType rail) |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
190 |
{ |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
191 |
return HasRailtypeAvail(_current_player, rail); |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
192 |
} |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
193 |
|
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
194 |
RailType GetBestRailtype(const PlayerID p) |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
195 |
{ |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
196 |
if (HasRailtypeAvail(p, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV; |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
197 |
if (HasRailtypeAvail(p, RAILTYPE_MONO)) return RAILTYPE_MONO; |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
198 |
if (HasRailtypeAvail(p, RAILTYPE_ELECTRIC)) return RAILTYPE_ELECTRIC; |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
199 |
return RAILTYPE_RAIL; |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
200 |
} |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
201 |
|
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
202 |
RailTypes GetPlayerRailtypes(PlayerID p) |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
203 |
{ |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
204 |
RailTypes rt = RAILTYPES_NONE; |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
205 |
|
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9065
diff
changeset
|
206 |
Engine *e; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9065
diff
changeset
|
207 |
FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) { |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9065
diff
changeset
|
208 |
const EngineInfo *ei = &e->info; |
8236
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
209 |
|
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9358
diff
changeset
|
210 |
if (HasBit(ei->climates, _settings_game.game_creation.landscape) && |
8236
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
211 |
(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) { |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9065
diff
changeset
|
212 |
const RailVehicleInfo *rvi = &e->u.rail; |
8236
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
213 |
|
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
214 |
if (rvi->railveh_type != RAILVEH_WAGON) { |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
215 |
assert(rvi->railtype < RAILTYPE_END); |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
216 |
SetBit(rt, rvi->railtype); |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
217 |
} |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
218 |
} |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
219 |
} |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
220 |
|
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
221 |
return rt; |
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8161
diff
changeset
|
222 |
} |