partial fix for 'msg_window' option processing

options.c gave some unused variable warnings in the 'msg_window'
parsing if compiled without having tty enabled.

The 'msg_window' option should be available if either tty or curses
is the interface in use, hidden otherwise.  The code to parse it
was included if TTY_GRAPHICS is enabled, so it worked in curses for
a tty+curses binary but not curses without tty one.  This fixes that.

It is still displayed by 'O' when X11 or Qt is in use if the binary
also supports tty or curses.  I've left that as is.
This commit is contained in:
PatR
2020-08-03 15:42:09 -07:00
parent a968acb242
commit 2b8763c9fe
2 changed files with 31 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.270 $ $NHDT-Date: 1596486996 2020/08/03 20:36:36 $
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.271 $ $NHDT-Date: 1596494524 2020/08/03 22:42:04 $
General Fixes and Modified Features
-----------------------------------
@@ -314,6 +314,8 @@ some versions of tiles processing (not X11's) complained about the rename of
wizard mode #timeout changed to show timed Displacement in 'can be timed in
normal play' section instead of 'timed via #wizintrinsic only' section
curses: 'msg_window' option wasn't functional for curses unless the binary
also included tty support
tty: redraw unexplored locations as S_unexplored rather than <space> after
map has been partially overwritten by popup menu or text display
tty: previous change resulted in remnants of previous level being shown on

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 options.c $NHDT-Date: 1594168619 2020/07/08 00:36:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.468 $ */
/* NetHack 3.7 options.c $NHDT-Date: 1596494520 2020/08/03 22:42:00 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.469 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2079,6 +2079,13 @@ char *op;
return optn_ok;
}
/* whether the 'msg_window' option is used to control ^P behavior */
#if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS)
#define PREV_MSGS 1
#else
#define PREV_MSGS 0
#endif
int
optfn_msg_window(optidx, req, negated, opts, op)
int optidx;
@@ -2088,8 +2095,12 @@ char *opts;
char *op;
{
int retval = optn_ok;
#ifdef TTY_GRAPHICS
#if PREV_MSGS
int tmp;
#else
nhUse(optidx);
nhUse(negated);
nhUse(op);
#endif
if (req == do_init) {
@@ -2098,8 +2109,8 @@ char *op;
if (req == do_set) {
/* msg_window:single, combo, full or reversed */
/* allow option to be silently ignored by non-tty ports */
#ifdef TTY_GRAPHICS
/* allow option to be silently ignored by non-tty ports */
#if PREV_MSGS
if (op == empty_optstr) {
tmp = negated ? 's' : 'f';
} else {
@@ -2111,16 +2122,10 @@ char *op;
}
switch (tmp) {
case 's': /* single message history cycle (default if negated) */
iflags.prevmsg_window = 's';
break;
case 'c': /* combination: two singles, then full page */
iflags.prevmsg_window = 'c';
break;
case 'c': /* combination: first two as singles, then full page */
case 'f': /* full page (default if specified without argument) */
iflags.prevmsg_window = 'f';
break;
case 'r': /* full page (reversed) */
iflags.prevmsg_window = 'r';
case 'r': /* full page in reverse order (LIFO; default for curses) */
iflags.prevmsg_window = (char) tmp;
break;
default:
config_error_add("Unknown %s parameter '%s'", allopt[optidx].name,
@@ -2134,11 +2139,16 @@ char *op;
if (!opts)
return optn_err;
opts[0] = '\0';
#ifdef TTY_GRAPHICS
Sprintf(opts, "%s", (iflags.prevmsg_window == 's') ? "single"
: (iflags.prevmsg_window == 'c') ? "combination"
: (iflags.prevmsg_window == 'f') ? "full"
: "reversed");
#if PREV_MSGS
tmp = iflags.prevmsg_window;
if (WINDOWPORT("curses")) {
if (tmp == 's' || tmp == 'c')
tmp = iflags.prevmsg_window = 'r';
}
Sprintf(opts, "%s", (tmp == 's') ? "single"
: (tmp == 'c') ? "combination"
: (tmp == 'f') ? "full"
: "reversed");
#endif
return optn_ok;
}