Core/Entities: moved PetAura handling to Player where it belongs

This commit is contained in:
Aokromes committed 2017-05-02 02:10:32 +02:00
1 parent f3246f835c
commit acd63b4259
8 files changed
+33 -36

No files matched your search

+2 -2
View File
@@ -1865,7 +1865,7 @@ void Pet::CastPetAuras(bool current)
if (!IsPermanentPetFor(owner))
return;
for (PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end();)
for (auto itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end();)
{
PetAura const* pa = *itr;
++itr;
@@ -1897,7 +1897,7 @@ bool Pet::IsPetAura(Aura const* aura)
Player* owner = GetOwner();
// if the owner has that pet aura, return true
for (PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end(); ++itr)
for (auto itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end(); ++itr)
{
if ((*itr)->GetAura(GetEntry()) == aura->GetId())
return true;
+1
View File
@@ -36,6 +36,7 @@ typedef std::unordered_map<uint32, PetSpell> PetSpellMap;
typedef std::vector<uint32> AutoSpellList;
class Player;
class PetAura;
class TC_GAME_API Pet : public Guardian
{
@@ -20852,6 +20852,20 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
}
}
void Player::AddPetAura(PetAura const* petSpell)
{
m_petAuras.insert(petSpell);
if (Pet* pet = GetPet())
pet->CastPetAura(petSpell);
}
void Player::RemovePetAura(PetAura const* petSpell)
{
m_petAuras.erase(petSpell);
if (Pet* pet = GetPet())
pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry()));
}
void Player::StopCastingCharm()
{
Unit* charm = GetCharm();
+6
View File
@@ -52,6 +52,7 @@ class Group;
class Guild;
class OutdoorPvP;
class Pet;
class PetAura;
class PlayerMenu;
class PlayerSocial;
class SpellCastTargets;
@@ -1325,6 +1326,11 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
Pet* SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime);
void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
// pet auras
std::unordered_set<PetAura const*> m_petAuras;
void AddPetAura(PetAura const* petSpell);
void RemovePetAura(PetAura const* petSpell);
/// Handles said message in regular chat based on declared language and in config pre-defined Range.
void Say(std::string const& text, Language language, WorldObject const* = nullptr) override;
void Say(uint32 textId, WorldObject const* target = nullptr) override;
-20
View File
@@ -13723,26 +13723,6 @@ void Unit::SetContestedPvP(Player* attackedPlayer)
}
}
void Unit::AddPetAura(PetAura const* petSpell)
{
if (GetTypeId() != TYPEID_PLAYER)
return;
m_petAuras.insert(petSpell);
if (Pet* pet = ToPlayer()->GetPet())
pet->CastPetAura(petSpell);
}
void Unit::RemovePetAura(PetAura const* petSpell)
{
if (GetTypeId() != TYPEID_PLAYER)
return;
m_petAuras.erase(petSpell);
if (Pet* pet = ToPlayer()->GetPet())
pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry()));
}
Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id)
{
if (GetTypeId() != TYPEID_PLAYER)
-7
View File
@@ -364,7 +364,6 @@ class DynamicObject;
class GameObject;
class Item;
class Pet;
class PetAura;
class Minion;
class Guardian;
class UnitAI;
@@ -2121,12 +2120,6 @@ class TC_GAME_API Unit : public WorldObject
bool CanProc() const {return !m_procDeep;}
void SetCantProc(bool apply);
// pet auras
typedef std::set<PetAura const*> PetAuraSet;
PetAuraSet m_petAuras;
void AddPetAura(PetAura const* petSpell);
void RemovePetAura(PetAura const* petSpell);
uint32 GetModelForForm(ShapeshiftForm form, uint32 spellId) const;
uint32 GetModelForTotem(PlayerTotemType totemType);
@@ -4274,15 +4274,15 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
Unit* caster = GetCaster();
if (mode & AURA_EFFECT_HANDLE_REAL)
// pet auras
if (target->GetTypeId() == TYPEID_PLAYER && (mode & AURA_EFFECT_HANDLE_REAL))
{
// pet auras
if (PetAura const* petSpell = sSpellMgr->GetPetAura(GetId(), m_effIndex))
{
if (apply)
target->AddPetAura(petSpell);
target->ToPlayer()->AddPetAura(petSpell);
else
target->RemovePetAura(petSpell);
target->ToPlayer()->RemovePetAura(petSpell);
}
}
+6 -3
View File
@@ -584,10 +584,13 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
}
// pet auras
if (PetAura const* petSpell = sSpellMgr->GetPetAura(m_spellInfo->Id, effIndex))
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
m_caster->AddPetAura(petSpell);
return;
if (PetAura const* petSpell = sSpellMgr->GetPetAura(m_spellInfo->Id, effIndex))
{
m_caster->ToPlayer()->AddPetAura(petSpell);
return;
}
}
// normal DB scripted effect