diff options
| author | Shauren <shauren.trinity@gmail.com> | 2022-10-06 18:33:44 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-10-06 18:33:44 +0200 |
| commit | 9ce47e6809eecc891904e272b368596fdc55e6a4 (patch) | |
| tree | e8e4f2df29ecf222f5666e6bc7dd23e6d6f22b58 /src/server/game/Loot | |
| parent | dc393e6ca646a093d1bb9937bdef57b5ee77d1c8 (diff) | |
Core/Loot: Prevent looting bosses by players that have already completed that encounter
Diffstat (limited to 'src/server/game/Loot')
| -rw-r--r-- | src/server/game/Loot/Loot.cpp | 26 | ||||
| -rw-r--r-- | src/server/game/Loot/Loot.h | 7 | ||||
| -rw-r--r-- | src/server/game/Loot/LootItemStorage.cpp | 2 |
3 files changed, 25 insertions, 10 deletions
diff --git a/src/server/game/Loot/Loot.cpp b/src/server/game/Loot/Loot.cpp index 91eac407aaa..d67f9ea55d9 100644 --- a/src/server/game/Loot/Loot.cpp +++ b/src/server/game/Loot/Loot.cpp @@ -68,7 +68,7 @@ LootItem& LootItem::operator=(LootItem&&) noexcept = default; LootItem::~LootItem() = default; // Basic checks for player/item compatibility - if false no chance to see the item in the loot -bool LootItem::AllowedForPlayer(Player const* player, bool isGivenByMasterLooter) const +bool LootItem::AllowedForPlayer(Player const* player, Loot const& loot) const { // DB conditions check if (!sConditionMgr->IsObjectMeetToConditions(const_cast<Player*>(player), conditions)) @@ -86,10 +86,8 @@ bool LootItem::AllowedForPlayer(Player const* player, bool isGivenByMasterLooter return false; // Master looter can see all items even if the character can't loot them - if (!isGivenByMasterLooter && player->GetGroup() && player->GetGroup()->GetMasterLooterGuid() == player->GetGUID()) - { + if (loot.GetLootMethod() == MASTER_LOOT && follow_loot_rules && player->GetGroup() && player->GetGroup()->GetMasterLooterGuid() == player->GetGUID()) return true; - } // Don't allow loot for players without profession or those who already know the recipe if (pProto->HasFlag(ITEM_FLAG_HIDE_UNUSABLE_RECIPE)) @@ -132,6 +130,11 @@ void LootItem::AddAllowedLooter(const Player* player) allowedGUIDs.insert(player->GetGUID()); } +bool LootItem::HasAllowedLooter(ObjectGuid const& looter) const +{ + return allowedGUIDs.find(looter) != allowedGUIDs.end(); +} + Optional<LootSlotType> LootItem::GetUiTypeForPlayer(Player const* player, Loot const& loot) const { if (is_looted) @@ -405,7 +408,7 @@ bool LootRoll::TryToStart(Map* map, Loot& loot, uint32 lootListId, uint16 enchan for (ObjectGuid allowedLooter : m_lootItem->GetAllowedLooters()) { Player* plr = ObjectAccessor::GetPlayer(m_map, allowedLooter); - if (!plr || !m_lootItem->AllowedForPlayer(plr)) // check if player meet the condition to be able to roll this item + if (!plr || !m_lootItem->HasAllowedLooter(plr->GetGUID())) // check if player meet the condition to be able to roll this item { m_rollVoteMap[allowedLooter].Vote = RollVote::NotValid; continue; @@ -739,6 +742,11 @@ void Loot::OnLootOpened(Map* map, ObjectGuid looter) } } +bool Loot::HasAllowedLooter(ObjectGuid const& looter) const +{ + return _allowedLooters.find(looter) != _allowedLooters.end(); +} + void Loot::generateMoneyLoot(uint32 minAmount, uint32 maxAmount) { if (maxAmount > 0) @@ -858,7 +866,7 @@ bool Loot::AutoStore(Player* player, uint8 bag, uint8 slot, bool broadcast, bool if (!lootItem || lootItem->is_looted) continue; - if (!lootItem->AllowedForPlayer(player)) + if (!lootItem->HasAllowedLooter(player->GetGUID())) continue; if (lootItem->is_blocked) @@ -1012,6 +1020,10 @@ void Loot::Update() void Loot::FillNotNormalLootFor(Player const* player) { + if (_dungeonEncounterId) + if (player->IsLockedToDungeonEncounter(_dungeonEncounterId)) + return; + ObjectGuid plguid = player->GetGUID(); _allowedLooters.insert(plguid); @@ -1019,7 +1031,7 @@ void Loot::FillNotNormalLootFor(Player const* player) for (LootItem& item : items) { - if (!item.AllowedForPlayer(player)) + if (!item.AllowedForPlayer(player, *this)) continue; item.AddAllowedLooter(player); diff --git a/src/server/game/Loot/Loot.h b/src/server/game/Loot/Loot.h index fda1cb0e9c7..12f3d559f05 100644 --- a/src/server/game/Loot/Loot.h +++ b/src/server/game/Loot/Loot.h @@ -192,10 +192,11 @@ struct TC_GAME_API LootItem LootItem& operator=(LootItem&&) noexcept; ~LootItem(); - // Basic checks for player/item compatibility - if false no chance to see the item in the loot - bool AllowedForPlayer(Player const* player, bool isGivenByMasterLooter = false) const; + // Basic checks for player/item compatibility - if false no chance to see the item in the loot - used only for loot generation + bool AllowedForPlayer(Player const* player, Loot const& loot) const; void AddAllowedLooter(Player const* player); GuidSet const& GetAllowedLooters() const { return allowedGUIDs; } + bool HasAllowedLooter(ObjectGuid const& looter) const; Optional<LootSlotType> GetUiTypeForPlayer(Player const* player, Loot const& loot) const; }; @@ -299,6 +300,8 @@ struct TC_GAME_API Loot void AddLooter(ObjectGuid GUID) { PlayersLooting.insert(GUID); } void RemoveLooter(ObjectGuid GUID) { PlayersLooting.erase(GUID); } + bool HasAllowedLooter(ObjectGuid const& looter) const; + void generateMoneyLoot(uint32 minAmount, uint32 maxAmount); bool FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bool personal, bool noEmptyError = false, uint16 lootMode = LOOT_MODE_DEFAULT, ItemContext context = ItemContext::NONE); diff --git a/src/server/game/Loot/LootItemStorage.cpp b/src/server/game/Loot/LootItemStorage.cpp index 5edb9f7e9fd..c464b6ee914 100644 --- a/src/server/game/Loot/LootItemStorage.cpp +++ b/src/server/game/Loot/LootItemStorage.cpp @@ -272,7 +272,7 @@ void LootItemStorage::AddNewStoredLoot(uint64 containerId, Loot* loot, Player* p // saved to the DB that the player never should have gotten. This check prevents that, so that only // items that the player should get in loot are in the DB. // IE: Horde items are not saved to the DB for Ally players. - if (!li.AllowedForPlayer(player)) + if (!li.AllowedForPlayer(player, *loot)) continue; // Don't save currency tokens |
