OpenTTD Source: src/rail.h Source File

OpenTTD Source 15.0-RC2

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
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/enum_type.hpp"
17#include "core/flatset_type.hpp"
18#include "economy_func.h"
19#include "slope_type.h"
20#include "strings_type.h"
21#include "timer/timer_game_calendar.h"
22#include "signal_type.h"
23#include "settings_type.h"
24#include "newgrf_badge_type.h"
25
27 enum class RailTypeFlag : uint8_t {
28 Catenary = 0,
29 NoLevelCrossing = 1,
30 Hidden = 2,
31 NoSpriteCombine = 3,
32 Allow90Deg = 4,
33 Disallow90Deg = 5,
34};
35using RailTypeFlags = EnumBitSet<RailTypeFlag, uint8_t>;
36
37struct SpriteGroup;
38
40 enum RailTypeSpriteGroup : uint8_t {
41 RTSG_CURSORS,
42 RTSG_OVERLAY,
43 RTSG_GROUND,
44 RTSG_TUNNEL,
45 RTSG_WIRES,
46 RTSG_PYLONS,
47 RTSG_BRIDGE,
48 RTSG_CROSSING,
49 RTSG_DEPOT,
50 RTSG_FENCES,
51 RTSG_TUNNEL_PORTAL,
52 RTSG_SIGNALS,
53 RTSG_GROUND_COMPLETE,
54 RTSG_END,
55};
56
61 enum RailTrackOffset : uint8_t {
62 RTO_X,
63 RTO_Y,
64 RTO_N,
65 RTO_S,
66 RTO_E,
67 RTO_W,
68 RTO_SLOPE_NE,
69 RTO_SLOPE_SE,
70 RTO_SLOPE_SW,
71 RTO_SLOPE_NW,
72 RTO_CROSSING_XY,
73 RTO_JUNCTION_SW,
74 RTO_JUNCTION_NE,
75 RTO_JUNCTION_SE,
76 RTO_JUNCTION_NW,
77 RTO_JUNCTION_NSEW,
78};
79
83 enum RailTrackBridgeOffset : uint8_t {
84 RTBO_X,
85 RTBO_Y,
86 RTBO_SLOPE,
87};
88
93 enum RailFenceOffset : uint8_t {
94 RFO_FLAT_X_NW,
95 RFO_FLAT_Y_NE,
96 RFO_FLAT_LEFT,
97 RFO_FLAT_UPPER,
98 RFO_SLOPE_SW_NW,
99 RFO_SLOPE_SE_NE,
100 RFO_SLOPE_NE_NW,
101 RFO_SLOPE_NW_NE,
102 RFO_FLAT_X_SE,
103 RFO_FLAT_Y_SW,
104 RFO_FLAT_RIGHT,
105 RFO_FLAT_LOWER,
106 RFO_SLOPE_SW_SE,
107 RFO_SLOPE_SE_SW,
108 RFO_SLOPE_NE_SE,
109 RFO_SLOPE_NW_SW,
110};
111
115 class RailTypeInfo {
116public:
121 struct {
122 SpriteID track_y;
123 SpriteID track_ns;
124 SpriteID ground;
125 SpriteID single_x;
126 SpriteID single_y;
127 SpriteID single_n;
128 SpriteID single_s;
129 SpriteID single_e;
130 SpriteID single_w;
131 SpriteID single_sloped;
132 SpriteID crossing;
133 SpriteID tunnel;
134 SpriteID bridge_deck;
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 uint8_t bridge_offset;
186
190 uint8_t fallback_railtype;
191
195 uint8_t curve_speed;
196
200 RailTypeFlags flags;
201
205 uint16_t cost_multiplier;
206
210 uint16_t maintenance_multiplier;
211
215 VehicleAccelerationModel acceleration_type;
216
220 uint16_t max_speed;
221
225 RailTypeLabel label;
226
230 FlatSet<RailTypeLabel> alternate_labels;
231
235 PixelColour map_colour;
236
244 TimerGameCalendar::Date introduction_date;
245
250 RailTypes introduction_required_railtypes;
251
255 RailTypes introduces_railtypes;
256
260 uint8_t sorting_order;
261
265 const GRFFile *grffile[RTSG_END];
266
270 const SpriteGroup *group[RTSG_END];
271
272 std::vector<BadgeID> badges;
273
274 inline bool UsesOverlay() const
275 {
276 return this->group[RTSG_GROUND] != nullptr;
277 }
278
286 inline uint GetRailtypeSpriteOffset() const
287 {
288 return 82 * this->fallback_railtype;
289 }
290
291 RailType Index() const;
292};
293
294
300 inline const RailTypeInfo *GetRailTypeInfo(RailType railtype)
301{
302 extern RailTypeInfo _railtypes[RAILTYPE_END];
303 assert(railtype < RAILTYPE_END);
304 return &_railtypes[railtype];
305}
306
312 inline RailTypes GetAllCompatibleRailTypes(RailTypes railtypes)
313{
314 RailTypes compatible{};
315 for (RailType rt : railtypes) compatible.Set(GetRailTypeInfo(rt)->compatible_railtypes);
316 return compatible;
317}
318
324 inline RailTypes GetAllPoweredRailTypes(RailTypes railtypes)
325{
326 RailTypes powered{};
327 for (RailType rt : railtypes) powered.Set(GetRailTypeInfo(rt)->powered_railtypes);
328 return powered;
329}
330
336 inline RailTypes GetAllIntroducesRailTypes(RailTypes railtypes)
337{
338 RailTypes introduces{};
339 for (RailType rt : railtypes) introduces.Set(GetRailTypeInfo(rt)->introduces_railtypes);
340 return introduces;
341}
342
351 inline bool IsCompatibleRail(RailType enginetype, RailType tiletype)
352{
353 return GetRailTypeInfo(enginetype)->compatible_railtypes.Test(tiletype);
354}
355
363 inline bool IsCompatibleRail(RailTypes enginetype, RailType tiletype)
364{
365 return GetAllCompatibleRailTypes(enginetype).Test(tiletype);
366}
367
376 inline bool HasPowerOnRail(RailType enginetype, RailType tiletype)
377{
378 return GetRailTypeInfo(enginetype)->powered_railtypes.Test(tiletype);
379}
380
388 inline bool HasPowerOnRail(RailTypes enginetype, RailType tiletype)
389{
390 return GetAllPoweredRailTypes(enginetype).Test(tiletype);
391}
392
398 inline bool RailNoLevelCrossings(RailType rt)
399{
400 return GetRailTypeInfo(rt)->flags.Test(RailTypeFlag::NoLevelCrossing);
401}
402
410 inline bool Rail90DegTurnDisallowed(RailType rt1, RailType rt2, bool def = _settings_game.pf.forbid_90_deg)
411{
412 if (rt1 == INVALID_RAILTYPE || rt2 == INVALID_RAILTYPE) return def;
413
414 const RailTypeInfo *rti1 = GetRailTypeInfo(rt1);
415 const RailTypeInfo *rti2 = GetRailTypeInfo(rt2);
416
417 bool rt1_90deg = rti1->flags.Test(RailTypeFlag::Disallow90Deg) || (!rti1->flags.Test(RailTypeFlag::Allow90Deg) && def);
418 bool rt2_90deg = rti2->flags.Test(RailTypeFlag::Disallow90Deg) || (!rti2->flags.Test(RailTypeFlag::Allow90Deg) && def);
419
420 return rt1_90deg || rt2_90deg;
421}
422
428 inline Money RailBuildCost(RailType railtype)
429{
430 assert(railtype < RAILTYPE_END);
431 return (_price[PR_BUILD_RAIL] * GetRailTypeInfo(railtype)->cost_multiplier) >> 3;
432}
433
439 inline Money RailClearCost(RailType railtype)
440{
441 /* Clearing rail in fact earns money, but if the build cost is set
442 * very low then a loophole exists where money can be made.
443 * In this case we limit the removal earnings to 3/4s of the build
444 * cost.
445 */
446 assert(railtype < RAILTYPE_END);
447 return std::max(_price[PR_CLEAR_RAIL], -RailBuildCost(railtype) * 3 / 4);
448}
449
456 inline Money RailConvertCost(RailType from, RailType to)
457{
458 /* Get the costs for removing and building anew
459 * A conversion can never be more costly */
460 Money rebuildcost = RailBuildCost(to) + RailClearCost(from);
461
462 /* Conversion between somewhat compatible railtypes:
463 * Pay 1/8 of the target rail cost (labour costs) and additionally any difference in the
464 * build costs, if the target type is more expensive (material upgrade costs).
465 * Upgrade can never be more expensive than re-building. */
466 if (HasPowerOnRail(from, to) || HasPowerOnRail(to, from)) {
467 Money upgradecost = RailBuildCost(to) / 8 + std::max((Money)0, RailBuildCost(to) - RailBuildCost(from));
468 return std::min(upgradecost, rebuildcost);
469 }
470
471 /* make the price the same as remove + build new type for rail types
472 * which are not compatible in any way */
473 return rebuildcost;
474}
475
483 inline Money RailMaintenanceCost(RailType railtype, uint32_t num, uint32_t total_num)
484{
485 assert(railtype < RAILTYPE_END);
486 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.
487}
488
494 inline Money SignalMaintenanceCost(uint32_t num)
495{
496 return (_price[PR_INFRASTRUCTURE_RAIL] * 15 * num * (1 + IntSqrt(num))) >> 8; // 1 bit fraction for the multiplier and 7 bits scaling.
497}
498
499void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
500int TicksToLeaveDepot(const Train *v);
501
502 Foundation GetRailFoundation(Slope tileh, TrackBits bits);
503
504
505bool HasRailTypeAvail(const CompanyID company, const RailType railtype);
506bool HasAnyRailTypesAvail(const CompanyID company);
507bool ValParamRailType(const RailType rail);
508
509 RailTypes AddDateIntroducedRailTypes(RailTypes current, TimerGameCalendar::Date date);
510
511 RailTypes GetCompanyRailTypes(CompanyID company, bool introduces = true);
512 RailTypes GetRailTypes(bool introduces);
513
514 RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels = true);
515
516void ResetRailTypes();
517void InitRailTypes();
518 RailType AllocateRailType(RailTypeLabel label);
519
520extern std::vector<RailType> _sorted_railtypes;
521extern RailTypes _railtypes_hidden_mask;
522
523#endif /* RAIL_H */
BaseBitSet::Test
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Definition base_bitset_type.hpp:141
BaseBitSet::Set
constexpr Timpl & Set()
Set all bits.
Definition base_bitset_type.hpp:40
EnumBitSet< RailTypeFlag, uint8_t >
FlatSet
Flat set implementation that uses a sorted vector for storage.
Definition flatset_type.hpp:20
OverflowSafeInt< int64_t >
RailTypeInfo
This struct contains all the info that is needed to draw and construct tracks.
Definition rail.h:115
RailTypeInfo::Index
RailType Index() const
Get the RailType for this RailTypeInfo.
Definition rail.cpp:26
RailTypeInfo::single_x
SpriteID single_x
single piece of rail in X direction, without ground
Definition rail.h:125
RailTypeInfo::max_speed
uint16_t max_speed
Maximum speed for vehicles travelling on this rail type.
Definition rail.h:220
RailTypeInfo::build_tunnel
SpriteID build_tunnel
button for building a tunnel
Definition rail.h:148
RailTypeInfo::rail_swne
CursorID rail_swne
Cursor for building rail in X direction.
Definition rail.h:155
RailTypeInfo::convert_rail
SpriteID convert_rail
button for converting rail
Definition rail.h:149
RailTypeInfo::convert
CursorID convert
Cursor for converting track.
Definition rail.h:161
RailTypeInfo::depot
CursorID depot
Cursor for building a depot.
Definition rail.h:159
RailTypeInfo::introduction_date
TimerGameCalendar::Date introduction_date
Introduction date.
Definition rail.h:244
RailTypeInfo::map_colour
PixelColour map_colour
Colour on mini-map.
Definition rail.h:235
RailTypeInfo::powered_railtypes
RailTypes powered_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype generates power
Definition rail.h:177
RailTypeInfo::introduces_railtypes
RailTypes introduces_railtypes
Bitmask of which other railtypes are introduced when this railtype is introduced.
Definition rail.h:255
RailTypeInfo::ground
SpriteID ground
ground sprite for a 3-way switch
Definition rail.h:124
RailTypeInfo::rail_nwse
CursorID rail_nwse
Cursor for building rail in Y direction.
Definition rail.h:157
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::build_x_rail
SpriteID build_x_rail
button for building single rail in X direction
Definition rail.h:143
RailTypeInfo::sorting_order
uint8_t sorting_order
The sorting order of this railtype for the toolbar dropdown.
Definition rail.h:260
RailTypeInfo::label
RailTypeLabel label
Unique 32 bit rail type identifier.
Definition rail.h:225
RailTypeInfo::single_n
SpriteID single_n
single piece of rail in the northern corner
Definition rail.h:127
RailTypeInfo::acceleration_type
VehicleAccelerationModel acceleration_type
Acceleration type of this rail type.
Definition rail.h:215
RailTypeInfo::tunnel
CursorID tunnel
Cursor for building a tunnel.
Definition rail.h:160
RailTypeInfo::maintenance_multiplier
uint16_t maintenance_multiplier
Cost multiplier for maintenance of this rail type.
Definition rail.h:210
RailTypeInfo::crossing
SpriteID crossing
level crossing, rail in X direction
Definition rail.h:132
RailTypeInfo::group
const SpriteGroup * group[RTSG_END]
Sprite groups for resolving sprites.
Definition rail.h:270
RailTypeInfo::bridge_deck
SpriteID bridge_deck
bridge deck sprites base
Definition rail.h:134
RailTypeInfo::rail_ew
CursorID rail_ew
Cursor for building rail in E-W direction.
Definition rail.h:156
RailTypeInfo::auto_rail
SpriteID auto_rail
button for the autorail construction
Definition rail.h:146
RailTypeInfo::autorail
CursorID autorail
Cursor for autorail tool.
Definition rail.h:158
RailTypeInfo::single_y
SpriteID single_y
single piece of rail in Y direction, without ground
Definition rail.h:126
RailTypeInfo::menu_text
StringID menu_text
Name of this rail type in the main toolbar dropdown.
Definition rail.h:167
RailTypeInfo::name
StringID name
Name of this rail type.
Definition rail.h:165
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
RailTypeInfo::fallback_railtype
uint8_t fallback_railtype
Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.
Definition rail.h:190
RailTypeInfo::GetRailtypeSpriteOffset
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
Definition rail.h:286
RailTypeInfo::toolbar_caption
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
Definition rail.h:166
RailTypeInfo::single_s
SpriteID single_s
single piece of rail in the southern corner
Definition rail.h:128
RailTypeInfo::flags
RailTypeFlags flags
Bit mask of rail type flags.
Definition rail.h:200
RailTypeInfo::curve_speed
uint8_t curve_speed
Multiplier for curve maximum speed advantage.
Definition rail.h:195
RailTypeInfo::signals
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
Definition rail.h:150
RailTypeInfo::build_ew_rail
SpriteID build_ew_rail
button for building single rail in E-W direction
Definition rail.h:144
RailTypeInfo::build_y_rail
SpriteID build_y_rail
button for building single rail in Y direction
Definition rail.h:145
RailTypeInfo::alternate_labels
FlatSet< RailTypeLabel > alternate_labels
Rail type labels this type provides in addition to the main label.
Definition rail.h:230
RailTypeInfo::strings
struct RailTypeInfo::@22 strings
Strings associated with the rail type.
RailTypeInfo::cost_multiplier
uint16_t cost_multiplier
Cost multiplier for building this rail type.
Definition rail.h:205
RailTypeInfo::bridge_offset
uint8_t bridge_offset
Bridge offset.
Definition rail.h:185
RailTypeInfo::base_sprites
struct RailTypeInfo::@19 base_sprites
Struct containing the main sprites.
RailTypeInfo::track_ns
SpriteID track_ns
two pieces of rail in North and South corner (East-West direction)
Definition rail.h:123
RailTypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition rail.h:169
RailTypeInfo::cursor
struct RailTypeInfo::@21 cursor
Cursors associated with the rail type.
RailTypeInfo::build_caption
StringID build_caption
Caption of the build vehicle GUI for this rail type.
Definition rail.h:168
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
RailTypeInfo::track_y
SpriteID track_y
single piece of rail in Y direction, with ground
Definition rail.h:122
RailTypeInfo::gui_sprites
struct RailTypeInfo::@20 gui_sprites
struct containing the sprites for the rail GUI.
RailTypeInfo::build_depot
SpriteID build_depot
button for building depots
Definition rail.h:147
RailTypeInfo::single_w
SpriteID single_w
single piece of rail in the western corner
Definition rail.h:130
RailTypeInfo::single_e
SpriteID single_e
single piece of rail in the eastern corner
Definition rail.h:129
RailTypeInfo::build_ns_rail
SpriteID build_ns_rail
button for building single rail in N-S direction
Definition rail.h:142
RailTypeInfo::rail_ns
CursorID rail_ns
Cursor for building rail in N-S direction.
Definition rail.h:154
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::grffile
const GRFFile * grffile[RTSG_END]
NewGRF providing the Action3 for the railtype.
Definition rail.h:265
RailTypeInfo::tunnel
SpriteID tunnel
tunnel sprites base
Definition rail.h:133
RailTypeInfo::single_sloped
SpriteID single_sloped
single piece of rail for slopes
Definition rail.h:131
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.
VehicleAccelerationModel
VehicleAccelerationModel
Acceleration model of a vehicle.
Definition engine_type.h:47
enum_type.hpp
Type (helpers) for enums.
flatset_type.hpp
Flat set container implementation.
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:17
CursorID
uint32_t CursorID
The number of the cursor (sprite)
Definition gfx_type.h:19
newgrf_badge_type.h
Types related to NewGRF badges.
RailConvertCost
Money RailConvertCost(RailType from, RailType to)
Calculates the cost of rail conversion.
Definition rail.h:456
TicksToLeaveDepot
int TicksToLeaveDepot(const Train *v)
Compute number of ticks when next wagon will leave a depot.
Definition rail_cmd.cpp:2926
RailTrackBridgeOffset
RailTrackBridgeOffset
Offsets for sprites within a bridge surface overlay set.
Definition rail.h:83
RTBO_Y
@ RTBO_Y
Piece of rail in Y direction.
Definition rail.h:85
RTBO_X
@ RTBO_X
Piece of rail in X direction.
Definition rail.h:84
RTBO_SLOPE
@ RTBO_SLOPE
Sloped rail pieces, in order NE, SE, SW, NW.
Definition rail.h:86
RailClearCost
Money RailClearCost(RailType railtype)
Returns the 'cost' of clearing the specified railtype.
Definition rail.h:439
RailBuildCost
Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
Definition rail.h:428
AllocateRailType
RailType AllocateRailType(RailTypeLabel label)
Allocate a new rail type label.
Definition rail_cmd.cpp:148
_sorted_railtypes
std::vector< RailType > _sorted_railtypes
Sorted list of rail types.
Definition rail_cmd.cpp:47
HasAnyRailTypesAvail
bool HasAnyRailTypesAvail(const CompanyID company)
Test if any buildable railtype is available for a company.
Definition rail.cpp:78
RailFenceOffset
RailFenceOffset
Offsets from base sprite for fence sprites.
Definition rail.h:93
RFO_FLAT_RIGHT
@ RFO_FLAT_RIGHT
Slope FLAT, Track RIGHT, Fence W.
Definition rail.h:104
RFO_FLAT_Y_NE
@ RFO_FLAT_Y_NE
Slope FLAT, Track Y, Fence NE.
Definition rail.h:95
RFO_SLOPE_NW_SW
@ RFO_SLOPE_NW_SW
Slope NW, Track Y, Fence SW.
Definition rail.h:109
RFO_FLAT_X_SE
@ RFO_FLAT_X_SE
Slope FLAT, Track X, Fence SE.
Definition rail.h:102
RFO_SLOPE_NW_NE
@ RFO_SLOPE_NW_NE
Slope NW, Track Y, Fence NE.
Definition rail.h:101
RFO_SLOPE_SE_SW
@ RFO_SLOPE_SE_SW
Slope SE, Track Y, Fence SW.
Definition rail.h:107
RFO_SLOPE_NE_SE
@ RFO_SLOPE_NE_SE
Slope NE, Track X, Fence SE.
Definition rail.h:108
RFO_FLAT_LOWER
@ RFO_FLAT_LOWER
Slope FLAT, Track LOWER, Fence N.
Definition rail.h:105
RFO_SLOPE_SW_SE
@ RFO_SLOPE_SW_SE
Slope SW, Track X, Fence SE.
Definition rail.h:106
RFO_FLAT_UPPER
@ RFO_FLAT_UPPER
Slope FLAT, Track UPPER, Fence S.
Definition rail.h:97
RFO_SLOPE_SE_NE
@ RFO_SLOPE_SE_NE
Slope SE, Track Y, Fence NE.
Definition rail.h:99
RFO_FLAT_Y_SW
@ RFO_FLAT_Y_SW
Slope FLAT, Track Y, Fence SW.
Definition rail.h:103
RFO_FLAT_LEFT
@ RFO_FLAT_LEFT
Slope FLAT, Track LEFT, Fence E.
Definition rail.h:96
RFO_SLOPE_NE_NW
@ RFO_SLOPE_NE_NW
Slope NE, Track X, Fence NW.
Definition rail.h:100
RFO_FLAT_X_NW
@ RFO_FLAT_X_NW
Slope FLAT, Track X, Fence NW.
Definition rail.h:94
RFO_SLOPE_SW_NW
@ RFO_SLOPE_SW_NW
Slope SW, Track X, Fence NW.
Definition rail.h:98
GetAllIntroducesRailTypes
RailTypes GetAllIntroducesRailTypes(RailTypes railtypes)
Returns all introduced railtypes for a set of railtypes.
Definition rail.h:336
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:483
HasRailTypeAvail
bool HasRailTypeAvail(const CompanyID company, const RailType railtype)
Finds out if a company has a certain buildable railtype available.
Definition rail.cpp:68
GetAllPoweredRailTypes
RailTypes GetAllPoweredRailTypes(RailTypes railtypes)
Returns all powered railtypes for a set of railtypes.
Definition rail.h:324
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:351
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:376
AddDateIntroducedRailTypes
RailTypes AddDateIntroducedRailTypes(RailTypes current, TimerGameCalendar::Date date)
Add the rail types that are to be introduced at the given date.
Definition rail.cpp:102
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:494
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:410
GetRailTypeInfo
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition rail.h:300
GetAllCompatibleRailTypes
RailTypes GetAllCompatibleRailTypes(RailTypes railtypes)
Returns all compatible railtypes for a set of railtypes.
Definition rail.h:312
RailTypeFlag
RailTypeFlag
Railtype flag bit numbers.
Definition rail.h:27
RailTypeFlag::Catenary
@ Catenary
Bit number for drawing a catenary.
RailTypeFlag::Allow90Deg
@ Allow90Deg
Bit number for always allowed 90 degree turns, regardless of setting.
RailTypeFlag::Disallow90Deg
@ Disallow90Deg
Bit number for never allowed 90 degree turns, regardless of setting.
RailTypeFlag::Hidden
@ Hidden
Bit number for hiding from selection.
RailTypeFlag::NoSpriteCombine
@ NoSpriteCombine
Bit number for using non-combined junctions.
RailTypeFlag::NoLevelCrossing
@ NoLevelCrossing
Bit number for disallowing level crossings.
GetCompanyRailTypes
RailTypes GetCompanyRailTypes(CompanyID company, bool introduces=true)
Get the rail types the given company can build.
Definition rail.cpp:135
RailTypeSpriteGroup
RailTypeSpriteGroup
Sprite groups for a railtype.
Definition rail.h:40
RTSG_GROUND
@ RTSG_GROUND
Main group of ground images.
Definition rail.h:43
RTSG_PYLONS
@ RTSG_PYLONS
Catenary pylons.
Definition rail.h:46
RTSG_CURSORS
@ RTSG_CURSORS
Cursor and toolbar icon images.
Definition rail.h:41
RTSG_GROUND_COMPLETE
@ RTSG_GROUND_COMPLETE
Complete ground images.
Definition rail.h:53
RTSG_CROSSING
@ RTSG_CROSSING
Level crossing overlay images.
Definition rail.h:48
RTSG_TUNNEL
@ RTSG_TUNNEL
Main group of ground images for snow or desert.
Definition rail.h:44
RTSG_WIRES
@ RTSG_WIRES
Catenary wires.
Definition rail.h:45
RTSG_OVERLAY
@ RTSG_OVERLAY
Images for overlaying track.
Definition rail.h:42
RTSG_SIGNALS
@ RTSG_SIGNALS
Signal images.
Definition rail.h:52
RTSG_DEPOT
@ RTSG_DEPOT
Depot images.
Definition rail.h:49
RTSG_BRIDGE
@ RTSG_BRIDGE
Bridge surface images.
Definition rail.h:47
RTSG_TUNNEL_PORTAL
@ RTSG_TUNNEL_PORTAL
Tunnel portal overlay.
Definition rail.h:51
RTSG_FENCES
@ RTSG_FENCES
Fence images.
Definition rail.h:50
GetRailTypes
RailTypes GetRailTypes(bool introduces)
Get list of rail types, regardless of company availability.
Definition rail.cpp:166
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:309
RailTrackOffset
RailTrackOffset
Offsets for sprites within an overlay/underlay set.
Definition rail.h:61
RTO_Y
@ RTO_Y
Piece of rail in Y direction.
Definition rail.h:63
RTO_S
@ RTO_S
Piece of rail in southern corner.
Definition rail.h:65
RTO_JUNCTION_NE
@ RTO_JUNCTION_NE
Ballast for junction 'pointing' NE.
Definition rail.h:74
RTO_JUNCTION_NSEW
@ RTO_JUNCTION_NSEW
Ballast for full junction.
Definition rail.h:77
RTO_JUNCTION_SW
@ RTO_JUNCTION_SW
Ballast for junction 'pointing' SW.
Definition rail.h:73
RTO_SLOPE_SE
@ RTO_SLOPE_SE
Piece of rail on slope with south-east raised.
Definition rail.h:69
RTO_E
@ RTO_E
Piece of rail in eastern corner.
Definition rail.h:66
RTO_W
@ RTO_W
Piece of rail in western corner.
Definition rail.h:67
RTO_CROSSING_XY
@ RTO_CROSSING_XY
Crossing of X and Y rail, with ballast.
Definition rail.h:72
RTO_SLOPE_SW
@ RTO_SLOPE_SW
Piece of rail on slope with south-west raised.
Definition rail.h:70
RTO_SLOPE_NW
@ RTO_SLOPE_NW
Piece of rail on slope with north-west raised.
Definition rail.h:71
RTO_JUNCTION_NW
@ RTO_JUNCTION_NW
Ballast for junction 'pointing' NW.
Definition rail.h:76
RTO_JUNCTION_SE
@ RTO_JUNCTION_SE
Ballast for junction 'pointing' SE.
Definition rail.h:75
RTO_SLOPE_NE
@ RTO_SLOPE_NE
Piece of rail on slope with north-east raised.
Definition rail.h:68
RTO_X
@ RTO_X
Piece of rail in X direction.
Definition rail.h:62
RTO_N
@ RTO_N
Piece of rail in northern corner.
Definition rail.h:64
RailNoLevelCrossings
bool RailNoLevelCrossings(RailType rt)
Test if a RailType disallows build of level crossings.
Definition rail.h:398
GetRailTypeByLabel
RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels=true)
Get the rail type for a given label.
Definition rail.cpp:195
ValParamRailType
bool ValParamRailType(const RailType rail)
Validate functions for rail building.
Definition rail.cpp:90
rail_type.h
The different types of rail.
RailType
RailType
Enumeration for all possible railtypes.
Definition rail_type.h:25
RAILTYPE_END
@ RAILTYPE_END
Used for iterations.
Definition rail_type.h:31
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition rail_type.h:32
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
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:19
GRFFile
Dynamic data of a loaded NewGRF.
Definition newgrf.h:114
GameSettings::pf
PathfinderSettings pf
settings for all pathfinders
Definition settings_type.h:639
PathfinderSettings::forbid_90_deg
bool forbid_90_deg
forbid trains to make 90 deg turns
Definition settings_type.h:493
PixelColour
Colour for pixel/line drawing.
Definition gfx_type.h:405
PoolID< uint8_t, struct CompanyIDTag, 0xF, 0xFF >
SpriteGroup
Definition newgrf_spritegroup.h:47
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition strong_typedef_type.hpp:130
Train
'Train' is either a loco or a wagon.
Definition train.h:91
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