1
0
Fork 0

(svn r4377) -Add and make use of a function that finds out whether a signal is an entry or and exit signal to a presignal block (as combos act as both)

release/0.5
celestar 2006-04-12 09:12:33 +00:00
parent e79c36bf8c
commit 5ae9a03a1f
2 changed files with 15 additions and 5 deletions

View File

@ -1498,10 +1498,10 @@ static bool SetSignalsEnumProc(TileIndex tile, SetSignalsData *ssd, int track, u
} }
// remember if this block has a presignal. // remember if this block has a presignal.
ssd->has_presignal |= (_m[tile].m4 & 1); ssd->has_presignal |= IsPresignalEntry(tile);
} }
if (HasSignalOnTrackdir(tile, track) && _m[tile].m4 & 2) { if (HasSignalOnTrackdir(tile, track) && IsPresignalExit(tile)) {
// this is an exit signal that points out from the segment // this is an exit signal that points out from the segment
ssd->presignal_exits++; ssd->presignal_exits++;
if (GetSignalStateByTrackdir(tile, track) != SIGNAL_STATE_RED) if (GetSignalStateByTrackdir(tile, track) != SIGNAL_STATE_RED)
@ -1647,11 +1647,11 @@ static void ChangeSignalStates(SetSignalsData *ssd)
uint16 m2 = _m[tile].m2; uint16 m2 = _m[tile].m2;
// presignals don't turn green if there is at least one presignal exit and none are free // presignals don't turn green if there is at least one presignal exit and none are free
if (_m[tile].m4 & 1) { if (IsPresignalEntry(tile)) {
int ex = ssd->presignal_exits, exfree = ssd->presignal_exits_free; int ex = ssd->presignal_exits, exfree = ssd->presignal_exits_free;
// subtract for dual combo signals so they don't count themselves // subtract for dual combo signals so they don't count themselves
if (_m[tile].m4 & 2 && HasSignalOnTrackdir(tile, ssd->bit[i])) { if (IsPresignalExit(tile) && HasSignalOnTrackdir(tile, ssd->bit[i])) {
ex--; ex--;
if (GetSignalStateByTrackdir(tile, ssd->bit[i]) != SIGNAL_STATE_RED) exfree--; if (GetSignalStateByTrackdir(tile, ssd->bit[i]) != SIGNAL_STATE_RED) exfree--;
} }
@ -1671,7 +1671,7 @@ make_red:
} }
/* Update signals on the other side of this exit-combo signal; it changed. */ /* Update signals on the other side of this exit-combo signal; it changed. */
if (_m[tile].m4 & 2) { if (IsPresignalExit(tile)) {
if (ssd->cur_stack != NUM_SSD_STACK) { if (ssd->cur_stack != NUM_SSD_STACK) {
ssd->next_tile[ssd->cur_stack] = tile; ssd->next_tile[ssd->cur_stack] = tile;
ssd->next_dir[ssd->cur_stack] = _dir_from_track[ssd->bit[i]]; ssd->next_dir[ssd->cur_stack] = _dir_from_track[ssd->bit[i]];

View File

@ -164,6 +164,16 @@ static inline void SetSignalType(TileIndex t, SignalType s)
SB(_m[t].m4, 0, 2, s); SB(_m[t].m4, 0, 2, s);
} }
static inline bool IsPresignalEntry(TileIndex t)
{
return GetSignalType(t) == SIGTYPE_ENTRY || GetSignalType(t) == SIGTYPE_COMBO;
}
static inline bool IsPresignalExit(TileIndex t)
{
return GetSignalType(t) == SIGTYPE_EXIT || GetSignalType(t) == SIGTYPE_COMBO;
}
typedef enum SignalVariant { typedef enum SignalVariant {
SIG_ELECTRIC = 0, SIG_ELECTRIC = 0,