Fix #9521: Don't load at just removed docks that were part of a multi-dock station (#9524)

This commit is contained in:
SamuXarick
2021-09-18 12:25:07 +01:00
committed by GitHub
parent b335b0501c
commit 18247bb3b8

View File

@@ -2720,19 +2720,24 @@ static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
ClearDockingTilesCheckingNeighbours(tile1); ClearDockingTilesCheckingNeighbours(tile1);
ClearDockingTilesCheckingNeighbours(tile2); ClearDockingTilesCheckingNeighbours(tile2);
/* All ships that were going to our station, can't go to it anymore. for (Ship *s : Ship::Iterate()) {
* Just clear the order, then automatically the next appropriate order /* Find all ships going to our dock. */
* will be selected and in case of no appropriate order it will just if (s->current_order.GetDestination() != st->index) {
* wander around the world. */ continue;
if (!(st->facilities & FACIL_DOCK)) { }
for (Ship *s : Ship::Iterate()) {
if (s->current_order.IsType(OT_LOADING) && s->current_order.GetDestination() == st->index) {
s->LeaveStation();
}
if (s->current_order.IsType(OT_GOTO_STATION) && s->current_order.GetDestination() == st->index) { /* Find ships that are marked as "loading" but are no longer on a
s->SetDestTile(s->GetOrderStationLocation(st->index)); * docking tile. Force them to leave the station (as they were loading
} * on the removed dock). */
if (s->current_order.IsType(OT_LOADING) && !(IsDockingTile(s->tile) && IsShipDestinationTile(s->tile, st->index))) {
s->LeaveStation();
}
/* If we no longer have a dock, mark the order as invalid and send
* the ship to the next order (or, if there is none, make it
* wander the world). */
if (s->current_order.IsType(OT_GOTO_STATION) && !(st->facilities & FACIL_DOCK)) {
s->SetDestTile(s->GetOrderStationLocation(st->index));
} }
} }
} }