mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 22:37:02 +00:00
[9618] More use ObjectGuid in spell/etc code
This commit is contained in:
parent
21ff192866
commit
b658b25ff8
19 changed files with 117 additions and 122 deletions
|
|
@ -312,7 +312,7 @@ void SpellCastTargets::write( ByteBuffer& data ) const
|
|||
data << m_strTarget;
|
||||
}
|
||||
|
||||
Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, Spell** triggeringContainer )
|
||||
Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, ObjectGuid originalCasterGUID, Spell** triggeringContainer )
|
||||
{
|
||||
ASSERT( Caster != NULL && info != NULL );
|
||||
ASSERT( info == sSpellStore.LookupEntry( info->Id ) && "`info` must be pointer to sSpellStore element");
|
||||
|
|
@ -345,10 +345,10 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi
|
|||
// Set health leech amount to zero
|
||||
m_healthLeech = 0;
|
||||
|
||||
if(originalCasterGUID)
|
||||
if(!originalCasterGUID.IsEmpty())
|
||||
m_originalCasterGUID = originalCasterGUID;
|
||||
else
|
||||
m_originalCasterGUID = m_caster->GetGUID();
|
||||
m_originalCasterGUID = m_caster->GetObjectGuid();
|
||||
|
||||
UpdateOriginalCasterPointer();
|
||||
|
||||
|
|
@ -767,7 +767,7 @@ void Spell::AddUnitTarget(Unit* pVictim, SpellEffectIndex effIndex)
|
|||
// Check for effect immune skip if immuned
|
||||
bool immuned = pVictim->IsImmunedToSpellEffect(m_spellInfo, effIndex);
|
||||
|
||||
uint64 targetGUID = pVictim->GetGUID();
|
||||
ObjectGuid targetGUID = pVictim->GetObjectGuid();
|
||||
|
||||
// Lookup target in already in list
|
||||
for(std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
|
||||
|
|
@ -837,7 +837,7 @@ void Spell::AddGOTarget(GameObject* pVictim, SpellEffectIndex effIndex)
|
|||
if( m_spellInfo->Effect[effIndex] == 0 )
|
||||
return;
|
||||
|
||||
uint64 targetGUID = pVictim->GetGUID();
|
||||
ObjectGuid targetGUID = pVictim->GetObjectGuid();
|
||||
|
||||
// Lookup target in already in list
|
||||
for(std::list<GOTargetInfo>::iterator ihit = m_UniqueGOTargetInfo.begin(); ihit != m_UniqueGOTargetInfo.end(); ++ihit)
|
||||
|
|
@ -913,7 +913,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
|
|||
// Get mask of effects for target
|
||||
uint32 mask = target->effectMask;
|
||||
|
||||
Unit* unit = m_caster->GetGUID() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID);
|
||||
Unit* unit = m_caster->GetObjectGuid() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID);
|
||||
if (!unit)
|
||||
return;
|
||||
|
||||
|
|
@ -1017,7 +1017,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
|
|||
// ignore pets or autorepeat/melee casts for speed (not exist quest for spells (hm... )
|
||||
if (real_caster && !((Creature*)unit)->isPet() && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive())
|
||||
if (Player* p = real_caster->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
p->CastedCreatureOrGO(unit->GetEntry(), unit->GetGUID(), m_spellInfo->Id);
|
||||
p->CastedCreatureOrGO(unit->GetEntry(), unit->GetObjectGuid(), m_spellInfo->Id);
|
||||
|
||||
if(((Creature*)unit)->AI())
|
||||
((Creature*)unit)->AI()->SpellHit(m_caster, m_spellInfo);
|
||||
|
|
@ -1178,7 +1178,7 @@ void Spell::DoAllEffectOnTarget(GOTargetInfo *target)
|
|||
if( !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() )
|
||||
{
|
||||
if ( Player* p = m_caster->GetCharmerOrOwnerPlayerOrPlayerItself() )
|
||||
p->CastedCreatureOrGO(go->GetEntry(), go->GetGUID(), m_spellInfo->Id);
|
||||
p->CastedCreatureOrGO(go->GetEntry(), go->GetObjectGuid(), m_spellInfo->Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1205,7 +1205,7 @@ bool Spell::IsAliveUnitPresentInTargetList()
|
|||
{
|
||||
if( ihit->missCondition == SPELL_MISS_NONE && (needAliveTargetMask & ihit->effectMask) )
|
||||
{
|
||||
Unit *unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
|
||||
Unit *unit = m_caster->GetObjectGuid() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
|
||||
|
||||
// either unit is alive and normal spell, or unit dead and deathonly-spell
|
||||
if (unit && (unit->isAlive() != IsDeathOnlySpell(m_spellInfo)))
|
||||
|
|
@ -2479,7 +2479,7 @@ void Spell::cancel()
|
|||
{
|
||||
if( ihit->missCondition == SPELL_MISS_NONE )
|
||||
{
|
||||
Unit* unit = m_caster->GetGUID() == (*ihit).targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
|
||||
Unit* unit = m_caster->GetObjectGuid() == (*ihit).targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
|
||||
if( unit && unit->isAlive() )
|
||||
unit->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID());
|
||||
}
|
||||
|
|
@ -2956,14 +2956,14 @@ void Spell::update(uint32 difftime)
|
|||
for(std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
|
||||
{
|
||||
TargetInfo* target = &*ihit;
|
||||
if(!IS_CREATURE_GUID(target->targetGUID))
|
||||
if(!target->targetGUID.IsCreature())
|
||||
continue;
|
||||
|
||||
Unit* unit = m_caster->GetGUID() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID);
|
||||
Unit* unit = m_caster->GetObjectGuid() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID);
|
||||
if (unit == NULL)
|
||||
continue;
|
||||
|
||||
p->CastedCreatureOrGO(unit->GetEntry(), unit->GetGUID(), m_spellInfo->Id);
|
||||
p->CastedCreatureOrGO(unit->GetEntry(), unit->GetObjectGuid(), m_spellInfo->Id);
|
||||
}
|
||||
|
||||
for(std::list<GOTargetInfo>::iterator ihit = m_UniqueGOTargetInfo.begin(); ihit != m_UniqueGOTargetInfo.end(); ++ihit)
|
||||
|
|
@ -2974,7 +2974,7 @@ void Spell::update(uint32 difftime)
|
|||
if(!go)
|
||||
continue;
|
||||
|
||||
p->CastedCreatureOrGO(go->GetEntry(), go->GetGUID(), m_spellInfo->Id);
|
||||
p->CastedCreatureOrGO(go->GetEntry(), go->GetObjectGuid(), m_spellInfo->Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3017,7 +3017,7 @@ void Spell::finish(bool ok)
|
|||
if( ihit->missCondition == SPELL_MISS_NONE )
|
||||
{
|
||||
// check m_caster->GetGUID() let load auras at login and speedup most often case
|
||||
Unit *unit = m_caster->GetGUID()== ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
|
||||
Unit *unit = m_caster->GetObjectGuid() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
|
||||
if (unit && unit->isAlive())
|
||||
{
|
||||
SpellEntry const *auraSpellInfo = (*i)->GetSpellProto();
|
||||
|
|
@ -3054,7 +3054,7 @@ void Spell::finish(bool ok)
|
|||
{
|
||||
for(std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
|
||||
{
|
||||
if (ihit->missCondition != SPELL_MISS_NONE && ihit->targetGUID != m_caster->GetGUID())
|
||||
if (ihit->missCondition != SPELL_MISS_NONE && ihit->targetGUID != m_caster->GetObjectGuid())
|
||||
{
|
||||
needDrop = false;
|
||||
break;
|
||||
|
|
@ -3380,20 +3380,20 @@ void Spell::WriteSpellGoTargets( WorldPacket * data )
|
|||
{
|
||||
if ((*ihit).missCondition == SPELL_MISS_NONE) // Add only hits
|
||||
{
|
||||
*data << uint64(ihit->targetGUID);
|
||||
*data << ihit->targetGUID;
|
||||
m_needAliveTargetMask |=ihit->effectMask;
|
||||
}
|
||||
}
|
||||
|
||||
for(std::list<GOTargetInfo>::const_iterator ighit = m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end(); ++ighit)
|
||||
*data << uint64(ighit->targetGUID); // Always hits
|
||||
*data << ighit->targetGUID; // Always hits
|
||||
|
||||
*data << (uint8)miss;
|
||||
for(std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
|
||||
{
|
||||
if( ihit->missCondition != SPELL_MISS_NONE ) // Add only miss
|
||||
{
|
||||
*data << uint64(ihit->targetGUID);
|
||||
*data << ihit->targetGUID;
|
||||
*data << uint8(ihit->missCondition);
|
||||
if( ihit->missCondition == SPELL_MISS_REFLECT )
|
||||
*data << uint8(ihit->reflectResult);
|
||||
|
|
@ -3535,10 +3535,10 @@ void Spell::SendChannelUpdate(uint32 time)
|
|||
{
|
||||
m_caster->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID());
|
||||
|
||||
if(uint64 target_guid = m_caster->GetChannelObjectGUID())
|
||||
if(target_guid != m_caster->GetGUID() && IS_UNIT_GUID(target_guid))
|
||||
if(Unit* target = ObjectAccessor::GetUnit(*m_caster, target_guid))
|
||||
target->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID());
|
||||
ObjectGuid target_guid = m_caster->GetChannelObjectGUID();
|
||||
if (target_guid != m_caster->GetObjectGuid() && target_guid.IsUnit())
|
||||
if (Unit* target = ObjectAccessor::GetUnit(*m_caster, target_guid))
|
||||
target->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID());
|
||||
|
||||
m_caster->SetChannelObjectGUID(0);
|
||||
m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, 0);
|
||||
|
|
@ -3559,7 +3559,7 @@ void Spell::SendChannelStart(uint32 duration)
|
|||
{
|
||||
for(std::list<TargetInfo>::const_iterator itr = m_UniqueTargetInfo.begin(); itr != m_UniqueTargetInfo.end(); ++itr)
|
||||
{
|
||||
if( (itr->effectMask & (1 << 0)) && itr->reflectResult == SPELL_MISS_NONE && itr->targetGUID != m_caster->GetGUID())
|
||||
if( (itr->effectMask & (1 << 0)) && itr->reflectResult == SPELL_MISS_NONE && itr->targetGUID != m_caster->GetObjectGuid())
|
||||
{
|
||||
target = ObjectAccessor::GetUnit(*m_caster, itr->targetGUID);
|
||||
break;
|
||||
|
|
@ -5209,7 +5209,7 @@ SpellCastResult Spell::CheckCasterAuras() const
|
|||
|
||||
bool Spell::CanAutoCast(Unit* target)
|
||||
{
|
||||
uint64 targetguid = target->GetGUID();
|
||||
ObjectGuid targetguid = target->GetObjectGuid();
|
||||
|
||||
for(int j = 0; j < MAX_EFFECT_INDEX; ++j)
|
||||
{
|
||||
|
|
@ -5916,7 +5916,7 @@ void Spell::DelayedChannel()
|
|||
{
|
||||
if ((*ihit).missCondition == SPELL_MISS_NONE)
|
||||
{
|
||||
if (Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID))
|
||||
if (Unit* unit = m_caster->GetObjectGuid() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID))
|
||||
for (int j = 0; j < MAX_EFFECT_INDEX; ++j)
|
||||
if (ihit->effectMask & (1 << j))
|
||||
unit->DelayAura(m_spellInfo->Id, SpellEffectIndex(j), delaytime);
|
||||
|
|
@ -5936,9 +5936,9 @@ void Spell::DelayedChannel()
|
|||
|
||||
void Spell::UpdateOriginalCasterPointer()
|
||||
{
|
||||
if(m_originalCasterGUID == m_caster->GetGUID())
|
||||
if(m_originalCasterGUID == m_caster->GetObjectGuid())
|
||||
m_originalCaster = m_caster;
|
||||
else if (IS_GAMEOBJECT_GUID(m_originalCasterGUID))
|
||||
else if (m_originalCasterGUID.IsGameobject())
|
||||
{
|
||||
GameObject* go = m_caster->IsInWorld() ? m_caster->GetMap()->GetGameObject(m_originalCasterGUID) : NULL;
|
||||
m_originalCaster = go ? go->GetOwner() : NULL;
|
||||
|
|
@ -6382,7 +6382,7 @@ void Spell::FillRaidOrPartyHealthPriorityTargets(UnitList &targetUnitMap, Unit*
|
|||
|
||||
WorldObject* Spell::GetCastingObject() const
|
||||
{
|
||||
if (IS_GAMEOBJECT_GUID(m_originalCasterGUID))
|
||||
if (m_originalCasterGUID.IsGameobject())
|
||||
return m_caster->IsInWorld() ? m_caster->GetMap()->GetGameObject(m_originalCasterGUID) : NULL;
|
||||
else
|
||||
return m_caster;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue