Core/Loot: Fixed items some not being lootable on second opening of a lootable item
Port From (https://github.com/TrinityCore/TrinityCore/commit/00cb775558d19209630850bb148748ed4c3836c7)
This commit is contained in:
@@ -7,6 +7,7 @@ using Framework.Database;
|
||||
using Game.Entities;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Game.Loots
|
||||
@@ -127,6 +128,25 @@ namespace Game.Loots
|
||||
}
|
||||
}
|
||||
|
||||
if (!loot.items.Empty())
|
||||
{
|
||||
loot.items = loot.items.OrderBy(p => p.LootListId).ToList();
|
||||
|
||||
int lootListId = 0;
|
||||
// add dummy loot items to ensure items are indexable by their LootListId
|
||||
while (loot.items.Count <= loot.items.Last().LootListId)
|
||||
{
|
||||
if (loot.items[lootListId].LootListId != lootListId)
|
||||
{
|
||||
loot.items.Add(loot.items[lootListId]);
|
||||
loot.items.Last().LootListId = (uint)lootListId;
|
||||
loot.items.Last().is_looted = true;
|
||||
}
|
||||
|
||||
++lootListId;
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the item if it has loot so it won't be generated again on open
|
||||
item.loot = loot;
|
||||
item.m_lootGenerated = true;
|
||||
@@ -280,7 +300,7 @@ namespace Game.Loots
|
||||
var bounds = _lootItems.LookupByKey(itemId);
|
||||
foreach (var itr in bounds)
|
||||
{
|
||||
if (itr.Count == count)
|
||||
if (itr.ItemIndex == itemIndex)
|
||||
{
|
||||
_lootItems.Remove(itr.ItemId);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user