Skip to content

Commit

Permalink
Fix: when a themeroom failed, xstart/ystart weren't reset
Browse files Browse the repository at this point in the history
Revealed this bug when testing the previous commit:

Themed room generation with a randomly placed map involves picking a
single random point on the map at which to plop it down, and then
declaring the themed room failed and exiting if it would go beyond the
map bounds or overlaps with an existing room. In the process,
xstart/ystart/xsize/ysize have been modified, but weren't getting reset.
(They would get reset if the map successfully got placed and it had a
contents function, as of commit 4af086b, but there wasn't handling for
the failure to place it.)
  • Loading branch information
copperwater committed May 22, 2023
1 parent ab7054a commit a1e01fd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sp_lev.c
Original file line number Diff line number Diff line change
Expand Up @@ -7044,7 +7044,12 @@ TODO: gc.coder->croom needs to be updated
skipmap:
mapfrag_free(&mf);

if (has_contents && !(gi.in_mk_themerooms && gt.themeroom_failed)) {
if (gi.in_mk_themerooms && gt.themeroom_failed) {
/* this mutated xstart and ystart in the process of trying to make a
* themed room, so undo them */
reset_xystart_size();
}
else if (has_contents) {
l_push_wid_hei_table(L, gx.xsize, gy.ysize);
if (nhl_pcall(L, 1, 0)){
impossible("Lua error: %s", lua_tostring(L, -1));
Expand Down

0 comments on commit a1e01fd

Please sign in to comment.