diff --git a/project/src/generators/LocationGenerator.ts b/project/src/generators/LocationGenerator.ts index 7673e8a3..55235bfd 100644 --- a/project/src/generators/LocationGenerator.ts +++ b/project/src/generators/LocationGenerator.ts @@ -638,7 +638,7 @@ export class LocationGenerator const randomSpawnpointCount = desiredSpawnpointCount - chosenSpawnpoints.length // only draw random spawn points if needed - if (randomSpawnpointCount > 0) + if (randomSpawnpointCount > 0 && spawnpointArray.length > 0) { // Add randomly chosen spawn points for (const si of spawnpointArray.draw(randomSpawnpointCount, false)) diff --git a/project/src/utils/RandomUtil.ts b/project/src/utils/RandomUtil.ts index 2e1246c4..0937568c 100644 --- a/project/src/utils/RandomUtil.ts +++ b/project/src/utils/RandomUtil.ts @@ -136,6 +136,8 @@ export class ProbabilityObjectArray extends Array = []): K[] { + if (this.length === 0) return []; + const { probArray, keyArray } = this.reduce((acc, x) => { acc.probArray.push(x.relativeProbability);