]> granicus.if.org Git - nethack/commitdiff
Make replace_terrain respect fromterrain='w'
authorcopperwater <aosdict@gmail.com>
Sun, 4 Sep 2022 16:31:45 +0000 (12:31 -0400)
committerPatR <rankin@nethack.org>
Fri, 23 Sep 2022 06:55:45 +0000 (23:55 -0700)
Noticed that an attempted terrain replacement wasn't taking hold even
though 'w' is supposed to mean "match any stone or wall"; this was
because w converts into non-terrain-type MATCH_WALL and replace_terrain
was doing a simple comparison on whether the potentially replaced
terrain matches that type. Add a special check here for w so it will
match the terrain types it's supposed to.

Note that using replace_terrain with 'w' now WILL match stone, since
this is the documented behavior of w, to match IS_STWALL rather than
just IS_WALL. If a level designer really wants to exclude stone, they
can work around this by either making a selection and filter out stone
terrain, or doing two replace_terrains with '-' and '|'.

src/sp_lev.c

index 81d7c136f8e5f0464635243486525f27f88ae5f5..73411d4fcf7486c6312e178f1b24dfeb92fb7a9a 100644 (file)
@@ -5564,7 +5564,9 @@ lspo_replace_terrain(lua_State *L)
                     if (mapfrag_match(mf, x, y) && (rn2(100)) < chance)
                         (void) set_levltyp_lit(x, y, totyp, tolit);
                 } else {
-                    if (levl[x][y].typ == fromtyp && rn2(100) < chance)
+                    if (((fromtyp == MATCH_WALL && IS_STWALL(levl[x][y].typ))
+                         || levl[x][y].typ == fromtyp)
+                        && rn2(100) < chance)
                         (void) set_levltyp_lit(x, y, totyp, tolit);
                 }
             }