aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/CombatHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Handlers/CombatHandler.cpp')
-rw-r--r--src/server/game/Handlers/CombatHandler.cpp34
1 files changed, 11 insertions, 23 deletions
diff --git a/src/server/game/Handlers/CombatHandler.cpp b/src/server/game/Handlers/CombatHandler.cpp
index 0d28d86da5a..2e768bb85f2 100644
--- a/src/server/game/Handlers/CombatHandler.cpp
+++ b/src/server/game/Handlers/CombatHandler.cpp
@@ -16,6 +16,7 @@
*/
#include "WorldSession.h"
+#include "CombatPackets.h"
#include "Common.h"
#include "CreatureAI.h"
#include "DBCStructure.h"
@@ -25,30 +26,25 @@
#include "Vehicle.h"
#include "WorldPacket.h"
-void WorldSession::HandleAttackSwingOpcode(WorldPacket& recvData)
+void WorldSession::HandleAttackSwingOpcode(WorldPackets::Combat::AttackSwing& packet)
{
- ObjectGuid guid;
- recvData >> guid;
+ Unit* enemy = ObjectAccessor::GetUnit(*_player, packet.Victim);
- TC_LOG_DEBUG("network", "WORLD: Recvd CMSG_ATTACKSWING Message %s", guid.ToString().c_str());
-
- Unit* pEnemy = ObjectAccessor::GetUnit(*_player, guid);
-
- if (!pEnemy)
+ if (!enemy)
{
// stop attack state at client
SendAttackStop(nullptr);
return;
}
- if (!_player->IsValidAttackTarget(pEnemy))
+ if (!_player->IsValidAttackTarget(enemy))
{
// stop attack state at client
- SendAttackStop(pEnemy);
+ SendAttackStop(enemy);
return;
}
- //! Client explicitly checks the following before sending CMSG_ATTACKSWING packet,
+ //! Client explicitly checks the following before sending CMSG_ATTACK_SWING packet,
//! so we'll place the same check here. Note that it might be possible to reuse this snippet
//! in other places as well.
if (Vehicle* vehicle = _player->GetVehicle())
@@ -57,15 +53,15 @@ void WorldSession::HandleAttackSwingOpcode(WorldPacket& recvData)
ASSERT(seat);
if (!(seat->m_flags & VEHICLE_SEAT_FLAG_CAN_ATTACK))
{
- SendAttackStop(pEnemy);
+ SendAttackStop(enemy);
return;
}
}
- _player->Attack(pEnemy, true);
+ _player->Attack(enemy, true);
}
-void WorldSession::HandleAttackStopOpcode(WorldPacket & /*recvData*/)
+void WorldSession::HandleAttackStopOpcode(WorldPackets::Combat::AttackStop& /*packet*/)
{
GetPlayer()->AttackStop();
}
@@ -88,13 +84,5 @@ void WorldSession::HandleSetSheathedOpcode(WorldPacket& recvData)
void WorldSession::SendAttackStop(Unit const* enemy)
{
- WorldPacket data(SMSG_ATTACKSTOP, (8+8+4)); // we guess size
- data << GetPlayer()->GetPackGUID();
- if (enemy)
- data << enemy->GetPackGUID();
- else
- data << uint8(0);
-
- data << uint32(0); // unk, can be 1 also
- SendPacket(&data);
+ SendPacket(WorldPackets::Combat::SAttackStop(GetPlayer(), enemy).Write());
}