From 6709300e93f38b367db4db604c32dd324a86be8d Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 12 Feb 2024 23:14:04 +0000 Subject: [PATCH] Update `moveItem()` to better handle when the item being moved has no `slotId` --- project/src/controllers/InventoryController.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/project/src/controllers/InventoryController.ts b/project/src/controllers/InventoryController.ts index e9580b4e..8385372c 100644 --- a/project/src/controllers/InventoryController.ts +++ b/project/src/controllers/InventoryController.ts @@ -106,8 +106,7 @@ export class InventoryController } // Check for item in inventory before allowing internal transfer - const originalItemLocation = ownerInventoryItems.from.find((x) => x._id === moveRequest.item); - const originalLocationSlotId = originalItemLocation.slotId; + const originalItemLocation = ownerInventoryItems.from.find((item) => item._id === moveRequest.item); if (!originalItemLocation) { // Internal item move but item never existed, possible dupe glitch @@ -115,6 +114,8 @@ export class InventoryController return; } + const originalLocationSlotId = originalItemLocation?.slotId; + const moveResult = this.inventoryHelper.moveItemInternal(pmcData, ownerInventoryItems.from, moveRequest); if (!moveResult.success) { @@ -123,7 +124,7 @@ export class InventoryController } // Item is moving into or out of place of fame dogtag slot - if (moveRequest.to.container.startsWith("dogtag") || originalLocationSlotId.startsWith("dogtag")) + if (moveRequest.to.container.startsWith("dogtag") || originalLocationSlotId?.startsWith("dogtag")) { this.hideoutHelper.applyPlaceOfFameDogtagBonus(pmcData); }