diff options
author | Gacko <gacko28@gmx.de> | 2014-05-06 18:46:08 +0200 |
---|---|---|
committer | Gacko <gacko28@gmx.de> | 2014-05-06 18:46:08 +0200 |
commit | 41d9364b164aca67d66134a565890d2f8d49fbd0 (patch) | |
tree | 51fecb265312b43b07e1d2016bbca35bc8f3a501 /src | |
parent | b48879ab7947b3910fb18d842cf05fcba8b5a5a2 (diff) |
Core/GameObject: Fix crash added in c6bf7e0b1d615a22c2145c6f4a757a10a9eca92c
Thanks @jackpoz
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 11 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 4f3f4c73f3b..ea27d7add1f 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -47,7 +47,7 @@ GameObject::GameObject() : WorldObject(false), MapObject(), m_respawnTime = 0; m_respawnDelayTime = 300; m_lootState = GO_NOT_READY; - m_lootStateUnit = NULL; + m_lootStateUnitGUID = 0; m_spawnedByDefault = true; m_usetimes = 0; m_spellId = 0; @@ -561,11 +561,12 @@ void GameObject::Update(uint32 diff) CastSpell(NULL, goInfo->trap.spellId); SetLootState(GO_JUST_DEACTIVATED); } - else if (m_lootStateUnit) + else if (m_lootStateUnitGUID) + if (Unit* target = Unit::GetUnit(*this, m_lootStateUnitGUID)) { // Some traps do not have a spell but should be triggered if (goInfo->trap.spellId) - CastSpell(m_lootStateUnit, goInfo->trap.spellId); + CastSpell(target, goInfo->trap.spellId); // Template value or 4 seconds m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4)); @@ -575,7 +576,7 @@ void GameObject::Update(uint32 diff) // Battleground gameobjects have data2 == 0 && data5 == 3 if (!goInfo->trap.diameter && goInfo->trap.cooldown == 3) - if (Player* player = m_lootStateUnit->ToPlayer()) + if (Player* player = target->ToPlayer()) if (Battleground* bg = player->GetBattleground()) bg->HandleTriggerBuff(GetGUID()); } @@ -2008,7 +2009,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* void GameObject::SetLootState(LootState state, Unit* unit) { m_lootState = state; - m_lootStateUnit = unit; + m_lootStateUnitGUID = unit ? unit->GetGUID() : 0; AI()->OnStateChanged(state, unit); sScriptMgr->OnGameObjectLootStateChanged(this, state, unit); if (m_model) diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 7b73f9a2318..a99c5db93aa 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -841,7 +841,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()), uint32 m_respawnDelayTime; // (secs) if 0 then current GO state no dependent from timer LootState m_lootState; - Unit* m_lootStateUnit; + uint64 m_lootStateUnitGUID; // GUID of the unit passed with SetLootState(LootState, Unit*) bool m_spawnedByDefault; time_t m_cooldownTime; // used as internal reaction delay time store (not state change reaction). // For traps this: spell casting cooldown, for doors/buttons: reset time. |