From: Pasi Kallinen Date: Wed, 23 Feb 2022 10:53:09 +0000 (+0200) Subject: Use IS_WATERWALL and is_waterwall X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5786ddadbbbebaebff7e9a544614930e94b82b09;p=nethack Use IS_WATERWALL and is_waterwall --- diff --git a/include/extern.h b/include/extern.h index ae78ddc8b..2e9152715 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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); diff --git a/include/rm.h b/include/rm.h index a875aa6d2..454dae112 100644 --- a/include/rm.h +++ b/include/rm.h @@ -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 diff --git a/src/dbridge.c b/src/dbridge.c index c4da8319e..869f56c30 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -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) { diff --git a/src/dothrow.c b/src/dothrow.c index c1665aa18..faf72cc78 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -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(); diff --git a/src/hack.c b/src/hack.c index a59aedce9..d7eb8f09c 100644 --- a/src/hack.c +++ b/src/hack.c @@ -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; diff --git a/src/mcastu.c b/src/mcastu.c index c84ed4e8b..1a16051d2 100644 --- a/src/mcastu.c +++ b/src/mcastu.c @@ -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; } diff --git a/src/mhitu.c b/src/mhitu.c index 59e208a83..515201fd1 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -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); } diff --git a/src/mon.c b/src/mon.c index b2a25a4f5..7612d7910 100644 --- 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 diff --git a/src/mthrowu.c b/src/mthrowu.c index a5c9ddcff..6c63ac552 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -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( /* is guaranteed to eventually converge with */ 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; diff --git a/src/pager.c b/src/pager.c index 89ad90e62..6b148026e 100644 --- a/src/pager.c +++ b/src/pager.c @@ -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")); diff --git a/src/teleport.c b/src/teleport.c index 77d16c15a..bf40b82a0 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -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; diff --git a/src/trap.c b/src/trap.c index 7433e6ec0..3fb7bf3e1 100644 --- a/src/trap.c +++ b/src/trap.c @@ -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 */ diff --git a/src/uhitm.c b/src/uhitm.c index 9f7125e68..738d26f89 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -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); diff --git a/src/vision.c b/src/vision.c index de93a8ba2..dbf1a9128 100644 --- a/src/vision.c +++ b/src/vision.c @@ -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; diff --git a/src/zap.c b/src/zap.c index 015e266ba..19ca24af0 100644 --- 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"));