Merge branch 'order_occupancy' into order_occupancy-sx
This commit is contained in:
@@ -2132,6 +2132,7 @@ void Vehicle::LeaveStation()
|
||||
new_occupancy /= 100;
|
||||
}
|
||||
if (new_occupancy + 1 != old_occupancy) {
|
||||
this->order_occupancy_average = 0;
|
||||
real_current_order->SetOccupancy(static_cast<uint8>(new_occupancy + 1));
|
||||
for (const Vehicle *v = this->FirstShared(); v != NULL; v = v->NextShared()) {
|
||||
SetWindowDirty(WC_VEHICLE_ORDERS, v->index);
|
||||
@@ -2142,6 +2143,25 @@ void Vehicle::LeaveStation()
|
||||
this->MarkDirty();
|
||||
}
|
||||
|
||||
void Vehicle::RecalculateOrderOccupancyAverage()
|
||||
{
|
||||
uint num_valid = 0;
|
||||
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) {
|
||||
num_valid++;
|
||||
total += (occupancy - 1);
|
||||
}
|
||||
}
|
||||
if (num_valid > 0) {
|
||||
this->order_occupancy_average = 16 + ((total + (num_valid / 2)) / num_valid);
|
||||
} else {
|
||||
this->order_occupancy_average = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all refit_cap in the consist to cargo_cap.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user