(svn r14826) -Fix [FS#2494]: infinite loop in order lookahead when reserving a path (Swallow)

This commit is contained in:
rubidium 2009-01-04 14:36:19 +00:00
parent 2283b8038f
commit ce5304f9a2

View File

@ -2849,6 +2849,8 @@ public:
{ {
++this->index; ++this->index;
int conditional_depth = 0;
do { do {
/* Wrap around. */ /* Wrap around. */
if (this->index >= this->v->GetNumOrders()) this->index = 0; if (this->index >= this->v->GetNumOrders()) this->index = 0;
@ -2866,8 +2868,10 @@ public:
UpdateOrderDest(this->v, order); UpdateOrderDest(this->v, order);
return true; return true;
case OT_CONDITIONAL: { case OT_CONDITIONAL: {
if (conditional_depth > this->v->GetNumOrders()) return false;
VehicleOrderID next = ProcessConditionalOrder(order, this->v); VehicleOrderID next = ProcessConditionalOrder(order, this->v);
if (next != INVALID_VEH_ORDER_ID) { if (next != INVALID_VEH_ORDER_ID) {
conditional_depth++;
this->index = next; this->index = next;
/* Don't increment next, so no break here. */ /* Don't increment next, so no break here. */
continue; continue;