mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-30 00:53:46 +00:00
fix(Core/Loot): properly save and load from DB loot from items (#6151)
- Closes #5472 - Closes https://github.com/chromiecraft/chromiecraft/issues/456
This commit is contained in:
@@ -1375,18 +1375,93 @@ void LootTemplate::CopyConditions(ConditionList conditions)
|
||||
group->CopyConditions(conditions);
|
||||
}
|
||||
|
||||
void LootTemplate::CopyConditions(LootItem* li) const
|
||||
bool LootTemplate::CopyConditions(LootItem* li) const
|
||||
{
|
||||
// Copies the conditions list from a template item to a LootItem
|
||||
for (LootStoreItemList::const_iterator _iter = Entries.begin(); _iter != Entries.end(); ++_iter)
|
||||
{
|
||||
LootStoreItem* item = *_iter;
|
||||
if (item->itemid != li->itemid)
|
||||
if (item->reference)
|
||||
{
|
||||
if (LootTemplate const* Referenced = LootTemplates_Reference.GetLootFor(item->reference))
|
||||
{
|
||||
if (Referenced->CopyConditions(li))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item->itemid != li->itemid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
li->conditions = item->conditions;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (LootGroups::const_iterator groupItr = Groups.begin(); groupItr != Groups.end(); ++groupItr)
|
||||
{
|
||||
LootGroup* group = *groupItr;
|
||||
if (!group)
|
||||
continue;
|
||||
|
||||
li->conditions = item->conditions;
|
||||
break;
|
||||
LootStoreItemList* itemList = group->GetExplicitlyChancedItemList();
|
||||
for (LootStoreItemList::iterator i = itemList->begin(); i != itemList->end(); ++i)
|
||||
{
|
||||
LootStoreItem* item = *i;
|
||||
if (item->reference)
|
||||
{
|
||||
if (LootTemplate const* Referenced = LootTemplates_Reference.GetLootFor(item->reference))
|
||||
{
|
||||
if (Referenced->CopyConditions(li))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item->itemid != li->itemid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
li->conditions = item->conditions;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
itemList = group->GetEqualChancedItemList();
|
||||
for (LootStoreItemList::iterator i = itemList->begin(); i != itemList->end(); ++i)
|
||||
{
|
||||
LootStoreItem* item = *i;
|
||||
if (item->reference)
|
||||
{
|
||||
if (LootTemplate const* Referenced = LootTemplates_Reference.GetLootFor(item->reference))
|
||||
{
|
||||
if (Referenced->CopyConditions(li))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item->itemid != li->itemid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
li->conditions = item->conditions;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Rolls for every item in the template and adds the rolled items the the loot
|
||||
|
||||
Reference in New Issue
Block a user