Fix: using a selection in a lit des.region modified it
The intuitive behavior when passing a selection to des.region, e.g.
local foo = selection.area(07,02,10,24)
des.region(foo, "lit")
is that foo will remain unmodified for further use. However, this wasn't
the case whenever making a lit region from it, because in order to light
walls adjacent to the lit area, the selection was having a grow
transformation applied as well. (This also seems like a problem - it
grows the selection even if what is being lit is not surrounded by
walls. I added a note in lua.adoc about this behavior.)
This fixes the selection mutation by cloning the passed-in selection and
growing the clone which leaves the original one unaffected.
This should not affect any special levels currently because the only
instance of des.region being used with a selection appears to be in
bigrm-2, which specifies *unlit* areas, which did not get grown.
This commit is contained in:
committed by
Pasi Kallinen
parent
ea2cd80349
commit
69d37be878
@@ -838,6 +838,11 @@ Example:
|
||||
|
||||
Create a room region, which can be irregular; use the boundary <<_map_characters,map character>> to restrict the floodfilled area.
|
||||
|
||||
If using the first form with a selection and "lit", the lit area will extend
|
||||
outward 1 space from the selection to attempt to accomodate adjacent walls,
|
||||
regardless of whether they are actually walls or not. If using "unlit", this
|
||||
will not happen.
|
||||
|
||||
Example:
|
||||
|
||||
des.region(selection, lit);
|
||||
|
||||
@@ -6061,12 +6061,12 @@ lspo_region(lua_State *L)
|
||||
} else if (argc == 2) {
|
||||
/* region(selection, "lit"); */
|
||||
static const char *const lits[] = { "unlit", "lit", NULL };
|
||||
struct selectionvar *sel = l_selection_check(L, 1);
|
||||
struct selectionvar *orig = l_selection_check(L, 1),
|
||||
*sel = selection_clone(orig);
|
||||
|
||||
rlit = luaL_checkoption(L, 2, "lit", lits);
|
||||
|
||||
/*
|
||||
TODO: adjust region size for wall, but only if lit
|
||||
TODO: lit=random
|
||||
*/
|
||||
if (rlit)
|
||||
|
||||
Reference in New Issue
Block a user