I actually like where you placed the test inside EquipItem(), in case of issue I'd better have a stack split for nothing that some item unequipped for nothing.
Maybe the check in SplitStack() that the item is indeed part of the container can catch stupid bugs later and can stay in, but other than that I'm totally fine with your fix.
Code: Select all
diff --git a/Assets/Scripts/Game/Items/ItemCollection.cs b/Assets/Scripts/Game/Items/ItemCollection.cs
index 64ecf818..63a18e53 100644
--- a/Assets/Scripts/Game/Items/ItemCollection.cs
+++ b/Assets/Scripts/Game/Items/ItemCollection.cs
@@ -260,7 +260,7 @@ namespace DaggerfallWorkshop.Game.Items
/// <param name="numberToPick">Number of items to pick</param>
public DaggerfallUnityItem SplitStack(DaggerfallUnityItem stack, int numberToPick)
{
- if (!stack.IsAStack() || numberToPick < 1 || numberToPick > stack.stackCount)
+ if (!stack.IsAStack() || numberToPick < 1 || numberToPick > stack.stackCount || !Contains(stack))
return null;
if (numberToPick == stack.stackCount)
return stack;