Updated EnsureItemHasValidStackCount to be an extension method

This commit is contained in:
Chomp
2025-09-08 12:48:06 +01:00
parent 88ec0d7240
commit 8177093b16
2 changed files with 21 additions and 21 deletions
@@ -856,8 +856,8 @@ public class InventoryController(
return; return;
} }
EnsureItemHasValidStackCount(destinationItem); destinationItem.EnsureItemHasValidStackCount();
EnsureItemHasValidStackCount(sourceItem); sourceItem.EnsureItemHasValidStackCount();
// Merging non Found in Raid (SpawnedInSession) items with FiR item causing result to be not Found in Raid // Merging non Found in Raid (SpawnedInSession) items with FiR item causing result to be not Found in Raid
if (!sourceItem.Upd.SpawnedInSession.GetValueOrDefault(false) && destinationItem.Upd.SpawnedInSession.GetValueOrDefault(false)) if (!sourceItem.Upd.SpawnedInSession.GetValueOrDefault(false) && destinationItem.Upd.SpawnedInSession.GetValueOrDefault(false))
@@ -881,25 +881,6 @@ public class InventoryController(
} }
} }
/// <summary>
/// Ensure an item has a upd object with a stack count of 1
/// </summary>
/// <param name="item">Item to check</param>
protected void EnsureItemHasValidStackCount(Item item)
{
if (item.Upd is null)
{
item.AddUpd();
item.Upd.StackObjectsCount = 1;
}
if (item.Upd.StackObjectsCount is null or 0)
{
// Items pulled out of raid can have no stack count, default to 1
item.Upd.StackObjectsCount = 1;
}
}
/// <summary> /// <summary>
/// Split Item stack - 1 stack into 2 /// Split Item stack - 1 stack into 2
/// </summary> /// </summary>
@@ -530,4 +530,23 @@ public static class ItemExtensions
return true; return true;
} }
/// <summary>
/// Ensure an item has an upd object with a stack count of 1
/// </summary>
/// <param name="item">Item to check</param>
public static void EnsureItemHasValidStackCount(this Item item)
{
if (item.Upd is null)
{
item.AddUpd();
item.Upd.StackObjectsCount = 1;
}
if (item.Upd.StackObjectsCount is null or 0)
{
// Items pulled out of raid can have no stack count, default to 1
item.Upd.StackObjectsCount = 1;
}
}
} }