OpenTTD Source: src/rail_map.h Source File

OpenTTD Source 14.1

rail_map.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_MAP_H
11 #define RAIL_MAP_H
12
13 #include "rail_type.h"
14 #include "depot_type.h"
15 #include "signal_func.h"
16 #include "track_func.h"
17 #include "tile_map.h"
18 #include "water_map.h"
19 #include "signal_type.h"
20
21
23 enum RailTileType {
24 RAIL_TILE_NORMAL = 0,
25 RAIL_TILE_SIGNALS = 1,
26 RAIL_TILE_DEPOT = 3,
27 };
28
36 debug_inline static RailTileType GetRailTileType(Tile t)
37 {
38 assert(IsTileType(t, MP_RAILWAY));
39 return (RailTileType)GB(t.m5(), 6, 2);
40 }
41
49 debug_inline static bool IsPlainRail(Tile t)
50 {
51 RailTileType rtt = GetRailTileType(t);
52 return rtt == RAIL_TILE_NORMAL || rtt == RAIL_TILE_SIGNALS;
53 }
54
60 debug_inline static bool IsPlainRailTile(Tile t)
61 {
62 return IsTileType(t, MP_RAILWAY) && IsPlainRail(t);
63 }
64
65
72 inline bool HasSignals(Tile t)
73 {
74 return GetRailTileType(t) == RAIL_TILE_SIGNALS;
75 }
76
83 inline void SetHasSignals(Tile tile, bool signals)
84 {
85 assert(IsPlainRailTile(tile));
86 SB(tile.m5(), 6, 1, signals);
87 }
88
95 debug_inline static bool IsRailDepot(Tile t)
96 {
97 return GetRailTileType(t) == RAIL_TILE_DEPOT;
98 }
99
105 debug_inline static bool IsRailDepotTile(Tile t)
106 {
107 return IsTileType(t, MP_RAILWAY) && IsRailDepot(t);
108 }
109
115 inline RailType GetRailType(Tile t)
116 {
117 return (RailType)GB(t.m8(), 0, 6);
118 }
119
125 inline void SetRailType(Tile t, RailType r)
126 {
127 SB(t.m8(), 0, 6, r);
128 }
129
130
136 inline TrackBits GetTrackBits(Tile tile)
137 {
138 assert(IsPlainRailTile(tile));
139 return (TrackBits)GB(tile.m5(), 0, 6);
140 }
141
147 inline void SetTrackBits(Tile t, TrackBits b)
148 {
149 assert(IsPlainRailTile(t));
150 SB(t.m5(), 0, 6, b);
151 }
152
160 inline bool HasTrack(Tile tile, Track track)
161 {
162 return HasBit(GetTrackBits(tile), track);
163 }
164
171 inline DiagDirection GetRailDepotDirection(Tile t)
172 {
173 return (DiagDirection)GB(t.m5(), 0, 2);
174 }
175
182 inline Track GetRailDepotTrack(Tile t)
183 {
184 return DiagDirToDiagTrack(GetRailDepotDirection(t));
185 }
186
187
194 inline TrackBits GetRailReservationTrackBits(Tile t)
195 {
196 assert(IsPlainRailTile(t));
197 byte track_b = GB(t.m2(), 8, 3);
198 Track track = (Track)(track_b - 1); // map array saves Track+1
199 if (track_b == 0) return TRACK_BIT_NONE;
200 return (TrackBits)(TrackToTrackBits(track) | (HasBit(t.m2(), 11) ? TrackToTrackBits(TrackToOppositeTrack(track)) : 0));
201 }
202
209 inline void SetTrackReservation(Tile t, TrackBits b)
210 {
211 assert(IsPlainRailTile(t));
212 assert(b != INVALID_TRACK_BIT);
213 assert(!TracksOverlap(b));
214 Track track = RemoveFirstTrack(&b);
215 SB(t.m2(), 8, 3, track == INVALID_TRACK ? 0 : track + 1);
216 SB(t.m2(), 11, 1, (byte)(b != TRACK_BIT_NONE));
217 }
218
226 inline bool TryReserveTrack(Tile tile, Track t)
227 {
228 assert(HasTrack(tile, t));
229 TrackBits bits = TrackToTrackBits(t);
230 TrackBits res = GetRailReservationTrackBits(tile);
231 if ((res & bits) != TRACK_BIT_NONE) return false; // already reserved
232 res |= bits;
233 if (TracksOverlap(res)) return false; // crossing reservation present
234 SetTrackReservation(tile, res);
235 return true;
236 }
237
244 inline void UnreserveTrack(Tile tile, Track t)
245 {
246 assert(HasTrack(tile, t));
247 TrackBits res = GetRailReservationTrackBits(tile);
248 res &= ~TrackToTrackBits(t);
249 SetTrackReservation(tile, res);
250 }
251
258 inline bool HasDepotReservation(Tile t)
259 {
260 assert(IsRailDepot(t));
261 return HasBit(t.m5(), 4);
262 }
263
270 inline void SetDepotReservation(Tile t, bool b)
271 {
272 assert(IsRailDepot(t));
273 SB(t.m5(), 4, 1, (byte)b);
274 }
275
282 inline TrackBits GetDepotReservationTrackBits(Tile t)
283 {
284 return HasDepotReservation(t) ? TrackToTrackBits(GetRailDepotTrack(t)) : TRACK_BIT_NONE;
285 }
286
287
288 inline bool IsPbsSignal(SignalType s)
289 {
290 return s == SIGTYPE_PBS || s == SIGTYPE_PBS_ONEWAY;
291 }
292
293 inline SignalType GetSignalType(Tile t, Track track)
294 {
295 assert(GetRailTileType(t) == RAIL_TILE_SIGNALS);
296 byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
297 return (SignalType)GB(t.m2(), pos, 3);
298 }
299
300 inline void SetSignalType(Tile t, Track track, SignalType s)
301 {
302 assert(GetRailTileType(t) == RAIL_TILE_SIGNALS);
303 byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
304 SB(t.m2(), pos, 3, s);
305 if (track == INVALID_TRACK) SB(t.m2(), 4, 3, s);
306 }
307
308 inline bool IsPresignalEntry(Tile t, Track track)
309 {
310 return GetSignalType(t, track) == SIGTYPE_ENTRY || GetSignalType(t, track) == SIGTYPE_COMBO;
311 }
312
313 inline bool IsPresignalExit(Tile t, Track track)
314 {
315 return GetSignalType(t, track) == SIGTYPE_EXIT || GetSignalType(t, track) == SIGTYPE_COMBO;
316 }
317
319 inline bool IsOnewaySignal(Tile t, Track track)
320 {
321 return GetSignalType(t, track) != SIGTYPE_PBS;
322 }
323
324 inline void CycleSignalSide(Tile t, Track track)
325 {
326 byte sig;
327 byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 6;
328
329 sig = GB(t.m3(), pos, 2);
330 if (--sig == 0) sig = IsPbsSignal(GetSignalType(t, track)) ? 2 : 3;
331 SB(t.m3(), pos, 2, sig);
332 }
333
334 inline SignalVariant GetSignalVariant(Tile t, Track track)
335 {
336 byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 7 : 3;
337 return (SignalVariant)GB(t.m2(), pos, 1);
338 }
339
340 inline void SetSignalVariant(Tile t, Track track, SignalVariant v)
341 {
342 byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 7 : 3;
343 SB(t.m2(), pos, 1, v);
344 if (track == INVALID_TRACK) SB(t.m2(), 7, 1, v);
345 }
346
352 inline void SetSignalStates(Tile tile, uint state)
353 {
354 SB(tile.m4(), 4, 4, state);
355 }
356
362 inline uint GetSignalStates(Tile tile)
363 {
364 return GB(tile.m4(), 4, 4);
365 }
366
373 inline SignalState GetSingleSignalState(Tile t, byte signalbit)
374 {
375 return (SignalState)HasBit(GetSignalStates(t), signalbit);
376 }
377
383 inline void SetPresentSignals(Tile tile, uint signals)
384 {
385 SB(tile.m3(), 4, 4, signals);
386 }
387
393 inline uint GetPresentSignals(Tile tile)
394 {
395 return GB(tile.m3(), 4, 4);
396 }
397
404 inline bool IsSignalPresent(Tile t, byte signalbit)
405 {
406 return HasBit(GetPresentSignals(t), signalbit);
407 }
408
413 inline bool HasSignalOnTrack(Tile tile, Track track)
414 {
415 assert(IsValidTrack(track));
416 return GetRailTileType(tile) == RAIL_TILE_SIGNALS && (GetPresentSignals(tile) & SignalOnTrack(track)) != 0;
417 }
418
426 inline bool HasSignalOnTrackdir(Tile tile, Trackdir trackdir)
427 {
428 assert (IsValidTrackdir(trackdir));
429 return GetRailTileType(tile) == RAIL_TILE_SIGNALS && GetPresentSignals(tile) & SignalAlongTrackdir(trackdir);
430 }
431
438 inline SignalState GetSignalStateByTrackdir(Tile tile, Trackdir trackdir)
439 {
440 assert(IsValidTrackdir(trackdir));
441 assert(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)));
442 return GetSignalStates(tile) & SignalAlongTrackdir(trackdir) ?
443 SIGNAL_STATE_GREEN : SIGNAL_STATE_RED;
444 }
445
449 inline void SetSignalStateByTrackdir(Tile tile, Trackdir trackdir, SignalState state)
450 {
451 if (state == SIGNAL_STATE_GREEN) { // set 1
452 SetSignalStates(tile, GetSignalStates(tile) | SignalAlongTrackdir(trackdir));
453 } else {
454 SetSignalStates(tile, GetSignalStates(tile) & ~SignalAlongTrackdir(trackdir));
455 }
456 }
457
463 inline bool HasPbsSignalOnTrackdir(Tile tile, Trackdir td)
464 {
465 return IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, td) &&
466 IsPbsSignal(GetSignalType(tile, TrackdirToTrack(td)));
467 }
468
475 inline bool HasOnewaySignalBlockingTrackdir(Tile tile, Trackdir td)
476 {
477 return IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, ReverseTrackdir(td)) &&
478 !HasSignalOnTrackdir(tile, td) && IsOnewaySignal(tile, TrackdirToTrack(td));
479 }
480
481
482 RailType GetTileRailType(Tile tile);
483
485 enum RailGroundType {
486 RAIL_GROUND_BARREN = 0,
487 RAIL_GROUND_GRASS = 1,
488 RAIL_GROUND_FENCE_NW = 2,
489 RAIL_GROUND_FENCE_SE = 3,
490 RAIL_GROUND_FENCE_SENW = 4,
491 RAIL_GROUND_FENCE_NE = 5,
492 RAIL_GROUND_FENCE_SW = 6,
493 RAIL_GROUND_FENCE_NESW = 7,
494 RAIL_GROUND_FENCE_VERT1 = 8,
495 RAIL_GROUND_FENCE_VERT2 = 9,
496 RAIL_GROUND_FENCE_HORIZ1 = 10,
497 RAIL_GROUND_FENCE_HORIZ2 = 11,
498 RAIL_GROUND_ICE_DESERT = 12,
499 RAIL_GROUND_WATER = 13,
500 RAIL_GROUND_HALF_SNOW = 14,
501 };
502
503 inline void SetRailGroundType(Tile t, RailGroundType rgt)
504 {
505 SB(t.m4(), 0, 4, rgt);
506 }
507
508 inline RailGroundType GetRailGroundType(Tile t)
509 {
510 return (RailGroundType)GB(t.m4(), 0, 4);
511 }
512
513 inline bool IsSnowRailGround(Tile t)
514 {
515 return GetRailGroundType(t) == RAIL_GROUND_ICE_DESERT;
516 }
517
518
519 inline void MakeRailNormal(Tile t, Owner o, TrackBits b, RailType r)
520 {
521 SetTileType(t, MP_RAILWAY);
522 SetTileOwner(t, o);
523 SetDockingTile(t, false);
524 t.m2() = 0;
525 t.m3() = 0;
526 t.m4() = 0;
527 t.m5() = RAIL_TILE_NORMAL << 6 | b;
528 SB(t.m6(), 2, 4, 0);
529 t.m7() = 0;
530 t.m8() = r;
531 }
532
538 inline void SetRailDepotExitDirection(Tile tile, DiagDirection dir)
539 {
540 assert(IsRailDepotTile(tile));
541 SB(tile.m5(), 0, 2, dir);
542 }
543
552 inline void MakeRailDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RailType rail_type)
553 {
554 SetTileType(tile, MP_RAILWAY);
555 SetTileOwner(tile, owner);
556 SetDockingTile(tile, false);
557 tile.m2() = depot_id;
558 tile.m3() = 0;
559 tile.m4() = 0;
560 tile.m5() = RAIL_TILE_DEPOT << 6 | dir;
561 SB(tile.m6(), 2, 4, 0);
562 tile.m7() = 0;
563 tile.m8() = rail_type;
564 }
565
566 #endif /* RAIL_MAP_H */
TRACK_BIT_NONE
@ TRACK_BIT_NONE
No track.
Definition: track_type.h:36
RAIL_GROUND_HALF_SNOW
@ RAIL_GROUND_HALF_SNOW
Snow only on higher part of slope (steep or one corner raised)
Definition: rail_map.h:500
SignalAlongTrackdir
byte SignalAlongTrackdir(Trackdir trackdir)
Maps a trackdir to the bit that stores its status in the map arrays, in the direction along with the ...
Definition: signal_func.h:22
RAIL_GROUND_FENCE_SE
@ RAIL_GROUND_FENCE_SE
Grass with a fence at the SE edge.
Definition: rail_map.h:489
IsOnewaySignal
bool IsOnewaySignal(Tile t, Track track)
One-way signals can't be passed the 'wrong' way.
Definition: rail_map.h:319
TrackdirToTrack
Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
Definition: track_func.h:262
IsPlainRail
static debug_inline bool IsPlainRail(Tile t)
Returns whether this is plain rails, with or without signals.
Definition: rail_map.h:49
TRACK_LOWER
@ TRACK_LOWER
Track in the lower corner of the tile (south)
Definition: track_type.h:24
RAIL_TILE_SIGNALS
@ RAIL_TILE_SIGNALS
Normal rail tile with signals.
Definition: rail_map.h:25
GB
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
GetTileRailType
RailType GetTileRailType(Tile tile)
Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
Definition: rail.cpp:155
UnreserveTrack
void UnreserveTrack(Tile tile, Track t)
Lift the reservation of a specific track on a tile.
Definition: rail_map.h:244
HasDepotReservation
bool HasDepotReservation(Tile t)
Get the reservation state of the depot.
Definition: rail_map.h:258
SetPresentSignals
void SetPresentSignals(Tile tile, uint signals)
Set whether the given signals are present (Along/AgainstTrackDir)
Definition: rail_map.h:383
Tile::m8
debug_inline uint16_t & m8()
General purpose.
Definition: map_func.h:197
RAIL_GROUND_FENCE_NW
@ RAIL_GROUND_FENCE_NW
Grass with a fence at the NW edge.
Definition: rail_map.h:488
Tile::m6
debug_inline byte & m6()
General purpose.
Definition: map_func.h:173
SIGNAL_STATE_GREEN
@ SIGNAL_STATE_GREEN
The signal is green.
Definition: signal_type.h:44
RAIL_GROUND_FENCE_VERT1
@ RAIL_GROUND_FENCE_VERT1
Grass with a fence at the eastern side.
Definition: rail_map.h:494
MP_RAILWAY
@ MP_RAILWAY
A railway.
Definition: tile_type.h:49
RAIL_GROUND_BARREN
@ RAIL_GROUND_BARREN
Nothing (dirt)
Definition: rail_map.h:486
Tile
Wrapper class to abstract away the way the tiles are stored.
Definition: map_func.h:25
SignalState
SignalState
These are states in which a signal can be.
Definition: signal_type.h:42
RAIL_GROUND_FENCE_SENW
@ RAIL_GROUND_FENCE_SENW
Grass with a fence at the NW and SE edges.
Definition: rail_map.h:490
RAIL_GROUND_FENCE_VERT2
@ RAIL_GROUND_FENCE_VERT2
Grass with a fence at the western side.
Definition: rail_map.h:495
IsValidTrack
bool IsValidTrack(Track track)
Checks if a Track is valid.
Definition: track_func.h:28
SignalVariant
SignalVariant
Variant of the signal, i.e.
Definition: signal_type.h:16
Window::owner
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
Definition: window_gui.h:310
SetHasSignals
void SetHasSignals(Tile tile, bool signals)
Add/remove the 'has signal' bit from the RailTileType.
Definition: rail_map.h:83
Tile::m5
debug_inline byte & m5()
General purpose.
Definition: map_func.h:161
GetRailType
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
Definition: rail_map.h:115
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
Tile::m4
debug_inline byte & m4()
General purpose.
Definition: map_func.h:149
SetSignalStates
void SetSignalStates(Tile tile, uint state)
Set the states of the signals (Along/AgainstTrackDir)
Definition: rail_map.h:352
TRACK_RIGHT
@ TRACK_RIGHT
Track in the right corner of the tile (east)
Definition: track_type.h:26
GetSignalStates
uint GetSignalStates(Tile tile)
Set the states of the signals (Along/AgainstTrackDir)
Definition: rail_map.h:362
TrackToTrackBits
TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
Definition: track_func.h:77
TracksOverlap
bool TracksOverlap(TrackBits bits)
Checks if the given tracks overlap, ie form a crossing.
Definition: track_func.h:645
SignalType
SignalType
Type of signal, i.e.
Definition: signal_type.h:23
SIGTYPE_PBS
@ SIGTYPE_PBS
normal pbs signal
Definition: signal_type.h:28
GetRailDepotDirection
DiagDirection GetRailDepotDirection(Tile t)
Returns the direction the depot is facing to.
Definition: rail_map.h:171
Tile::m7
debug_inline byte & m7()
Primarily used for newgrf support.
Definition: map_func.h:185
IsRailDepot
static debug_inline bool IsRailDepot(Tile t)
Is this rail tile a rail depot?
Definition: rail_map.h:95
RAIL_GROUND_GRASS
@ RAIL_GROUND_GRASS
Grassy.
Definition: rail_map.h:487
tile_map.h
TryReserveTrack
bool TryReserveTrack(Tile tile, Track t)
Try to reserve a specific track on a tile.
Definition: rail_map.h:226
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
Tile::m2
debug_inline uint16_t & m2()
Primarily used for indices to towns, industries and stations.
Definition: map_func.h:125
RemoveFirstTrack
Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
Definition: track_func.h:131
GetRailDepotTrack
Track GetRailDepotTrack(Tile t)
Returns the track of a depot, ignoring direction.
Definition: rail_map.h:182
SIGTYPE_PBS_ONEWAY
@ SIGTYPE_PBS_ONEWAY
no-entry signal
Definition: signal_type.h:29
SIGNAL_STATE_RED
@ SIGNAL_STATE_RED
The signal is red.
Definition: signal_type.h:43
GetRailReservationTrackBits
TrackBits GetRailReservationTrackBits(Tile t)
Returns the reserved track bits of the tile.
Definition: rail_map.h:194
HasTrack
bool HasTrack(Tile tile, Track track)
Returns whether the given track is present on the given tile.
Definition: rail_map.h:160
HasSignalOnTrack
bool HasSignalOnTrack(Tile tile, Track track)
Checks for the presence of signals (either way) on the given track on the given rail tile.
Definition: rail_map.h:413
ReverseTrackdir
Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
Definition: track_func.h:247
SetTrackReservation
void SetTrackReservation(Tile t, TrackBits b)
Sets the reserved track bits of the tile.
Definition: rail_map.h:209
GetSignalStateByTrackdir
SignalState GetSignalStateByTrackdir(Tile tile, Trackdir trackdir)
Gets the state of the signal along the given trackdir.
Definition: rail_map.h:438
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:73
GetRailTileType
static debug_inline RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
Definition: rail_map.h:36
HasOnewaySignalBlockingTrackdir
bool HasOnewaySignalBlockingTrackdir(Tile tile, Trackdir td)
Is a one-way signal blocking the trackdir? A one-way signal on the trackdir against will block,...
Definition: rail_map.h:475
GetPresentSignals
uint GetPresentSignals(Tile tile)
Get whether the given signals are present (Along/AgainstTrackDir)
Definition: rail_map.h:393
SIGTYPE_EXIT
@ SIGTYPE_EXIT
presignal block exit
Definition: signal_type.h:26
SIGTYPE_COMBO
@ SIGTYPE_COMBO
presignal inter-block
Definition: signal_type.h:27
INVALID_TRACK_BIT
@ INVALID_TRACK_BIT
Flag for an invalid trackbits value.
Definition: track_type.h:54
SetTileOwner
void SetTileOwner(Tile tile, Owner owner)
Sets the owner of a tile.
Definition: tile_map.h:198
RailGroundType
RailGroundType
The ground 'under' the rail.
Definition: rail_map.h:485
IsPlainRailTile
static debug_inline bool IsPlainRailTile(Tile t)
Checks whether the tile is a rail tile or rail tile with signals.
Definition: rail_map.h:60
GetTrackBits
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
Definition: rail_map.h:136
RAIL_GROUND_WATER
@ RAIL_GROUND_WATER
Grass with a fence and shore or water on the free halftile.
Definition: rail_map.h:499
water_map.h
MakeRailDepot
void MakeRailDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RailType rail_type)
Make a rail depot.
Definition: rail_map.h:552
DepotID
uint16_t DepotID
Type for the unique identifier of depots.
Definition: depot_type.h:13
signal_type.h
SIGTYPE_ENTRY
@ SIGTYPE_ENTRY
presignal block entry
Definition: signal_type.h:25
RAIL_GROUND_FENCE_HORIZ1
@ RAIL_GROUND_FENCE_HORIZ1
Grass with a fence at the southern side.
Definition: rail_map.h:496
IsRailDepotTile
static debug_inline bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
Definition: rail_map.h:105
GetDepotReservationTrackBits
TrackBits GetDepotReservationTrackBits(Tile t)
Get the reserved track bits for a depot.
Definition: rail_map.h:282
SetDepotReservation
void SetDepotReservation(Tile t, bool b)
Set the reservation state of the depot.
Definition: rail_map.h:270
depot_type.h
GetSingleSignalState
SignalState GetSingleSignalState(Tile t, byte signalbit)
Get the state of a single signal.
Definition: rail_map.h:373
HasSignals
bool HasSignals(Tile t)
Checks if a rail tile has signals.
Definition: rail_map.h:72
SetDockingTile
void SetDockingTile(Tile t, bool b)
Set the docking tile state of a tile.
Definition: water_map.h:364
SetRailType
void SetRailType(Tile t, RailType r)
Sets the rail type of the given tile.
Definition: rail_map.h:125
SetTileType
void SetTileType(Tile tile, TileType type)
Set the type of a tile.
Definition: tile_map.h:131
RAIL_TILE_NORMAL
@ RAIL_TILE_NORMAL
Normal rail tile without signals.
Definition: rail_map.h:24
signal_func.h
SetRailDepotExitDirection
void SetRailDepotExitDirection(Tile tile, DiagDirection dir)
Sets the exit direction of a rail depot.
Definition: rail_map.h:538
RAIL_GROUND_FENCE_NE
@ RAIL_GROUND_FENCE_NE
Grass with a fence at the NE edge.
Definition: rail_map.h:491
track_func.h
DiagDirToDiagTrack
Track DiagDirToDiagTrack(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track incidating with that diagdir.
Definition: track_func.h:512
rail_type.h
TrackBits
TrackBits
Allow incrementing of Track variables.
Definition: track_type.h:35
IsSignalPresent
bool IsSignalPresent(Tile t, byte signalbit)
Checks whether the given signals is present.
Definition: rail_map.h:404
SB
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
Definition: bitmath_func.hpp:58
RAIL_GROUND_FENCE_HORIZ2
@ RAIL_GROUND_FENCE_HORIZ2
Grass with a fence at the northern side.
Definition: rail_map.h:497
Trackdir
Trackdir
Enumeration for tracks and directions.
Definition: track_type.h:67
IsTileType
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
RAIL_TILE_DEPOT
@ RAIL_TILE_DEPOT
Depot (one entrance)
Definition: rail_map.h:26
HasPbsSignalOnTrackdir
bool HasPbsSignalOnTrackdir(Tile tile, Trackdir td)
Is a pbs signal present along the trackdir?
Definition: rail_map.h:463
SetTrackBits
void SetTrackBits(Tile t, TrackBits b)
Sets the track bits of the given tile.
Definition: rail_map.h:147
Track
Track
These are used to specify a single track.
Definition: track_type.h:19
IsValidTrackdir
bool IsValidTrackdir(Trackdir trackdir)
Checks if a Trackdir is valid for non-road vehicles.
Definition: track_func.h:52
RailTileType
RailTileType
Different types of Rail-related tiles.
Definition: rail_map.h:23
Tile::m3
debug_inline byte & m3()
General purpose.
Definition: map_func.h:137
SetSignalStateByTrackdir
void SetSignalStateByTrackdir(Tile tile, Trackdir trackdir, SignalState state)
Sets the state of the signal along the given trackdir.
Definition: rail_map.h:449
RAIL_GROUND_ICE_DESERT
@ RAIL_GROUND_ICE_DESERT
Icy or sandy.
Definition: rail_map.h:498
RAIL_GROUND_FENCE_SW
@ RAIL_GROUND_FENCE_SW
Grass with a fence at the SW edge.
Definition: rail_map.h:492
SignalOnTrack
byte SignalOnTrack(Track track)
Maps a Track to the bits that store the status of the two signals that can be present on the given tr...
Definition: signal_func.h:42
HasSignalOnTrackdir
bool HasSignalOnTrackdir(Tile tile, Trackdir trackdir)
Checks for the presence of signals along the given trackdir on the given rail tile.
Definition: rail_map.h:426
TrackToOppositeTrack
Track TrackToOppositeTrack(Track t)
Find the opposite track to a given track.
Definition: track_func.h:231
INVALID_TRACK
@ INVALID_TRACK
Flag for an invalid track.
Definition: track_type.h:28
RAIL_GROUND_FENCE_NESW
@ RAIL_GROUND_FENCE_NESW
Grass with a fence at the NE and SW edges.
Definition: rail_map.h:493
HasBit
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103