diff options
-rw-r--r-- | src/game/TemporarySummon.cpp | 35 | ||||
-rw-r--r-- | src/game/TemporarySummon.h | 4 | ||||
-rw-r--r-- | src/game/Totem.cpp | 41 | ||||
-rw-r--r-- | src/game/Unit.cpp | 11 |
4 files changed, 33 insertions, 58 deletions
diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index b5ef539ab0c..ff67f19aca3 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -257,37 +257,18 @@ 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; - SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); - } - } - 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; -} - Minion::Minion(SummonPropertiesEntry const *properties, Unit *owner) : TempSummon(properties, owner) , m_owner(owner) { + assert(m_owner); m_summonMask |= SUMMON_MASK_MINION; + SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_owner->GetGUID()); + + if(m_owner->GetTypeId() == TYPEID_PLAYER) + { + m_ControlledByPlayer = true; + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); + } } void Minion::InitSummon(uint32 duration) diff --git a/src/game/TemporarySummon.h b/src/game/TemporarySummon.h index 8db384d2eba..1a3dfef1c7d 100644 --- a/src/game/TemporarySummon.h +++ b/src/game/TemporarySummon.h @@ -38,8 +38,6 @@ class TempSummon : public Creature uint64 const& GetSummonerGUID() { return m_summonerGUID; } SummonPropertiesEntry const *m_Properties; - - bool SetOwner(Unit *owner, bool apply); private: TempSummonType m_type; uint32 m_timer; @@ -55,7 +53,7 @@ class Minion : public TempSummon void RemoveFromWorld(); Unit *GetOwner() { return m_owner; } protected: - Unit *m_owner; + Unit * const m_owner; }; class Guardian : public Minion diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp index 5f1a044d4df..af36c43a999 100644 --- a/src/game/Totem.cpp +++ b/src/game/Totem.cpp @@ -110,35 +110,32 @@ void Totem::UnSummon() CombatStop(); RemoveAurasDueToSpell(GetSpell()); - Unit *owner = GetOwner(); - if (owner) + + // clear owenr's totem slot + for(int i = SUMMON_SLOT_TOTEM; i < MAX_TOTEM_SLOT; ++i) { - // clear owenr's totem slot - for(int i = SUMMON_SLOT_TOTEM; i < MAX_TOTEM_SLOT; ++i) + if(m_owner->m_SummonSlot[i]==GetGUID()) { - if(owner->m_SummonSlot[i]==GetGUID()) - { - owner->m_SummonSlot[i] = 0; - break; - } + m_owner->m_SummonSlot[i] = 0; + break; } + } - owner->RemoveAurasDueToSpell(GetSpell()); + m_owner->RemoveAurasDueToSpell(GetSpell()); - //remove aura all party members too - Group *pGroup = NULL; - if (owner->GetTypeId() == TYPEID_PLAYER) + //remove aura all party members too + Group *pGroup = NULL; + if (m_owner->GetTypeId() == TYPEID_PLAYER) + { + // Not only the player can summon the totem (scripted AI) + pGroup = ((Player*)m_owner)->GetGroup(); + if (pGroup) { - // Not only the player can summon the totem (scripted AI) - pGroup = ((Player*)owner)->GetGroup(); - if (pGroup) + for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player* Target = itr->getSource(); - if(Target && pGroup->SameSubGroup((Player*)owner, Target)) - Target->RemoveAurasDueToSpell(GetSpell()); - } + Player* Target = itr->getSource(); + if(Target && pGroup->SameSubGroup((Player*)m_owner, Target)) + Target->RemoveAurasDueToSpell(GetSpell()); } } } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index df61c321797..5ee9bc4c5c4 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8143,12 +8143,14 @@ 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->SetOwner(this, true)) - return; - m_Controlled.insert(minion); // Can only have one pet. If a new one is summoned, dismiss the old one. @@ -8204,9 +8206,6 @@ void Unit::SetMinion(Minion *minion, bool apply) } else { - if(!minion->SetOwner(this, false)) - return; - m_Controlled.erase(minion); if(minion->isPet() || minion->m_Properties && minion->m_Properties->Category == SUMMON_CATEGORY_PET) |