Improve link refresher handling of conditional orders

This commit is contained in:
Jonathan G Rennison
2020-05-14 18:40:25 +01:00
parent d37d08ebb3
commit 212f6f4dcb

View File

@@ -197,11 +197,19 @@ const Order *LinkRefresher::PredictNextOrder(const Order *cur, const Order *next
SetBit(flags, USE_NEXT);
if (next->IsType(OT_CONDITIONAL)) {
if (next->GetConditionVariable() == OCV_UNCONDITIONALLY) {
CargoTypes this_cargo_mask = this->cargo_mask;
next = this->vehicle->orders.list->GetNextDecisionNode(
this->vehicle->orders.list->GetOrderAt(next->GetConditionSkipToOrder()),
num_hops++, this_cargo_mask);
assert(this_cargo_mask == this->cargo_mask);
continue;
}
CargoTypes this_cargo_mask = this->cargo_mask;
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()) {
if (skip_to != nullptr && num_hops < 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