From a644e0d951f335121ad13ff3ea1cdb5f8e1825d2 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sat, 17 Sep 2011 13:20:21 +0200 Subject: Core/Entities: GameObject's m_unique_users will now store full guids to get rid of silly casts --- src/server/game/Entities/GameObject/GameObject.cpp | 20 +++++++------------- src/server/game/Entities/GameObject/GameObject.h | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) (limited to 'src/server') diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index c0bf5865f28..b69478ab0e5 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -527,13 +527,10 @@ void GameObject::Update(uint32 diff) if (spellId) { - std::set::const_iterator it = m_unique_users.begin(); - std::set::const_iterator end = m_unique_users.end(); - for (; it != end; ++it) - { - if (Unit* owner = Unit::GetUnit(*this, uint64(*it))) + for (std::set::const_iterator it = m_unique_users.begin(); it != m_unique_users.end(); ++it) + // m_unique_users can contain only player GUIDs + if (Player* owner = ObjectAccessor::GetPlayer(*this, *it)) owner->CastSpell(owner, spellId, false); - } m_unique_users.clear(); m_usetimes = 0; @@ -606,7 +603,7 @@ void GameObject::Refresh() void GameObject::AddUniqueUse(Player* player) { AddUse(); - m_unique_users.insert(player->GetGUIDLow()); + m_unique_users.insert(player->GetGUID()); } void GameObject::Delete() @@ -1397,13 +1394,10 @@ void GameObject::Use(Unit* user) // on the current DB there is only one gameobject that uses this (Ritual of Doom) // and its required target number is 1 (outter for loop will run once) if (info->summoningRitual.casterTargetSpell && info->summoningRitual.casterTargetSpell != 1) // No idea why this field is a bool in some cases - { - for (int i = 0; i < info->summoningRitual.casterTargetSpellTargets; i++) - { - if (Unit* target = Unit::GetUnit(*this, (uint64)SelectRandomContainerElement(m_unique_users))) + for (uint32 i = 0; i < info->summoningRitual.casterTargetSpellTargets; i++) + // m_unique_users can contain only player GUIDs + if (Player* target = ObjectAccessor::GetPlayer(*this, SelectRandomContainerElement(m_unique_users))) spellCaster->CastSpell(target, info->summoningRitual.casterTargetSpell, true); - } - } // finish owners spell if (owner) diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index be4ab451354..ff0cf03c8b8 100755 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -800,7 +800,7 @@ class GameObject : public WorldObject, public GridObject std::list m_SkillupList; Player* m_ritualOwner; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner) - std::set m_unique_users; + std::set m_unique_users; uint32 m_usetimes; typedef std::map ChairSlotAndUser; -- cgit v1.2.3