From 246807d5aef1c1386c695863400c02211df64dff Mon Sep 17 00:00:00 2001 From: lee Date: Sat, 17 Aug 2024 00:46:14 +0800 Subject: [PATCH] [Core/Paccket] Split CMSG_SHOWING_CLOAK, CMSG_SHOWING_HELM to CharacterPackets (#326) --- src/server/game/Handlers/CharacterHandler.cpp | 19 ++++++++++-------- .../game/Server/Packets/CharacterPackets.cpp | 10 ++++++++++ .../game/Server/Packets/CharacterPackets.h | 20 +++++++++++++++++++ src/server/game/Server/WorldSession.h | 6 +++--- 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 7a6c8e91e..151734068 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -1345,18 +1345,21 @@ void WorldSession::HandleRequestForcedReactionsOpcode(WorldPacket& recvData) _player->GetReputationMgr().SendForceReactions(); } -void WorldSession::HandleShowingHelmOpcode(WorldPacket& recvData) +void WorldSession::HandleShowingHelmOpcode(WorldPackets::Character::ShowingHelm& packet) { - TC_LOG_DEBUG("network", "CMSG_SHOWING_HELM for %s", _player->GetName().c_str()); - recvData.read_skip(); // unknown, bool? - _player->ToggleFlag(PLAYER_FIELD_PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM); + if (packet.ShowHelm) + _player->RemoveFlag(PLAYER_FIELD_PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM); + else + _player->SetFlag(PLAYER_FIELD_PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM); } -void WorldSession::HandleShowingCloakOpcode(WorldPacket& recvData) +void WorldSession::HandleShowingCloakOpcode(WorldPackets::Character::ShowingCloak& packet) { - TC_LOG_DEBUG("network", "CMSG_SHOWING_CLOAK for %s", _player->GetName().c_str()); - recvData.read_skip(); // unknown, bool? - _player->ToggleFlag(PLAYER_FIELD_PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK); + if (packet.ShowCloak) + _player->RemoveFlag(PLAYER_FIELD_PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK); + else + _player->SetFlag(PLAYER_FIELD_PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK); + } void WorldSession::SendRenameResult(uint8 result, ObjectGuid guid, std::string name) diff --git a/src/server/game/Server/Packets/CharacterPackets.cpp b/src/server/game/Server/Packets/CharacterPackets.cpp index f00f40638..d7f980c66 100644 --- a/src/server/game/Server/Packets/CharacterPackets.cpp +++ b/src/server/game/Server/Packets/CharacterPackets.cpp @@ -17,6 +17,16 @@ #include "CharacterPackets.h" +void WorldPackets::Character::ShowingCloak::Read() +{ + _worldPacket >> ShowCloak; +} + +void WorldPackets::Character::ShowingHelm::Read() +{ + _worldPacket >> ShowHelm; +} + WorldPacket const* WorldPackets::Character::LogoutResponse::Write() { _worldPacket << uint32(LogoutResult); diff --git a/src/server/game/Server/Packets/CharacterPackets.h b/src/server/game/Server/Packets/CharacterPackets.h index 6f5042a26..786d4b5ad 100644 --- a/src/server/game/Server/Packets/CharacterPackets.h +++ b/src/server/game/Server/Packets/CharacterPackets.h @@ -26,6 +26,26 @@ namespace WorldPackets namespace Character { + class ShowingCloak final : public ClientPacket + { + public: + ShowingCloak(WorldPacket&& packet) : ClientPacket(CMSG_SHOWING_CLOAK, std::move(packet)) { } + + void Read() override; + + bool ShowCloak = false; + }; + + class ShowingHelm final : public ClientPacket + { + public: + ShowingHelm(WorldPacket&& packet) : ClientPacket(CMSG_SHOWING_HELM, std::move(packet)) { } + + void Read() override; + + bool ShowHelm = false; + }; + class LogoutResponse final : public ServerPacket { public: diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index b25e9c94e..f61912435 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -1,5 +1,5 @@ /* -* This file is part of the Pandaria 5.4.8 Project. See THANKS file for Copyright information +* This file is part of the Legends of Azeroth Pandaria Project. See THANKS 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 @@ -522,8 +522,8 @@ class TC_GAME_API WorldSession void HandleMountSpecialAnimOpcode(WorldPacket& recvdata); // character view - void HandleShowingHelmOpcode(WorldPacket& recvData); - void HandleShowingCloakOpcode(WorldPacket& recvData); + void HandleShowingHelmOpcode(WorldPackets::Character::ShowingHelm& packet); + void HandleShowingCloakOpcode(WorldPackets::Character::ShowingCloak& packet); // repair void HandleRepairItemOpcode(WorldPacket& recvPacket);