>B1014 <Someone> [reported] change request - disclosure default

>
>	I'd like the default for "Would you like to see your <whatever>"
>	at the end of a game to be "y" instead of "n". I haven't asked
>	for full disclosure in order to have it skipped if I press the
>	space bar once too often by mistake.

This changes the way the flags.end_disclose array is used to
allow what this request is asking for.  It should be backward
compatible with previous "disclose" options.

The order that the end_disclore options are stored:
inventory, attribs, vanquished, genocided, conduct
There is an array in flags:
	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:
	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

Those setting values can be used in the option
string as a prefix to each disclosure option
to get the desired behaviour for that option.

For backward compatibility, no prefix is actually required,
and the presence of a i,a,g,v, or c without a prefix sets
the corresponding value to DISCLOSE_YES_WITHOUT_PROMPT;

The actual prefixes used are controlled by the following in flag.h:
#define DISCLOSE_PROMPT_DEFAULT_YES	'y'
#define DISCLOSE_PROMPT_DEFAULT_NO	'n'
#define DISCLOSE_YES_WITHOUT_PROMPT	'+'
#define DISCLOSE_NO_WITHOUT_PROMPT	'-'

As far as the docs go, I don't know if I've got the *roff
stuff right.   The TeX stuff looks okay when I converted it to .pdf.

This increments EDITLEVEL.  If that is a problem, I can
add a routine to restore.c to perform a conversion of the old
values in flags. Let me know.
This commit is contained in:
nethack.allison
2002-01-27 01:26:59 +00:00
parent df9092ccb5
commit 8389fb1f29
9 changed files with 287 additions and 67 deletions

View File

@@ -4,7 +4,7 @@
.ds vr "NetHack 3.3
.ds f0 "\*(vr
.ds f1
.ds f2 "January 22, 2002
.ds f2 "January 26, 2002
.mt
A Guide to the Mazes of Menace
(Guidebook for NetHack)
@@ -1646,13 +1646,41 @@ This option also sets up proper handling of graphics
characters for such terminals, so you should specify it when appropriate
even if you override the selections with your own graphics strings.
.lp disclose
Offer to disclose various information when the game ends (default all).
The possibilities are identifying your inventory ('i'),
disclosing your attributes ('a'), summarizing monsters that have been
vanquished ('v'), listing monster species that have been genocided ('g'),
and displaying your conduct ('c').
Controls options for disclosing various information when the game ends (defaults
to all possibilities being disclosed).
The possibilities are:
.sd
.si
i - disclose your inventory.
a - disclose your attributes.
v - summarizing monsters that have been vanquished.
g - listing monster species that have been genocided.
c - displaying your conduct.
.ei
.ed
Each disclosure possibility can optionally be preceded by a prefix which
let you refine how it behaves. Here are some of the prefixes:
.sd
.si
y - prompt you and default to yes on the prompt.
n - prompt you and default to no on the prompt.
+ - disclose it without prompting.
- - do not disclose it and do not prompt.
.ei
.ed
Note that the vanquished monsters list includes all monsters killed by
traps and each other as well as by you.
traps and each other as well as by you.(ex. ``disclose:yina+v-g-c'')
The example sets
.op inventory
to prompt and default to yes,
.op attributes
to prompt and default to no,
.op vanquished
to disclose without prompting,
.op genocided
to not disclose and not to prompt,
.op conduct
to not disclose and not to prompt.
.lp dogname
Name your starting dog (ex. ``dogname:Fang'').
Cannot be set with the `O' command.

View File

@@ -39,7 +39,7 @@
%.au
\author{Eric S. Raymond\\
(Extensively edited and expanded for 3.3)}
\date{January 22, 2002}
\date{January 26, 2002}
\maketitle
@@ -2067,13 +2067,39 @@ characters for such terminals, so you should specify it when appropriate
even if you override the selections with your own graphics strings.
%.lp
\item[\ib{disclose}]
Offer to disclose various information when the game ends (default all).
The possibilities are identifying your inventory (`{\tt i}'),
disclosing your attributes (`{\tt a}'), summarizing monsters that have been
vanquished (`{\tt v}'), listing monster species that have been
genocided (`{\tt g}'), and displaying your conduct (`{\tt c}').
Controls options for disclosing various information when the game ends (defaults
to all possibilities being disclosed).
The possibilities are:
%.sd
%.si
{\tt i} --- disclose your inventory.\\
{\tt a} --- disclose your attributes.\\
{\tt v} --- summarizing monsters that have been vanquished.\\
{\tt g} --- listing monster species that have been genocided.\\
{\tt c} --- displaying your conduct.
%.ei
%.ed
Each disclosure possibility can optionally be preceded by a prefix which
let you refine how it behaves. Here are some of the prefixes:
%.sd
%.si
{\tt y} --- prompt you and default to yes on the prompt.\\
{\tt n} --- prompt you and default to no on the prompt.\\
{\tt +} --- disclose it without prompting.\\
{\tt -} --- do not disclose it and do not prompt.
%.ei
%.ed
Note that the vanquished monsters list includes all monsters killed by
traps and each other as well as by you.
traps and each other as well as by you. (ex.\ ``{\tt disclose:yina+v-g-c}'')
The example sets {\it inventory\/} to {\it prompt\/} and default to {\it yes\/},
{\it attributes\/} to {\it prompt\/} and default to {\it no\/},
{\it vanquished\/} to {\it disclose without prompting\/},
{\it genocided\/} to {\it not disclose\/} and not to {\it prompt\/}, and
{\it conduct\/} to {\it not disclose\/} and not to {\it prompt\/}.
%.lp
\item[\ib{dogname}]
Name your starting dog (ex.\ ``{\tt dogname:Fang}'').

View File

@@ -507,6 +507,8 @@ add Jason Short's additional lenses use patch
add new Gnomish Mines levels from Kelly Bailey's patch
jousting by players wielding a lance while riding
can start game without a pet via pettype:none (Dylan O'Donnell)
allow disclose options to be more finally tuned, including being able
to specify the default response for being prompted
Platform- and/or Interface-Specific New Features

View File

@@ -162,6 +162,9 @@ E const char ynqchars[];
E const char ynaqchars[];
E const char ynNaqchars[];
E NEARDATA long yn_number;
E const char disclosure_options[];
E NEARDATA int smeq[];
E NEARDATA int doorindex;
E NEARDATA char *save_cm;

View File

@@ -100,7 +100,13 @@ struct flag {
int pickup_burden; /* maximum burden before prompt */
char inv_order[MAXOCLASSES];
char pickup_types[MAXOCLASSES];
char end_disclose[6]; /* disclose various info upon exit */
#define NUM_DISCLOSURE_OPTIONS 5
#define DISCLOSE_PROMPT_DEFAULT_YES 'y'
#define DISCLOSE_PROMPT_DEFAULT_NO 'n'
#define DISCLOSE_YES_WITHOUT_PROMPT '+'
#define DISCLOSE_NO_WITHOUT_PROMPT '-'
char end_disclose[NUM_DISCLOSURE_OPTIONS + 1]; /* disclose various info
upon exit */
char menu_style; /* User interface style setting */
#ifdef AMII_GRAPHICS
int numcols;

View File

@@ -13,7 +13,7 @@
* Incrementing EDITLEVEL can be used to force invalidation of old bones
* and save files.
*/
#define EDITLEVEL 2
#define EDITLEVEL 3
#define COPYRIGHT_BANNER_A \
"NetHack, Copyright 1985-2002"

View File

@@ -73,6 +73,8 @@ const char ynaqchars[] = "ynaq";
const char ynNaqchars[] = "yn#aq";
NEARDATA long yn_number = 0L;
const char disclosure_options[] = "iavgc";
#ifdef MICRO
char hackdir[PATHLEN]; /* where rumors, help, record are */
char levels[PATHLEN]; /* where levels are */

108
src/end.c
View File

@@ -40,8 +40,9 @@ STATIC_DCL void FDECL(sort_valuables, (struct valuable_data *,int));
STATIC_DCL void FDECL(add_artifact_score, (struct obj *));
STATIC_DCL void FDECL(display_artifact_score, (struct obj *,winid));
STATIC_DCL void FDECL(savelife, (int));
STATIC_DCL void NDECL(list_vanquished);
STATIC_DCL void NDECL(list_genocided);
STATIC_DCL void FDECL(list_vanquished, (int));
STATIC_DCL void FDECL(list_genocided, (int));
STATIC_DCL boolean FDECL(should_query_disclose_option, (int, int*));
#if defined(__BEOS__) || defined(MICRO) || defined(WIN32) || defined(OS2)
extern void FDECL(nethack_exit,(int));
@@ -286,6 +287,41 @@ panic VA_DECL(const char *, str)
done(PANICKED);
}
STATIC_OVL boolean
should_query_disclose_option(category, defquery)
int category;
int *defquery;
{
int idx;
char *dop = index(disclosure_options, category);
if (dop && defquery) {
idx = (dop - disclosure_options) / sizeof(char);
if (idx < 0 || idx > (NUM_DISCLOSURE_OPTIONS - 1)) {
impossible(
"should_query_disclose_option: bad disclosure index %d %c",
idx, category);
*defquery = DISCLOSE_PROMPT_DEFAULT_YES;
return TRUE;
}
if (flags.end_disclose[idx] == DISCLOSE_YES_WITHOUT_PROMPT) {
*defquery = 'q';
return FALSE;
} else if (flags.end_disclose[idx] == DISCLOSE_NO_WITHOUT_PROMPT) {
*defquery = 'q';
return FALSE;
} else if (flags.end_disclose[idx] == DISCLOSE_PROMPT_DEFAULT_YES) {
*defquery = 'y';
return TRUE;
} else if (flags.end_disclose[idx] == DISCLOSE_PROMPT_DEFAULT_NO) {
*defquery = 'n';
return TRUE;
}
}
if (defquery)impossible("should_query_disclose_option: bad category %c", category);
else impossible("should_query_disclose_option: null defquery");
return TRUE;
}
STATIC_OVL void
disclose(how,taken)
int how;
@@ -293,48 +329,44 @@ boolean taken;
{
char c;
char qbuf[QBUFSZ];
int defquery;
if (invent && !done_stopprint &&
(!flags.end_disclose[0] || index(flags.end_disclose, 'i'))) {
if(taken)
Sprintf(qbuf,"Do you want to see what you had when you %s?",
(how == QUIT) ? "quit" : "died");
else
Strcpy(qbuf,"Do you want your possessions identified?");
if ((c = yn_function(qbuf, ynqchars, 'y')) == 'y') {
/* New dump format by maartenj@cs.vu.nl */
struct obj *obj;
for (obj = invent; obj; obj = obj->nobj) {
makeknown(obj->otyp);
obj->known = obj->bknown = obj->dknown = obj->rknown = 1;
if (invent && !done_stopprint) {
if (should_query_disclose_option('i', &defquery)) {
if(taken)
Sprintf(qbuf,"Do you want to see what you had when you %s?",
(how == QUIT) ? "quit" : "died");
else
Strcpy(qbuf,"Do you want your possessions identified?");
if ((c = yn_function(qbuf, ynqchars, defquery)) == 'y') {
/* New dump format by maartenj@cs.vu.nl */
struct obj *obj;
for (obj = invent; obj; obj = obj->nobj) {
makeknown(obj->otyp);
obj->known = obj->bknown = obj->dknown = obj->rknown = 1;
}
(void) display_inventory((char *)0, TRUE);
container_contents(invent, TRUE, TRUE);
}
(void) display_inventory((char *)0, TRUE);
container_contents(invent, TRUE, TRUE);
if (c == 'q') done_stopprint++;
}
if (c == 'q') done_stopprint++;
}
if (!done_stopprint &&
(!flags.end_disclose[0] || index(flags.end_disclose, 'a'))) {
c = yn_function("Do you want to see your attributes?",ynqchars,'y');
if (!done_stopprint && should_query_disclose_option('a', &defquery)) {
c = yn_function("Do you want to see your attributes?",ynqchars, defquery);
if (c == 'y') enlightenment(how >= PANICKED ? 1 : 2); /* final */
if (c == 'q') done_stopprint++;
}
if (!done_stopprint &&
(!flags.end_disclose[0] || index(flags.end_disclose, 'v'))) {
list_vanquished();
}
if (!done_stopprint && should_query_disclose_option('v', &defquery))
list_vanquished(defquery);
if (!done_stopprint &&
(!flags.end_disclose[0] || index(flags.end_disclose, 'g'))) {
list_genocided();
}
if (!done_stopprint && should_query_disclose_option('g', &defquery))
list_genocided(defquery);
if (!done_stopprint &&
(!flags.end_disclose[0] || index(flags.end_disclose, 'c'))) {
c = yn_function("Do you want to see your conduct?",ynqchars,'y');
if (!done_stopprint && should_query_disclose_option('c', &defquery)) {
c = yn_function("Do you want to see your conduct?",ynqchars,defquery);
if (c == 'y') show_conduct(how >= PANICKED ? 1 : 2);
if (c == 'q') done_stopprint++;
}
@@ -896,7 +928,8 @@ int status;
}
STATIC_OVL void
list_vanquished()
list_vanquished(defquery)
int defquery;
{
register int i, lev;
int ntypes = 0, max_lev = 0, nkilled;
@@ -917,7 +950,7 @@ list_vanquished()
*/
if (ntypes != 0) {
c = yn_function("Do you want an account of creatures vanquished?",
ynqchars, 'n');
ynqchars, defquery);
if (c == 'q') done_stopprint++;
if (c == 'y') {
klwin = create_nhwindow(NHW_MENU);
@@ -980,7 +1013,8 @@ num_genocides()
}
STATIC_OVL void
list_genocided()
list_genocided(defquery)
int defquery;
{
register int i;
int ngenocided;
@@ -993,7 +1027,7 @@ list_genocided()
/* genocided species list */
if (ngenocided != 0) {
c = yn_function("Do you want a list of species genocided?",
ynqchars, 'n');
ynqchars, defquery);
if (c == 'q') done_stopprint++;
if (c == 'y') {
klwin = create_nhwindow(NHW_MENU);

View File

@@ -214,7 +214,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),
sizeof(flags.end_disclose) * 2,
SET_IN_GAME },
{ "dogname", "the name of your (first) dog (e.g., dogname:Fang)",
PL_PSIZ, DISP_IN_GAME },
@@ -499,6 +499,8 @@ initoptions()
flags.pickup_types[0] = '\0';
flags.pickup_burden = MOD_ENCUMBER;
for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++)
flags.end_disclose[i] = DISCLOSE_PROMPT_DEFAULT_NO;
switch_graphics(ASCII_GRAPHICS); /* set default characters */
#if defined(UNIX) && defined(TTY_GRAPHICS)
/*
@@ -1554,7 +1556,28 @@ goodfruit:
/* things to disclose at end of game */
if (match_optname(opts, "disclose", 4, TRUE)) {
flags.end_disclose[0] = '\0'; /* all */
/*
* The order that the end_disclore options are stored:
* inventory, attribs, vanquished, genocided, conduct
* There is an array in flags:
* 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:
* 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
*
* Those setting values can be used in the option
* string as a prefix to get the desired behaviour.
*
* For backward compatibility, no prefix is required,
* and the presence of a i,a,g,v, or c without a
* prefix sets the corresponding value to DISCLOSE_YES_WITHOUT_PROMPT;
*/
boolean badopt = FALSE;
int idx, prefix_val;
if (!(op = string_for_opt(opts, TRUE))) {
/* for backwards compatibility, "disclose" without a
* value means all (was inventory and attributes,
@@ -1562,7 +1585,11 @@ goodfruit:
* it means "none"
* (note "none" contains none of "iavkgc")
*/
if (negated) Strcpy(flags.end_disclose, "none");
for (num = 0; num < NUM_DISCLOSURE_OPTIONS; num++) {
if (negated)
flags.end_disclose[num] = DISCLOSE_NO_WITHOUT_PROMPT;
else flags.end_disclose[num] = DISCLOSE_PROMPT_DEFAULT_YES;
}
return;
}
if (negated) {
@@ -1570,16 +1597,37 @@ goodfruit:
return;
}
num = 0;
prefix_val = -1;
while (*op && num < sizeof flags.end_disclose - 1) {
register char c;
register char c, *dop;
char valid_settings[] = {
DISCLOSE_PROMPT_DEFAULT_YES,
DISCLOSE_PROMPT_DEFAULT_NO,
DISCLOSE_YES_WITHOUT_PROMPT,
DISCLOSE_NO_WITHOUT_PROMPT
};
c = lowc(*op);
if (c == 'k') c = 'v'; /* killed -> vanquished */
if (!index(flags.end_disclose, c)) {
flags.end_disclose[num++] = c;
flags.end_disclose[num] = '\0'; /* for index */
}
dop = index(disclosure_options, c);
if (dop) {
idx = dop - disclosure_options;
if (idx < 0 || idx > NUM_DISCLOSURE_OPTIONS - 1) {
impossible("bad disclosure index %d %c",
idx, c);
continue;
}
if (prefix_val != -1) {
flags.end_disclose[idx] = prefix_val;
prefix_val = -1;
} else
flags.end_disclose[idx] = DISCLOSE_YES_WITHOUT_PROMPT;
} else if (index(valid_settings, c)) {
prefix_val = c;
} else
badopt = TRUE;
op++;
}
if (badopt) badoption(opts);
return;
}
@@ -2188,7 +2236,7 @@ boolean setinitial,setfromfile;
char buf[BUFSZ];
boolean retval = FALSE;
/* Special handling of menustyle, pickup_burden, and pickup_types. */
/* Special handling of menustyle, pickup_burden, and pickup_types, disclose options. */
if (!strcmp("menustyle", optname)) {
const char *style_name;
menu_item *style_pick = (menu_item *)0;
@@ -2231,6 +2279,71 @@ boolean setinitial,setfromfile;
/* parseoptions will prompt for the list of types */
parseoptions(strcpy(buf, "pickup_types"), setinitial, setfromfile);
retval = TRUE;
} else if (!strcmp("disclose", optname)) {
int pick_cnt, pick_idx, opt_idx;
winid tmpwin;
menu_item *disclosure_category_pick = (menu_item *)0;
/*
* The order of disclose_names[]
* must correspond to disclosure_options in decl.h
*/
const char *disclosure_names[] = {
"inventory", "attributes", "vanquished", "genocides", "conduct"
};
int disc_cat[NUM_DISCLOSURE_OPTIONS];
const char *disclosure_name;
tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin);
for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) {
disclosure_name = disclosure_names[i];
any.a_int = i + 1;
add_menu(tmpwin, NO_GLYPH, &any, disclosure_options[i], 0,
ATR_NONE, disclosure_name, MENU_UNSELECTED);
disc_cat[i] = 0;
}
end_menu(tmpwin, "Change which disclosure options categories:");
if ((pick_cnt = select_menu(tmpwin, PICK_ANY, &disclosure_category_pick)) > 0) {
for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) {
opt_idx = disclosure_category_pick[pick_idx].item.a_int - 1;
disc_cat[opt_idx] = 1;
}
free((genericptr_t)disclosure_category_pick);
disclosure_category_pick = (menu_item *)0;
}
destroy_nhwindow(tmpwin);
for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) {
if (disc_cat[i]) {
char dbuf[BUFSZ];
menu_item *disclosure_option_pick = (menu_item *)0;
Sprintf(dbuf, "Disclosure options for %s:", disclosure_names[i]);
tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin);
any.a_char = DISCLOSE_NO_WITHOUT_PROMPT;
add_menu(tmpwin, NO_GLYPH, &any, 'a', 0,
ATR_NONE,"Never disclose and don't prompt", MENU_UNSELECTED);
any.a_void = 0;
any.a_char = DISCLOSE_YES_WITHOUT_PROMPT;
add_menu(tmpwin, NO_GLYPH, &any, 'b', 0,
ATR_NONE,"Always disclose and don't prompt", MENU_UNSELECTED);
any.a_void = 0;
any.a_char = DISCLOSE_PROMPT_DEFAULT_NO;
add_menu(tmpwin, NO_GLYPH, &any, 'c', 0,
ATR_NONE,"Prompt and default answer to \"No\"", MENU_UNSELECTED);
any.a_void = 0;
any.a_char = DISCLOSE_PROMPT_DEFAULT_YES;
add_menu(tmpwin, NO_GLYPH, &any, 'd', 0,
ATR_NONE,"Prompt and default answer to \"Yes\"", MENU_UNSELECTED);
end_menu(tmpwin, dbuf);
if (select_menu(tmpwin, PICK_ONE, &disclosure_option_pick) > 0) {
flags.end_disclose[i] = disclosure_option_pick->item.a_char;
free((genericptr_t)disclosure_option_pick);
}
destroy_nhwindow(tmpwin);
}
}
retval = TRUE;
}
return retval;
}
@@ -2248,9 +2361,7 @@ char *buf;
char ocl[MAXOCLASSES+1];
static const char none[] = "(none)", randomrole[] = "random",
to_be_done[] = "(to be done)";
#ifdef PREFIXES_IN_USE
int i;
#endif
buf[0] = '\0';
if (!strcmp(optname,"align"))
@@ -2260,9 +2371,17 @@ char *buf;
iflags.bouldersym : oc_syms[(int)objects[BOULDER].oc_class]);
else if (!strcmp(optname, "catname"))
Sprintf(buf, "%s", catname[0] ? catname : none );
else if (!strcmp(optname, "disclose"))
Sprintf(buf, "%s",
flags.end_disclose[0] ? flags.end_disclose : "all" );
else if (!strcmp(optname, "disclose")) {
boolean all = TRUE, dnone = TRUE;
for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) {
char topt[2];
topt[1] = '\0';
topt[0] = flags.end_disclose[i];
Strcat(buf, topt);
topt[0] = disclosure_options[i];
Strcat(buf, topt);
}
}
else if (!strcmp(optname, "dogname"))
Sprintf(buf, "%s", dogname[0] ? dogname : none );
else if (!strcmp(optname, "dungeon"))