]> granicus.if.org Git - nethack/commitdiff
Lua: Allow matching any wall
authorPasi Kallinen <paxed@alt.org>
Sat, 10 Oct 2020 08:31:16 +0000 (11:31 +0300)
committerPasi Kallinen <paxed@alt.org>
Sat, 10 Oct 2020 08:31:16 +0000 (11:31 +0300)
A 'w' in a map fragment will match any wall (IS_WALL macro):

   des.replace_terrain({ mapfragment = "w", toterrain = "F" });

src/sp_lev.c

index 446e782581dd70c742643a1d2b6a685cba82bff5..f11099af29faab368f7dc5738fa160f1d5f0e052 100755 (executable)
@@ -197,6 +197,9 @@ static struct monst *invent_carrying_monster = (struct monst *) 0;
      * end of no 'g.'
      */
 
+#define TYP_CANNOT_MATCH(typ) \
+    ((typ) == MAX_TYPE || (typ) == INVALID_TYPE)
+
 /* Does typ match with levl[][].typ, considering special types
    MATCH_WALL and MAX_TYPE (aka transparency)? */
 static boolean
@@ -277,7 +280,7 @@ struct mapfragment *mf;
     else if (!mapfrag_canmatch(mf)) {
         mapfrag_free(&mf);
         return "mapfragment needs to have odd height and width";
-    } else if (mapfrag_get(mf, (mf->wid/2), (mf->hei/2)) >= MAX_TYPE) {
+    } else if (TYP_CANNOT_MATCH(mapfrag_get(mf, (mf->wid/2), (mf->hei/2)))) {
         mapfrag_free(&mf);
         return "mapfragment center must be valid terrain";
     }