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

Function root_plselection_prompt

src/role.c:1430–1580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1428}
1429
1430char *
1431root_plselection_prompt(
1432 char *suppliedbuf, int buflen,
1433 int rolenum, int racenum, int gendnum, int alignnum)
1434{
1435 int k, gendercount = 0, aligncount = 0;
1436 char buf[BUFSZ];
1437 static char err_ret[] = " character's";
1438 boolean donefirst = FALSE;
1439
1440 if (!suppliedbuf || buflen < 1)
1441 return err_ret;
1442
1443 /* initialize these static variables each time this is called */
1444 gr.role_post_attribs = 0;
1445 for (k = 0; k < NUM_BP; ++k)
1446 gr.role_pa[k] = 0;
1447 buf[0] = '\0';
1448 *suppliedbuf = '\0';
1449
1450 /* How many alignments are allowed for the desired race? */
1451 if (racenum != ROLE_NONE && racenum != ROLE_RANDOM)
1452 aligncount = race_alignmentcount(racenum);
1453
1454 if (alignnum != ROLE_NONE && alignnum != ROLE_RANDOM
1455 && ok_align(rolenum, racenum, gendnum, alignnum)) {
1456#if 0 /* 'if' and 'else' had duplicate code here; probably a copy+parse
1457 * oversight; if a problem with filtering of random role selection
1458 * crops up, this is probably the place to start looking */
1459
1460 /* if race specified, and multiple choice of alignments for it */
1461 if ((racenum >= 0) && (aligncount > 1)) {
1462 } else {
1463 }
1464#endif /* the four lines of code below were in both 'if' and 'else' above */
1465 if (donefirst)
1466 Strcat(buf, " ");
1467 Strcat(buf, aligns[alignnum].adj);
1468 donefirst = TRUE;
1469 } else {
1470 /* in case we got here by failing the ok_align() test */
1471 if (alignnum != ROLE_RANDOM)
1472 alignnum = ROLE_NONE;
1473 /* if alignment not specified, but race is specified
1474 and only one choice of alignment for that race then
1475 don't include it in the later list */
1476 if ((((racenum != ROLE_NONE && racenum != ROLE_RANDOM)
1477 && ok_race(rolenum, racenum, gendnum, alignnum))
1478 && (aligncount > 1))
1479 || (racenum == ROLE_NONE || racenum == ROLE_RANDOM)) {
1480 gr.role_pa[BP_ALIGN] = 1;
1481 gr.role_post_attribs++;
1482 }
1483 }
1484 /* <your lawful> */
1485
1486 /* How many genders are allowed for the desired role? */
1487 if (validrole(rolenum))

Callers 5

winmisc.cFile · 0.85
amii_player_selectionFunction · 0.85
build_plselection_promptFunction · 0.85

Calls 5

race_alignmentcountFunction · 0.85
ok_alignFunction · 0.85
ok_raceFunction · 0.85
validroleFunction · 0.85
role_gendercountFunction · 0.85

Tested by

no test coverage detected