summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuXarick <43006711+SamuXarick@users.noreply.github.com>2021-09-18 12:25:07 +0100
committerGitHub <noreply@github.com>2021-09-18 13:25:07 +0200
commit18247bb3b8aaad6db1137e5590b695a8e0dd8068 (patch)
treedbb7b8e94b893afb2dfb3ac89a90549d7fd9c262
parentb335b0501cba1765ec97e89da828942cd925a1e9 (diff)
downloadopenttd-18247bb3b8aaad6db1137e5590b695a8e0dd8068.tar.xz
Fix #9521: Don't load at just removed docks that were part of a multi-dock station (#9524)
-rw-r--r--src/station_cmd.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index fa11c05d5..ab21d4424 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2720,19 +2720,24 @@ static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
ClearDockingTilesCheckingNeighbours(tile1);
ClearDockingTilesCheckingNeighbours(tile2);
- /* All ships that were going to our station, can't go to it anymore.
- * Just clear the order, then automatically the next appropriate order
- * will be selected and in case of no appropriate order it will just
- * wander around the world. */
- 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();
- }
+ for (Ship *s : Ship::Iterate()) {
+ /* Find all ships going to our dock. */
+ if (s->current_order.GetDestination() != st->index) {
+ continue;
+ }
- if (s->current_order.IsType(OT_GOTO_STATION) && s->current_order.GetDestination() == st->index) {
- s->SetDestTile(s->GetOrderStationLocation(st->index));
- }
+ /* Find ships that are marked as "loading" but are no longer on a
+ * 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));
}
}
}