summaryrefslogtreecommitdiff
path: root/src/order_cmd.cpp
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2014-05-01 14:49:16 +0000
committerfonsinchen <fonsinchen@openttd.org>2014-05-01 14:49:16 +0000
commit3ee31a8f893dbbedf89de9b3ecf44a71a48c6666 (patch)
treeee4d710aacfd15a4d76f1f0da1c22879fdb09126 /src/order_cmd.cpp
parentc915d9fa55e8bb42b33c56b94c5a5e0ff446d7da (diff)
downloadopenttd-3ee31a8f893dbbedf89de9b3ecf44a71a48c6666.tar.xz
(svn r26547) -Codechange: Collect order travel and wait times independent of timetables
Diffstat (limited to 'src/order_cmd.cpp')
-rw-r--r--src/order_cmd.cpp21
1 files changed, 14 insertions, 7 deletions
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. */