Make lua map and terrain commands use same routine

This commit is contained in:
Pasi Kallinen
2023-03-17 13:25:40 +02:00
parent a5934470dd
commit da0a681688

View File

@@ -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);
}
}