MCPcopy Create free account
hub / github.com/NetHack/NetHack / optfn_disclose

Function optfn_disclose

src/options.c:1441–1560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1439}
1440
1441staticfn int
1442optfn_disclose(
1443 int optidx, int req, boolean negated,
1444 char *opts, char *op)
1445{
1446 int i, idx, prefix_val;
1447 unsigned num;
1448
1449 if (req == do_init) {
1450 return optn_ok;
1451 }
1452 if (req == do_set) {
1453 /* things to disclose at end of game */
1454
1455 /*
1456 * The order that the end_disclose options are stored:
1457 * inventory, attribs, vanquished, genocided,
1458 * conduct, overview.
1459 * There is an array in flags:
1460 * end_disclose[NUM_DISCLOSURE_OPT];
1461 * with option settings for the each of the following:
1462 * iagvc [see disclosure_options in decl.c]:
1463 * Allowed setting values in that array are:
1464 * DISCLOSE_PROMPT_DEFAULT_YES ask with default answer yes
1465 * DISCLOSE_PROMPT_DEFAULT_NO ask with default answer no
1466 * DISCLOSE_YES_WITHOUT_PROMPT always disclose and don't ask
1467 * DISCLOSE_NO_WITHOUT_PROMPT never disclose and don't ask
1468 * DISCLOSE_PROMPT_DEFAULT_SPECIAL for 'vanq'/'genod' only...
1469 * DISCLOSE_SPECIAL_WITHOUT_PROMPT ...to set up sort order.
1470 *
1471 * Those setting values can be used in the option
1472 * string as a prefix to get the desired behavior.
1473 *
1474 * For backward compatibility, no prefix is required,
1475 * and the presence of a i,a,g,v, or c without a prefix
1476 * sets the corresponding value to DISCLOSE_YES_WITHOUT_PROMPT.
1477 */
1478
1479 op = string_for_opt(opts, TRUE);
1480 if (op != empty_optstr && negated) {
1481 bad_negation(allopt[optidx].name, TRUE);
1482 return optn_err;
1483 }
1484 /* "disclose" without a value means "all with prompting"
1485 and negated means "none without prompting" */
1486 if (op == empty_optstr || !strcmpi(op, "all")
1487 || !strcmpi(op, "none")) {
1488 if (op != empty_optstr && !strcmpi(op, "none"))
1489 negated = TRUE;
1490 for (num = 0; num < NUM_DISCLOSURE_OPTIONS; num++)
1491 flags.end_disclose[num] = negated
1492 ? DISCLOSE_NO_WITHOUT_PROMPT
1493 : DISCLOSE_PROMPT_DEFAULT_YES;
1494 return optn_ok;
1495 }
1496
1497 num = 0;
1498 prefix_val = -1;

Callers

nothing calls this directly

Calls 7

string_for_optFunction · 0.85
bad_negationFunction · 0.85
config_error_addFunction · 0.85
strkittenFunction · 0.85
handler_discloseFunction · 0.85
lowcFunction · 0.70
impossibleFunction · 0.70

Tested by

no test coverage detected