.sd
.si
.CC c "compass ('east' or '3s' or '2n,4w');"
+.CC f "full compass ('east' or '3south' or '2north,4west');"
.CC m "map <x,y> (map column x=0 is not used);"
.CC s "screen [row,column] (row is offset to match tty usage);"
.CC n "none (no coordinates shown) [default]."
%.sd
%.si
{\tt c} --- \verb#compass ('east' or '3s' or '2n,4w')#;\\
+{\tt f} --- \verb#full compass ('east' or '3south' or '2north,4west')#;\\
{\tt m} --- \verb#map <x,y> (map column x=0 is not used)#;\\
{\tt s} --- \verb#screen [row,column] (row is offset to match tty usage)#;\\
{\tt n} --- \verb#none (no coordinates shown) [default]#.
#define GPCOORDS_NONE 'n'
#define GPCOORDS_MAP 'm'
#define GPCOORDS_COMPASS 'c'
+#define GPCOORDS_COMFULL 'f'
#define GPCOORDS_SCREEN 's'
struct instance_flags {
}
char *
-dxdy_to_dist_descr(dx, dy)
+dxdy_to_dist_descr(dx, dy, fulldir)
int dx, dy;
+boolean fulldir;
{
- /* [12] suffices, but guard against long translation for direction-name */
- static char buf[20];
+ static char buf[30];
int dst;
if (!dx && !dy) {
/* explicit direction; 'one step' is implicit */
Sprintf(buf, "%s", directionname(dst));
} else {
+ const char *dirnames[4][2] = {
+ { "n", "north" },
+ { "s", "south" },
+ { "w", "west" },
+ { "e", "east" } };
buf[0] = '\0';
/* 9999: protect buf[] against overflow caused by invalid values */
if (dy) {
if (abs(dy) > 9999)
dy = sgn(dy) * 9999;
- Sprintf(eos(buf), "%d%c%s", abs(dy), (dy > 0) ? 's' : 'n',
+ Sprintf(eos(buf), "%d%s%s", abs(dy), dirnames[(dy > 0)][fulldir],
dx ? "," : "");
}
if (dx) {
if (abs(dx) > 9999)
dx = sgn(dx) * 9999;
- Sprintf(eos(buf), "%d%c", abs(dx), (dx > 0) ? 'e' : 'w');
+ Sprintf(eos(buf), "%d%s", abs(dx), dirnames[2 + (dx > 0)][fulldir]);
}
}
return buf;
switch (cmode) {
default:
break;
+ case GPCOORDS_COMFULL:
case GPCOORDS_COMPASS:
/* "east", "3s", "2n,4w" */
dx = x - u.ux;
dy = y - u.uy;
- Sprintf(outbuf, "(%s)", dxdy_to_dist_descr(dx, dy));
+ Sprintf(outbuf, "(%s)",
+ dxdy_to_dist_descr(dx, dy, cmode == GPCOORDS_COMFULL));
break;
case GPCOORDS_MAP: /* x,y */
/* upper left corner of map is <1,0>;
return;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
static char gpcoords[] = { GPCOORDS_NONE, GPCOORDS_COMPASS,
- GPCOORDS_MAP, GPCOORDS_SCREEN, '\0' };
+ GPCOORDS_COMFULL, GPCOORDS_MAP,
+ GPCOORDS_SCREEN, '\0' };
char c = lowc(*op);
if (c && index(gpcoords, c))
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_COMPASS,
0, ATR_NONE, "compass ('east' or '3s' or '2n,4w')",
(gp == GPCOORDS_COMPASS) ? MENU_SELECTED : MENU_UNSELECTED);
+ any.a_char = GPCOORDS_COMFULL;
+ add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_COMFULL,
+ 0, ATR_NONE, "full compass ('east' or '3south' or '2north,4west')",
+ (gp == GPCOORDS_COMFULL) ? MENU_SELECTED : MENU_UNSELECTED);
any.a_char = GPCOORDS_MAP;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_MAP,
0, ATR_NONE, "map <x,y>",
Sprintf(buf, "%s",
(iflags.getpos_coords == GPCOORDS_MAP) ? "map"
: (iflags.getpos_coords == GPCOORDS_COMPASS) ? "compass"
+ : (iflags.getpos_coords == GPCOORDS_COMFULL) ? "full compass"
: (iflags.getpos_coords == GPCOORDS_SCREEN) ? "screen"
: "none");
} else if (!strcmp(optname, "scores")) {