From: PatR Date: Sun, 7 Aug 2022 23:02:44 +0000 (-0700) Subject: fix #K3656 - chest in pit X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e6d3aba4f11b31f4c763addee9605da5b54f68c;p=nethack fix #K3656 - chest in pit Using #loot while in a pit allows looting containers in that pit. Using open and specifying the hero's spot when not in a pit allows looting containers at hero's spot. But using open while in a pit complained about not being able to reach out of the pit before player had a chance to give hero's spot at the place of interest, so did not allow looting any container there. Get a target spot before rejecting use of 'open' while in a pit. The alternate prompt might be tty-centric. --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 2e2d4b142..e5ebf68d8 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1336,6 +1336,8 @@ if the game crashed or the process was killed, recovering a save file ended when using --nethackrc=file on the command line (currently only implemented for ports that use unixmain.c), options parsing freed the string containing 'file' before using it as the RC file name +using 'o'pen as a synonym for #loot of a container at the hero's location did + not work if the hero was in a pit curses: 'msg_window' option wasn't functional for curses unless the binary also included tty support diff --git a/include/extern.h b/include/extern.h index 7fac7b2ba..15f27d001 100644 --- a/include/extern.h +++ b/include/extern.h @@ -288,7 +288,8 @@ extern int getdir(const char *); extern void confdir(boolean); extern const char *directionname(int); extern int isok(coordxy, coordxy); -extern int get_adjacent_loc(const char *, const char *, coordxy, coordxy, coord *); +extern int get_adjacent_loc(const char *, const char *, coordxy, coordxy, + coord *); extern const char *click_to_cmd(coordxy, coordxy, int); extern char get_count(const char *, char, long, cmdcount_nht *, unsigned); #ifdef HANGUPHANDLING diff --git a/src/lock.c b/src/lock.c index cc07ab82c..9c9edefff 100644 --- a/src/lock.c +++ b/src/lock.c @@ -756,6 +756,7 @@ doopen_indir(coordxy x, coordxy y) coord cc; register struct rm *door; boolean portcullis; + const char *dirprompt; int res = ECMD_OK; if (nohands(g.youmonst.data)) { @@ -763,21 +764,32 @@ doopen_indir(coordxy x, coordxy y) return ECMD_OK; } - if (u.utrap && u.utraptype == TT_PIT) { - You_cant("reach over the edge of the pit."); - return ECMD_OK; - } + dirprompt = NULL; /* have get_adjacent_loc() -> getdir() use default */ + if (u.utrap && u.utraptype == TT_PIT && container_at(u.ux, u.uy, FALSE)) + dirprompt = "Open where? [.>]"; - if (x > 0 && y > 0) { + if (x > 0 && y >= 0) { + /* nonzero is used when hero in amorphous form tries to + flow under a closed door at ; the test here was using + 'y > 0' but that would give incorrect results if doors are + ever allowed to be placed on the top row of the map */ cc.x = x; cc.y = y; - } else if (!get_adjacent_loc((char *) 0, (char *) 0, u.ux, u.uy, &cc)) + } else if (!get_adjacent_loc(dirprompt, (char *) 0, u.ux, u.uy, &cc)) { return ECMD_OK; + } /* open at yourself/up/down */ if (u_at(cc.x, cc.y)) return doloot(); + /* this used to be done prior to get_adjacent_loc() but doing so was + incorrect once open at hero's spot became an alternate way to loot */ + if (u.utrap && u.utraptype == TT_PIT) { + You_cant("reach over the edge of the pit."); + return ECMD_OK; + } + if (stumble_on_door_mimic(cc.x, cc.y)) return ECMD_TIME;