From 9eee25a1754301fd4cea311e0f3f87076da1ca5e Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 2 Jan 2024 19:46:21 +0000 Subject: [PATCH] Prevent server error when loot generator tries to find non-existent loot --- project/src/generators/LocationGenerator.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/project/src/generators/LocationGenerator.ts b/project/src/generators/LocationGenerator.ts index f5eb2af6..36433f57 100644 --- a/project/src/generators/LocationGenerator.ts +++ b/project/src/generators/LocationGenerator.ts @@ -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);