From 858026b5b91b5680f1cb033246ca24dbbd44cb79 Mon Sep 17 00:00:00 2001 From: Dev Date: Wed, 21 Aug 2024 13:28:30 +0100 Subject: [PATCH] Handled edge case handling for adding an item to a hideout area --- project/src/controllers/HideoutController.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/project/src/controllers/HideoutController.ts b/project/src/controllers/HideoutController.ts index a3a07d76..64f03b74 100644 --- a/project/src/controllers/HideoutController.ts +++ b/project/src/controllers/HideoutController.ts @@ -401,7 +401,16 @@ export class HideoutController { // Add item to area.slots const destinationLocationIndex = Number(item.slot); - const hideoutSlotIndex = hideoutArea.slots.findIndex((x) => x.locationIndex === destinationLocationIndex); + const hideoutSlotIndex = hideoutArea.slots.findIndex( + (slot) => slot.locationIndex === destinationLocationIndex, + ); + if (hideoutSlotIndex === -1) { + this.logger.error( + `Unable to put item: ${item.requestedItem.id} into slot as slot cannot be found for area: ${addItemToHideoutRequest.areaType}, skipping`, + ); + continue; + } + hideoutArea.slots[hideoutSlotIndex].item = [ { _id: item.inventoryItem._id,