Update moveItem() to better handle when the item being moved has no slotId

This commit is contained in:
Dev 2024-02-12 23:14:04 +00:00
parent c4520ddbe9
commit 6709300e93

View File

@ -106,8 +106,7 @@ export class InventoryController
} }
// Check for item in inventory before allowing internal transfer // Check for item in inventory before allowing internal transfer
const originalItemLocation = ownerInventoryItems.from.find((x) => x._id === moveRequest.item); const originalItemLocation = ownerInventoryItems.from.find((item) => item._id === moveRequest.item);
const originalLocationSlotId = originalItemLocation.slotId;
if (!originalItemLocation) if (!originalItemLocation)
{ {
// Internal item move but item never existed, possible dupe glitch // Internal item move but item never existed, possible dupe glitch
@ -115,6 +114,8 @@ export class InventoryController
return; return;
} }
const originalLocationSlotId = originalItemLocation?.slotId;
const moveResult = this.inventoryHelper.moveItemInternal(pmcData, ownerInventoryItems.from, moveRequest); const moveResult = this.inventoryHelper.moveItemInternal(pmcData, ownerInventoryItems.from, moveRequest);
if (!moveResult.success) if (!moveResult.success)
{ {
@ -123,7 +124,7 @@ export class InventoryController
} }
// Item is moving into or out of place of fame dogtag slot // 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); this.hideoutHelper.applyPlaceOfFameDogtagBonus(pmcData);
} }