diff --git a/src/linkgraph/refresh.cpp b/src/linkgraph/refresh.cpp index 97632d160d..eda67d8b36 100644 --- a/src/linkgraph/refresh.cpp +++ b/src/linkgraph/refresh.cpp @@ -209,7 +209,7 @@ const Order *LinkRefresher::PredictNextOrder(const Order *cur, const Order *next const Order *skip_to = this->vehicle->orders.list->GetNextDecisionNode( this->vehicle->orders.list->GetOrderAt(next->GetConditionSkipToOrder()), num_hops, this_cargo_mask); assert(this_cargo_mask == this->cargo_mask); - if (skip_to != nullptr && num_hops < this->vehicle->orders.list->GetNumOrders() && skip_to != next) { + if (skip_to != nullptr && num_hops < min(64, this->vehicle->orders.list->GetNumOrders()) && skip_to != next) { /* Make copies of capacity tracking lists. There is potential * for optimization here: If the vehicle never refits we don't * need to copy anything. Also, if we've seen the branched link diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 0f50ca3d80..0d070a0b98 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -542,7 +542,7 @@ VehicleOrderID OrderList::GetIndexOfOrder(const Order *order) const */ const Order *OrderList::GetNextDecisionNode(const Order *next, uint hops, CargoTypes &cargo_mask) const { - if (hops > this->GetNumOrders() || next == nullptr) return nullptr; + if (hops > min(64, this->GetNumOrders()) || next == nullptr) return nullptr; if (next->IsType(OT_CONDITIONAL)) { if (next->GetConditionVariable() != OCV_UNCONDITIONALLY) return next;