- [Bugfix] Fixed bug with unequip and item in bags (#1327)

This commit is contained in:
kadeshar
2025-05-22 22:10:53 +02:00
committed by GitHub
parent e68c5a76c6
commit a4ff66f12a

View File

@@ -46,7 +46,20 @@ void UnequipAction::UnequipItem(FindItemVisitor* visitor)
IterateItems(visitor, ITERATE_ALL_ITEMS);
std::vector<Item*> items = visitor->GetResult();
if (!items.empty())
UnequipItem(*items.begin());
{
// Prefer equipped item
auto equipped = std::find_if(items.begin(), items.end(),
[](Item* item)
{
uint8 bag = item->GetBagSlot();
return bag == INVENTORY_SLOT_BAG_0 && item->GetSlot() < EQUIPMENT_SLOT_END;
});
if (equipped != items.end())
UnequipItem(*equipped);
else
UnequipItem(*items.begin());
}
}
void UnequipAction::UnequipItem(Item* item)