Fix bridges not being redrawn after all signals reset when cleared
This commit is contained in:
@@ -107,17 +107,22 @@ void SetBridgeEntranceSimulatedSignalStateExtended(TileIndex t, uint16 signal, S
|
|||||||
_m[t].m2 |= BRIDGE_M2_SIGNAL_STATE_EXT_FLAG;
|
_m[t].m2 |= BRIDGE_M2_SIGNAL_STATE_EXT_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAllBridgeEntranceSimulatedSignalsGreenExtended(TileIndex t)
|
bool SetAllBridgeEntranceSimulatedSignalsGreenExtended(TileIndex t)
|
||||||
{
|
{
|
||||||
|
bool changed = GB(_m[t].m2, BRIDGE_M2_SIGNAL_STATE_OFFSET, BRIDGE_M2_SIGNAL_STATE_COUNT) != 0;
|
||||||
SB(_m[t].m2, BRIDGE_M2_SIGNAL_STATE_OFFSET, BRIDGE_M2_SIGNAL_STATE_FIELD_SIZE, 0);
|
SB(_m[t].m2, BRIDGE_M2_SIGNAL_STATE_OFFSET, BRIDGE_M2_SIGNAL_STATE_FIELD_SIZE, 0);
|
||||||
auto it = _long_bridge_signal_sim_map.find(t);
|
auto it = _long_bridge_signal_sim_map.find(t);
|
||||||
if (it != _long_bridge_signal_sim_map.end()) {
|
if (it != _long_bridge_signal_sim_map.end()) {
|
||||||
LongBridgeSignalStorage &lbss = it->second;
|
LongBridgeSignalStorage &lbss = it->second;
|
||||||
for (auto &it : lbss.signal_red_bits) {
|
for (auto &it : lbss.signal_red_bits) {
|
||||||
it = 0;
|
if (it != 0) {
|
||||||
|
changed = true;
|
||||||
|
it = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_m[t].m2 |= BRIDGE_M2_SIGNAL_STATE_EXT_FLAG;
|
_m[t].m2 |= BRIDGE_M2_SIGNAL_STATE_EXT_FLAG;
|
||||||
}
|
}
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearBridgeEntranceSimulatedSignalsExtended(TileIndex t)
|
void ClearBridgeEntranceSimulatedSignalsExtended(TileIndex t)
|
||||||
|
@@ -53,14 +53,16 @@ static inline void SetBridgeEntranceSimulatedSignalState(TileIndex t, uint16 sig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAllBridgeEntranceSimulatedSignalsGreenExtended(TileIndex t);
|
bool SetAllBridgeEntranceSimulatedSignalsGreenExtended(TileIndex t);
|
||||||
|
|
||||||
static inline void SetAllBridgeEntranceSimulatedSignalsGreen(TileIndex t)
|
static inline bool SetAllBridgeEntranceSimulatedSignalsGreen(TileIndex t)
|
||||||
{
|
{
|
||||||
if (_m[t].m2 & BRIDGE_M2_SIGNAL_STATE_EXT_FLAG) {
|
if (_m[t].m2 & BRIDGE_M2_SIGNAL_STATE_EXT_FLAG) {
|
||||||
SetAllBridgeEntranceSimulatedSignalsGreenExtended(t);
|
return SetAllBridgeEntranceSimulatedSignalsGreenExtended(t);
|
||||||
} else {
|
} else {
|
||||||
|
bool changed = GB(_m[t].m2, BRIDGE_M2_SIGNAL_STATE_OFFSET, BRIDGE_M2_SIGNAL_STATE_FIELD_SIZE) != 0;
|
||||||
SB(_m[t].m2, BRIDGE_M2_SIGNAL_STATE_OFFSET, BRIDGE_M2_SIGNAL_STATE_FIELD_SIZE, 0);
|
SB(_m[t].m2, BRIDGE_M2_SIGNAL_STATE_OFFSET, BRIDGE_M2_SIGNAL_STATE_FIELD_SIZE, 0);
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2763,8 +2763,14 @@ static void HandleLastTunnelBridgeSignals(TileIndex tile, TileIndex end, DiagDir
|
|||||||
if (free) {
|
if (free) {
|
||||||
/* Open up the wormhole and clear m2. */
|
/* Open up the wormhole and clear m2. */
|
||||||
if (IsBridge(end)) {
|
if (IsBridge(end)) {
|
||||||
if (IsTunnelBridgeSignalSimulationEntrance(tile)) SetAllBridgeEntranceSimulatedSignalsGreen(tile);
|
bool redraw = false;
|
||||||
if (IsTunnelBridgeSignalSimulationEntrance(end)) SetAllBridgeEntranceSimulatedSignalsGreen(end);
|
if (IsTunnelBridgeSignalSimulationEntrance(tile)) {
|
||||||
|
redraw |= SetAllBridgeEntranceSimulatedSignalsGreen(tile);
|
||||||
|
}
|
||||||
|
if (IsTunnelBridgeSignalSimulationEntrance(end)) {
|
||||||
|
redraw |= SetAllBridgeEntranceSimulatedSignalsGreen(end);
|
||||||
|
}
|
||||||
|
if (redraw) MarkBridgeDirty(tile, end, GetTunnelBridgeDirection(tile), GetBridgeHeight(tile), VMDF_NOT_MAP_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsTunnelBridgeSignalSimulationEntrance(end) && GetTunnelBridgeEntranceSignalState(end) == SIGNAL_STATE_RED) {
|
if (IsTunnelBridgeSignalSimulationEntrance(end) && GetTunnelBridgeEntranceSignalState(end) == SIGNAL_STATE_RED) {
|
||||||
|
Reference in New Issue
Block a user