Fix reservation not cleared from far end of signalled tunnel when removing
This commit is contained in:
@@ -1158,11 +1158,18 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
|
||||
Track track = DiagDirToDiagTrack(dir);
|
||||
Owner owner = GetTileOwner(tile);
|
||||
|
||||
Train *v = nullptr;
|
||||
if (HasTunnelReservation(tile)) {
|
||||
v = GetTrainForReservation(tile, track);
|
||||
if (v != nullptr) FreeTrainTrackReservation(v);
|
||||
}
|
||||
std::vector<Train *> vehicles_affected;
|
||||
auto check_tile = [&](TileIndex t) {
|
||||
if (HasTunnelReservation(t)) {
|
||||
Train *v = GetTrainForReservation(t, track);
|
||||
if (v != nullptr) {
|
||||
FreeTrainTrackReservation(v);
|
||||
vehicles_affected.push_back(v);
|
||||
}
|
||||
}
|
||||
};
|
||||
check_tile(tile);
|
||||
check_tile(endtile);
|
||||
|
||||
if (Company::IsValidID(owner)) {
|
||||
Company::Get(owner)->infrastructure.rail[GetRailType(tile)] -= len * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
||||
@@ -1184,7 +1191,9 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
|
||||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
YapfNotifyTrackLayoutChange(endtile, track);
|
||||
|
||||
if (v != nullptr) TryPathReserve(v);
|
||||
for (Train *v : vehicles_affected) {
|
||||
TryPathReserve(v);
|
||||
}
|
||||
} else {
|
||||
/* A full diagonal road tile has two road bits. */
|
||||
UpdateCompanyRoadInfrastructure(GetRoadTypeRoad(tile), GetRoadOwner(tile, RTT_ROAD), -(int)(len * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR));
|
||||
|
Reference in New Issue
Block a user