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

Function condopt

src/botl.c:1302–1329  ·  view source on GitHub ↗

deal with player's choice to change processing of a condition */

Source from the content-addressed store, hash-verified

1300
1301/* deal with player's choice to change processing of a condition */
1302void
1303condopt(int idx, boolean *addr, boolean negated)
1304{
1305 int i;
1306
1307 /* sanity check */
1308 if ((idx < 0 || idx >= CONDITION_COUNT)
1309 || (addr && addr != &condtests[idx].choice))
1310 return;
1311
1312 if (!addr) {
1313 /* special: indicates a request to init so
1314 set the choice values to match the defaults */
1315 gc.condmenu_sortorder = 0;
1316 for (i = 0; i < CONDITION_COUNT; ++i) {
1317 cond_idx[i] = i;
1318 condtests[i].choice = condtests[i].enabled;
1319 }
1320 qsort((genericptr_t) cond_idx, CONDITION_COUNT,
1321 sizeof cond_idx[0], cond_cmp);
1322 } else {
1323 /* (addr == &condtests[idx].choice) */
1324 condtests[idx].enabled = negated ? FALSE : TRUE;
1325 condtests[idx].choice = condtests[idx].enabled;
1326 /* avoid lingering false positives if test is no longer run */
1327 condtests[idx].test = FALSE;
1328 }
1329}
1330
1331/* qsort callback routine for sorting the condition index */
1332staticfn int QSORTCALLBACK

Callers 2

pfxfn_cond_Function · 0.85
parse_cond_optionFunction · 0.85

Calls 1

qsortFunction · 0.85

Tested by

no test coverage detected