Don't use occupancy of unload and leave empty orders for occupancy average

pull/510/head
Jonathan G Rennison 1 year ago
parent c0f7ab8071
commit 359fe89d2f

@ -563,6 +563,8 @@ public:
*/
inline void SetOccupancy(uint8 occupancy) { this->occupancy = occupancy; }
bool UseOccupancyValueForAverage() const;
bool ShouldStopAtStation(StationID last_station_visited, StationID station, bool waypoint) const;
bool ShouldStopAtStation(const Vehicle *v, StationID station, bool waypoint) const;
bool CanLeaveWithCargo(bool has_cargo, CargoID cargo) const;

@ -3556,6 +3556,19 @@ bool ProcessOrders(Vehicle *v)
return UpdateOrderDest(v, order) && may_reverse;
}
bool Order::UseOccupancyValueForAverage() const
{
if (this->GetOccupancy() == 0) return false;
if (this->GetOccupancy() > 1) return true;
if (this->IsType(OT_GOTO_STATION)) {
OrderUnloadFlags unload_type = this->GetUnloadType();
if ((unload_type == OUFB_TRANSFER || unload_type == OUFB_UNLOAD) && this->GetLoadType() == OLFB_NO_LOAD) return false;
}
return true;
}
/**
* Check whether the given vehicle should stop at the given station
* based on this order and the non-stop settings.

@ -2381,7 +2381,13 @@ public:
uint8 occupancy = order->GetOccupancy();
if (occupancy > 0) {
SetDParam(0, occupancy - 1);
DrawString(ir.left, ir.right, y, STR_ORDERS_OCCUPANCY_PERCENT, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
TextColour colour;
if (order->UseOccupancyValueForAverage()) {
colour = (i == this->selected_order) ? TC_WHITE : TC_BLACK;
} else {
colour = ((i == this->selected_order) ? TC_SILVER : TC_GREY) | TC_NO_SHADE;
}
DrawString(ir.left, ir.right, y, STR_ORDERS_OCCUPANCY_PERCENT, colour);
}
y += line_height;

@ -3503,8 +3503,9 @@ void Vehicle::RecalculateOrderOccupancyAverage()
uint total = 0;
uint order_count = this->GetNumOrders();
for (uint i = 0; i < order_count; i++) {
uint occupancy = this->GetOrder(i)->GetOccupancy();
if (occupancy > 0) {
const Order *order = this->GetOrder(i);
uint occupancy = order->GetOccupancy();
if (occupancy > 0 && order->UseOccupancyValueForAverage()) {
num_valid++;
total += (occupancy - 1);
}

Loading…
Cancel
Save