aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-09-14 16:14:12 +0200
committerShauren <shauren.trinity@gmail.com>2014-09-14 16:14:12 +0200
commita0e50ea35fca61447bf07fc45d93c98234ba59f7 (patch)
treeb4ee69a63866f42e466a3c03fc031ce0710ac762 /src/server/game/Spells
parentce67a097bf3c0c3241f4441a808e32639ddbaafb (diff)
Core/Entities: Use ObjectGuid class in game project
Diffstat (limited to 'src/server/game/Spells')
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp42
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.h4
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp16
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.h38
-rw-r--r--src/server/game/Spells/Spell.cpp121
-rw-r--r--src/server/game/Spells/Spell.h30
-rw-r--r--src/server/game/Spells/SpellEffects.cpp36
-rw-r--r--src/server/game/Spells/SpellScript.cpp2
-rw-r--r--src/server/game/Spells/SpellScript.h2
9 files changed, 140 insertions, 151 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 55336d6082c..6f0298ee22f 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -423,7 +423,7 @@ int32 AuraEffect::CalculateAmount(Unit* caster)
// check item enchant aura cast
if (!amount && caster)
- if (uint64 itemGUID = GetBase()->GetCastItemGUID())
+ if (ObjectGuid itemGUID = GetBase()->GetCastItemGUID())
if (Player* playerCaster = caster->ToPlayer())
if (Item* castItem = playerCaster->GetItemByGuid(itemGUID))
if (castItem->GetItemSuffixFactor())
@@ -704,7 +704,7 @@ void AuraEffect::ApplySpellMod(Unit* target, bool apply)
case SPELLMOD_EFFECT2:
case SPELLMOD_EFFECT3:
{
- uint64 guid = target->GetGUID();
+ ObjectGuid guid = target->GetGUID();
Unit::AuraApplicationMap & auras = target->GetAppliedAuras();
for (Unit::AuraApplicationMap::iterator iter = auras.begin(); iter != auras.end(); ++iter)
{
@@ -1663,7 +1663,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
}
// remove other shapeshift before applying a new one
- target->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT, 0, GetBase());
+ target->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT, ObjectGuid::Empty, GetBase());
// stop handling the effect if it was removed by linked event
if (aurApp->GetRemoveMode())
@@ -2025,7 +2025,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode,
{
// for players, start regeneration after 1s (in polymorph fast regeneration case)
// only if caster is Player (after patch 2.4.2)
- if (IS_PLAYER_GUID(GetCasterGUID()))
+ if (GetCasterGUID().IsPlayer())
target->ToPlayer()->setRegenTimerCount(1*IN_MILLISECONDS);
//dismount polymorphed target (after patch 2.4.2)
@@ -3333,7 +3333,7 @@ void AuraEffect::HandleAuraModStateImmunity(AuraApplication const* aurApp, uint8
target->ApplySpellImmune(GetId(), IMMUNITY_STATE, GetMiscValue(), apply);
if (apply && GetSpellInfo()->AttributesEx & SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY)
- target->RemoveAurasByType(AuraType(GetMiscValue()), 0, GetBase());
+ target->RemoveAurasByType(AuraType(GetMiscValue()), ObjectGuid::Empty, GetBase());
}
void AuraEffect::HandleAuraModSchoolImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -5183,13 +5183,13 @@ void AuraEffect::HandleAuraLinked(AuraApplication const* aurApp, uint8 mode, boo
}
else
{
- uint64 casterGUID = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? GetCasterGUID() : target->GetGUID();
+ ObjectGuid casterGUID = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? GetCasterGUID() : target->GetGUID();
target->RemoveAura(triggeredSpellId, casterGUID, 0, aurApp->GetRemoveMode());
}
}
else if (mode & AURA_EFFECT_HANDLE_REAPPLY && apply)
{
- uint64 casterGUID = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? GetCasterGUID() : target->GetGUID();
+ ObjectGuid casterGUID = triggeredSpellInfo->NeedsToBeTriggeredByCaster(m_spellInfo) ? GetCasterGUID() : target->GetGUID();
// change the stack amount to be equal to stack amount of our aura
if (Aura* triggeredAura = target->GetAura(triggeredSpellId, casterGUID))
triggeredAura->ModStackAmount(GetBase()->GetStackAmount() - triggeredAura->GetStackAmount());
@@ -5629,7 +5629,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
case 28820:
{
// Need remove self if Lightning Shield not active
- if (!target->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_SHAMAN, 0x400))
+ if (!target->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_SHAMAN, 0x400, 0, 0))
target->RemoveAurasDueToSpell(28820);
return;
}
@@ -5918,8 +5918,8 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
caster->CalcAbsorbResist(target, GetSpellInfo()->GetSchoolMask(), DOT, damage, &absorb, &resist, GetSpellInfo());
- TC_LOG_INFO("spells", "PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
- GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), damage, GetId(), absorb);
+ TC_LOG_INFO("spells", "PeriodicTick: %s attacked %s for %u dmg inflicted by %u absorb is %u",
+ GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), damage, GetId(), absorb);
caster->DealDamageMods(target, damage, &absorb);
@@ -6008,8 +6008,8 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
if (target->GetHealth() < damage)
damage = uint32(target->GetHealth());
- TC_LOG_INFO("spells", "PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
- GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), damage, GetId(), absorb);
+ TC_LOG_INFO("spells", "PeriodicTick: %s health leech of %s for %u dmg inflicted by %u abs is %u",
+ GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), damage, GetId(), absorb);
caster->SendSpellNonMeleeDamageLog(target, GetId(), damage, GetSpellInfo()->GetSchoolMask(), absorb, resist, false, 0, crit);
@@ -6145,8 +6145,8 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
if (crit)
damage = caster->SpellCriticalHealingBonus(m_spellInfo, damage, target);
- TC_LOG_INFO("spells", "PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u",
- GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), damage, GetId());
+ TC_LOG_INFO("spells", "PeriodicTick: %s heal of %s for %u health inflicted by %u",
+ GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), damage, GetId());
uint32 absorb = 0;
uint32 heal = uint32(damage);
@@ -6158,7 +6158,7 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
target->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f, GetSpellInfo());
- bool haveCastItem = GetBase()->GetCastItemGUID() != 0;
+ bool haveCastItem = !GetBase()->GetCastItemGUID().IsEmpty();
// Health Funnel
// damage caster for heal amount
@@ -6216,8 +6216,8 @@ void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) con
drainAmount = maxmana;
}
- TC_LOG_INFO("spells", "PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
- GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), drainAmount, GetId());
+ TC_LOG_INFO("spells", "PeriodicTick: %s power leech of %s for %u dmg inflicted by %u",
+ GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), drainAmount, GetId());
// resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
if (powerType == POWER_MANA)
@@ -6277,8 +6277,8 @@ void AuraEffect::HandleObsModPowerAuraTick(Unit* target, Unit* caster) const
// ignore negative values (can be result apply spellmods to aura damage
uint32 amount = std::max(m_amount, 0) * target->GetMaxPower(powerType) /100;
- TC_LOG_INFO("spells", "PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
- GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), amount, GetId());
+ TC_LOG_INFO("spells", "PeriodicTick: %s energize s for %u dmg inflicted by %u",
+ GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), amount, GetId());
SpellPeriodicAuraLogInfo pInfo(this, amount, 0, 0, 0, 0.0f, false);
target->SendPeriodicAuraLog(&pInfo);
@@ -6315,8 +6315,8 @@ void AuraEffect::HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) cons
SpellPeriodicAuraLogInfo pInfo(this, amount, 0, 0, 0, 0.0f, false);
target->SendPeriodicAuraLog(&pInfo);
- TC_LOG_INFO("spells", "PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
- GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), amount, GetId());
+ TC_LOG_INFO("spells", "PeriodicTick: %s energize %s for %u dmg inflicted by %u",
+ GetCasterGUID().ToString().c_str(), target->GetGUID().ToString().c_str(), amount, GetId());
int32 gain = target->ModifyPower(powerType, amount);
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h
index 5eec9021291..eae1bebab8b 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.h
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.h
@@ -30,14 +30,14 @@ typedef void(AuraEffect::*pAuraEffectHandler)(AuraApplication const* aurApp, uin
class AuraEffect
{
friend void Aura::_InitEffects(uint8 effMask, Unit* caster, int32 *baseAmount);
- friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID);
+ friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID);
friend Aura::~Aura();
private:
~AuraEffect();
explicit AuraEffect(Aura* base, uint8 effIndex, int32 *baseAmount, Unit* caster);
public:
Unit* GetCaster() const { return GetBase()->GetCaster(); }
- uint64 GetCasterGUID() const { return GetBase()->GetCasterGUID(); }
+ ObjectGuid GetCasterGUID() const { return GetBase()->GetCasterGUID(); }
Aura* GetBase() const { return m_base; }
void GetTargetList(std::list<Unit*> & targetList) const;
void GetApplicationList(std::list<AuraApplication*> & applicationList) const;
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 21d7a6ccac1..1d21d3556ab 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -200,7 +200,7 @@ void AuraApplication::BuildUpdatePacket(ByteBuffer& data, bool remove) const
data << uint8(aura->GetSpellInfo()->StackAmount ? aura->GetStackAmount() : aura->GetCharges());
if (!(flags & AFLAG_CASTER))
- data.appendPackGUID(aura->GetCasterGUID());
+ data << aura->GetCasterGUID().WriteAsPacked();
if (flags & AFLAG_DURATION)
{
@@ -248,7 +248,7 @@ uint8 Aura::BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 avalibleE
return effMask & avalibleEffectMask;
}
-Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/, bool* refresh /*= NULL*/)
+Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/, bool* refresh /*= NULL*/)
{
ASSERT(spellproto);
ASSERT(owner);
@@ -274,7 +274,7 @@ Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMas
return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
}
-Aura* Aura::TryCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/)
+Aura* Aura::TryCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/)
{
ASSERT(spellproto);
ASSERT(owner);
@@ -286,7 +286,7 @@ Aura* Aura::TryCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject
return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
}
-Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID)
+Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID)
{
ASSERT(effMask);
ASSERT(spellproto);
@@ -331,9 +331,9 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne
return aura;
}
-Aura::Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, uint64 casterGUID) :
+Aura::Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, ObjectGuid casterGUID) :
m_spellInfo(spellproto), m_casterGuid(casterGUID ? casterGUID : caster->GetGUID()),
-m_castItemGuid(castItem ? castItem->GetGUID() : 0), m_applyTime(time(NULL)),
+m_castItemGuid(castItem ? castItem->GetGUID() : ObjectGuid::Empty), m_applyTime(time(NULL)),
m_owner(owner), m_timeCla(0), m_updateTargetMapInterval(0),
m_casterLevel(caster ? caster->getLevel() : m_spellInfo->SpellLevel), m_procCharges(0), m_stackAmount(1),
m_isRemoved(false), m_isSingleTarget(false), m_isUsingCharges(false), m_dropEvent(nullptr)
@@ -2418,7 +2418,7 @@ void Aura::CallScriptAfterEffectProcHandlers(AuraEffect const* aurEff, AuraAppli
}
}
-UnitAura::UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, uint64 casterGUID)
+UnitAura::UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, ObjectGuid casterGUID)
: Aura(spellproto, owner, caster, castItem, casterGUID)
{
m_AuraDRGroup = DIMINISHING_NONE;
@@ -2521,7 +2521,7 @@ void UnitAura::FillTargetMap(std::map<Unit*, uint8> & targets, Unit* caster)
}
}
-DynObjAura::DynObjAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, uint64 casterGUID)
+DynObjAura::DynObjAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, ObjectGuid casterGUID)
: Aura(spellproto, owner, caster, castItem, casterGUID)
{
LoadScripts();
diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h
index 1266bf5c6ec..f69d9baafe0 100644
--- a/src/server/game/Spells/Auras/SpellAuras.h
+++ b/src/server/game/Spells/Auras/SpellAuras.h
@@ -84,23 +84,23 @@ class AuraApplication
class Aura
{
- friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32 *baseAmount, Item* castItem, uint64 casterGUID);
+ friend Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32 *baseAmount, Item* castItem, ObjectGuid casterGUID);
public:
- typedef std::map<uint64, AuraApplication *> ApplicationMap;
+ typedef std::map<ObjectGuid, AuraApplication*> ApplicationMap;
static uint8 BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 avalibleEffectMask, WorldObject* owner);
- static Aura* TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount = NULL, Item* castItem = NULL, uint64 casterGUID = 0, bool* refresh = NULL);
- static Aura* TryCreate(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount = NULL, Item* castItem = NULL, uint64 casterGUID = 0);
- static Aura* Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID);
- explicit Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, uint64 casterGUID);
+ static Aura* TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount = NULL, Item* castItem = NULL, ObjectGuid casterGUID = ObjectGuid::Empty, bool* refresh = NULL);
+ static Aura* TryCreate(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount = NULL, Item* castItem = NULL, ObjectGuid casterGUID = ObjectGuid::Empty);
+ static Aura* Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID);
+ explicit Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, ObjectGuid casterGUID);
void _InitEffects(uint8 effMask, Unit* caster, int32 *baseAmount);
virtual ~Aura();
SpellInfo const* GetSpellInfo() const { return m_spellInfo; }
uint32 GetId() const{ return GetSpellInfo()->Id; }
- uint64 GetCastItemGUID() const { return m_castItemGuid; }
- uint64 GetCasterGUID() const { return m_casterGuid; }
+ ObjectGuid GetCastItemGUID() const { return m_castItemGuid; }
+ ObjectGuid GetCasterGUID() const { return m_casterGuid; }
Unit* GetCaster() const;
WorldObject* GetOwner() const { return m_owner; }
Unit* GetUnitOwner() const { ASSERT(GetType() == UNIT_AURA_TYPE); return (Unit*)m_owner; }
@@ -186,11 +186,11 @@ class Aura
void HandleAllEffects(AuraApplication * aurApp, uint8 mode, bool apply);
// Helpers for targets
- ApplicationMap const & GetApplicationMap() {return m_applications;}
+ ApplicationMap const& GetApplicationMap() { return m_applications; }
void GetApplicationList(Unit::AuraApplicationList& applicationList) const;
- const AuraApplication * GetApplicationOfTarget (uint64 guid) const { ApplicationMap::const_iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; }
- AuraApplication * GetApplicationOfTarget (uint64 guid) { ApplicationMap::iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; }
- bool IsAppliedOnTarget(uint64 guid) const { return m_applications.find(guid) != m_applications.end(); }
+ const AuraApplication* GetApplicationOfTarget(ObjectGuid guid) const { ApplicationMap::const_iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; }
+ AuraApplication* GetApplicationOfTarget(ObjectGuid guid) { ApplicationMap::iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; }
+ bool IsAppliedOnTarget(ObjectGuid guid) const { return m_applications.find(guid) != m_applications.end(); }
void SetNeedClientUpdateForTargets() const;
void HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, bool apply, bool onReapply);
@@ -246,10 +246,10 @@ class Aura
void _DeleteRemovedApplications();
protected:
SpellInfo const* const m_spellInfo;
- uint64 const m_casterGuid;
- uint64 const m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted
+ ObjectGuid const m_casterGuid;
+ ObjectGuid const m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted
time_t const m_applyTime;
- WorldObject* const m_owner; //
+ WorldObject* const m_owner;
int32 m_maxDuration; // Max aura duration
int32 m_duration; // Current time
@@ -275,9 +275,9 @@ class Aura
class UnitAura : public Aura
{
- friend Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, uint64 casterGUID);
+ friend Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, ObjectGuid casterGUID);
protected:
- explicit UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, uint64 casterGUID);
+ explicit UnitAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, ObjectGuid casterGUID);
public:
void _ApplyForTarget(Unit* target, Unit* caster, AuraApplication * aurApp) override;
void _UnapplyForTarget(Unit* target, Unit* caster, AuraApplication * aurApp) override;
@@ -296,9 +296,9 @@ class UnitAura : public Aura
class DynObjAura : public Aura
{
- friend Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, uint64 casterGUID);
+ friend Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, ObjectGuid casterGUID);
protected:
- explicit DynObjAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, uint64 casterGUID);
+ explicit DynObjAura(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32 *baseAmount, Item* castItem, ObjectGuid casterGUID);
public:
void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT) override;
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 0a742fea7b5..c4ae36d5d24 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -61,14 +61,14 @@ extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS];
SpellDestination::SpellDestination()
{
_position.Relocate(0, 0, 0, 0);
- _transportGUID = 0;
+ _transportGUID.Clear();
_transportOffset.Relocate(0, 0, 0, 0);
}
SpellDestination::SpellDestination(float x, float y, float z, float orientation, uint32 mapId)
{
_position.Relocate(x, y, z, orientation);
- _transportGUID = 0;
+ _transportGUID.Clear();
_position.m_mapId = mapId;
_transportOffset.Relocate(0, 0, 0, 0);
}
@@ -76,7 +76,7 @@ SpellDestination::SpellDestination(float x, float y, float z, float orientation,
SpellDestination::SpellDestination(Position const& pos)
{
_position.Relocate(pos);
- _transportGUID = 0;
+ _transportGUID.Clear();
_transportOffset.Relocate(0, 0, 0, 0);
}
@@ -111,8 +111,8 @@ SpellCastTargets::SpellCastTargets() : m_elevation(0), m_speed(0), m_strTarget()
m_objectTarget = NULL;
m_itemTarget = NULL;
- m_objectTargetGUID = 0;
- m_itemTargetGUID = 0;
+ m_objectTargetGUID.Clear();
+ m_itemTargetGUID.Clear();
m_itemTargetEntry = 0;
m_targetMask = 0;
@@ -128,14 +128,14 @@ void SpellCastTargets::Read(ByteBuffer& data, Unit* caster)
return;
if (m_targetMask & (TARGET_FLAG_UNIT | TARGET_FLAG_UNIT_MINIPET | TARGET_FLAG_GAMEOBJECT | TARGET_FLAG_CORPSE_ENEMY | TARGET_FLAG_CORPSE_ALLY))
- data.readPackGUID(m_objectTargetGUID);
+ data >> m_objectTargetGUID.ReadAsPacked();
if (m_targetMask & (TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM))
- data.readPackGUID(m_itemTargetGUID);
+ data >> m_itemTargetGUID.ReadAsPacked();
if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
{
- data.readPackGUID(m_src._transportGUID);
+ data >> m_src._transportGUID.ReadAsPacked();
if (m_src._transportGUID)
data >> m_src._transportOffset.PositionXYZStream();
else
@@ -152,7 +152,7 @@ void SpellCastTargets::Read(ByteBuffer& data, Unit* caster)
if (m_targetMask & TARGET_FLAG_DEST_LOCATION)
{
- data.readPackGUID(m_dst._transportGUID);
+ data >> m_dst._transportGUID.ReadAsPacked();
if (m_dst._transportGUID)
data >> m_dst._transportOffset.PositionXYZStream();
else
@@ -178,7 +178,7 @@ void SpellCastTargets::Write(ByteBuffer& data)
data << uint32(m_targetMask);
if (m_targetMask & (TARGET_FLAG_UNIT | TARGET_FLAG_CORPSE_ALLY | TARGET_FLAG_GAMEOBJECT | TARGET_FLAG_CORPSE_ENEMY | TARGET_FLAG_UNIT_MINIPET))
- data.appendPackGUID(m_objectTargetGUID);
+ data << m_objectTargetGUID.WriteAsPacked();
if (m_targetMask & (TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM))
{
@@ -190,7 +190,7 @@ void SpellCastTargets::Write(ByteBuffer& data)
if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
{
- data.appendPackGUID(m_src._transportGUID); // relative position guid here - transport for example
+ data << m_src._transportGUID.WriteAsPacked(); // relative position guid here - transport for example
if (m_src._transportGUID)
data << m_src._transportOffset.PositionXYZStream();
else
@@ -199,7 +199,7 @@ void SpellCastTargets::Write(ByteBuffer& data)
if (m_targetMask & TARGET_FLAG_DEST_LOCATION)
{
- data.appendPackGUID(m_dst._transportGUID); // relative position guid here - transport for example
+ data << m_dst._transportGUID.WriteAsPacked(); // relative position guid here - transport for example
if (m_dst._transportGUID)
data << m_dst._transportOffset.PositionXYZStream();
else
@@ -210,24 +210,19 @@ void SpellCastTargets::Write(ByteBuffer& data)
data << m_strTarget;
}
-uint64 SpellCastTargets::GetUnitTargetGUID() const
+ObjectGuid SpellCastTargets::GetUnitTargetGUID() const
{
- switch (GUID_HIPART(m_objectTargetGUID))
- {
- case HIGHGUID_PLAYER:
- case HIGHGUID_VEHICLE:
- case HIGHGUID_UNIT:
- case HIGHGUID_PET:
- return m_objectTargetGUID;
- default:
- return 0LL;
- }
+ if (m_objectTargetGUID.IsUnit())
+ return m_objectTargetGUID;
+
+ return ObjectGuid::Empty;
}
Unit* SpellCastTargets::GetUnitTarget() const
{
if (m_objectTarget)
return m_objectTarget->ToUnit();
+
return NULL;
}
@@ -241,27 +236,22 @@ void SpellCastTargets::SetUnitTarget(Unit* target)
m_targetMask |= TARGET_FLAG_UNIT;
}
-uint64 SpellCastTargets::GetGOTargetGUID() const
+ObjectGuid SpellCastTargets::GetGOTargetGUID() const
{
- switch (GUID_HIPART(m_objectTargetGUID))
- {
- case HIGHGUID_TRANSPORT:
- case HIGHGUID_MO_TRANSPORT:
- case HIGHGUID_GAMEOBJECT:
- return m_objectTargetGUID;
- default:
- return 0LL;
- }
+ if (m_objectTargetGUID.IsAnyTypeGameObject())
+ return m_objectTargetGUID;
+
+ return ObjectGuid::Empty;
}
GameObject* SpellCastTargets::GetGOTarget() const
{
if (m_objectTarget)
return m_objectTarget->ToGameObject();
+
return NULL;
}
-
void SpellCastTargets::SetGOTarget(GameObject* target)
{
if (!target)
@@ -272,21 +262,19 @@ void SpellCastTargets::SetGOTarget(GameObject* target)
m_targetMask |= TARGET_FLAG_GAMEOBJECT;
}
-uint64 SpellCastTargets::GetCorpseTargetGUID() const
+ObjectGuid SpellCastTargets::GetCorpseTargetGUID() const
{
- switch (GUID_HIPART(m_objectTargetGUID))
- {
- case HIGHGUID_CORPSE:
- return m_objectTargetGUID;
- default:
- return 0LL;
- }
+ if (m_objectTargetGUID.IsCorpse())
+ return m_objectTargetGUID;
+
+ return ObjectGuid::Empty;
}
Corpse* SpellCastTargets::GetCorpseTarget() const
{
if (m_objectTarget)
return m_objectTarget->ToCorpse();
+
return NULL;
}
@@ -295,7 +283,7 @@ WorldObject* SpellCastTargets::GetObjectTarget() const
return m_objectTarget;
}
-uint64 SpellCastTargets::GetObjectTargetGUID() const
+ObjectGuid SpellCastTargets::GetObjectTargetGUID() const
{
return m_objectTargetGUID;
}
@@ -303,7 +291,7 @@ uint64 SpellCastTargets::GetObjectTargetGUID() const
void SpellCastTargets::RemoveObjectTarget()
{
m_objectTarget = NULL;
- m_objectTargetGUID = 0LL;
+ m_objectTargetGUID.Clear();
m_targetMask &= ~(TARGET_FLAG_UNIT_MASK | TARGET_FLAG_CORPSE_MASK | TARGET_FLAG_GAMEOBJECT_MASK);
}
@@ -320,7 +308,7 @@ void SpellCastTargets::SetItemTarget(Item* item)
void SpellCastTargets::SetTradeItemTarget(Player* caster)
{
- m_itemTargetGUID = uint64(TRADE_SLOT_NONTRADED);
+ m_itemTargetGUID.Set(uint64(TRADE_SLOT_NONTRADED));
m_itemTargetEntry = 0;
m_targetMask |= TARGET_FLAG_TRADE_ITEM;
@@ -443,7 +431,7 @@ void SpellCastTargets::Update(Unit* caster)
if (m_targetMask & TARGET_FLAG_ITEM)
m_itemTarget = player->GetItemByGuid(m_itemTargetGUID);
else if (m_targetMask & TARGET_FLAG_TRADE_ITEM)
- if (m_itemTargetGUID == TRADE_SLOT_NONTRADED) // here it is not guid but slot. Also prevents hacking slots
+ if (m_itemTargetGUID.GetRawValue() == TRADE_SLOT_NONTRADED) // here it is not guid but slot. Also prevents hacking slots
if (TradeData* pTrade = player->GetTradeData())
m_itemTarget = pTrade->GetTraderData()->GetItem(TRADE_SLOT_NONTRADED);
@@ -502,7 +490,7 @@ SpellValue::SpellValue(SpellInfo const* proto)
AuraStackAmount = 1;
}
-Spell::Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, uint64 originalCasterGUID, bool skipCheck) :
+Spell::Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID, bool skipCheck) :
m_spellInfo(sSpellMgr->GetSpellForDifficultyFromSpell(info, caster)),
m_caster((info->AttributesEx6 & SPELL_ATTR6_CAST_BY_CHARMER && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster)
, m_spellValue(new SpellValue(m_spellInfo)), m_preGeneratedPath(PathGenerator(m_caster))
@@ -570,7 +558,7 @@ m_caster((info->AttributesEx6 & SPELL_ATTR6_CAST_BY_CHARMER && caster->GetCharme
_triggeredCastFlags = TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_EQUIPPED_ITEM_REQUIREMENT);
m_CastItem = NULL;
- m_castItemGUID = 0;
+ m_castItemGUID.Clear();
m_castItemEntry = 0;
unitTarget = NULL;
@@ -953,7 +941,7 @@ void Spell::SelectImplicitChannelTargets(SpellEffIndex effIndex, SpellImplicitTa
{
case TARGET_UNIT_CHANNEL_TARGET:
{
- WorldObject* target = ObjectAccessor::GetUnit(*m_caster, m_originalCaster->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT));
+ WorldObject* target = ObjectAccessor::GetUnit(*m_caster, m_originalCaster->GetChannelObjectGuid());
CallScriptObjectTargetSelectHandlers(target, effIndex, targetType);
// unit target may be no longer avalible - teleported out of map for example
if (target && target->ToUnit())
@@ -965,7 +953,7 @@ void Spell::SelectImplicitChannelTargets(SpellEffIndex effIndex, SpellImplicitTa
case TARGET_DEST_CHANNEL_TARGET:
if (channeledSpell->m_targets.HasDst())
m_targets.SetDst(channeledSpell->m_targets);
- else if (WorldObject* target = ObjectAccessor::GetWorldObject(*m_caster, m_originalCaster->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT)))
+ else if (WorldObject* target = ObjectAccessor::GetWorldObject(*m_caster, m_originalCaster->GetChannelObjectGuid()))
{
CallScriptObjectTargetSelectHandlers(target, effIndex, targetType);
if (target)
@@ -1063,7 +1051,7 @@ void Spell::SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTar
AddUnitTarget(unitTarget, effMask, true, false);
else
{
- TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set object of wrong type, expected unit, got %s, effect %u", m_spellInfo->Id, GetLogNameForGuid(target->GetGUID()), effMask);
+ TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set object of wrong type, expected unit, got %s, effect %u", m_spellInfo->Id, target->GetGUID().GetTypeName(), effMask);
return;
}
break;
@@ -1073,7 +1061,7 @@ void Spell::SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTar
AddGOTarget(gobjTarget, effMask);
else
{
- TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set object of wrong type, expected gameobject, got %s, effect %u", m_spellInfo->Id, GetLogNameForGuid(target->GetGUID()), effMask);
+ TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set object of wrong type, expected gameobject, got %s, effect %u", m_spellInfo->Id, target->GetGUID().GetTypeName(), effMask);
return;
}
break;
@@ -2019,7 +2007,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
if (target->IsImmunedToSpellEffect(m_spellInfo, effIndex))
effectMask &= ~(1 << effIndex);
- uint64 targetGUID = target->GetGUID();
+ ObjectGuid targetGUID = target->GetGUID();
// Lookup target in already in list
for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
@@ -2129,7 +2117,7 @@ void Spell::AddGOTarget(GameObject* go, uint32 effectMask)
if (!effectMask)
return;
- uint64 targetGUID = go->GetGUID();
+ ObjectGuid targetGUID = go->GetGUID();
// Lookup target in already in list
for (std::list<GOTargetInfo>::iterator ihit = m_UniqueGOTargetInfo.begin(); ihit != m_UniqueGOTargetInfo.end(); ++ihit)
@@ -2574,7 +2562,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
{
bool refresh = false;
m_spellAura = Aura::TryRefreshStackOrCreate(aurSpellInfo, effectMask, unit,
- m_originalCaster, (aurSpellInfo == m_spellInfo)? &m_spellValue->EffectBasePoints[0] : &basePoints[0], m_CastItem, 0, &refresh);
+ m_originalCaster, (aurSpellInfo == m_spellInfo) ? &m_spellValue->EffectBasePoints[0] : &basePoints[0], m_CastItem, ObjectGuid::Empty, &refresh);
if (m_spellAura)
{
// Set aura stack amount to desired value
@@ -2818,7 +2806,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
}
else
{
- m_castItemGUID = 0;
+ m_castItemGUID.Clear();
m_castItemEntry = 0;
}
@@ -4167,7 +4155,7 @@ void Spell::SendChannelUpdate(uint32 time)
{
if (time == 0)
{
- m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, 0);
+ m_caster->SetChannelObjectGuid(ObjectGuid::Empty);
m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, 0);
}
@@ -4180,7 +4168,7 @@ void Spell::SendChannelUpdate(uint32 time)
void Spell::SendChannelStart(uint32 duration)
{
- uint64 channelTarget = m_targets.GetObjectTargetGUID();
+ ObjectGuid channelTarget = m_targets.GetObjectTargetGUID();
if (!channelTarget && !m_spellInfo->NeedsExplicitUnitTarget())
if (m_UniqueTargetInfo.size() + m_UniqueGOTargetInfo.size() == 1) // this is for TARGET_SELECT_CATEGORY_NEARBY
channelTarget = !m_UniqueTargetInfo.empty() ? m_UniqueTargetInfo.front().targetGUID : m_UniqueGOTargetInfo.front().targetGUID;
@@ -4194,7 +4182,7 @@ void Spell::SendChannelStart(uint32 duration)
m_timer = duration;
if (channelTarget)
- m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, channelTarget);
+ m_caster->SetChannelObjectGuid(channelTarget);
m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, m_spellInfo->Id);
}
@@ -4284,7 +4272,7 @@ void Spell::TakeCastItem()
m_targets.SetItemTarget(NULL);
m_CastItem = NULL;
- m_castItemGUID = 0;
+ m_castItemGUID.Clear();
m_castItemEntry = 0;
}
}
@@ -4306,7 +4294,7 @@ void Spell::TakePower()
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
if (powerType == POWER_RAGE || powerType == POWER_ENERGY || powerType == POWER_RUNE)
- if (uint64 targetGUID = m_targets.GetUnitTargetGUID())
+ if (ObjectGuid targetGUID = m_targets.GetUnitTargetGUID())
for (std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
if (ihit->targetGUID == targetGUID)
{
@@ -4530,7 +4518,7 @@ void Spell::TakeReagents()
}
m_CastItem = NULL;
- m_castItemGUID = 0;
+ m_castItemGUID.Clear();
m_castItemEntry = 0;
}
@@ -5123,7 +5111,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_targets.GetTargetMask() & TARGET_FLAG_TRADE_ITEM)
{
if (TradeData* pTrade = m_caster->ToPlayer()->GetTradeData())
- pTempItem = pTrade->GetTraderData()->GetItem(TradeSlots(m_targets.GetItemTargetGUID()));
+ pTempItem = pTrade->GetTraderData()->GetItem(TradeSlots(m_targets.GetItemTargetGUID().GetRawValue())); // at this point item target guid contains the trade slot
}
else if (m_targets.GetTargetMask() & TARGET_FLAG_ITEM)
pTempItem = m_caster->ToPlayer()->GetItemByGuid(m_targets.GetItemTargetGUID());
@@ -5451,7 +5439,8 @@ SpellCastResult Spell::CheckCast(bool strict)
if (!my_trade)
return SPELL_FAILED_NOT_TRADING;
- TradeSlots slot = TradeSlots(m_targets.GetItemTargetGUID());
+ // Item target guid contains trade slot until m_targets.UpdateTradeSlotItem() is called
+ TradeSlots slot = TradeSlots(m_targets.GetItemTargetGUID().GetRawValue());
if (slot != TRADE_SLOT_NONTRADED)
return SPELL_FAILED_BAD_TARGETS;
@@ -5633,7 +5622,7 @@ SpellCastResult Spell::CheckCasterAuras() const
bool Spell::CanAutoCast(Unit* target)
{
- uint64 targetguid = target->GetGUID();
+ ObjectGuid targetguid = target->GetGUID();
for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
@@ -6486,7 +6475,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* lo
{
// Get GO cast coordinates if original caster -> GO
WorldObject* caster = NULL;
- if (IS_GAMEOBJECT_GUID(m_originalCasterGUID))
+ if (m_originalCasterGUID.IsGameObject())
caster = m_caster->GetMap()->GetGameObject(m_originalCasterGUID);
if (!caster)
caster = m_caster;
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index e1e16100141..372e7d239a2 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -91,7 +91,7 @@ struct SpellDestination
void RelocateOffset(Position const& offset);
WorldLocation _position;
- uint64 _transportGUID;
+ ObjectGuid _transportGUID;
Position _transportOffset;
};
@@ -109,22 +109,22 @@ class SpellCastTargets
void SetTargetFlag(SpellCastTargetFlags flag) { m_targetMask |= flag; }
- uint64 GetUnitTargetGUID() const;
+ ObjectGuid GetUnitTargetGUID() const;
Unit* GetUnitTarget() const;
void SetUnitTarget(Unit* target);
- uint64 GetGOTargetGUID() const;
+ ObjectGuid GetGOTargetGUID() const;
GameObject* GetGOTarget() const;
void SetGOTarget(GameObject* target);
- uint64 GetCorpseTargetGUID() const;
+ ObjectGuid GetCorpseTargetGUID() const;
Corpse* GetCorpseTarget() const;
WorldObject* GetObjectTarget() const;
- uint64 GetObjectTargetGUID() const;
+ ObjectGuid GetObjectTargetGUID() const;
void RemoveObjectTarget();
- uint64 GetItemTargetGUID() const { return m_itemTargetGUID; }
+ ObjectGuid GetItemTargetGUID() const { return m_itemTargetGUID; }
Item* GetItemTarget() const { return m_itemTarget; }
uint32 GetItemTargetEntry() const { return m_itemTargetEntry; }
void SetItemTarget(Item* item);
@@ -174,8 +174,8 @@ class SpellCastTargets
Item* m_itemTarget;
// object GUID/etc, can be used always
- uint64 m_objectTargetGUID;
- uint64 m_itemTargetGUID;
+ ObjectGuid m_objectTargetGUID;
+ ObjectGuid m_itemTargetGUID;
uint32 m_itemTargetEntry;
SpellDestination m_src;
@@ -212,6 +212,8 @@ enum SpellEffectHandleMode
SPELL_EFFECT_HANDLE_HIT_TARGET
};
+typedef std::list<std::pair<uint32, ObjectGuid>> DispelList;
+
class Spell
{
friend void Unit::SetCurrentCastSpell(Spell* pSpell);
@@ -346,7 +348,7 @@ class Spell
typedef std::set<Aura*> UsedSpellMods;
- Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, uint64 originalCasterGUID = 0, bool skipCheck = false);
+ Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID = ObjectGuid::Empty, bool skipCheck = false);
~Spell();
void InitExplicitTargets(SpellCastTargets const& targets);
@@ -450,7 +452,7 @@ class Spell
SpellInfo const* const m_spellInfo;
Item* m_CastItem;
- uint64 m_castItemGUID;
+ ObjectGuid m_castItemGUID;
uint32 m_castItemEntry;
uint8 m_cast_count;
uint32 m_glyphIndex;
@@ -497,13 +499,13 @@ class Spell
void TriggerGlobalCooldown();
void CancelGlobalCooldown();
- void SendLoot(uint64 guid, LootType loottype);
+ void SendLoot(ObjectGuid guid, LootType loottype);
Unit* const m_caster;
SpellValue* const m_spellValue;
- uint64 m_originalCasterGUID; // real source of cast (aura caster/etc), used for spell targets selection
+ ObjectGuid m_originalCasterGUID; // real source of cast (aura caster/etc), used for spell targets selection
// e.g. damage around area spell trigered by victim aura and damage enemies of aura caster
Unit* m_originalCaster; // cached pointer for m_originalCaster, updated at Spell::UpdatePointers()
@@ -576,7 +578,7 @@ class Spell
// Targets store structures and data
struct TargetInfo
{
- uint64 targetGUID;
+ ObjectGuid targetGUID;
uint64 timeDelay;
SpellMissInfo missCondition:8;
SpellMissInfo reflectResult:8;
@@ -592,7 +594,7 @@ class Spell
struct GOTargetInfo
{
- uint64 targetGUID;
+ ObjectGuid targetGUID;
uint64 timeDelay;
uint8 effectMask:8;
bool processed:1;
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index d3da5ceb015..81dc412bb86 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -1628,7 +1628,7 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype)
// set the "Crafted by ..." property of the item
if (pItem->GetTemplate()->Class != ITEM_CLASS_CONSUMABLE && pItem->GetTemplate()->Class != ITEM_CLASS_QUEST && newitemid != 6265 && newitemid != 6948)
- pItem->SetUInt32Value(ITEM_FIELD_CREATOR, player->GetGUIDLow());
+ pItem->SetGuidValue(ITEM_FIELD_CREATOR, player->GetGUID());
// send info to the client
player->SendNewItem(pItem, num_to_add, true, bgType == 0);
@@ -1881,7 +1881,7 @@ void Spell::EffectEnergizePct(SpellEffIndex effIndex)
m_caster->EnergizeBySpell(unitTarget, m_spellInfo->Id, gain, power);
}
-void Spell::SendLoot(uint64 guid, LootType loottype)
+void Spell::SendLoot(ObjectGuid guid, LootType loottype)
{
Player* player = m_caster->ToPlayer();
if (!player)
@@ -1963,7 +1963,7 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex)
Player* player = m_caster->ToPlayer();
uint32 lockId = 0;
- uint64 guid = 0;
+ ObjectGuid guid;
// Get lockId
if (gameObjTarget)
@@ -2106,7 +2106,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
m_targets.SetItemTarget(NULL);
m_CastItem = NULL;
- m_castItemGUID = 0;
+ m_castItemGUID.Clear();
m_castItemEntry = 0;
player->StoreItem(dest, pNewItem, true);
@@ -2126,7 +2126,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
m_targets.SetItemTarget(NULL);
m_CastItem = NULL;
- m_castItemGUID = 0;
+ m_castItemGUID.Clear();
m_castItemEntry = 0;
player->BankItem(dest, pNewItem, true);
@@ -2150,7 +2150,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
m_targets.SetItemTarget(NULL);
m_CastItem = NULL;
- m_castItemGUID = 0;
+ m_castItemGUID.Clear();
m_castItemEntry = 0;
player->EquipItem(dest, pNewItem, true);
@@ -2388,7 +2388,6 @@ void Spell::EffectLearnSpell(SpellEffIndex effIndex)
TC_LOG_DEBUG("spells", "Spell: Player %u has learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow());
}
-typedef std::list< std::pair<uint32, uint64> > DispelList;
void Spell::EffectDispel(SpellEffIndex effIndex)
{
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
@@ -2578,7 +2577,7 @@ void Spell::EffectUntrainTalents(SpellEffIndex /*effIndex*/)
if (!unitTarget || m_caster->GetTypeId() == TYPEID_PLAYER)
return;
- if (uint64 guid = m_caster->GetGUID()) // the trainer is the caster
+ if (ObjectGuid guid = m_caster->GetGUID()) // the trainer is the caster
unitTarget->ToPlayer()->SendTalentWipeConfirm(guid);
}
@@ -4208,8 +4207,8 @@ void Spell::EffectDuel(SpellEffIndex effIndex)
duel2->isMounted = (GetSpellInfo()->Id == 62875); // Mounted Duel
target->duel = duel2;
- caster->SetUInt64Value(PLAYER_DUEL_ARBITER, pGameObj->GetGUID());
- target->SetUInt64Value(PLAYER_DUEL_ARBITER, pGameObj->GetGUID());
+ caster->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetGUID());
+ target->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetGUID());
sScriptMgr->OnPlayerDuelRequest(target, caster);
}
@@ -4485,7 +4484,7 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex)
uint32 go_id = m_spellInfo->Effects[effIndex].MiscValue;
uint8 slot = m_spellInfo->Effects[effIndex].Effect - SPELL_EFFECT_SUMMON_OBJECT_SLOT1;
- if (uint64 guid = m_caster->m_ObjectSlot[slot])
+ if (ObjectGuid guid = m_caster->m_ObjectSlot[slot])
{
if (GameObject* obj = m_caster->GetMap()->GetGameObject(guid))
{
@@ -4494,7 +4493,7 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex)
obj->SetSpellId(0);
m_caster->RemoveGameObject(obj, true);
}
- m_caster->m_ObjectSlot[slot] = 0;
+ m_caster->m_ObjectSlot[slot].Clear();
}
GameObject* go = new GameObject();
@@ -4915,9 +4914,7 @@ void Spell::EffectDispelMechanic(SpellEffIndex effIndex)
return;
uint32 mechanic = m_spellInfo->Effects[effIndex].MiscValue;
-
- std::queue < std::pair < uint32, uint64 > > dispel_list;
-
+ DispelList dispel_list;
Unit::AuraMap const& auras = unitTarget->GetOwnedAuras();
for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
@@ -4926,12 +4923,13 @@ void Spell::EffectDispelMechanic(SpellEffIndex effIndex)
continue;
if (roll_chance_i(aura->CalcDispelChance(unitTarget, !unitTarget->IsFriendlyTo(m_caster))))
if ((aura->GetSpellInfo()->GetAllEffectsMechanicMask() & (1 << mechanic)))
- dispel_list.push(std::make_pair(aura->GetId(), aura->GetCasterGUID()));
+ dispel_list.push_back(std::make_pair(aura->GetId(), aura->GetCasterGUID()));
}
- for (; dispel_list.size(); dispel_list.pop())
+ while (!dispel_list.empty())
{
unitTarget->RemoveAura(dispel_list.front().first, dispel_list.front().second, 0, AURA_REMOVE_BY_ENEMY_SPELL);
+ dispel_list.pop_front();
}
}
@@ -5150,7 +5148,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
{
case GAMEOBJECT_TYPE_FISHINGNODE:
{
- m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, pGameObj->GetGUID());
+ m_caster->SetChannelObjectGuid(pGameObj->GetGUID());
m_caster->AddGameObject(pGameObj); // will removed at spell cancel
// end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
@@ -5433,7 +5431,7 @@ void Spell::EffectKillCreditPersonal(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
- unitTarget->ToPlayer()->KilledMonsterCredit(m_spellInfo->Effects[effIndex].MiscValue, 0);
+ unitTarget->ToPlayer()->KilledMonsterCredit(m_spellInfo->Effects[effIndex].MiscValue);
}
void Spell::EffectKillCredit(SpellEffIndex effIndex)
diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp
index 7132e0583e8..8ab3a72b47e 100644
--- a/src/server/game/Spells/SpellScript.cpp
+++ b/src/server/game/Spells/SpellScript.cpp
@@ -972,7 +972,7 @@ uint32 AuraScript::GetId() const
return m_aura->GetId();
}
-uint64 AuraScript::GetCasterGUID() const
+ObjectGuid AuraScript::GetCasterGUID() const
{
return m_aura->GetCasterGUID();
}
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h
index 756644dbd1b..653ae9ab5e9 100644
--- a/src/server/game/Spells/SpellScript.h
+++ b/src/server/game/Spells/SpellScript.h
@@ -797,7 +797,7 @@ class AuraScript : public _SpellScript
uint32 GetId() const;
// returns guid of object which cast the aura (m_originalCaster of the Spell class)
- uint64 GetCasterGUID() const;
+ ObjectGuid GetCasterGUID() const;
// returns unit which cast the aura or NULL if not avalible (caster logged out for example)
Unit* GetCaster() const;
// returns object on which aura was cast, target for non-area auras, area aura source for area auras