]> granicus.if.org Git - nethack/commitdiff
Use IS_WATERWALL and is_waterwall
authorPasi Kallinen <paxed@alt.org>
Wed, 23 Feb 2022 10:53:09 +0000 (12:53 +0200)
committerPasi Kallinen <paxed@alt.org>
Wed, 23 Feb 2022 10:53:09 +0000 (12:53 +0200)
15 files changed:
include/extern.h
include/rm.h
src/dbridge.c
src/dothrow.c
src/hack.c
src/mcastu.c
src/mhitu.c
src/mon.c
src/mthrowu.c
src/pager.c
src/teleport.c
src/trap.c
src/uhitm.c
src/vision.c
src/zap.c

index ae78ddc8b5bb678ca18d27a9684e7226b0fc609b..2e9152715c92935a8c41c4ad17cd84f6e983c8d3 100644 (file)
@@ -296,6 +296,7 @@ extern void free_nomakedefs(void);
 
 /* ### dbridge.c ### */
 
+extern boolean is_waterwall(xchar, xchar);
 extern boolean is_pool(int, int);
 extern boolean is_lava(int, int);
 extern boolean is_pool_or_lava(int, int);
index a875aa6d2cc582c35d23d85f93b8cc698dc1a036..454dae112852c04e048859228148fe2e0fe046d5 100644 (file)
@@ -105,6 +105,7 @@ enum levl_typ_types {
 #define IS_FURNITURE(typ) ((typ) >= STAIRS && (typ) <= ALTAR)
 #define IS_AIR(typ) ((typ) == AIR || (typ) == CLOUD)
 #define IS_SOFT(typ) ((typ) == AIR || (typ) == CLOUD || IS_POOL(typ))
+#define IS_WATERWALL(typ) ((typ) == WATER)
 
 /*
  *      Note:  secret doors (SDOOR) want to use both rm.doormask and
index c4da8319e0d9ca6a0ac0d36023431a928b89b379..869f56c30bdf7cd36be3a90f0bc9a4a9882887d8 100644 (file)
@@ -33,6 +33,14 @@ static boolean e_missed(struct entity *, boolean);
 static boolean e_jumps(struct entity *);
 static void do_entity(struct entity *);
 
+boolean
+is_waterwall(xchar x, xchar y)
+{
+    if (isok(x, y) && IS_WATERWALL(levl[x][y].typ))
+        return TRUE;
+    return FALSE;
+}
+
 boolean
 is_pool(int x, int y)
 {
index c1665aa184c0d812b0d88533674c871935bc6a8d..faf72cc78a2606a05efcebeb56571f8d594db225 100644 (file)
@@ -851,7 +851,7 @@ hurtle_step(genericptr_t arg, int x, int y)
         switch_terrain();
 
     if (is_pool(x, y) && !u.uinwater) {
-        if ((Is_waterlevel(&u.uz) && levl[x][y].typ == WATER)
+        if ((Is_waterlevel(&u.uz) && is_waterwall(x,y))
             || !(Levitation || Flying || Wwalking)) {
             g.multi = 0; /* can move, so drown() allows crawling out of water */
             (void) drown();
index a59aedce9fe120707d9cf647009e7bd672c1b4eb..d7eb8f09c25e644a0419f22aab603d57bd506491 100644 (file)
@@ -1535,7 +1535,7 @@ u_simple_floortyp(xchar x, xchar y)
 {
     boolean u_in_air = (Levitation || Flying || !grounded(g.youmonst.data));
 
-    if (levl[x][y].typ == WATER)
+    if (is_waterwall(x,y))
         return WATER; /* wall of water, fly/lev does not matter */
     if (!u_in_air) {
         if (is_pool(x,y))
@@ -1551,7 +1551,7 @@ static boolean
 swim_move_danger(xchar x, xchar y)
 {
     schar newtyp = u_simple_floortyp(x, y);
-    boolean liquid_wall = (newtyp == WATER);
+    boolean liquid_wall = IS_WATERWALL(newtyp);
 
     if ((newtyp != u_simple_floortyp(u.ux, u.uy))
         && !Stunned && !Confusion && levl[x][y].seenv
@@ -2352,7 +2352,7 @@ switch_terrain(void)
 {
     struct rm *lev = &levl[u.ux][u.uy];
     boolean blocklev = (IS_ROCK(lev->typ) || closed_door(u.ux, u.uy)
-                        || lev->typ == WATER),
+                        || IS_WATERWALL(lev->typ)),
             was_levitating = !!Levitation, was_flying = !!Flying;
 
     if (blocklev) {
@@ -2464,7 +2464,7 @@ pooleffects(boolean newspot)             /* true if called by spoteffects */
         if (is_lava(u.ux, u.uy)) {
             if (lava_effects())
                 return TRUE;
-        } else if ((!Wwalking || levl[u.ux][u.uy].typ == WATER)
+        } else if ((!Wwalking || is_waterwall(u.ux,u.uy))
                    && (newspot || !u.uinwater || !(Swimming || Amphibious))) {
             if (drown())
                 return TRUE;
index c84ed4e8b440301d80596610ad22dcb3bec34cee..1a16051d22798a98043cb8e0ec3662ec897783a3 100644 (file)
@@ -239,8 +239,8 @@ castmu(register struct monst *mtmp,
         && !is_undirected_spell(mattk->adtyp, spellnum)) {
         pline("%s casts a spell at %s!",
               canseemon(mtmp) ? Monnam(mtmp) : "Something",
-              levl[mtmp->mux][mtmp->muy].typ == WATER ? "empty water"
-                                                      : "thin air");
+              is_waterwall(mtmp->mux,mtmp->muy) ? "empty water"
+                                                : "thin air");
         return 0;
     }
 
index 59e208a835d630e8a72b337ebc9486fb96757c4a..515201fd1cd77a487094ae8711af585e4f73af97 100644 (file)
@@ -195,7 +195,7 @@ wildmiss(struct monst *mtmp, struct attack *mattk)
                 break;
             case 2:
                 pline("%s strikes at %s!", Monst_name,
-                      (levl[mtmp->mux][mtmp->muy].typ == WATER)
+                      is_waterwall(mtmp->mux,mtmp->muy)
                         ? "empty water"
                         : "thin air");
                 break;
@@ -1402,8 +1402,8 @@ explmu(struct monst *mtmp, struct attack *mattk, boolean ufound)
     if (!ufound) {
         pline("%s explodes at a spot in %s!",
               canseemon(mtmp) ? Monnam(mtmp) : "It",
-              levl[mtmp->mux][mtmp->muy].typ == WATER ? "empty water"
-                                                      : "thin air");
+              is_waterwall(mtmp->mux,mtmp->muy) ? "empty water"
+                                                : "thin air");
     } else {
         hitmsg(mtmp, mattk);
     }
index b2a25a4f5045e52909a83961f2a4672dba703534..7612d791031311a30297cc9dd595bdface9fdf8f 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -708,7 +708,7 @@ static int
 minliquid_core(struct monst* mtmp)
 {
     boolean inpool, inlava, infountain;
-    boolean waterwall = (levl[mtmp->mx][mtmp->my].typ == WATER);
+    boolean waterwall = is_waterwall(mtmp->mx,mtmp->my);
 
     /* [ceiling clingers are handled below] */
     inpool = (is_pool(mtmp->mx, mtmp->my)
@@ -1785,7 +1785,7 @@ mfndpos(
 
     nodiag = NODIAG(mdat - mons);
     wantpool = (mdat->mlet == S_EEL);
-    poolok = ((!Is_waterlevel(&u.uz) && !(nowtyp != WATER)
+    poolok = ((!Is_waterlevel(&u.uz) && IS_WATERWALL(nowtyp)
                && !grounded(mdat))
               || (is_swimmer(mdat) && !wantpool));
     /* note: floating eye is the only is_floater() so this could be
index a5c9ddcffe324c2d79b25918a8b0b13f979b8f17..6c63ac5524cd7293c5e1cad0c5104d9ed57bb8db 100644 (file)
@@ -1079,7 +1079,7 @@ linedup_callback(
             if (!isok(bx, by))
                 return FALSE;
             if (IS_ROCK(levl[bx][by].typ) || closed_door(bx, by)
-                || levl[bx][by].typ == WATER)
+                || is_waterwall(bx, by))
                 return FALSE;
             if ((*fnc)(bx, by))
                 return TRUE;
@@ -1123,7 +1123,7 @@ linedup(
             /* <bx,by> is guaranteed to eventually converge with <ax,ay> */
             bx += dx, by += dy;
             if (IS_ROCK(levl[bx][by].typ) || closed_door(bx, by)
-                || levl[bx][by].typ == WATER)
+                || is_waterwall(bx, by))
                 return FALSE;
             if (sobj_at(BOULDER, bx, by))
                 ++boulderspots;
index 89ad90e627b02be05d663197150fbf82066d8f31..6b148026e1b67e17eb40b3d37536dd54a04ab6dd 100644 (file)
@@ -510,7 +510,7 @@ waterbody_name(xchar x, xchar y)
         } else {
             return "moat";
         }
-    } else if (ltyp == WATER) {
+    } else if (IS_WATERWALL(ltyp)) {
         if (Is_waterlevel(&u.uz))
             return "limitless water"; /* even if hallucinating */
         Snprintf(pooltype, sizeof pooltype, "wall of %s", hliquid("water"));
index 77d16c15a02cbfd013bbc02440dcafd4596ac063..bf40b82a020cdc91eb10456df45562d631f2147c 100644 (file)
@@ -83,14 +83,14 @@ goodpos(int x, int y, struct monst* mtmp, long gpflags)
             if (mtmp == &g.youmonst)
                 return (Swimming || Amphibious
                         || (!Is_waterlevel(&u.uz)
-                            && !(levl[x][y].typ == WATER)
+                            && !is_waterwall(x, y)
                             /* water on the Plane of Water has no surface
                                so there's no way to be on or above that */
                             && (Levitation || Flying || Wwalking)));
             else
                 return (is_swimmer(mdat)
                         || (!Is_waterlevel(&u.uz)
-                            && !(levl[x][y].typ == WATER)
+                            && !is_waterwall(x, y)
                             && !grounded(mdat)));
         } else if (mdat->mlet == S_EEL && rn2(13) && !ignorewater) {
             return FALSE;
index 7433e6ec0836b6e50fa084d0c864bc58052bc15b..3fb7bf3e111018dca0cbbc5f601b5769d1fbc750 100644 (file)
@@ -4185,7 +4185,7 @@ drown(void)
     const char *pool_of_water;
     boolean inpool_ok = FALSE, crawl_ok;
     int i, x, y;
-    boolean is_solid = (levl[u.ux][u.uy].typ == WATER);
+    boolean is_solid = is_waterwall(u.ux, u.uy);
 
     feel_newsym(u.ux, u.uy); /* in case Blind, map the water here */
     /* happily wading in the same contiguous pool */
index 9f7125e68246c5d15f813c228c1a878820343589..738d26f8920e152a6e16b0334eac2c03ee9287d2 100644 (file)
@@ -2911,7 +2911,7 @@ mhitm_ad_wrap(struct monst *magr, struct attack *mattk, struct monst *mdef,
             } else if (u.ustuck == magr) {
                 if (is_pool(magr->mx, magr->my) && !Swimming && !Amphibious) {
                     boolean moat = (levl[magr->mx][magr->my].typ != POOL)
-                                   && (levl[magr->mx][magr->my].typ != WATER)
+                                   && !is_waterwall(magr->mx, magr->my)
                                    && !Is_medusa_level(&u.uz)
                                    && !Is_waterlevel(&u.uz);
 
index de93a8ba25e83179ffdb31f950a1fda43a6b5022..dbf1a9128906118f5227ce94ded4c20a491f6693 100644 (file)
@@ -149,7 +149,7 @@ does_block(int x, int y, struct rm *lev)
             && (lev->doormask & (D_CLOSED | D_LOCKED | D_TRAPPED))))
         return 1;
 
-    if (lev->typ == CLOUD || lev->typ == WATER
+    if (lev->typ == CLOUD || IS_WATERWALL(lev->typ)
         || (lev->typ == MOAT && Underwater))
         return 1;
 
index 015e266baf3487c0c8424177cc609f7019451f1b..19ca24af0d41a34bba3b683812726a212ea4e37f 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -3460,7 +3460,7 @@ bhit(int ddx, int ddy, int range,  /* direction and range */
         typ = levl[g.bhitpos.x][g.bhitpos.y].typ;
 
         /* WATER aka "wall of water" stops items */
-        if (typ == WATER) {
+        if (IS_WATERWALL(typ)) {
             if (weapon == THROWN_WEAPON || weapon == KICKED_WEAPON)
                 break;
         }
@@ -4705,7 +4705,7 @@ zap_over_floor(xchar x, xchar y, int type, boolean *shopdamage,
             boolean lava = is_lava(x, y),
                     moat = is_moat(x, y);
 
-            if (lev->typ == WATER) {
+            if (IS_WATERWALL(lev->typ)) {
                 /* For now, don't let WATER freeze. */
                 if (see_it)
                     pline_The("%s freezes for a moment.", hliquid("water"));