mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 13:46:24 +00:00
refactor(Core/Packet): Pet (#9473)
Co-authored-by: temperrr <temperrr@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
6b3b0632be
commit
b275499de4
@@ -25,6 +25,7 @@
|
||||
#include "InstanceScript.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "PetPackets.h"
|
||||
#include "Player.h"
|
||||
#include "QueryHolder.h"
|
||||
#include "ScriptMgr.h"
|
||||
@@ -1863,10 +1864,10 @@ bool Pet::learnSpell(uint32 spell_id)
|
||||
|
||||
if (!m_loading)
|
||||
{
|
||||
WorldPacket data(SMSG_PET_LEARNED_SPELL, 4);
|
||||
data << uint32(spell_id);
|
||||
GetOwner()->GetSession()->SendPacket(&data);
|
||||
GetOwner()->PetSpellInitialize();
|
||||
WorldPackets::Pet::PetLearnedSpell packet;
|
||||
packet.SpellID = spell_id;
|
||||
m_owner->SendDirectMessage(packet.Write());
|
||||
m_owner->PetSpellInitialize();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1917,9 +1918,9 @@ bool Pet::unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
|
||||
{
|
||||
if (!m_loading)
|
||||
{
|
||||
WorldPacket data(SMSG_PET_REMOVED_SPELL, 4);
|
||||
data << uint32(spell_id);
|
||||
GetOwner()->GetSession()->SendPacket(&data);
|
||||
WorldPackets::Pet::PetUnlearnedSpell packet;
|
||||
packet.SpellID = spell_id;
|
||||
m_owner->SendDirectMessage(packet.Write());
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -2179,25 +2180,22 @@ uint8 Pet::GetMaxTalentPointsForLevel(uint8 level)
|
||||
|
||||
void Pet::ToggleAutocast(SpellInfo const* spellInfo, bool apply)
|
||||
{
|
||||
ASSERT(spellInfo);
|
||||
|
||||
if (!spellInfo->IsAutocastable())
|
||||
return;
|
||||
|
||||
uint32 spellid = spellInfo->Id;
|
||||
|
||||
PetSpellMap::iterator itr = m_spells.find(spellid);
|
||||
PetSpellMap::iterator itr = m_spells.find(spellInfo->Id);
|
||||
if (itr == m_spells.end())
|
||||
return;
|
||||
|
||||
uint32 i;
|
||||
auto autospellItr = std::find(m_autospells.begin(), m_autospells.end(), spellInfo->Id);
|
||||
|
||||
if (apply)
|
||||
{
|
||||
for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i)
|
||||
; // just search
|
||||
|
||||
if (i == m_autospells.size())
|
||||
if (autospellItr == m_autospells.end())
|
||||
{
|
||||
m_autospells.push_back(spellid);
|
||||
m_autospells.push_back(spellInfo->Id);
|
||||
|
||||
if (itr->second.active != ACT_ENABLED)
|
||||
{
|
||||
@@ -2209,13 +2207,9 @@ void Pet::ToggleAutocast(SpellInfo const* spellInfo, bool apply)
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoSpellList::iterator itr2 = m_autospells.begin();
|
||||
for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i, ++itr2)
|
||||
; // just search
|
||||
|
||||
if (i < m_autospells.size())
|
||||
if (autospellItr != m_autospells.end())
|
||||
{
|
||||
m_autospells.erase(itr2);
|
||||
m_autospells.erase(autospellItr);
|
||||
if (itr->second.active != ACT_DISABLED)
|
||||
{
|
||||
itr->second.active = ACT_DISABLED;
|
||||
|
||||
Reference in New Issue
Block a user