Don't use occupancy of unload and leave empty orders for occupancy average
This commit is contained in:
@@ -563,6 +563,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
inline void SetOccupancy(uint8 occupancy) { this->occupancy = occupancy; }
|
inline void SetOccupancy(uint8 occupancy) { this->occupancy = occupancy; }
|
||||||
|
|
||||||
|
bool UseOccupancyValueForAverage() const;
|
||||||
|
|
||||||
bool ShouldStopAtStation(StationID last_station_visited, StationID station, bool waypoint) const;
|
bool ShouldStopAtStation(StationID last_station_visited, StationID station, bool waypoint) const;
|
||||||
bool ShouldStopAtStation(const Vehicle *v, StationID station, bool waypoint) const;
|
bool ShouldStopAtStation(const Vehicle *v, StationID station, bool waypoint) const;
|
||||||
bool CanLeaveWithCargo(bool has_cargo, CargoID cargo) const;
|
bool CanLeaveWithCargo(bool has_cargo, CargoID cargo) const;
|
||||||
|
@@ -3556,6 +3556,19 @@ bool ProcessOrders(Vehicle *v)
|
|||||||
return UpdateOrderDest(v, order) && may_reverse;
|
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
|
* Check whether the given vehicle should stop at the given station
|
||||||
* based on this order and the non-stop settings.
|
* based on this order and the non-stop settings.
|
||||||
|
@@ -2381,7 +2381,13 @@ public:
|
|||||||
uint8 occupancy = order->GetOccupancy();
|
uint8 occupancy = order->GetOccupancy();
|
||||||
if (occupancy > 0) {
|
if (occupancy > 0) {
|
||||||
SetDParam(0, occupancy - 1);
|
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;
|
y += line_height;
|
||||||
|
|
||||||
|
@@ -3503,8 +3503,9 @@ void Vehicle::RecalculateOrderOccupancyAverage()
|
|||||||
uint total = 0;
|
uint total = 0;
|
||||||
uint order_count = this->GetNumOrders();
|
uint order_count = this->GetNumOrders();
|
||||||
for (uint i = 0; i < order_count; i++) {
|
for (uint i = 0; i < order_count; i++) {
|
||||||
uint occupancy = this->GetOrder(i)->GetOccupancy();
|
const Order *order = this->GetOrder(i);
|
||||||
if (occupancy > 0) {
|
uint occupancy = order->GetOccupancy();
|
||||||
|
if (occupancy > 0 && order->UseOccupancyValueForAverage()) {
|
||||||
num_valid++;
|
num_valid++;
|
||||||
total += (occupancy - 1);
|
total += (occupancy - 1);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user