mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
Show tunnel/bridge exit signal facing correct way with correct colour.
This commit is contained in:
parent
a25ac7a161
commit
2b4dbf582a
@ -390,11 +390,17 @@ static SigFlags ExploreSegment(Owner owner)
|
||||
if (HasVehicleOnPos(GetOtherTunnelBridgeEnd(tile), &tile, &TrainInWormholeTileEnum)) flags |= SF_TRAIN;
|
||||
if (!(flags & SF_TRAIN) && HasVehicleOnPos(tile, &tile, &TrainInWormholeTileEnum)) flags |= SF_TRAIN;
|
||||
}
|
||||
if (IsTunnelBridgeExit(tile) && !_tbuset.Add(tile, INVALID_TRACKDIR)) {
|
||||
return flags | SF_FULL;
|
||||
}
|
||||
enterdir = dir;
|
||||
exitdir = ReverseDiagDir(dir);
|
||||
tile += TileOffsByDiagDir(exitdir); // just skip to next tile
|
||||
} else { // NOT incoming from the wormhole!
|
||||
if (ReverseDiagDir(enterdir) != dir) continue;
|
||||
if (IsTunnelBridgeExit(tile) && !_tbuset.Add(tile, INVALID_TRACKDIR)) {
|
||||
return flags | SF_FULL;
|
||||
}
|
||||
if (!(flags & SF_TRAIN)) {
|
||||
if (HasVehicleOnPos(tile, &tile, &TrainInWormholeTileEnum)) flags |= SF_TRAIN;
|
||||
if (!(flags & SF_TRAIN) && IsTunnelBridgeExit(tile)) {
|
||||
@ -443,6 +449,16 @@ static void UpdateSignalsAroundSegment(SigFlags flags)
|
||||
Trackdir trackdir;
|
||||
|
||||
while (_tbuset.Get(&tile, &trackdir)) {
|
||||
if (IsTileType(tile, MP_TUNNELBRIDGE) && IsTunnelBridgeExit(tile)) {
|
||||
bool old_state = IsTunnelBridgeExitGreen(tile);
|
||||
bool new_state = !(flags & SF_TRAIN);
|
||||
if (old_state != new_state) {
|
||||
SetTunnelBridgeExitGreen(tile, new_state);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
assert(HasSignalOnTrackdir(tile, trackdir));
|
||||
|
||||
SignalType sig = GetSignalType(tile, TrackdirToTrack(trackdir));
|
||||
|
@ -1164,20 +1164,34 @@ static void DrawTunnelBridgeRampSignal(const TileInfo *ti)
|
||||
case DIAGDIR_NW: position = 3; break;
|
||||
}
|
||||
|
||||
uint x = TileX(ti->tile) * TILE_SIZE + SignalPositions[side][position].x;
|
||||
uint y = TileY(ti->tile) * TILE_SIZE + SignalPositions[side][position].y;
|
||||
bool is_green;
|
||||
bool show_exit;
|
||||
if (IsTunnelBridgeExit(ti->tile) && IsBridge(ti->tile)) {
|
||||
is_green = IsTunnelBridgeExitGreen(ti->tile);
|
||||
show_exit = true;
|
||||
position ^= 1;
|
||||
} else {
|
||||
is_green = IsTunnelBridgeWithSignGreen(ti->tile);
|
||||
show_exit = false;
|
||||
}
|
||||
|
||||
uint x = TileX(ti->tile) * TILE_SIZE + SignalPositions[side != show_exit][position ^ show_exit].x;
|
||||
uint y = TileY(ti->tile) * TILE_SIZE + SignalPositions[side != show_exit][position ^ show_exit].y;
|
||||
uint z = ti->z;
|
||||
|
||||
if (ti->tileh == SLOPE_FLAT && side == show_exit && dir == DIAGDIR_SE) z += 2;
|
||||
if (ti->tileh == SLOPE_FLAT && side != show_exit && dir == DIAGDIR_SW) z += 2;
|
||||
|
||||
if (ti->tileh != SLOPE_FLAT && IsBridge(ti->tile)) z += 8; // sloped bridge head
|
||||
SignalVariant variant = (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC);
|
||||
|
||||
SpriteID sprite;
|
||||
if (variant == SIG_ELECTRIC) {
|
||||
/* Normal electric signals are picked from original sprites. */
|
||||
sprite = SPR_ORIGINAL_SIGNALS_BASE + ((position << 1) + IsTunnelBridgeWithSignGreen(ti->tile));
|
||||
sprite = SPR_ORIGINAL_SIGNALS_BASE + ((position << 1) + is_green);
|
||||
} else {
|
||||
/* All other signals are picked from add on sprites. */
|
||||
sprite = SPR_SIGNALS_BASE + ((SIGTYPE_NORMAL - 1) * 16 + variant * 64 + (position << 1) + IsTunnelBridgeWithSignGreen(ti->tile));
|
||||
sprite = SPR_SIGNALS_BASE + ((SIGTYPE_NORMAL - 1) * 16 + variant * 64 + (position << 1) + is_green);
|
||||
}
|
||||
|
||||
AddSortableSpriteToDraw(sprite, PAL_NONE, x, y, 1, 1, TILE_HEIGHT, z, false, 0, 0, BB_Z_SEPARATOR);
|
||||
|
@ -213,6 +213,16 @@ static inline bool IsTunnelBridgeExit(TileIndex t)
|
||||
return !HasBit(_m[t].m5, 5) && HasBit(_m[t].m5, 6);
|
||||
}
|
||||
|
||||
static inline bool IsTunnelBridgeExitGreen(TileIndex t)
|
||||
{
|
||||
assert(IsTunnelBridgeExit(t));
|
||||
return HasBit(_me[t].m6, 0);
|
||||
}
|
||||
|
||||
static inline void SetTunnelBridgeExitGreen(TileIndex t, bool green)
|
||||
{
|
||||
assert(IsTunnelBridgeExit(t));
|
||||
SB(_me[t].m6, 0, 1, green ? 1 : 0);
|
||||
}
|
||||
|
||||
#endif /* TUNNELBRIDGE_MAP_H */
|
||||
|
Loading…
Reference in New Issue
Block a user