tty prompting fix and DUMPLOG of prompts+answers

Update DUMPLOG's message history to include player responses to
most queries.  For tty, both getlin() and yn_function().  For other
interfaces, only yn_function() is covered.  (It's intercepted by a
core routine that can take care of the logging; getlin() isn't.)
Also includes saved messages from previous session(s), for the
interfaces which support that (tty), to fill out the logging when
a game ends shortly after a save/restore cycle.

The tty interface was using pline() to display prompt strings.
Having 'MSGTYPE=hide "#"' or 'MSGTYPE=hide "yn"' in .nethackrc
would suppress many prompt strings (in the two examples mentioned,
entering extended commands or the vast majority of yes/no questions,
respectively) and generally lead to substantial confusion even if
done intentionally, so switch to putstr(WIN_MESSAGE) instead.
This commit is contained in:
PatR
2017-03-20 19:11:48 -07:00
parent a03d20d7ab
commit 82620d16f5
6 changed files with 102 additions and 24 deletions

View File

@@ -4571,11 +4571,12 @@ int x, y, mod;
}
char
get_count(allowchars, inkey, maxcount, count)
get_count(allowchars, inkey, maxcount, count, historical)
char *allowchars;
char inkey;
long maxcount;
long *count;
boolean historical; /* whether to include in message history: True => yes */
{
char qbuf[QBUFSZ];
int key;
@@ -4616,10 +4617,19 @@ long *count;
Sprintf(qbuf, "Count: %ld", cnt);
backspaced = FALSE;
}
pline1(qbuf);
/* bypassing pline() keeps intermediate prompt out of
DUMPLOG message history */
putstr(WIN_MESSAGE, 0, qbuf);
mark_synch();
}
}
if (historical) {
Sprintf(qbuf, "Count: %ld ", *count);
(void) key2txt((uchar) key, eos(qbuf));
putmsghistory(qbuf, FALSE);
}
return key;
}
@@ -4645,7 +4655,7 @@ parse()
if (!Cmd.num_pad || (foo = readchar()) == Cmd.spkeys[NHKF_COUNT]) {
long tmpmulti = multi;
foo = get_count((char *) 0, '\0', LARGEST_INT, &tmpmulti);
foo = get_count((char *) 0, '\0', LARGEST_INT, &tmpmulti, FALSE);
last_multi = multi = tmpmulti;
}
#ifdef ALTMETA
@@ -4902,7 +4912,13 @@ yn_function(query, resp, def)
const char *query, *resp;
char def;
{
char qbuf[QBUFSZ];
char res, qbuf[QBUFSZ];
#ifdef DUMPLOG
extern unsigned saved_pline_index; /* pline.c */
unsigned idx = saved_pline_index;
/* buffer to hold query+space+formatted_single_char_response */
char dumplog_buf[QBUFSZ + 1 + 15]; /* [QBUFSZ+1+7] should suffice */
#endif
iflags.last_msg = PLNMSG_UNKNOWN; /* most recent pline is clobbered */
@@ -4914,7 +4930,18 @@ char def;
Strcpy(&qbuf[QBUFSZ - 1 - 3], "...");
query = qbuf;
}
return (*windowprocs.win_yn_function)(query, resp, def);
res = (*windowprocs.win_yn_function)(query, resp, def);
#ifdef DUMPLOG
if (idx == saved_pline_index) {
/* when idx is still the same as saved_pline_index, the interface
didn't put the prompt into saved_plines[]; we put a simplified
version in there now (without response choices or default) */
Sprintf(dumplog_buf, "%s ", query);
(void) key2txt((uchar) res, eos(dumplog_buf));
dumplogmsg(dumplog_buf);
}
#endif
return res;
}
/* for paranoid_confirm:quit,die,attack prompting */