From 8e91320d2f8fbc3477a38151fc6d395118baa0ba Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 23 Feb 2022 20:28:35 +0200 Subject: [PATCH] Use u_at macro --- include/you.h | 2 ++ src/apply.c | 11 +++++------ src/bones.c | 2 +- src/cmd.c | 6 +++--- src/dbridge.c | 2 +- src/detect.c | 26 +++++++++++++------------- src/dig.c | 11 +++++------ src/display.c | 10 +++++----- src/do.c | 9 ++++----- src/do_name.c | 9 ++++----- src/dogmove.c | 4 ++-- src/dungeon.c | 2 +- src/engrave.c | 2 +- src/explode.c | 13 ++++++------- src/fountain.c | 4 ++-- src/hack.c | 12 ++++++------ src/invent.c | 2 +- src/light.c | 4 ++-- src/lock.c | 6 +++--- src/mail.c | 4 ++-- src/makemon.c | 2 +- src/mhitu.c | 2 +- src/mkmaze.c | 2 +- src/mon.c | 4 ++-- src/monmove.c | 9 ++++----- src/mthrowu.c | 8 ++++---- src/muse.c | 6 +++--- src/music.c | 4 ++-- src/pager.c | 6 +++--- src/pickup.c | 2 +- src/priest.c | 2 +- src/read.c | 2 +- src/region.c | 2 +- src/shk.c | 12 ++++++------ src/steed.c | 2 +- src/teleport.c | 4 ++-- src/trap.c | 24 ++++++++++++------------ src/vault.c | 6 +++--- src/wizard.c | 2 +- src/zap.c | 14 +++++++------- 40 files changed, 126 insertions(+), 130 deletions(-) diff --git a/include/you.h b/include/you.h index 8b3adaff3..a563a4063 100644 --- a/include/you.h +++ b/include/you.h @@ -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 */ diff --git a/src/apply.c b/src/apply.c index 9d16053a7..86b39e0ae 100644 --- a/src/apply.c +++ b/src/apply.c @@ -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!"); diff --git a/src/bones.c b/src/bones.c index c34bd1449..6fa2dac4e 100644 --- a/src/bones.c +++ b/src/bones.c @@ -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; diff --git a/src/cmd.c b/src/cmd.c index 69dc376e1..9c16566bc 100644 --- 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); diff --git a/src/dbridge.c b/src/dbridge.c index 869f56c30..4f9a32d16 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -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); diff --git a/src/detect.c b/src/detect.c index 879407432..24f6572dd 100644 --- a/src/detect.c +++ b/src/detect.c @@ -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) diff --git a/src/dig.c b/src/dig.c index 063b531ff..55d9949be 100644 --- 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); diff --git a/src/display.c b/src/display.c index fc20048fc..d09b47fba 100644 --- a/src/display.c +++ b/src/display.c @@ -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 (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); diff --git a/src/do.c b/src/do.c index 481c12ca0..0a6f7597c 100644 --- 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) diff --git a/src/do_name.c b/src/do_name.c index a35970845..4919f7a4a 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -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 diff --git a/src/dogmove.c b/src/dogmove.c index 9ad37937c..486f5b38f 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -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); diff --git a/src/dungeon.c b/src/dungeon.c index a7165b013..8cb095978 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -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); diff --git a/src/engrave.c b/src/engrave.c index 35e89a9a7..8878b9578 100644 --- a/src/engrave.c +++ b/src/engrave.c @@ -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"; diff --git a/src/explode.c b/src/explode.c index d2419870d..406867267 100644 --- a/src/explode.c +++ b/src/explode.c @@ -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); diff --git a/src/fountain.c b/src/fountain.c index dbc19f887..b6d389560 100644 --- a/src/fountain.c +++ b/src/fountain.c @@ -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; diff --git a/src/hack.c b/src/hack.c index d7eb8f09c..5dbb7ebc7 100644 --- a/src/hack.c +++ b/src/hack.c @@ -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 diff --git a/src/invent.c b/src/invent.c index 502ca71d8..1142ae9bf 100644 --- a/src/invent.c +++ b/src/invent.c @@ -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 */ diff --git a/src/light.c b/src/light.c index 591cc0e8a..bf3791616 100644 --- a/src/light.c +++ b/src/light.c @@ -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 diff --git a/src/lock.c b/src/lock.c index 123aeb991..0d2ddda80 100644 --- a/src/lock.c +++ b/src/lock.c @@ -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; } diff --git a/src/mail.c b/src/mail.c index 6fceff2a9..7274ac0e1 100644 --- a/src/mail.c +++ b/src/mail.c @@ -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) diff --git a/src/makemon.c b/src/makemon.c index a06eaaf72..a4cae89f7 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -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); diff --git a/src/mhitu.c b/src/mhitu.c index 515201fd1..23c7243a5 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -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; diff --git a/src/mkmaze.c b/src/mkmaze.c index 17dda6a8c..8b256ca34 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -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; diff --git a/src/mon.c b/src/mon.c index 7612d7910..3dd7a562f 100644 --- 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 diff --git a/src/monmove.c b/src/monmove.c index 1605f7c03..79222263e 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -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))); diff --git a/src/mthrowu.c b/src/mthrowu.c index 6c63ac552..a0cb795ff 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -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 */ diff --git a/src/muse.c b/src/muse.c index a450e499a..9ed9b2ed2 100644 --- a/src/muse.c +++ b/src/muse.c @@ -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) */ diff --git a/src/music.c b/src/music.c index 1e38064e3..f471210c8 100644 --- a/src/music.c +++ b/src/music.c @@ -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 diff --git a/src/pager.c b/src/pager.c index 6b148026e..c40dc11e8 100644 --- a/src/pager.c +++ b/src/pager.c @@ -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) { diff --git a/src/pickup.c b/src/pickup.c index d0da3e667..397d47283 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -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; diff --git a/src/priest.c b/src/priest.c index 885078a7e..29886b860 100644 --- a/src/priest.c +++ b/src/priest.c @@ -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; diff --git a/src/read.c b/src/read.c index bb9d50a20..bfc1353cf 100644 --- a/src/read.c +++ b/src/read.c @@ -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(); diff --git a/src/region.c b/src/region.c index bcae7c0d8..e54a17504 100644 --- a/src/region.c +++ b/src/region.c @@ -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++; diff --git a/src/shk.c b/src/shk.c index d1d1cf0fc..883c71a0b 100644 --- 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) diff --git a/src/steed.c b/src/steed.c index 976d63087..d87ed7197 100644 --- a/src/steed.c +++ b/src/steed.c @@ -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) diff --git a/src/teleport.c b/src/teleport.c index bf40b82a0..305cc9291 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -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; } diff --git a/src/trap.c b/src/trap.c index 3fb7bf3e1..224a9651c 100644 --- a/src/trap.c +++ b/src/trap.c @@ -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) { diff --git a/src/vault.c b/src/vault.c index 81b06b60a..71a8a644e 100644 --- a/src/vault.c +++ b/src/vault.c @@ -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) { diff --git a/src/wizard.c b/src/wizard.c index d917adcef..784a20b90 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -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; diff --git a/src/zap.c b/src/zap.c index 19ca24af0..e052e894f 100644 --- 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 */