fix bz60 and bz61 - meta char feedback

60: getpos() doesn't report the offending keystroke accurately when
rejecting M-something as a movement keystroke while moving the cursor;
61: typing M-N as a command keystroke produces
 |Unknown command 'M-
 |                 '.
where the '.' on the second line clobbers the top line of the map.

I can't reproduce the first one without extending the altmeta hack
[a run-time option to treat two char sequence ESC c as M-c] to getpos()
and nh_poskey(), which I've done for testing but am not including here.

I can't reproduce the second as it's described, but M-^J produces
 |Unknown command 'M-
 |'.--More--
and this fixes that, with a general fix that applies to any meta char.

The diffs include some cleanup/groundwork for maybe extending altmeta.
This commit is contained in:
PatR
2015-12-15 03:22:39 -08:00
parent f3f2233122
commit 3ec592e3f1
4 changed files with 44 additions and 54 deletions
+4
View File
@@ -29,10 +29,14 @@ negative intrinsic protection shouldn't confer MC=1, "you are warded" (not
make a slight adjustment to the quickmimic() sense wording make a slight adjustment to the quickmimic() sense wording
fix typo in passage 1 of The Colour of Magic fix typo in passage 1 of The Colour of Magic
falling asleep when reading dull spellbook ignored sleep resistance falling asleep when reading dull spellbook ignored sleep resistance
getpos() complaint about invalid movement keystroke didn't describe meta-chars
accurately
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes
----------------------------------------- -----------------------------------------
tty: M-N gave "Unknown command 'M-" with "'." finishing the sentence on the
line below it, leaving bogus '.' displayed on the top row of the map
unix/X11: in top level Makefile, some commented out definitions of VARDATND unix/X11: in top level Makefile, some commented out definitions of VARDATND
misspelled pilemark.xbm (as pilemark.xpm) misspelled pilemark.xbm (as pilemark.xpm)
win32gui: getversionstring() was overflowing the provided Help About buffer win32gui: getversionstring() was overflowing the provided Help About buffer
+19 -37
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 cmd.c $NHDT-Date: 1449736557 2015/12/10 08:35:57 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.208 $ */ /* NetHack 3.6 cmd.c $NHDT-Date: 1450178549 2015/12/15 11:22:29 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.209 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -107,7 +107,7 @@ extern int NDECL(dowield); /**/
extern int NDECL(dowieldquiver); /**/ extern int NDECL(dowieldquiver); /**/
extern int NDECL(dozap); /**/ extern int NDECL(dozap); /**/
extern int NDECL(doorganize); /**/ extern int NDECL(doorganize); /**/
#endif /* DUMB */ #endif /* DUMB */
static int NDECL(dosuspend_core); /**/ static int NDECL(dosuspend_core); /**/
@@ -3402,15 +3402,8 @@ register char *cmd;
register const struct func_tab *tlist; register const struct func_tab *tlist;
int res, NDECL((*func)); int res, NDECL((*func));
#if 0
/* obsolete - scan through the cmdlist array looking for *cmd */
for (tlist = cmdlist; tlist->f_char; tlist++) {
if ((*cmd & 0xff) != (tlist->f_char & 0xff))
continue;
#else
/* current - use *cmd to directly index cmdlist array */ /* current - use *cmd to directly index cmdlist array */
if ((tlist = Cmd.commands[*cmd & 0xff]) != 0) { if ((tlist = Cmd.commands[*cmd & 0xff]) != 0) {
#endif
if (u.uburied && !tlist->can_if_buried) { if (u.uburied && !tlist->can_if_buried) {
You_cant("do that while you are buried!"); You_cant("do that while you are buried!");
res = 0; res = 0;
@@ -3433,23 +3426,13 @@ register char *cmd;
} }
if (bad_command) { if (bad_command) {
char expcmd[10]; char expcmd[20]; /* we expect 'cmd' to point to 1 or 2 chars */
register char c, *cp = expcmd; register char c;
expcmd[0] = '\0';
while ((c = *cmd++) != '\0')
Strcat(expcmd, visctrl(c)); /* add 1..4 chars plus terminator */
while ((c = *cmd++) != '\0'
&& (int) (cp - expcmd) < (int) (sizeof expcmd - 3)) {
if (c >= 040 && c < 0177) {
*cp++ = c;
} else if (c & 0200) {
*cp++ = 'M';
*cp++ = '-';
*cp++ = c & ~0200;
} else {
*cp++ = '^';
*cp++ = c ^ 0100;
}
}
*cp = '\0';
if (!prefix_seen || !iflags.cmdassist if (!prefix_seen || !iflags.cmdassist
|| !help_dir(0, "Invalid direction key!")) || !help_dir(0, "Invalid direction key!"))
Norep("Unknown command '%s'.", expcmd); Norep("Unknown command '%s'.", expcmd);
@@ -3587,10 +3570,9 @@ retry:
if (!index(quitchars, dirsym)) { if (!index(quitchars, dirsym)) {
help_requested = (dirsym == '?'); help_requested = (dirsym == '?');
if (help_requested || iflags.cmdassist) { if (help_requested || iflags.cmdassist) {
did_help = did_help = help_dir((s && *s == '^') ? dirsym : 0,
help_dir((s && *s == '^') ? dirsym : 0, help_requested ? (const char *) 0
help_requested ? (const char *) 0 : "Invalid direction key!");
: "Invalid direction key!");
if (help_requested) if (help_requested)
goto retry; goto retry;
} }
@@ -4121,14 +4103,14 @@ char def;
iflags.last_msg = PLNMSG_UNKNOWN; /* most recent pline is clobbered */ iflags.last_msg = PLNMSG_UNKNOWN; /* most recent pline is clobbered */
/* maximum acceptable length is QBUFSZ-1 */ /* maximum acceptable length is QBUFSZ-1 */
if (strlen(query) < QBUFSZ) if (strlen(query) >= QBUFSZ) {
return (*windowprocs.win_yn_function)(query, resp, def); /* caller shouldn't have passed anything this long */
paniclog("Query truncated: ", query);
/* caller shouldn't have passed anything this long */ (void) strncpy(qbuf, query, QBUFSZ - 1 - 3);
paniclog("Query truncated: ", query); Strcpy(&qbuf[QBUFSZ - 1 - 3], "...");
(void) strncpy(qbuf, query, QBUFSZ - 1 - 3); query = qbuf;
Strcpy(&qbuf[QBUFSZ - 1 - 3], "..."); }
return (*windowprocs.win_yn_function)(qbuf, resp, def); return (*windowprocs.win_yn_function)(query, resp, def);
} }
/* for paranoid_confirm:quit,die,attack prompting */ /* for paranoid_confirm:quit,die,attack prompting */
+4 -4
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 do_name.c $NHDT-Date: 1449982602 2015/12/13 04:56:42 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.79 $ */ /* NetHack 3.6 do_name.c $NHDT-Date: 1450178550 2015/12/15 11:22:30 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.80 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -54,7 +54,7 @@ const char *goal;
putstr(tmpwin, 0, "Use [HJKL] to move the cursor 8 units at a time."); putstr(tmpwin, 0, "Use [HJKL] to move the cursor 8 units at a time.");
putstr(tmpwin, 0, "Or enter a background symbol (ex. <)."); putstr(tmpwin, 0, "Or enter a background symbol (ex. <).");
putstr(tmpwin, 0, "Use @ to move the cursor on yourself."); putstr(tmpwin, 0, "Use @ to move the cursor on yourself.");
if (getpos_hilitefunc != NULL) if (getpos_hilitefunc)
putstr(tmpwin, 0, "Use $ to display valid locations."); putstr(tmpwin, 0, "Use $ to display valid locations.");
putstr(tmpwin, 0, "Use # to toggle automatic description."); putstr(tmpwin, 0, "Use # to toggle automatic description.");
/* disgusting hack; the alternate selection characters work for any /* disgusting hack; the alternate selection characters work for any
@@ -197,7 +197,7 @@ const char *goal;
/* update message window to reflect that we're still targetting */ /* update message window to reflect that we're still targetting */
show_goal_msg = TRUE; show_goal_msg = TRUE;
msg_given = TRUE; msg_given = TRUE;
} else if ((c == '$') && (getpos_hilitefunc != NULL)) { } else if (c == '$' && getpos_hilitefunc) {
if (!hilite_state) { if (!hilite_state) {
(*getpos_hilitefunc)(0); (*getpos_hilitefunc)(0);
(*getpos_hilitefunc)(1); (*getpos_hilitefunc)(1);
@@ -307,7 +307,7 @@ const char *goal;
clear_nhwindow(WIN_MESSAGE); clear_nhwindow(WIN_MESSAGE);
ccp->x = cx; ccp->x = cx;
ccp->y = cy; ccp->y = cy;
getpos_hilitefunc = NULL; getpos_hilitefunc = (void FDECL((*), (int))) 0;
return result; return result;
} }
+17 -13
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 hacklib.c $NHDT-Date: 1446336792 2015/11/01 00:13:12 $ $NHDT-Branch: master $:$NHDT-Revision: 1.44 $ */ /* NetHack 3.6 hacklib.c $NHDT-Date: 1450178551 2015/12/15 11:22:31 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.46 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* Copyright (c) Robert Patrick Rankin, 1991 */ /* Copyright (c) Robert Patrick Rankin, 1991 */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -373,20 +373,24 @@ char *
visctrl(c) visctrl(c)
char c; char c;
{ {
Static char ccc[3]; Static char ccc[5];
register int i = 0;
c &= 0177; if ((uchar) c & 0200) {
ccc[2] = '\0'; ccc[i++] = 'M';
if (c < 040) { ccc[i++] = '-';
ccc[0] = '^';
ccc[1] = c | 0100; /* letter */
} else if (c == 0177) {
ccc[0] = '^';
ccc[1] = c & ~0100; /* '?' */
} else {
ccc[0] = c; /* printable character */
ccc[1] = '\0';
} }
c &= 0177;
if (c < 040) {
ccc[i++] = '^';
ccc[i++] = c | 0100; /* letter */
} else if (c == 0177) {
ccc[i++] = '^';
ccc[i++] = c & ~0100; /* '?' */
} else {
ccc[i++] = c; /* printable character */
}
ccc[i] = '\0';
return ccc; return ccc;
} }