Skip to content

Commit

Permalink
Core/Spells: Restored totem category check
Browse files Browse the repository at this point in the history
Revert "Core/Totems: In cata totem items are no longer needed"

This reverts commit 45e0cae
  • Loading branch information
Shauren committed Feb 21, 2015
1 parent d2396fb commit ea9ecca
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/server/game/DataStores/DBCStores.cpp
Expand Up @@ -828,7 +828,7 @@ uint32 GetExpansionForLevel(uint32 level)
return CURRENT_EXPANSION;
}

bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId)
bool IsTotemCategoryCompatibleWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId)
{
if (requiredTotemCategoryId == 0)
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/DataStores/DBCStores.h
Expand Up @@ -61,7 +61,7 @@ uint32 GetExpansionForLevel(uint32 level);

ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId);

bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId);
bool IsTotemCategoryCompatibleWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId);

void Zone2MapCoordinates(float &x, float &y, uint32 zone);
void Map2ZoneCoordinates(float &x, float &y, uint32 zone);
Expand Down
1 change: 1 addition & 0 deletions src/server/game/Entities/Item/ItemTemplate.h
Expand Up @@ -631,6 +631,7 @@ struct ItemTemplate
uint32 GetArea() const { return ExtendedData->Area; }
uint32 GetMap() const { return ExtendedData->Map; }
uint32 GetBagFamily() const { return ExtendedData->BagFamily; }
uint32 GetTotemCategory() const { return ExtendedData->TotemCategory; }
SocketColor GetSocketColor(uint32 index) const { ASSERT(index < MAX_ITEM_PROTO_SOCKETS); return SocketColor(ExtendedData->SocketColor[index]); }
uint32 GetSocketBonus() const { return ExtendedData->SocketBonus; }
uint32 GetGemProperties() const { return ExtendedData->GemProperties; }
Expand Down
28 changes: 28 additions & 0 deletions src/server/game/Entities/Player/Player.cpp
Expand Up @@ -10211,6 +10211,34 @@ InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& des
return CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL);
}

bool Player::HasItemTotemCategory(uint32 TotemCategory) const
{
Item* item;
for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
{
item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, i);
if (item && IsTotemCategoryCompatibleWith(item->GetTemplate()->GetTotemCategory(), TotemCategory))
return true;
}

Bag* bag;
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
{
bag = GetBagByPos(i);
if (bag)
{
for (uint32 j = 0; j < bag->GetBagSize(); ++j)
{
item = GetUseableItemByPos(i, j);
if (item && IsTotemCategoryCompatibleWith(item->GetTemplate()->GetTotemCategory(), TotemCategory))
return true;
}
}
}

return false;
}

InventoryResult Player::CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec &dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const
{
Item* pItem2 = GetItemByPos(bag, slot);
Expand Down
20 changes: 20 additions & 0 deletions src/server/game/Spells/Spell.cpp
Expand Up @@ -6146,8 +6146,28 @@ SpellCastResult Spell::CheckItems()
else
totems -= 1;
}

if (totems != 0)
return SPELL_FAILED_TOTEMS;

// Check items for TotemCategory (items presence in inventory)
uint32 totemCategory = 2;
for (uint8 i = 0; i < 2; ++i)
{
if (m_spellInfo->TotemCategory[i] != 0)
{
if (player->HasItemTotemCategory(m_spellInfo->TotemCategory[i]))
{
totemCategory -= 1;
continue;
}
}
else
totemCategory -= 1;
}

if (totemCategory != 0)
return SPELL_FAILED_TOTEM_CATEGORY;
}

// special checks for spell effects
Expand Down

0 comments on commit ea9ecca

Please sign in to comment.