diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/order_base.h | 2 | ||||
-rw-r--r-- | src/order_cmd.cpp | 16 | ||||
-rw-r--r-- | src/saveload/afterload.cpp | 10 | ||||
-rw-r--r-- | src/saveload/order_sl.cpp | 4 |
4 files changed, 26 insertions, 6 deletions
diff --git a/src/order_base.h b/src/order_base.h index 347adbcee..ba4959c0f 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -281,6 +281,8 @@ public: void Initialize(Order *chain, Vehicle *v); + void RecalculateTimetableDuration(); + /** * Get the first order of the order chain. * @return the first order of the chain. 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! diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 47d2c7b03..c37c297c5 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -2963,6 +2963,16 @@ bool AfterLoadGame() } } + if (IsSavegameVersionBefore(SLV_190)) { + for (Order *order : Order::Iterate()) { + order->SetTravelTimetabled(order->GetTravelTime() > 0); + order->SetWaitTimetabled(order->GetWaitTime() > 0); + } + for (OrderList *orderlist : OrderList::Iterate()) { + orderlist->RecalculateTimetableDuration(); + } + } + /* * Only keep order-backups for network clients (and when replaying). * If we are a network server or not networking, then we just loaded a previously diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp index 0a9fa2a8c..c8747d36b 100644 --- a/src/saveload/order_sl.cpp +++ b/src/saveload/order_sl.cpp @@ -182,10 +182,6 @@ static void Load_ORDR() while ((index = SlIterateArray()) != -1) { Order *order = new (index) Order(); SlObject(order, GetOrderDescription()); - if (IsSavegameVersionBefore(SLV_190)) { - order->SetTravelTimetabled(order->GetTravelTime() > 0); - order->SetWaitTimetabled(order->GetWaitTime() > 0); - } } } } |