summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2008-10-19 17:16:26 +0000
committermichi_cc <michi_cc@openttd.org>2008-10-19 17:16:26 +0000
commit6815cc52fec52c2db050211737fdad22bec4294c (patch)
tree64a5033e39b43369d5972ba15af917c44c2be064 /src
parentd832626bb9f8009c636c3ebef0620ead499ef8d3 (diff)
downloadopenttd-6815cc52fec52c2db050211737fdad22bec4294c.tar.xz
(svn r14492) -Fix [FS#2366] (r14482): Conditional orders could lead to an infinite loop on path look-ahead.
Don't refactor things that don't want to be refactored, folks. And some comments can't hurt either.
Diffstat (limited to 'src')
-rw-r--r--src/train_cmd.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 9e10b5169..be41cf556 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2857,6 +2857,7 @@ public:
VehicleOrderID next = ProcessConditionalOrder(order, this->v);
if (next != INVALID_VEH_ORDER_ID) {
this->index = next;
+ /* Don't increment next, so no break here. */
continue;
}
break;
@@ -2864,7 +2865,10 @@ public:
default:
break;
}
- } while (++this->index != this->v->cur_order_index);
+ /* Don't increment inside the while because otherwise conditional
+ * orders can lead to an infinite loop. */
+ ++this->index;
+ } while (this->index != this->v->cur_order_index);
return false;
}