Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1f8b489

Browse files
committedJul 16, 2019
Fix potential crash when few loot items are registered
1 parent c340393 commit 1f8b489

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎mods/dungeon_loot/mapgen.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ local function populate_chest(pos, rand, dungeontype)
7676

7777
local item_list = dungeon_loot._internal_get_loot(pos.y, dungeontype)
7878
-- take random (partial) sample of all possible items
79-
assert(#item_list >= dungeon_loot.STACKS_PER_CHEST_MAX)
80-
item_list = random_sample(rand, item_list, dungeon_loot.STACKS_PER_CHEST_MAX)
79+
local n = math.min(#item_list, dungeon_loot.STACKS_PER_CHEST_MAX)
80+
item_list = random_sample(rand, item_list, n)
8181

8282
-- apply chances / randomized amounts and collect resulting items
8383
local items = {}

0 commit comments

Comments
 (0)
Please sign in to comment.