diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp index 0bf3a0c40..9c494d627 100644 --- a/src/server/game/Handlers/LFGHandler.cpp +++ b/src/server/game/Handlers/LFGHandler.cpp @@ -15,9 +15,11 @@ * with this program. If not, see . */ +#include "DBCStores.h" #include "GameTime.h" #include "Group.h" #include "LFGMgr.h" +#include "LFGPackets.h" #include "ObjectMgr.h" #include "Opcodes.h" #include "Player.h" @@ -44,56 +46,34 @@ void BuildPartyLockDungeonBlock(WorldPacket& data, const lfg::LfgLockPartyMap& l } } -void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData) +void WorldSession::HandleLfgJoinOpcode(WorldPackets::LFG::LFGJoin& packet) { - if (!sLFGMgr->isOptionEnabled(lfg::LFG_OPTION_ENABLE_DUNGEON_FINDER | lfg::LFG_OPTION_ENABLE_RAID_BROWSER | lfg::LFG_OPTION_ENABLE_SEASONAL_BOSSES)) - { - recvData.rfinish(); + if (!sLFGMgr->isOptionEnabled(lfg::LFG_OPTION_ENABLE_DUNGEON_FINDER | lfg::LFG_OPTION_ENABLE_RAID_BROWSER) || + (GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->GetLeaderGUID() != GetPlayer()->GetGUID() && + (GetPlayer()->GetGroup()->GetMembersCount() == MAXGROUPSIZE || !GetPlayer()->GetGroup()->isLFGGroup()))) return; - } - // pussywizard: - if (Group* g = GetPlayer()->GetGroup()) - if (g->isLFGGroup() && g->GetLeaderGUID() != GetPlayer()->GetGUID()) - { - recvData.rfinish(); - return; - } - - uint8 numDungeons; - uint32 roles; - - recvData >> roles; - recvData.read_skip(); // uint8 (always 0) - uint8 (always 0) - recvData >> numDungeons; - if (!numDungeons) + if (packet.Slots.empty()) { - LOG_DEBUG("network", "CMSG_LFG_JOIN [{}] no dungeons selected", GetPlayer()->GetGUID().ToString()); - recvData.rfinish(); + LOG_DEBUG("lfg", "CMSG_LFG_JOIN {} no dungeons selected", GetPlayerInfo().c_str()); return; } lfg::LfgDungeonSet newDungeons; - for (int8 i = 0; i < numDungeons; ++i) + for (uint32 slot : packet.Slots) { - uint32 dungeon; - recvData >> dungeon; - dungeon &= 0x00FFFFFF; // remove the type from the dungeon entry - if (dungeon) + uint32 dungeon = slot & 0x00FFFFFF; // remove the type from the dungeon entry + if (sLFGDungeonStore.LookupEntry(dungeon)) newDungeons.insert(dungeon); } - recvData.read_skip(); // for 0..uint8 (always 3) { uint8 (always 0) } - - std::string comment; - recvData >> comment; LOG_DEBUG("network", "CMSG_LFG_JOIN [{}] roles: {}, Dungeons: {}, Comment: {}", - GetPlayer()->GetGUID().ToString(), roles, uint8(newDungeons.size()), comment); + GetPlayerInfo().c_str(), packet.Roles, newDungeons.size(), packet.Comment.c_str()); - sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment); + sLFGMgr->JoinLfg(GetPlayer(), uint8(packet.Roles), newDungeons, packet.Comment); } -void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recvData*/) +void WorldSession::HandleLfgLeaveOpcode(WorldPackets::LFG::LFGLeave& /*packet*/) { Group* group = GetPlayer()->GetGroup(); ObjectGuid guid = GetPlayer()->GetGUID(); diff --git a/src/server/game/Server/Packets/AllPackets.h b/src/server/game/Server/Packets/AllPackets.h index f8dc886e1..33caecf09 100644 --- a/src/server/game/Server/Packets/AllPackets.h +++ b/src/server/game/Server/Packets/AllPackets.h @@ -18,6 +18,7 @@ #ifndef AllPackets_h__ #define AllPackets_h__ +#include "LFGPackets.h" #include "BankPackets.h" #include "CharacterPackets.h" #include "ChatPackets.h" diff --git a/src/server/game/Server/Packets/LFGPackets.cpp b/src/server/game/Server/Packets/LFGPackets.cpp new file mode 100644 index 000000000..4079bf52f --- /dev/null +++ b/src/server/game/Server/Packets/LFGPackets.cpp @@ -0,0 +1,34 @@ +/* + * 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 "LFGPackets.h" + +void WorldPackets::LFG::LFGJoin::Read() +{ + _worldPacket >> Roles; + _worldPacket >> NoPartialClear; + _worldPacket >> Achievements; + Slots.resize(_worldPacket.read()); + for (uint32& slot : Slots) + _worldPacket >> slot; + + _worldPacket.read_skip(); // Needs count, hardcoded to 3 in client + for (uint8& needs : Needs) + _worldPacket >> needs; + + _worldPacket >> Comment; +} diff --git a/src/server/game/Server/Packets/LFGPackets.h b/src/server/game/Server/Packets/LFGPackets.h new file mode 100644 index 000000000..e91dc84c1 --- /dev/null +++ b/src/server/game/Server/Packets/LFGPackets.h @@ -0,0 +1,50 @@ +/* + * 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 LFGPackets_h__ +#define LFGPackets_h__ + +#include "Packet.h" +#include "PacketUtilities.h" + +namespace WorldPackets::LFG +{ + class LFGJoin final : public ClientPacket + { + public: + LFGJoin(WorldPacket&& packet) : ClientPacket(CMSG_LFG_JOIN, std::move(packet)) { } + + void Read() override; + + uint32 Roles = 0; + Array Slots; + std::string Comment; + bool NoPartialClear = false; + bool Achievements = false; + std::array Needs = { }; + }; + + class LFGLeave final : public ClientPacket + { + public: + LFGLeave(WorldPacket&& packet) : ClientPacket(CMSG_LFG_LEAVE, std::move(packet)) { } + + void Read() override { }; + }; +} + +#endif // LFGPackets_h__ diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 0f2268864..9960232ea 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -71,6 +71,12 @@ namespace lfg namespace WorldPackets { + namespace LFG + { + class LFGJoin; + class LFGLeave; + } + namespace Chat { class EmoteClient; @@ -930,8 +936,8 @@ public: // opcodes handlers void HandleLfgSetCommentOpcode(WorldPacket& recvData); void HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& recvData); void HandleLfgPartyLockInfoRequestOpcode(WorldPacket& recvData); - void HandleLfgJoinOpcode(WorldPacket& recvData); - void HandleLfgLeaveOpcode(WorldPacket& recvData); + void HandleLfgJoinOpcode(WorldPackets::LFG::LFGJoin& lfgJoin); + void HandleLfgLeaveOpcode(WorldPackets::LFG::LFGLeave& lfgleave); void HandleLfgSetRolesOpcode(WorldPacket& recvData); void HandleLfgProposalResultOpcode(WorldPacket& recvData); void HandleLfgSetBootVoteOpcode(WorldPacket& recvData);