From 4f7eec88dcd05c990abaec9b3b50283d3bc0667c Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Wed, 8 Jul 2020 14:19:44 +0200 Subject: [PATCH] Core/Packets: converted SMSG_LOOT_LIST to packet class --- src/server/game/Entities/Unit/Unit.cpp | 11 ++--- src/server/game/Groups/Group.cpp | 22 +++++----- src/server/game/Groups/Group.h | 6 +-- .../game/Server/Packets/LootPackets.cpp | 27 ++++++++++++ src/server/game/Server/Packets/LootPackets.h | 43 +++++++++++++++++++ 5 files changed, 89 insertions(+), 20 deletions(-) create mode 100644 src/server/game/Server/Packets/LootPackets.cpp create mode 100644 src/server/game/Server/Packets/LootPackets.h diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 9483f04394e..294ca80ff85 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -40,6 +40,7 @@ #include "Item.h" #include "Log.h" #include "LootMgr.h" +#include "LootPackets.h" #include "MiscPackets.h" #include "MotionMaster.h" #include "MovementGenerator.h" @@ -11861,11 +11862,11 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) if (creature) { - WorldPacket data2(SMSG_LOOT_LIST, 8 + 1 + 1); - data2 << uint64(creature->GetGUID()); - data2 << uint8(0); // unk1 - data2 << uint8(0); // no group looter - player->SendMessageToSet(&data2, true); + WorldPackets::Loot::LootList lootList; + lootList.Owner = creature->GetGUID(); + lootList.RoundRobinWinner = player->GetGUID(); + + player->SendMessageToSet(lootList.Write(), true); } } diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 9081da706eb..b60a5c22e45 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -29,6 +29,7 @@ #include "InstanceSaveMgr.h" #include "LFGMgr.h" #include "LootMgr.h" +#include "LootPackets.h" #include "MapManager.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" @@ -1015,20 +1016,17 @@ void Group::SendLooter(Creature* creature, Player* groupLooter) { ASSERT(creature); - WorldPacket data(SMSG_LOOT_LIST, (8+8)); - data << uint64(creature->GetGUID()); + WorldPackets::Loot::LootList lootList; + + lootList.Owner = creature->GetGUID(); if (GetLootMethod() == MASTER_LOOT && creature->loot.hasOverThresholdItem()) - data << GetMasterLooterGuid().WriteAsPacked(); - else - data << uint8(0); + lootList.Master = GetMasterLooterGuid(); if (groupLooter) - data << groupLooter->GetPackGUID(); - else - data << uint8(0); + lootList.RoundRobinWinner = groupLooter->GetGUID(); - BroadcastPacket(&data, false); + BroadcastPacket(lootList.Write(), false); } void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject) @@ -1814,7 +1812,7 @@ void Group::UpdatePlayerOutOfRange(Player* player) } } -void Group::BroadcastAddonMessagePacket(WorldPacket* packet, const std::string& prefix, bool ignorePlayersInBGRaid, int group, uint64 ignore) +void Group::BroadcastAddonMessagePacket(WorldPacket const* packet, const std::string& prefix, bool ignorePlayersInBGRaid, int group, uint64 ignore) { for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { @@ -1829,7 +1827,7 @@ void Group::BroadcastAddonMessagePacket(WorldPacket* packet, const std::string& } } -void Group::BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int group, ObjectGuid ignoredPlayer) +void Group::BroadcastPacket(WorldPacket const* packet, bool ignorePlayersInBGRaid, int group, ObjectGuid ignoredPlayer) { for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { @@ -1842,7 +1840,7 @@ void Group::BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int } } -void Group::BroadcastReadyCheck(WorldPacket* packet) +void Group::BroadcastReadyCheck(WorldPacket const* packet) { for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index 5cc8aaf683f..19a79516f4b 100644 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -334,9 +334,9 @@ class TC_GAME_API Group worker(itr->GetSource()); } - void BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int group = -1, ObjectGuid ignoredPlayer = ObjectGuid::Empty); - void BroadcastAddonMessagePacket(WorldPacket* packet, const std::string& prefix, bool ignorePlayersInBGRaid, int group = -1, uint64 ignore = 0); - void BroadcastReadyCheck(WorldPacket* packet); + void BroadcastPacket(WorldPacket const* packet, bool ignorePlayersInBGRaid, int group = -1, ObjectGuid ignoredPlayer = ObjectGuid::Empty); + void BroadcastAddonMessagePacket(WorldPacket const* packet, const std::string& prefix, bool ignorePlayersInBGRaid, int group = -1, uint64 ignore = 0); + void BroadcastReadyCheck(WorldPacket const* packet); void OfflineReadyCheck(); /*********************************************************/ diff --git a/src/server/game/Server/Packets/LootPackets.cpp b/src/server/game/Server/Packets/LootPackets.cpp new file mode 100644 index 00000000000..84e3a772f3f --- /dev/null +++ b/src/server/game/Server/Packets/LootPackets.cpp @@ -0,0 +1,27 @@ +/* + * 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 . + */ + +#include "LootPackets.h" + +WorldPacket const* WorldPackets::Loot::LootList::Write() +{ + _worldPacket << Owner; + _worldPacket << Master.WriteAsPacked(); + _worldPacket << RoundRobinWinner.WriteAsPacked(); + + return &_worldPacket; +} diff --git a/src/server/game/Server/Packets/LootPackets.h b/src/server/game/Server/Packets/LootPackets.h new file mode 100644 index 00000000000..252d332fda0 --- /dev/null +++ b/src/server/game/Server/Packets/LootPackets.h @@ -0,0 +1,43 @@ +/* + * 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 . + */ + +#ifndef LootPackets_h__ +#define LootPackets_h__ + +#include "Packet.h" +#include "ObjectGuid.h" +#include "ItemPacketsCommon.h" + +namespace WorldPackets +{ + namespace Loot + { + class LootList final : public ServerPacket + { + public: + LootList() : ServerPacket(SMSG_LOOT_LIST, 8 + 8 + 8) { } + + WorldPacket const* Write() override; + + ObjectGuid Owner; + ObjectGuid Master; + ObjectGuid RoundRobinWinner; + }; + } +} + +#endif // LootPackets_h__