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:
parent
04f22601d4
commit
e173b3d361
@ -553,10 +553,24 @@ export class HideoutController {
|
||||
output: IItemEventRouterResponse,
|
||||
hideoutArea: IBotHideoutArea,
|
||||
): 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
|
||||
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 = {
|
||||
itemWithModsToAdd: [itemToReturn],
|
||||
|
Loading…
x
Reference in New Issue
Block a user