From ce5304f9a2ca43f6b32fbfb09b2d72106b0a7055 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 4 Jan 2009 14:36:19 +0000 Subject: [PATCH] (svn r14826) -Fix [FS#2494]: infinite loop in order lookahead when reserving a path (Swallow) --- src/train_cmd.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 5cf5947167..432ef9e8e8 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;