summaryrefslogtreecommitdiff
path: root/src/ship_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-04-10 10:47:21 +0000
committerfrosch <frosch@openttd.org>2011-04-10 10:47:21 +0000
commit5bf90860f8af2c648c2704f29e1c9ac28deddd55 (patch)
tree4dd6a62700c30a7956213bc231e10814a63e9c61 /src/ship_cmd.cpp
parentd1a50a01b46684486428a2b63959cb160a016c39 (diff)
downloadopenttd-5bf90860f8af2c648c2704f29e1c9ac28deddd55.tar.xz
(svn r22309) -Fix: Make road vehicles, ships and aircraft skip orders if they are leaving a depot and heading to the same one again; just like trains since r16322.
Diffstat (limited to 'src/ship_cmd.cpp')
-rw-r--r--src/ship_cmd.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 6eb03ebbf..ccc0c33b5 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -266,9 +266,16 @@ static const TileIndexDiffC _ship_leave_depot_offs[] = {
{ 0, -1}
};
-static void CheckShipLeaveDepot(Ship *v)
+static bool CheckShipLeaveDepot(Ship *v)
{
- if (!v->IsInDepot()) return;
+ if (!v->IsInDepot()) return false;
+
+ /* We are leaving a depot, but have to go to the exact same one; re-enter */
+ if (v->current_order.IsType(OT_GOTO_DEPOT) &&
+ IsShipDepotTile(v->tile) && GetDepotIndex(v->tile) == v->current_order.GetDestination()) {
+ VehicleEnterDepot(v);
+ return true;
+ }
TileIndex tile = v->tile;
Axis axis = GetShipDepotAxis(tile);
@@ -280,7 +287,7 @@ static void CheckShipLeaveDepot(Ship *v)
} else if (DiagdirReachesTracks((DiagDirection)(axis + 2)) & GetTileShipTrackStatus(TILE_ADD(tile, -2 * ToTileIndexDiff(_ship_leave_depot_offs[axis])))) {
v->direction = AxisToDirection(axis);
} else {
- return;
+ return false;
}
v->state = AxisToTrackBits(axis);
@@ -294,6 +301,8 @@ static void CheckShipLeaveDepot(Ship *v)
VehicleServiceInDepot(v);
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
SetWindowClassesDirty(WC_SHIPS_LIST);
+
+ return false;
}
static bool ShipAccelerate(Vehicle *v)
@@ -446,7 +455,7 @@ static void ShipController(Ship *v)
if (v->current_order.IsType(OT_LOADING)) return;
- CheckShipLeaveDepot(v);
+ if (CheckShipLeaveDepot(v)) return;
v->ShowVisualEffect();