]> granicus.if.org Git - nethack/commitdiff
Use u_at macro
authorPasi Kallinen <paxed@alt.org>
Wed, 23 Feb 2022 18:28:35 +0000 (20:28 +0200)
committerPasi Kallinen <paxed@alt.org>
Wed, 23 Feb 2022 18:28:55 +0000 (20:28 +0200)
40 files changed:
include/you.h
src/apply.c
src/bones.c
src/cmd.c
src/dbridge.c
src/detect.c
src/dig.c
src/display.c
src/do.c
src/do_name.c
src/dogmove.c
src/dungeon.c
src/engrave.c
src/explode.c
src/fountain.c
src/hack.c
src/invent.c
src/light.c
src/lock.c
src/mail.c
src/makemon.c
src/mhitu.c
src/mkmaze.c
src/mon.c
src/monmove.c
src/mthrowu.c
src/muse.c
src/music.c
src/pager.c
src/pickup.c
src/priest.c
src/read.c
src/region.c
src/shk.c
src/steed.c
src/teleport.c
src/trap.c
src/vault.c
src/wizard.c
src/zap.c

index 8b3adaff343d69620673e27a12fa7fc36595bea5..a563a4063740134cc87f6ae1274b6c4242dbccca 100644 (file)
@@ -486,5 +486,7 @@ struct you {
 
 /* point px,py is adjacent to (or same location as) hero */
 #define next2u(px,py) (distu((px),(py)) <= 2)
+/* hero at (x,y)? */
+#define u_at(x,y) ((x) == u.ux && (y) == u.uy)
 
 #endif /* YOU_H */
index 9d16053a7e4327d455c85cd4990f21d257a9b04e..86b39e0ae8a6447a744e763755ac612087bdc97c 100644 (file)
@@ -235,7 +235,7 @@ its_dead(int rx, int ry, int *resp)
         return TRUE;
 
     } else if (corpse) {
-        boolean here = (rx == u.ux && ry == u.uy),
+        boolean here = u_at(rx, ry),
                 one = (corpse->quan == 1L && !more_corpses), reviver = FALSE;
         int visglyph, corpseglyph;
 
@@ -265,7 +265,7 @@ its_dead(int rx, int ry, int *resp)
         mptr = &mons[statue->corpsenm];
         if (Blind) { /* ignore statue->dknown; it'll always be set */
             Sprintf(buf, "%s %s",
-                    (rx == u.ux && ry == u.uy) ? "This" : "That",
+                    u_at(rx, ry) ? "This" : "That",
                     humanoid(mptr) ? "person" : "creature");
             what = buf;
         } else {
@@ -627,7 +627,7 @@ use_leash(struct obj *obj)
     if (!get_adjacent_loc((char *) 0, (char *) 0, u.ux, u.uy, &cc))
         return ECMD_OK;
 
-    if (cc.x == u.ux && cc.y == u.uy) {
+    if (u_at(cc.x, cc.y)) {
         if (u.usteed && u.dz > 0) {
             mtmp = u.usteed;
             spotmon = 1;
@@ -2587,8 +2587,7 @@ use_trap(struct obj *otmp)
         return;
     }
     ttyp = (otmp->otyp == LAND_MINE) ? LANDMINE : BEAR_TRAP;
-    if (otmp == g.trapinfo.tobj && u.ux == g.trapinfo.tx
-                                && u.uy == g.trapinfo.ty) {
+    if (otmp == g.trapinfo.tobj && u_at(g.trapinfo.tx, g.trapinfo.ty)) {
         You("resume setting %s%s.", shk_your(buf, otmp),
             trapname(ttyp, FALSE));
         set_occupation(set_trap, occutext, 0);
@@ -3139,7 +3138,7 @@ use_pole(struct obj *obj, boolean autohit)
         pline("Too far!");
         return res;
     } else if (distu(cc.x, cc.y) < min_range) {
-        if (autohit && cc.x == u.ux && cc.y == u.uy)
+        if (autohit && u_at(cc.x, cc.y))
             pline("Don't know what to hit.");
         else
             pline("Too close!");
index c34bd14497283dbdd20e033b056890adceec21de..6fa2dac4e49e67c4cb13bc5083d14c6d24b6215d 100644 (file)
@@ -228,7 +228,7 @@ give_to_nearby_mon(struct obj *otmp, int x, int y)
         for (yy = y - 1; yy <= y + 1; ++yy) {
             if (!isok(xx, yy))
                 continue;
-            if (xx == u.ux && yy == u.uy)
+            if (u_at(xx, yy))
                 continue;
             if (!(mtmp = m_at(xx, yy)))
                 continue;
index 69dc376e1ec4f220e95b114e987490b81e541e10..9c16566bc57d03921823f6fa019224a08fab45e8 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1302,7 +1302,7 @@ wiz_show_seenv(void)
 
     for (y = 0; y < ROWNO; y++) {
         for (x = startx, curx = 0; x < stopx; x++, curx += 2) {
-            if (x == u.ux && y == u.uy) {
+            if (u_at(x, y)) {
                 row[curx] = row[curx + 1] = '@';
             } else {
                 v = levl[x][y].seenv & 0xff;
@@ -1340,7 +1340,7 @@ wiz_show_vision(void)
     putstr(win, 0, "");
     for (y = 0; y < ROWNO; y++) {
         for (x = 1; x < COLNO; x++) {
-            if (x == u.ux && y == u.uy) {
+            if (u_at(x, y)) {
                 row[x] = '@';
             } else {
                 v = g.viz_array[y][x]; /* data access should be hidden */
@@ -1376,7 +1376,7 @@ wiz_show_wmodes(void)
     for (y = 0; y < ROWNO; y++) {
         for (x = 0; x < COLNO; x++) {
             lev = &levl[x][y];
-            if (x == u.ux && y == u.uy)
+            if (u_at(x, y))
                 row[x] = '@';
             else if (IS_WALL(lev->typ) || lev->typ == SDOOR)
                 row[x] = '0' + (lev->wall_info & WM_MASK);
index 869f56c30bdf7cd36be3a90f0bc9a4a9882887d8..4f9a32d16bdcb37b52a774c4e5634b81e2fdcad1 100644 (file)
@@ -322,7 +322,7 @@ u_to_e(struct entity *etmp)
 static void
 set_entity(int x, int y, struct entity *etmp)
 {
-    if ((x == u.ux) && (y == u.uy))
+    if (u_at(x, y))
         u_to_e(etmp);
     else if (MON_AT(x, y))
         m_to_e(m_at(x, y), x, y, etmp);
index 87940743232ffc11db9609a0ba87e7ac846e84c1..24f6572ddfe6233a128dd62625e73ef9be313b2c 100644 (file)
@@ -127,7 +127,7 @@ trapped_chest_at(int ttyp, int x, int y)
     if (sobj_at(CHEST, x, y) || sobj_at(LARGE_BOX, x, y))
         return TRUE;
     /* in inventory, we need to find one which is actually trapped */
-    if (x == u.ux && y == u.uy) {
+    if (u_at(x, y)) {
         for (otmp = g.invent; otmp; otmp = otmp->nobj)
             if (Is_box(otmp) && otmp->otrapped)
                 return TRUE;
@@ -397,7 +397,7 @@ gold_detect(struct obj *sobj)
             }
             map_object(temp, 1);
         }
-        if (temp && temp->ox == u.ux && temp->oy == u.uy)
+        if (temp && u_at(temp->ox, temp->oy))
             ugold = TRUE;
     }
     for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
@@ -426,7 +426,7 @@ gold_detect(struct obj *sobj)
                     break;
                 }
         }
-        if (temp && temp->ox == u.ux && temp->oy == u.uy)
+        if (temp && u_at(temp->ox, temp->oy))
             ugold = TRUE;
     }
     if (!ugold) {
@@ -459,7 +459,7 @@ food_detect(struct obj *sobj)
 
     for (obj = fobj; obj; obj = obj->nobj)
         if (o_in(obj, oclass)) {
-            if (obj->ox == u.ux && obj->oy == u.uy)
+            if (u_at(obj->ox, obj->oy))
                 ctu++;
             else
                 ct++;
@@ -469,7 +469,7 @@ food_detect(struct obj *sobj)
             continue;
         for (obj = mtmp->minvent; obj; obj = obj->nobj)
             if (o_in(obj, oclass)) {
-                if (mtmp->mx == u.ux && mtmp->my == u.uy)
+                if (u_at(mtmp->mx, mtmp->my))
                     ctu++; /* steed or an engulfer with inventory */
                 else
                     ct++;
@@ -610,7 +610,7 @@ object_detect(struct obj *detector, /* object doing the detecting */
 
     for (obj = fobj; obj; obj = obj->nobj) {
         if ((!class && !boulder) || o_in(obj, class) || o_in(obj, boulder)) {
-            if (obj->ox == u.ux && obj->oy == u.uy)
+            if (u_at(obj->ox, obj->oy))
                 ctu++;
             else
                 ct++;
@@ -621,7 +621,7 @@ object_detect(struct obj *detector, /* object doing the detecting */
 
     for (obj = g.level.buriedobjlist; obj; obj = obj->nobj) {
         if (!class || o_in(obj, class)) {
-            if (obj->ox == u.ux && obj->oy == u.uy)
+            if (u_at(obj->ox, obj->oy))
                 ctu++;
             else
                 ct++;
@@ -885,7 +885,7 @@ detect_obj_traps(struct obj *objlist, boolean show_them,
     for (otmp = objlist; otmp; otmp = otmp->nobj) {
         if (Is_box(otmp) && otmp->otrapped
             && get_obj_location(otmp, &x, &y, BURIED_TOO | CONTAINED_TOO)) {
-            result |= (x == u.ux && y == u.uy) ? OTRAP_HERE : OTRAP_THERE;
+            result |= u_at(x, y) ? OTRAP_HERE : OTRAP_THERE;
             if (show_them)
                 sense_trap((struct trap *) 0, x, y, how);
         }
@@ -1467,7 +1467,7 @@ do_vicinity_map(struct obj *sobj) /* scroll--actually fake spellbook--object */
        see_monsters() to update visible ones and warned-of ones */
     for (zx = lo_x; zx <= hi_x; zx++)
         for (zy = lo_y; zy <= hi_y; zy++) {
-            if (zx == u.ux && zy == u.uy)
+            if (u_at(zx, zy))
                 continue;
             newglyph = glyph_at(zx, zy);
             if (glyph_is_monster(newglyph)
@@ -1608,7 +1608,7 @@ openone(int zx, int zy, genericptr_t num)
             newsym(zx, zy);
             (*num_p)++;
         }
-        mon = (zx == u.ux && zy == u.uy) ? &g.youmonst : m_at(zx, zy);
+        mon = u_at(zx, zy) ? &g.youmonst : m_at(zx, zy);
         if (openholdingtrap(mon, &dummy)
             || openfallingtrap(mon, TRUE, &dummy))
             (*num_p)++;
@@ -1758,7 +1758,7 @@ dosearch0(int aflag) /* intrinsic autosearch vs explicit searching */
             for (y = u.uy - 1; y < u.uy + 2; y++) {
                 if (!isok(x, y))
                     continue;
-                if (x == u.ux && y == u.uy)
+                if (u_at(x, y))
                     continue;
 
                 if (Blind && !aflag)
@@ -1832,7 +1832,7 @@ warnreveal(void)
 
     for (x = u.ux - 1; x <= u.ux + 1; x++)
         for (y = u.uy - 1; y <= u.uy + 1; y++) {
-            if (!isok(x, y) || (x == u.ux && y == u.uy))
+            if (!isok(x, y) || u_at(x, y))
                 continue;
             if ((mtmp = m_at(x, y)) != 0
                 && warning_of(mtmp) && mtmp->mundetected)
@@ -1901,7 +1901,7 @@ reveal_terrain_getglyph(int x, int y, int full, unsigned swallowed,
            the invisible monster glyph, which is handled like
            an object, replacing any object or trap at its spot) */
         glyph = !swallowed ? glyph_at(x, y) : levl_glyph;
-        if (keep_mons && x == u.ux && y == u.uy && swallowed)
+        if (keep_mons && u_at(x, y) && swallowed)
             glyph = mon_to_glyph(u.ustuck, rn2_on_display_rng);
         else if (((glyph_is_monster(glyph)
                    || glyph_is_warning(glyph)) && !keep_mons)
index 063b531ff14381e38631f3e1e8d48c8934685df6..55d9949be675f8caf9152a4df492ba092b08128b 100644 (file)
--- a/src/dig.c
+++ b/src/dig.c
@@ -561,7 +561,7 @@ digactualhole(int x, int y, struct monst *madeby, int ttyp)
     struct monst *mtmp = m_at(x, y); /* may be madeby */
     boolean madeby_u = (madeby == BY_YOU);
     boolean madeby_obj = (madeby == BY_OBJECT);
-    boolean at_u = (x == u.ux) && (y == u.uy);
+    boolean at_u = u_at(x, y);
     boolean wont_fall = Levitation || Flying;
 
     if (at_u && u.utrap) {
@@ -738,7 +738,7 @@ liquid_flow(xchar x, xchar y, schar typ, struct trap *ttmp,
 {
     struct obj *objchain;
     struct monst *mon;
-    boolean u_spot = (x == u.ux && y == u.uy);
+    boolean u_spot = u_at(x, y);
 
     if (ttmp)
         (void) delfloortrap(ttmp);
@@ -1131,8 +1131,7 @@ use_pick_axe2(struct obj *obj)
                 || g.context.digging.down) {
                 if (flags.autodig && dig_target == DIGTYP_ROCK
                     && !g.context.digging.down
-                    && g.context.digging.pos.x == u.ux
-                    && g.context.digging.pos.y == u.uy
+                    && u_at(g.context.digging.pos.x, g.context.digging.pos.y)
                     && (g.moves <= g.context.digging.lastdigtime + 2
                         && g.moves >= g.context.digging.lastdigtime)) {
                     /* avoid messages if repeated autodigging */
@@ -1693,7 +1692,7 @@ pit_flow(struct trap *trap, schar filltyp)
         t = *trap;
         levl[t.tx][t.ty].typ = filltyp, levl[t.tx][t.ty].flags = 0;
         liquid_flow(t.tx, t.ty, filltyp, trap,
-                    (t.tx == u.ux && t.ty == u.uy)
+                    u_at(t.tx, t.ty)
                         ? "Suddenly %s flows in from the adjacent pit!"
                         : (char *) 0);
         for (idx = 0; idx < N_DIRS; ++idx) {
@@ -2015,7 +2014,7 @@ rot_corpse(anything *arg, long timeout)
         if (mtmp && !OBJ_AT(x, y) && mtmp->mundetected
             && hides_under(mtmp->data)) {
             mtmp->mundetected = 0;
-        } else if (x == u.ux && y == u.uy
+        } else if (u_at(x, y)
                    && u.uundetected && hides_under(g.youmonst.data))
             (void) hideunder(&g.youmonst);
         newsym(x, y);
index fc20048fc88b952a9372b3d289e82f8cf6d4c102..d09b47fba3c75d8ea18dc2398645ec78ec51a11a 100644 (file)
@@ -749,7 +749,7 @@ newsym(register int x, register int y)
 
     /* only permit updating the hero when swallowed */
     if (u.uswallow) {
-        if (x == u.ux && y == u.uy)
+        if (u_at(x, y))
             display_self();
         return;
     }
@@ -794,7 +794,7 @@ newsym(register int x, register int y)
             return;
         }
 
-        if (x == u.ux && y == u.uy) {
+        if (u_at(x, y)) {
             int see_self = canspotself();
 
             /* update map information for <u.ux,u.uy> (remembered topology
@@ -831,7 +831,7 @@ newsym(register int x, register int y)
 
     /* Can't see the location. */
     } else {
-        if (x == u.ux && y == u.uy) {
+        if (u_at(x, y)) {
             feel_location(u.ux, u.uy); /* forces an update */
 
             if (canspotself())
@@ -1216,7 +1216,7 @@ under_water(int mode)
     for (x = u.ux - 1; x <= u.ux + 1; x++)
         for (y = u.uy - 1; y <= u.uy + 1; y++)
             if (isok(x, y) && (is_pool_or_lava(x, y) || is_ice(x, y))) {
-                if (Blind && !(x == u.ux && y == u.uy))
+                if (Blind && !u_at(x, y))
                     show_glyph(x, y, GLYPH_UNEXPLORED);
                 else
                     newsym(x, y);
@@ -2182,7 +2182,7 @@ map_glyphinfo(
     glyph_info *glyphinfo)
 {
     int offset;
-    boolean is_you = (x == u.ux && y == u.uy
+    boolean is_you = (u_at(x, y)
                       /* verify hero or steed (not something underneath
                          when hero is invisible without see invisible,
                          or a temporary display effect like an explosion);
index 481c12ca080bab943fa89ef47759c27279399e4f..0a6f7597c2e3c223e922158b00d17654440a50e5 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -166,7 +166,7 @@ flooreffects(struct obj *obj, int x, int y, const char *verb)
         ttyp = t->ttyp;
         tseen = t->tseen ? TRUE : FALSE;
         if (((mtmp = m_at(x, y)) && mtmp->mtrapped)
-            || (u.utrap && u.ux == x && u.uy == y)) {
+            || (u.utrap && u_at(x,y))) {
             if (*verb && (cansee(x, y) || distu(x, y) == 0))
                 pline("%s boulder %s into the pit%s.",
                       Blind ? "A" : "The",
@@ -213,7 +213,7 @@ flooreffects(struct obj *obj, int x, int y, const char *verb)
             }
         }
         if (*verb) {
-            if (Blind && (x == u.ux) && (y == u.uy)) {
+            if (Blind && u_at(x, y)) {
                 You_hear("a CRASH! beneath you.");
             } else if (!Blind && cansee(x, y)) {
                 pline_The("boulder %s%s.",
@@ -244,8 +244,7 @@ flooreffects(struct obj *obj, int x, int y, const char *verb)
         /* Reasonably bulky objects (arbitrary) splash when dropped.
          * If you're floating above the water even small things make
          * noise.  Stuff dropped near fountains always misses */
-        if ((Blind || (Levitation || Flying)) && !Deaf
-            && ((x == u.ux) && (y == u.uy))) {
+        if ((Blind || (Levitation || Flying)) && !Deaf && u_at(x, y)) {
             if (!Underwater) {
                 if (weight(obj) > 9) {
                     pline("Splash!");
@@ -257,7 +256,7 @@ flooreffects(struct obj *obj, int x, int y, const char *verb)
             newsym(x, y);
         }
         res = water_damage(obj, NULL, FALSE) == ER_DESTROYED;
-    } else if (u.ux == x && u.uy == y && (t = t_at(x, y)) != 0
+    } else if (u_at(x, y) && (t = t_at(x, y)) != 0
                && (uteetering_at_seen_pit(t) || uescaped_shaft(t))) {
         if (is_pit(t->ttyp)) {
             if (Blind && !Deaf)
index a35970845192e8ba6c1ee76a1683f18c5e17a1ba..4919f7a4aa7c0ca6fef437cf1c8195598b472389 100644 (file)
@@ -447,8 +447,7 @@ gather_locs(coord **arr_p, int *cnt_p, int gloc)
     for (pass = 0; pass < 2; pass++) {
         for (x = 1; x < COLNO; x++)
             for (y = 0; y < ROWNO; y++) {
-                if ((x == u.ux && y == u.uy)
-                    || gather_locs_interesting(x, y, gloc)) {
+                if (u_at(x, y) || gather_locs_interesting(x, y, gloc)) {
                     if (!pass) {
                         ++*cnt_p;
                     } else {
@@ -1165,7 +1164,7 @@ do_mgivenname(void)
         return;
     cx = cc.x, cy = cc.y;
 
-    if (cx == u.ux && cy == u.uy) {
+    if (u_at(cx, cy)) {
         if (u.usteed && canspotmon(u.usteed)) {
             mtmp = u.usteed;
         } else {
@@ -1596,7 +1595,7 @@ namefloorobj(void)
               ? "over" : "under");
     if (getpos(&cc, FALSE, buf) < 0 || cc.x <= 0)
         return;
-    if (cc.x == u.ux && cc.y == u.uy) {
+    if (u_at(cc.x, cc.y)) {
         obj = vobj_at(u.ux, u.uy);
     } else {
         glyph = glyph_at(cc.x, cc.y);
@@ -1607,7 +1606,7 @@ namefloorobj(void)
     if (!obj) {
         /* "under you" is safe here since there's no object to hide under */
         pline("There doesn't seem to be any object %s.",
-              (cc.x == u.ux && cc.y == u.uy) ? "under you" : "there");
+              u_at(cc.x, cc.y) ? "under you" : "there");
         return;
     }
     /* note well: 'obj' might be an instance of STRANGE_OBJECT if target
index 9ad37937c743647758df68e1be916b214bc68362..486f5b38feb5f35c5f26ed6a924f4d7e4ebb0fc4 100644 (file)
@@ -570,7 +570,7 @@ dog_goal(register struct monst *mtmp, struct edog *edog,
                           && g.moves < edog->hungrytime)) {
         g.gx = u.ux;
         g.gy = u.uy;
-        if (after && udist <= 4 && g.gx == u.ux && g.gy == u.uy)
+        if (after && udist <= 4 && u_at(g.gx, g.gy))
             return -2;
         appr = (udist >= 9) ? 1 : (mtmp->mflee) ? -1 : 0;
         if (udist > 1) {
@@ -591,7 +591,7 @@ dog_goal(register struct monst *mtmp, struct edog *edog,
         appr = 0;
 
 #define FARAWAY (COLNO + 2) /* position outside screen */
-    if (g.gx == u.ux && g.gy == u.uy && !in_masters_sight) {
+    if (u_at(g.gx, g.gy) && !in_masters_sight) {
         register coord *cp;
 
         cp = gettrack(omx, omy);
index a7165b01363038003ae6f3a938b329384243f525..8cb095978197c7c2a3c58b5208ed831e06759751 100644 (file)
@@ -2874,7 +2874,7 @@ recalc_mapseen(void)
      */
     for (x = 1; x < COLNO; x++) {
         for (y = 0; y < ROWNO; y++) {
-            if (cansee(x, y) || (x == u.ux && y == u.uy && !Levitation)) {
+            if (cansee(x, y) || (u_at(x, y) && !Levitation)) {
                 ltyp = levl[x][y].typ;
                 if (ltyp == DRAWBRIDGE_UP)
                     ltyp = db_under_typ(levl[x][y].drawbridgemask);
index 35e89a9a7b2900409f6c35b55248d3f455b1b32f..8878b95784620e56a08155305e35f6e0e1deeb7d 100644 (file)
@@ -191,7 +191,7 @@ surface(int x, int y)
 {
     struct rm *lev = &levl[x][y];
 
-    if (x == u.ux && y == u.uy && u.uswallow && is_animal(u.ustuck->data))
+    if (u_at(x, y) && u.uswallow && is_animal(u.ustuck->data))
         return "maw";
     else if (IS_AIR(lev->typ) && Is_airlevel(&u.uz))
         return "air";
index d2419870d6b6aebdea71d82a174d181ed05e35bc..4068672674e401504568ab951bee88db73300f60 100644 (file)
@@ -182,7 +182,7 @@ explode(
             } else
                 explmask[i][j] = 0;
 
-            if (i + x - 1 == u.ux && j + y - 1 == u.uy) {
+            if (u_at(i + x - 1, j + y - 1)) {
                 switch (adtyp) {
                 case AD_PHYS:
                     explmask[i][j] = 0;
@@ -219,7 +219,7 @@ explode(
             }
             /* can be both you and mtmp if you're swallowed or riding */
             mtmp = m_at(i + x - 1, j + y - 1);
-            if (!mtmp && i + x - 1 == u.ux && j + y - 1 == u.uy)
+            if (!mtmp && u_at(i + x - 1, j + y - 1))
                 mtmp = u.usteed;
             if (mtmp) {
                 if (DEADMONSTER(mtmp))
@@ -327,7 +327,7 @@ explode(
             for (j = 0; j < 3; j++) {
                 if (explmask[i][j] == 2)
                     continue;
-                if (i + x - 1 == u.ux && j + y - 1 == u.uy) {
+                if (u_at(i + x - 1, j + y - 1)) {
                     uhurt = (explmask[i][j] == 1) ? 1 : 2;
                     /* If the player is attacking via polyself into something
                      * with an explosion attack, leave them (and their gear)
@@ -348,7 +348,7 @@ explode(
                                           &shopdamage, exploding_wand_typ);
 
                 mtmp = m_at(i + x - 1, j + y - 1);
-                if (!mtmp && i + x - 1 == u.ux && j + y - 1 == u.uy)
+                if (!mtmp && u_at(i + x - 1, j + y - 1))
                     mtmp = u.usteed;
                 if (!mtmp)
                     continue;
@@ -766,7 +766,7 @@ scatter(int sx, int sy,  /* location of objects to scatter */
                             stmp->stopped = TRUE;
                         }
                     }
-                } else if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) {
+                } else if (u_at(g.bhitpos.x, g.bhitpos.y)) {
                     if (scflags & MAY_HITYOU) {
                         int hitvalu, hitu;
 
@@ -836,8 +836,7 @@ scatter(int sx, int sy,  /* location of objects to scatter */
         newsym(x, y);
     }
     newsym(sx, sy);
-    if (sx == u.ux && sy == u.uy && u.uundetected
-        && hides_under(g.youmonst.data))
+    if (u_at(sx, sy) && u.uundetected && hides_under(g.youmonst.data))
         (void) hideunder(&g.youmonst);
     if (lostgoods) /* implies shop_origin and therefore shkp valid */
         credit_report(shkp, 1, FALSE);
index dbc19f887f2406c8d4fd28cd726612326ca3d477..b6d389560f098adec324a9df9e90f496c611fbd8 100644 (file)
@@ -125,7 +125,7 @@ gush(int x, int y, genericptr_t poolcnt)
     register struct monst *mtmp;
     register struct trap *ttmp;
 
-    if (((x + y) % 2) || (x == u.ux && y == u.uy)
+    if (((x + y) % 2) || u_at(x, y)
         || (rn2(1 + distmin(u.ux, u.uy, x, y))) || (levl[x][y].typ != ROOM)
         || (sobj_at(BOULDER, x, y)) || nexttodoor(x, y))
         return;
@@ -519,7 +519,7 @@ dipfountain(register struct obj *obj)
 void
 breaksink(int x, int y)
 {
-    if (cansee(x, y) || (x == u.ux && y == u.uy))
+    if (cansee(x, y) || u_at(x, y))
         pline_The("pipes break!  Water spurts out!");
     g.level.flags.nsinks--;
     levl[x][y].typ = FOUNTAIN, levl[x][y].looted = 0;
index d7eb8f09c25e644a0419f22aab603d57bd506491..5dbb7ebc7354cef44c711a7c34eeff1ba1f71178 100644 (file)
@@ -633,7 +633,7 @@ still_chewing(xchar x, xchar y)
                updates hunger state and requests status update if changed */
             morehungry(-nut);
         }
-        digtxt = (x == u.ux && y == u.uy)
+        digtxt = u_at(x, y)
                  ? "devour the iron bars."
                  : "eat through the bars.";
         dissolve_bars(x, y);
@@ -1282,7 +1282,7 @@ findtravelpath(int mode)
                         }
                     }
 
-            if (px == u.ux && py == u.uy) {
+            if (u_at(px, py)) {
                 /* no guesses, just go in the general direction */
                 u.dx = sgn(u.tx - u.ux);
                 u.dy = sgn(u.ty - u.uy);
@@ -1332,7 +1332,7 @@ is_valid_travelpt(int x, int y)
     boolean ret;
     int glyph = glyph_at(x,y);
 
-    if (x == u.ux && y == u.uy)
+    if (u_at(x, y))
         return TRUE;
     if (isok(x,y) && glyph_is_cmap(glyph) && S_stone == glyph_to_cmap(glyph)
         && !levl[x][y].seenv)
@@ -2489,7 +2489,7 @@ spoteffects(boolean pick)
     /* prevent recursion from affecting the hero all over again
        [hero poly'd to iron golem enters water here, drown() inflicts
        damage that triggers rehumanize() which calls spoteffects()...] */
-    if (inspoteffects && u.ux == spotloc.x && u.uy == spotloc.y
+    if (inspoteffects && u_at(spotloc.x, spotloc.y)
         /* except when reason is transformed terrain (ice -> water) */
         && spotterrain == levl[u.ux][u.uy].typ
         /* or transformed trap (land mine -> pit) */
@@ -3042,7 +3042,7 @@ lookaround(void)
     for (x = u.ux - 1; x <= u.ux + 1; x++)
         for (y = u.uy - 1; y <= u.uy + 1; y++) {
             /* ignore out of bounds, and our own location */
-            if (!isok(x, y) || (x == u.ux && y == u.uy))
+            if (!isok(x, y) || u_at(x, y))
                 continue;
             /* (grid bugs) ignore diagonals */
             if (NODIAG(u.umonnum) && x != u.ux && y != u.uy)
@@ -3246,7 +3246,7 @@ monster_nearby(void)
     /* Also see the similar check in dochugw() in monmove.c */
     for (x = u.ux - 1; x <= u.ux + 1; x++)
         for (y = u.uy - 1; y <= u.uy + 1; y++) {
-            if (!isok(x, y) || (x == u.ux && y == u.uy))
+            if (!isok(x, y) || u_at(x, y))
                 continue;
             if ((mtmp = m_at(x, y)) != 0
                 && M_AP_TYPE(mtmp) != M_AP_FURNITURE
index 502ca71d8f5429fca8d14720472e33447f3bf27d..1142ae9bf3a1de13b5977f80faaff579fde606b7 100644 (file)
@@ -3935,7 +3935,7 @@ void
 useupf(struct obj *obj, long numused)
 {
     struct obj *otmp;
-    boolean at_u = (obj->ox == u.ux && obj->oy == u.uy);
+    boolean at_u = u_at(obj->ox, obj->oy);
 
     /* burn_floor_objects() keeps an object pointer that it tries to
      * useupf() multiple times, so obj must survive if plural */
index 591cc0e8a47ab96227a6e3d30d56422db0d1bdd4..bf379161678b73a35ae5cb1a1aa72dca80237485 100644 (file)
@@ -162,7 +162,7 @@ do_light_sources(xchar **cs_rows)
 
         /* minor optimization: don't bother with duplicate light sources
            at hero */
-        if (ls->x == u.ux && ls->y == u.uy) {
+        if (u_at(ls->x, ls->y)) {
             if (at_hero_range >= ls->range)
                 ls->flags &= ~LSF_SHOW;
             else
@@ -190,7 +190,7 @@ do_light_sources(xchar **cs_rows)
                 if ((max_x = (ls->x + offset)) >= COLNO)
                     max_x = COLNO - 1;
 
-                if (ls->x == u.ux && ls->y == u.uy) {
+                if (u_at(ls->x, ls->y)) {
                     /*
                      * If the light source is located at the hero, then
                      * we can use the COULD_SEE bits already calculated
index 123aeb991d24412578f93c8fe793993ec5006a26..0d2ddda80ac515b9e448cbcbb001d65b23af4fb1 100644 (file)
@@ -416,7 +416,7 @@ pick_lock(struct obj *pick,
         return PICKLOCK_DID_NOTHING;
     }
 
-    if (cc.x == u.ux && cc.y == u.uy) { /* pick lock on a container */
+    if (u_at(cc.x, cc.y)) { /* pick lock on a container */
         const char *verb;
         char qsfx[QBUFSZ];
         boolean it;
@@ -740,7 +740,7 @@ doopen_indir(int x, int y)
         return ECMD_OK;
 
     /* open at yourself/up/down */
-    if ((cc.x == u.ux) && (cc.y == u.uy))
+    if (u_at(cc.x, cc.y))
         return doloot();
 
     if (stumble_on_door_mimic(cc.x, cc.y))
@@ -885,7 +885,7 @@ doclose(void)
 
     x = u.ux + u.dx;
     y = u.uy + u.dy;
-    if ((x == u.ux) && (y == u.uy)) {
+    if (u_at(x, y)) {
         You("are in the way!");
         return ECMD_TIME;
     }
index 6fceff2a999763b4dde8a8323a3c8a55718573f3..7274ac0e144c3bedede89d4c83289bf609d1e11c 100644 (file)
@@ -251,7 +251,7 @@ md_stop(coord *stopp,  /* stopping position (we fill it in) */
 
     for (x = u.ux - 1; x <= u.ux + 1; x++)
         for (y = u.uy - 1; y <= u.uy + 1; y++) {
-            if (!isok(x, y) || (x == u.ux && y == u.uy))
+            if (!isok(x, y) || u_at(x, y))
                 continue;
 
             if (accessible(x, y) && !MON_AT(x, y)) {
@@ -334,7 +334,7 @@ md_rush(struct monst *md,
 
         if ((mon = m_at(fx, fy)) != 0) /* save monster at this position */
             verbalize1(md_exclamations());
-        else if (fx == u.ux && fy == u.uy)
+        else if (u_at(fx, fy))
             verbalize("Excuse me.");
 
         if (mon)
index a06eaaf72f6f86f21ad80a7d3c8f10472ed141d1..a4cae89f73fc8d8d80e9a315e6573da6d351e24e 100644 (file)
@@ -1118,7 +1118,7 @@ makemon(register struct permonst *ptr,
     coord cc;
     int mndx, mcham, ct, mitem;
     boolean anymon = !ptr,
-            byyou = (x == u.ux && y == u.uy),
+            byyou = u_at(x, y),
             allow_minvent = ((mmflags & NO_MINVENT) == 0),
             countbirth = ((mmflags & MM_NOCOUNTBIRTH) == 0),
             allowtail = ((mmflags & MM_NOTAIL) == 0);
index 515201fd1cd77a487094ae8711af585e4f73af97..23c7243a5b0f62dfe765a910a46cd05e8d00135c 100644 (file)
@@ -403,7 +403,7 @@ mattacku(register struct monst *mtmp)
      */
     boolean ranged = (distu(mtmp->mx, mtmp->my) > 3),
             range2 = !monnear(mtmp, mtmp->mux, mtmp->muy),
-            foundyou = (mtmp->mux == u.ux && mtmp->muy == u.uy),
+            foundyou = u_at(mtmp->mux, mtmp->muy),
             youseeit = canseemon(mtmp),
             skipnonmagc = FALSE;
 
index 17dda6a8c8a9c0ddbe2721ee58e8807fffe45a92..8b256ca3472b3db7204392094c669cd148601dd5 100644 (file)
@@ -1432,7 +1432,7 @@ movebubbles(void)
                             mon->mx = mon->my = 0;
                             mon->mstate |= MON_BUBBLEMOVE;
                         }
-                        if (!u.uswallow && x == u.ux && y == u.uy) {
+                        if (!u.uswallow && u_at(x, y)) {
                             cons = (struct container *) alloc(sizeof *cons);
                             cons->x = x;
                             cons->y = y;
index 7612d791031311a30297cc9dd595bdface9fdf8f..3dd7a562ff10a883c36697bcc409d16029e5b24e 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1891,9 +1891,9 @@ mfndpos(
                         continue;
                     info[cnt] |= ALLOW_SSM;
                 }
-                if ((nx == u.ux && ny == u.uy)
+                if (u_at(nx, ny)
                     || (nx == mon->mux && ny == mon->muy)) {
-                    if (nx == u.ux && ny == u.uy) {
+                    if (u_at(nx, ny)) {
                         /* If it's right next to you, it found you,
                          * displaced or no.  We must set mux and muy
                          * right now, so when we return we can tell
index 1605f7c034d58196b7cbd4cea7f3663f84fb3784..79222263eea5d691bbaeee62c4d177a08bc48803 100644 (file)
@@ -175,8 +175,7 @@ onscary(int x, int y, struct monst* mtmp)
      * Astral Plane; the influence of the Valar only reaches so far.
      */
     return (sengr_at("Elbereth", x, y, TRUE)
-            && ((u.ux == x && u.uy == y)
-                || (Displaced && mtmp->mux == x && mtmp->muy == y))
+            && (u_at(x, y) || (Displaced && mtmp->mux == x && mtmp->muy == y))
             && !(mtmp->isshk || mtmp->isgd || !mtmp->mcansee
                  || mtmp->mpeaceful || mtmp->data->mlet == S_HUMAN
                  || mtmp->data == &mons[PM_MINOTAUR]
@@ -1398,7 +1397,7 @@ m_move(register struct monst* mtmp, register int after)
             nix = mtmp->mux;
             niy = mtmp->muy;
         }
-        if (nix == u.ux && niy == u.uy) {
+        if (u_at(nix, niy)) {
             mtmp->mux = u.ux;
             mtmp->muy = u.uy;
             return 0;
@@ -1751,7 +1750,7 @@ dissolve_bars(register int x, register int y)
     levl[x][y].typ = (Is_special(&u.uz) || *in_rooms(x, y, 0)) ? ROOM : CORR;
     levl[x][y].flags = 0;
     newsym(x, y);
-    if (x == u.ux && y == u.uy)
+    if (u_at(x, y))
         switch_terrain();
 }
 
@@ -1792,7 +1791,7 @@ set_apparxy(register struct monst* mtmp)
 
     /* monsters which know where you are don't suddenly forget,
        if you haven't moved away */
-    if (mx == u.ux && my == u.uy)
+    if (u_at(mx, my))
         goto found_you;
 
     notseen = (!mtmp->mcansee || (Invis && !perceives(mtmp->data)));
index 6c63ac5524cd7293c5e1cad0c5104d9ed57bb8db..a0cb795fff2fcc1edff5a7a8e08f098e4de76e6e 100644 (file)
@@ -181,7 +181,7 @@ drop_throw(
         if (!objgone) {
             if (!flooreffects(obj, x, y, "fall")) {
                 place_object(obj, x, y);
-                if (!mtmp && x == u.ux && y == u.uy)
+                if (!mtmp && u_at(x, y))
                     mtmp = &g.youmonst;
                 if (mtmp && ohit)
                     passive_obj(mtmp, obj, (struct attack *) 0);
@@ -598,7 +598,7 @@ m_throw(
         } else if (mtmp) {
             if (ohitmon(mtmp, singleobj, range, TRUE))
                 break;
-        } else if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) {
+        } else if (u_at(g.bhitpos.x, g.bhitpos.y)) {
             if (g.multi)
                 nomul(0);
 
@@ -1110,8 +1110,8 @@ linedup(
     /* straight line, orthogonal to the map or diagonal */
     if ((!g.tbx || !g.tby || abs(g.tbx) == abs(g.tby))
         && distmin(g.tbx, g.tby, 0, 0) < BOLT_LIM) {
-        if ((ax == u.ux && ay == u.uy) ? (boolean) couldsee(bx, by)
-                                       : clear_path(ax, ay, bx, by))
+        if (u_at(ax, ay) ? (boolean) couldsee(bx, by)
+                         : clear_path(ax, ay, bx, by))
             return TRUE;
         /* don't have line of sight, but might still be lined up
            if that lack of sight is due solely to boulders */
index a450e499ac6e1433a31cb451eb418908d00a4372..9ed9b2ed2837e742285664d4e311b6a7d3fbac71 100644 (file)
@@ -484,7 +484,7 @@ find_defensive(struct monst* mtmp)
             /* skip if it's hero's location
                or a diagonal spot and monster can't move diagonally
                or some other monster is there */
-            if ((xx == u.ux && yy == u.uy)
+            if (u_at(xx, yy)
                 || (xx != x && yy != y && !diag_ok)
                 || (g.level.monsters[xx][yy] && !(xx == x && yy == y)))
                 continue;
@@ -1483,7 +1483,7 @@ mbhit(
             case WAN_STRIKING:
                 destroy_drawbridge(x, y);
             }
-        if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) {
+        if (u_at(g.bhitpos.x, g.bhitpos.y)) {
             (*fhitm)(&g.youmonst, obj);
             range -= 3;
         } else if ((mtmp = m_at(g.bhitpos.x, g.bhitpos.y)) != 0) {
@@ -1854,7 +1854,7 @@ find_misc(struct monst* mtmp)
                monster from attempting disarm every turn */
             && uwep && !rn2(5) && obj == MON_WEP(mtmp)
             /* hero's location must be known and adjacent */
-            && mtmp->mux == u.ux && mtmp->muy == u.uy
+            && u_at(mtmp->mux, mtmp->muy)
             && next2u(mtmp->mx, mtmp->my)
             /* don't bother if it can't work (this doesn't
                prevent cursed weapons from being targetted) */
index 1e38064e3b5c93e4a400f48150e000c7184c5016..f471210c8711e90609caa2743660193414c76660 100644 (file)
@@ -349,7 +349,7 @@ do_earthquake(int force)
                 if ((otmp = sobj_at(BOULDER, x, y)) != 0) {
                     if (cansee(x, y))
                         pline("KADOOM!  The boulder falls into a chasm%s!",
-                              (x == u.ux && y == u.uy) ? " below you" : "");
+                              u_at(x, y) ? " below you" : "");
                     if (mtmp)
                         mtmp->mtrapped = 0;
                     obj_extract_self(otmp);
@@ -391,7 +391,7 @@ do_earthquake(int force)
                             }
                         }
                     }
-                } else if (x == u.ux && y == u.uy) {
+                } else if (u_at(x, y)) {
                     if (u.utrap && u.utraptype == TT_BURIEDBALL) {
                         /* Note:  the chain should break if a pit gets
                            created at the buried ball's location, which
index 6b148026e1b67e17eb40b3d37536dd54a04ab6dd..c40dc11e8a27a83e35d3c99474ae19f8701fa7d1 100644 (file)
@@ -533,7 +533,7 @@ lookat(int x, int y, char *buf, char *monbuf)
 
     buf[0] = monbuf[0] = '\0';
     glyph = glyph_at(x, y);
-    if (u.ux == x && u.uy == y && canspotself()
+    if (u_at(x, y) && canspotself()
         && !(iflags.save_uswallow
              && glyph == mon_to_glyph(u.ustuck, rn2_on_display_rng))
         && (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0)) {
@@ -1161,7 +1161,7 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str,
            playing a character which isn't normally displayed by that
            symbol; firstmatch is assumed to already be set for '@' */
         if ((looked ? (sym == g.showsyms[S_HUMAN + SYM_OFF_M]
-                       && cc.x == u.ux && cc.y == u.uy)
+                       && u_at(cc.x, cc.y))
                     : (sym == def_monsyms[S_HUMAN].sym && !flags.showrace))
             && !(Race_if(PM_HUMAN) || Race_if(PM_ELF)) && !Upolyd)
             found += append_str(out_str, "you"); /* tack on "or you" */
@@ -1664,7 +1664,7 @@ look_all(
 
                     g.bhitpos.x = x; /* [is this actually necessary?] */
                     g.bhitpos.y = y;
-                    if (x == u.ux && y == u.uy && canspotself()) {
+                    if (u_at(x, y) && canspotself()) {
                         (void) self_lookat(lookbuf);
                         ++count;
                     } else if ((mtmp = m_at(x, y)) != 0) {
index d0da3e6672762a6b792a58a35d24a676d46b2c2a..397d4728394dee435c4910a07bd874b0e9d351fd 100644 (file)
@@ -2040,7 +2040,7 @@ doloot_core(void)
         if (!get_adjacent_loc("Loot in what direction?",
                               "Invalid loot location", u.ux, u.uy, &cc))
             return ECMD_OK;
-        if (cc.x == u.ux && cc.y == u.uy) {
+        if (u_at(cc.x, cc.y)) {
             underfoot = TRUE;
             if (container_at(cc.x, cc.y, FALSE))
                 goto lootcont;
index 885078a7e31f8d14d971cdeec8ae17f929ac088e..29886b86068a7e2fe0a54d05d6406b8c46cbc0c2 100644 (file)
@@ -755,7 +755,7 @@ ghod_hitsu(struct monst *priest)
     ay = y = EPRI(priest)->shrpos.y;
     troom = &g.rooms[roomno - ROOMOFFSET];
 
-    if ((u.ux == x && u.uy == y) || !linedup(u.ux, u.uy, x, y, 1)) {
+    if (u_at(x, y) || !linedup(u.ux, u.uy, x, y, 1)) {
         if (IS_DOOR(levl[u.ux][u.uy].typ)) {
             if (u.ux == troom->lx - 1) {
                 x = troom->hx;
index bb9d50a202a1fba6eccd29d76147d6a764fbf9a1..bfc1353cfa66cf9a4c026ba3d8bf6054ec08d997 100644 (file)
@@ -1757,7 +1757,7 @@ seffect_fire(struct obj **sobjp)
                 cc.y = u.uy;
             }
         }
-        if (cc.x == u.ux && cc.y == u.uy) {
+        if (u_at(cc.x, cc.y)) {
             pline_The("scroll erupts in a tower of flame!");
             iflags.last_msg = PLNMSG_TOWER_OF_FLAME; /* for explode() */
             burn_away_slime();
index bcae7c0d86bdbfce09bc8253cee7ec86998f0956..e54a175044cfaeea37f57b1e4dc414e2818d5f7e 100644 (file)
@@ -985,7 +985,7 @@ expire_gas_cloud(genericptr_t p1, genericptr_t p2 UNUSED)
             if (inside_region(reg, x, y)) {
                 if (!does_block(x, y, &levl[x][y]))
                     unblock_point(x, y);
-                if (x == u.ux && y == u.uy)
+                if (u_at(x, y))
                     g.gas_cloud_diss_within = TRUE;
                 if (cansee(x, y))
                     g.gas_cloud_diss_seen++;
index d1d1cf0fc5ed00b1b762a43ef6b7d90e2995a02b..883c71a0b8ee9433747312a3ff422c692c8acc6e 100644 (file)
--- a/src/shk.c
+++ b/src/shk.c
@@ -534,7 +534,7 @@ deserted_shop(/*const*/ char* enterstring)
 
     for (x = r->lx; x <= r->hx; ++x)
         for (y = r->ly; y <= r->hy; ++y) {
-            if (x == u.ux && y == u.uy)
+            if (u_at(x, y))
                 continue;
             if ((mtmp = m_at(x, y)) != 0) {
                 ++n;
@@ -1304,7 +1304,7 @@ dopay(void)
             pline("Try again...");
             return ECMD_OK;
         }
-        if (u.ux == cx && u.uy == cy) {
+        if (u_at(cx, cy)) {
             You("are generous to yourself.");
             return ECMD_OK;
         }
@@ -1888,7 +1888,7 @@ set_repo_loc(struct monst* shkp)
     /* if you're not in this shk's shop room, or if you're in its doorway
         or entry spot, then your gear gets dumped all the way inside */
     if (*u.ushops != eshkp->shoproom || IS_DOOR(levl[u.ux][u.uy].typ)
-        || (u.ux == eshkp->shk.x && u.uy == eshkp->shk.y)) {
+        || u_at(eshkp->shk.x, eshkp->shk.y)) {
         /* shk.x,shk.y is the position immediately in
          * front of the door -- move in one more space
          */
@@ -3544,7 +3544,7 @@ repairable_damage(struct damage *dam, struct monst *shkp)
         return FALSE;
     /* is it a wall? don't fix if anyone is in the way */
     if (!IS_ROOM(dam->typ)) {
-        if ((x == u.ux && y == u.uy && !Passes_walls)
+        if ((u_at(x, y) && !Passes_walls)
             || (x == shkp->mx && y == shkp->my)
             || ((mtmp = m_at(x, y)) != 0 && !passes_walls(mtmp->data)))
             return FALSE;
@@ -3552,7 +3552,7 @@ repairable_damage(struct damage *dam, struct monst *shkp)
     /* is it a trap? don't fix if hero or monster is in it */
     ttmp = t_at(x, y);
     if (ttmp) {
-        if (x == u.ux && y == u.uy)
+        if (u_at(x, y))
             return FALSE;
         if ((mtmp = m_at(x,y)) != 0 && mtmp->mtrapped)
             return FALSE;
@@ -3956,7 +3956,7 @@ shk_move(struct monst* shkp)
         if (Invis || u.usteed) {
             avoid = FALSE;
         } else {
-            uondoor = (u.ux == eshkp->shd.x && u.uy == eshkp->shd.y);
+            uondoor = u_at(eshkp->shd.x, eshkp->shd.y);
             if (uondoor) {
                 badinv =
                     (carrying(PICK_AXE) || carrying(DWARVISH_MATTOCK)
index 976d630875aef8eb65d0cedba2b90630f476799c..d87ed719742305ca7db7ad9a8df5b9aa1b2bea9d 100644 (file)
@@ -449,7 +449,7 @@ landing_spot(
     for (; !found && i < 2; ++i) {
         for (x = u.ux - 1; x <= u.ux + 1; x++)
             for (y = u.uy - 1; y <= u.uy + 1; y++) {
-                if (!isok(x, y) || (x == u.ux && y == u.uy))
+                if (!isok(x, y) || u_at(x, y))
                     continue;
 
                 if (accessible(x, y) && !MON_AT(x, y)
index bf40b82a020cdc91eb10456df45562d631f2147c..305cc929164a58b33e6f12b27d828bd327061227 100644 (file)
@@ -55,7 +55,7 @@ goodpos(int x, int y, struct monst* mtmp, long gpflags)
      * oh well.
      */
     if (!allow_u) {
-        if (x == u.ux && y == u.uy && mtmp != &g.youmonst
+        if (u_at(x, y) && mtmp != &g.youmonst
             && (mtmp != u.ustuck || !u.uswallow)
             && (!u.usteed || mtmp != u.usteed))
             return FALSE;
@@ -532,7 +532,7 @@ scrolltele(struct obj* scroll)
             if (teleok(cc.x, cc.y, FALSE)) {
                 /* for scroll, discover it regardless of destination */
                 teleds(cc.x, cc.y, TELEDS_TELEPORT);
-                if (iflags.travelcc.x == u.ux && iflags.travelcc.y == u.uy)
+                if (u_at(iflags.travelcc.x, iflags.travelcc.y))
                     iflags.travelcc.x = iflags.travelcc.y = 0;
                 return;
             }
index 3fb7bf3e111018dca0cbbc5f601b5769d1fbc750..224a9651c74a06641ef1b5629481b71152a03279 100644 (file)
@@ -350,7 +350,7 @@ maketrap(int x, int y, int typ)
         if (undestroyable_trap(ttmp->ttyp))
             return (struct trap *) 0;
         oldplace = TRUE;
-        if (u.utrap && x == u.ux && y == u.uy
+        if (u.utrap && u_at(x, y)
             && ((u.utraptype == TT_BEARTRAP && typ != BEAR_TRAP)
                 || (u.utraptype == TT_WEB && typ != WEB)
                 || (u.utraptype == TT_PIT && !is_pit(typ))
@@ -691,7 +691,7 @@ animate_statue(
                     : golem_xform ? "turns into flesh"
                       : (nonliving(mon->data) || is_vampshifter(mon)) ? "moves"
                         : "comes to life";
-    if ((x == u.ux && y == u.uy) || cause == ANIMATE_SPELL) {
+    if (u_at(x, y) || cause == ANIMATE_SPELL) {
         /* "the|your|Manlobbi's statue [of a wombat]" */
         shkp = shop_keeper(*in_rooms(mon->mx, mon->my, SHOPBASE));
         Sprintf(statuename, "%s%s", shk_your(tmpbuf, statue),
@@ -761,7 +761,7 @@ animate_statue(
     delobj(statue);
 
     /* avoid hiding under nothing */
-    if (x == u.ux && y == u.uy && Upolyd && hides_under(g.youmonst.data)
+    if (u_at(x, y) && Upolyd && hides_under(g.youmonst.data)
         && !OBJ_AT(x, y))
         u.uundetected = 0;
 
@@ -2797,7 +2797,7 @@ launch_obj(
                 launch_drop_spot((struct obj *) 0, 0, 0);
                 break;
             }
-        } else if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) {
+        } else if (u_at(g.bhitpos.x, g.bhitpos.y)) {
             if (g.multi)
                 nomul(0);
             if (thitu(9 + singleobj->spe, dmgval(singleobj, &g.youmonst),
@@ -4461,7 +4461,7 @@ cnv_trap_obj(
         stackobj(otmp);
     }
     newsym(ttmp->tx, ttmp->ty);
-    if (u.utrap && ttmp->tx == u.ux && ttmp->ty == u.uy)
+    if (u.utrap && u_at(ttmp->tx, ttmp->ty))
         reset_utrap(TRUE);
     deltrap(ttmp);
 }
@@ -4882,7 +4882,7 @@ untrap(boolean force)
     if (ttmp && !ttmp->tseen)
         ttmp = 0;
     trapdescr = ttmp ? trapname(ttmp->ttyp, FALSE) : 0;
-    here = (x == u.ux && y == u.uy); /* !u.dx && !u.dy */
+    here = u_at(x, y); /* !u.dx && !u.dy */
 
     if (here) /* are there are one or more containers here? */
         for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere)
@@ -4941,7 +4941,7 @@ untrap(boolean force)
             if (deal_with_floor_trap) {
                 if (u.utrap) {
                     You("cannot deal with %s while trapped%s!", the_trap,
-                        (x == u.ux && y == u.uy) ? " in it" : "");
+                        u_at(x, y) ? " in it" : "");
                     return 1;
                 }
                 if ((mtmp = m_at(x, y)) != 0
@@ -5354,9 +5354,9 @@ chest_trap(
             delete_contents(obj);
             /* unpunish() in advance if either ball or chain (or both)
                is going to be destroyed */
-            if (Punished && ((uchain->ox == u.ux && uchain->oy == u.uy)
+            if (Punished && (u_at(uchain->ox, uchain->oy)
                              || (uball->where == OBJ_FLOOR
-                                 && uball->ox == u.ux && uball->oy == u.uy)))
+                                 && u_at(uball->ox, uball->oy))))
                 unpunish();
 
             for (otmp = g.level.objects[u.ux][u.uy]; otmp; otmp = otmp2) {
@@ -5613,7 +5613,7 @@ boolean
 uteetering_at_seen_pit(struct trap* trap)
 {
     return (trap && is_pit(trap->ttyp) && trap->tseen
-            && trap->tx == u.ux && trap->ty == u.uy
+            && u_at(trap->tx, trap->ty)
             && !(u.utrap && u.utraptype == TT_PIT));
 }
 
@@ -5625,7 +5625,7 @@ boolean
 uescaped_shaft(struct trap* trap)
 {
     return (trap && is_hole(trap->ttyp) && trap->tseen
-            && trap->tx == u.ux && trap->ty == u.uy);
+            && u_at(trap->tx, trap->ty));
 }
 
 /* Destroy a trap that emanates from the floor. */
@@ -5642,7 +5642,7 @@ delfloortrap(struct trap* ttmp)
                  || (ttmp->ttyp == ANTI_MAGIC))) {
         register struct monst *mtmp;
 
-        if (ttmp->tx == u.ux && ttmp->ty == u.uy) {
+        if (u_at(ttmp->tx, ttmp->ty)) {
             if (u.utraptype != TT_BURIEDBALL)
                 reset_utrap(TRUE);
         } else if ((mtmp = m_at(ttmp->tx, ttmp->ty)) != 0) {
index 81b06b60a2ad14ef90f317b0b9adad30c7fcb8ef..71a8a644e8d89d15f02124b95fc9b1f4d6e9bfef 100644 (file)
@@ -63,7 +63,7 @@ clear_fcorr(struct monst *grd, boolean forceshow)
         if ((DEADMONSTER(grd) || !in_fcorridor(grd, u.ux, u.uy))
             && egrd->gddone)
             forceshow = TRUE;
-        if ((u.ux == fcx && u.uy == fcy && !DEADMONSTER(grd))
+        if ((u_at(fcx, fcy) && !DEADMONSTER(grd))
             || (!forceshow && couldsee(fcx, fcy))
             || (Punished && !carried(uball) && uball->ox == fcx
                 && uball->oy == fcy))
@@ -352,7 +352,7 @@ invault(void)
             else
                 y += dy;
         }
-        if (x == u.ux && y == u.uy) {
+        if (u_at(x, y)) {
             if (levl[x + 1][y].typ == HWALL || levl[x + 1][y].typ == DOOR)
                 x = x + 1;
             else if (levl[x - 1][y].typ == HWALL
@@ -686,7 +686,7 @@ gd_pick_corridor_gold(struct monst *grd, int goldx, int goldy)
     coord newcc, bestcc;
     int gdelta, newdelta, bestdelta, tryct,
         guardx = grd->mx, guardy = grd->my;
-    boolean under_u = (goldx == u.ux && goldy == u.uy),
+    boolean under_u = u_at(goldx, goldy),
             see_it = cansee(goldx, goldy);
 
     if (under_u) {
index d917adcef7505fa78d450f87f1c0640a84344d5d..784a20b9055609708ee2f3a7d4a2da408dc7937e 100644 (file)
@@ -394,7 +394,7 @@ tactics(struct monst *mtmp)
         if (!targ) { /* simply wants you to close */
             return 0;
         }
-        if ((u.ux == tx && u.uy == ty) || where == STRAT_PLAYER) {
+        if (u_at(tx, ty) || where == STRAT_PLAYER) {
             /* player is standing on it (or has it) */
             mnexto(mtmp, RLOC_MSG);
             return 0;
index 19ca24af0d41a34bba3b683812726a212ea4e37f..e052e894f6feb66e2d69706f3d91d216e75ef83c 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -3772,7 +3772,7 @@ boomhit(struct obj *obj, int dx, int dy)
             g.bhitpos.y -= dy;
             break;
         }
-        if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) { /* ct == 9 */
+        if (u_at(g.bhitpos.x, g.bhitpos.y)) { /* ct == 9 */
             if (Fumbling || rn2(20) >= ACURR(A_DEX)) {
                 /* we hit ourselves */
                 (void) thitu(10 + obj->spe, dmgval(obj, &g.youmonst), &obj,
@@ -4149,11 +4149,11 @@ burn_floor_objects(int x, int y,
                 /* save name before potential delobj() */
                 if (give_feedback) {
                     obj->quan = 1L;
-                    Strcpy(buf1, (x == u.ux && y == u.uy)
+                    Strcpy(buf1, u_at(x, y)
                                      ? xname(obj)
                                      : distant_name(obj, xname));
                     obj->quan = 2L;
-                    Strcpy(buf2, (x == u.ux && y == u.uy)
+                    Strcpy(buf2, u_at(x, y)
                                      ? xname(obj)
                                      : distant_name(obj, xname));
                     obj->quan = scrquan;
@@ -4412,7 +4412,7 @@ dobuzz(int type, int nd, xchar sx, xchar sy, int dx, int dy,
                 if (say || canseemon(mon))
                     miss(flash_str(fltyp, FALSE), mon);
             }
-        } else if (sx == u.ux && sy == u.uy && range >= 0) {
+        } else if (u_at(sx, sy) && range >= 0) {
             nomul(0);
             if (u.usteed && !rn2(3) && !mon_reflects(u.usteed, (char *) 0)) {
                 mon = u.usteed;
@@ -4545,7 +4545,7 @@ melt_ice(xchar x, xchar y, const char *msg)
     if (Underwater)
         vision_recalc(1);
     newsym(x, y);
-    if (cansee(x, y) || (x == u.ux && y == u.uy))
+    if (cansee(x, y) || u_at(x, y))
         Norep("%s", msg);
     if ((otmp = sobj_at(BOULDER, x, y)) != 0) {
         if (cansee(x, y))
@@ -4558,7 +4558,7 @@ melt_ice(xchar x, xchar y, const char *msg)
         } while (is_pool(x, y) && (otmp = sobj_at(BOULDER, x, y)) != 0);
         newsym(x, y);
     }
-    if (x == u.ux && y == u.uy)
+    if (u_at(x, y))
         spoteffects(TRUE); /* possibly drown, notice objects */
     else if (is_pool(x, y) && (mtmp = m_at(x, y)) != 0)
         (void) minliquid(mtmp);
@@ -4739,7 +4739,7 @@ zap_over_floor(xchar x, xchar y, int type, boolean *shopdamage,
                 } else if (!lava)
                     You_hear("a crackling sound.");
 
-                if (x == u.ux && y == u.uy) {
+                if (u_at(x, y)) {
                     if (u.uinwater) { /* not just `if (Underwater)' */
                         /* leave the no longer existent water */
                         set_uinwater(0); /* u.uinwater = 0 */