Core/Toys: Check whether player has the toy he is attempting to use and if that toy has the spell that player is trying to cast

This commit is contained in:
Shauren
2016-04-13 17:35:03 +02:00
parent f4a19fe795
commit 51e2d7f997
2 changed files with 12 additions and 0 deletions

View File

@@ -60,6 +60,7 @@ public:
bool AddToy(uint32 itemId, bool isFavourite /*= false*/);
bool UpdateAccountToys(uint32 itemId, bool isFavourite /*= false*/);
bool HasToy(uint32 itemId) const { return _toys.count(itemId) > 0; }
ToyBoxContainer const& GetAccountToys() const { return _toys; }

View File

@@ -51,6 +51,17 @@ void WorldSession::HandleUseToy(WorldPackets::Toy::UseToy& packet)
if (!item)
return;
if (!_collectionMgr->HasToy(packet.ItemID))
return;
auto effect = std::find_if(item->Effects.begin(), item->Effects.end(), [&packet](ItemEffectEntry const* effect)
{
return packet.Cast.SpellID = effect->SpellID;
});
if (effect == item->Effects.end())
return;
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(packet.Cast.SpellID);
if (!spellInfo)
{