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
+32 -9
View File
@@ -331,6 +331,7 @@ register int n;
extern char erase_char; /* from xxxtty.c; don't need kill_char */
/* returns a single keystroke; also sets 'yn_number' */
char
tty_yn_function(query, resp, def)
const char *query, *resp;
@@ -354,6 +355,7 @@ char def;
boolean doprev = 0;
char prompt[BUFSZ];
yn_number = 0L;
if (ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP))
more();
cw->flags &= ~WIN_STOP;
@@ -383,11 +385,14 @@ char def;
/* not pline("%s ", prompt);
trailing space is wanted here in case of reprompt */
Strcat(prompt, " ");
pline("%s", prompt);
/* pline("%s", prompt); -- see comment in hooked_tty_getlin() */
tty_putstr(WIN_MESSAGE, 0, prompt);
} else {
/* no restriction on allowed response, so always preserve case */
/* preserve_case = TRUE; -- moot since we're jumping to the end */
pline("%s ", query);
/* pline("%s ", query); -- see above about tty_getlin() */
Sprintf(prompt, "%s ", query);
tty_putstr(WIN_MESSAGE, 0, prompt);
q = readchar();
goto clean_up;
}
@@ -444,6 +449,7 @@ char def;
char z, digit_string[2];
int n_len = 0;
long value = 0;
addtopl("#"), n_len++;
digit_string[1] = '\0';
if (q != '#') {
@@ -491,11 +497,16 @@ char def;
}
} while (!q);
if (q != '#') {
Sprintf(rtmp, "%c", q);
addtopl(rtmp);
}
clean_up:
clean_up:
if (yn_number)
Sprintf(rtmp, "#%ld", yn_number);
else
(void) key2txt(q, rtmp);
/* addtopl(rtmp); -- rewrite toplines instead */
Sprintf(toplines, "%s%s", prompt, rtmp);
#ifdef DUMPLOG
dumplogmsg(toplines);
#endif
ttyDisplay->inread--;
ttyDisplay->toplin = 2;
if (ttyDisplay->intr)
@@ -636,6 +647,9 @@ boolean restoring_msghist;
{
static boolean initd = FALSE;
int idx;
#ifdef DUMPLOG
extern unsigned saved_pline_index; /* pline.c */
#endif
if (restoring_msghist && !initd) {
/* we're restoring history from the previous session, but new
@@ -645,18 +659,27 @@ boolean restoring_msghist;
restored ones are being put into place */
msghistory_snapshot(TRUE);
initd = TRUE;
#ifdef DUMPLOG
/* this suffices; there's no need to scrub saved_pline[] pointers */
saved_pline_index = 0;
#endif
}
if (msg) {
/* move most recent message to history, make this become most recent
*/
/* move most recent message to history, make this become most recent */
remember_topl();
Strcpy(toplines, msg);
#ifdef DUMPLOG
dumplogmsg(toplines);
#endif
} else if (snapshot_mesgs) {
/* done putting arbitrary messages in; put the snapshot ones back */
for (idx = 0; snapshot_mesgs[idx]; ++idx) {
remember_topl();
Strcpy(toplines, snapshot_mesgs[idx]);
#ifdef DUMPLOG
dumplogmsg(toplines);
#endif
}
/* now release the snapshot */
free_msghistory_snapshot(TRUE);