0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-12 16:10:43 -05:00

Added nullguards to removeResourceFromArea

This commit is contained in:
Chomp 2024-12-20 09:33:13 +00:00
parent 04f22601d4
commit e173b3d361

View File

@ -553,10 +553,24 @@ export class HideoutController {
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
hideoutArea: IBotHideoutArea, hideoutArea: IBotHideoutArea,
): IItemEventRouterResponse { ): IItemEventRouterResponse {
const slotIndexToRemove = removeResourceRequest.slots[0]; const slotIndexToRemove = removeResourceRequest?.slots[0];
if (typeof slotIndexToRemove === "undefined") {
this.logger.warning(
`Unable to remove resource from area: ${removeResourceRequest.areaType} slot as no slots found in request, RESTART CLIENT IMMEDIATELY`,
);
return output;
}
// Assume only one item in slot // Assume only one item in slot
const itemToReturn = hideoutArea.slots.find((slot) => slot.locationIndex === slotIndexToRemove).item[0]; const itemToReturn = hideoutArea.slots.find((slot) => slot.locationIndex === slotIndexToRemove)?.item[0];
if (!itemToReturn) {
this.logger.warning(
`Unable to remove resource from area: ${removeResourceRequest.areaType} slot as no item found, RESTART CLIENT IMMEDIATELY`,
);
return output;
}
const request: IAddItemDirectRequest = { const request: IAddItemDirectRequest = {
itemWithModsToAdd: [itemToReturn], itemWithModsToAdd: [itemToReturn],