aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclick <none@none>2010-04-14 15:43:45 +0200
committerclick <none@none>2010-04-14 15:43:45 +0200
commitc8bf52d19105dc367e7ad26d5e35d9404ac7cf20 (patch)
treed4d1bb9a49be07fc7f718a9e0170a7856b5d5d5c
parenta6af93c3d6df91e6f9f5d374a55ef1d7b8d7a5f4 (diff)
Retain pet buffs/debuffs/spells when pet is resummoned after lagout/flightpath unsummon
Research and patch by Liberate (minor assist by click) Fixes issue #689 Fixes issue #794 Fixes issue #1454 --HG-- branch : trunk
-rw-r--r--src/game/Pet.cpp25
-rw-r--r--src/game/Pet.h1
2 files changed, 24 insertions, 2 deletions
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
index 3b842034423..3e18f1f5480 100644
--- a/src/game/Pet.cpp
+++ b/src/game/Pet.cpp
@@ -378,6 +378,9 @@ void Pet::SavePetToDB(PetSaveMode mode)
uint32 curhealth = GetHealth();
uint32 curmana = GetPower(POWER_MANA);
+ // save auras before possibly removing them
+ _SaveAuras();
+
// stable and not in slot saves
if (mode > PET_SAVE_AS_CURRENT)
{
@@ -386,7 +389,6 @@ void Pet::SavePetToDB(PetSaveMode mode)
_SaveSpells();
_SaveSpellCooldowns();
- _SaveAuras();
// current/stable/not_in_slot
if (mode >= PET_SAVE_AS_CURRENT)
@@ -1261,7 +1263,8 @@ void Pet::_SaveAuras()
for (AuraMap::const_iterator itr = m_ownedAuras.begin(); itr != m_ownedAuras.end() ; ++itr)
{
- if (!itr->second->CanBeSaved())
+ // check if the aura has to be saved
+ if (!itr->second->CanBeSaved() || IsPetAura(itr->second))
continue;
Aura * aura = itr->second;
@@ -1935,6 +1938,24 @@ void Pet::CastPetAura(PetAura const* aura)
CastSpell(this, auraId, true);
}
+bool Pet::IsPetAura(Aura const* aura)
+{
+ Unit* owner = GetOwner();
+
+ if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
+ return false;
+
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ {
+ PetAura const* pa = spellmgr.GetPetAura(aura->GetId(),i);
+
+ // if the owner has that pet aura, return true
+ if (owner->m_petAuras.find(pa) != m_petAuras.end())
+ return true;
+ }
+ return false;
+}
+
void Pet::learnSpellHighRank(uint32 spellid)
{
learnSpell(spellid);
diff --git a/src/game/Pet.h b/src/game/Pet.h
index 0c0127c6f9a..16e80170cd4 100644
--- a/src/game/Pet.h
+++ b/src/game/Pet.h
@@ -186,6 +186,7 @@ class Pet : public Guardian
void LearnPetPassives();
void CastPetAuras(bool current);
void CastPetAura(PetAura const* aura);
+ bool IsPetAura(Aura const* aura);
void _LoadSpellCooldowns();
void _SaveSpellCooldowns();