Skip to content

Commit

Permalink
Fix potential crash when few loot items are registered
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Jul 16, 2019
1 parent c340393 commit 1f8b489
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mods/dungeon_loot/mapgen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 n = math.min(#item_list, dungeon_loot.STACKS_PER_CHEST_MAX)
item_list = random_sample(rand, item_list, n)

-- apply chances / randomized amounts and collect resulting items
local items = {}
Expand Down

0 comments on commit 1f8b489

Please sign in to comment.