Core/Entities: GameObject's m_unique_users will now store full guids to get rid of silly casts

This commit is contained in:
Shauren
2011-09-17 13:20:21 +02:00
parent 63b62d4ad0
commit a644e0d951
2 changed files with 8 additions and 14 deletions

View File

@@ -527,13 +527,10 @@ void GameObject::Update(uint32 diff)
if (spellId)
{
std::set<uint32>::const_iterator it = m_unique_users.begin();
std::set<uint32>::const_iterator end = m_unique_users.end();
for (; it != end; ++it)
{
if (Unit* owner = Unit::GetUnit(*this, uint64(*it)))
for (std::set<uint64>::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)

View File

@@ -800,7 +800,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>
std::list<uint32> m_SkillupList;
Player* m_ritualOwner; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner)
std::set<uint32> m_unique_users;
std::set<uint64> m_unique_users;
uint32 m_usetimes;
typedef std::map<uint32, uint64> ChairSlotAndUser;