Another switch to get_adjacent_loc()

This commit is contained in:
nethack.allison
2002-12-09 02:06:40 +00:00
parent 167231f9ad
commit 9816ca5a5b
+20 -23
View File
@@ -226,7 +226,8 @@ int
pick_lock(pick) /* pick a lock with a given object */ pick_lock(pick) /* pick a lock with a given object */
register struct obj *pick; register struct obj *pick;
{ {
int x, y, picktyp, c, ch; int picktyp, c, ch;
coord cc;
struct rm *door; struct rm *door;
struct obj *otmp; struct obj *otmp;
char qbuf[QBUFSZ]; char qbuf[QBUFSZ];
@@ -270,12 +271,10 @@ pick_lock(pick) /* pick a lock with a given object */
impossible("picking lock with object %d?", picktyp); impossible("picking lock with object %d?", picktyp);
return(0); return(0);
} }
if(!getdir((char *)0)) return(0);
ch = 0; /* lint suppression */ ch = 0; /* lint suppression */
x = u.ux + u.dx;
y = u.uy + u.dy; if(!get_adjacent_loc((char *)0, "Invalid location!", u.ux, u.uy, &cc)) return 0;
if (x == u.ux && y == u.uy) { /* pick lock on a container */ if (cc.x == u.ux && cc.y == u.uy) { /* pick lock on a container */
const char *verb; const char *verb;
boolean it; boolean it;
int count; int count;
@@ -295,7 +294,7 @@ pick_lock(pick) /* pick a lock with a given object */
count = 0; count = 0;
c = 'n'; /* in case there are no boxes here */ c = 'n'; /* in case there are no boxes here */
for(otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) for(otmp = level.objects[cc.x][cc.y]; otmp; otmp = otmp->nexthere)
if (Is_box(otmp)) { if (Is_box(otmp)) {
++count; ++count;
if (!can_reach_floor()) { if (!can_reach_floor()) {
@@ -354,8 +353,8 @@ pick_lock(pick) /* pick a lock with a given object */
} else { /* pick the lock in a door */ } else { /* pick the lock in a door */
struct monst *mtmp; struct monst *mtmp;
door = &levl[x][y]; door = &levl[cc.x][cc.y];
if ((mtmp = m_at(x, y)) && canseemon(mtmp) if ((mtmp = m_at(cc.x, cc.y)) && canseemon(mtmp)
&& mtmp->m_ap_type != M_AP_FURNITURE && mtmp->m_ap_type != M_AP_FURNITURE
&& mtmp->m_ap_type != M_AP_OBJECT) { && mtmp->m_ap_type != M_AP_OBJECT) {
#ifdef TOURIST #ifdef TOURIST
@@ -368,7 +367,7 @@ pick_lock(pick) /* pick a lock with a given object */
return(0); return(0);
} }
if(!IS_DOOR(door->typ)) { if(!IS_DOOR(door->typ)) {
if (is_drawbridge_wall(x,y) >= 0) if (is_drawbridge_wall(cc.x,cc.y) >= 0)
You("%s no lock on the drawbridge.", You("%s no lock on the drawbridge.",
Blind ? "feel" : "see"); Blind ? "feel" : "see");
else else
@@ -490,7 +489,7 @@ doforce() /* try to force a chest with your weapon */
int int
doopen() /* try to open a door */ doopen() /* try to open a door */
{ {
register int x, y; coord cc;
register struct rm *door; register struct rm *door;
struct monst *mtmp; struct monst *mtmp;
@@ -504,13 +503,11 @@ doopen() /* try to open a door */
return 0; return 0;
} }
if(!getdir((char *)0)) return(0); if(!get_adjacent_loc((char *)0, (char *)0, u.ux, u.uy, &cc)) return(0);
x = u.ux + u.dx; if((cc.x == u.ux) && (cc.y == u.uy)) return(0);
y = u.uy + u.dy;
if((x == u.ux) && (y == u.uy)) return(0);
if ((mtmp = m_at(x,y)) && if ((mtmp = m_at(cc.x,cc.y)) &&
mtmp->m_ap_type == M_AP_FURNITURE && mtmp->m_ap_type == M_AP_FURNITURE &&
(mtmp->mappearance == S_hcdoor || (mtmp->mappearance == S_hcdoor ||
mtmp->mappearance == S_vcdoor) && mtmp->mappearance == S_vcdoor) &&
@@ -520,10 +517,10 @@ doopen() /* try to open a door */
return(1); return(1);
} }
door = &levl[x][y]; door = &levl[cc.x][cc.y];
if(!IS_DOOR(door->typ)) { if(!IS_DOOR(door->typ)) {
if (is_db_wall(x,y)) { if (is_db_wall(cc.x,cc.y)) {
There("is no obvious way to open the drawbridge."); There("is no obvious way to open the drawbridge.");
return(0); return(0);
} }
@@ -542,7 +539,7 @@ doopen() /* try to open a door */
default: mesg = " is locked"; break; default: mesg = " is locked"; break;
} }
pline("This door%s.", mesg); pline("This door%s.", mesg);
if (Blind) feel_location(x,y); if (Blind) feel_location(cc.x,cc.y);
return(0); return(0);
} }
@@ -557,14 +554,14 @@ doopen() /* try to open a door */
if(door->doormask & D_TRAPPED) { if(door->doormask & D_TRAPPED) {
b_trapped("door", FINGER); b_trapped("door", FINGER);
door->doormask = D_NODOOR; door->doormask = D_NODOOR;
if (*in_rooms(x, y, SHOPBASE)) add_damage(x, y, 0L); if (*in_rooms(cc.x, cc.y, SHOPBASE)) add_damage(cc.x, cc.y, 0L);
} else } else
door->doormask = D_ISOPEN; door->doormask = D_ISOPEN;
if (Blind) if (Blind)
feel_location(x,y); /* the hero knows she opened it */ feel_location(cc.x,cc.y); /* the hero knows she opened it */
else else
newsym(x,y); newsym(cc.x,cc.y);
unblock_point(x,y); /* vision: new see through there */ unblock_point(cc.x,cc.y); /* vision: new see through there */
} else { } else {
exercise(A_STR, TRUE); exercise(A_STR, TRUE);
pline_The("door resists!"); pline_The("door resists!");