aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/TemporarySummon.cpp8
-rw-r--r--src/game/Unit.cpp23
2 files changed, 18 insertions, 13 deletions
diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp
index 8e661c36649..034bf492e1c 100644
--- a/src/game/TemporarySummon.cpp
+++ b/src/game/TemporarySummon.cpp
@@ -266,14 +266,6 @@ Minion::Minion(SummonPropertiesEntry const *properties, Unit *owner) : TempSummo
void Minion::InitSummon(uint32 duration)
{
- SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_owner->GetGUID());
-
- if(m_owner->GetTypeId() == TYPEID_PLAYER)
- {
- m_ControlledByPlayer = true;
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
- }
-
TempSummon::InitSummon(duration);
SetReactState(REACT_PASSIVE);
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 8bddd073ee9..0dcf535c4b5 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -8143,16 +8143,23 @@ Unit* Unit::GetCharm() const
void Unit::SetMinion(Minion *minion, bool apply)
{
sLog.outDebug("SetMinion %u for %u, apply %u", minion->GetEntry(), GetEntry(), apply);
- if(minion->GetOwnerGUID() != GetGUID())
- {
- sLog.outCrash("SetMinion: Minion %u is not the minion of owner %u", minion->GetEntry(), GetEntry());
- return;
- }
if(apply)
{
+ if(!minion->AddUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID()))
+ {
+ sLog.outCrash("SetMinion: Minion %u is not the minion of owner %u", minion->GetEntry(), GetEntry());
+ return;
+ }
+
m_Controlled.insert(minion);
+ if(GetTypeId() == TYPEID_PLAYER)
+ {
+ minion->m_ControlledByPlayer = true;
+ minion->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
+ }
+
// Can only have one pet. If a new one is summoned, dismiss the old one.
if(minion->isPet() || minion->m_Properties && minion->m_Properties->Category == SUMMON_CATEGORY_PET)
{
@@ -8206,6 +8213,12 @@ void Unit::SetMinion(Minion *minion, bool apply)
}
else
{
+ if(minion->GetOwnerGUID() != GetGUID())
+ {
+ sLog.outCrash("SetMinion: Minion %u is not the minion of owner %u", minion->GetEntry(), GetEntry());
+ return;
+ }
+
m_Controlled.erase(minion);
if(minion->isPet() || minion->m_Properties && minion->m_Properties->Category == SUMMON_CATEGORY_PET)