0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00
Fixed `openRandomLootContainer()` failing when no config values are found for desired random container
This commit is contained in:
Dev 2024-07-10 13:46:09 +01:00
parent e9d8c02ac2
commit a53eea239c

View File

@ -891,24 +891,34 @@ export class InventoryController
else else
{ {
const rewardContainerDetails = this.inventoryHelper.getRandomLootContainerRewardDetails(openedItem._tpl); const rewardContainerDetails = this.inventoryHelper.getRandomLootContainerRewardDetails(openedItem._tpl);
rewards.push(...this.lootGenerator.getRandomLootContainerLoot(rewardContainerDetails)); if (!rewardContainerDetails || !rewardContainerDetails.rewardCount)
if (rewardContainerDetails.foundInRaid)
{ {
foundInRaid = rewardContainerDetails.foundInRaid; this.logger.error(`Unable to add loot to container: ${openedItem._tpl}, no rewards found`);
}
else
{
rewards.push(...this.lootGenerator.getRandomLootContainerLoot(rewardContainerDetails));
if (rewardContainerDetails.foundInRaid)
{
foundInRaid = rewardContainerDetails.foundInRaid;
}
} }
} }
const addItemsRequest: IAddItemsDirectRequest = { if (rewards.length > 0)
itemsWithModsToAdd: rewards,
foundInRaid: foundInRaid,
callback: undefined,
useSortingTable: true,
};
this.inventoryHelper.addItemsToStash(sessionID, addItemsRequest, pmcData, output);
if (output.warnings.length > 0)
{ {
return; const addItemsRequest: IAddItemsDirectRequest = {
itemsWithModsToAdd: rewards,
foundInRaid: foundInRaid,
callback: undefined,
useSortingTable: true,
};
this.inventoryHelper.addItemsToStash(sessionID, addItemsRequest, pmcData, output);
if (output.warnings.length > 0)
{
return;
}
} }
// Find and delete opened container item from player inventory // Find and delete opened container item from player inventory