Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix potential crash when few loot items are registered
- Loading branch information
Showing
with
2 additions
and
2 deletions.
-
+2
−2
mods/dungeon_loot/mapgen.lua
|
@@ -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 = {} |
|
|