(svn r23781) -Fix [FS#4964]: under certain circumstances, e.g. a single invalid order, trying to determine the next order state could end up in an infinite loop

This commit is contained in:
rubidium 2012-01-09 22:19:53 +00:00
parent 6c7c02eb14
commit 2728cb21a9
1 changed files with 4 additions and 4 deletions

View File

@ -2416,7 +2416,7 @@ public:
if (skip_first) ++this->index;
int conditional_depth = 0;
int depth = 0;
do {
/* Wrap around. */
@ -2434,10 +2434,9 @@ public:
this->v->current_order = *order;
return UpdateOrderDest(this->v, order, 0, 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++;
depth++;
this->index = next;
/* Don't increment next, so no break here. */
continue;
@ -2450,7 +2449,8 @@ public:
/* Don't increment inside the while because otherwise conditional
* orders can lead to an infinite loop. */
++this->index;
} while (this->index != this->v->cur_real_order_index);
depth++;
} while (this->index != this->v->cur_real_order_index && depth < this->v->GetNumOrders());
return false;
}