diff --git a/src/order_base.h b/src/order_base.h index 3fa8f3fffb..27e335433b 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -218,11 +218,12 @@ public: /** * Update the jump_counter of this order. - * @param the jump chance in %. + * @param percent the jump chance in %. + * @param dry_run whether this is a dry-run, so do not execute side-effects * @return whether to jump or not. * @pre IsType(OT_CONDITIONAL) && this->GetConditionVariable() == OCV_PERCENT. */ - bool UpdateJumpCounter(uint8 percent); + bool UpdateJumpCounter(uint8 percent, bool dry_run); /** How must the consist be loaded? */ inline OrderLoadFlags GetLoadType() const diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 58547d21ce..1b94e63cd1 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -169,10 +169,14 @@ void Order::MakeLoading(bool ordered) * Not that jump_counter is signed and may become * negative when a jump has been taken * + * @param percent the jump chance in %. + * @param dry_run whether this is a dry-run, so do not execute side-effects + * * @return true if the jump should be taken */ -bool Order::UpdateJumpCounter(byte percent) +bool Order::UpdateJumpCounter(byte percent, bool dry_run) { + if (dry_run) return this->jump_counter >= 0; if (this->jump_counter >= 0) { this->jump_counter += (percent - 100); return true; @@ -2690,7 +2694,7 @@ VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v, boo case OCV_PERCENT: { /* get a non-const reference to the current order */ Order *ord = const_cast(order); - skip_order = ord->UpdateJumpCounter((byte)value); + skip_order = ord->UpdateJumpCounter((byte)value, dry_run); break; } case OCV_REMAINING_LIFETIME: skip_order = OrderConditionCompare(occ, max(v->max_age - v->age + DAYS_IN_LEAP_YEAR - 1, 0) / DAYS_IN_LEAP_YEAR, value); break;