options.c formatting; glob as named fruit

This started out removing one tab and I got carried away.  It moves
some labels to column 2, removes some parentheses where sizeof is
used on strings rather than types, adds or revises several comments,
replaces a couple of 'while' loops which can be simplified as 'for'
loops, and updates named fruit handling.

"glob of black pudding" became "candied glob of black pudding" if used
as a fruit name, but "small glob of black pudding" was used as-is and
became indistinguishable from an actual small glob.  Unless you had
more than one; then you could try to check whether they merged into a
stack or coalesced into a bigger glob (but if neither of those changes
happened, you still couldn't tell which was the glob and which was the
named fruit).
This commit is contained in:
PatR
2019-01-04 19:03:34 -08:00
parent c0cce3110e
commit ab5b400aec

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 options.c $NHDT-Date: 1546212618 2018/12/30 23:30:18 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.350 $ */
/* NetHack 3.6 options.c $NHDT-Date: 1546657409 2019/01/05 03:03:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.351 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -279,7 +279,7 @@ static struct Comp_Opt {
{ "catname", "the name of your (first) cat (e.g., catname:Tabby)",
PL_PSIZ, DISP_IN_GAME },
{ "disclose", "the kinds of information to disclose at end of game",
sizeof(flags.end_disclose) * 2, SET_IN_GAME },
sizeof flags.end_disclose * 2, SET_IN_GAME },
{ "dogname", "the name of your (first) dog (e.g., dogname:Fang)", PL_PSIZ,
DISP_IN_GAME },
{ "dungeon", "the symbols to use in drawing the dungeon map",
@@ -720,7 +720,7 @@ initoptions_init()
#endif
#ifdef SYSFLAGS
Strcpy(sysflags.sysflagsid, "sysflags");
sysflags.sysflagsid[9] = (char) sizeof(struct sysflag);
sysflags.sysflagsid[9] = (char) sizeof (struct sysflag);
#endif
flags.end_own = FALSE;
flags.end_top = 3;
@@ -908,6 +908,8 @@ int maxlen;
/*
* escapes(): escape expansion for showsyms. C-style escapes understood
* include \n, \b, \t, \r, \xnnn (hex), \onnn (octal), \nnn (decimal).
* (Note: unlike in C, leading digit 0 is not used to indicate octal;
* the letter o (either upper or lower case) is used for that.
* The ^-prefix for control characters is also understood, and \[mM]
* has the effect of 'meta'-ing the value which follows (so that the
* alternate character set will be enabled).
@@ -1013,7 +1015,7 @@ const char *optname;
/*
# errors:
OPTIONS=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
OPTIONS=aaaaaaaaaa[ more than 247 (255 - 8 for 'OPTIONS=') total ]aaaaaaaaaa
OPTIONS
OPTIONS=
MSGTYPE=stop"You swap places with "
@@ -1386,7 +1388,7 @@ char *str;
/* allow "lightblue", "light blue", and "light-blue" to match "light blue"
(also junk like "_l i-gh_t---b l u e" but we won't worry about that);
also copes with trailing space; mungspaces removed any leading space */
also copes with trailing space; caller has removed any leading space */
for (i = 0; i < SIZE(colornames); i++)
if (colornames[i].name
&& fuzzymatch(str, colornames[i].name, " -_", TRUE)) {
@@ -1613,8 +1615,7 @@ msgtype_add(typ, pattern)
int typ;
char *pattern;
{
struct plinemsg_type
*tmp = (struct plinemsg_type *) alloc(sizeof (struct plinemsg_type));
struct plinemsg_type *tmp = (struct plinemsg_type *) alloc(sizeof *tmp);
tmp->msgtype = typ;
tmp->regex = regex_init();
@@ -1785,7 +1786,7 @@ int c, a;
if (!str)
return FALSE;
tmp = (struct menucoloring *) alloc(sizeof (struct menucoloring));
tmp = (struct menucoloring *) alloc(sizeof *tmp);
tmp->match = regex_init();
if (!regex_compile(str, tmp->match)) {
config_error_add("%s: %s", re_error, regex_error_desc(tmp->match));
@@ -1846,7 +1847,6 @@ char *tmpstr;
tmps++;
}
}
return add_menu_coloring_parsed(tmps, c, a);
}
@@ -1870,15 +1870,13 @@ int *color, *attr;
void
free_menu_coloring()
{
struct menucoloring *tmp = menu_colorings;
while (tmp) {
struct menucoloring *tmp2 = tmp->next;
struct menucoloring *tmp, *tmp2;
for (tmp = menu_colorings; tmp; tmp = tmp2) {
tmp2 = tmp->next;
regex_free(tmp->match);
free((genericptr_t) tmp->origstr);
free((genericptr_t) tmp);
tmp = tmp2;
}
}
@@ -1911,13 +1909,11 @@ int idx; /* 0 .. */
STATIC_OVL int
count_menucolors(VOID_ARGS)
{
struct menucoloring *tmp;
int count = 0;
struct menucoloring *tmp = menu_colorings;
while (tmp) {
for (tmp = menu_colorings; tmp; tmp = tmp->next)
count++;
tmp = tmp->next;
}
return count;
}
@@ -2066,7 +2062,7 @@ boolean tinitial, tfrom_file;
/* align:string */
fullname = "align";
if (match_optname(opts, fullname, sizeof("align") - 1, TRUE)) {
if (match_optname(opts, fullname, sizeof "align" - 1, TRUE)) {
if (parse_role_opts(negated, fullname, opts, &op)) {
if ((flags.initalign = str2align(op)) == ROLE_NONE) {
config_error_add("Unknown %s '%s'", fullname, op);
@@ -2620,7 +2616,7 @@ boolean tinitial, tfrom_file;
}
}
}
goodfruit:
goodfruit:
nmcpy(pl_fruit, op, PL_FSIZ);
sanitize_name(pl_fruit);
/* OBJ_NAME(objects[SLIME_MOLD]) won't work for this after
@@ -2793,16 +2789,16 @@ boolean tinitial, tfrom_file;
/* WINCAP
* align_status:[left|top|right|bottom] */
fullname = "align_status";
if (match_optname(opts, fullname, sizeof("align_status") - 1, TRUE)) {
if (match_optname(opts, fullname, sizeof "align_status" - 1, TRUE)) {
op = string_for_opt(opts, negated);
if (op && !negated) {
if (!strncmpi(op, "left", sizeof("left") - 1))
if (!strncmpi(op, "left", sizeof "left" - 1))
iflags.wc_align_status = ALIGN_LEFT;
else if (!strncmpi(op, "top", sizeof("top") - 1))
else if (!strncmpi(op, "top", sizeof "top" - 1))
iflags.wc_align_status = ALIGN_TOP;
else if (!strncmpi(op, "right", sizeof("right") - 1))
else if (!strncmpi(op, "right", sizeof "right" - 1))
iflags.wc_align_status = ALIGN_RIGHT;
else if (!strncmpi(op, "bottom", sizeof("bottom") - 1))
else if (!strncmpi(op, "bottom", sizeof "bottom" - 1))
iflags.wc_align_status = ALIGN_BOTTOM;
else {
config_error_add("Unknown %s parameter '%s'", fullname, op);
@@ -2818,18 +2814,18 @@ boolean tinitial, tfrom_file;
/* WINCAP
* align_message:[left|top|right|bottom] */
fullname = "align_message";
if (match_optname(opts, fullname, sizeof("align_message") - 1, TRUE)) {
if (match_optname(opts, fullname, sizeof "align_message" - 1, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
if (op && !negated) {
if (!strncmpi(op, "left", sizeof("left") - 1))
if (!strncmpi(op, "left", sizeof "left" - 1))
iflags.wc_align_message = ALIGN_LEFT;
else if (!strncmpi(op, "top", sizeof("top") - 1))
else if (!strncmpi(op, "top", sizeof "top" - 1))
iflags.wc_align_message = ALIGN_TOP;
else if (!strncmpi(op, "right", sizeof("right") - 1))
else if (!strncmpi(op, "right", sizeof "right" - 1))
iflags.wc_align_message = ALIGN_RIGHT;
else if (!strncmpi(op, "bottom", sizeof("bottom") - 1))
else if (!strncmpi(op, "bottom", sizeof "bottom" - 1))
iflags.wc_align_message = ALIGN_BOTTOM;
else {
config_error_add("Unknown %s parameter '%s'", fullname, op);
@@ -2883,7 +2879,7 @@ boolean tinitial, tfrom_file;
pp = index(op, ' ');
if (pp)
*pp = '\0';
/* we aren't matching option names but match_optname
/* we aren't matching option names but match_optname()
does what we want once we've broken the space
delimited aggregate into separate tokens */
for (i = 0; i < SIZE(paranoia); ++i) {
@@ -2968,8 +2964,8 @@ boolean tinitial, tfrom_file;
/* types of objects to pick up automatically */
fullname = "pickup_types";
if (match_optname(opts, fullname, 8, TRUE)) {
char ocl[MAXOCLASSES + 1], tbuf[MAXOCLASSES + 1], qbuf[QBUFSZ],
abuf[BUFSZ] = DUMMY;
char ocl[MAXOCLASSES + 1], tbuf[MAXOCLASSES + 1],
qbuf[QBUFSZ], abuf[BUFSZ];
int oc_sym;
boolean badopt = FALSE, compat = (strlen(opts) <= 6), use_menu;
@@ -2995,6 +2991,7 @@ boolean tinitial, tfrom_file;
use_menu = FALSE;
Sprintf(qbuf, "New %s: [%s am] (%s)", fullname, ocl,
*tbuf ? tbuf : "all");
abuf[0] = '\0';
getlin(qbuf, abuf);
wasspace = (abuf[0] == ' '); /* before mungspaces */
op = mungspaces(abuf);
@@ -3004,6 +3001,8 @@ boolean tinitial, tfrom_file;
op = tbuf; /* restore */
else if (abuf[0] == 'm')
use_menu = TRUE;
/* note: abuf[0]=='a' is already handled via clearing the
the old value (above) as a default action */
}
if (use_menu) {
if (wizard && !index(ocl, VENOM_SYM))
@@ -3087,18 +3086,18 @@ boolean tinitial, tfrom_file;
}
/* WINCAP
* player_selection: dialog | prompts */
* player_selection: dialog | prompt/prompts/prompting */
fullname = "player_selection";
if (match_optname(opts, fullname, sizeof("player_selection") - 1, TRUE)) {
if (match_optname(opts, fullname, sizeof "player_selection" - 1, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
if (op && !negated) {
if (!strncmpi(op, "dialog", sizeof("dialog") - 1))
if (!strncmpi(op, "dialog", sizeof "dialog" - 1)) {
iflags.wc_player_selection = VIA_DIALOG;
else if (!strncmpi(op, "prompt", sizeof("prompt") - 1))
} else if (!strncmpi(op, "prompt", sizeof "prompt" - 1)) {
iflags.wc_player_selection = VIA_PROMPTS;
else {
} else {
config_error_add("Unknown %s parameter '%s'", fullname, op);
return FALSE;
}
@@ -3120,11 +3119,13 @@ boolean tinitial, tfrom_file;
* end_disclose[NUM_DISCLOSURE_OPT];
* with option settings for the each of the following:
* iagvc [see disclosure_options in decl.c]:
* Legal setting values in that array are:
* Allowed setting values in that array are:
* DISCLOSE_PROMPT_DEFAULT_YES ask with default answer yes
* DISCLOSE_PROMPT_DEFAULT_NO ask with default answer no
* DISCLOSE_YES_WITHOUT_PROMPT always disclose and don't ask
* DISCLOSE_NO_WITHOUT_PROMPT never disclose and don't ask
* DISCLOSE_PROMPT_DEFAULT_SPECIAL for 'vanquished' only...
* DISCLOSE_SPECIAL_WITHOUT_PROMPT ...to set up sort order.
*
* Those setting values can be used in the option
* string as a prefix to get the desired behaviour.
@@ -3360,33 +3361,33 @@ boolean tinitial, tfrom_file;
* |ascii8x12|ascii16x12|ascii12x16|ascii10x18|fit_to_screen]
*/
fullname = "map_mode";
if (match_optname(opts, fullname, sizeof("map_mode") - 1, TRUE)) {
if (match_optname(opts, fullname, sizeof "map_mode" - 1, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
if (op && !negated) {
if (!strncmpi(op, "tiles", sizeof("tiles") - 1))
if (!strncmpi(op, "tiles", sizeof "tiles" - 1))
iflags.wc_map_mode = MAP_MODE_TILES;
else if (!strncmpi(op, "ascii4x6", sizeof("ascii4x6") - 1))
else if (!strncmpi(op, "ascii4x6", sizeof "ascii4x6" - 1))
iflags.wc_map_mode = MAP_MODE_ASCII4x6;
else if (!strncmpi(op, "ascii6x8", sizeof("ascii6x8") - 1))
else if (!strncmpi(op, "ascii6x8", sizeof "ascii6x8" - 1))
iflags.wc_map_mode = MAP_MODE_ASCII6x8;
else if (!strncmpi(op, "ascii8x8", sizeof("ascii8x8") - 1))
else if (!strncmpi(op, "ascii8x8", sizeof "ascii8x8" - 1))
iflags.wc_map_mode = MAP_MODE_ASCII8x8;
else if (!strncmpi(op, "ascii16x8", sizeof("ascii16x8") - 1))
else if (!strncmpi(op, "ascii16x8", sizeof "ascii16x8" - 1))
iflags.wc_map_mode = MAP_MODE_ASCII16x8;
else if (!strncmpi(op, "ascii7x12", sizeof("ascii7x12") - 1))
else if (!strncmpi(op, "ascii7x12", sizeof "ascii7x12" - 1))
iflags.wc_map_mode = MAP_MODE_ASCII7x12;
else if (!strncmpi(op, "ascii8x12", sizeof("ascii8x12") - 1))
else if (!strncmpi(op, "ascii8x12", sizeof "ascii8x12" - 1))
iflags.wc_map_mode = MAP_MODE_ASCII8x12;
else if (!strncmpi(op, "ascii16x12", sizeof("ascii16x12") - 1))
else if (!strncmpi(op, "ascii16x12", sizeof "ascii16x12" - 1))
iflags.wc_map_mode = MAP_MODE_ASCII16x12;
else if (!strncmpi(op, "ascii12x16", sizeof("ascii12x16") - 1))
else if (!strncmpi(op, "ascii12x16", sizeof "ascii12x16" - 1))
iflags.wc_map_mode = MAP_MODE_ASCII12x16;
else if (!strncmpi(op, "ascii10x18", sizeof("ascii10x18") - 1))
else if (!strncmpi(op, "ascii10x18", sizeof "ascii10x18" - 1))
iflags.wc_map_mode = MAP_MODE_ASCII10x18;
else if (!strncmpi(op, "fit_to_screen",
sizeof("fit_to_screen") - 1))
sizeof "fit_to_screen" - 1))
iflags.wc_map_mode = MAP_MODE_ASCII_FIT_TO_SCREEN;
else {
config_error_add("Unknown %s parameter '%s'", fullname, op);
@@ -3453,7 +3454,7 @@ boolean tinitial, tfrom_file;
/* WINCAP
* tile_width:nn */
fullname = "tile_width";
if (match_optname(opts, fullname, sizeof("tile_width") - 1, TRUE)) {
if (match_optname(opts, fullname, sizeof "tile_width" - 1, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
@@ -3468,7 +3469,7 @@ boolean tinitial, tfrom_file;
/* WINCAP
* tile_file:name */
fullname = "tile_file";
if (match_optname(opts, fullname, sizeof("tile_file") - 1, TRUE)) {
if (match_optname(opts, fullname, sizeof "tile_file" - 1, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
if ((op = string_for_opt(opts, FALSE)) != 0) {
@@ -3482,7 +3483,7 @@ boolean tinitial, tfrom_file;
/* WINCAP
* tile_height:nn */
fullname = "tile_height";
if (match_optname(opts, fullname, sizeof("tile_height") - 1, TRUE)) {
if (match_optname(opts, fullname, sizeof "tile_height" - 1, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
@@ -3498,7 +3499,7 @@ boolean tinitial, tfrom_file;
/* WINCAP
* vary_msgcount:nn */
fullname = "vary_msgcount";
if (match_optname(opts, fullname, sizeof("vary_msgcount") - 1, TRUE)) {
if (match_optname(opts, fullname, sizeof "vary_msgcount" - 1, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
@@ -3521,7 +3522,8 @@ boolean tinitial, tfrom_file;
* OPTIONS=windowtype:Foo
* as the first non-comment line of the file.
* Making it first in NETHACKOPTIONS requires it to be at the _end_
* because option strings are processed from right to left.
* because comma-separated option strings are processed from right
* to left.
*/
fullname = "windowtype";
if (match_optname(opts, fullname, 3, TRUE)) {
@@ -3540,7 +3542,7 @@ boolean tinitial, tfrom_file;
choose_windows(buf);
} else {
nmcpy(chosen_windowtype, op, WINTYPELEN);
}
}
} else
return FALSE;
return retval;
@@ -3582,7 +3584,7 @@ boolean tinitial, tfrom_file;
/* WINCAP2
* term_cols:amount */
fullname = "term_cols";
if (match_optname(opts, fullname, sizeof("term_cols")-1, TRUE)) {
if (match_optname(opts, fullname, sizeof "term_cols" - 1, TRUE)) {
op = string_for_opt(opts, negated);
iflags.wc2_term_cols = atoi(op);
if (negated)
@@ -3593,7 +3595,7 @@ boolean tinitial, tfrom_file;
/* WINCAP2
* term_rows:amount */
fullname = "term_rows";
if (match_optname(opts, fullname, sizeof("term_rows")-1, TRUE)) {
if (match_optname(opts, fullname, sizeof "term_rows" - 1, TRUE)) {
op = string_for_opt(opts, negated);
iflags.wc2_term_rows = atoi(op);
if (negated)
@@ -3604,7 +3606,7 @@ boolean tinitial, tfrom_file;
/* WINCAP2
* petattr:string */
fullname = "petattr";
if (match_optname(opts, fullname, sizeof("petattr")-1, TRUE)) {
if (match_optname(opts, fullname, sizeof "petattr" - 1, TRUE)) {
op = string_for_opt(opts, negated);
if (op && !negated) {
#ifdef CURSES_GRAPHICS
@@ -3625,7 +3627,7 @@ boolean tinitial, tfrom_file;
/* WINCAP2
* windowborders:n */
fullname = "windowborders";
if (match_optname(opts, fullname, sizeof("windowborders")-1, TRUE)) {
if (match_optname(opts, fullname, sizeof "windowborders" - 1, TRUE)) {
op = string_for_opt(opts, negated);
if (negated && op)
bad_negation(fullname, TRUE);
@@ -3637,10 +3639,9 @@ boolean tinitial, tfrom_file;
else /* Value supplied */
iflags.wc2_windowborders = atoi(op);
if ((iflags.wc2_windowborders > 3)
|| (iflags.wc2_windowborders < 1)) {
|| (iflags.wc2_windowborders < 1)) {
iflags.wc2_windowborders = 0;
config_error_add(
"Badoption - windowborders %s.", opts);
config_error_add("Badoption - windowborders %s.", opts);
}
}
return retval;
@@ -3722,10 +3723,10 @@ boolean tinitial, tfrom_file;
escapes(op, op_buf);
c = *op_buf;
if (illegal_menu_cmd_key(c)) {
if (illegal_menu_cmd_key(c))
return FALSE;
} else
add_menu_cmd_alias(c, default_menu_cmd_info[i].cmd);
add_menu_cmd_alias(c, default_menu_cmd_info[i].cmd);
}
return retval;
}
@@ -3887,8 +3888,9 @@ boolean tinitial, tfrom_file;
#endif /* ?(MAC_GRAPHICS_ENV && BACKWARD_COMPAT) */
} /* "MACgraphics" */
/* OK, if we still haven't recognized the option, check the boolean
* options list
/*
* OK, if we still haven't recognized the option, check the boolean
* options list.
*/
for (i = 0; boolopt[i].name; i++) {
if (match_optname(opts, boolopt[i].name, 3, TRUE)) {
@@ -4121,8 +4123,8 @@ char from_ch, to_ch;
mapped_menu_cmds[n_menu_mapped] = from_ch;
mapped_menu_op[n_menu_mapped] = to_ch;
n_menu_mapped++;
mapped_menu_cmds[n_menu_mapped] = 0;
mapped_menu_op[n_menu_mapped] = 0;
mapped_menu_cmds[n_menu_mapped] = '\0';
mapped_menu_op[n_menu_mapped] = '\0';
}
}
@@ -4349,17 +4351,14 @@ doset() /* changing options via menu by Per Liboriussen */
and adjust the format string accordingly */
longest_name_len = 0;
for (pass = 0; pass <= 2; pass++)
for (i = 0; (name = ((pass == 0)
? boolopt[i].name
: (pass == 1)
? compopt[i].name
for (i = 0; (name = ((pass == 0) ? boolopt[i].name
: (pass == 1) ? compopt[i].name
: othropt[i].name)) != 0; i++) {
if (pass == 0 && !boolopt[i].addr)
continue;
optflags = (pass == 0) ? boolopt[i].optflags
: (pass == 1)
? compopt[i].optflags
: othropt[i].optflags;
: (pass == 1) ? compopt[i].optflags
: othropt[i].optflags;
if (optflags < startpass || optflags > endpass)
continue;
if ((is_wc_option(name) && !wc_supported(name))
@@ -4511,8 +4510,7 @@ doset() /* changing options via menu by Per Liboriussen */
preference_update(compopt[opt_indx].name);
}
}
free((genericptr_t) pick_list);
pick_list = (menu_item *) 0;
free((genericptr_t) pick_list), pick_list = (menu_item *) 0;
}
destroy_nhwindow(tmpwin);
@@ -4524,6 +4522,7 @@ doset() /* changing options via menu by Per Liboriussen */
return 0;
}
/* common to msg-types, menu-colors, autopickup-exceptions */
STATIC_OVL int
handle_add_list_remove(optname, numtotal)
const char *optname;
@@ -4572,7 +4571,7 @@ int numtotal;
}
struct symsetentry *symset_list = 0; /* files.c will populate this with
list of available sets */
* list of available sets */
STATIC_OVL boolean
special_handling(optname, setinitial, setfromfile)
@@ -4777,24 +4776,24 @@ boolean setinitial, setfromfile;
start_menu(tmpwin);
any = zeroany;
any.a_char = GPCOORDS_COMPASS;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_COMPASS,
0, ATR_NONE, "compass ('east' or '3s' or '2n,4w')",
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_COMPASS, 0, ATR_NONE,
"compass ('east' or '3s' or '2n,4w')",
(gp == GPCOORDS_COMPASS) ? MENU_SELECTED : MENU_UNSELECTED);
any.a_char = GPCOORDS_COMFULL;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_COMFULL, 0, ATR_NONE,
"full compass ('east' or '3south' or '2north,4west')",
(gp == GPCOORDS_COMFULL) ? MENU_SELECTED : MENU_UNSELECTED);
any.a_char = GPCOORDS_MAP;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_MAP,
0, ATR_NONE, "map <x,y>",
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_MAP, 0, ATR_NONE,
"map <x,y>",
(gp == GPCOORDS_MAP) ? MENU_SELECTED : MENU_UNSELECTED);
any.a_char = GPCOORDS_SCREEN;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_SCREEN,
0, ATR_NONE, "screen [row,column]",
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_SCREEN, 0, ATR_NONE,
"screen [row,column]",
(gp == GPCOORDS_SCREEN) ? MENU_SELECTED : MENU_UNSELECTED);
any.a_char = GPCOORDS_NONE;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_NONE,
0, ATR_NONE, "none (no coordinates displayed)",
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_NONE, 0, ATR_NONE,
"none (no coordinates displayed)",
(gp == GPCOORDS_NONE) ? MENU_SELECTED : MENU_UNSELECTED);
any.a_long = 0L;
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
@@ -4802,7 +4801,7 @@ boolean setinitial, setfromfile;
1, 0, COLNO - 1, ROWNO - 1,
flags.verbose ? "; column 0 unused, off left edge" : "");
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
if (strcmp(windowprocs.name, "tty"))
if (strcmp(windowprocs.name, "tty")) /* only show for non-tty */
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
"screen: row is offset to accommodate tty interface's use of top line",
MENU_UNSELECTED);
@@ -5002,7 +5001,7 @@ boolean setinitial, setfromfile;
int opt_idx, nmt, mttyp;
char mtbuf[BUFSZ] = DUMMY;
msgtypes_again:
msgtypes_again:
nmt = msgtype_count();
opt_idx = handle_add_list_remove("message type", nmt);
if (opt_idx == 3) { /* done */
@@ -5064,11 +5063,11 @@ boolean setinitial, setfromfile;
int opt_idx, nmc, mcclr, mcattr;
char mcbuf[BUFSZ] = DUMMY;
menucolors_again:
menucolors_again:
nmc = count_menucolors();
opt_idx = handle_add_list_remove("menucolor", nmc);
if (opt_idx == 3) { /* done */
menucolors_done:
menucolors_done:
if (nmc > 0 && !iflags.use_menu_color)
pline(
"To have menu colors become active, toggle 'menucolors' option to True.");
@@ -5139,15 +5138,18 @@ boolean setinitial, setfromfile;
}
} else if (!strcmp("autopickup_exception", optname)) {
int opt_idx, pass, totalapes = 0, numapes[2] = { 0, 0 };
char apebuf[1 + BUFSZ] = DUMMY; /* so &apebuf[1] is BUFSZ long for getlin() */
char apebuf[1 + BUFSZ]; /* so &apebuf[1] is BUFSZ long for getlin() */
struct autopickup_exception *ape;
ape_again:
ape_again:
totalapes = count_ape_maps(&numapes[AP_LEAVE], &numapes[AP_GRAB]);
opt_idx = handle_add_list_remove("autopickup exception", totalapes);
if (opt_idx == 3) { /* done */
return TRUE;
} else if (opt_idx == 0) { /* add new */
/* EDIT_GETLIN: assume user doesn't user want previous
exception used as default input string for this one... */
apebuf[0] = apebuf[1] = '\0';
getlin("What new autopickup exception pattern?", &apebuf[1]);
mungspaces(&apebuf[1]); /* regularize whitespace */
if (apebuf[1] == '\033')
@@ -5219,7 +5221,6 @@ boolean setinitial, setfromfile;
symset[which_set].name = (char *) 0;
res = read_sym_file(which_set);
/* put symset name back */
symset[which_set].name = symset_name;
@@ -5698,9 +5699,10 @@ char *buf;
#ifdef CURSES_GRAPHICS
} else if (!strcmp(optname,"windowborders")) {
Sprintf(buf, "%s",
iflags.wc2_windowborders == 1 ? "1=on" :
iflags.wc2_windowborders == 2 ? "2=off" :
iflags.wc2_windowborders == 3 ? "3=auto" : defopt);
(iflags.wc2_windowborders == 1) ? "1=on"
: (iflags.wc2_windowborders == 2) ? "2=off"
: (iflags.wc2_windowborders == 3) ? "3=auto"
: defopt);
#endif
} else if (!strcmp(optname, "windowtype")) {
Sprintf(buf, "%s", windowprocs.name);
@@ -5725,10 +5727,9 @@ char *buf;
#endif
}
if (buf[0])
return buf;
else
return "unknown";
if (!buf[0])
Strcpy(buf, "unknown");
return buf;
}
int
@@ -5807,13 +5808,12 @@ STATIC_OVL void
remove_autopickup_exception(whichape)
struct autopickup_exception *whichape;
{
struct autopickup_exception *ape, *prev = 0;
struct autopickup_exception *ape, *freeape, *prev = 0;
int chain = whichape->grab ? AP_GRAB : AP_LEAVE;
for (ape = iflags.autopickup_exceptions[chain]; ape;) {
if (ape == whichape) {
struct autopickup_exception *freeape = ape;
freeape = ape;
ape = ape->next;
if (prev)
prev->next = ape;
@@ -6006,7 +6006,8 @@ const char *strval;
/* data for option_help() */
static const char *opt_intro[] = {
"", " NetHack Options Help:", "",
"",
" NetHack Options Help:", "",
#define CONFIG_SLOT 3 /* fill in next value at run-time */
(char *) 0,
#if !defined(MICRO) && !defined(MAC)
@@ -6016,7 +6017,8 @@ static const char *opt_intro[] = {
#ifdef VMS
"-- for example, $ DEFINE NETHACKOPTIONS \"noautopickup,fruit:kumquat\"",
#endif
"or press \"O\" while playing and use the menu.", "",
"or press \"O\" while playing and use the menu.",
"",
"Boolean options (which can be negated by prefixing them with '!' or \"no\"):",
(char *) 0
};
@@ -6024,7 +6026,8 @@ static const char *opt_intro[] = {
static const char *opt_epilog[] = {
"",
"Some of the options can be set only before the game is started; those",
"items will not be selectable in the 'O' command's menu.", (char *) 0
"items will not be selectable in the 'O' command's menu.",
(char *) 0
};
void
@@ -6121,11 +6124,11 @@ struct fruit *replace_fruit;
{
register int i;
register struct fruit *f;
int highest_fruit_id = 0;
int highest_fruit_id = 0, globpfx;
char buf[PL_FSIZ], altname[PL_FSIZ];
boolean user_specified = (str == pl_fruit);
/* if not user-specified, then it's a fruit name for a fruit on
* a bones level...
* a bones level or from orctown raider's loot...
*/
/* Note: every fruit has an id (kept in obj->spe) of at least 1;
@@ -6136,39 +6139,54 @@ struct fruit *replace_fruit;
/* force fruit to be singular; this handling is not
needed--or wanted--for fruits from bones because
they already received it in their original game */
they already received it in their original game;
str==pl_fruit but makesingular() creates a copy
so we need to copy that back into pl_fruit */
nmcpy(pl_fruit, makesingular(str), PL_FSIZ);
/* (assertion doesn't matter; we use 'pl_fruit' from here on out) */
/* assert( str == pl_fruit ); */
/* disallow naming after other foods (since it'd be impossible
* to tell the difference)
* to tell the difference); globs might have a size prefix which
* needs to be skipped in order to match the object type name
*/
globpfx = (!strncmp(pl_fruit, "small ", 6)
|| !strncmp(pl_fruit, "large ", 6)) ? 6
: (!strncmp(pl_fruit, "very large ", 11)) ? 11
: 0;
for (i = bases[FOOD_CLASS]; objects[i].oc_class == FOOD_CLASS; i++) {
if (!strcmp(OBJ_NAME(objects[i]), pl_fruit)) {
if (!strcmp(OBJ_NAME(objects[i]), pl_fruit)
|| (globpfx > 0
&& !strcmp(OBJ_NAME(objects[i]), &pl_fruit[globpfx]))) {
found = TRUE;
break;
}
}
{
if (!found) {
char *c;
for (c = pl_fruit; *c >= '0' && *c <= '9'; c++)
continue;
if (isspace((uchar) *c) || *c == 0)
if (!*c || isspace((uchar) *c))
numeric = TRUE;
}
if (found || numeric
|| !strncmp(str, "cursed ", 7)
|| !strncmp(str, "uncursed ", 9)
|| !strncmp(str, "blessed ", 8)
|| !strncmp(str, "partly eaten ", 13)
|| (!strncmp(str, "tin of ", 7)
&& (!strcmp(str + 7, "spinach")
|| name_to_mon(str + 7) >= LOW_PM))
|| !strcmp(str, "empty tin")
|| ((str_end_is(str, " corpse")
|| str_end_is(str, " egg"))
&& name_to_mon(str) >= LOW_PM)) {
/* these checks for applying food attributes to actual items
are case sensitive; "glob of foo" is caught by 'found'
if 'foo' is a valid glob; when not valid, allow it as-is */
|| !strncmp(pl_fruit, "cursed ", 7)
|| !strncmp(pl_fruit, "uncursed ", 9)
|| !strncmp(pl_fruit, "blessed ", 8)
|| !strncmp(pl_fruit, "partly eaten ", 13)
|| (!strncmp(pl_fruit, "tin of ", 7)
&& (!strcmp(pl_fruit + 7, "spinach")
|| name_to_mon(pl_fruit + 7) >= LOW_PM))
|| !strcmp(pl_fruit, "empty tin")
|| (!strcmp(pl_fruit, "glob")
|| (globpfx > 0 && !strcmp("glob", &pl_fruit[globpfx])))
|| ((str_end_is(pl_fruit, " corpse")
|| str_end_is(pl_fruit, " egg"))
&& name_to_mon(pl_fruit) >= LOW_PM)) {
Strcpy(buf, pl_fruit);
Strcpy(pl_fruit, "candied ");
nmcpy(pl_fruit + 8, buf, PL_FSIZ - 8);
@@ -6186,11 +6204,11 @@ struct fruit *replace_fruit;
/* replace_fruit is already part of the fruit chain;
update it in place rather than looking it up again */
f = replace_fruit;
copynchars(f->fname, str, PL_FSIZ - 1);
copynchars(f->fname, pl_fruit, PL_FSIZ - 1);
goto nonew;
}
} else {
/* not user_supplied, so assumed to be from bones */
/* not user_supplied, so assumed to be from bones (or orc gang) */
copynchars(altname, str, PL_FSIZ - 1);
sanitize_name(altname);
flags.made_fruit = TRUE; /* for safety. Any fruit name added from a