From 0e01828ed85adc81a91dcd8137ab38c41d12d597 Mon Sep 17 00:00:00 2001 From: copperwater Date: Sun, 21 May 2023 21:02:10 -0400 Subject: [PATCH] Fix: when a themeroom failed, xstart/ystart weren't reset 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.) --- src/sp_lev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sp_lev.c b/src/sp_lev.c index 3e72d814d..f10a21810 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -6829,7 +6829,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));