From 3d4ba4d66640694d3f961a5c49dbd3f64a705a10 Mon Sep 17 00:00:00 2001 From: copperwater Date: Sat, 23 May 2020 17:11:36 -0400 Subject: [PATCH] Avoid calling rn2(0) when the first room(s) have frequency 0 This probably won't happen in practice, but it is a good safeguard if this ever does happen (it happened for me in debugging when I wished to have no "regular" rooms and only generate themed rooms). --- dat/themerms.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dat/themerms.lua b/dat/themerms.lua index 73d6e8367..4f4f59029 100644 --- a/dat/themerms.lua +++ b/dat/themerms.lua @@ -576,7 +576,8 @@ function themerooms_generate() this_frequency = 1; end total_frequency = total_frequency + this_frequency; - if (nh.rn2(total_frequency) < this_frequency) then + -- avoid rn2(0) if a room has freq 0 + if this_frequency > 0 and nh.rn2(total_frequency) < this_frequency then pick = i; end end