OpenTTD

rail.h
Go to the documentation of this file.
1 /* $Id: rail.h 27687 2016-12-10 13:26:29Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #ifndef RAIL_H
13 #define RAIL_H
14
15 #include "rail_type.h"
16 #include "track_type.h"
17 #include "gfx_type.h"
18 #include "core/bitmath_func.hpp"
19 #include "economy_func.h"
20 #include "slope_type.h"
21 #include "strings_type.h"
22 #include "date_type.h"
23 #include "signal_type.h"
24
26 enum RailTypeFlags {
27 RTF_CATENARY = 0,
28 RTF_NO_LEVEL_CROSSING = 1,
29
30 RTFB_NONE = 0,
31 RTFB_CATENARY = 1 << RTF_CATENARY,
32 RTFB_NO_LEVEL_CROSSING = 1 << RTF_NO_LEVEL_CROSSING,
33 };
34 DECLARE_ENUM_AS_BIT_SET(RailTypeFlags)
35
36 struct SpriteGroup;
37
39 enum RailTypeSpriteGroup {
40 RTSG_CURSORS,
41 RTSG_OVERLAY,
42 RTSG_GROUND,
43 RTSG_TUNNEL,
44 RTSG_WIRES,
45 RTSG_PYLONS,
46 RTSG_BRIDGE,
47 RTSG_CROSSING,
48 RTSG_DEPOT,
49 RTSG_FENCES,
50 RTSG_TUNNEL_PORTAL,
51 RTSG_SIGNALS,
52 RTSG_END,
53 };
54
59 enum RailTrackOffset {
60 RTO_X,
61 RTO_Y,
62 RTO_N,
63 RTO_S,
64 RTO_E,
65 RTO_W,
66 RTO_SLOPE_NE,
67 RTO_SLOPE_SE,
68 RTO_SLOPE_SW,
69 RTO_SLOPE_NW,
70 RTO_CROSSING_XY,
71 RTO_JUNCTION_SW,
72 RTO_JUNCTION_NE,
73 RTO_JUNCTION_SE,
74 RTO_JUNCTION_NW,
75 RTO_JUNCTION_NSEW,
76 };
77
81 enum RailTrackBridgeOffset {
82 RTBO_X,
83 RTBO_Y,
84 RTBO_SLOPE,
85 };
86
91 enum RailFenceOffset {
92 RFO_FLAT_X_NW,
93 RFO_FLAT_Y_NE,
94 RFO_FLAT_LEFT,
95 RFO_FLAT_UPPER,
96 RFO_SLOPE_SW_NW,
97 RFO_SLOPE_SE_NE,
98 RFO_SLOPE_NE_NW,
99 RFO_SLOPE_NW_NE,
100 RFO_FLAT_X_SE,
101 RFO_FLAT_Y_SW,
102 RFO_FLAT_RIGHT,
103 RFO_FLAT_LOWER,
104 RFO_SLOPE_SW_SE,
105 RFO_SLOPE_SE_SW,
106 RFO_SLOPE_NE_SE,
107 RFO_SLOPE_NW_SW,
108 };
109
111 typedef SmallVector<RailTypeLabel, 4> RailTypeLabelList;
112
116 class RailtypeInfo {
117 public:
122 struct {
123 SpriteID track_y;
124 SpriteID track_ns;
125 SpriteID ground;
126 SpriteID single_x;
127 SpriteID single_y;
128 SpriteID single_n;
129 SpriteID single_s;
130 SpriteID single_e;
131 SpriteID single_w;
132 SpriteID single_sloped;
133 SpriteID crossing;
134 SpriteID tunnel;
135 } base_sprites;
136
141 struct {
142 SpriteID build_ns_rail;
143 SpriteID build_x_rail;
144 SpriteID build_ew_rail;
145 SpriteID build_y_rail;
146 SpriteID auto_rail;
147 SpriteID build_depot;
148 SpriteID build_tunnel;
149 SpriteID convert_rail;
150 SpriteID signals[SIGTYPE_END][2][2];
151 } gui_sprites;
152
153 struct {
154 CursorID rail_ns;
155 CursorID rail_swne;
156 CursorID rail_ew;
157 CursorID rail_nwse;
158 CursorID autorail;
159 CursorID depot;
160 CursorID tunnel;
161 CursorID convert;
162 } cursor;
163
164 struct {
165 StringID name;
166 StringID toolbar_caption;
167 StringID menu_text;
168 StringID build_caption;
169 StringID replace_text;
170 StringID new_loco;
171 } strings;
172
174 SpriteID snow_offset;
175
177 RailTypes powered_railtypes;
178
180 RailTypes compatible_railtypes;
181
185 SpriteID bridge_offset;
186
190 byte fallback_railtype;
191
195 byte curve_speed;
196
200 RailTypeFlags flags;
201
205 uint16 cost_multiplier;
206
210 uint16 maintenance_multiplier;
211
215 uint8 acceleration_type;
216
220 uint16 max_speed;
221
225 RailTypeLabel label;
226
230 RailTypeLabelList alternate_labels;
231
235 byte map_colour;
236
244 Date introduction_date;
245
250 RailTypes introduction_required_railtypes;
251
255 RailTypes introduces_railtypes;
256
260 byte sorting_order;
261
265 const GRFFile *grffile[RTSG_END];
266
270 const SpriteGroup *group[RTSG_END];
271
272 inline bool UsesOverlay() const
273 {
274 return this->group[RTSG_GROUND] != NULL;
275 }
276
284 inline uint GetRailtypeSpriteOffset() const
285 {
286 return 82 * this->fallback_railtype;
287 }
288 };
289
290
296 static inline const RailtypeInfo *GetRailTypeInfo(RailType railtype)
297 {
298 extern RailtypeInfo _railtypes[RAILTYPE_END];
299 assert(railtype < RAILTYPE_END);
300 return &_railtypes[railtype];
301 }
302
311 static inline bool IsCompatibleRail(RailType enginetype, RailType tiletype)
312 {
313 return HasBit(GetRailTypeInfo(enginetype)->compatible_railtypes, tiletype);
314 }
315
324 static inline bool HasPowerOnRail(RailType enginetype, RailType tiletype)
325 {
326 return HasBit(GetRailTypeInfo(enginetype)->powered_railtypes, tiletype);
327 }
328
334 static inline bool RailNoLevelCrossings(RailType rt)
335 {
336 return HasBit(GetRailTypeInfo(rt)->flags, RTF_NO_LEVEL_CROSSING);
337 }
338
344 static inline Money RailBuildCost(RailType railtype)
345 {
346 assert(railtype < RAILTYPE_END);
347 return (_price[PR_BUILD_RAIL] * GetRailTypeInfo(railtype)->cost_multiplier) >> 3;
348 }
349
355 static inline Money RailClearCost(RailType railtype)
356 {
357 /* Clearing rail in fact earns money, but if the build cost is set
358 * very low then a loophole exists where money can be made.
359 * In this case we limit the removal earnings to 3/4s of the build
360 * cost.
361 */
362 assert(railtype < RAILTYPE_END);
363 return max(_price[PR_CLEAR_RAIL], -RailBuildCost(railtype) * 3 / 4);
364 }
365
372 static inline Money RailConvertCost(RailType from, RailType to)
373 {
374 /* Get the costs for removing and building anew
375 * A conversion can never be more costly */
376 Money rebuildcost = RailBuildCost(to) + RailClearCost(from);
377
378 /* Conversion between somewhat compatible railtypes:
379 * Pay 1/8 of the target rail cost (labour costs) and additionally any difference in the
380 * build costs, if the target type is more expensive (material upgrade costs).
381 * Upgrade can never be more expensive than re-building. */
382 if (HasPowerOnRail(from, to) || HasPowerOnRail(to, from)) {
383 Money upgradecost = RailBuildCost(to) / 8 + max((Money)0, RailBuildCost(to) - RailBuildCost(from));
384 return min(upgradecost, rebuildcost);
385 }
386
387 /* make the price the same as remove + build new type for rail types
388 * which are not compatible in any way */
389 return rebuildcost;
390 }
391
399 static inline Money RailMaintenanceCost(RailType railtype, uint32 num, uint32 total_num)
400 {
401 assert(railtype < RAILTYPE_END);
402 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.
403 }
404
410 static inline Money SignalMaintenanceCost(uint32 num)
411 {
412 return (_price[PR_INFRASTRUCTURE_RAIL] * 15 * num * (1 + IntSqrt(num))) >> 8; // 1 bit fraction for the multiplier and 7 bits scaling.
413 }
414
415 void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
416 int TicksToLeaveDepot(const Train *v);
417
418 Foundation GetRailFoundation(Slope tileh, TrackBits bits);
419
420
421 bool HasRailtypeAvail(const CompanyID company, const RailType railtype);
422 bool ValParamRailtype(const RailType rail);
423
424 RailTypes AddDateIntroducedRailTypes(RailTypes current, Date date);
425
426 RailType GetBestRailtype(const CompanyID company);
427 RailTypes GetCompanyRailtypes(const CompanyID c);
428
429 RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels = true);
430
431 void ResetRailTypes();
432 void InitRailTypes();
433 RailType AllocateRailType(RailTypeLabel label);
434
435 extern RailType _sorted_railtypes[RAILTYPE_END];
436 extern uint8 _sorted_railtypes_size;
437
442 #define FOR_ALL_SORTED_RAILTYPES(var) for (uint8 index = 0; index < _sorted_railtypes_size && (var = _sorted_railtypes[index], true) ; index++)
443
444 #endif /* RAIL_H */
track_type.h
All types related to tracks.
RAILTYPE_END
Used for iterations.
Definition: rail_type.h:35
RTO_SLOPE_NW
Piece of rail on slope with north-west raised.
Definition: rail.h:69
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:324
RailtypeInfo::crossing
SpriteID crossing
level crossing, rail in X direction
Definition: rail.h:133
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:31
RailtypeInfo::group
const SpriteGroup * group[RTSG_END]
Sprite groups for resolving sprites.
Definition: rail.h:270
RailtypeInfo::base_sprites
struct RailtypeInfo::@36 base_sprites
Struct containing the main sprites.
RailTypeFlags
RailTypeFlags
Railtype flags.
Definition: rail.h:26
GetRailTypeInfo
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:296
RailTypes
RailTypes
The different roadtypes we support, but then a bitmask of them.
Definition: rail_type.h:52
RailtypeInfo::grffile
const GRFFile * grffile[RTSG_END]
NewGRF providing the Action3 for the railtype.
Definition: rail.h:265
slope_type.h
Definitions of a slope.
RFO_SLOPE_NW_NE
Slope NW, Track Y, Fence NE.
Definition: rail.h:99
RailConvertCost
static Money RailConvertCost(RailType from, RailType to)
Calculates the cost of rail conversion.
Definition: rail.h:372
RailtypeInfo::single_sloped
SpriteID single_sloped
single piece of rail for slopes
Definition: rail.h:132
RailtypeInfo::auto_rail
SpriteID auto_rail
button for the autorail construction
Definition: rail.h:146
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:29
RailtypeInfo::toolbar_caption
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
Definition: rail.h:166
RFO_FLAT_Y_NE
Slope FLAT, Track Y, Fence NE.
Definition: rail.h:93
TicksToLeaveDepot
int TicksToLeaveDepot(const Train *v)
Compute number of ticks when next wagon will leave a depot.
Definition: rail_cmd.cpp:2889
RailtypeInfo::curve_speed
byte curve_speed
Multiplier for curve maximum speed advantage.
Definition: rail.h:195
RailtypeInfo::build_y_rail
SpriteID build_y_rail
button for building single rail in Y direction
Definition: rail.h:145
RTO_S
Piece of rail in southern corner.
Definition: rail.h:63
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:250
RailtypeInfo::flags
RailTypeFlags flags
Bit mask of rail type flags.
Definition: rail.h:200
RTSG_BRIDGE
Bridge surface images.
Definition: rail.h:46
RTO_JUNCTION_NE
Ballast for junction &#39;pointing&#39; NE.
Definition: rail.h:72
RTO_JUNCTION_NW
Ballast for junction &#39;pointing&#39; NW.
Definition: rail.h:74
ValParamRailtype
bool ValParamRailtype(const RailType rail)
Validate functions for rail building.
Definition: rail.cpp:198
GetCompanyRailtypes
RailTypes GetCompanyRailtypes(const CompanyID c)
Get the rail types the given company can build.
Definition: rail.cpp:257
RTO_SLOPE_NE
Piece of rail on slope with north-east raised.
Definition: rail.h:66
RTO_W
Piece of rail in western corner.
Definition: rail.h:65
RailtypeInfo::single_e
SpriteID single_e
single piece of rail in the eastern corner
Definition: rail.h:130
RTSG_FENCES
Fence images.
Definition: rail.h:49
RailtypeInfo::alternate_labels
RailTypeLabelList alternate_labels
Rail type labels this type provides in addition to the main label.
Definition: rail.h:230
SignalMaintenanceCost
static Money SignalMaintenanceCost(uint32 num)
Calculates the maintenance cost of a number of signals.
Definition: rail.h:410
bitmath_func.hpp
Functions related to bit mathematics.
RFO_FLAT_LOWER
Slope FLAT, Track LOWER, Fence N.
Definition: rail.h:103
RailtypeInfo::cursor
struct RailtypeInfo::@38 cursor
Cursors associated with the rail type.
SmallVector< RailTypeLabel, 4 >
RailtypeInfo::compatible_railtypes
RailTypes compatible_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel ...
Definition: rail.h:180
RFO_FLAT_LEFT
Slope FLAT, Track LEFT, Fence E.
Definition: rail.h:94
RailtypeInfo::autorail
CursorID autorail
Cursor for autorail tool.
Definition: rail.h:158
max
static T max(const T a, const T b)
Returns the maximum of two values.
Definition: math_func.hpp:26
RailNoLevelCrossings
static bool RailNoLevelCrossings(RailType rt)
Test if a RailType disallows build of level crossings.
Definition: rail.h:334
RailtypeInfo::strings
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
RailtypeInfo::track_y
SpriteID track_y
single piece of rail in Y direction, with ground
Definition: rail.h:123
RailtypeInfo::menu_text
StringID menu_text
Name of this rail type in the main toolbar dropdown.
Definition: rail.h:167
RailtypeInfo::new_loco
StringID new_loco
Name of an engine for this type of rail in the engine preview GUI.
Definition: rail.h:170
RailtypeInfo::rail_ew
CursorID rail_ew
Cursor for building rail in E-W direction.
Definition: rail.h:156
RTSG_PYLONS
Catenary pylons.
Definition: rail.h:45
RailtypeInfo::build_caption
StringID build_caption
Caption of the build vehicle GUI for this rail type.
Definition: rail.h:168
RailtypeInfo
This struct contains all the info that is needed to draw and construct tracks.
Definition: rail.h:116
RailtypeInfo::signals
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
Definition: rail.h:150
RailFenceOffset
RailFenceOffset
Offsets from base sprite for fence sprites.
Definition: rail.h:91
RailtypeInfo::single_y
SpriteID single_y
single piece of rail in Y direction, without ground
Definition: rail.h:127
TrackBits
TrackBits
Bitfield corresponding to Track.
Definition: track_type.h:41
RailtypeInfo::tunnel
CursorID tunnel
Cursor for building a tunnel.
Definition: rail.h:160
signal_type.h
Types and classes related to signals.
Foundation
Foundation
Enumeration for Foundations.
Definition: slope_type.h:95
RailtypeInfo::ground
SpriteID ground
ground sprite for a 3-way switch
Definition: rail.h:125
AllocateRailType
RailType AllocateRailType(RailTypeLabel label)
Allocate a new rail type label.
Definition: rail_cmd.cpp:157
RTBO_SLOPE
Sloped rail pieces, in order NE, SE, SW, NW.
Definition: rail.h:84
RTBO_X
Piece of rail in X direction.
Definition: rail.h:82
RTSG_CROSSING
Level crossing overlay images.
Definition: rail.h:47
RTSG_OVERLAY
Images for overlaying track.
Definition: rail.h:41
RFO_SLOPE_SE_SW
Slope SE, Track Y, Fence SW.
Definition: rail.h:105
RFO_FLAT_UPPER
Slope FLAT, Track UPPER, Fence S.
Definition: rail.h:95
RTO_SLOPE_SW
Piece of rail on slope with south-west raised.
Definition: rail.h:68
RTO_X
Piece of rail in X direction.
Definition: rail.h:60
RailtypeInfo::build_ns_rail
SpriteID build_ns_rail
button for building single rail in N-S direction
Definition: rail.h:142
RailtypeInfo::acceleration_type
uint8 acceleration_type
Acceleration type of this rail type.
Definition: rail.h:215
SpriteGroup
Definition: newgrf_spritegroup.h:58
RailtypeInfo::introduces_railtypes
RailTypes introduces_railtypes
Bitmask of which other railtypes are introduced when this railtype is introduced. ...
Definition: rail.h:255
RailtypeInfo::sorting_order
byte sorting_order
The sorting order of this railtype for the toolbar dropdown.
Definition: rail.h:260
RTFB_CATENARY
Value for drawing a catenary.
Definition: rail.h:31
RFO_SLOPE_SW_NW
Slope SW, Track X, Fence NW.
Definition: rail.h:96
RailtypeInfo::max_speed
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
Definition: rail.h:220
RailtypeInfo::single_w
SpriteID single_w
single piece of rail in the western corner
Definition: rail.h:131
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:328
HasRailtypeAvail
bool HasRailtypeAvail(const CompanyID company, const RailType railtype)
Finds out if a company has a certain railtype available.
Definition: rail.cpp:188
RailtypeInfo::rail_nwse
CursorID rail_nwse
Cursor for building rail in Y direction.
Definition: rail.h:157
RTF_CATENARY
Bit number for drawing a catenary.
Definition: rail.h:27
RTO_CROSSING_XY
Crossing of X and Y rail, with ballast.
Definition: rail.h:70
RailtypeInfo::single_x
SpriteID single_x
single piece of rail in X direction, without ground
Definition: rail.h:126
RailtypeInfo::convert_rail
SpriteID convert_rail
button for converting rail
Definition: rail.h:149
RailClearCost
static Money RailClearCost(RailType railtype)
Returns the &#39;cost&#39; of clearing the specified railtype.
Definition: rail.h:355
RTSG_DEPOT
Depot images.
Definition: rail.h:48
RailTrackBridgeOffset
RailTrackBridgeOffset
Offsets for sprites within a bridge surface overlay set.
Definition: rail.h:81
min
static T min(const T a, const T b)
Returns the minimum of two values.
Definition: math_func.hpp:42
RailtypeInfo::label
RailTypeLabel label
Unique 32 bit rail type identifier.
Definition: rail.h:225
RTFB_NONE
All flags cleared.
Definition: rail.h:30
RTO_Y
Piece of rail in Y direction.
Definition: rail.h:61
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
RTO_SLOPE_SE
Piece of rail on slope with south-east raised.
Definition: rail.h:67
RTBO_Y
Piece of rail in Y direction.
Definition: rail.h:83
RFO_FLAT_X_SE
Slope FLAT, Track X, Fence SE.
Definition: rail.h:100
RailtypeInfo::single_n
SpriteID single_n
single piece of rail in the northern corner
Definition: rail.h:128
RTO_E
Piece of rail in eastern corner.
Definition: rail.h:64
RailtypeInfo::single_s
SpriteID single_s
single piece of rail in the southern corner
Definition: rail.h:129
RTO_N
Piece of rail in northern corner.
Definition: rail.h:62
RailtypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: rail.h:169
RFO_SLOPE_NE_NW
Slope NE, Track X, Fence NW.
Definition: rail.h:98
RailtypeInfo::build_depot
SpriteID build_depot
button for building depots
Definition: rail.h:147
Train
&#39;Train&#39; is either a loco or a wagon.
Definition: train.h:88
RailtypeInfo::depot
CursorID depot
Cursor for building a depot.
Definition: rail.h:159
RailtypeInfo::convert
CursorID convert
Cursor for converting track.
Definition: rail.h:161
RailtypeInfo::introduction_date
Date introduction_date
Introduction date.
Definition: rail.h:244
RailtypeInfo::cost_multiplier
uint16 cost_multiplier
Cost multiplier for building this rail type.
Definition: rail.h:205
RailTypeSpriteGroup
RailTypeSpriteGroup
Sprite groups for a railtype.
Definition: rail.h:39
AddDateIntroducedRailTypes
RailTypes AddDateIntroducedRailTypes(RailTypes current, Date date)
Add the rail types that are to be introduced at the given date.
Definition: rail.cpp:225
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:19
RailtypeInfo::rail_swne
CursorID rail_swne
Cursor for building rail in X direction.
Definition: rail.h:155
RFO_FLAT_RIGHT
Slope FLAT, Track RIGHT, Fence W.
Definition: rail.h:102
RailtypeInfo::fallback_railtype
byte fallback_railtype
Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations...
Definition: rail.h:190
RailBuildCost
static Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
Definition: rail.h:344
economy_func.h
Functions related to the economy.
RTFB_NO_LEVEL_CROSSING
Value for disallowing level crossings.
Definition: rail.h:32
RTSG_CURSORS
Cursor and toolbar icon images.
Definition: rail.h:40
RTSG_TUNNEL_PORTAL
Tunnel portal overlay.
Definition: rail.h:50
RailtypeInfo::map_colour
byte map_colour
Colour on mini-map.
Definition: rail.h:235
InitRailTypes
void InitRailTypes()
Resolve sprites of custom rail types.
Definition: rail_cmd.cpp:138
Slope
Slope
Enumeration for the slope-type.
Definition: slope_type.h:50
RailtypeInfo::build_tunnel
SpriteID build_tunnel
button for building a tunnel
Definition: rail.h:148
RTO_JUNCTION_SE
Ballast for junction &#39;pointing&#39; SE.
Definition: rail.h:73
RTO_JUNCTION_SW
Ballast for junction &#39;pointing&#39; SW.
Definition: rail.h:71
RTSG_GROUND
Main group of ground images.
Definition: rail.h:42
RFO_SLOPE_SE_NE
Slope SE, Track Y, Fence NE.
Definition: rail.h:97
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:311
RailtypeInfo::powered_railtypes
RailTypes powered_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype generates power ...
Definition: rail.h:177
RTSG_WIRES
Catenary wires.
Definition: rail.h:44
RailtypeInfo::GetRailtypeSpriteOffset
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
Definition: rail.h:284
ResetRailTypes
void ResetRailTypes()
Reset all rail type information to its default values.
Definition: rail_cmd.cpp:65
CursorID
uint32 CursorID
The number of the cursor (sprite)
Definition: gfx_type.h:21
RailtypeInfo::gui_sprites
struct RailtypeInfo::@37 gui_sprites
struct containing the sprites for the rail GUI.
RailTypeLabelList
SmallVector< RailTypeLabel, 4 > RailTypeLabelList
List of rail type labels.
Definition: rail.h:111
RFO_SLOPE_SW_SE
Slope SW, Track X, Fence SE.
Definition: rail.h:104
GetBestRailtype
RailType GetBestRailtype(const CompanyID company)
Returns the "best" railtype a company can build.
Definition: rail.cpp:210
RailtypeInfo::bridge_offset
SpriteID bridge_offset
Bridge offset.
Definition: rail.h:185
strings_type.h
Types related to strings.
date_type.h
Types related to the dates in OpenTTD.
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:16
RailtypeInfo::name
StringID name
Name of this rail type.
Definition: rail.h:165
RailTrackOffset
RailTrackOffset
Offsets for sprites within an overlay/underlay set.
Definition: rail.h:59
IntSqrt
uint32 IntSqrt(uint32 num)
Compute the integer square root.
Definition: math_func.cpp:79
RailtypeInfo::tunnel
SpriteID tunnel
tunnel sprites base
Definition: rail.h:134
RailtypeInfo::rail_ns
CursorID rail_ns
Cursor for building rail in N-S direction.
Definition: rail.h:154
RFO_SLOPE_NE_SE
Slope NE, Track X, Fence SE.
Definition: rail.h:106
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:105
RTSG_TUNNEL
Main group of ground images for snow or desert.
Definition: rail.h:43
RailtypeInfo::track_ns
SpriteID track_ns
two pieces of rail in North and South corner (East-West direction)
Definition: rail.h:124
RTO_JUNCTION_NSEW
Ballast for full junction.
Definition: rail.h:75
RFO_FLAT_X_NW
Slope FLAT, Track X, Fence NW.
Definition: rail.h:92
GetRailTypeByLabel
RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels=true)
Get the rail type for a given label.
Definition: rail.cpp:285
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:20
RTSG_SIGNALS
Signal images.
Definition: rail.h:51
RailtypeInfo::build_x_rail
SpriteID build_x_rail
button for building single rail in X direction
Definition: rail.h:143
RFO_SLOPE_NW_SW
Slope NW, Track Y, Fence SW.
Definition: rail.h:107
RailMaintenanceCost
static Money RailMaintenanceCost(RailType railtype, uint32 num, uint32 total_num)
Calculates the maintenance cost of a number of track bits.
Definition: rail.h:399
RailtypeInfo::build_ew_rail
SpriteID build_ew_rail
button for building single rail in E-W direction
Definition: rail.h:144
RTF_NO_LEVEL_CROSSING
Bit number for disallowing level crossings.
Definition: rail.h:28
OverflowSafeInt< int64, INT64_MAX, INT64_MIN >
gfx_type.h
Types related to the graphics and/or input devices.
RFO_FLAT_Y_SW
Slope FLAT, Track Y, Fence SW.
Definition: rail.h:101
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:174
GRFFile
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:104
RailtypeInfo::maintenance_multiplier
uint16 maintenance_multiplier
Cost multiplier for maintenance of this rail type.
Definition: rail.h:210
rail_type.h
The different types of rail.