mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-21 20:56:23 +00:00
feat(Core/Player): implement GetFreeInventorySpace() (#4297)
This commit is contained in:
@@ -10636,6 +10636,28 @@ Bag* Player::GetBagByPos(uint8 bag) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32 Player::GetFreeInventorySpace() const
|
||||
{
|
||||
uint32 freeSpace = 0;
|
||||
|
||||
// Check backpack
|
||||
for (uint8 slot = INVENTORY_SLOT_ITEM_START; slot < INVENTORY_SLOT_ITEM_END; ++slot)
|
||||
{
|
||||
Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
|
||||
if (!item)
|
||||
freeSpace += 1;
|
||||
}
|
||||
|
||||
// Check bags
|
||||
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
|
||||
{
|
||||
if (Bag* bag = GetBagByPos(i))
|
||||
freeSpace += bag->GetFreeSlots();
|
||||
}
|
||||
|
||||
return freeSpace;
|
||||
}
|
||||
|
||||
Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable /*= false*/) const
|
||||
{
|
||||
uint8 slot;
|
||||
|
||||
@@ -1242,6 +1242,7 @@ public:
|
||||
[[nodiscard]] Item* GetItemByPos(uint16 pos) const;
|
||||
[[nodiscard]] Item* GetItemByPos(uint8 bag, uint8 slot) const;
|
||||
[[nodiscard]] Bag* GetBagByPos(uint8 slot) const;
|
||||
[[nodiscard]] uint32 GetFreeInventorySpace() const;
|
||||
[[nodiscard]] inline Item* GetUseableItemByPos(uint8 bag, uint8 slot) const //Does additional check for disarmed weapons
|
||||
{
|
||||
if (!CanUseAttackType(GetAttackBySlot(slot)))
|
||||
|
||||
Reference in New Issue
Block a user