'I' command support for BUCX
Allow the 'I' command to show inventory of known blessed items via pseudo object classes B, C, U, and X. That's instead of an showing inventory of specific object class. The two can't be combined because 'I' operates on single character input. I had to modify tty_yn_function to prevent it from forcing a BUCX character into lower case (simply using lower case would cause a conflict with 'u' and 'x' for inventory of shopping bill), and did that by checking whether any of the acceptable response characters are upper case. Pretty straightforward and shouldn't impact any other uses that don't specify upper case choices. I did the same thing for X11. Other interfaces most likely need to do something similar. If they don't, a response of 'B' or 'C' (for menustyle:traditional or menustyle:combination) will simply not work, without causing any problems, same as typing an invalid choice, and 'U' or 'X' will give shop feedback instead of the requested subset of inventory. The Guidebook revisions are untested.
This commit is contained in:
+16
-4
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.5 topl.c $NHDT-Date: 1425081315 2015/02/27 23:55:15 $ $NHDT-Branch: master $:$NHDT-Revision: 1.24 $ */
|
||||
/* NetHack 3.5 topl.c $NHDT-Date: 1430040322 2015/04/26 09:25:22 $ $NHDT-Branch: master $:$NHDT-Revision: 1.29 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -333,7 +333,7 @@ char def;
|
||||
{
|
||||
register char q;
|
||||
char rtmp[40];
|
||||
boolean digit_ok, allow_num;
|
||||
boolean digit_ok, allow_num, preserve_case = FALSE;
|
||||
struct WinDesc *cw = wins[WIN_MESSAGE];
|
||||
boolean doprev = 0;
|
||||
char prompt[BUFSZ];
|
||||
@@ -347,6 +347,14 @@ char def;
|
||||
|
||||
allow_num = (index(resp, '#') != 0);
|
||||
Strcpy(respbuf, resp);
|
||||
/* normally we force lowercase, but if any uppercase letters
|
||||
are present in the allowed response, preserve case;
|
||||
check this before stripping the hidden choices */
|
||||
for (rb = respbuf; *rb; ++rb)
|
||||
if ('A' <= *rb && *rb <= 'Z') {
|
||||
preserve_case = TRUE;
|
||||
break;
|
||||
}
|
||||
/* any acceptable responses that follow <esc> aren't displayed */
|
||||
if ((rb = index(respbuf, '\033')) != 0) *rb = '\0';
|
||||
(void)strncpy(prompt, query, QBUFSZ-1);
|
||||
@@ -358,13 +366,16 @@ char def;
|
||||
Strcat(prompt, " ");
|
||||
pline("%s", 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);
|
||||
q = readchar();
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
do { /* loop until we get valid input */
|
||||
q = lowc(readchar());
|
||||
q = readchar();
|
||||
if (!preserve_case) q = lowc(q);
|
||||
if (q == '\020') { /* ctrl-P */
|
||||
if (iflags.prevmsg_window != 's') {
|
||||
int sav = ttyDisplay->inread;
|
||||
@@ -422,7 +433,8 @@ char def;
|
||||
q = '#';
|
||||
}
|
||||
do { /* loop until we get a non-digit */
|
||||
z = lowc(readchar());
|
||||
z = readchar();
|
||||
if (!preserve_case) z = lowc(z);
|
||||
if (digit(z)) {
|
||||
value = (10 * value) + (z - '0');
|
||||
if (value < 0) break; /* overflow: try again */
|
||||
|
||||
Reference in New Issue
Block a user