Prevent server error when loot generator tries to find non-existent loot

This commit is contained in:
Dev 2024-01-02 19:46:21 +00:00
parent 90f82d0e03
commit 9eee25a175

View File

@ -694,6 +694,13 @@ export class LocationGenerator
itemArray.push(new ProbabilityObject(itemDist.composedKey.key, itemDist.relativeProbability));
}
if (itemArray.length === 0)
{
this.logger.warning(`Loot pool for position: ${spawnPoint.template.Id} is empty. Skipping`);
continue;
}
// Draw a random item from spawn points possible items
const chosenComposedKey = itemArray.draw(1)[0];
const createItemResult = this.createDynamicLootItem(chosenComposedKey, spawnPoint, staticAmmoDist);