summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2018-05-18 18:02:53 +0100
committerCharles Pigott <charlespigott@googlemail.com>2019-01-14 19:57:07 +0000
commitb98887c4a014d5bc193b0c1089b3ac0334187775 (patch)
treea7bbaef87736f400385a7fd558456f3d443f0c36
parentebddd596c7138d629ec0259d2397c1039401ada7 (diff)
downloadopenttd-b98887c4a014d5bc193b0c1089b3ac0334187775.tar.xz
Change: Allow only one ship to leave depot at a time.
-rw-r--r--src/ship_cmd.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 0ea400b95..080015eac 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -319,6 +319,14 @@ void Ship::UpdateDeltaXY()
this->z_extent = 6;
}
+/**
+ * Test-procedure for HasVehicleOnPos to check for a ship.
+ */
+static Vehicle *EnsureNoVisibleShipProc(Vehicle *v, void *data)
+{
+ return v->type == VEH_SHIP && (v->vehstatus & VS_HIDDEN) == 0 ? v : NULL;
+}
+
static bool CheckShipLeaveDepot(Ship *v)
{
if (!v->IsChainInDepot()) return false;
@@ -333,6 +341,10 @@ static bool CheckShipLeaveDepot(Ship *v)
/* Don't leave depot if no destination set */
if (v->dest_tile == 0) return true;
+ /* Don't leave depot if another vehicle is already entering/leaving */
+ /* This helps avoid CPU load if many ships are set to start at the same time */
+ if (HasVehicleOnPos(v->tile, NULL, &EnsureNoVisibleShipProc)) return true;
+
TileIndex tile = v->tile;
Axis axis = GetShipDepotAxis(tile);