summaryrefslogtreecommitdiff
path: root/src/order_cmd.cpp
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2020-01-03 14:11:33 +0000
committerCharles Pigott <charlespigott@googlemail.com>2020-01-05 20:51:26 +0000
commitd1cead7f251e09e572c73130bad601f7d991ecc6 (patch)
treecf8b1c6b508eccbe0760f1b6b397c6b187f9c801 /src/order_cmd.cpp
parentcddb8a4605570666e076ab0e0f7b1f986f393e17 (diff)
downloadopenttd-d1cead7f251e09e572c73130bad601f7d991ecc6.tar.xz
Fix: When loading old timetabled saves, also reset cached timetable duration
Diffstat (limited to 'src/order_cmd.cpp')
-rw-r--r--src/order_cmd.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 67092bc77..1e9e8f2f3 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -296,15 +296,15 @@ 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 != nullptr; o = o->next) {
++this->num_orders;
if (!o->IsType(OT_IMPLICIT)) ++this->num_manual_orders;
- this->timetable_duration += o->GetTimetabledWait() + o->GetTimetabledTravel();
this->total_duration += o->GetWaitTime() + o->GetTravelTime();
}
+ this->RecalculateTimetableDuration();
+
for (Vehicle *u = this->first_shared->PreviousShared(); u != nullptr; u = u->PreviousShared()) {
++this->num_vehicles;
this->first_shared = u;
@@ -314,6 +314,18 @@ void OrderList::Initialize(Order *chain, Vehicle *v)
}
/**
+ * Recomputes Timetable duration.
+ * Split out into a separate function so it can be used by afterload.
+ */
+void OrderList::RecalculateTimetableDuration()
+{
+ this->timetable_duration = 0;
+ for (Order *o = this->first; o != nullptr; o = o->next) {
+ this->timetable_duration += o->GetTimetabledWait() + o->GetTimetabledTravel();
+ }
+}
+
+/**
* Free a complete order chain.
* @param keep_orderlist If this is true only delete the orders, otherwise also delete the OrderList.
* @note do not use on "current_order" vehicle orders!