Guard against no themed rooms or fills being eligible to generate
The themed room code previously assumed that on any given level, at least one room or fill would resolve as OK to generate there. However, that's not a great assumption to make, and if it happened to be broken, the first themed room or fill would arbitrarily be executed, even though it wasn't eligible. Fix that by setting the initial pick to nil, and raising an impossible if it's still nil after trying to choose a random room.
This commit is contained in:
@@ -936,7 +936,7 @@ function themerooms_generate()
|
||||
themerooms[actualrm].contents();
|
||||
return
|
||||
end
|
||||
local pick = 1;
|
||||
local pick = nil;
|
||||
local total_frequency = 0;
|
||||
for i = 1, #themerooms do
|
||||
if (type(themerooms[i]) ~= "table") then
|
||||
@@ -957,6 +957,10 @@ function themerooms_generate()
|
||||
end
|
||||
end
|
||||
end
|
||||
if pick == nil then
|
||||
nh.impossible('no eligible themed rooms?')
|
||||
return
|
||||
end
|
||||
themerooms[pick].contents();
|
||||
end
|
||||
|
||||
@@ -995,7 +999,7 @@ function themeroom_fill(rm)
|
||||
end
|
||||
return
|
||||
end
|
||||
local pick = 1;
|
||||
local pick = nil;
|
||||
local total_frequency = 0;
|
||||
for i = 1, #themeroom_fills do
|
||||
if (type(themeroom_fills[i]) ~= "table") then
|
||||
@@ -1016,6 +1020,10 @@ function themeroom_fill(rm)
|
||||
end
|
||||
end
|
||||
end
|
||||
if pick == nil then
|
||||
nh.impossible('no eligible themed room fills?')
|
||||
return
|
||||
end
|
||||
themeroom_fills[pick].contents(rm);
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user