Fixed collection modification exceptions during item removal. Added unit tests to ensure functionality.

This commit is contained in:
bluextx
2025-07-24 21:31:03 +03:00
parent 1f6231ce6b
commit 4095da3e2b
2 changed files with 131 additions and 7 deletions
@@ -169,14 +169,13 @@ public class InRaidHelper(
/// <param name="sessionId">Player/Session id</param>
public void DeleteInventory(PmcData pmcData, MongoId sessionId)
{
// Get inventory item ids to remove from players profile
var itemIdsToDeleteFromProfile = GetInventoryItemsLostOnDeath(pmcData)
.Select(item => item.Id)
.ToList();
foreach (var itemIdToDelete in itemIdsToDeleteFromProfile)
// Items inside containers are handled as part of function
// Get inventory items to remove from players profile
var itemsToDeleteFromProfile = GetInventoryItemsLostOnDeath(pmcData).ToList();
foreach (var itemToDelete in itemsToDeleteFromProfile)
{
inventoryHelper.RemoveItem(pmcData, itemIdToDelete, sessionId);
// Items inside containers are handled as part of function
inventoryHelper.RemoveItem(pmcData, itemToDelete.Id, sessionId);
}
// Remove contents of fast panel