diff --git a/src/server/game/Handlers/CombatHandler.cpp b/src/server/game/Handlers/CombatHandler.cpp index 7dd25be19..b3d84d5ec 100644 --- a/src/server/game/Handlers/CombatHandler.cpp +++ b/src/server/game/Handlers/CombatHandler.cpp @@ -16,6 +16,7 @@ */ #include "CreatureAI.h" +#include "CombatPackets.h" #include "Log.h" #include "ObjectAccessor.h" #include "ObjectDefines.h" @@ -70,18 +71,15 @@ void WorldSession::HandleAttackStopOpcode(WorldPacket& /*recvData*/) GetPlayer()->AttackStop(); } -void WorldSession::HandleSetSheathedOpcode(WorldPacket& recvData) +void WorldSession::HandleSetSheathedOpcode(WorldPackets::Combat::SetSheathed& packet) { - uint32 sheathed; - recvData >> sheathed; - - if (sheathed >= MAX_SHEATH_STATE) + if (packet.CurrentSheathState >= MAX_SHEATH_STATE) { - LOG_ERROR("network.opcode", "Unknown sheath state {} ??", sheathed); + LOG_ERROR("network.opcode", "Unknown sheath state {} ??", packet.CurrentSheathState); return; } - GetPlayer()->SetSheath(SheathState(sheathed)); + _player->SetSheath(SheathState(packet.CurrentSheathState)); } void WorldSession::SendAttackStop(Unit const* enemy) diff --git a/src/server/game/Server/Packets/AllPackets.h b/src/server/game/Server/Packets/AllPackets.h index 33caecf09..012400299 100644 --- a/src/server/game/Server/Packets/AllPackets.h +++ b/src/server/game/Server/Packets/AllPackets.h @@ -24,6 +24,7 @@ #include "ChatPackets.h" #include "PetPackets.h" #include "CombatLogPackets.h" +#include "CombatPackets.h" #include "GuildPackets.h" #include "MiscPackets.h" #include "TotemPackets.h" diff --git a/src/server/game/Server/Packets/CombatPackets.cpp b/src/server/game/Server/Packets/CombatPackets.cpp new file mode 100644 index 000000000..7a82cf0b8 --- /dev/null +++ b/src/server/game/Server/Packets/CombatPackets.cpp @@ -0,0 +1,23 @@ +/* + * This file is part of the AzerothCore 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 Affero General Public License as published by the + * Free Software Foundation; either version 3 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 Affero 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 . + */ + +#include "CombatPackets.h" + +void WorldPackets::Combat::SetSheathed::Read() +{ + _worldPacket >> CurrentSheathState; +} diff --git a/src/server/game/Server/Packets/CombatPackets.h b/src/server/game/Server/Packets/CombatPackets.h new file mode 100644 index 000000000..7c221d8e7 --- /dev/null +++ b/src/server/game/Server/Packets/CombatPackets.h @@ -0,0 +1,40 @@ +/* + * This file is part of the AzerothCore 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 Affero General Public License as published by the + * Free Software Foundation; either version 3 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 Affero 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 . + */ + +#ifndef CombatPackets_h__ +#define CombatPackets_h__ + +#include "Packet.h" +#include "ObjectGuid.h" + +namespace WorldPackets +{ + namespace Combat + { + class SetSheathed final : public ClientPacket + { + public: + SetSheathed(WorldPacket&& packet) : ClientPacket(CMSG_SET_SHEATHED, std::move(packet)) { } + + void Read() override; + + uint32 CurrentSheathState = 0; + }; + } +} + +#endif // CombatPackets_h__ diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index 3691f1f42..77052de11 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -608,7 +608,7 @@ void OpcodeTable::Initialize() /*0x1DD*/ DEFINE_SERVER_OPCODE_HANDLER(SMSG_PONG, STATUS_NEVER); /*0x1DE*/ DEFINE_SERVER_OPCODE_HANDLER(SMSG_CLEAR_COOLDOWN, STATUS_NEVER); /*0x1DF*/ DEFINE_SERVER_OPCODE_HANDLER(SMSG_GAMEOBJECT_PAGETEXT, STATUS_NEVER); - /*0x1E0*/ DEFINE_HANDLER(CMSG_SETSHEATHED, STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleSetSheathedOpcode ); + /*0x1E0*/ DEFINE_HANDLER(CMSG_SET_SHEATHED, STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleSetSheathedOpcode ); /*0x1E1*/ DEFINE_SERVER_OPCODE_HANDLER(SMSG_COOLDOWN_CHEAT, STATUS_NEVER); /*0x1E2*/ DEFINE_SERVER_OPCODE_HANDLER(SMSG_SPELL_DELAYED, STATUS_NEVER); /*0x1E3*/ DEFINE_HANDLER(CMSG_QUEST_POI_QUERY, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleQuestPOIQuery ); diff --git a/src/server/game/Server/Protocol/Opcodes.h b/src/server/game/Server/Protocol/Opcodes.h index c3b06bfe2..037949916 100644 --- a/src/server/game/Server/Protocol/Opcodes.h +++ b/src/server/game/Server/Protocol/Opcodes.h @@ -507,7 +507,7 @@ enum Opcodes : uint16 SMSG_PONG = 0x1DD, SMSG_CLEAR_COOLDOWN = 0x1DE, SMSG_GAMEOBJECT_PAGETEXT = 0x1DF, - CMSG_SETSHEATHED = 0x1E0, + CMSG_SET_SHEATHED = 0x1E0, SMSG_COOLDOWN_CHEAT = 0x1E1, SMSG_SPELL_DELAYED = 0x1E2, CMSG_QUEST_POI_QUERY = 0x1E3, diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index c07b31b6d..e54c94c92 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -1363,7 +1363,7 @@ uint32 WorldSession::DosProtection::GetMaxPacketCounterAllowed(uint16 opcode) co case CMSG_CORPSE_MAP_POSITION_QUERY: // 0 1 case CMSG_MOVE_TIME_SKIPPED: // 0 1 case MSG_QUERY_NEXT_MAIL_TIME: // 0 1 - case CMSG_SETSHEATHED: // 0 1 + case CMSG_SET_SHEATHED: // 0 1 case MSG_RAID_TARGET_UPDATE: // 0 1 case CMSG_PLAYER_LOGOUT: // 0 1 case CMSG_LOGOUT_REQUEST: // 0 1 diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 9960232ea..ea2375a9f 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -104,6 +104,11 @@ namespace WorldPackets class BuyBankSlot; } + namespace Combat + { + class SetSheathed; + } + namespace Guild { class QueryGuildInfo; @@ -794,7 +799,7 @@ public: // opcodes handlers void HandleAttackSwingOpcode(WorldPacket& recvPacket); void HandleAttackStopOpcode(WorldPacket& recvPacket); - void HandleSetSheathedOpcode(WorldPacket& recvPacket); + void HandleSetSheathedOpcode(WorldPackets::Combat::SetSheathed& packet); void HandleUseItemOpcode(WorldPacket& recvPacket); void HandleOpenItemOpcode(WorldPacket& recvPacket);