From: copperwater Date: Sat, 23 May 2020 21:11:36 +0000 (-0400) Subject: Avoid calling rn2(0) when the first room(s) have frequency 0 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d4ba4d66640694d3f961a5c49dbd3f64a705a10;p=nethack 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). --- 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