For travel target location, report if no known travel path

Yet another accessibility feature.  When asked for a location
to travel, and autodescribe is on, the location description
has "(no travel path)" appended, if there is no known path
to that location.
This commit is contained in:
Pasi Kallinen
2016-08-31 22:08:15 +03:00
parent 2710106661
commit f82205c232
6 changed files with 57 additions and 16 deletions
+2
View File
@@ -483,6 +483,8 @@ undead #turning takes less time at higher experience level
peacefuls may react when you attack other peacefuls peacefuls may react when you attack other peacefuls
prevent diagonal jumping through open doorways prevent diagonal jumping through open doorways
different liquids when hallucinating different liquids when hallucinating
when moving a cursor for travel target, show if there is no known travel
path to that location, if "autodescribe" is on
Platform- and/or Interface-Specific New Features Platform- and/or Interface-Specific New Features
+1
View File
@@ -796,6 +796,7 @@ E void NDECL(drinksink);
/* ### hack.c ### */ /* ### hack.c ### */
E boolean FDECL(is_valid_travelpt, (int,int));
E anything *FDECL(uint_to_any, (unsigned)); E anything *FDECL(uint_to_any, (unsigned));
E anything *FDECL(long_to_any, (long)); E anything *FDECL(long_to_any, (long));
E anything *FDECL(monst_to_any, (struct monst *)); E anything *FDECL(monst_to_any, (struct monst *));
+1
View File
@@ -192,6 +192,7 @@ struct instance_flags {
#define TER_OBJ 0x04 #define TER_OBJ 0x04
#define TER_MON 0x08 #define TER_MON 0x08
#define TER_DETECT 0x10 /* detect_foo magic rather than #terrain */ #define TER_DETECT 0x10 /* detect_foo magic rather than #terrain */
boolean getloc_travelmode;
coord travelcc; /* coordinates for travel_cache */ coord travelcc; /* coordinates for travel_cache */
boolean window_inited; /* true if init_nhwindows() completed */ boolean window_inited; /* true if init_nhwindows() completed */
boolean vision_inited; /* true if vision is ready */ boolean vision_inited; /* true if vision is ready */
+3
View File
@@ -4323,11 +4323,14 @@ dotravel(VOID_ARGS)
cc.x = u.ux; cc.x = u.ux;
cc.y = u.uy; cc.y = u.uy;
} }
iflags.getloc_travelmode = TRUE;
pline("Where do you want to travel to?"); pline("Where do you want to travel to?");
if (getpos(&cc, TRUE, "the desired destination") < 0) { if (getpos(&cc, TRUE, "the desired destination") < 0) {
/* user pressed ESC */ /* user pressed ESC */
iflags.getloc_travelmode = FALSE;
return 0; return 0;
} }
iflags.getloc_travelmode = FALSE;
iflags.travelcc.x = u.tx = cc.x; iflags.travelcc.x = u.tx = cc.x;
iflags.travelcc.y = u.ty = cc.y; iflags.travelcc.y = u.ty = cc.y;
cmd[0] = CMD_TRAVEL; cmd[0] = CMD_TRAVEL;
+3 -1
View File
@@ -316,7 +316,9 @@ int cx, cy;
cc.y = cy; cc.y = cy;
if (do_screen_description(cc, TRUE, sym, tmpbuf, &firstmatch)) { if (do_screen_description(cc, TRUE, sym, tmpbuf, &firstmatch)) {
(void) coord_desc(cx, cy, tmpbuf, iflags.getpos_coords); (void) coord_desc(cx, cy, tmpbuf, iflags.getpos_coords);
pline("%s%s%s", firstmatch, *tmpbuf ? " " : "", tmpbuf); pline("%s%s%s%s", firstmatch, *tmpbuf ? " " : "", tmpbuf,
(iflags.getloc_travelmode && !is_valid_travelpt(cx,cy))
? " (no travel path)" : "");
curs(WIN_MAP, cx, cy); curs(WIN_MAP, cx, cy);
flush_screen(0); flush_screen(0);
} }
+47 -15
View File
@@ -10,7 +10,7 @@ STATIC_DCL void NDECL(maybe_wail);
STATIC_DCL int NDECL(moverock); STATIC_DCL int NDECL(moverock);
STATIC_DCL int FDECL(still_chewing, (XCHAR_P, XCHAR_P)); STATIC_DCL int FDECL(still_chewing, (XCHAR_P, XCHAR_P));
STATIC_DCL void NDECL(dosinkfall); STATIC_DCL void NDECL(dosinkfall);
STATIC_DCL boolean FDECL(findtravelpath, (BOOLEAN_P)); STATIC_DCL boolean FDECL(findtravelpath, (int));
STATIC_DCL boolean FDECL(trapmove, (int, int, struct trap *)); STATIC_DCL boolean FDECL(trapmove, (int, int, struct trap *));
STATIC_DCL void NDECL(switch_terrain); STATIC_DCL void NDECL(switch_terrain);
STATIC_DCL struct monst *FDECL(monstinroom, (struct permonst *, int)); STATIC_DCL struct monst *FDECL(monstinroom, (struct permonst *, int));
@@ -19,6 +19,11 @@ STATIC_DCL void FDECL(move_update, (BOOLEAN_P));
#define IS_SHOP(x) (rooms[x].rtype >= SHOPBASE) #define IS_SHOP(x) (rooms[x].rtype >= SHOPBASE)
/* mode values for findtravelpath() */
#define TRAVP_TRAVEL 0
#define TRAVP_GUESS 1
#define TRAVP_VALID 2
static anything tmp_anything; static anything tmp_anything;
anything * anything *
@@ -887,21 +892,25 @@ int wiz_debug_cmd_traveldisplay()
* Returns TRUE if a path was found. * Returns TRUE if a path was found.
*/ */
STATIC_OVL boolean STATIC_OVL boolean
findtravelpath(guess) findtravelpath(mode)
boolean guess; int mode;
{ {
/* if travel to adjacent, reachable location, use normal movement rules */ /* if travel to adjacent, reachable location, use normal movement rules */
if (!guess && context.travel1 && distmin(u.ux, u.uy, u.tx, u.ty) == 1 if ((mode == TRAVP_TRAVEL || mode == TRAVP_VALID) && context.travel1
&& distmin(u.ux, u.uy, u.tx, u.ty) == 1
&& !(u.ux != u.tx && u.uy != u.ty && NODIAG(u.umonnum))) { && !(u.ux != u.tx && u.uy != u.ty && NODIAG(u.umonnum))) {
context.run = 0; context.run = 0;
if (test_move(u.ux, u.uy, u.tx - u.ux, u.ty - u.uy, TEST_MOVE)) { if (test_move(u.ux, u.uy, u.tx - u.ux, u.ty - u.uy, TEST_MOVE)) {
u.dx = u.tx - u.ux; if (mode == TRAVP_TRAVEL) {
u.dy = u.ty - u.uy; u.dx = u.tx - u.ux;
nomul(0); u.dy = u.ty - u.uy;
iflags.travelcc.x = iflags.travelcc.y = -1; nomul(0);
iflags.travelcc.x = iflags.travelcc.y = -1;
}
return TRUE; return TRUE;
} }
context.run = 8; if (mode == TRAVP_TRAVEL)
context.run = 8;
} }
if (u.tx != u.ux || u.ty != u.uy) { if (u.tx != u.ux || u.ty != u.uy) {
xchar travel[COLNO][ROWNO]; xchar travel[COLNO][ROWNO];
@@ -917,7 +926,7 @@ boolean guess;
* goal is the position the player knows of, or might figure out * goal is the position the player knows of, or might figure out
* (couldsee) that is closest to the target on a straight path. * (couldsee) that is closest to the target on a straight path.
*/ */
if (guess) { if (mode == TRAVP_GUESS || mode == TRAVP_VALID) {
tx = u.ux; tx = u.ux;
ty = u.uy; ty = u.uy;
ux = u.tx; ux = u.tx;
@@ -987,7 +996,8 @@ boolean guess;
* example above is never included in it, preventing * example above is never included in it, preventing
* the cycle. * the cycle.
*/ */
if (!isok(nx, ny) || (guess && !couldsee(nx, ny))) if (!isok(nx, ny)
|| ((mode == TRAVP_GUESS) && !couldsee(nx, ny)))
continue; continue;
if ((!Passes_walls && !can_ooze(&youmonst) if ((!Passes_walls && !can_ooze(&youmonst)
&& closed_door(x, y)) || sobj_at(BOULDER, x, y) && closed_door(x, y)) || sobj_at(BOULDER, x, y)
@@ -1009,10 +1019,11 @@ boolean guess;
&& (levl[nx][ny].seenv && (levl[nx][ny].seenv
|| (!Blind && couldsee(nx, ny)))) { || (!Blind && couldsee(nx, ny)))) {
if (nx == ux && ny == uy) { if (nx == ux && ny == uy) {
if (!guess) { if (mode == TRAVP_TRAVEL || mode == TRAVP_VALID) {
u.dx = x - ux; u.dx = x - ux;
u.dy = y - uy; u.dy = y - uy;
if (x == u.tx && y == u.ty) { if (mode == TRAVP_TRAVEL
&& x == u.tx && y == u.ty) {
nomul(0); nomul(0);
/* reset run so domove run checks work */ /* reset run so domove run checks work */
context.run = 8; context.run = 8;
@@ -1052,7 +1063,7 @@ boolean guess;
} }
/* if guessing, find best location in travel matrix and go there */ /* if guessing, find best location in travel matrix and go there */
if (guess) { if (mode == TRAVP_GUESS) {
int px = tx, py = ty; /* pick location */ int px = tx, py = ty; /* pick location */
int dist, nxtdist, d2, nd2; int dist, nxtdist, d2, nd2;
@@ -1107,7 +1118,7 @@ boolean guess;
uy = u.uy; uy = u.uy;
set = 0; set = 0;
n = radius = 1; n = radius = 1;
guess = FALSE; mode = TRAVP_TRAVEL;
goto noguess; goto noguess;
} }
return FALSE; return FALSE;
@@ -1120,6 +1131,27 @@ found:
return FALSE; return FALSE;
} }
boolean
is_valid_travelpt(x,y)
int x,y;
{
int tx = u.tx;
int ty = u.ty;
boolean ret;
int g = glyph_at(x,y);
if (x == u.ux && y == u.uy)
return TRUE;
if (isok(x,y) && glyph_is_cmap(g) && S_stone == glyph_to_cmap(g)
&& !levl[x][y].seenv)
return FALSE;
u.tx = x;
u.ty = y;
ret = findtravelpath(TRAVP_VALID);
u.tx = tx;
u.ty = ty;
return ret;
}
/* try to escape being stuck in a trapped state by walking out of it; /* try to escape being stuck in a trapped state by walking out of it;
return true iff moving should continue to intended destination return true iff moving should continue to intended destination
(all failures and most successful escapes leave hero at original spot) */ (all failures and most successful escapes leave hero at original spot) */