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

Function generic_plname

win/Qt/qt_plsel.cpp:41–67  ·  view source on GitHub ↗

check whether plname[] is among the list of generic user names */

Source from the content-addressed store, hash-verified

39
40/* check whether plname[] is among the list of generic user names */
41static bool generic_plname()
42{
43 if (*svp.plname) {
44 const char *sptr, *p;
45 const char *genericusers = sysopt.genericusers;
46 int ln = (int) strlen(svp.plname);
47
48 if (!genericusers || !*genericusers)
49 genericusers = "player games";
50 else if (!strcmp(genericusers, "*")) /* "*" => always ask for name */
51 return true;
52
53 while ((sptr = strstri(genericusers, svp.plname)) != NULL) {
54 /* check for full word: start of list or following a space */
55 if ((sptr == genericusers || sptr[-1] == ' ')
56 /* and also preceding a space or at end of list */
57 && (sptr[ln] == ' ' || sptr[ln] == '\0'))
58 return true;
59 /* doesn't match full word, but maybe we got a false hit when
60 looking for "play" in list "player play" so keep going */
61 if ((p = strchr(sptr + 1, ' ')) == NULL)
62 break;
63 genericusers = p + 1;
64 }
65 }
66 return false;
67}
68
69namespace nethack_qt_ {
70

Callers 1

qt_plsel.cppFile · 0.85

Calls 1

strstriFunction · 0.85

Tested by

no test coverage detected