Skip to content
Snippets Groups Projects
Commit 773011fd authored by sfan5's avatar sfan5
Browse files

Fix potential crash when few loot items are registered

parent c3403936
No related branches found
No related tags found
No related merge requests found
......@@ -76,8 +76,8 @@ local function populate_chest(pos, rand, dungeontype)
local item_list = dungeon_loot._internal_get_loot(pos.y, dungeontype)
-- take random (partial) sample of all possible items
assert(#item_list >= dungeon_loot.STACKS_PER_CHEST_MAX)
item_list = random_sample(rand, item_list, dungeon_loot.STACKS_PER_CHEST_MAX)
local sample_n = math.min(#item_list, dungeon_loot.STACKS_PER_CHEST_MAX)
item_list = random_sample(rand, item_list, sample_n)
-- apply chances / randomized amounts and collect resulting items
local items = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment