]> granicus.if.org Git - nethack/commitdiff
Define for generic usernames which prompt for name
authorPasi Kallinen <paxed@alt.org>
Mon, 9 Mar 2015 16:42:53 +0000 (18:42 +0200)
committerPasi Kallinen <paxed@alt.org>
Tue, 17 Mar 2015 16:47:19 +0000 (18:47 +0200)
Instead of hard-coding the "play", "player", etc. usernames
which will prompt the user for their name, allow defining
the names in config.h

include/config.h
src/role.c

index d8b067fc75cd5ee545cc186bc65d6cbe9547fe45..930bd549c123be356f85cb35861d1b2a50f85718 100644 (file)
 #endif /* CHDIR */
 
 
+/* If GENERIC_USERNAMES is defined, and the user name is found
+ * in that list, prompt for username instead.
+ * A public server should probably disable this. */
+#define GENERIC_USERNAMES "play player game games nethack nethacker"
+
 
 /*
  * Section 3:  Definitions that may vary with system type.
index 59624c528cf584377a765a02a3fa0ebce79b517b..2e2cbabae666d6a5f6093be3c0fcad91db8f19e7 100644 (file)
@@ -1332,12 +1332,15 @@ plnamesuffix()
     char *sptr, *eptr;
     int i;
 
+#ifdef GENERIC_USERNAMES
     /* some generic user names will be ignored in favor of prompting */
     i = (int)strlen(plname);
-    if ((i >= 4 && !strncmpi(plname, "player", i)) ||      /* play[er] */
-           (i >= 4 && !strncmpi(plname, "games", i)) ||           /* game[s] */
-           (i >= 7 && !strncmpi(plname, "nethacker", i)))  /* nethack[er] */
+    eptr = GENERIC_USERNAMES;
+    sptr = strstri(eptr, plname);
+    if (sptr && ((sptr == eptr && (sptr[i] == ' ' || sptr[i] == '\0'))
+                || sptr[i] == ' ' || sptr[i] == '\0'))
        *plname = '\0'; /* call askname() */
+#endif
 
     do {
        if (!*plname) askname();        /* fill plname[] if necessary */