(svn r26547) -Codechange: Collect order travel and wait times independent of timetables
This commit is contained in:
@@ -297,11 +297,13 @@ void OrderList::Initialize(Order *chain, Vehicle *v)
|
||||
this->num_manual_orders = 0;
|
||||
this->num_vehicles = 1;
|
||||
this->timetable_duration = 0;
|
||||
this->total_duration = 0;
|
||||
|
||||
for (Order *o = this->first; o != NULL; o = o->next) {
|
||||
++this->num_orders;
|
||||
if (!o->IsType(OT_IMPLICIT)) ++this->num_manual_orders;
|
||||
this->timetable_duration += o->GetWaitTime() + o->GetTravelTime();
|
||||
this->timetable_duration += o->GetTimetabledWait() + o->GetTimetabledTravel();
|
||||
this->total_duration += o->GetWaitTime() + o->GetTravelTime();
|
||||
}
|
||||
|
||||
for (Vehicle *u = this->first_shared->PreviousShared(); u != NULL; u = u->PreviousShared()) {
|
||||
@@ -476,7 +478,8 @@ void OrderList::InsertOrderAt(Order *new_order, int index)
|
||||
}
|
||||
++this->num_orders;
|
||||
if (!new_order->IsType(OT_IMPLICIT)) ++this->num_manual_orders;
|
||||
this->timetable_duration += new_order->GetWaitTime() + new_order->GetTravelTime();
|
||||
this->timetable_duration += new_order->GetTimetabledWait() + new_order->GetTimetabledTravel();
|
||||
this->total_duration += new_order->GetWaitTime() + new_order->GetTravelTime();
|
||||
|
||||
/* We can visit oil rigs and buoys that are not our own. They will be shown in
|
||||
* the list of stations. So, we need to invalidate that window if needed. */
|
||||
@@ -508,7 +511,8 @@ void OrderList::DeleteOrderAt(int index)
|
||||
}
|
||||
--this->num_orders;
|
||||
if (!to_remove->IsType(OT_IMPLICIT)) --this->num_manual_orders;
|
||||
this->timetable_duration -= (to_remove->GetWaitTime() + to_remove->GetTravelTime());
|
||||
this->timetable_duration -= (to_remove->GetTimetabledWait() + to_remove->GetTimetabledTravel());
|
||||
this->total_duration -= (to_remove->GetWaitTime() + to_remove->GetTravelTime());
|
||||
delete to_remove;
|
||||
}
|
||||
|
||||
@@ -603,26 +607,29 @@ void OrderList::DebugCheckSanity() const
|
||||
VehicleOrderID check_num_manual_orders = 0;
|
||||
uint check_num_vehicles = 0;
|
||||
Ticks check_timetable_duration = 0;
|
||||
Ticks check_total_duration = 0;
|
||||
|
||||
DEBUG(misc, 6, "Checking OrderList %hu for sanity...", this->index);
|
||||
|
||||
for (const Order *o = this->first; o != NULL; o = o->next) {
|
||||
++check_num_orders;
|
||||
if (!o->IsType(OT_IMPLICIT)) ++check_num_manual_orders;
|
||||
check_timetable_duration += o->GetWaitTime() + o->GetTravelTime();
|
||||
check_timetable_duration += o->GetTimetabledWait() + o->GetTimetabledTravel();
|
||||
check_total_duration += o->GetWaitTime() + o->GetTravelTime();
|
||||
}
|
||||
assert(this->num_orders == check_num_orders);
|
||||
assert(this->num_manual_orders == check_num_manual_orders);
|
||||
assert(this->timetable_duration == check_timetable_duration);
|
||||
assert(this->total_duration == check_total_duration);
|
||||
|
||||
for (const Vehicle *v = this->first_shared; v != NULL; v = v->NextShared()) {
|
||||
++check_num_vehicles;
|
||||
assert(v->orders.list == this);
|
||||
}
|
||||
assert(this->num_vehicles == check_num_vehicles);
|
||||
DEBUG(misc, 6, "... detected %u orders (%u manual), %u vehicles, %i ticks",
|
||||
DEBUG(misc, 6, "... detected %u orders (%u manual), %u vehicles, %i timetabled, %i total",
|
||||
(uint)this->num_orders, (uint)this->num_manual_orders,
|
||||
this->num_vehicles, this->timetable_duration);
|
||||
this->num_vehicles, this->timetable_duration, this->total_duration);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2081,7 +2088,7 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool
|
||||
UpdateVehicleTimetable(v, false);
|
||||
v->cur_implicit_order_index = v->cur_real_order_index = next_order;
|
||||
v->UpdateRealOrderIndex();
|
||||
v->current_order_time += v->GetOrder(v->cur_real_order_index)->GetTravelTime();
|
||||
v->current_order_time += v->GetOrder(v->cur_real_order_index)->GetTimetabledTravel();
|
||||
|
||||
/* Disable creation of implicit orders.
|
||||
* When inserting them we do not know that we would have to make the conditional orders point to them. */
|
||||
|
Reference in New Issue
Block a user