mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[10383] Store guid instaed pointer for first user of GAMEOBJECT_TYPE_SUMMONING_RITUAL
This is more safe way in pointer store comparison with. LAso Some related code cleanups.
This commit is contained in:
parent
b672913633
commit
0649b508e4
5 changed files with 81 additions and 71 deletions
|
|
@ -50,11 +50,10 @@ GameObject::GameObject() : WorldObject()
|
|||
m_respawnDelayTime = 25;
|
||||
m_lootState = GO_NOT_READY;
|
||||
m_spawnedByDefault = true;
|
||||
m_usetimes = 0;
|
||||
m_useTimes = 0;
|
||||
m_spellId = 0;
|
||||
m_cooldownTime = 0;
|
||||
m_goInfo = NULL;
|
||||
m_ritualOwner = NULL;
|
||||
|
||||
m_DBTableGuid = 0;
|
||||
m_rotation = 0;
|
||||
|
|
@ -219,8 +218,7 @@ void GameObject::Update(uint32 /*p_time*/)
|
|||
if (m_respawnTime <= time(NULL)) // timer expired
|
||||
{
|
||||
m_respawnTime = 0;
|
||||
m_SkillupList.clear();
|
||||
m_usetimes = 0;
|
||||
ClearAllUsesData();
|
||||
|
||||
switch (GetGoType())
|
||||
{
|
||||
|
|
@ -336,9 +334,9 @@ void GameObject::Update(uint32 /*p_time*/)
|
|||
|
||||
if (uint32 max_charges = goInfo->GetCharges())
|
||||
{
|
||||
if (m_usetimes >= max_charges)
|
||||
if (m_useTimes >= max_charges)
|
||||
{
|
||||
m_usetimes = 0;
|
||||
m_useTimes = 0;
|
||||
SetLootState(GO_JUST_DEACTIVATED); // can be despawned or destroyed
|
||||
}
|
||||
}
|
||||
|
|
@ -377,16 +375,11 @@ void GameObject::Update(uint32 /*p_time*/)
|
|||
|
||||
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 (GuidsSet::const_iterator itr = m_UniqueUsers.begin(); itr != m_UniqueUsers.end(); ++itr)
|
||||
if (Player* owner = GetMap()->GetPlayer(*itr))
|
||||
owner->CastSpell(owner, spellId, false, NULL, NULL, GetGUID());
|
||||
}
|
||||
|
||||
m_unique_users.clear();
|
||||
m_usetimes = 0;
|
||||
ClearAllUsesData();
|
||||
}
|
||||
|
||||
SetGoState(GO_STATE_READY);
|
||||
|
|
@ -451,7 +444,12 @@ void GameObject::Refresh()
|
|||
void GameObject::AddUniqueUse(Player* player)
|
||||
{
|
||||
AddUse();
|
||||
m_unique_users.insert(player->GetGUIDLow());
|
||||
|
||||
if (m_firstUser.IsEmpty())
|
||||
m_firstUser = player->GetObjectGuid();
|
||||
|
||||
m_UniqueUsers.insert(player->GetObjectGuid());
|
||||
|
||||
}
|
||||
|
||||
void GameObject::Delete()
|
||||
|
|
@ -1179,10 +1177,6 @@ void GameObject::Use(Unit* user)
|
|||
|
||||
GameObjectInfo const* info = GetGOInfo();
|
||||
|
||||
// ritual owner is set for GO's without owner (not summoned)
|
||||
if (!m_ritualOwner && !owner)
|
||||
m_ritualOwner = player;
|
||||
|
||||
if (owner)
|
||||
{
|
||||
if (owner->GetTypeId() != TYPEID_PLAYER)
|
||||
|
|
@ -1201,8 +1195,16 @@ void GameObject::Use(Unit* user)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (player != m_ritualOwner && (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(m_ritualOwner)))
|
||||
return;
|
||||
if (!m_firstUser.IsEmpty() && player->GetObjectGuid() != m_firstUser && info->summoningRitual.castersGrouped)
|
||||
{
|
||||
if (Group* group = player->GetGroup())
|
||||
{
|
||||
if (!group->IsMember(m_firstUser))
|
||||
return;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
spellCaster = player;
|
||||
}
|
||||
|
|
@ -1217,40 +1219,31 @@ void GameObject::Use(Unit* user)
|
|||
triggered = true;
|
||||
}
|
||||
|
||||
// full amount unique participants including original summoner
|
||||
if (GetUniqueUseCount() == info->summoningRitual.reqParticipants)
|
||||
{
|
||||
spellCaster = m_ritualOwner ? m_ritualOwner : spellCaster;
|
||||
|
||||
spellId = info->summoningRitual.spellId;
|
||||
|
||||
if (spellId == 62330) // GO store nonexistent spell, replace by expected
|
||||
{
|
||||
// spell have reagent and mana cost but it not expected use its
|
||||
// it triggered spell in fact casted at currently channeled GO
|
||||
spellId = 61993;
|
||||
triggered = true;
|
||||
}
|
||||
|
||||
// finish owners spell
|
||||
if (owner)
|
||||
owner->FinishSpell(CURRENT_CHANNELED_SPELL);
|
||||
|
||||
// can be deleted now, if
|
||||
if (!info->summoningRitual.ritualPersistent)
|
||||
SetLootState(GO_JUST_DEACTIVATED);
|
||||
else
|
||||
{
|
||||
// reset ritual for this GO
|
||||
m_ritualOwner = NULL;
|
||||
m_unique_users.clear();
|
||||
m_usetimes = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// full amount unique participants including original summoner, need more
|
||||
if (GetUniqueUseCount() < info->summoningRitual.reqParticipants)
|
||||
return;
|
||||
}
|
||||
|
||||
spellCaster = GetMap()->GetPlayer(m_firstUser);
|
||||
|
||||
spellId = info->summoningRitual.spellId;
|
||||
|
||||
if (spellId == 62330) // GO store nonexistent spell, replace by expected
|
||||
spellId = 61993;
|
||||
|
||||
// spell have reagent and mana cost but it not expected use its
|
||||
// it triggered spell in fact casted at currently channeled GO
|
||||
triggered = true;
|
||||
|
||||
// finish owners spell
|
||||
if (owner)
|
||||
owner->FinishSpell(CURRENT_CHANNELED_SPELL);
|
||||
|
||||
// can be deleted now, if
|
||||
if (!info->summoningRitual.ritualPersistent)
|
||||
SetLootState(GO_JUST_DEACTIVATED);
|
||||
// reset ritual for this GO
|
||||
else
|
||||
ClearAllUsesData();
|
||||
|
||||
// go to end function to spell casting
|
||||
break;
|
||||
|
|
@ -1575,4 +1568,14 @@ float GameObject::GetObjectBoundingRadius() const
|
|||
return fabs(dispEntry->unknown12) * GetObjectScale();
|
||||
|
||||
return DEFAULT_WORLD_OBJECT_SIZE;
|
||||
}
|
||||
|
||||
bool GameObject::IsInSkillupList(Player* player) const
|
||||
{
|
||||
return m_SkillupSet.find(player->GetObjectGuid()) != m_SkillupSet.end();
|
||||
}
|
||||
|
||||
void GameObject::AddToSkillupList(Player* player)
|
||||
{
|
||||
m_SkillupSet.insert(player->GetObjectGuid());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue