mirror of https://github.com/OpenTTD/OpenTTD.git
(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:
parent
6c7c02eb14
commit
2728cb21a9
|
@ -2416,7 +2416,7 @@ public:
|
||||||
|
|
||||||
if (skip_first) ++this->index;
|
if (skip_first) ++this->index;
|
||||||
|
|
||||||
int conditional_depth = 0;
|
int depth = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Wrap around. */
|
/* Wrap around. */
|
||||||
|
@ -2434,10 +2434,9 @@ public:
|
||||||
this->v->current_order = *order;
|
this->v->current_order = *order;
|
||||||
return UpdateOrderDest(this->v, order, 0, true);
|
return UpdateOrderDest(this->v, order, 0, 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++;
|
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;
|
||||||
|
@ -2450,7 +2449,8 @@ public:
|
||||||
/* Don't increment inside the while because otherwise conditional
|
/* Don't increment inside the while because otherwise conditional
|
||||||
* orders can lead to an infinite loop. */
|
* orders can lead to an infinite loop. */
|
||||||
++this->index;
|
++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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue