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:
hondacrx
2024-02-06 16:11:02 -05:00
parent 1fc1153f67
commit f3993521bc
2 changed files with 22 additions and 1 deletions
+21 -1
View File
@@ -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;