aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-09-11 18:21:01 +0200
committerShauren <shauren.trinity@gmail.com>2022-09-11 18:21:01 +0200
commite9d083a2ee59d297271b04f3b7fb63808f7f0c8c (patch)
treed32b537dcc05ff251d326f2f9424d4defe205fba /src/server
parent78698463ff6b20255148fb647e9ad33a487bb09d (diff)
Core/Loot: Set loot guid and type in Loot constructor
Diffstat (limited to 'src/server')
-rw-r--r--src/server/game/Entities/Player/Player.cpp29
-rw-r--r--src/server/game/Entities/Player/Player.h2
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp3
-rw-r--r--src/server/game/Groups/Group.cpp8
-rw-r--r--src/server/game/Handlers/LootHandler.cpp4
-rw-r--r--src/server/game/Loot/Loot.cpp88
-rw-r--r--src/server/game/Loot/Loot.h27
-rw-r--r--src/server/game/Loot/LootMgr.cpp18
-rw-r--r--src/server/game/Loot/LootMgr.h2
-rw-r--r--src/server/game/Mails/Mail.cpp2
10 files changed, 86 insertions, 97 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 138fe450158..20c8f8805ce 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -8760,8 +8760,7 @@ void Player::RemovedInsignia(Player* looterPlr)
// Now we must make bones lootable, and send player loot
bones->SetCorpseDynamicFlag(CORPSE_DYNFLAG_LOOTABLE);
- bones->m_loot.reset(new Loot());
- bones->m_loot->SetGUID(ObjectGuid::Create<HighGuid::LootObject>(GetMapId(), 0, GetMap()->GenerateLowGuid<HighGuid::LootObject>()));
+ bones->m_loot.reset(new Loot(GetMap(), bones->GetGUID(), LOOT_INSIGNIA));
// For AV Achievement
if (Battleground* bg = GetBattleground())
@@ -8855,8 +8854,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type, bool aeLooting/* = fa
return;
}
- loot = new Loot();
- loot->SetGUID(ObjectGuid::Create<HighGuid::LootObject>(go->GetMapId(), 0, go->GetMap()->GenerateLowGuid<HighGuid::LootObject>()));
+ loot = new Loot(GetMap(), guid, loot_type);
if (go->GetMap()->Is25ManRaid())
loot->maxDuplicates = 3;
@@ -8952,8 +8950,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type, bool aeLooting/* = fa
if (!item->m_lootGenerated && !sLootItemStorage->LoadStoredLoot(item, this))
{
item->m_lootGenerated = true;
- loot = new Loot();
- loot->SetGUID(ObjectGuid::Create<HighGuid::LootObject>(GetMapId(), 0, GetMap()->GenerateLowGuid<HighGuid::LootObject>()));
+ loot = new Loot(GetMap(), guid, loot_type);
item->m_loot.reset(loot);
switch (loot_type)
@@ -9126,10 +9123,6 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type, bool aeLooting/* = fa
}
}
- // need know merged fishing/corpse loot type for achievements
- if (loot)
- loot->loot_type = loot_type;
-
if (permission != NONE_PERMISSION)
{
LootMethod _lootMethod = FREE_FOR_ALL;
@@ -9186,11 +9179,11 @@ void Player::SendNotifyLootMoneyRemoved(ObjectGuid lootObj) const
SendDirectMessage(packet.Write());
}
-void Player::SendNotifyLootItemRemoved(ObjectGuid lootObj, uint8 lootSlot) const
+void Player::SendNotifyLootItemRemoved(ObjectGuid lootObj, ObjectGuid owner, uint8 lootSlot) const
{
WorldPackets::Loot::LootRemoved packet;
- packet.Owner = GetLootWorldObjectGUID(lootObj);
packet.LootObj = lootObj;
+ packet.Owner = owner;
packet.LootListID = lootSlot + 1;
SendDirectMessage(packet.Write());
}
@@ -26067,8 +26060,8 @@ void Player::InitRunes()
void Player::AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, ItemContext context, bool broadcast, bool createdByPlayer)
{
- Loot loot;
- loot.FillLoot (loot_id, store, this, true, false, LOOT_MODE_DEFAULT, context);
+ Loot loot(nullptr, ObjectGuid::Empty, LOOT_NONE);
+ loot.FillLoot(loot_id, store, this, true, false, LOOT_MODE_DEFAULT, context);
uint32 max_slot = loot.GetMaxSlotInLootFor(this);
for (uint32 i = 0; i < max_slot; ++i)
@@ -26140,9 +26133,9 @@ void Player::StoreLootItem(ObjectGuid lootWorldObjectGuid, uint8 lootSlot, Loot*
qitem->is_looted = true;
//freeforall is 1 if everyone's supposed to get the quest item.
if (item->freeforall || loot->GetPlayerQuestItems().size() == 1)
- SendNotifyLootItemRemoved(loot->GetGUID(), lootSlot);
+ SendNotifyLootItemRemoved(loot->GetGUID(), loot->GetOwnerGUID(), lootSlot);
else
- loot->NotifyQuestItemRemoved(qitem->index);
+ loot->NotifyQuestItemRemoved(qitem->index, GetMap());
}
else
{
@@ -26150,14 +26143,14 @@ void Player::StoreLootItem(ObjectGuid lootWorldObjectGuid, uint8 lootSlot, Loot*
{
//freeforall case, notify only one player of the removal
ffaitem->is_looted = true;
- SendNotifyLootItemRemoved(loot->GetGUID(), lootSlot);
+ SendNotifyLootItemRemoved(loot->GetGUID(), loot->GetOwnerGUID(), lootSlot);
}
else
{
//not freeforall, notify everyone
if (conditem)
conditem->is_looted = true;
- loot->NotifyItemRemoved(lootSlot);
+ loot->NotifyItemRemoved(lootSlot, GetMap());
}
}
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index dffc1965443..40eaae73828 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -2353,7 +2353,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void SendLootError(ObjectGuid const& lootObj, ObjectGuid const& owner, LootError error) const;
void SendLootRelease(ObjectGuid guid) const;
void SendLootReleaseAll() const;
- void SendNotifyLootItemRemoved(ObjectGuid lootObj, uint8 lootSlot) const;
+ void SendNotifyLootItemRemoved(ObjectGuid lootObj, ObjectGuid owner, uint8 lootSlot) const;
void SendNotifyLootMoneyRemoved(ObjectGuid lootObj) const;
/*********************************************************/
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 59e9e05daea..9eb93bd863b 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -10686,9 +10686,8 @@ void Unit::SetMeleeAnimKitId(uint16 animKitId)
// Generate loot before updating looter
if (creature)
{
- creature->m_loot.reset(new Loot());
+ creature->m_loot.reset(new Loot(creature->GetMap(), creature->GetGUID(), LOOT_CORPSE));
Loot* loot = creature->m_loot.get();
- loot->SetGUID(ObjectGuid::Create<HighGuid::LootObject>(creature->GetMapId(), 0, creature->GetMap()->GenerateLowGuid<HighGuid::LootObject>()));
if (creature->GetMap()->Is25ManRaid())
loot->maxDuplicates = 3;
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp
index e371053dfac..42f5d3f837e 100644
--- a/src/server/game/Groups/Group.cpp
+++ b/src/server/game/Groups/Group.cpp
@@ -1352,7 +1352,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap)
if (msg == EQUIP_ERR_OK)
{
item->is_looted = true;
- roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
+ roll->getLoot()->NotifyItemRemoved(roll->itemSlot, allowedMap);
roll->getLoot()->unlootedCount--;
player->StoreNewItem(dest, roll->itemid, true, item->randomBonusListId, item->GetAllowedLooters(), item->context, item->BonusListIDs);
}
@@ -1419,7 +1419,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap)
if (msg == EQUIP_ERR_OK)
{
item->is_looted = true;
- roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
+ roll->getLoot()->NotifyItemRemoved(roll->itemSlot, allowedMap);
roll->getLoot()->unlootedCount--;
player->StoreNewItem(dest, roll->itemid, true, item->randomBonusListId, item->GetAllowedLooters(), item->context, item->BonusListIDs);
}
@@ -1433,7 +1433,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap)
else if (rollvote == DISENCHANT)
{
item->is_looted = true;
- roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
+ roll->getLoot()->NotifyItemRemoved(roll->itemSlot, allowedMap);
roll->getLoot()->unlootedCount--;
player->UpdateCriteria(CriteriaType::CastSpell, 13262); // Disenchant
@@ -1445,7 +1445,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap)
player->AutoStoreLoot(disenchant->ID, LootTemplates_Disenchant, ItemContext::NONE, true);
else // If the player's inventory is full, send the disenchant result in a mail.
{
- Loot loot;
+ Loot loot(allowedMap, roll->getLoot()->GetOwnerGUID(), LOOT_DISENCHANTING);
loot.FillLoot(disenchant->ID, LootTemplates_Disenchant, player, true);
uint32 max_slot = loot.GetMaxSlotInLootFor(player);
diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp
index 08f43c41a25..7978f4be74c 100644
--- a/src/server/game/Handlers/LootHandler.cpp
+++ b/src/server/game/Handlers/LootHandler.cpp
@@ -235,7 +235,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPackets::Loot::LootMoney& /*packet
if (!loot)
continue;
- loot->NotifyMoneyRemoved();
+ loot->NotifyMoneyRemoved(player->GetMap());
if (shareMoney && player->GetGroup()) //item, pickpocket and players can be looted only single player
{
Group* group = player->GetGroup();
@@ -571,7 +571,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPackets::Loot::MasterLootItem
item.count = 0;
item.is_looted = true;
- loot->NotifyItemRemoved(slotid);
+ loot->NotifyItemRemoved(slotid, GetPlayer()->GetMap());
--loot->unlootedCount;
}
diff --git a/src/server/game/Loot/Loot.cpp b/src/server/game/Loot/Loot.cpp
index 7445d96dc71..70d3da25e8f 100644
--- a/src/server/game/Loot/Loot.cpp
+++ b/src/server/game/Loot/Loot.cpp
@@ -23,6 +23,7 @@
#include "Log.h"
#include "LootMgr.h"
#include "LootPackets.h"
+#include "Map.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Player.h"
@@ -125,7 +126,9 @@ void LootItem::AddAllowedLooter(const Player* player)
// --------- Loot ---------
//
-Loot::Loot() : gold(0), unlootedCount(0), roundRobinPlayer(), loot_type(LOOT_NONE), maxDuplicates(1), _itemContext(ItemContext::NONE)
+Loot::Loot(Map* map, ObjectGuid owner, LootType type) : gold(0), unlootedCount(0), roundRobinPlayer(), loot_type(type), maxDuplicates(1),
+ _guid(map ? ObjectGuid::Create<HighGuid::LootObject>(map->GetId(), 0, map->GenerateLowGuid<HighGuid::LootObject>()) : ObjectGuid::Empty),
+ _owner(owner), _itemContext(ItemContext::NONE)
{
}
@@ -159,35 +162,31 @@ void Loot::clear()
_itemContext = ItemContext::NONE;
}
-void Loot::NotifyItemRemoved(uint8 lootIndex)
+void Loot::NotifyItemRemoved(uint8 lootIndex, Map const* map)
{
// notify all players that are looting this that the item was removed
// convert the index to the slot the player sees
- GuidSet::iterator i_next;
- for (GuidSet::iterator i = PlayersLooting.begin(); i != PlayersLooting.end(); i = i_next)
+ for (auto itr = PlayersLooting.begin(); itr != PlayersLooting.end();)
{
- i_next = i;
- ++i_next;
- if (Player* player = ObjectAccessor::FindPlayer(*i))
- player->SendNotifyLootItemRemoved(GetGUID(), lootIndex);
+ if (Player* player = ObjectAccessor::GetPlayer(map, *itr))
+ {
+ player->SendNotifyLootItemRemoved(GetGUID(), GetOwnerGUID(), lootIndex);
+ ++itr;
+ }
else
- PlayersLooting.erase(i);
+ itr = PlayersLooting.erase(itr);
}
}
-void Loot::NotifyQuestItemRemoved(uint8 questIndex)
+void Loot::NotifyQuestItemRemoved(uint8 questIndex, Map const* map)
{
// when a free for all questitem is looted
// all players will get notified of it being removed
// (other questitems can be looted by each group member)
// bit inefficient but isn't called often
-
- GuidSet::iterator i_next;
- for (GuidSet::iterator i = PlayersLooting.begin(); i != PlayersLooting.end(); i = i_next)
+ for (auto itr = PlayersLooting.begin(); itr != PlayersLooting.end();)
{
- i_next = i;
- ++i_next;
- if (Player* player = ObjectAccessor::FindPlayer(*i))
+ if (Player* player = ObjectAccessor::GetPlayer(map, *itr))
{
NotNormalLootItemMap::const_iterator pq = PlayerQuestItems.find(player->GetGUID());
if (pq != PlayerQuestItems.end() && pq->second)
@@ -201,26 +200,28 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex)
break;
if (j < pql.size())
- player->SendNotifyLootItemRemoved(GetGUID(), items.size() + j);
+ player->SendNotifyLootItemRemoved(GetGUID(), GetOwnerGUID(), items.size() + j);
}
+
+ ++itr;
}
else
- PlayersLooting.erase(i);
+ itr = PlayersLooting.erase(itr);
}
}
-void Loot::NotifyMoneyRemoved()
+void Loot::NotifyMoneyRemoved(Map const* map)
{
// notify all players that are looting this that the money was removed
- GuidSet::iterator i_next;
- for (GuidSet::iterator i = PlayersLooting.begin(); i != PlayersLooting.end(); i = i_next)
+ for (auto itr = PlayersLooting.begin(); itr != PlayersLooting.end();)
{
- i_next = i;
- ++i_next;
- if (Player* player = ObjectAccessor::FindPlayer(*i))
+ if (Player* player = ObjectAccessor::GetPlayer(map, *itr))
+ {
player->SendNotifyLootMoneyRemoved(GetGUID());
+ ++itr;
+ }
else
- PlayersLooting.erase(i);
+ itr = PlayersLooting.erase(itr);
}
}
@@ -244,8 +245,6 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo
if (!lootOwner)
return false;
- lootOwnerGUID = lootOwner->GetGUID();
-
LootTemplate const* tab = store.GetLootFor(lootId);
if (!tab)
@@ -260,16 +259,16 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo
items.reserve(MAX_NR_LOOT_ITEMS);
quest_items.reserve(MAX_NR_QUEST_ITEMS);
- tab->Process(*this, store.IsRatesAllowed(), lootMode); // Processing is done there, callback via Loot::AddItem()
+ tab->Process(*this, store.IsRatesAllowed(), lootMode, 0, lootOwner); // Processing is done there, callback via Loot::AddItem()
// Setting access rights for group loot case
- Group* group = lootOwner->GetGroup();
+ Group const* group = lootOwner->GetGroup();
if (!personal && group)
{
roundRobinPlayer = lootOwner->GetGUID();
- for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
- if (Player* player = itr->GetSource()) // should actually be looted object instead of lootOwner but looter has to be really close so doesnt really matter
+ for (GroupReference const* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
+ if (Player const* player = itr->GetSource()) // should actually be looted object instead of lootOwner but looter has to be really close so doesnt really matter
if (player->IsInMap(lootOwner))
FillNotNormalLootFor(player, player->IsAtGroupRewardDistance(lootOwner));
@@ -288,7 +287,7 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo
}
// Inserts the item into the loot (called by LootTemplate processors)
-void Loot::AddItem(LootStoreItem const& item)
+void Loot::AddItem(LootStoreItem const& item, Player const* player)
{
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item.itemid);
if (!proto)
@@ -317,18 +316,15 @@ void Loot::AddItem(LootStoreItem const& item)
// In some cases, a dropped item should be visible/lootable only for some players in group
bool canSeeItemInLootWindow = false;
- if (Player* player = ObjectAccessor::FindPlayer(lootOwnerGUID))
+ if (Group const* group = player->GetGroup())
{
- if (Group* group = player->GetGroup())
- {
- for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
- if (Player* member = itr->GetSource())
- if (generatedLoot.AllowedForPlayer(member))
- canSeeItemInLootWindow = true;
- }
- else if (generatedLoot.AllowedForPlayer(player))
- canSeeItemInLootWindow = true;
+ for (GroupReference const* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
+ if (Player const* member = itr->GetSource())
+ if (generatedLoot.AllowedForPlayer(member))
+ canSeeItemInLootWindow = true;
}
+ else if (generatedLoot.AllowedForPlayer(player))
+ canSeeItemInLootWindow = true;
if (!canSeeItemInLootWindow)
continue;
@@ -690,7 +686,7 @@ void Loot::BuildLootResponse(WorldPackets::Loot::LootResponse& packet, Player* v
}
}
-void Loot::FillNotNormalLootFor(Player* player, bool presentAtLooting)
+void Loot::FillNotNormalLootFor(Player const* player, bool presentAtLooting)
{
ObjectGuid plguid = player->GetGUID();
@@ -707,7 +703,7 @@ void Loot::FillNotNormalLootFor(Player* player, bool presentAtLooting)
FillNonQuestNonFFAConditionalLoot(player, presentAtLooting);
}
-NotNormalLootItemList* Loot::FillFFALoot(Player* player)
+NotNormalLootItemList* Loot::FillFFALoot(Player const* player)
{
NotNormalLootItemList* ql = new NotNormalLootItemList();
@@ -730,7 +726,7 @@ NotNormalLootItemList* Loot::FillFFALoot(Player* player)
return ql;
}
-NotNormalLootItemList* Loot::FillQuestLoot(Player* player)
+NotNormalLootItemList* Loot::FillQuestLoot(Player const* player)
{
if (items.size() == MAX_NR_LOOT_ITEMS)
return nullptr;
@@ -768,7 +764,7 @@ NotNormalLootItemList* Loot::FillQuestLoot(Player* player)
return ql;
}
-NotNormalLootItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player* player, bool presentAtLooting)
+NotNormalLootItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player const* player, bool presentAtLooting)
{
NotNormalLootItemList* ql = new NotNormalLootItemList();
diff --git a/src/server/game/Loot/Loot.h b/src/server/game/Loot/Loot.h
index eaef0bba362..d003df3be9f 100644
--- a/src/server/game/Loot/Loot.h
+++ b/src/server/game/Loot/Loot.h
@@ -30,6 +30,7 @@
class Item;
class LootStore;
+class Map;
class Player;
struct Loot;
struct LootStoreItem;
@@ -237,15 +238,14 @@ struct TC_GAME_API Loot
uint32 gold;
uint8 unlootedCount;
ObjectGuid roundRobinPlayer; // GUID of the player having the Round-Robin ownership for the loot. If 0, round robin owner has released.
- ObjectGuid lootOwnerGUID;
LootType loot_type; // required for achievement system
uint8 maxDuplicates; // Max amount of items with the same entry that can drop (default is 1; on 25 man raid mode 3)
- Loot();
+ explicit Loot(Map* map, ObjectGuid owner, LootType type);
~Loot();
- ObjectGuid const& GetGUID() const { return _GUID; }
- void SetGUID(ObjectGuid const& guid) { _GUID = guid; }
+ ObjectGuid const& GetGUID() const { return _guid; }
+ ObjectGuid const& GetOwnerGUID() const { return _owner; }
// if loot becomes invalid this reference is used to inform the listener
void addLootValidatorRef(LootValidatorRef* pLootValidatorRef)
@@ -258,9 +258,9 @@ struct TC_GAME_API Loot
bool empty() const { return items.empty() && gold == 0; }
bool isLooted() const { return gold == 0 && unlootedCount == 0; }
- void NotifyItemRemoved(uint8 lootIndex);
- void NotifyQuestItemRemoved(uint8 questIndex);
- void NotifyMoneyRemoved();
+ void NotifyItemRemoved(uint8 lootIndex, Map const* map);
+ void NotifyQuestItemRemoved(uint8 questIndex, Map const* map);
+ void NotifyMoneyRemoved(Map const* map);
void AddLooter(ObjectGuid GUID) { PlayersLooting.insert(GUID); }
void RemoveLooter(ObjectGuid GUID) { PlayersLooting.erase(GUID); }
@@ -268,7 +268,7 @@ struct TC_GAME_API Loot
bool FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bool personal, bool noEmptyError = false, uint16 lootMode = LOOT_MODE_DEFAULT, ItemContext context = ItemContext::NONE);
// Inserts the item into the loot (called by LootTemplate processors)
- void AddItem(LootStoreItem const & item);
+ void AddItem(LootStoreItem const& item, Player const* player);
LootItem const* GetItemInSlot(uint32 lootSlot) const;
LootItem* LootItemInSlot(uint32 lootslot, Player* player, NotNormalLootItem** qitem = nullptr, NotNormalLootItem** ffaitem = nullptr, NotNormalLootItem** conditem = nullptr);
@@ -282,10 +282,10 @@ struct TC_GAME_API Loot
private:
- void FillNotNormalLootFor(Player* player, bool presentAtLooting);
- NotNormalLootItemList* FillFFALoot(Player* player);
- NotNormalLootItemList* FillQuestLoot(Player* player);
- NotNormalLootItemList* FillNonQuestNonFFAConditionalLoot(Player* player, bool presentAtLooting);
+ void FillNotNormalLootFor(Player const* player, bool presentAtLooting);
+ NotNormalLootItemList* FillFFALoot(Player const* player);
+ NotNormalLootItemList* FillQuestLoot(Player const* player);
+ NotNormalLootItemList* FillNonQuestNonFFAConditionalLoot(Player const* player, bool presentAtLooting);
GuidSet PlayersLooting;
NotNormalLootItemMap PlayerQuestItems;
@@ -296,7 +296,8 @@ private:
LootValidatorRefManager i_LootValidatorRefManager;
// Loot GUID
- ObjectGuid _GUID;
+ ObjectGuid _guid;
+ ObjectGuid _owner; // The WorldObject that holds this loot
ItemContext _itemContext;
};
diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp
index 9247d2efdc6..b37d22f10eb 100644
--- a/src/server/game/Loot/LootMgr.cpp
+++ b/src/server/game/Loot/LootMgr.cpp
@@ -87,7 +87,7 @@ class LootTemplate::LootGroup // A set of loot def
bool HasQuestDrop() const; // True if group includes at least 1 quest drop entry
bool HasQuestDropForPlayer(Player const* player) const;
// The same for active quests of the player
- void Process(Loot& loot, uint16 lootMode) const; // Rolls an item from the group (if any) and adds the item to the loot
+ void Process(Loot& loot, uint16 lootMode, Player const* player) const; // Rolls an item from the group (if any) and adds the item to the loot
float RawTotalChance() const; // Overall chance for the group (without equal chanced items)
float TotalChance() const; // Overall chance for the group
@@ -443,10 +443,10 @@ void LootTemplate::LootGroup::CopyConditions(ConditionContainer /*conditions*/)
}
// Rolls an item from the group (if any takes its chance) and adds the item to the loot
-void LootTemplate::LootGroup::Process(Loot& loot, uint16 lootMode) const
+void LootTemplate::LootGroup::Process(Loot& loot, uint16 lootMode, Player const* player) const
{
if (LootStoreItem const* item = Roll(loot, lootMode))
- loot.AddItem(*item);
+ loot.AddItem(*item, player);
}
// Overall chance for the group without equal chanced items
@@ -563,7 +563,7 @@ void LootTemplate::CopyConditions(LootItem* li) const
}
// Rolls for every item in the template and adds the rolled items the the loot
-void LootTemplate::Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId) const
+void LootTemplate::Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId, Player const* player) const
{
if (groupId) // Group reference uses own processing of the group
{
@@ -573,7 +573,7 @@ void LootTemplate::Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId
if (!Groups[groupId - 1])
return;
- Groups[groupId - 1]->Process(loot, lootMode);
+ Groups[groupId - 1]->Process(loot, lootMode, player);
return;
}
@@ -587,7 +587,7 @@ void LootTemplate::Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId
if (!item->Roll(rate))
continue; // Bad luck for the entry
- if (item->reference > 0) // References processing
+ if (item->reference > 0) // References processing
{
LootTemplate const* Referenced = LootTemplates_Reference.GetLootFor(item->reference);
if (!Referenced)
@@ -595,16 +595,16 @@ void LootTemplate::Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId
uint32 maxcount = uint32(float(item->maxcount) * sWorld->getRate(RATE_DROP_ITEM_REFERENCED_AMOUNT));
for (uint32 loop = 0; loop < maxcount; ++loop) // Ref multiplicator
- Referenced->Process(loot, rate, lootMode, item->groupid);
+ Referenced->Process(loot, rate, lootMode, item->groupid, player);
}
else // Plain entries (not a reference, not grouped)
- loot.AddItem(*item); // Chance is already checked, just add
+ loot.AddItem(*item, player); // Chance is already checked, just add
}
// Now processing groups
for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i)
if (LootGroup* group = *i)
- group->Process(loot, lootMode);
+ group->Process(loot, lootMode, player);
}
// True if template includes at least 1 quest drop entry
diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h
index 5aba7928fdb..b6161aed051 100644
--- a/src/server/game/Loot/LootMgr.h
+++ b/src/server/game/Loot/LootMgr.h
@@ -108,7 +108,7 @@ class TC_GAME_API LootTemplate
// Adds an entry to the group (at loading stage)
void AddEntry(LootStoreItem* item);
// Rolls for every item in the template and adds the rolled items the the loot
- void Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId = 0) const;
+ void Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId, Player const* player) const;
void CopyConditions(ConditionContainer const& conditions);
void CopyConditions(LootItem* li) const;
diff --git a/src/server/game/Mails/Mail.cpp b/src/server/game/Mails/Mail.cpp
index 7f633f5c49c..f6eaf319c9d 100644
--- a/src/server/game/Mails/Mail.cpp
+++ b/src/server/game/Mails/Mail.cpp
@@ -113,7 +113,7 @@ void MailDraft::prepareItems(Player* receiver, CharacterDatabaseTransaction tran
if (m_mailTemplateId == 123)
m_money = 1000000;
- Loot mailLoot;
+ Loot mailLoot(nullptr, ObjectGuid::Empty, LOOT_NONE);
// can be empty
mailLoot.FillLoot(m_mailTemplateId, LootTemplates_Mail, receiver, true, true, LOOT_MODE_DEFAULT, ItemContext::NONE);