summaryrefslogtreecommitdiff
path: root/src/ship_cmd.cpp
diff options
context:
space:
mode:
authorPeterN <peter@fuzzle.org>2018-06-14 09:25:39 +0100
committerGitHub <noreply@github.com>2018-06-14 09:25:39 +0100
commitc2a77280842b5d752ef6c744adab20d9d1b67857 (patch)
tree1598d70926196cdaf99b64396a8624c1774411dc /src/ship_cmd.cpp
parent7ae1e3e1e2a23b5cbd09bc88f9abd7ccdde23201 (diff)
downloadopenttd-c2a77280842b5d752ef6c744adab20d9d1b67857.tar.xz
Fix: Prevent ships moving into docks after finishing (un)loading. (#6791)
Diffstat (limited to 'src/ship_cmd.cpp')
-rw-r--r--src/ship_cmd.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 967cd4e1d..0bdcf7041 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -537,6 +537,10 @@ static void ShipController(Ship *v)
if (v->current_order.IsType(OT_LEAVESTATION)) {
v->current_order.Free();
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
+ /* Test if continuing forward would lead to a dead-end, moving into the dock. */
+ DiagDirection exitdir = VehicleExitDir(v->direction, v->state);
+ TileIndex tile = TileAddByDiagDir(v->tile, exitdir);
+ if (TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0, exitdir)) == TRACK_BIT_NONE) goto reverse_direction;
} else if (v->dest_tile != 0) {
/* We have a target, let's see if we reached it... */
if (v->current_order.IsType(OT_GOTO_WAYPOINT) &&