From da0a6816888c61b0889744681f12cb790c36dd70 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 17 Mar 2023 13:25:40 +0200 Subject: [PATCH] Make lua map and terrain commands use same routine --- src/sp_lev.c | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/src/sp_lev.c b/src/sp_lev.c index b68571353..605364b0b 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -5216,6 +5216,7 @@ selection_iterate( (*func)(x, y, arg); } +/* change map location terrain type during level creation */ static void sel_set_ter(coordxy x, coordxy y, genericptr_t arg) { @@ -5231,7 +5232,11 @@ sel_set_ter(coordxy x, coordxy y, genericptr_t arg) levl[x][y].doormask = D_CLOSED; if (x && (IS_WALL(levl[x - 1][y].typ) || levl[x - 1][y].horizontal)) levl[x][y].horizontal = 1; - } + } else if (levl[x][y].typ == HWALL + || levl[x][y].typ == IRONBARS) + levl[x][y].horizontal = 1; + else if (splev_init_present && levl[x][y].typ == ICE) + levl[x][y].icedpool = icedpools ? ICED_POOL : ICED_MOAT; } static void @@ -6715,6 +6720,7 @@ TODO: gc.coder->croom needs to be updated reset_xystart_size(); } else { coordxy mptyp; + terrain terr; /* Themed rooms should never overwrite anything */ if (gi.in_mk_themerooms) { @@ -6757,37 +6763,16 @@ TODO: gc.coder->croom needs to be updated } if (mptyp >= MAX_TYPE) continue; - selection_setpoint(x, y, sel, 1); - levl[x][y].typ = mptyp; - levl[x][y].lit = lit; /* clear out levl: load_common_data may set them */ levl[x][y].flags = 0; levl[x][y].horizontal = 0; levl[x][y].roomno = 0; levl[x][y].edge = 0; SpLev_Map[x][y] = 1; - /* - * Set secret doors to closed (why not trapped too?). Set - * the horizontal bit. - */ - if (levl[x][y].typ == SDOOR || IS_DOOR(levl[x][y].typ)) { - if (levl[x][y].typ == SDOOR) - levl[x][y].doormask = D_CLOSED; - /* - * If there is a wall to the left that connects to a - * (secret) door, then it is horizontal. This does - * not allow (secret) doors to be corners of rooms. - */ - if (x != gx.xstart && (IS_WALL(levl[x - 1][y].typ) - || levl[x - 1][y].horizontal)) - levl[x][y].horizontal = 1; - } else if (levl[x][y].typ == HWALL - || levl[x][y].typ == IRONBARS) - levl[x][y].horizontal = 1; - else if (levl[x][y].typ == LAVAPOOL) - levl[x][y].lit = 1; - else if (splev_init_present && levl[x][y].typ == ICE) - levl[x][y].icedpool = icedpools ? ICED_POOL : ICED_MOAT; + selection_setpoint(x, y, sel, 1); + terr.ter = mptyp; + terr.tlit = lit; + sel_set_ter(x, y, &terr); } }