From 69ae516353923a6302572c6483065ed88bfc6454 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Tue, 20 Feb 2024 23:15:01 +0000 Subject: [PATCH] Fix loading of depot unbunch bit from vanilla saves --- src/saveload/afterload.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 5964637489..12de639281 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -2160,9 +2160,6 @@ bool AfterLoadGame() order->SetWaitTimetabled(HasBit(order->GetRawFlags(), 3)); } OrderDepotActionFlags flags = (OrderDepotActionFlags)(order->GetDepotActionType() >> 1); - if (((flags & (1 << 2)) != 0) && !SlXvIsFeatureMissing(XSLFI_DEPOT_UNBUNCHING)) { - flags ^= (ODATFB_SELL | ODATFB_UNBUNCH); // Unbunch moved from bit 2 to bit 3 - } order->SetDepotActionType(flags); } } else if (SlXvIsFeaturePresent(XSLFI_TT_WAIT_IN_DEPOT, 1, 1)) { @@ -2171,6 +2168,17 @@ bool AfterLoadGame() if (order->IsType(OT_GOTO_DEPOT)) order->SetWaitTimetabled(HasBit(order->GetRawFlags(), 3)); } } + if (!IsSavegameVersionBefore(SLV_DEPOT_UNBUNCHING)) { + /* Move unbunch depot action from bit 2 to bit 3 */ + for (Order *order : Order::Iterate()) { + if (!order->IsType(OT_GOTO_DEPOT)) continue; + OrderDepotActionFlags flags = order->GetDepotActionType(); + if ((flags & ODATFB_SELL) != 0) { + flags ^= (ODATFB_SELL | ODATFB_UNBUNCH); // Move unbunch from bit 2 to bit 3 (sell to unbunch) + order->SetDepotActionType(flags); + } + } + } if (SlXvIsFeaturePresent(XSLFI_JOKERPP, 1, SL_JOKER_1_23)) { for (Order *order : Order::Iterate()) {