aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/SpellHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Handlers/SpellHandler.cpp')
-rw-r--r--src/server/game/Handlers/SpellHandler.cpp65
1 files changed, 33 insertions, 32 deletions
diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp
index 39a7915eb4f..35c6ae898fb 100644
--- a/src/server/game/Handlers/SpellHandler.cpp
+++ b/src/server/game/Handlers/SpellHandler.cpp
@@ -32,6 +32,7 @@
#include "Spell.h"
#include "SpellAuraEffects.h"
#include "SpellMgr.h"
+#include "SpellPackets.h"
#include "Totem.h"
#include "TotemPackets.h"
#include "World.h"
@@ -432,23 +433,15 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
spell->prepare(targets);
}
-void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket)
+void WorldSession::HandleCancelCastOpcode(WorldPackets::Spells::CancelCast& cancelCast)
{
- uint32 spellId;
-
- recvPacket.read_skip<uint8>(); // counter, increments with every CANCEL packet, don't use for now
- recvPacket >> spellId;
-
if (_player->IsNonMeleeSpellCast(false))
- _player->InterruptNonMeleeSpells(false, spellId, false);
+ _player->InterruptNonMeleeSpells(false, cancelCast.SpellID, false);
}
-void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket)
+void WorldSession::HandleCancelAuraOpcode(WorldPackets::Spells::CancelAura& cancelAura)
{
- uint32 spellId;
- recvPacket >> spellId;
-
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cancelAura.SpellID);
if (!spellInfo)
return;
@@ -460,7 +453,7 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket)
if (spellInfo->IsChanneled())
{
if (Spell* curSpell = _player->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
- if (curSpell->m_spellInfo->Id == spellId)
+ if (curSpell->m_spellInfo->Id == cancelAura.SpellID)
_player->InterruptSpell(CURRENT_CHANNELED_SPELL);
return;
}
@@ -472,7 +465,7 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket)
return;
// maybe should only remove one buff when there are multiple?
- _player->RemoveOwnedAura(spellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_CANCEL);
+ _player->RemoveOwnedAura(cancelAura.SpellID, ObjectGuid::Empty, 0, AURA_REMOVE_BY_CANCEL);
// If spell being removed is a resource tracker, see if player was tracking both (herbs / minerals) and remove the other
if (sWorld->getBoolConfig(CONFIG_ALLOW_TRACK_BOTH_RESOURCES) && spellInfo->HasAura(SPELL_AURA_TRACK_RESOURCES))
@@ -494,32 +487,26 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket)
}
}
-void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket)
+void WorldSession::HandlePetCancelAuraOpcode(WorldPackets::Spells::PetCancelAura& packet)
{
- ObjectGuid guid;
- uint32 spellId;
-
- recvPacket >> guid;
- recvPacket >> spellId;
-
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(packet.SpellID);
if (!spellInfo)
{
- TC_LOG_ERROR("network", "WORLD: unknown PET spell id %u", spellId);
+ TC_LOG_ERROR("network", "WORLD: unknown PET spell id %u", packet.SpellID);
return;
}
- Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);
+ Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, packet.PetGUID);
if (!pet)
{
- TC_LOG_ERROR("network", "HandlePetCancelAura: Attempt to cancel an aura for non-existant %s by player '%s'", guid.ToString().c_str(), GetPlayer()->GetName().c_str());
+ TC_LOG_ERROR("network", "HandlePetCancelAura: Attempt to cancel an aura for non-existant %s by player '%s'", packet.PetGUID.ToString().c_str(), GetPlayer()->GetName().c_str());
return;
}
if (pet != GetPlayer()->GetGuardianPet() && pet != GetPlayer()->GetCharmed())
{
- TC_LOG_ERROR("network", "HandlePetCancelAura: %s is not a pet of player '%s'", guid.ToString().c_str(), GetPlayer()->GetName().c_str());
+ TC_LOG_ERROR("network", "HandlePetCancelAura: %s is not a pet of player '%s'", packet.PetGUID.ToString().c_str(), GetPlayer()->GetName().c_str());
return;
}
@@ -529,22 +516,36 @@ void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket)
return;
}
- pet->RemoveOwnedAura(spellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_CANCEL);
+ pet->RemoveOwnedAura(packet.SpellID, ObjectGuid::Empty, 0, AURA_REMOVE_BY_CANCEL);
}
-void WorldSession::HandleCancelGrowthAuraOpcode(WorldPacket& /*recvPacket*/) { }
+void WorldSession::HandleCancelGrowthAuraOpcode(WorldPackets::Spells::CancelGrowthAura& /*cancelGrowthAura*/)
+{
+ _player->RemoveAurasByType(SPELL_AURA_MOD_SCALE, [](AuraApplication const* aurApp)
+ {
+ SpellInfo const* spellInfo = aurApp->GetBase()->GetSpellInfo();
+ return !spellInfo->HasAttribute(SPELL_ATTR0_CANT_CANCEL) && spellInfo->IsPositive() && !spellInfo->IsPassive();
+ });
+}
-void WorldSession::HandleCancelAutoRepeatSpellOpcode(WorldPacket& /*recvPacket*/)
+void WorldSession::HandleCancelMountAuraOpcode(WorldPackets::Spells::CancelMountAura& /*cancelMountAura*/)
+{
+ _player->RemoveAurasByType(SPELL_AURA_MOUNTED, [](AuraApplication const* aurApp)
+ {
+ SpellInfo const* spellInfo = aurApp->GetBase()->GetSpellInfo();
+ return !spellInfo->HasAttribute(SPELL_ATTR0_CANT_CANCEL) && spellInfo->IsPositive() && !spellInfo->IsPassive();
+ });
+}
+
+void WorldSession::HandleCancelAutoRepeatSpellOpcode(WorldPackets::Spells::CancelAutoRepeatSpell& /*cancelAutoRepeatSpell*/)
{
// may be better send SMSG_CANCEL_AUTO_REPEAT?
// cancel and prepare for deleting
_player->InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
}
-void WorldSession::HandleCancelChanneling(WorldPacket& recvData)
+void WorldSession::HandleCancelChanneling(WorldPackets::Spells::CancelChannelling& /*cancelChanneling*/)
{
- recvData.read_skip<uint32>(); // spellid, not used
-
// ignore for remote control state (for player case)
Unit* mover = _player->GetUnitBeingMoved();
if (mover != _player && mover->GetTypeId() == TYPEID_PLAYER)