getpos help
This started with fixing a warning suggesting parentheses when mixing || and &&, then started sprawling. The getpos help for x/X was misleading. It said that using x or X would move cursor to the next unexplored location but it actually moves the cursor to next explored location that's adjacent to an unexplored one.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 do_name.c $NHDT-Date: 1582364431 2020/02/22 09:40:31 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.174 $ */
|
||||
/* NetHack 3.6 do_name.c $NHDT-Date: 1586940208 2020/04/15 08:43:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.178 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Pasi Kallinen, 2018. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -58,9 +58,10 @@ boolean FDECL((*gp_getvalidf), (int, int));
|
||||
static const char *const gloc_descr[NUM_GLOCS][4] = {
|
||||
{ "any monsters", "monster", "next/previous monster", "monsters" },
|
||||
{ "any items", "item", "next/previous object", "objects" },
|
||||
{ "any doors", "door", "next/previous door or doorway", "doors or doorways" },
|
||||
{ "any doors", "door", "next/previous door or doorway",
|
||||
"doors or doorways" },
|
||||
{ "any unexplored areas", "unexplored area", "unexplored location",
|
||||
"unexplored locations" },
|
||||
"locations next to unexplored locations" },
|
||||
{ "anything interesting", "interesting thing", "anything interesting",
|
||||
"anything interesting" },
|
||||
{ "any valid locations", "valid location", "valid location",
|
||||
@@ -80,14 +81,24 @@ const char *k1;
|
||||
const char *k2;
|
||||
int gloc;
|
||||
{
|
||||
char sbuf[BUFSZ];
|
||||
char sbuf[BUFSZ], fbuf[QBUFSZ];
|
||||
const char *move_cursor_to = "move the cursor to ",
|
||||
*filtertxt = gloc_filtertxt[iflags.getloc_filter];
|
||||
|
||||
if (gloc == GLOC_EXPLORE) {
|
||||
/* default of "move to unexplored location" is inaccurate
|
||||
because the position will be one spot short of that */
|
||||
move_cursor_to = "move the cursor next to an ";
|
||||
if (iflags.getloc_usemenu)
|
||||
/* default is too wide for basic 80-column tty so shorten it
|
||||
to avoid wrapping */
|
||||
filtertxt = strsubst(strcpy(fbuf, filtertxt),
|
||||
"this area", "area");
|
||||
}
|
||||
Sprintf(sbuf, "Use '%s'/'%s' to %s%s%s.",
|
||||
k1, k2,
|
||||
iflags.getloc_usemenu ? "get a menu of "
|
||||
: "move the cursor to ",
|
||||
gloc_descr[gloc][2 + iflags.getloc_usemenu],
|
||||
gloc_filtertxt[iflags.getloc_filter]);
|
||||
iflags.getloc_usemenu ? "get a menu of " : move_cursor_to,
|
||||
gloc_descr[gloc][2 + iflags.getloc_usemenu], filtertxt);
|
||||
putstr(tmpwin, 0, sbuf);
|
||||
}
|
||||
|
||||
@@ -139,8 +150,8 @@ const char *goal;
|
||||
visctrl(g.Cmd.spkeys[NHKF_GETPOS_UNEX_PREV]),
|
||||
GLOC_EXPLORE);
|
||||
getpos_help_keyxhelp(tmpwin,
|
||||
visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_NEXT]),
|
||||
visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_PREV]),
|
||||
visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_NEXT]),
|
||||
visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_PREV]),
|
||||
GLOC_INTERESTING);
|
||||
}
|
||||
Sprintf(sbuf, "Use '%s' to change fast-move mode to %s.",
|
||||
@@ -340,10 +351,7 @@ static boolean
|
||||
gather_locs_interesting(x, y, gloc)
|
||||
int x, y, gloc;
|
||||
{
|
||||
/* TODO: if glyph is a pile glyph, convert to ordinary one
|
||||
* in order to keep tail/boulder/rock check simple.
|
||||
*/
|
||||
int glyph = glyph_at(x, y);
|
||||
int glyph, sym;
|
||||
|
||||
if (iflags.getloc_filter == GFILTER_VIEW && !cansee(x, y))
|
||||
return FALSE;
|
||||
@@ -352,6 +360,8 @@ int x, y, gloc;
|
||||
&& !GLOC_SAME_AREA(x + 1, y) && !GLOC_SAME_AREA(x, y + 1))
|
||||
return FALSE;
|
||||
|
||||
glyph = glyph_at(x, y);
|
||||
sym = glyph_is_cmap(glyph) ? glyph_to_cmap(glyph) : -1;
|
||||
switch (gloc) {
|
||||
default:
|
||||
case GLOC_MONS:
|
||||
@@ -365,46 +375,41 @@ int x, y, gloc;
|
||||
&& glyph != objnum_to_glyph(ROCK));
|
||||
case GLOC_DOOR:
|
||||
return (glyph_is_cmap(glyph)
|
||||
&& (is_cmap_door(glyph_to_cmap(glyph))
|
||||
|| is_cmap_drawbridge(glyph_to_cmap(glyph))
|
||||
|| glyph_to_cmap(glyph) == S_ndoor));
|
||||
&& (is_cmap_door(sym)
|
||||
|| is_cmap_drawbridge(sym)
|
||||
|| sym == S_ndoor));
|
||||
case GLOC_EXPLORE:
|
||||
return (glyph_is_cmap(glyph)
|
||||
&& !glyph_is_nothing(glyph_to_cmap(glyph))
|
||||
&& (is_cmap_door(glyph_to_cmap(glyph))
|
||||
|| is_cmap_drawbridge(glyph_to_cmap(glyph))
|
||||
|| glyph_to_cmap(glyph) == S_ndoor
|
||||
|| glyph_to_cmap(glyph) == S_room
|
||||
|| glyph_to_cmap(glyph) == S_darkroom
|
||||
|| glyph_to_cmap(glyph) == S_corr
|
||||
|| glyph_to_cmap(glyph) == S_litcorr)
|
||||
&& (is_cmap_door(sym)
|
||||
|| is_cmap_drawbridge(sym)
|
||||
|| sym == S_ndoor
|
||||
|| is_cmap_room(sym)
|
||||
|| is_cmap_corr(sym))
|
||||
&& (IS_UNEXPLORED_LOC(x + 1, y)
|
||||
|| IS_UNEXPLORED_LOC(x - 1, y)
|
||||
|| IS_UNEXPLORED_LOC(x, y + 1)
|
||||
|| IS_UNEXPLORED_LOC(x, y - 1)));
|
||||
case GLOC_VALID:
|
||||
if (getpos_getvalid)
|
||||
return (*getpos_getvalid)(x,y);
|
||||
return (*getpos_getvalid)(x, y);
|
||||
/*FALLTHRU*/
|
||||
case GLOC_INTERESTING:
|
||||
return gather_locs_interesting(x,y, GLOC_DOOR)
|
||||
|| !(glyph_is_cmap(glyph)
|
||||
&& (is_cmap_wall(glyph_to_cmap(glyph))
|
||||
|| glyph_to_cmap(glyph) == S_tree
|
||||
|| glyph_to_cmap(glyph) == S_bars
|
||||
|| glyph_to_cmap(glyph) == S_ice
|
||||
|| glyph_to_cmap(glyph) == S_air
|
||||
|| glyph_to_cmap(glyph) == S_cloud
|
||||
|| glyph_to_cmap(glyph) == S_lava
|
||||
|| glyph_to_cmap(glyph) == S_water
|
||||
|| glyph_to_cmap(glyph) == S_pool
|
||||
|| glyph_to_cmap(glyph) == S_ndoor
|
||||
|| glyph_to_cmap(glyph) == S_room
|
||||
|| glyph_to_cmap(glyph) == S_darkroom
|
||||
|| glyph_to_cmap(glyph) == S_corr
|
||||
|| glyph_to_cmap(glyph) == S_litcorr)
|
||||
|| glyph_is_nothing(glyph)
|
||||
|| glyph_is_unexplored(glyph));
|
||||
return (gather_locs_interesting(x, y, GLOC_DOOR)
|
||||
|| !((glyph_is_cmap(glyph)
|
||||
&& (is_cmap_wall(sym)
|
||||
|| sym == S_tree
|
||||
|| sym == S_bars
|
||||
|| sym == S_ice
|
||||
|| sym == S_air
|
||||
|| sym == S_cloud
|
||||
|| is_cmap_lava(sym)
|
||||
|| is_cmap_water(sym)
|
||||
|| sym == S_ndoor
|
||||
|| is_cmap_room(sym)
|
||||
|| is_cmap_corr(sym)))
|
||||
|| glyph_is_nothing(glyph)
|
||||
|| glyph_is_unexplored(glyph)));
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
return FALSE;
|
||||
@@ -582,7 +587,7 @@ int gloc;
|
||||
if (gcount < 2) { /* gcount always includes the hero */
|
||||
free((genericptr_t) garr);
|
||||
You("cannot %s %s.",
|
||||
iflags.getloc_filter == GFILTER_VIEW ? "see" : "detect",
|
||||
(iflags.getloc_filter == GFILTER_VIEW) ? "see" : "detect",
|
||||
gloc_descr[gloc][0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user