aboutsummaryrefslogtreecommitdiff
path: root/src/game/TemporarySummon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/TemporarySummon.cpp')
-rw-r--r--src/game/TemporarySummon.cpp28
1 files changed, 26 insertions, 2 deletions
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)
{