mirror of
https://github.com/mangosfour/server.git
synced 2025-12-20 16:37:04 +00:00
[11462] Missing ObjectGuids in spell code.
This commit is contained in:
parent
4989ffba9d
commit
31c34a940d
7 changed files with 53 additions and 57 deletions
|
|
@ -871,10 +871,9 @@ void Spell::AddUnitTarget(Unit* pVictim, SpellEffectIndex effIndex)
|
|||
m_UniqueTargetInfo.push_back(target);
|
||||
}
|
||||
|
||||
void Spell::AddUnitTarget(uint64 unitGUID, SpellEffectIndex effIndex)
|
||||
void Spell::AddUnitTarget(ObjectGuid unitGuid, SpellEffectIndex effIndex)
|
||||
{
|
||||
Unit* unit = m_caster->GetGUID() == unitGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, unitGUID);
|
||||
if (unit)
|
||||
if (Unit* unit = m_caster->GetObjectGuid() == unitGuid ? m_caster : ObjectAccessor::GetUnit(*m_caster, unitGuid))
|
||||
AddUnitTarget(unit, effIndex);
|
||||
}
|
||||
|
||||
|
|
@ -923,10 +922,9 @@ void Spell::AddGOTarget(GameObject* pVictim, SpellEffectIndex effIndex)
|
|||
m_UniqueGOTargetInfo.push_back(target);
|
||||
}
|
||||
|
||||
void Spell::AddGOTarget(uint64 goGUID, SpellEffectIndex effIndex)
|
||||
void Spell::AddGOTarget(ObjectGuid goGuid, SpellEffectIndex effIndex)
|
||||
{
|
||||
GameObject* go = m_caster->GetMap()->GetGameObject(goGUID);
|
||||
if (go)
|
||||
if (GameObject* go = m_caster->GetMap()->GetGameObject(goGuid))
|
||||
AddGOTarget(go, effIndex);
|
||||
}
|
||||
|
||||
|
|
@ -2226,9 +2224,9 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
|||
break;
|
||||
}
|
||||
case TARGET_GAMEOBJECT_ITEM:
|
||||
if(m_targets.getGOTargetGUID())
|
||||
if (!m_targets.getGOTargetGuid().IsEmpty())
|
||||
AddGOTarget(m_targets.getGOTarget(), effIndex);
|
||||
else if(m_targets.getItemTarget())
|
||||
else if (m_targets.getItemTarget())
|
||||
AddItemTarget(m_targets.getItemTarget(), effIndex);
|
||||
break;
|
||||
case TARGET_MASTER:
|
||||
|
|
@ -2649,15 +2647,11 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
|||
case SPELL_EFFECT_RESURRECT_NEW:
|
||||
if (m_targets.getUnitTarget())
|
||||
targetUnitMap.push_back(m_targets.getUnitTarget());
|
||||
if (m_targets.getCorpseTargetGUID())
|
||||
if (!m_targets.getCorpseTargetGuid().IsEmpty())
|
||||
{
|
||||
Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID());
|
||||
if(corpse)
|
||||
{
|
||||
Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid());
|
||||
if(owner)
|
||||
if (Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGuid()))
|
||||
if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid()))
|
||||
targetUnitMap.push_back(owner);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SPELL_EFFECT_SUMMON:
|
||||
|
|
@ -2711,9 +2705,9 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
|||
case SPELL_EFFECT_SKIN_PLAYER_CORPSE:
|
||||
if (m_targets.getUnitTarget())
|
||||
targetUnitMap.push_back(m_targets.getUnitTarget());
|
||||
else if (m_targets.getCorpseTargetGUID())
|
||||
else if (!m_targets.getCorpseTargetGuid().IsEmpty())
|
||||
{
|
||||
if (Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID()))
|
||||
if (Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGuid()))
|
||||
if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid()))
|
||||
targetUnitMap.push_back(owner);
|
||||
}
|
||||
|
|
@ -2918,7 +2912,7 @@ void Spell::cast(bool skipCheck)
|
|||
UpdatePointers();
|
||||
|
||||
// cancel at lost main target unit
|
||||
if(!m_targets.getUnitTarget() && m_targets.getUnitTargetGUID() && m_targets.getUnitTargetGUID() != m_caster->GetGUID())
|
||||
if (!m_targets.getUnitTarget() && !m_targets.getUnitTargetGuid().IsEmpty() && m_targets.getUnitTargetGuid() != m_caster->GetObjectGuid())
|
||||
{
|
||||
cancel();
|
||||
m_caster->DecreaseCastCounter();
|
||||
|
|
@ -2926,11 +2920,11 @@ void Spell::cast(bool skipCheck)
|
|||
return;
|
||||
}
|
||||
|
||||
if(m_caster->GetTypeId() != TYPEID_PLAYER && m_targets.getUnitTarget() && m_targets.getUnitTarget() != m_caster)
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER && m_targets.getUnitTarget() && m_targets.getUnitTarget() != m_caster)
|
||||
m_caster->SetInFront(m_targets.getUnitTarget());
|
||||
|
||||
SpellCastResult castResult = CheckPower();
|
||||
if(castResult != SPELL_CAST_OK)
|
||||
if (castResult != SPELL_CAST_OK)
|
||||
{
|
||||
SendCastResult(castResult);
|
||||
finish(false);
|
||||
|
|
@ -2940,7 +2934,7 @@ void Spell::cast(bool skipCheck)
|
|||
}
|
||||
|
||||
// triggered cast called from Spell::prepare where it was already checked
|
||||
if(!skipCheck)
|
||||
if (!skipCheck)
|
||||
{
|
||||
castResult = CheckCast(false);
|
||||
if(castResult != SPELL_CAST_OK)
|
||||
|
|
@ -3311,7 +3305,7 @@ void Spell::update(uint32 difftime)
|
|||
// update pointers based at it's GUIDs
|
||||
UpdatePointers();
|
||||
|
||||
if(m_targets.getUnitTargetGUID() && !m_targets.getUnitTarget())
|
||||
if (!m_targets.getUnitTargetGuid().IsEmpty() && !m_targets.getUnitTarget())
|
||||
{
|
||||
cancel();
|
||||
return;
|
||||
|
|
@ -3916,11 +3910,11 @@ void Spell::SendLogExecute()
|
|||
case SPELL_EFFECT_SUMMON_OBJECT_SLOT2:
|
||||
case SPELL_EFFECT_SUMMON_OBJECT_SLOT3:
|
||||
case SPELL_EFFECT_SUMMON_OBJECT_SLOT4:
|
||||
if(Unit *unit = m_targets.getUnitTarget())
|
||||
if (Unit *unit = m_targets.getUnitTarget())
|
||||
data << unit->GetPackGUID();
|
||||
else if(m_targets.getItemTargetGUID())
|
||||
data.appendPackGUID(m_targets.getItemTargetGUID());
|
||||
else if(GameObject *go = m_targets.getGOTarget())
|
||||
else if (!m_targets.getItemTargetGuid().IsEmpty())
|
||||
data << m_targets.getItemTargetGuid().WriteAsPacked();
|
||||
else if (GameObject *go = m_targets.getGOTarget())
|
||||
data << go->GetPackGUID();
|
||||
else
|
||||
data << uint8(0); // guid
|
||||
|
|
@ -5571,7 +5565,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
if (!my_trade)
|
||||
return SPELL_FAILED_NOT_TRADING;
|
||||
|
||||
TradeSlots slot = TradeSlots(m_targets.getItemTargetGUID());
|
||||
TradeSlots slot = TradeSlots(m_targets.getItemTargetGuid().GetRawValue());
|
||||
if (slot != TRADE_SLOT_NONTRADED)
|
||||
return SPELL_FAILED_ITEM_NOT_READY;
|
||||
|
||||
|
|
@ -6128,18 +6122,18 @@ SpellCastResult Spell::CheckItems()
|
|||
}
|
||||
|
||||
// check target item (for triggered case not report error)
|
||||
if(m_targets.getItemTargetGUID())
|
||||
if (!m_targets.getItemTargetGuid().IsEmpty())
|
||||
{
|
||||
if(m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
return m_IsTriggeredSpell && !(m_targets.m_targetMask & TARGET_FLAG_TRADE_ITEM)
|
||||
? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_BAD_TARGETS;
|
||||
|
||||
if(!m_targets.getItemTarget())
|
||||
if (!m_targets.getItemTarget())
|
||||
return m_IsTriggeredSpell && !(m_targets.m_targetMask & TARGET_FLAG_TRADE_ITEM)
|
||||
? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_ITEM_GONE;
|
||||
|
||||
isVellumTarget = m_targets.getItemTarget()->GetProto()->IsVellum();
|
||||
if(!m_targets.getItemTarget()->IsFitToSpellRequirements(m_spellInfo))
|
||||
if (!m_targets.getItemTarget()->IsFitToSpellRequirements(m_spellInfo))
|
||||
return m_IsTriggeredSpell && !(m_targets.m_targetMask & TARGET_FLAG_TRADE_ITEM)
|
||||
? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_EQUIPPED_ITEM_CLASS;
|
||||
|
||||
|
|
@ -6696,10 +6690,10 @@ bool Spell::CheckTarget( Unit* target, SpellEffectIndex eff )
|
|||
// player far away, maybe his corpse near?
|
||||
if(target != m_caster && !target->IsWithinLOSInMap(m_caster))
|
||||
{
|
||||
if(!m_targets.getCorpseTargetGUID())
|
||||
if (!m_targets.getCorpseTargetGuid().IsEmpty())
|
||||
return false;
|
||||
|
||||
Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID());
|
||||
Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGuid());
|
||||
if(!corpse)
|
||||
return false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue