mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
- [Bugfix] Fixed bug with unequip and item in bags (#1327)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user