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) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Pasi Kallinen, 2018. */
|
/*-Copyright (c) Pasi Kallinen, 2018. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* 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] = {
|
static const char *const gloc_descr[NUM_GLOCS][4] = {
|
||||||
{ "any monsters", "monster", "next/previous monster", "monsters" },
|
{ "any monsters", "monster", "next/previous monster", "monsters" },
|
||||||
{ "any items", "item", "next/previous object", "objects" },
|
{ "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",
|
{ "any unexplored areas", "unexplored area", "unexplored location",
|
||||||
"unexplored locations" },
|
"locations next to unexplored locations" },
|
||||||
{ "anything interesting", "interesting thing", "anything interesting",
|
{ "anything interesting", "interesting thing", "anything interesting",
|
||||||
"anything interesting" },
|
"anything interesting" },
|
||||||
{ "any valid locations", "valid location", "valid location",
|
{ "any valid locations", "valid location", "valid location",
|
||||||
@@ -80,14 +81,24 @@ const char *k1;
|
|||||||
const char *k2;
|
const char *k2;
|
||||||
int gloc;
|
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.",
|
Sprintf(sbuf, "Use '%s'/'%s' to %s%s%s.",
|
||||||
k1, k2,
|
k1, k2,
|
||||||
iflags.getloc_usemenu ? "get a menu of "
|
iflags.getloc_usemenu ? "get a menu of " : move_cursor_to,
|
||||||
: "move the cursor to ",
|
gloc_descr[gloc][2 + iflags.getloc_usemenu], filtertxt);
|
||||||
gloc_descr[gloc][2 + iflags.getloc_usemenu],
|
|
||||||
gloc_filtertxt[iflags.getloc_filter]);
|
|
||||||
putstr(tmpwin, 0, sbuf);
|
putstr(tmpwin, 0, sbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,8 +150,8 @@ const char *goal;
|
|||||||
visctrl(g.Cmd.spkeys[NHKF_GETPOS_UNEX_PREV]),
|
visctrl(g.Cmd.spkeys[NHKF_GETPOS_UNEX_PREV]),
|
||||||
GLOC_EXPLORE);
|
GLOC_EXPLORE);
|
||||||
getpos_help_keyxhelp(tmpwin,
|
getpos_help_keyxhelp(tmpwin,
|
||||||
visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_NEXT]),
|
visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_NEXT]),
|
||||||
visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_PREV]),
|
visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_PREV]),
|
||||||
GLOC_INTERESTING);
|
GLOC_INTERESTING);
|
||||||
}
|
}
|
||||||
Sprintf(sbuf, "Use '%s' to change fast-move mode to %s.",
|
Sprintf(sbuf, "Use '%s' to change fast-move mode to %s.",
|
||||||
@@ -340,10 +351,7 @@ static boolean
|
|||||||
gather_locs_interesting(x, y, gloc)
|
gather_locs_interesting(x, y, gloc)
|
||||||
int x, y, gloc;
|
int x, y, gloc;
|
||||||
{
|
{
|
||||||
/* TODO: if glyph is a pile glyph, convert to ordinary one
|
int glyph, sym;
|
||||||
* in order to keep tail/boulder/rock check simple.
|
|
||||||
*/
|
|
||||||
int glyph = glyph_at(x, y);
|
|
||||||
|
|
||||||
if (iflags.getloc_filter == GFILTER_VIEW && !cansee(x, y))
|
if (iflags.getloc_filter == GFILTER_VIEW && !cansee(x, y))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -352,6 +360,8 @@ int x, y, gloc;
|
|||||||
&& !GLOC_SAME_AREA(x + 1, y) && !GLOC_SAME_AREA(x, y + 1))
|
&& !GLOC_SAME_AREA(x + 1, y) && !GLOC_SAME_AREA(x, y + 1))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
glyph = glyph_at(x, y);
|
||||||
|
sym = glyph_is_cmap(glyph) ? glyph_to_cmap(glyph) : -1;
|
||||||
switch (gloc) {
|
switch (gloc) {
|
||||||
default:
|
default:
|
||||||
case GLOC_MONS:
|
case GLOC_MONS:
|
||||||
@@ -365,46 +375,41 @@ int x, y, gloc;
|
|||||||
&& glyph != objnum_to_glyph(ROCK));
|
&& glyph != objnum_to_glyph(ROCK));
|
||||||
case GLOC_DOOR:
|
case GLOC_DOOR:
|
||||||
return (glyph_is_cmap(glyph)
|
return (glyph_is_cmap(glyph)
|
||||||
&& (is_cmap_door(glyph_to_cmap(glyph))
|
&& (is_cmap_door(sym)
|
||||||
|| is_cmap_drawbridge(glyph_to_cmap(glyph))
|
|| is_cmap_drawbridge(sym)
|
||||||
|| glyph_to_cmap(glyph) == S_ndoor));
|
|| sym == S_ndoor));
|
||||||
case GLOC_EXPLORE:
|
case GLOC_EXPLORE:
|
||||||
return (glyph_is_cmap(glyph)
|
return (glyph_is_cmap(glyph)
|
||||||
&& !glyph_is_nothing(glyph_to_cmap(glyph))
|
&& !glyph_is_nothing(glyph_to_cmap(glyph))
|
||||||
&& (is_cmap_door(glyph_to_cmap(glyph))
|
&& (is_cmap_door(sym)
|
||||||
|| is_cmap_drawbridge(glyph_to_cmap(glyph))
|
|| is_cmap_drawbridge(sym)
|
||||||
|| glyph_to_cmap(glyph) == S_ndoor
|
|| sym == S_ndoor
|
||||||
|| glyph_to_cmap(glyph) == S_room
|
|| is_cmap_room(sym)
|
||||||
|| glyph_to_cmap(glyph) == S_darkroom
|
|| is_cmap_corr(sym))
|
||||||
|| glyph_to_cmap(glyph) == S_corr
|
|
||||||
|| glyph_to_cmap(glyph) == S_litcorr)
|
|
||||||
&& (IS_UNEXPLORED_LOC(x + 1, y)
|
&& (IS_UNEXPLORED_LOC(x + 1, y)
|
||||||
|| IS_UNEXPLORED_LOC(x - 1, y)
|
|| IS_UNEXPLORED_LOC(x - 1, y)
|
||||||
|| IS_UNEXPLORED_LOC(x, y + 1)
|
|| IS_UNEXPLORED_LOC(x, y + 1)
|
||||||
|| IS_UNEXPLORED_LOC(x, y - 1)));
|
|| IS_UNEXPLORED_LOC(x, y - 1)));
|
||||||
case GLOC_VALID:
|
case GLOC_VALID:
|
||||||
if (getpos_getvalid)
|
if (getpos_getvalid)
|
||||||
return (*getpos_getvalid)(x,y);
|
return (*getpos_getvalid)(x, y);
|
||||||
/*FALLTHRU*/
|
/*FALLTHRU*/
|
||||||
case GLOC_INTERESTING:
|
case GLOC_INTERESTING:
|
||||||
return gather_locs_interesting(x,y, GLOC_DOOR)
|
return (gather_locs_interesting(x, y, GLOC_DOOR)
|
||||||
|| !(glyph_is_cmap(glyph)
|
|| !((glyph_is_cmap(glyph)
|
||||||
&& (is_cmap_wall(glyph_to_cmap(glyph))
|
&& (is_cmap_wall(sym)
|
||||||
|| glyph_to_cmap(glyph) == S_tree
|
|| sym == S_tree
|
||||||
|| glyph_to_cmap(glyph) == S_bars
|
|| sym == S_bars
|
||||||
|| glyph_to_cmap(glyph) == S_ice
|
|| sym == S_ice
|
||||||
|| glyph_to_cmap(glyph) == S_air
|
|| sym == S_air
|
||||||
|| glyph_to_cmap(glyph) == S_cloud
|
|| sym == S_cloud
|
||||||
|| glyph_to_cmap(glyph) == S_lava
|
|| is_cmap_lava(sym)
|
||||||
|| glyph_to_cmap(glyph) == S_water
|
|| is_cmap_water(sym)
|
||||||
|| glyph_to_cmap(glyph) == S_pool
|
|| sym == S_ndoor
|
||||||
|| glyph_to_cmap(glyph) == S_ndoor
|
|| is_cmap_room(sym)
|
||||||
|| glyph_to_cmap(glyph) == S_room
|
|| is_cmap_corr(sym)))
|
||||||
|| glyph_to_cmap(glyph) == S_darkroom
|
|| glyph_is_nothing(glyph)
|
||||||
|| glyph_to_cmap(glyph) == S_corr
|
|| glyph_is_unexplored(glyph)));
|
||||||
|| glyph_to_cmap(glyph) == S_litcorr)
|
|
||||||
|| glyph_is_nothing(glyph)
|
|
||||||
|| glyph_is_unexplored(glyph));
|
|
||||||
}
|
}
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -582,7 +587,7 @@ int gloc;
|
|||||||
if (gcount < 2) { /* gcount always includes the hero */
|
if (gcount < 2) { /* gcount always includes the hero */
|
||||||
free((genericptr_t) garr);
|
free((genericptr_t) garr);
|
||||||
You("cannot %s %s.",
|
You("cannot %s %s.",
|
||||||
iflags.getloc_filter == GFILTER_VIEW ? "see" : "detect",
|
(iflags.getloc_filter == GFILTER_VIEW) ? "see" : "detect",
|
||||||
gloc_descr[gloc][0]);
|
gloc_descr[gloc][0]);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user