OpenTTD Source: src/rail.h Source File

OpenTTD Source 15.0-beta1

rail.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef RAIL_H
11#define RAIL_H
12
13#include "rail_type.h"
14#include "track_type.h"
15#include "gfx_type.h"
16#include "core/bitmath_func.hpp"
17#include "economy_func.h"
18#include "slope_type.h"
19#include "strings_type.h"
20#include "timer/timer_game_calendar.h"
21#include "signal_type.h"
22#include "settings_type.h"
23
25 enum RailTypeFlag {
26 RTF_CATENARY = 0,
27 RTF_NO_LEVEL_CROSSING = 1,
28 RTF_HIDDEN = 2,
29 RTF_NO_SPRITE_COMBINE = 3,
30 RTF_ALLOW_90DEG = 4,
31 RTF_DISALLOW_90DEG = 5,
32};
33
35 enum RailTypeFlags : uint8_t {
36 RTFB_NONE = 0,
37 RTFB_CATENARY = 1 << RTF_CATENARY,
38 RTFB_NO_LEVEL_CROSSING = 1 << RTF_NO_LEVEL_CROSSING,
39 RTFB_HIDDEN = 1 << RTF_HIDDEN,
40 RTFB_NO_SPRITE_COMBINE = 1 << RTF_NO_SPRITE_COMBINE,
41 RTFB_ALLOW_90DEG = 1 << RTF_ALLOW_90DEG,
42 RTFB_DISALLOW_90DEG = 1 << RTF_DISALLOW_90DEG,
43};
44 DECLARE_ENUM_AS_BIT_SET(RailTypeFlags)
45
46struct SpriteGroup;
47
49 enum RailTypeSpriteGroup {
50 RTSG_CURSORS,
51 RTSG_OVERLAY,
52 RTSG_GROUND,
53 RTSG_TUNNEL,
54 RTSG_WIRES,
55 RTSG_PYLONS,
56 RTSG_BRIDGE,
57 RTSG_CROSSING,
58 RTSG_DEPOT,
59 RTSG_FENCES,
60 RTSG_TUNNEL_PORTAL,
61 RTSG_SIGNALS,
62 RTSG_GROUND_COMPLETE,
63 RTSG_END,
64};
65
70 enum RailTrackOffset {
71 RTO_X,
72 RTO_Y,
73 RTO_N,
74 RTO_S,
75 RTO_E,
76 RTO_W,
77 RTO_SLOPE_NE,
78 RTO_SLOPE_SE,
79 RTO_SLOPE_SW,
80 RTO_SLOPE_NW,
81 RTO_CROSSING_XY,
82 RTO_JUNCTION_SW,
83 RTO_JUNCTION_NE,
84 RTO_JUNCTION_SE,
85 RTO_JUNCTION_NW,
86 RTO_JUNCTION_NSEW,
87};
88
92 enum RailTrackBridgeOffset {
93 RTBO_X,
94 RTBO_Y,
95 RTBO_SLOPE,
96};
97
102 enum RailFenceOffset {
103 RFO_FLAT_X_NW,
104 RFO_FLAT_Y_NE,
105 RFO_FLAT_LEFT,
106 RFO_FLAT_UPPER,
107 RFO_SLOPE_SW_NW,
108 RFO_SLOPE_SE_NE,
109 RFO_SLOPE_NE_NW,
110 RFO_SLOPE_NW_NE,
111 RFO_FLAT_X_SE,
112 RFO_FLAT_Y_SW,
113 RFO_FLAT_RIGHT,
114 RFO_FLAT_LOWER,
115 RFO_SLOPE_SW_SE,
116 RFO_SLOPE_SE_SW,
117 RFO_SLOPE_NE_SE,
118 RFO_SLOPE_NW_SW,
119};
120
122 typedef std::vector<RailTypeLabel> RailTypeLabelList;
123
127 class RailTypeInfo {
128public:
133 struct {
134 SpriteID track_y;
135 SpriteID track_ns;
136 SpriteID ground;
137 SpriteID single_x;
138 SpriteID single_y;
139 SpriteID single_n;
140 SpriteID single_s;
141 SpriteID single_e;
142 SpriteID single_w;
143 SpriteID single_sloped;
144 SpriteID crossing;
145 SpriteID tunnel;
146 } base_sprites;
147
152 struct {
153 SpriteID build_ns_rail;
154 SpriteID build_x_rail;
155 SpriteID build_ew_rail;
156 SpriteID build_y_rail;
157 SpriteID auto_rail;
158 SpriteID build_depot;
159 SpriteID build_tunnel;
160 SpriteID convert_rail;
161 SpriteID signals[SIGTYPE_END][2][2];
162 } gui_sprites;
163
164 struct {
165 CursorID rail_ns;
166 CursorID rail_swne;
167 CursorID rail_ew;
168 CursorID rail_nwse;
169 CursorID autorail;
170 CursorID depot;
171 CursorID tunnel;
172 CursorID convert;
173 } cursor;
174
175 struct {
176 StringID name;
177 StringID toolbar_caption;
178 StringID menu_text;
179 StringID build_caption;
180 StringID replace_text;
181 StringID new_loco;
182 } strings;
183
185 SpriteID snow_offset;
186
188 RailTypes powered_railtypes;
189
191 RailTypes compatible_railtypes;
192
196 SpriteID bridge_offset;
197
201 uint8_t fallback_railtype;
202
206 uint8_t curve_speed;
207
211 RailTypeFlags flags;
212
216 uint16_t cost_multiplier;
217
221 uint16_t maintenance_multiplier;
222
226 uint8_t acceleration_type;
227
231 uint16_t max_speed;
232
236 RailTypeLabel label;
237
241 RailTypeLabelList alternate_labels;
242
246 uint8_t map_colour;
247
255 TimerGameCalendar::Date introduction_date;
256
261 RailTypes introduction_required_railtypes;
262
266 RailTypes introduces_railtypes;
267
271 uint8_t sorting_order;
272
276 const GRFFile *grffile[RTSG_END];
277
281 const SpriteGroup *group[RTSG_END];
282
283 inline bool UsesOverlay() const
284 {
285 return this->group[RTSG_GROUND] != nullptr;
286 }
287
295 inline uint GetRailtypeSpriteOffset() const
296 {
297 return 82 * this->fallback_railtype;
298 }
299};
300
301
307 inline const RailTypeInfo *GetRailTypeInfo(RailType railtype)
308{
309 extern RailTypeInfo _railtypes[RAILTYPE_END];
310 assert(railtype < RAILTYPE_END);
311 return &_railtypes[railtype];
312}
313
322 inline bool IsCompatibleRail(RailType enginetype, RailType tiletype)
323{
324 return HasBit(GetRailTypeInfo(enginetype)->compatible_railtypes, tiletype);
325}
326
335 inline bool HasPowerOnRail(RailType enginetype, RailType tiletype)
336{
337 return HasBit(GetRailTypeInfo(enginetype)->powered_railtypes, tiletype);
338}
339
345 inline bool RailNoLevelCrossings(RailType rt)
346{
347 return HasBit(GetRailTypeInfo(rt)->flags, RTF_NO_LEVEL_CROSSING);
348}
349
357 inline bool Rail90DegTurnDisallowed(RailType rt1, RailType rt2, bool def = _settings_game.pf.forbid_90_deg)
358{
359 if (rt1 == INVALID_RAILTYPE || rt2 == INVALID_RAILTYPE) return def;
360
361 const RailTypeInfo *rti1 = GetRailTypeInfo(rt1);
362 const RailTypeInfo *rti2 = GetRailTypeInfo(rt2);
363
364 bool rt1_90deg = HasBit(rti1->flags, RTF_DISALLOW_90DEG) || (!HasBit(rti1->flags, RTF_ALLOW_90DEG) && def);
365 bool rt2_90deg = HasBit(rti2->flags, RTF_DISALLOW_90DEG) || (!HasBit(rti2->flags, RTF_ALLOW_90DEG) && def);
366
367 return rt1_90deg || rt2_90deg;
368}
369
375 inline Money RailBuildCost(RailType railtype)
376{
377 assert(railtype < RAILTYPE_END);
378 return (_price[PR_BUILD_RAIL] * GetRailTypeInfo(railtype)->cost_multiplier) >> 3;
379}
380
386 inline Money RailClearCost(RailType railtype)
387{
388 /* Clearing rail in fact earns money, but if the build cost is set
389 * very low then a loophole exists where money can be made.
390 * In this case we limit the removal earnings to 3/4s of the build
391 * cost.
392 */
393 assert(railtype < RAILTYPE_END);
394 return std::max(_price[PR_CLEAR_RAIL], -RailBuildCost(railtype) * 3 / 4);
395}
396
403 inline Money RailConvertCost(RailType from, RailType to)
404{
405 /* Get the costs for removing and building anew
406 * A conversion can never be more costly */
407 Money rebuildcost = RailBuildCost(to) + RailClearCost(from);
408
409 /* Conversion between somewhat compatible railtypes:
410 * Pay 1/8 of the target rail cost (labour costs) and additionally any difference in the
411 * build costs, if the target type is more expensive (material upgrade costs).
412 * Upgrade can never be more expensive than re-building. */
413 if (HasPowerOnRail(from, to) || HasPowerOnRail(to, from)) {
414 Money upgradecost = RailBuildCost(to) / 8 + std::max((Money)0, RailBuildCost(to) - RailBuildCost(from));
415 return std::min(upgradecost, rebuildcost);
416 }
417
418 /* make the price the same as remove + build new type for rail types
419 * which are not compatible in any way */
420 return rebuildcost;
421}
422
430 inline Money RailMaintenanceCost(RailType railtype, uint32_t num, uint32_t total_num)
431{
432 assert(railtype < RAILTYPE_END);
433 return (_price[PR_INFRASTRUCTURE_RAIL] * GetRailTypeInfo(railtype)->maintenance_multiplier * num * (1 + IntSqrt(total_num))) >> 11; // 4 bits fraction for the multiplier and 7 bits scaling.
434}
435
441 inline Money SignalMaintenanceCost(uint32_t num)
442{
443 return (_price[PR_INFRASTRUCTURE_RAIL] * 15 * num * (1 + IntSqrt(num))) >> 8; // 1 bit fraction for the multiplier and 7 bits scaling.
444}
445
446void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
447int TicksToLeaveDepot(const Train *v);
448
449 Foundation GetRailFoundation(Slope tileh, TrackBits bits);
450
451
452bool HasRailTypeAvail(const CompanyID company, const RailType railtype);
453bool HasAnyRailTypesAvail(const CompanyID company);
454bool ValParamRailType(const RailType rail);
455
456 RailTypes AddDateIntroducedRailTypes(RailTypes current, TimerGameCalendar::Date date);
457
458 RailTypes GetCompanyRailTypes(CompanyID company, bool introduces = true);
459 RailTypes GetRailTypes(bool introduces);
460
461 RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels = true);
462
463void ResetRailTypes();
464void InitRailTypes();
465 RailType AllocateRailType(RailTypeLabel label);
466
467extern std::vector<RailType> _sorted_railtypes;
468extern RailTypes _railtypes_hidden_mask;
469
470#endif /* RAIL_H */
bitmath_func.hpp
Functions related to bit mathematics.
HasBit
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition bitmath_func.hpp:103
OverflowSafeInt< int64_t >
RailTypeInfo
This struct contains all the info that is needed to draw and construct tracks.
Definition rail.h:127
RailTypeInfo::single_x
SpriteID single_x
single piece of rail in X direction, without ground
Definition rail.h:137
RailTypeInfo::cursor
struct RailTypeInfo::@25 cursor
Cursors associated with the rail type.
RailTypeInfo::bridge_offset
SpriteID bridge_offset
Bridge offset.
Definition rail.h:196
RailTypeInfo::max_speed
uint16_t max_speed
Maximum speed for vehicles travelling on this rail type.
Definition rail.h:231
RailTypeInfo::build_tunnel
SpriteID build_tunnel
button for building a tunnel
Definition rail.h:159
RailTypeInfo::rail_swne
CursorID rail_swne
Cursor for building rail in X direction.
Definition rail.h:166
RailTypeInfo::convert_rail
SpriteID convert_rail
button for converting rail
Definition rail.h:160
RailTypeInfo::convert
CursorID convert
Cursor for converting track.
Definition rail.h:172
RailTypeInfo::base_sprites
struct RailTypeInfo::@23 base_sprites
Struct containing the main sprites.
RailTypeInfo::depot
CursorID depot
Cursor for building a depot.
Definition rail.h:170
RailTypeInfo::introduction_date
TimerGameCalendar::Date introduction_date
Introduction date.
Definition rail.h:255
RailTypeInfo::strings
struct RailTypeInfo::@26 strings
Strings associated with the rail type.
RailTypeInfo::powered_railtypes
RailTypes powered_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype generates power
Definition rail.h:188
RailTypeInfo::introduces_railtypes
RailTypes introduces_railtypes
Bitmask of which other railtypes are introduced when this railtype is introduced.
Definition rail.h:266
RailTypeInfo::ground
SpriteID ground
ground sprite for a 3-way switch
Definition rail.h:136
RailTypeInfo::rail_nwse
CursorID rail_nwse
Cursor for building rail in Y direction.
Definition rail.h:168
RailTypeInfo::introduction_required_railtypes
RailTypes introduction_required_railtypes
Bitmask of railtypes that are required for this railtype to be introduced at a given introduction_dat...
Definition rail.h:261
RailTypeInfo::build_x_rail
SpriteID build_x_rail
button for building single rail in X direction
Definition rail.h:154
RailTypeInfo::sorting_order
uint8_t sorting_order
The sorting order of this railtype for the toolbar dropdown.
Definition rail.h:271
RailTypeInfo::label
RailTypeLabel label
Unique 32 bit rail type identifier.
Definition rail.h:236
RailTypeInfo::single_n
SpriteID single_n
single piece of rail in the northern corner
Definition rail.h:139
RailTypeInfo::tunnel
CursorID tunnel
Cursor for building a tunnel.
Definition rail.h:171
RailTypeInfo::maintenance_multiplier
uint16_t maintenance_multiplier
Cost multiplier for maintenance of this rail type.
Definition rail.h:221
RailTypeInfo::crossing
SpriteID crossing
level crossing, rail in X direction
Definition rail.h:144
RailTypeInfo::group
const SpriteGroup * group[RTSG_END]
Sprite groups for resolving sprites.
Definition rail.h:281
RailTypeInfo::map_colour
uint8_t map_colour
Colour on mini-map.
Definition rail.h:246
RailTypeInfo::rail_ew
CursorID rail_ew
Cursor for building rail in E-W direction.
Definition rail.h:167
RailTypeInfo::auto_rail
SpriteID auto_rail
button for the autorail construction
Definition rail.h:157
RailTypeInfo::autorail
CursorID autorail
Cursor for autorail tool.
Definition rail.h:169
RailTypeInfo::single_y
SpriteID single_y
single piece of rail in Y direction, without ground
Definition rail.h:138
RailTypeInfo::menu_text
StringID menu_text
Name of this rail type in the main toolbar dropdown.
Definition rail.h:178
RailTypeInfo::name
StringID name
Name of this rail type.
Definition rail.h:176
RailTypeInfo::compatible_railtypes
RailTypes compatible_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel
Definition rail.h:191
RailTypeInfo::fallback_railtype
uint8_t fallback_railtype
Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.
Definition rail.h:201
RailTypeInfo::GetRailtypeSpriteOffset
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
Definition rail.h:295
RailTypeInfo::toolbar_caption
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
Definition rail.h:177
RailTypeInfo::single_s
SpriteID single_s
single piece of rail in the southern corner
Definition rail.h:140
RailTypeInfo::flags
RailTypeFlags flags
Bit mask of rail type flags.
Definition rail.h:211
RailTypeInfo::curve_speed
uint8_t curve_speed
Multiplier for curve maximum speed advantage.
Definition rail.h:206
RailTypeInfo::signals
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
Definition rail.h:161
RailTypeInfo::build_ew_rail
SpriteID build_ew_rail
button for building single rail in E-W direction
Definition rail.h:155
RailTypeInfo::build_y_rail
SpriteID build_y_rail
button for building single rail in Y direction
Definition rail.h:156
RailTypeInfo::cost_multiplier
uint16_t cost_multiplier
Cost multiplier for building this rail type.
Definition rail.h:216
RailTypeInfo::track_ns
SpriteID track_ns
two pieces of rail in North and South corner (East-West direction)
Definition rail.h:135
RailTypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition rail.h:180
RailTypeInfo::alternate_labels
RailTypeLabelList alternate_labels
Rail type labels this type provides in addition to the main label.
Definition rail.h:241
RailTypeInfo::build_caption
StringID build_caption
Caption of the build vehicle GUI for this rail type.
Definition rail.h:179
RailTypeInfo::snow_offset
SpriteID snow_offset
sprite number difference between a piece of track on a snowy ground and the corresponding one on norm...
Definition rail.h:185
RailTypeInfo::track_y
SpriteID track_y
single piece of rail in Y direction, with ground
Definition rail.h:134
RailTypeInfo::build_depot
SpriteID build_depot
button for building depots
Definition rail.h:158
RailTypeInfo::gui_sprites
struct RailTypeInfo::@24 gui_sprites
struct containing the sprites for the rail GUI.
RailTypeInfo::single_w
SpriteID single_w
single piece of rail in the western corner
Definition rail.h:142
RailTypeInfo::single_e
SpriteID single_e
single piece of rail in the eastern corner
Definition rail.h:141
RailTypeInfo::build_ns_rail
SpriteID build_ns_rail
button for building single rail in N-S direction
Definition rail.h:153
RailTypeInfo::rail_ns
CursorID rail_ns
Cursor for building rail in N-S direction.
Definition rail.h:165
RailTypeInfo::new_loco
StringID new_loco
Name of an engine for this type of rail in the engine preview GUI.
Definition rail.h:181
RailTypeInfo::grffile
const GRFFile * grffile[RTSG_END]
NewGRF providing the Action3 for the railtype.
Definition rail.h:276
RailTypeInfo::tunnel
SpriteID tunnel
tunnel sprites base
Definition rail.h:145
RailTypeInfo::single_sloped
SpriteID single_sloped
single piece of rail for slopes
Definition rail.h:143
RailTypeInfo::acceleration_type
uint8_t acceleration_type
Acceleration type of this rail type.
Definition rail.h:226
Owner
Owner
Enum for all companies/owners.
Definition company_type.h:18
IntSqrt
uint32_t IntSqrt(uint32_t num)
Compute the integer square root.
Definition math_func.cpp:42
economy_func.h
Functions related to the economy.
DECLARE_ENUM_AS_BIT_SET
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
Definition enum_type.hpp:35
gfx_type.h
Types related to the graphics and/or input devices.
SpriteID
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:18
CursorID
uint32_t CursorID
The number of the cursor (sprite)
Definition gfx_type.h:20
RailConvertCost
Money RailConvertCost(RailType from, RailType to)
Calculates the cost of rail conversion.
Definition rail.h:403
TicksToLeaveDepot
int TicksToLeaveDepot(const Train *v)
Compute number of ticks when next wagon will leave a depot.
Definition rail_cmd.cpp:2916
RailTypeSpriteGroup
RailTypeSpriteGroup
Sprite groups for a railtype.
Definition rail.h:49
RTSG_GROUND
@ RTSG_GROUND
Main group of ground images.
Definition rail.h:52
RTSG_PYLONS
@ RTSG_PYLONS
Catenary pylons.
Definition rail.h:55
RTSG_CURSORS
@ RTSG_CURSORS
Cursor and toolbar icon images.
Definition rail.h:50
RTSG_GROUND_COMPLETE
@ RTSG_GROUND_COMPLETE
Complete ground images.
Definition rail.h:62
RTSG_CROSSING
@ RTSG_CROSSING
Level crossing overlay images.
Definition rail.h:57
RTSG_TUNNEL
@ RTSG_TUNNEL
Main group of ground images for snow or desert.
Definition rail.h:53
RTSG_WIRES
@ RTSG_WIRES
Catenary wires.
Definition rail.h:54
RTSG_OVERLAY
@ RTSG_OVERLAY
Images for overlaying track.
Definition rail.h:51
RTSG_SIGNALS
@ RTSG_SIGNALS
Signal images.
Definition rail.h:61
RTSG_DEPOT
@ RTSG_DEPOT
Depot images.
Definition rail.h:58
RTSG_BRIDGE
@ RTSG_BRIDGE
Bridge surface images.
Definition rail.h:56
RTSG_TUNNEL_PORTAL
@ RTSG_TUNNEL_PORTAL
Tunnel portal overlay.
Definition rail.h:60
RTSG_FENCES
@ RTSG_FENCES
Fence images.
Definition rail.h:59
RailTrackBridgeOffset
RailTrackBridgeOffset
Offsets for sprites within a bridge surface overlay set.
Definition rail.h:92
RTBO_Y
@ RTBO_Y
Piece of rail in Y direction.
Definition rail.h:94
RTBO_X
@ RTBO_X
Piece of rail in X direction.
Definition rail.h:93
RTBO_SLOPE
@ RTBO_SLOPE
Sloped rail pieces, in order NE, SE, SW, NW.
Definition rail.h:95
RailClearCost
Money RailClearCost(RailType railtype)
Returns the 'cost' of clearing the specified railtype.
Definition rail.h:386
RailBuildCost
Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
Definition rail.h:375
AllocateRailType
RailType AllocateRailType(RailTypeLabel label)
Allocate a new rail type label.
Definition rail_cmd.cpp:150
HasAnyRailTypesAvail
bool HasAnyRailTypesAvail(const CompanyID company)
Test if any buildable railtype is available for a company.
Definition rail.cpp:196
RailMaintenanceCost
Money RailMaintenanceCost(RailType railtype, uint32_t num, uint32_t total_num)
Calculates the maintenance cost of a number of track bits.
Definition rail.h:430
HasRailTypeAvail
bool HasRailTypeAvail(const CompanyID company, const RailType railtype)
Finds out if a company has a certain buildable railtype available.
Definition rail.cpp:186
IsCompatibleRail
bool IsCompatibleRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType can drive on a tile with a given RailType.
Definition rail.h:322
InitRailTypes
void InitRailTypes()
Resolve sprites of custom rail types.
Definition rail_cmd.cpp:130
HasPowerOnRail
bool HasPowerOnRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType got power on a tile with a given RailType.
Definition rail.h:335
RailTypeLabelList
std::vector< RailTypeLabel > RailTypeLabelList
List of rail type labels.
Definition rail.h:122
RailTrackOffset
RailTrackOffset
Offsets for sprites within an overlay/underlay set.
Definition rail.h:70
RTO_Y
@ RTO_Y
Piece of rail in Y direction.
Definition rail.h:72
RTO_S
@ RTO_S
Piece of rail in southern corner.
Definition rail.h:74
RTO_JUNCTION_NE
@ RTO_JUNCTION_NE
Ballast for junction 'pointing' NE.
Definition rail.h:83
RTO_JUNCTION_NSEW
@ RTO_JUNCTION_NSEW
Ballast for full junction.
Definition rail.h:86
RTO_JUNCTION_SW
@ RTO_JUNCTION_SW
Ballast for junction 'pointing' SW.
Definition rail.h:82
RTO_SLOPE_SE
@ RTO_SLOPE_SE
Piece of rail on slope with south-east raised.
Definition rail.h:78
RTO_E
@ RTO_E
Piece of rail in eastern corner.
Definition rail.h:75
RTO_W
@ RTO_W
Piece of rail in western corner.
Definition rail.h:76
RTO_CROSSING_XY
@ RTO_CROSSING_XY
Crossing of X and Y rail, with ballast.
Definition rail.h:81
RTO_SLOPE_SW
@ RTO_SLOPE_SW
Piece of rail on slope with south-west raised.
Definition rail.h:79
RTO_SLOPE_NW
@ RTO_SLOPE_NW
Piece of rail on slope with north-west raised.
Definition rail.h:80
RTO_JUNCTION_NW
@ RTO_JUNCTION_NW
Ballast for junction 'pointing' NW.
Definition rail.h:85
RTO_JUNCTION_SE
@ RTO_JUNCTION_SE
Ballast for junction 'pointing' SE.
Definition rail.h:84
RTO_SLOPE_NE
@ RTO_SLOPE_NE
Piece of rail on slope with north-east raised.
Definition rail.h:77
RTO_X
@ RTO_X
Piece of rail in X direction.
Definition rail.h:71
RTO_N
@ RTO_N
Piece of rail in northern corner.
Definition rail.h:73
AddDateIntroducedRailTypes
RailTypes AddDateIntroducedRailTypes(RailTypes current, TimerGameCalendar::Date date)
Add the rail types that are to be introduced at the given date.
Definition rail.cpp:218
ResetRailTypes
void ResetRailTypes()
Reset all rail type information to its default values.
Definition rail_cmd.cpp:65
SignalMaintenanceCost
Money SignalMaintenanceCost(uint32_t num)
Calculates the maintenance cost of a number of signals.
Definition rail.h:441
Rail90DegTurnDisallowed
bool Rail90DegTurnDisallowed(RailType rt1, RailType rt2, bool def=_settings_game.pf.forbid_90_deg)
Test if 90 degree turns are disallowed between two railtypes.
Definition rail.h:357
GetRailTypeInfo
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition rail.h:307
GetCompanyRailTypes
RailTypes GetCompanyRailTypes(CompanyID company, bool introduces=true)
Get the rail types the given company can build.
Definition rail.cpp:251
RailFenceOffset
RailFenceOffset
Offsets from base sprite for fence sprites.
Definition rail.h:102
RFO_FLAT_RIGHT
@ RFO_FLAT_RIGHT
Slope FLAT, Track RIGHT, Fence W.
Definition rail.h:113
RFO_FLAT_Y_NE
@ RFO_FLAT_Y_NE
Slope FLAT, Track Y, Fence NE.
Definition rail.h:104
RFO_SLOPE_NW_SW
@ RFO_SLOPE_NW_SW
Slope NW, Track Y, Fence SW.
Definition rail.h:118
RFO_FLAT_X_SE
@ RFO_FLAT_X_SE
Slope FLAT, Track X, Fence SE.
Definition rail.h:111
RFO_SLOPE_NW_NE
@ RFO_SLOPE_NW_NE
Slope NW, Track Y, Fence NE.
Definition rail.h:110
RFO_SLOPE_SE_SW
@ RFO_SLOPE_SE_SW
Slope SE, Track Y, Fence SW.
Definition rail.h:116
RFO_SLOPE_NE_SE
@ RFO_SLOPE_NE_SE
Slope NE, Track X, Fence SE.
Definition rail.h:117
RFO_FLAT_LOWER
@ RFO_FLAT_LOWER
Slope FLAT, Track LOWER, Fence N.
Definition rail.h:114
RFO_SLOPE_SW_SE
@ RFO_SLOPE_SW_SE
Slope SW, Track X, Fence SE.
Definition rail.h:115
RFO_FLAT_UPPER
@ RFO_FLAT_UPPER
Slope FLAT, Track UPPER, Fence S.
Definition rail.h:106
RFO_SLOPE_SE_NE
@ RFO_SLOPE_SE_NE
Slope SE, Track Y, Fence NE.
Definition rail.h:108
RFO_FLAT_Y_SW
@ RFO_FLAT_Y_SW
Slope FLAT, Track Y, Fence SW.
Definition rail.h:112
RFO_FLAT_LEFT
@ RFO_FLAT_LEFT
Slope FLAT, Track LEFT, Fence E.
Definition rail.h:105
RFO_SLOPE_NE_NW
@ RFO_SLOPE_NE_NW
Slope NE, Track X, Fence NW.
Definition rail.h:109
RFO_FLAT_X_NW
@ RFO_FLAT_X_NW
Slope FLAT, Track X, Fence NW.
Definition rail.h:103
RFO_SLOPE_SW_NW
@ RFO_SLOPE_SW_NW
Slope SW, Track X, Fence NW.
Definition rail.h:107
RailTypeFlag
RailTypeFlag
Railtype flag bit numbers.
Definition rail.h:25
RTF_NO_LEVEL_CROSSING
@ RTF_NO_LEVEL_CROSSING
Bit number for disallowing level crossings.
Definition rail.h:27
RTF_HIDDEN
@ RTF_HIDDEN
Bit number for hiding from selection.
Definition rail.h:28
RTF_NO_SPRITE_COMBINE
@ RTF_NO_SPRITE_COMBINE
Bit number for using non-combined junctions.
Definition rail.h:29
RTF_ALLOW_90DEG
@ RTF_ALLOW_90DEG
Bit number for always allowed 90 degree turns, regardless of setting.
Definition rail.h:30
RTF_DISALLOW_90DEG
@ RTF_DISALLOW_90DEG
Bit number for never allowed 90 degree turns, regardless of setting.
Definition rail.h:31
RTF_CATENARY
@ RTF_CATENARY
Bit number for drawing a catenary.
Definition rail.h:26
GetRailTypes
RailTypes GetRailTypes(bool introduces)
Get list of rail types, regardless of company availability.
Definition rail.cpp:282
GetRailFoundation
Foundation GetRailFoundation(Slope tileh, TrackBits bits)
Checks if a track combination is valid on a specific slope and returns the needed foundation.
Definition rail_cmd.cpp:312
RailNoLevelCrossings
bool RailNoLevelCrossings(RailType rt)
Test if a RailType disallows build of level crossings.
Definition rail.h:345
RailTypeFlags
RailTypeFlags
Railtype flags.
Definition rail.h:35
RTFB_NO_LEVEL_CROSSING
@ RTFB_NO_LEVEL_CROSSING
Value for disallowing level crossings.
Definition rail.h:38
RTFB_ALLOW_90DEG
@ RTFB_ALLOW_90DEG
Value for always allowed 90 degree turns, regardless of setting.
Definition rail.h:41
RTFB_DISALLOW_90DEG
@ RTFB_DISALLOW_90DEG
Value for never allowed 90 degree turns, regardless of setting.
Definition rail.h:42
RTFB_NO_SPRITE_COMBINE
@ RTFB_NO_SPRITE_COMBINE
Value for using non-combined junctions.
Definition rail.h:40
RTFB_CATENARY
@ RTFB_CATENARY
Value for drawing a catenary.
Definition rail.h:37
RTFB_NONE
@ RTFB_NONE
All flags cleared.
Definition rail.h:36
RTFB_HIDDEN
@ RTFB_HIDDEN
Value for hiding from selection.
Definition rail.h:39
GetRailTypeByLabel
RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels=true)
Get the rail type for a given label.
Definition rail.cpp:311
ValParamRailType
bool ValParamRailType(const RailType rail)
Validate functions for rail building.
Definition rail.cpp:206
rail_type.h
The different types of rail.
RailTypes
RailTypes
Allow incrementing of Track variables.
Definition rail_type.h:44
RailType
RailType
Enumeration for all possible railtypes.
Definition rail_type.h:27
RAILTYPE_END
@ RAILTYPE_END
Used for iterations.
Definition rail_type.h:33
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition rail_type.h:34
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:57
settings_type.h
Types related to global configuration settings.
signal_type.h
Types and classes related to signals.
slope_type.h
Definitions of a slope.
Slope
Slope
Enumeration for the slope-type.
Definition slope_type.h:48
Foundation
Foundation
Enumeration for Foundations.
Definition slope_type.h:93
strings_type.h
Types related to strings.
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:16
GRFFile
Dynamic data of a loaded NewGRF.
Definition newgrf.h:108
GameSettings::pf
PathfinderSettings pf
settings for all pathfinders
Definition settings_type.h:599
PathfinderSettings::forbid_90_deg
bool forbid_90_deg
forbid trains to make 90 deg turns
Definition settings_type.h:466
SpriteGroup
Definition newgrf_spritegroup.h:57
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition strong_typedef_type.hpp:150
Train
'Train' is either a loco or a wagon.
Definition train.h:89
timer_game_calendar.h
Definition of the game-calendar-timer.
track_type.h
All types related to tracks.
TrackBits
TrackBits
Allow incrementing of Track variables.
Definition track_type.h:35