Fix assertion failure when command triggers PBS tunnel/bridge unreserve

In the case where the signal update buffer is not currently empty
pull/226/head
Jonathan G Rennison 3 years ago
parent 1f360e97a1
commit fb64e29c6c

@ -241,7 +241,9 @@ void UnreserveRailTrack(TileIndex tile, Track t)
if (IsTunnelBridgePBS(tile)) {
SetTunnelBridgeExitSignalState(tile, SIGNAL_STATE_RED);
} else {
UpdateSignalsOnSegment(tile, INVALID_DIAGDIR, GetTileOwner(tile));
UpdateSignalsInBufferIfOwnerNotAddable(GetTileOwner(tile));
AddSideToSignalBuffer(tile, INVALID_DIAGDIR, GetTileOwner(tile));
UpdateSignalsInBuffer();
}
}
MarkBridgeOrTunnelDirtyOnReservationChange(tile, VMDF_NOT_MAP_MODE);

@ -735,6 +735,18 @@ void UpdateSignalsInBuffer()
}
}
/**
* Update signals in buffer if the owner could not be added to the current buffer
* Called from 'outside'
*/
void UpdateSignalsInBufferIfOwnerNotAddable(Owner owner)
{
if (!_globset.IsEmpty() && !IsOneSignalBlock(owner, _last_owner)) {
UpdateSignalsInBuffer(_last_owner);
_last_owner = INVALID_OWNER; // invalidate
}
}
/**
* Add track to signal update buffer

@ -152,5 +152,6 @@ void SetSignalsOnBothDir(TileIndex tile, Track track, Owner owner);
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner);
void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner);
void UpdateSignalsInBuffer();
void UpdateSignalsInBufferIfOwnerNotAddable(Owner owner);
#endif /* SIGNAL_FUNC_H */

Loading…
Cancel
Save