From c10a9e6cccd0ff2a43003916a859171387c7e591 Mon Sep 17 00:00:00 2001 From: megamage Date: Sun, 2 Nov 2008 08:44:15 -0600 Subject: [svn] Fix a bug that GameObject::CastSpell crash the server. --HG-- branch : trunk --- src/game/GameObject.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 57d206fa1aa..fbeb30144bb 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -1271,9 +1271,15 @@ void GameObject::CastSpell(Unit* target, uint32 spell) Creature *trigger = SummonCreature(12999, GetPositionX(), GetPositionY(), GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 1); if(!trigger) return; - Unit *owner = GetOwner(); - if(owner) trigger->setFaction(owner->getFaction()); - else trigger->setFaction(14); trigger->SetVisibility(VISIBILITY_OFF); //should this be true? - trigger->CastSpell(target, spell, true, 0, 0, owner->GetGUID()); + if(Unit *owner = GetOwner()) + { + trigger->setFaction(owner->getFaction()); + trigger->CastSpell(target, spell, true, 0, 0, owner->GetGUID()); + } + else + { + trigger->setFaction(14); + trigger->CastSpell(target, spell, true); + } } \ No newline at end of file -- cgit v1.2.3