From 03b7e3a22be9e1231072a5f6f8f559634f40f47f Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:44:07 +1000 Subject: [PATCH] PlayerInventory: fix bag loading issue --- source/game/StarPlayerInventory.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/source/game/StarPlayerInventory.cpp b/source/game/StarPlayerInventory.cpp index 1edcdca..f64794d 100644 --- a/source/game/StarPlayerInventory.cpp +++ b/source/game/StarPlayerInventory.cpp @@ -781,19 +781,14 @@ void PlayerInventory::load(Json const& store) { //reuse ItemBags so the Inventory pane still works after load()'ing into the same PlayerInventory again (from swap) auto itemBags = store.get("itemBags").toObject(); - eraseWhere(m_bags, [&](auto const& p) { return !itemBags.contains(p.first); }); m_inventoryLoadOverflow.clear(); for (auto const& p : itemBags) { auto& bagType = p.first; auto newBag = ItemBag::loadStore(p.second); if (m_bags.contains(bagType)) { - auto& bag = m_bags[bagType]; - auto size = bag->size(); - if (bag) - *bag = std::move(newBag); - else - bag = make_shared(std::move(newBag)); - m_inventoryLoadOverflow.appendAll(bag->resize(size)); + auto& bag = m_bags.at(bagType); + m_inventoryLoadOverflow.appendAll(newBag.resize(bag->size())); + *bag = std::move(newBag); } else { m_inventoryLoadOverflow.appendAll(newBag.items()); }