Core/Spells: don't allow spells with SPELL_EFFECT_CREATE_ITEM_2 to be cast if there isn't enough space in inventory

This commit is contained in:
Wyrserth authored and Ovahlord committed 2022-09-12 09:15:24 +02:00
1 parent 85893e9a44
commit 2f5fd3f227
4 files changed
+61 -42

No files matched your search

@@ -9899,6 +9899,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;