OpenTTD Source: src/signal_func.h Source File

OpenTTD Source 15.0-RC2

signal_func.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 SIGNAL_FUNC_H
11#define SIGNAL_FUNC_H
12
13#include "track_type.h"
14#include "tile_type.h"
15#include "direction_type.h"
16#include "company_type.h"
17
22 inline uint8_t SignalAlongTrackdir(Trackdir trackdir)
23{
24 extern const uint8_t _signal_along_trackdir[TRACKDIR_END];
25 return _signal_along_trackdir[trackdir];
26}
27
32 inline uint8_t SignalAgainstTrackdir(Trackdir trackdir)
33{
34 extern const uint8_t _signal_against_trackdir[TRACKDIR_END];
35 return _signal_against_trackdir[trackdir];
36}
37
42 inline uint8_t SignalOnTrack(Track track)
43{
44 extern const uint8_t _signal_on_track[TRACK_END];
45 return _signal_on_track[track];
46}
47
49 enum SigSegState : uint8_t {
50 SIGSEG_FREE,
51 SIGSEG_FULL,
52 SIGSEG_PBS,
53};
54
55 SigSegState UpdateSignalsOnSegment(TileIndex tile, DiagDirection side, Owner owner);
56void SetSignalsOnBothDir(TileIndex tile, Track track, Owner owner);
57void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner);
58void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner);
59void UpdateSignalsInBuffer();
60
61#endif /* SIGNAL_FUNC_H */
company_type.h
Types related to companies.
direction_type.h
Different types to 'show' directions.
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition direction_type.h:78
SignalAgainstTrackdir
uint8_t SignalAgainstTrackdir(Trackdir trackdir)
Maps a trackdir to the bit that stores its status in the map arrays, in the direction against the tra...
Definition signal_func.h:32
AddTrackToSignalBuffer
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner)
Add track to signal update buffer.
Definition signal.cpp:589
UpdateSignalsOnSegment
SigSegState UpdateSignalsOnSegment(TileIndex tile, DiagDirection side, Owner owner)
Update signals, starting at one side of a tile Will check tile next to this at opposite side too.
Definition signal.cpp:647
UpdateSignalsInBuffer
void UpdateSignalsInBuffer()
Update signals in buffer Called from 'outside'.
Definition signal.cpp:573
AddSideToSignalBuffer
void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner)
Add side of tile to signal update buffer.
Definition signal.cpp:621
SigSegState
SigSegState
State of the signal segment.
Definition signal_func.h:49
SIGSEG_PBS
@ SIGSEG_PBS
Segment is a PBS segment.
Definition signal_func.h:52
SIGSEG_FREE
@ SIGSEG_FREE
Free and has no pre-signal exits or at least one green exit.
Definition signal_func.h:50
SIGSEG_FULL
@ SIGSEG_FULL
Occupied by a train.
Definition signal_func.h:51
SignalAlongTrackdir
uint8_t 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
SetSignalsOnBothDir
void SetSignalsOnBothDir(TileIndex tile, Track track, Owner owner)
Update signals at segments that are at both ends of given (existent or non-existent) track.
Definition signal.cpp:665
SignalOnTrack
uint8_t 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
PoolID< uint8_t, struct CompanyIDTag, 0xF, 0xFF >
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
tile_type.h
Types related to tiles.
track_type.h
All types related to tracks.
Trackdir
Trackdir
Enumeration for tracks and directions.
Definition track_type.h:66
TRACKDIR_END
@ TRACKDIR_END
Used for iterations.
Definition track_type.h:84
Track
Track
These are used to specify a single track.
Definition track_type.h:19
TRACK_END
@ TRACK_END
Used for iterations.
Definition track_type.h:27