diff options
| author | ForesterDev <11771800+ForesterDev@users.noreply.github.com> | 2020-03-12 20:06:15 +0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-12 17:06:15 +0100 |
| commit | af6d207addfef177fb5ac3e7fa61ec93ced83d16 (patch) | |
| tree | b13c33d01ada684127a9576c8a60b9352d590dde /src/server/game/Server/Packets | |
| parent | 535206594ce10c1d2f5547fc70bec3b715020dfa (diff) | |
Core/PacketIO: update some combat packets to new system (#24236)
Diffstat (limited to 'src/server/game/Server/Packets')
| -rw-r--r-- | src/server/game/Server/Packets/AllPackets.h | 1 | ||||
| -rw-r--r-- | src/server/game/Server/Packets/CombatPackets.cpp | 59 | ||||
| -rw-r--r-- | src/server/game/Server/Packets/CombatPackets.h | 124 |
3 files changed, 184 insertions, 0 deletions
diff --git a/src/server/game/Server/Packets/AllPackets.h b/src/server/game/Server/Packets/AllPackets.h index c161bc8d871..e377bb07215 100644 --- a/src/server/game/Server/Packets/AllPackets.h +++ b/src/server/game/Server/Packets/AllPackets.h @@ -19,6 +19,7 @@ #define AllPackets_h__ #include "ChatPackets.h" +#include "CombatPackets.h" #include "NPCPackets.h" #include "MiscPackets.h" #include "QueryPackets.h" diff --git a/src/server/game/Server/Packets/CombatPackets.cpp b/src/server/game/Server/Packets/CombatPackets.cpp new file mode 100644 index 00000000000..fa9d0370dd2 --- /dev/null +++ b/src/server/game/Server/Packets/CombatPackets.cpp @@ -0,0 +1,59 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "CombatPackets.h" +#include "Unit.h" + +void WorldPackets::Combat::AttackSwing::Read() +{ + _worldPacket >> Victim; +} + +WorldPacket const* WorldPackets::Combat::AttackStart::Write() +{ + _worldPacket << Attacker; + _worldPacket << Victim; + + return &_worldPacket; +} + +WorldPackets::Combat::SAttackStop::SAttackStop(Unit const* attacker, Unit const* victim) : ServerPacket(SMSG_ATTACK_STOP, 8 + 8 + 4) +{ + Attacker = attacker->GetPackGUID(); + if (victim) + { + Victim = victim->GetPackGUID(); + NowDead = victim->isDead(); + } +} + +WorldPacket const* WorldPackets::Combat::SAttackStop::Write() +{ + _worldPacket << Attacker; + _worldPacket << Victim; + _worldPacket << uint32(NowDead); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Combat::CancelAutoRepeat::Write() +{ + _worldPacket << Guid; + + return &_worldPacket; +} + diff --git a/src/server/game/Server/Packets/CombatPackets.h b/src/server/game/Server/Packets/CombatPackets.h new file mode 100644 index 00000000000..6b6fc7c85ee --- /dev/null +++ b/src/server/game/Server/Packets/CombatPackets.h @@ -0,0 +1,124 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef CombatPackets_h__ +#define CombatPackets_h__ + +#include "Packet.h" +#include "ObjectGuid.h" + +class Unit; + +namespace WorldPackets +{ + namespace Combat + { + class AttackSwing final : public ClientPacket + { + public: + AttackSwing(WorldPacket&& packet) : ClientPacket(CMSG_ATTACK_SWING, std::move(packet)) { } + + void Read() override; + + ObjectGuid Victim; + }; + + class AttackSwingNotInRange final : public ServerPacket + { + public: + AttackSwingNotInRange() : ServerPacket(SMSG_ATTACK_SWING_NOT_IN_RANGE, 0) { } + + WorldPacket const* Write() override { return &_worldPacket; } + }; + + class AttackSwingBadFacing final : public ServerPacket + { + public: + AttackSwingBadFacing() : ServerPacket(SMSG_ATTACK_SWING_BAD_FACING, 0) { } + + WorldPacket const* Write() override { return &_worldPacket; } + }; + + class AttackSwingDeadTarget final : public ServerPacket + { + public: + AttackSwingDeadTarget() : ServerPacket(SMSG_ATTACK_SWING_DEAD_TARGET, 0) { } + + WorldPacket const* Write() override { return &_worldPacket; } + }; + + class AttackSwingCantAttack final : public ServerPacket + { + public: + AttackSwingCantAttack() : ServerPacket(SMSG_ATTACK_SWING_CANT_ATTACK, 0) { } + + WorldPacket const* Write() override { return &_worldPacket; } + }; + + class AttackStop final : public ClientPacket + { + public: + AttackStop(WorldPacket&& packet) : ClientPacket(CMSG_ATTACK_STOP, std::move(packet)) { } + + void Read() override { } + }; + + class AttackStart final : public ServerPacket + { + public: + AttackStart() : ServerPacket(SMSG_ATTACK_START, 8 + 8) { } + + WorldPacket const* Write() override; + + ObjectGuid Attacker; + ObjectGuid Victim; + }; + + class SAttackStop final : public ServerPacket + { + public: + SAttackStop() : ServerPacket(SMSG_ATTACK_STOP, 8 + 8 + 4) { } + SAttackStop(Unit const* attacker, Unit const* victim); + + WorldPacket const* Write() override; + + PackedGuid Attacker; + PackedGuid Victim; + bool NowDead = false; + }; + + class CancelCombat final : public ServerPacket + { + public: + CancelCombat() : ServerPacket(SMSG_CANCEL_COMBAT, 0) { } + + WorldPacket const* Write() override { return &_worldPacket; } + }; + + class CancelAutoRepeat final : public ServerPacket + { + public: + CancelAutoRepeat() : ServerPacket(SMSG_CANCEL_AUTO_REPEAT, 8) { } + + WorldPacket const* Write() override; + + PackedGuid Guid; + }; + } +} + +#endif // CombatPackets_h__ |
