aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Handlers/LFGHandler.cpp36
-rw-r--r--src/server/game/Server/Packets/AllPackets.h1
-rw-r--r--src/server/game/Server/Packets/LFGPackets.cpp29
-rw-r--r--src/server/game/Server/Packets/LFGPackets.h47
-rw-r--r--src/server/game/Server/WorldSession.h9
5 files changed, 95 insertions, 27 deletions
diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp
index 40daa756b3d..621ad554277 100644
--- a/src/server/game/Handlers/LFGHandler.cpp
+++ b/src/server/game/Handlers/LFGHandler.cpp
@@ -15,7 +15,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "DBCStores.h"
#include "LFGMgr.h"
+#include "LFGPackets.h"
#include "Log.h"
#include "GameTime.h"
#include "Group.h"
@@ -46,50 +48,34 @@ void BuildPartyLockDungeonBlock(WorldPacket& data, lfg::LfgLockPartyMap const& 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) ||
(GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->GetLeaderGUID() != GetPlayer()->GetGUID() &&
(GetPlayer()->GetGroup()->GetMembersCount() == MAXGROUPSIZE || !GetPlayer()->GetGroup()->isLFGGroup())))
- {
- recvData.rfinish();
return;
- }
-
- uint8 numDungeons;
- uint32 roles;
- recvData >> roles;
- recvData.read_skip<uint16>(); // uint8 (always 0) - uint8 (always 0)
- recvData >> numDungeons;
- if (!numDungeons)
+ if (packet.Slots.empty())
{
TC_LOG_DEBUG("lfg", "CMSG_LFG_JOIN %s no dungeons selected", GetPlayerInfo().c_str());
- recvData.rfinish();
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<uint32>(); // for 0..uint8 (always 3) { uint8 (always 0) }
-
- std::string comment;
- recvData >> comment;
- TC_LOG_DEBUG("lfg", "CMSG_LFG_JOIN %s roles: %u, Dungeons: %u, Comment: %s",
- GetPlayerInfo().c_str(), roles, uint8(newDungeons.size()), comment.c_str());
+ TC_LOG_DEBUG("lfg", "CMSG_LFG_JOIN %s roles: %u, Dungeons: " SZFMTD ", Comment: %s",
+ 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 5fb2c5b9e82..1b3d2006854 100644
--- a/src/server/game/Server/Packets/AllPackets.h
+++ b/src/server/game/Server/Packets/AllPackets.h
@@ -24,6 +24,7 @@
#include "CombatLogPackets.h"
#include "CombatPackets.h"
#include "GuildPackets.h"
+#include "LFGPackets.h"
#include "NPCPackets.h"
#include "MiscPackets.h"
#include "PetPackets.h"
diff --git a/src/server/game/Server/Packets/LFGPackets.cpp b/src/server/game/Server/Packets/LFGPackets.cpp
new file mode 100644
index 00000000000..a1e3e5e146a
--- /dev/null
+++ b/src/server/game/Server/Packets/LFGPackets.cpp
@@ -0,0 +1,29 @@
+/*
+ * 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 "LFGPackets.h"
+
+void WorldPackets::LFG::LFGJoin::Read()
+{
+ _worldPacket >> Roles;
+ _worldPacket.read_skip<uint16>();
+ Slots.resize(_worldPacket.read<uint8>());
+ for (uint32& slot : Slots)
+ _worldPacket >> slot;
+ _worldPacket.read_skip<uint32>();
+ _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 00000000000..f04aa3a387b
--- /dev/null
+++ b/src/server/game/Server/Packets/LFGPackets.h
@@ -0,0 +1,47 @@
+/*
+ * 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 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<uint32, 50> Slots;
+ std::string Comment;
+ };
+
+ 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 f929c013030..33e863b15c5 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -141,6 +141,11 @@ namespace WorldPackets
class GuildSetGuildMaster;
class SaveGuildEmblem;
}
+ namespace LFG
+ {
+ class LFGJoin;
+ class LFGLeave;
+ }
namespace NPC
{
class Hello;
@@ -980,8 +985,8 @@ class TC_GAME_API WorldSession
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);