[11462] Missing ObjectGuids in spell code.

This commit is contained in:
VladimirMangos 2011-05-10 13:03:17 +04:00
parent 4989ffba9d
commit 31c34a940d
7 changed files with 53 additions and 57 deletions

View file

@ -871,10 +871,9 @@ void Spell::AddUnitTarget(Unit* pVictim, SpellEffectIndex effIndex)
m_UniqueTargetInfo.push_back(target); 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* unit = m_caster->GetObjectGuid() == unitGuid ? m_caster : ObjectAccessor::GetUnit(*m_caster, unitGuid))
if (unit)
AddUnitTarget(unit, effIndex); AddUnitTarget(unit, effIndex);
} }
@ -923,10 +922,9 @@ void Spell::AddGOTarget(GameObject* pVictim, SpellEffectIndex effIndex)
m_UniqueGOTargetInfo.push_back(target); 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 (GameObject* go = m_caster->GetMap()->GetGameObject(goGuid))
if (go)
AddGOTarget(go, effIndex); AddGOTarget(go, effIndex);
} }
@ -2226,9 +2224,9 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
break; break;
} }
case TARGET_GAMEOBJECT_ITEM: case TARGET_GAMEOBJECT_ITEM:
if(m_targets.getGOTargetGUID()) if (!m_targets.getGOTargetGuid().IsEmpty())
AddGOTarget(m_targets.getGOTarget(), effIndex); AddGOTarget(m_targets.getGOTarget(), effIndex);
else if(m_targets.getItemTarget()) else if (m_targets.getItemTarget())
AddItemTarget(m_targets.getItemTarget(), effIndex); AddItemTarget(m_targets.getItemTarget(), effIndex);
break; break;
case TARGET_MASTER: case TARGET_MASTER:
@ -2649,15 +2647,11 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
case SPELL_EFFECT_RESURRECT_NEW: case SPELL_EFFECT_RESURRECT_NEW:
if (m_targets.getUnitTarget()) if (m_targets.getUnitTarget())
targetUnitMap.push_back(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 *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGuid()))
if(corpse) if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid()))
{
Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid());
if(owner)
targetUnitMap.push_back(owner); targetUnitMap.push_back(owner);
}
} }
break; break;
case SPELL_EFFECT_SUMMON: case SPELL_EFFECT_SUMMON:
@ -2711,9 +2705,9 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
case SPELL_EFFECT_SKIN_PLAYER_CORPSE: case SPELL_EFFECT_SKIN_PLAYER_CORPSE:
if (m_targets.getUnitTarget()) if (m_targets.getUnitTarget())
targetUnitMap.push_back(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())) if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid()))
targetUnitMap.push_back(owner); targetUnitMap.push_back(owner);
} }
@ -2918,7 +2912,7 @@ void Spell::cast(bool skipCheck)
UpdatePointers(); UpdatePointers();
// cancel at lost main target unit // 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(); cancel();
m_caster->DecreaseCastCounter(); m_caster->DecreaseCastCounter();
@ -2926,11 +2920,11 @@ void Spell::cast(bool skipCheck)
return; 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()); m_caster->SetInFront(m_targets.getUnitTarget());
SpellCastResult castResult = CheckPower(); SpellCastResult castResult = CheckPower();
if(castResult != SPELL_CAST_OK) if (castResult != SPELL_CAST_OK)
{ {
SendCastResult(castResult); SendCastResult(castResult);
finish(false); finish(false);
@ -2940,7 +2934,7 @@ void Spell::cast(bool skipCheck)
} }
// triggered cast called from Spell::prepare where it was already checked // triggered cast called from Spell::prepare where it was already checked
if(!skipCheck) if (!skipCheck)
{ {
castResult = CheckCast(false); castResult = CheckCast(false);
if(castResult != SPELL_CAST_OK) if(castResult != SPELL_CAST_OK)
@ -3311,7 +3305,7 @@ void Spell::update(uint32 difftime)
// update pointers based at it's GUIDs // update pointers based at it's GUIDs
UpdatePointers(); UpdatePointers();
if(m_targets.getUnitTargetGUID() && !m_targets.getUnitTarget()) if (!m_targets.getUnitTargetGuid().IsEmpty() && !m_targets.getUnitTarget())
{ {
cancel(); cancel();
return; return;
@ -3916,11 +3910,11 @@ void Spell::SendLogExecute()
case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: case SPELL_EFFECT_SUMMON_OBJECT_SLOT2:
case SPELL_EFFECT_SUMMON_OBJECT_SLOT3: case SPELL_EFFECT_SUMMON_OBJECT_SLOT3:
case SPELL_EFFECT_SUMMON_OBJECT_SLOT4: case SPELL_EFFECT_SUMMON_OBJECT_SLOT4:
if(Unit *unit = m_targets.getUnitTarget()) if (Unit *unit = m_targets.getUnitTarget())
data << unit->GetPackGUID(); data << unit->GetPackGUID();
else if(m_targets.getItemTargetGUID()) else if (!m_targets.getItemTargetGuid().IsEmpty())
data.appendPackGUID(m_targets.getItemTargetGUID()); data << m_targets.getItemTargetGuid().WriteAsPacked();
else if(GameObject *go = m_targets.getGOTarget()) else if (GameObject *go = m_targets.getGOTarget())
data << go->GetPackGUID(); data << go->GetPackGUID();
else else
data << uint8(0); // guid data << uint8(0); // guid
@ -5571,7 +5565,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (!my_trade) if (!my_trade)
return SPELL_FAILED_NOT_TRADING; return SPELL_FAILED_NOT_TRADING;
TradeSlots slot = TradeSlots(m_targets.getItemTargetGUID()); TradeSlots slot = TradeSlots(m_targets.getItemTargetGuid().GetRawValue());
if (slot != TRADE_SLOT_NONTRADED) if (slot != TRADE_SLOT_NONTRADED)
return SPELL_FAILED_ITEM_NOT_READY; return SPELL_FAILED_ITEM_NOT_READY;
@ -6128,18 +6122,18 @@ SpellCastResult Spell::CheckItems()
} }
// check target item (for triggered case not report error) // 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) return m_IsTriggeredSpell && !(m_targets.m_targetMask & TARGET_FLAG_TRADE_ITEM)
? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_BAD_TARGETS; ? 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) return m_IsTriggeredSpell && !(m_targets.m_targetMask & TARGET_FLAG_TRADE_ITEM)
? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_ITEM_GONE; ? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_ITEM_GONE;
isVellumTarget = m_targets.getItemTarget()->GetProto()->IsVellum(); 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) return m_IsTriggeredSpell && !(m_targets.m_targetMask & TARGET_FLAG_TRADE_ITEM)
? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_EQUIPPED_ITEM_CLASS; ? 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? // player far away, maybe his corpse near?
if(target != m_caster && !target->IsWithinLOSInMap(m_caster)) if(target != m_caster && !target->IsWithinLOSInMap(m_caster))
{ {
if(!m_targets.getCorpseTargetGUID()) if (!m_targets.getCorpseTargetGuid().IsEmpty())
return false; return false;
Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID()); Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGuid());
if(!corpse) if(!corpse)
return false; return false;

View file

@ -135,19 +135,20 @@ class SpellCastTargets
return *this; return *this;
} }
uint64 getUnitTargetGUID() const { return m_unitTargetGUID.GetRawValue(); } ObjectGuid getUnitTargetGuid() const { return m_unitTargetGUID; }
Unit *getUnitTarget() const { return m_unitTarget; } Unit *getUnitTarget() const { return m_unitTarget; }
void setUnitTarget(Unit *target); void setUnitTarget(Unit *target);
void setDestination(float x, float y, float z); void setDestination(float x, float y, float z);
void setSource(float x, float y, float z); void setSource(float x, float y, float z);
uint64 getGOTargetGUID() const { return m_GOTargetGUID.GetRawValue(); } ObjectGuid getGOTargetGuid() const { return m_GOTargetGUID; }
GameObject *getGOTarget() const { return m_GOTarget; } GameObject *getGOTarget() const { return m_GOTarget; }
void setGOTarget(GameObject *target); void setGOTarget(GameObject *target);
uint64 getCorpseTargetGUID() const { return m_CorpseTargetGUID.GetRawValue(); } ObjectGuid getCorpseTargetGuid() const { return m_CorpseTargetGUID; }
void setCorpseTarget(Corpse* corpse); void setCorpseTarget(Corpse* corpse);
uint64 getItemTargetGUID() const { return m_itemTargetGUID.GetRawValue(); }
ObjectGuid getItemTargetGuid() const { return m_itemTargetGUID; }
Item* getItemTarget() const { return m_itemTarget; } Item* getItemTarget() const { return m_itemTarget; }
uint32 getItemTargetEntry() const { return m_itemTargetEntry; } uint32 getItemTargetEntry() const { return m_itemTargetEntry; }
void setItemTarget(Item* item); void setItemTarget(Item* item);
@ -156,7 +157,7 @@ class SpellCastTargets
{ {
if(m_itemTarget && (m_targetMask & TARGET_FLAG_TRADE_ITEM)) if(m_itemTarget && (m_targetMask & TARGET_FLAG_TRADE_ITEM))
{ {
m_itemTargetGUID = m_itemTarget->GetGUID(); m_itemTargetGUID = m_itemTarget->GetObjectGuid();
m_itemTargetEntry = m_itemTarget->GetEntry(); m_itemTargetEntry = m_itemTarget->GetEntry();
} }
} }
@ -496,7 +497,7 @@ class Spell
void TriggerGlobalCooldown(); void TriggerGlobalCooldown();
void CancelGlobalCooldown(); void CancelGlobalCooldown();
void SendLoot(uint64 guid, LootType loottype); void SendLoot(ObjectGuid guid, LootType loottype);
bool IgnoreItemRequirements() const; // some item use spells have unexpected reagent data bool IgnoreItemRequirements() const; // some item use spells have unexpected reagent data
void UpdateOriginalCasterPointer(); void UpdateOriginalCasterPointer();
@ -608,9 +609,9 @@ class Spell
ItemTargetList m_UniqueItemInfo; ItemTargetList m_UniqueItemInfo;
void AddUnitTarget(Unit* target, SpellEffectIndex effIndex); void AddUnitTarget(Unit* target, SpellEffectIndex effIndex);
void AddUnitTarget(uint64 unitGUID, SpellEffectIndex effIndex); void AddUnitTarget(ObjectGuid unitGuid, SpellEffectIndex effIndex);
void AddGOTarget(GameObject* target, SpellEffectIndex effIndex); void AddGOTarget(GameObject* target, SpellEffectIndex effIndex);
void AddGOTarget(uint64 goGUID, SpellEffectIndex effIndex); void AddGOTarget(ObjectGuid goGuid, SpellEffectIndex effIndex);
void AddItemTarget(Item* target, SpellEffectIndex effIndex); void AddItemTarget(Item* target, SpellEffectIndex effIndex);
void DoAllEffectOnTarget(TargetInfo *target); void DoAllEffectOnTarget(TargetInfo *target);
void HandleDelayedSpellLaunch(TargetInfo *target); void HandleDelayedSpellLaunch(TargetInfo *target);

View file

@ -4302,7 +4302,7 @@ void Spell::EffectEnergisePct(SpellEffectIndex eff_idx)
m_caster->EnergizeBySpell(unitTarget, m_spellInfo->Id, gain, power); m_caster->EnergizeBySpell(unitTarget, m_spellInfo->Id, gain, power);
} }
void Spell::SendLoot(uint64 guid, LootType loottype) void Spell::SendLoot(ObjectGuid guid, LootType loottype)
{ {
if (gameObjTarget) if (gameObjTarget)
{ {
@ -4345,7 +4345,7 @@ void Spell::EffectOpenLock(SpellEffectIndex eff_idx)
Player* player = (Player*)m_caster; Player* player = (Player*)m_caster;
uint32 lockId = 0; uint32 lockId = 0;
uint64 guid = 0; ObjectGuid guid;
// Get lockId // Get lockId
if (gameObjTarget) if (gameObjTarget)
@ -4377,12 +4377,12 @@ void Spell::EffectOpenLock(SpellEffectIndex eff_idx)
} }
} }
lockId = goInfo->GetLockId(); lockId = goInfo->GetLockId();
guid = gameObjTarget->GetGUID(); guid = gameObjTarget->GetObjectGuid();
} }
else if (itemTarget) else if (itemTarget)
{ {
lockId = itemTarget->GetProto()->LockID; lockId = itemTarget->GetProto()->LockID;
guid = itemTarget->GetGUID(); guid = itemTarget->GetObjectGuid();
} }
else else
{ {
@ -8059,7 +8059,7 @@ void Spell::EffectSummonObject(SpellEffectIndex eff_idx)
uint32 go_id = m_spellInfo->EffectMiscValue[eff_idx]; uint32 go_id = m_spellInfo->EffectMiscValue[eff_idx];
uint8 slot = 0; uint8 slot = 0;
switch(m_spellInfo->Effect[eff_idx]) switch (m_spellInfo->Effect[eff_idx])
{ {
case SPELL_EFFECT_SUMMON_OBJECT_SLOT1: slot = 0; break; case SPELL_EFFECT_SUMMON_OBJECT_SLOT1: slot = 0; break;
case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: slot = 1; break; case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: slot = 1; break;
@ -8068,11 +8068,13 @@ void Spell::EffectSummonObject(SpellEffectIndex eff_idx)
default: return; default: return;
} }
if(uint64 guid = m_caster->m_ObjectSlot[slot]) ObjectGuid guid = m_caster->m_ObjectSlotGuid[slot];
if (!guid.IsEmpty())
{ {
if(GameObject* obj = m_caster ? m_caster->GetMap()->GetGameObject(guid) : NULL) if (GameObject* obj = m_caster ? m_caster->GetMap()->GetGameObject(guid) : NULL)
obj->SetLootState(GO_JUST_DEACTIVATED); obj->SetLootState(GO_JUST_DEACTIVATED);
m_caster->m_ObjectSlot[slot] = 0; m_caster->m_ObjectSlotGuid[slot].Clear();
} }
GameObject* pGameObj = new GameObject; GameObject* pGameObj = new GameObject;
@ -8105,7 +8107,7 @@ void Spell::EffectSummonObject(SpellEffectIndex eff_idx)
map->Add(pGameObj); map->Add(pGameObj);
m_caster->m_ObjectSlot[slot] = pGameObj->GetGUID(); m_caster->m_ObjectSlotGuid[slot] = pGameObj->GetObjectGuid();
pGameObj->SummonLinkedTrapIfAny(); pGameObj->SummonLinkedTrapIfAny();

View file

@ -34,11 +34,11 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
uint8 bagIndex, slot; uint8 bagIndex, slot;
uint8 unk_flags; // flags (if 0x02 - some additional data are received) uint8 unk_flags; // flags (if 0x02 - some additional data are received)
uint8 cast_count; // next cast if exists (single or not) uint8 cast_count; // next cast if exists (single or not)
uint64 item_guid; ObjectGuid itemGuid;
uint32 glyphIndex; // something to do with glyphs? uint32 glyphIndex; // something to do with glyphs?
uint32 spellid; // casted spell id uint32 spellid; // casted spell id
recvPacket >> bagIndex >> slot >> cast_count >> spellid >> item_guid >> glyphIndex >> unk_flags; recvPacket >> bagIndex >> slot >> cast_count >> spellid >> itemGuid >> glyphIndex >> unk_flags;
// TODO: add targets.read() check // TODO: add targets.read() check
Player* pUser = _player; Player* pUser = _player;
@ -66,7 +66,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
return; return;
} }
if (pItem->GetGUID() != item_guid) if (pItem->GetObjectGuid() != itemGuid)
{ {
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
@ -250,7 +250,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
uint32 entry = fields[0].GetUInt32(); uint32 entry = fields[0].GetUInt32();
uint32 flags = fields[1].GetUInt32(); uint32 flags = fields[1].GetUInt32();
pItem->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0); pItem->SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid());
pItem->SetEntry(entry); pItem->SetEntry(entry);
pItem->SetUInt32Value(ITEM_FIELD_FLAGS, flags); pItem->SetUInt32Value(ITEM_FIELD_FLAGS, flags);
pItem->SetState(ITEM_CHANGED, pUser); pItem->SetState(ITEM_CHANGED, pUser);

View file

@ -210,7 +210,6 @@ Unit::Unit() :
m_addDmgOnce = 0; m_addDmgOnce = 0;
m_ObjectSlot[0] = m_ObjectSlot[1] = m_ObjectSlot[2] = m_ObjectSlot[3] = 0;
//m_Aura = NULL; //m_Aura = NULL;
//m_AurasCheck = 2000; //m_AurasCheck = 2000;
//m_removeAuraTimer = 4; //m_removeAuraTimer = 4;

View file

@ -1646,7 +1646,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void DecreaseCastCounter() { if (m_castCounter) --m_castCounter; } void DecreaseCastCounter() { if (m_castCounter) --m_castCounter; }
uint32 m_addDmgOnce; uint32 m_addDmgOnce;
uint64 m_ObjectSlot[4]; ObjectGuid m_ObjectSlotGuid[4];
uint32 m_detectInvisibilityMask; uint32 m_detectInvisibilityMask;
uint32 m_invisibilityMask; uint32 m_invisibilityMask;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11461" #define REVISION_NR "11462"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__