From 68fd41d2c8990459ca1d82ab82d53cb78d03dd49 Mon Sep 17 00:00:00 2001 From: megamage Date: Sun, 19 Apr 2009 19:45:54 -0500 Subject: *Fix a bug that pet/charmed cannot AOE neutral creatures. --HG-- branch : trunk --- src/game/TemporarySummon.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/game/TemporarySummon.cpp') diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index c87ad91ff90..10b4eedb1c8 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -244,8 +244,8 @@ void TempSummon::RemoveFromWorld() } } - if(GetOwnerGUID()) - sLog.outError("Unit %u has owner guid when removed from world", GetEntry()); + //if(GetOwnerGUID()) + // sLog.outError("Unit %u has owner guid when removed from world", GetEntry()); Creature::RemoveFromWorld(); } @@ -254,6 +254,30 @@ void TempSummon::SaveToDB() { } +bool TempSummon::SetOwner(Unit *owner, bool apply) +{ + if(apply) + { + if(!AddUInt64Value(UNIT_FIELD_SUMMONEDBY, owner->GetGUID())) + { + sLog.outCrash("Unit %u is summoned by %u but it already has a owner", GetEntry(), owner->GetEntry()); + return false; + } + if(owner->GetTypeId() == TYPEID_PLAYER) + m_ControlledByPlayer = true; + } + else + { + if(!RemoveUInt64Value(UNIT_FIELD_SUMMONEDBY, owner->GetGUID())) + { + sLog.outCrash("Unit %u is unsummoned by %u but it has another owner", GetEntry(), owner->GetEntry()); + return false; + } + } + + return true; +} + Guardian::Guardian(SummonPropertiesEntry const *properties, Unit *owner) : TempSummon(properties, owner) , m_owner(owner), m_bonusdamage(0) { -- cgit v1.2.3