2007-12-25 23:42:52 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/** @file signal_func.h Functions related to signals. */
|
|
|
|
|
|
|
|
#ifndef SIGNAL_FUNC_H
|
|
|
|
#define SIGNAL_FUNC_H
|
|
|
|
|
2008-01-09 23:00:59 +00:00
|
|
|
#include "track_type.h"
|
|
|
|
#include "tile_type.h"
|
|
|
|
#include "direction_type.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_type.h"
|
2007-12-25 23:42:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps a trackdir to the bit that stores its status in the map arrays, in the
|
|
|
|
* direction along with the trackdir.
|
|
|
|
*/
|
|
|
|
static inline byte SignalAlongTrackdir(Trackdir trackdir)
|
|
|
|
{
|
|
|
|
extern const byte _signal_along_trackdir[TRACKDIR_END];
|
|
|
|
return _signal_along_trackdir[trackdir];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps a trackdir to the bit that stores its status in the map arrays, in the
|
|
|
|
* direction against the trackdir.
|
|
|
|
*/
|
|
|
|
static inline byte SignalAgainstTrackdir(Trackdir trackdir)
|
|
|
|
{
|
|
|
|
extern const byte _signal_against_trackdir[TRACKDIR_END];
|
|
|
|
return _signal_against_trackdir[trackdir];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps a Track to the bits that store the status of the two signals that can
|
|
|
|
* be present on the given track.
|
|
|
|
*/
|
|
|
|
static inline byte SignalOnTrack(Track track)
|
|
|
|
{
|
|
|
|
extern const byte _signal_on_track[TRACK_END];
|
|
|
|
return _signal_on_track[track];
|
|
|
|
}
|
|
|
|
|
2008-05-14 16:38:53 +00:00
|
|
|
/** State of the signal segment */
|
|
|
|
enum SigSegState {
|
|
|
|
SIGSEG_FREE, ///< Free and has no pre-signal exits or at least one green exit
|
|
|
|
SIGSEG_FULL, ///< Occupied by a train
|
2008-08-02 22:55:52 +00:00
|
|
|
SIGSEG_PBS, ///< Segment is a PBS segment
|
2008-05-14 16:38:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SigSegState UpdateSignalsOnSegment(TileIndex tile, DiagDirection side, Owner owner);
|
2008-01-15 15:00:01 +00:00
|
|
|
void SetSignalsOnBothDir(TileIndex tile, Track track, Owner owner);
|
2008-01-16 01:18:15 +00:00
|
|
|
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner);
|
|
|
|
void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner);
|
|
|
|
void UpdateSignalsInBuffer();
|
2008-01-09 23:00:59 +00:00
|
|
|
|
2007-12-25 23:42:52 +00:00
|
|
|
#endif /* SIGNAL_FUNC_H */
|