diff options
Diffstat (limited to 'src/game/Pet.cpp')
-rw-r--r-- | src/game/Pet.cpp | 25 |
1 files changed, 23 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); |