diff --git a/Libraries/SPTarkov.Server.Core/Helpers/ContainerHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/ContainerHelper.cs
index 9e7cd1ba..57a718a1 100644
--- a/Libraries/SPTarkov.Server.Core/Helpers/ContainerHelper.cs
+++ b/Libraries/SPTarkov.Server.Core/Helpers/ContainerHelper.cs
@@ -10,15 +10,15 @@ public class ContainerHelper
/// Finds a slot for an item in a given 2D container map
///
/// List of container with positions filled/free
- /// Width of item
- /// Height of item
+ /// Width of item
+ /// Height of item
/// Location to place item in container
- public FindSlotResult FindSlotForItem(int[][] container2D, int itemWidth, int itemHeight)
+ public FindSlotResult FindSlotForItem(int[][] container2D, int? itemX, int? itemY)
{
// Assume not rotated
var rotation = false;
- var minVolume = (itemWidth < itemHeight ? itemWidth : itemHeight) - 1;
+ var minVolume = (itemX < itemY ? itemX : itemY) - 1;
var containerY = container2D.Length;
var containerX = container2D[0].Length;
var limitY = containerY - minVolume;
@@ -42,20 +42,20 @@ public class ContainerHelper
// Go left to right across x-axis looking for free position
for (var x = 0; x < limitX; x++)
{
- if (CanItemBePlacedInContainerAtPosition(container2D, containerX, containerY, x, y, itemWidth, itemHeight))
+ if (CanItemBePlacedInContainerAtPosition(container2D, containerX, containerY, x, y, itemX!.Value, itemY!.Value))
{
// Success, return result
return new FindSlotResult(true, x, y, rotation);
}
- if (ItemBiggerThan1X1(itemWidth, itemHeight))
+ if (ItemBiggerThan1X1(itemX!.Value, itemY!.Value))
{
// Pointless rotating a 1x1, try next position across
continue;
}
// Bigger than 1x1, try rotating by swapping x and y values
- if (!CanItemBePlacedInContainerAtPosition(container2D, containerX, containerY, x, y, itemHeight, itemWidth))
+ if (!CanItemBePlacedInContainerAtPosition(container2D, containerX, containerY, x, y, itemY!.Value, itemX!.Value))
{
continue;
}
@@ -132,8 +132,8 @@ public class ContainerHelper
int[][] container2D,
int x,
int y,
- int itemW,
- int itemH,
+ int? itemW,
+ int? itemH,
bool rotate)
{
// Swap height/width if we want to fit it in rotated
diff --git a/Libraries/SPTarkov.Server.Core/Helpers/InventoryHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/InventoryHelper.cs
index d4a45a18..54fc35d8 100644
--- a/Libraries/SPTarkov.Server.Core/Helpers/InventoryHelper.cs
+++ b/Libraries/SPTarkov.Server.Core/Helpers/InventoryHelper.cs
@@ -803,10 +803,10 @@ public class InventoryHelper(
/// Players inventory items
/// Id of the container
/// Two-dimensional representation of container
- public int[][] GetContainerMap(int containerH, int containerV, List- itemList, string containerId)
+ public int[][] GetContainerMap(int sizeX, int sizeY, List
- itemList, string containerId)
{
// Create blank 2d map of container
- var container2D = _itemHelper.GetBlankContainerMap(containerH, containerV);
+ var containerYX = _itemHelper.GetBlankContainerMap(sizeY, sizeX);
// Get all items in players inventory keyed by their parentId and by ItemId
var inventoryItemHash = GetInventoryItemHash(itemList);
@@ -815,7 +815,7 @@ public class InventoryHelper(
if (!inventoryItemHash.ByParentId.TryGetValue(containerId, out var containerItemHash))
// No items in container, exit early
{
- return container2D;
+ return containerYX;
}
// Check each item in container
@@ -854,14 +854,14 @@ public class InventoryHelper(
try
{
var rowIndex = itemLocation.Y + y;
- var containerRow = container2D[rowIndex.Value];
- if (containerRow is null)
+ var containerX = containerYX[rowIndex.Value];
+ if (containerX is null)
{
_logger.Error($"Unable to find container: {containerId} row line: {itemLocation.Y + y}");
}
// Fill the corresponding cells in the container map to show the slot is taken
- Array.Fill(containerRow, 1, itemLocation.X.Value, fW);
+ Array.Fill(containerX, 1, itemLocation.X.Value, fW);
}
catch (Exception ex)
{
@@ -879,7 +879,7 @@ public class InventoryHelper(
}
}
- return container2D;
+ return containerYX;
}
protected bool IsVertical(ItemLocation itemLocation)
diff --git a/Libraries/SPTarkov.Server.Core/Helpers/ItemHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/ItemHelper.cs
index 67766016..b360b985 100644
--- a/Libraries/SPTarkov.Server.Core/Helpers/ItemHelper.cs
+++ b/Libraries/SPTarkov.Server.Core/Helpers/ItemHelper.cs
@@ -2206,7 +2206,7 @@ public class ItemHelper(
/// Horizontal size of container
/// Vertical size of container
/// Two-dimensional representation of container
- public int[][] GetBlankContainerMap(int containerH, int containerY)
+ public int[][] GetBlankContainerMap(int containerY, int containerX)
{
//var x = new int[containerY][];
//for (int i = 0; i < containerY; i++)
@@ -2217,7 +2217,7 @@ public class ItemHelper(
//return x;
return Enumerable.Range(0, containerY)
- .Select(i => new int[containerH])
+ .Select(i => new int[containerX])
.ToArray();
}
}