mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
This commit is contained in:
parent
2232412f59
commit
41ee22ed99
2
npf.c
2
npf.c
@ -348,7 +348,7 @@ static int32 NPFRailPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare
|
||||
* encounter, if it is red */
|
||||
|
||||
/* Is this a presignal exit or combo? */
|
||||
SignalType sigtype = GetSignalType(tile, TrackdirToTrack(trackdir));
|
||||
SignalType sigtype = GetSignalType(tile);
|
||||
if (sigtype == SIGTYPE_EXIT || sigtype == SIGTYPE_COMBO) {
|
||||
/* Penalise exit and combo signals differently (heavier) */
|
||||
cost += _patches.npf_rail_firstred_exit_penalty;
|
||||
|
23
rail.h
23
rail.h
@ -42,15 +42,6 @@ typedef enum RailTileSubtypes {
|
||||
RAIL_SUBTYPE_MASK = 0x3C,
|
||||
} RailTileSubtype;
|
||||
|
||||
typedef enum SignalTypes {
|
||||
/* Stored in m4[0..1] for MP_RAILWAY */
|
||||
SIGTYPE_NORMAL = 0, // normal signal
|
||||
SIGTYPE_ENTRY = 1, // presignal block entry
|
||||
SIGTYPE_EXIT = 2, // presignal block exit
|
||||
SIGTYPE_COMBO = 3, // presignal inter-block
|
||||
SIGTYPE_END,
|
||||
SIGTYPE_MASK = 3,
|
||||
} SignalType;
|
||||
|
||||
typedef enum RailTypes {
|
||||
RAILTYPE_RAIL = 0,
|
||||
@ -514,20 +505,6 @@ static inline SignalState GetSignalState(TileIndex tile, Trackdir trackdir)
|
||||
SIGNAL_STATE_GREEN : SIGNAL_STATE_RED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of signal on a given track on a given rail tile with signals.
|
||||
*
|
||||
* Note that currently, the track argument is not used, since
|
||||
* signal types cannot be mixed. This function is trying to be
|
||||
* future-compatible, though.
|
||||
*/
|
||||
static inline SignalType GetSignalType(TileIndex tile, Track track)
|
||||
{
|
||||
assert(IsValidTrack(track));
|
||||
assert(GetRailTileType(tile) == RAIL_TYPE_SIGNALS);
|
||||
return (SignalType)(_m[tile].m4 & SIGTYPE_MASK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
|
||||
|
@ -745,8 +745,9 @@ int32 CmdBuildSingleSignal(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
} else {
|
||||
if (pre_signal) {
|
||||
// cycle between normal -> pre -> exit -> combo -> ...
|
||||
byte type = (GetSignalType(tile, track) + 1) % SIGTYPE_END;
|
||||
SB(_m[tile].m4, 0, 2, type);
|
||||
SignalType type = GetSignalType(tile);
|
||||
|
||||
SetSignalType(tile, type == SIGTYPE_COMBO ? SIGTYPE_NORMAL : type + 1);
|
||||
} else {
|
||||
// cycle between two-way -> one-way -> one-way -> ...
|
||||
/* TODO: Rewrite switch into something more general */
|
||||
@ -2035,7 +2036,7 @@ static void GetTileDesc_Track(TileIndex tile, TileDesc *td)
|
||||
STR_RAILROAD_TRACK_WITH_COMBOSIGNALS
|
||||
};
|
||||
|
||||
td->str = signal_type[GB(_m[tile].m4, 0, 2)];
|
||||
td->str = signal_type[GetSignalType(tile)];
|
||||
break;
|
||||
}
|
||||
|
||||
|
20
rail_map.h
20
rail_map.h
@ -20,6 +20,26 @@ static inline TrackBits GetRailWaypointBits(TileIndex t)
|
||||
}
|
||||
|
||||
|
||||
typedef enum SignalType {
|
||||
SIGTYPE_NORMAL = 0, // normal signal
|
||||
SIGTYPE_ENTRY = 1, // presignal block entry
|
||||
SIGTYPE_EXIT = 2, // presignal block exit
|
||||
SIGTYPE_COMBO = 3 // presignal inter-block
|
||||
} SignalType;
|
||||
|
||||
static inline SignalType GetSignalType(TileIndex t)
|
||||
{
|
||||
assert(GetRailTileType(t) == RAIL_TYPE_SIGNALS);
|
||||
return (SignalType)GB(_m[t].m4, 0, 2);
|
||||
}
|
||||
|
||||
static inline void SetSignalType(TileIndex t, SignalType s)
|
||||
{
|
||||
assert(GetRailTileType(t) == RAIL_TYPE_SIGNALS);
|
||||
SB(_m[t].m4, 0, 2, s);
|
||||
}
|
||||
|
||||
|
||||
typedef enum SignalVariant {
|
||||
SIG_ELECTRIC = 0,
|
||||
SIG_SEMAPHORE = 1
|
||||
|
Loading…
Reference in New Issue
Block a user