mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-03-09 10:40:28 +00:00
fix(Core/Loot): Allow References to be grouped like Items (#24275)
This commit is contained in:
@@ -376,9 +376,9 @@ bool LootStoreItem::IsValid(LootStore const& store, uint32 entry) const
|
||||
{
|
||||
if (needs_quest)
|
||||
LOG_ERROR("sql.sql", "Table '{}' Entry {} Item {}: quest required will be ignored", store.GetName(), entry, itemid);
|
||||
else if (chance == 0) // no chance for the reference
|
||||
else if (chance == 0 && groupid == 0)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table '{}' Entry {} Item {}: zero chance is specified for a reference, skipped", store.GetName(), entry, itemid);
|
||||
LOG_ERROR("sql.sql", "Table '{}' Entry {} Item {}: zero chance is specified for an ungrouped reference, skipped", store.GetName(), entry, itemid);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1340,7 +1340,7 @@ bool LootTemplate::LootGroup::HasQuestDrop(LootTemplateMap const& store) const
|
||||
continue; // Error message [should be] already printed at loading stage
|
||||
}
|
||||
|
||||
if (Referenced->second->HasQuestDrop(store, item->groupid))
|
||||
if (Referenced->second->HasQuestDrop(store))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1362,7 +1362,7 @@ bool LootTemplate::LootGroup::HasQuestDrop(LootTemplateMap const& store) const
|
||||
continue; // Error message [should be] already printed at loading stage
|
||||
}
|
||||
|
||||
if (Referenced->second->HasQuestDrop(store, item->groupid))
|
||||
if (Referenced->second->HasQuestDrop(store))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1390,7 +1390,7 @@ bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const* player, LootTe
|
||||
continue; // Error message already printed at loading stage
|
||||
}
|
||||
|
||||
if (Referenced->second->HasQuestDropForPlayer(store, player, item->groupid))
|
||||
if (Referenced->second->HasQuestDropForPlayer(store, player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1412,7 +1412,7 @@ bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const* player, LootTe
|
||||
continue; // Error message already printed at loading stage
|
||||
}
|
||||
|
||||
if (Referenced->second->HasQuestDropForPlayer(store, player, item->groupid))
|
||||
if (Referenced->second->HasQuestDropForPlayer(store, player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1451,7 +1451,7 @@ void LootTemplate::LootGroup::Process(Loot& loot, Player const* player, LootStor
|
||||
for (uint32 loop = 0; loop < maxcount; ++loop) // Ref multiplicator
|
||||
// This reference needs to be processed further, but it is marked isTopLevel=false so that any groups inside
|
||||
// the reference are not multiplied by Rate.Drop.Item.GroupAmount
|
||||
Referenced->Process(loot, store, lootMode, player, item->groupid, false);
|
||||
Referenced->Process(loot, store, lootMode, player, 0, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1561,9 +1561,7 @@ LootTemplate::~LootTemplate()
|
||||
// Adds an entry to the group (at loading stage)
|
||||
void LootTemplate::AddEntry(LootStoreItem* item)
|
||||
{
|
||||
// `item->reference` > 0 --> Reference is counted as a normal and non grouped entry
|
||||
// `item->reference` < 0 --> Reference is counted as grouped entry within shared groupid
|
||||
if (item->groupid > 0 && item->reference <= 0) // Group and grouped reference
|
||||
if (item->groupid > 0) // Group and grouped reference
|
||||
{
|
||||
if (item->groupid >= Groups.size())
|
||||
{
|
||||
@@ -1768,19 +1766,8 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, uint16 lootMode,
|
||||
}
|
||||
|
||||
// True if template includes at least 1 quest drop entry
|
||||
bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) const
|
||||
bool LootTemplate::HasQuestDrop(LootTemplateMap const& store) const
|
||||
{
|
||||
if (groupId) // Group reference
|
||||
{
|
||||
if (groupId > Groups.size())
|
||||
return false; // Error message [should be] already printed at loading stage
|
||||
|
||||
if (!Groups[groupId - 1])
|
||||
return false;
|
||||
|
||||
return Groups[groupId - 1]->HasQuestDrop(store);
|
||||
}
|
||||
|
||||
for (LootStoreItemList::const_iterator i = Entries.begin(); i != Entries.end(); ++i)
|
||||
{
|
||||
LootStoreItem* item = *i;
|
||||
@@ -1790,7 +1777,7 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con
|
||||
if (Referenced == store.end())
|
||||
continue; // Error message [should be] already printed at loading stage
|
||||
|
||||
if (Referenced->second->HasQuestDrop(store, item->groupid))
|
||||
if (Referenced->second->HasQuestDrop(store))
|
||||
return true;
|
||||
}
|
||||
else if (item->needs_quest)
|
||||
@@ -1813,19 +1800,8 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con
|
||||
}
|
||||
|
||||
// True if template includes at least 1 quest drop for an active quest of the player
|
||||
bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player const* player, uint8 groupId) const
|
||||
bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player const* player) const
|
||||
{
|
||||
if (groupId) // Group reference
|
||||
{
|
||||
if (groupId > Groups.size())
|
||||
return false; // Error message already printed at loading stage
|
||||
|
||||
if (!Groups[groupId - 1])
|
||||
return false;
|
||||
|
||||
return Groups[groupId - 1]->HasQuestDropForPlayer(player, store);
|
||||
}
|
||||
|
||||
// Checking non-grouped entries
|
||||
for (LootStoreItemList::const_iterator i = Entries.begin(); i != Entries.end(); ++i)
|
||||
{
|
||||
@@ -1835,7 +1811,7 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co
|
||||
LootTemplateMap::const_iterator Referenced = store.find(std::abs(item->reference));
|
||||
if (Referenced == store.end())
|
||||
continue; // Error message already printed at loading stage
|
||||
if (Referenced->second->HasQuestDropForPlayer(store, player, item->groupid))
|
||||
if (Referenced->second->HasQuestDropForPlayer(store, player))
|
||||
return true;
|
||||
}
|
||||
else if (player->HasQuestForItem(item->itemid))
|
||||
|
||||
@@ -258,9 +258,9 @@ public:
|
||||
bool CopyConditions(LootItem* li, uint32 conditionLootId = 0) const;
|
||||
|
||||
// True if template includes at least 1 quest drop entry
|
||||
[[nodiscard]] bool HasQuestDrop(LootTemplateMap const& store, uint8 groupId = 0) const;
|
||||
[[nodiscard]] bool HasQuestDrop(LootTemplateMap const& store) const;
|
||||
// True if template includes at least 1 quest drop for an active quest of the player
|
||||
bool HasQuestDropForPlayer(LootTemplateMap const& store, Player const* player, uint8 groupId = 0) const;
|
||||
bool HasQuestDropForPlayer(LootTemplateMap const& store, Player const* player) const;
|
||||
|
||||
// Checks integrity of the template
|
||||
void Verify(LootStore const& store, uint32 Id) const;
|
||||
|
||||
Reference in New Issue
Block a user