summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/train_cmd.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 5cf594716..432ef9e8e 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2849,6 +2849,8 @@ public:
{
++this->index;
+ int conditional_depth = 0;
+
do {
/* Wrap around. */
if (this->index >= this->v->GetNumOrders()) this->index = 0;
@@ -2866,8 +2868,10 @@ public:
UpdateOrderDest(this->v, order);
return true;
case OT_CONDITIONAL: {
+ if (conditional_depth > this->v->GetNumOrders()) return false;
VehicleOrderID next = ProcessConditionalOrder(order, this->v);
if (next != INVALID_VEH_ORDER_ID) {
+ conditional_depth++;
this->index = next;
/* Don't increment next, so no break here. */
continue;