MCPcopy Index your code
hub / github.com/NetHack/NetHack / plnamesuffix

Function plnamesuffix

src/role.c:1664–1721  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1662#undef NUM_BP
1663
1664void
1665plnamesuffix(void)
1666{
1667 char *sptr, *eptr;
1668 int i;
1669
1670 /* some generic user names will be ignored in favor of prompting */
1671 if (sysopt.genericusers) {
1672 if (*sysopt.genericusers == '*') {
1673 svp.plname[0] = '\0';
1674 } else {
1675 /* need to ignore appended '-role-race-gender-alignment';
1676 'plnamelen' is non-zero when dealing with plname[] value that
1677 contains a username with dash(es) in it and is usually 0 */
1678 i = ((eptr = strchr(svp.plname + gp.plnamelen, '-')) != 0)
1679 ? (int) (eptr - svp.plname)
1680 : (int) Strlen(svp.plname);
1681 /* look for plname[] in the 'genericusers' space-separated list */
1682 if (findword(sysopt.genericusers, svp.plname, i, FALSE))
1683 /* it's generic; remove it so that askname() will be called */
1684 svp.plname[0] = '\0';
1685 }
1686 if (!svp.plname[0])
1687 gp.plnamelen = 0;
1688 }
1689
1690 do {
1691 if (!svp.plname[0]) {
1692 askname(); /* fill svp.plname[] if necessary, or set
1693 * defer_plname */
1694 gp.plnamelen = 0; /* plname[] might have -role-race-&c attached */
1695 }
1696
1697 /* Look for tokens delimited by '-' */
1698 sptr = svp.plname + gp.plnamelen;
1699 if ((eptr = strchr(sptr, '-')) != (char *) 0)
1700 *eptr++ = '\0';
1701 while (eptr) {
1702 /* Isolate the next token */
1703 sptr = eptr;
1704 if ((eptr = strchr(sptr, '-')) != (char *) 0)
1705 *eptr++ = '\0';
1706
1707 /* Try to match it to something */
1708 if ((i = str2role(sptr)) != ROLE_NONE)
1709 flags.initrole = i;
1710 else if ((i = str2race(sptr)) != ROLE_NONE)
1711 flags.initrace = i;
1712 else if ((i = str2gend(sptr)) != ROLE_NONE)
1713 flags.initgend = i;
1714 else if ((i = str2align(sptr)) != ROLE_NONE)
1715 flags.initalign = i;
1716 }
1717 } while (!svp.plname[0] && !iflags.defer_plname);
1718
1719 /* commas in the svp.plname confuse the record file, convert to spaces */
1720 (void) strNsubst(svp.plname, ",", " ", 0);
1721}

Callers 9

mainFunction · 0.85
libnhmain.cFile · 0.85
MAINFunction · 0.85
mainFunction · 0.85
pcmainFunction · 0.85
role_initFunction · 0.85
genl_player_setupFunction · 0.85
MAINFunction · 0.85
mainFunction · 0.85

Calls 6

findwordFunction · 0.85
str2roleFunction · 0.85
str2raceFunction · 0.85
str2gendFunction · 0.85
str2alignFunction · 0.85
strNsubstFunction · 0.85

Tested by

no test coverage detected