OpenTTD Source: src/rail.h Source File

OpenTTD Source 13.2.1

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 "date_type.h"
21 #include "signal_type.h"
22 #include "settings_type.h"
23
25 enum RailTypeFlags {
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 RTFB_NONE = 0,
34 RTFB_CATENARY = 1 << RTF_CATENARY,
35 RTFB_NO_LEVEL_CROSSING = 1 << RTF_NO_LEVEL_CROSSING,
36 RTFB_HIDDEN = 1 << RTF_HIDDEN,
37 RTFB_NO_SPRITE_COMBINE = 1 << RTF_NO_SPRITE_COMBINE,
38 RTFB_ALLOW_90DEG = 1 << RTF_ALLOW_90DEG,
39 RTFB_DISALLOW_90DEG = 1 << RTF_DISALLOW_90DEG,
40 };
41 DECLARE_ENUM_AS_BIT_SET(RailTypeFlags)
42
43 struct SpriteGroup;
44
46 enum RailTypeSpriteGroup {
47 RTSG_CURSORS,
48 RTSG_OVERLAY,
49 RTSG_GROUND,
50 RTSG_TUNNEL,
51 RTSG_WIRES,
52 RTSG_PYLONS,
53 RTSG_BRIDGE,
54 RTSG_CROSSING,
55 RTSG_DEPOT,
56 RTSG_FENCES,
57 RTSG_TUNNEL_PORTAL,
58 RTSG_SIGNALS,
59 RTSG_GROUND_COMPLETE,
60 RTSG_END,
61 };
62
67 enum RailTrackOffset {
68 RTO_X,
69 RTO_Y,
70 RTO_N,
71 RTO_S,
72 RTO_E,
73 RTO_W,
74 RTO_SLOPE_NE,
75 RTO_SLOPE_SE,
76 RTO_SLOPE_SW,
77 RTO_SLOPE_NW,
78 RTO_CROSSING_XY,
79 RTO_JUNCTION_SW,
80 RTO_JUNCTION_NE,
81 RTO_JUNCTION_SE,
82 RTO_JUNCTION_NW,
83 RTO_JUNCTION_NSEW,
84 };
85
89 enum RailTrackBridgeOffset {
90 RTBO_X,
91 RTBO_Y,
92 RTBO_SLOPE,
93 };
94
99 enum RailFenceOffset {
100 RFO_FLAT_X_NW,
101 RFO_FLAT_Y_NE,
102 RFO_FLAT_LEFT,
103 RFO_FLAT_UPPER,
104 RFO_SLOPE_SW_NW,
105 RFO_SLOPE_SE_NE,
106 RFO_SLOPE_NE_NW,
107 RFO_SLOPE_NW_NE,
108 RFO_FLAT_X_SE,
109 RFO_FLAT_Y_SW,
110 RFO_FLAT_RIGHT,
111 RFO_FLAT_LOWER,
112 RFO_SLOPE_SW_SE,
113 RFO_SLOPE_SE_SW,
114 RFO_SLOPE_NE_SE,
115 RFO_SLOPE_NW_SW,
116 };
117
119 typedef std::vector<RailTypeLabel> RailTypeLabelList;
120
124 class RailtypeInfo {
125 public:
130 struct {
131 SpriteID track_y;
132 SpriteID track_ns;
133 SpriteID ground;
134 SpriteID single_x;
135 SpriteID single_y;
136 SpriteID single_n;
137 SpriteID single_s;
138 SpriteID single_e;
139 SpriteID single_w;
140 SpriteID single_sloped;
141 SpriteID crossing;
142 SpriteID tunnel;
143 } base_sprites;
144
149 struct {
150 SpriteID build_ns_rail;
151 SpriteID build_x_rail;
152 SpriteID build_ew_rail;
153 SpriteID build_y_rail;
154 SpriteID auto_rail;
155 SpriteID build_depot;
156 SpriteID build_tunnel;
157 SpriteID convert_rail;
158 SpriteID signals[SIGTYPE_END][2][2];
159 } gui_sprites;
160
161 struct {
162 CursorID rail_ns;
163 CursorID rail_swne;
164 CursorID rail_ew;
165 CursorID rail_nwse;
166 CursorID autorail;
167 CursorID depot;
168 CursorID tunnel;
169 CursorID convert;
170 } cursor;
171
172 struct {
173 StringID name;
174 StringID toolbar_caption;
175 StringID menu_text;
176 StringID build_caption;
177 StringID replace_text;
178 StringID new_loco;
179 } strings;
180
182 SpriteID snow_offset;
183
185 RailTypes powered_railtypes;
186
188 RailTypes compatible_railtypes;
189
193 SpriteID bridge_offset;
194
198 byte fallback_railtype;
199
203 byte curve_speed;
204
208 RailTypeFlags flags;
209
213 uint16 cost_multiplier;
214
218 uint16 maintenance_multiplier;
219
223 uint8 acceleration_type;
224
228 uint16 max_speed;
229
233 RailTypeLabel label;
234
238 RailTypeLabelList alternate_labels;
239
243 byte map_colour;
244
252 Date introduction_date;
253
258 RailTypes introduction_required_railtypes;
259
263 RailTypes introduces_railtypes;
264
268 byte sorting_order;
269
273 const GRFFile *grffile[RTSG_END];
274
278 const SpriteGroup *group[RTSG_END];
279
280 inline bool UsesOverlay() const
281 {
282 return this->group[RTSG_GROUND] != nullptr;
283 }
284
292 inline uint GetRailtypeSpriteOffset() const
293 {
294 return 82 * this->fallback_railtype;
295 }
296 };
297
298
304 static inline const RailtypeInfo *GetRailTypeInfo(RailType railtype)
305 {
306 extern RailtypeInfo _railtypes[RAILTYPE_END];
307 assert(railtype < RAILTYPE_END);
308 return &_railtypes[railtype];
309 }
310
319 static inline bool IsCompatibleRail(RailType enginetype, RailType tiletype)
320 {
321 return HasBit(GetRailTypeInfo(enginetype)->compatible_railtypes, tiletype);
322 }
323
332 static inline bool HasPowerOnRail(RailType enginetype, RailType tiletype)
333 {
334 return HasBit(GetRailTypeInfo(enginetype)->powered_railtypes, tiletype);
335 }
336
342 static inline bool RailNoLevelCrossings(RailType rt)
343 {
344 return HasBit(GetRailTypeInfo(rt)->flags, RTF_NO_LEVEL_CROSSING);
345 }
346
354 static inline bool Rail90DegTurnDisallowed(RailType rt1, RailType rt2, bool def = _settings_game.pf.forbid_90_deg)
355 {
356 if (rt1 == INVALID_RAILTYPE || rt2 == INVALID_RAILTYPE) return def;
357
358 const RailtypeInfo *rti1 = GetRailTypeInfo(rt1);
359 const RailtypeInfo *rti2 = GetRailTypeInfo(rt2);
360
361 bool rt1_90deg = HasBit(rti1->flags, RTF_DISALLOW_90DEG) || (!HasBit(rti1->flags, RTF_ALLOW_90DEG) && def);
362 bool rt2_90deg = HasBit(rti2->flags, RTF_DISALLOW_90DEG) || (!HasBit(rti2->flags, RTF_ALLOW_90DEG) && def);
363
364 return rt1_90deg || rt2_90deg;
365 }
366
372 static inline Money RailBuildCost(RailType railtype)
373 {
374 assert(railtype < RAILTYPE_END);
375 return (_price[PR_BUILD_RAIL] * GetRailTypeInfo(railtype)->cost_multiplier) >> 3;
376 }
377
383 static inline Money RailClearCost(RailType railtype)
384 {
385 /* Clearing rail in fact earns money, but if the build cost is set
386 * very low then a loophole exists where money can be made.
387 * In this case we limit the removal earnings to 3/4s of the build
388 * cost.
389 */
390 assert(railtype < RAILTYPE_END);
391 return std::max(_price[PR_CLEAR_RAIL], -RailBuildCost(railtype) * 3 / 4);
392 }
393
400 static inline Money RailConvertCost(RailType from, RailType to)
401 {
402 /* Get the costs for removing and building anew
403 * A conversion can never be more costly */
404 Money rebuildcost = RailBuildCost(to) + RailClearCost(from);
405
406 /* Conversion between somewhat compatible railtypes:
407 * Pay 1/8 of the target rail cost (labour costs) and additionally any difference in the
408 * build costs, if the target type is more expensive (material upgrade costs).
409 * Upgrade can never be more expensive than re-building. */
410 if (HasPowerOnRail(from, to) || HasPowerOnRail(to, from)) {
411 Money upgradecost = RailBuildCost(to) / 8 + std::max((Money)0, RailBuildCost(to) - RailBuildCost(from));
412 return std::min(upgradecost, rebuildcost);
413 }
414
415 /* make the price the same as remove + build new type for rail types
416 * which are not compatible in any way */
417 return rebuildcost;
418 }
419
427 static inline Money RailMaintenanceCost(RailType railtype, uint32 num, uint32 total_num)
428 {
429 assert(railtype < RAILTYPE_END);
430 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.
431 }
432
438 static inline Money SignalMaintenanceCost(uint32 num)
439 {
440 return (_price[PR_INFRASTRUCTURE_RAIL] * 15 * num * (1 + IntSqrt(num))) >> 8; // 1 bit fraction for the multiplier and 7 bits scaling.
441 }
442
443 void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
444 int TicksToLeaveDepot(const Train *v);
445
446 Foundation GetRailFoundation(Slope tileh, TrackBits bits);
447
448
449 bool HasRailtypeAvail(const CompanyID company, const RailType railtype);
450 bool HasAnyRailtypesAvail(const CompanyID company);
451 bool ValParamRailtype(const RailType rail);
452
453 RailTypes AddDateIntroducedRailTypes(RailTypes current, Date date);
454
455 RailTypes GetCompanyRailtypes(CompanyID company, bool introduces = true);
456 RailTypes GetRailTypes(bool introduces);
457
458 RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels = true);
459
460 void ResetRailTypes();
461 void InitRailTypes();
462 RailType AllocateRailType(RailTypeLabel label);
463
464 extern std::vector<RailType> _sorted_railtypes;
465 extern RailTypes _railtypes_hidden_mask;
466
467 #endif /* RAIL_H */
RailtypeInfo::rail_nwse
CursorID rail_nwse
Cursor for building rail in Y direction.
Definition: rail.h:165
RailNoLevelCrossings
static bool RailNoLevelCrossings(RailType rt)
Test if a RailType disallows build of level crossings.
Definition: rail.h:342
RTO_JUNCTION_SE
@ RTO_JUNCTION_SE
Ballast for junction 'pointing' SE.
Definition: rail.h:81
RailtypeInfo::track_ns
SpriteID track_ns
two pieces of rail in North and South corner (East-West direction)
Definition: rail.h:132
RTO_W
@ RTO_W
Piece of rail in western corner.
Definition: rail.h:73
RailtypeInfo::single_x
SpriteID single_x
single piece of rail in X direction, without ground
Definition: rail.h:134
RailtypeInfo::max_speed
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
Definition: rail.h:228
SignalMaintenanceCost
static Money SignalMaintenanceCost(uint32 num)
Calculates the maintenance cost of a number of signals.
Definition: rail.h:438
RFO_SLOPE_NW_SW
@ RFO_SLOPE_NW_SW
Slope NW, Track Y, Fence SW.
Definition: rail.h:115
RFO_SLOPE_SW_SE
@ RFO_SLOPE_SW_SE
Slope SW, Track X, Fence SE.
Definition: rail.h:112
RailFenceOffset
RailFenceOffset
Offsets from base sprite for fence sprites.
Definition: rail.h:99
RailtypeInfo::menu_text
StringID menu_text
Name of this rail type in the main toolbar dropdown.
Definition: rail.h:175
RailtypeInfo::single_n
SpriteID single_n
single piece of rail in the northern corner
Definition: rail.h:136
PathfinderSettings::forbid_90_deg
bool forbid_90_deg
forbid trains to make 90 deg turns
Definition: settings_type.h:462
RailtypeInfo::build_depot
SpriteID build_depot
button for building depots
Definition: rail.h:155
RailtypeInfo::convert
CursorID convert
Cursor for converting track.
Definition: rail.h:169
RTSG_CROSSING
@ RTSG_CROSSING
Level crossing overlay images.
Definition: rail.h:54
RailtypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: rail.h:177
RTSG_PYLONS
@ RTSG_PYLONS
Catenary pylons.
Definition: rail.h:52
RailTypeLabelList
std::vector< RailTypeLabel > RailTypeLabelList
List of rail type labels.
Definition: rail.h:119
RTSG_SIGNALS
@ RTSG_SIGNALS
Signal images.
Definition: rail.h:58
HasPowerOnRail
static 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:332
RailtypeInfo::single_y
SpriteID single_y
single piece of rail in Y direction, without ground
Definition: rail.h:135
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
RailtypeInfo::rail_swne
CursorID rail_swne
Cursor for building rail in X direction.
Definition: rail.h:163
ResetRailTypes
void ResetRailTypes()
Reset all rail type information to its default values.
Definition: rail_cmd.cpp:64
RTO_SLOPE_SW
@ RTO_SLOPE_SW
Piece of rail on slope with south-west raised.
Definition: rail.h:76
RailtypeInfo
This struct contains all the info that is needed to draw and construct tracks.
Definition: rail.h:124
RailtypeInfo::tunnel
CursorID tunnel
Cursor for building a tunnel.
Definition: rail.h:168
RailtypeInfo::grffile
const GRFFile * grffile[RTSG_END]
NewGRF providing the Action3 for the railtype.
Definition: rail.h:273
RailtypeInfo::build_tunnel
SpriteID build_tunnel
button for building a tunnel
Definition: rail.h:156
RailtypeInfo::depot
CursorID depot
Cursor for building a depot.
Definition: rail.h:167
RailtypeInfo::single_sloped
SpriteID single_sloped
single piece of rail for slopes
Definition: rail.h:140
IntSqrt
uint32 IntSqrt(uint32 num)
Compute the integer square root.
Definition: math_func.cpp:77
RailtypeInfo::auto_rail
SpriteID auto_rail
button for the autorail construction
Definition: rail.h:154
GetCompanyRailtypes
RailTypes GetCompanyRailtypes(CompanyID company, bool introduces=true)
Get the rail types the given company can build.
Definition: rail.cpp:251
HasAnyRailtypesAvail
bool HasAnyRailtypesAvail(const CompanyID company)
Test if any buildable railtype is available for a company.
Definition: rail.cpp:196
Rail90DegTurnDisallowed
static 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:354
RFO_SLOPE_SW_NW
@ RFO_SLOPE_SW_NW
Slope SW, Track X, Fence NW.
Definition: rail.h:104
economy_func.h
RailtypeInfo::fallback_railtype
byte fallback_railtype
Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.
Definition: rail.h:198
strings_type.h
RailtypeInfo::build_ns_rail
SpriteID build_ns_rail
button for building single rail in N-S direction
Definition: rail.h:150
RTFB_HIDDEN
@ RTFB_HIDDEN
Value for hiding from selection.
Definition: rail.h:36
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
RailClearCost
static Money RailClearCost(RailType railtype)
Returns the 'cost' of clearing the specified railtype.
Definition: rail.h:383
RFO_SLOPE_SE_SW
@ RFO_SLOPE_SE_SW
Slope SE, Track Y, Fence SW.
Definition: rail.h:113
RailTrackBridgeOffset
RailTrackBridgeOffset
Offsets for sprites within a bridge surface overlay set.
Definition: rail.h:89
Foundation
Foundation
Enumeration for Foundations.
Definition: slope_type.h:93
RailtypeInfo::sorting_order
byte sorting_order
The sorting order of this railtype for the toolbar dropdown.
Definition: rail.h:268
RailTypeSpriteGroup
RailTypeSpriteGroup
Sprite groups for a railtype.
Definition: rail.h:46
RTO_JUNCTION_NE
@ RTO_JUNCTION_NE
Ballast for junction 'pointing' NE.
Definition: rail.h:80
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
RTO_SLOPE_NE
@ RTO_SLOPE_NE
Piece of rail on slope with north-east raised.
Definition: rail.h:74
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:258
RailtypeInfo::name
StringID name
Name of this rail type.
Definition: rail.h:173
GetRailTypeInfo
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:304
RailtypeInfo::build_x_rail
SpriteID build_x_rail
button for building single rail in X direction
Definition: rail.h:151
RailtypeInfo::rail_ns
CursorID rail_ns
Cursor for building rail in N-S direction.
Definition: rail.h:162
RTFB_CATENARY
@ RTFB_CATENARY
Value for drawing a catenary.
Definition: rail.h:34
Slope
Slope
Enumeration for the slope-type.
Definition: slope_type.h:48
RTBO_Y
@ RTBO_Y
Piece of rail in Y direction.
Definition: rail.h:91
bitmath_func.hpp
GameSettings::pf
PathfinderSettings pf
settings for all pathfinders
Definition: settings_type.h:593
RTO_N
@ RTO_N
Piece of rail in northern corner.
Definition: rail.h:70
RailtypeInfo::single_w
SpriteID single_w
single piece of rail in the western corner
Definition: rail.h:139
RailtypeInfo::gui_sprites
struct RailtypeInfo::@37 gui_sprites
struct containing the sprites for the rail GUI.
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
RailtypeInfo::tunnel
SpriteID tunnel
tunnel sprites base
Definition: rail.h:142
RTF_CATENARY
@ RTF_CATENARY
Bit number for drawing a catenary.
Definition: rail.h:26
RTSG_GROUND_COMPLETE
@ RTSG_GROUND_COMPLETE
Complete ground images.
Definition: rail.h:59
CursorID
uint32 CursorID
The number of the cursor (sprite)
Definition: gfx_type.h:19
RTF_HIDDEN
@ RTF_HIDDEN
Bit number for hiding from selection.
Definition: rail.h:28
RTSG_BRIDGE
@ RTSG_BRIDGE
Bridge surface images.
Definition: rail.h:53
AddDateIntroducedRailTypes
RailTypes AddDateIntroducedRailTypes(RailTypes current, Date date)
Add the rail types that are to be introduced at the given date.
Definition: rail.cpp:218
RTO_CROSSING_XY
@ RTO_CROSSING_XY
Crossing of X and Y rail, with ballast.
Definition: rail.h:78
RTFB_DISALLOW_90DEG
@ RTFB_DISALLOW_90DEG
Value for never allowed 90 degree turns, regardless of setting.
Definition: rail.h:39
RailtypeInfo::alternate_labels
RailTypeLabelList alternate_labels
Rail type labels this type provides in addition to the main label.
Definition: rail.h:238
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:182
RailtypeInfo::base_sprites
struct RailtypeInfo::@36 base_sprites
Struct containing the main sprites.
RTF_DISALLOW_90DEG
@ RTF_DISALLOW_90DEG
Bit number for never allowed 90 degree turns, regardless of setting.
Definition: rail.h:31
RailtypeInfo::track_y
SpriteID track_y
single piece of rail in Y direction, with ground
Definition: rail.h:131
RTO_SLOPE_SE
@ RTO_SLOPE_SE
Piece of rail on slope with south-east raised.
Definition: rail.h:75
RTSG_FENCES
@ RTSG_FENCES
Fence images.
Definition: rail.h:56
RailConvertCost
static Money RailConvertCost(RailType from, RailType to)
Calculates the cost of rail conversion.
Definition: rail.h:400
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
ValParamRailtype
bool ValParamRailtype(const RailType rail)
Validate functions for rail building.
Definition: rail.cpp:206
RailtypeInfo::introduction_date
Date introduction_date
Introduction date.
Definition: rail.h:252
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:54
RailtypeInfo::autorail
CursorID autorail
Cursor for autorail tool.
Definition: rail.h:166
RFO_SLOPE_NE_NW
@ RFO_SLOPE_NE_NW
Slope NE, Track X, Fence NW.
Definition: rail.h:106
RailBuildCost
static Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
Definition: rail.h:372
RTSG_CURSORS
@ RTSG_CURSORS
Cursor and toolbar icon images.
Definition: rail.h:47
RTFB_ALLOW_90DEG
@ RTFB_ALLOW_90DEG
Value for always allowed 90 degree turns, regardless of setting.
Definition: rail.h:38
Train
'Train' is either a loco or a wagon.
Definition: train.h:89
GetRailTypeByLabel
RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels=true)
Get the rail type for a given label.
Definition: rail.cpp:311
RFO_FLAT_LEFT
@ RFO_FLAT_LEFT
Slope FLAT, Track LEFT, Fence E.
Definition: rail.h:102
settings_type.h
RTSG_GROUND
@ RTSG_GROUND
Main group of ground images.
Definition: rail.h:49
RailMaintenanceCost
static Money RailMaintenanceCost(RailType railtype, uint32 num, uint32 total_num)
Calculates the maintenance cost of a number of track bits.
Definition: rail.h:427
RTBO_SLOPE
@ RTBO_SLOPE
Sloped rail pieces, in order NE, SE, SW, NW.
Definition: rail.h:92
RailtypeInfo::toolbar_caption
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
Definition: rail.h:174
RTSG_OVERLAY
@ RTSG_OVERLAY
Images for overlaying track.
Definition: rail.h:48
RailtypeInfo::powered_railtypes
RailTypes powered_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype generates power
Definition: rail.h:185
RailtypeInfo::map_colour
byte map_colour
Colour on mini-map.
Definition: rail.h:243
date_type.h
RTSG_TUNNEL
@ RTSG_TUNNEL
Main group of ground images for snow or desert.
Definition: rail.h:50
RTFB_NO_SPRITE_COMBINE
@ RTFB_NO_SPRITE_COMBINE
Value for using non-combined junctions.
Definition: rail.h:37
RailtypeInfo::acceleration_type
uint8 acceleration_type
Acceleration type of this rail type.
Definition: rail.h:223
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
RFO_FLAT_X_NW
@ RFO_FLAT_X_NW
Slope FLAT, Track X, Fence NW.
Definition: rail.h:100
RFO_SLOPE_SE_NE
@ RFO_SLOPE_SE_NE
Slope SE, Track Y, Fence NE.
Definition: rail.h:105
IsCompatibleRail
static 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:319
signal_type.h
AllocateRailType
RailType AllocateRailType(RailTypeLabel label)
Allocate a new rail type label.
Definition: rail_cmd.cpp:159
RTSG_WIRES
@ RTSG_WIRES
Catenary wires.
Definition: rail.h:51
RailtypeInfo::flags
RailTypeFlags flags
Bit mask of rail type flags.
Definition: rail.h:208
RTBO_X
@ RTBO_X
Piece of rail in X direction.
Definition: rail.h:90
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:322
RFO_FLAT_UPPER
@ RFO_FLAT_UPPER
Slope FLAT, Track UPPER, Fence S.
Definition: rail.h:103
RailTrackOffset
RailTrackOffset
Offsets for sprites within an overlay/underlay set.
Definition: rail.h:67
RAILTYPE_END
@ RAILTYPE_END
Used for iterations.
Definition: rail_type.h:33
RFO_SLOPE_NE_SE
@ RFO_SLOPE_NE_SE
Slope NE, Track X, Fence SE.
Definition: rail.h:114
RTO_X
@ RTO_X
Piece of rail in X direction.
Definition: rail.h:68
RTSG_DEPOT
@ RTSG_DEPOT
Depot images.
Definition: rail.h:55
RTO_JUNCTION_NSEW
@ RTO_JUNCTION_NSEW
Ballast for full junction.
Definition: rail.h:83
RailTypeFlags
RailTypeFlags
Railtype flags.
Definition: rail.h:25
RailtypeInfo::label
RailTypeLabel label
Unique 32 bit rail type identifier.
Definition: rail.h:233
RTF_ALLOW_90DEG
@ RTF_ALLOW_90DEG
Bit number for always allowed 90 degree turns, regardless of setting.
Definition: rail.h:30
RTFB_NONE
@ RTFB_NONE
All flags cleared.
Definition: rail.h:33
GetRailTypes
RailTypes GetRailTypes(bool introduces)
Get list of rail types, regardless of company availability.
Definition: rail.cpp:282
RTO_Y
@ RTO_Y
Piece of rail in Y direction.
Definition: rail.h:69
RailtypeInfo::build_caption
StringID build_caption
Caption of the build vehicle GUI for this rail type.
Definition: rail.h:176
RailtypeInfo::single_e
SpriteID single_e
single piece of rail in the eastern corner
Definition: rail.h:138
RTO_SLOPE_NW
@ RTO_SLOPE_NW
Piece of rail on slope with north-west raised.
Definition: rail.h:77
RTO_E
@ RTO_E
Piece of rail in eastern corner.
Definition: rail.h:72
RTF_NO_SPRITE_COMBINE
@ RTF_NO_SPRITE_COMBINE
Bit number for using non-combined junctions.
Definition: rail.h:29
rail_type.h
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
RailtypeInfo::build_ew_rail
SpriteID build_ew_rail
button for building single rail in E-W direction
Definition: rail.h:152
TrackBits
TrackBits
Bitfield corresponding to Track.
Definition: track_type.h:38
TicksToLeaveDepot
int TicksToLeaveDepot(const Train *v)
Compute number of ticks when next wagon will leave a depot.
Definition: rail_cmd.cpp:2902
RFO_SLOPE_NW_NE
@ RFO_SLOPE_NW_NE
Slope NW, Track Y, Fence NE.
Definition: rail.h:107
RTF_NO_LEVEL_CROSSING
@ RTF_NO_LEVEL_CROSSING
Bit number for disallowing level crossings.
Definition: rail.h:27
RailtypeInfo::new_loco
StringID new_loco
Name of an engine for this type of rail in the engine preview GUI.
Definition: rail.h:178
RailtypeInfo::compatible_railtypes
RailTypes compatible_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel
Definition: rail.h:188
OverflowSafeInt< int64 >
HasRailtypeAvail
bool HasRailtypeAvail(const CompanyID company, const RailType railtype)
Finds out if a company has a certain buildable railtype available.
Definition: rail.cpp:186
RailtypeInfo::cursor
struct RailtypeInfo::@38 cursor
Cursors associated with the rail type.
RailtypeInfo::single_s
SpriteID single_s
single piece of rail in the southern corner
Definition: rail.h:137
RFO_FLAT_Y_SW
@ RFO_FLAT_Y_SW
Slope FLAT, Track Y, Fence SW.
Definition: rail.h:109
RailtypeInfo::maintenance_multiplier
uint16 maintenance_multiplier
Cost multiplier for maintenance of this rail type.
Definition: rail.h:218
RFO_FLAT_X_SE
@ RFO_FLAT_X_SE
Slope FLAT, Track X, Fence SE.
Definition: rail.h:108
RTO_S
@ RTO_S
Piece of rail in southern corner.
Definition: rail.h:71
RFO_FLAT_RIGHT
@ RFO_FLAT_RIGHT
Slope FLAT, Track RIGHT, Fence W.
Definition: rail.h:110
RailtypeInfo::crossing
SpriteID crossing
level crossing, rail in X direction
Definition: rail.h:141
RailtypeInfo::group
const SpriteGroup * group[RTSG_END]
Sprite groups for resolving sprites.
Definition: rail.h:278
RailtypeInfo::rail_ew
CursorID rail_ew
Cursor for building rail in E-W direction.
Definition: rail.h:164
RailtypeInfo::strings
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
RailtypeInfo::cost_multiplier
uint16 cost_multiplier
Cost multiplier for building this rail type.
Definition: rail.h:213
RailtypeInfo::build_y_rail
SpriteID build_y_rail
button for building single rail in Y direction
Definition: rail.h:153
RailtypeInfo::signals
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
Definition: rail.h:158
slope_type.h
gfx_type.h
RailTypes
RailTypes
The different railtypes we support, but then a bitmask of them.
Definition: rail_type.h:46
InitRailTypes
void InitRailTypes()
Resolve sprites of custom rail types.
Definition: rail_cmd.cpp:139
RTO_JUNCTION_SW
@ RTO_JUNCTION_SW
Ballast for junction 'pointing' SW.
Definition: rail.h:79
RFO_FLAT_Y_NE
@ RFO_FLAT_Y_NE
Slope FLAT, Track Y, Fence NE.
Definition: rail.h:101
RailtypeInfo::curve_speed
byte curve_speed
Multiplier for curve maximum speed advantage.
Definition: rail.h:203
RailtypeInfo::ground
SpriteID ground
ground sprite for a 3-way switch
Definition: rail.h:133
SpriteGroup
Definition: newgrf_spritegroup.h:57
RailtypeInfo::GetRailtypeSpriteOffset
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
Definition: rail.h:292
track_type.h
GRFFile
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:106
RFO_FLAT_LOWER
@ RFO_FLAT_LOWER
Slope FLAT, Track LOWER, Fence N.
Definition: rail.h:111
RailtypeInfo::bridge_offset
SpriteID bridge_offset
Bridge offset.
Definition: rail.h:193
RailtypeInfo::convert_rail
SpriteID convert_rail
button for converting rail
Definition: rail.h:157
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition: rail_type.h:34
RTFB_NO_LEVEL_CROSSING
@ RTFB_NO_LEVEL_CROSSING
Value for disallowing level crossings.
Definition: rail.h:35
RailtypeInfo::introduces_railtypes
RailTypes introduces_railtypes
Bitmask of which other railtypes are introduced when this railtype is introduced.
Definition: rail.h:263
RTSG_TUNNEL_PORTAL
@ RTSG_TUNNEL_PORTAL
Tunnel portal overlay.
Definition: rail.h:57
RTO_JUNCTION_NW
@ RTO_JUNCTION_NW
Ballast for junction 'pointing' NW.
Definition: rail.h:82