Fix assertion failure when command triggers PBS tunnel/bridge unreserve

In the case where the signal update buffer is not currently empty
This commit is contained in:
Jonathan G Rennison
2021-03-16 03:23:00 +00:00
parent 1f360e97a1
commit fb64e29c6c
3 changed files with 16 additions and 1 deletions

View File

@@ -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);

View File

@@ -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

View File

@@ -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 */