From 8725eec9c1c15f3e76bd9d524d4a5d8d0b3f0a44 Mon Sep 17 00:00:00 2001 From: xinef1 Date: Sat, 4 Feb 2017 14:58:50 +0100 Subject: [PATCH] Core/Loot: Only allow the roll winner to loot the item he won in case it cannot be added to inventory instantly (full or any other reason) (#19037) (cherry-picked from ab6ac42bf032b723167c37caed875c76a1295ec6) --- src/server/game/Entities/Player/Player.cpp | 7 +++++++ src/server/game/Groups/Group.cpp | 8 +++++--- src/server/game/Loot/Loot.cpp | 8 ++++++++ src/server/game/Loot/Loot.h | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 6131c40aca01b..5ec2a72d2ad12 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -25751,6 +25751,13 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot, AELootResult* aeResult/* return; } + // dont allow protected item to be looted by someone else + if (!item->rollWinnerGUID.IsEmpty() && item->rollWinnerGUID != GetGUID()) + { + SendLootRelease(GetLootGUID()); + return; + } + ItemPosCountVec dest; InventoryResult msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item->itemid, item->count); if (msg == EQUIP_ERR_OK) diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 184bd97e17d5a..7321244578c8b 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -1283,7 +1283,8 @@ void Group::CountTheRoll(Rolls::iterator rollI) else { item->is_blocked = false; - player->SendEquipError(msg, NULL, NULL, roll->itemid); + item->rollWinnerGUID = player->GetGUID(); + player->SendEquipError(msg, nullptr, nullptr, roll->itemid); } } } @@ -1335,7 +1336,8 @@ void Group::CountTheRoll(Rolls::iterator rollI) else { item->is_blocked = false; - player->SendEquipError(msg, NULL, NULL, roll->itemid); + item->rollWinnerGUID = player->GetGUID(); + player->SendEquipError(msg, nullptr, nullptr, roll->itemid); } } else if (rollvote == DISENCHANT) @@ -1360,7 +1362,7 @@ void Group::CountTheRoll(Rolls::iterator rollI) for (uint32 i = 0; i < max_slot; ++i) { LootItem* lootItem = loot.LootItemInSlot(i, player); - player->SendEquipError(msg, NULL, NULL, lootItem->itemid); + player->SendEquipError(msg, nullptr, nullptr, lootItem->itemid); player->SendItemRetrievalMail(lootItem->itemid, lootItem->count); } } diff --git a/src/server/game/Loot/Loot.cpp b/src/server/game/Loot/Loot.cpp index 681f441ea84af..e9a4e0c47577e 100644 --- a/src/server/game/Loot/Loot.cpp +++ b/src/server/game/Loot/Loot.cpp @@ -55,6 +55,7 @@ LootItem::LootItem(LootStoreItem const& li) is_blocked = 0; is_underthreshold = 0; is_counted = 0; + rollWinnerGUID = ObjectGuid::Empty; canSave = true; } @@ -518,6 +519,13 @@ void Loot::BuildLootResponse(WorldPackets::Loot::LootResponse& packet, Player* v // => item is lootable slot_type = LOOT_SLOT_TYPE_ALLOW_LOOT; } + else if (!items[i].rollWinnerGUID.IsEmpty()) + { + if (items[i].rollWinnerGUID == viewer->GetGUID()) + slot_type = LOOT_SLOT_TYPE_OWNER; + else + continue; + } else // item shall not be displayed. continue; diff --git a/src/server/game/Loot/Loot.h b/src/server/game/Loot/Loot.h index a2c30e42a0cee..f9da5537806c0 100644 --- a/src/server/game/Loot/Loot.h +++ b/src/server/game/Loot/Loot.h @@ -140,6 +140,7 @@ struct TC_GAME_API LootItem uint8 context; ConditionContainer conditions; // additional loot condition GuidSet allowedGUIDs; + ObjectGuid rollWinnerGUID; // Stores the guid of person who won loot, if his bags are full only he can see the item in loot list! uint8 count : 8; bool is_looted : 1; bool is_blocked : 1;