PlayerInventory: fix bag loading issue
This commit is contained in:
parent
25f3edbae3
commit
03b7e3a22b
@ -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)
|
||||
auto& bag = m_bags.at(bagType);
|
||||
m_inventoryLoadOverflow.appendAll(newBag.resize(bag->size()));
|
||||
*bag = std::move(newBag);
|
||||
else
|
||||
bag = make_shared<ItemBag>(std::move(newBag));
|
||||
m_inventoryLoadOverflow.appendAll(bag->resize(size));
|
||||
} else {
|
||||
m_inventoryLoadOverflow.appendAll(newBag.items());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user