summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-01-04 14:36:19 +0000
committerrubidium <rubidium@openttd.org>2009-01-04 14:36:19 +0000
commitce5304f9a2ca43f6b32fbfb09b2d72106b0a7055 (patch)
treec3bb5f424d1792fc8aec5389920ebe7cc7483e6c
parent2283b8038f288d24ca719e482be256229430f53d (diff)
downloadopenttd-ce5304f9a2ca43f6b32fbfb09b2d72106b0a7055.tar.xz
(svn r14826) -Fix [FS#2494]: infinite loop in order lookahead when reserving a path (Swallow)
-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;