From 3ee31a8f893dbbedf89de9b3ecf44a71a48c6666 Mon Sep 17 00:00:00 2001 From: fonsinchen Date: Thu, 1 May 2014 14:49:16 +0000 Subject: (svn r26547) -Codechange: Collect order travel and wait times independent of timetables --- src/order_cmd.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/order_cmd.cpp') diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 1b74416da..9aff6cde4 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -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. */ -- cgit v1.2.3-54-g00ecf