]> granicus.if.org Git - nethack/commitdiff
Move generic usernames to sysconf
authorPasi Kallinen <paxed@alt.org>
Mon, 13 Jun 2016 08:01:05 +0000 (11:01 +0300)
committerPasi Kallinen <paxed@alt.org>
Mon, 13 Jun 2016 08:01:05 +0000 (11:01 +0300)
include/config.h
include/sys.h
src/files.c
src/role.c
src/sys.c
sys/unix/sysconf

index 47b2951cc9f316f2001c02cf30d296f812cb991e..9fc7dc6fed12dd68dadeedca7965b88ec7e5e93a 100644 (file)
  */
 #endif /* CHDIR */
 
-/* If GENERIC_USERNAMES is defined, and the player's username is found
- * in the list, prompt for character name instead of using username.
- * 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.
  *              For example, both schar and uchar should be short ints on
index d2989a84282f99f79be6a04da4c39b6e79dec4a8..bf652ede28eabdbfd78960bf811f0a3bd218d82c 100644 (file)
@@ -13,6 +13,7 @@ struct sysopt {
                                or "one or two" or "one, two, or three", &c */
     char *explorers;  /* like wizards, but for access to explore mode */
     char *shellers;   /* like wizards, for ! command (-DSHELL); also ^Z */
+    char *genericusers; /* usernames that prompt for user name */
     char *debugfiles; /* files to show debugplines in. '*' is all. */
     int env_dbgfl;    /*  1: debugfiles comes from getenv("DEBUGFILES")
                        *     so sysconf's DEBUGFILES shouldn't override it;
index 51a76f188673047063e74a91efaa299df4cfa5cc..646737dabb13244b0a42262215e4889728694cb7 100644 (file)
@@ -2263,6 +2263,9 @@ int src;
                 free((genericptr_t) sysopt.debugfiles);
             sysopt.debugfiles = dupstr(bufp);
         }
+    } else if (src == SET_IN_SYS && match_varname(buf, "GENERICUSERS", 12)) {
+        if (sysopt.genericusers) free(sysopt.genericusers);
+        sysopt.genericusers = dupstr(bufp);
     } else if (src == SET_IN_SYS && match_varname(buf, "SUPPORT", 7)) {
         if (sysopt.support)
             free((genericptr_t) sysopt.support);
index 3bee60d6171a619a763ac74c9b4bc8d2b6d58002..5a1a4ab56755ec7f79e873cf1837c18b550be477 100644 (file)
@@ -1700,18 +1700,17 @@ plnamesuffix()
     char *sptr, *eptr;
     int i;
 
-#ifdef GENERIC_USERNAMES
-    {
-        /* some generic user names will be ignored in favor of prompting */
-        const char *uptr = GENERIC_USERNAMES;
-
-        i = (int) strlen(plname);
-        if ((sptr = strstri(uptr, plname)) != 0
-            && (sptr == uptr || sptr[-1] == ' ')
-            && (sptr[i] == ' ' || sptr[i] == '\0'))
-            *plname = '\0'; /* call askname() */
+    /* some generic user names will be ignored in favor of prompting */
+    if (sysopt.genericusers) {
+       if (*sysopt.genericusers == '*') *plname = '\0';
+       else {
+           i = (int)strlen(plname);
+           if ((sptr = strstri(sysopt.genericusers, plname)) != 0
+               && (sptr == sysopt.genericusers || sptr[-1] == ' ')
+               && (sptr[i] == ' ' || sptr[i] == '\0'))
+               *plname = '\0'; /* call askname() */
+       }
     }
-#endif
 
     do {
         if (!*plname)
index c56e75feca6b9f1dee2a3b27107e4423b4ea78bd..deab17eb5ef82254bf138df689446ccf43aa0b56 100644 (file)
--- a/src/sys.c
+++ b/src/sys.c
@@ -35,6 +35,7 @@ sys_early_init()
     sysopt.env_dbgfl = 0; /* haven't checked getenv("DEBUGFILES") yet */
     sysopt.shellers = (char *) 0;
     sysopt.explorers = (char *) 0;
+    sysopt.genericusers = (char *) 0;
     sysopt.maxplayers = 0; /* XXX eventually replace MAX_NR_OF_PLAYERS */
 
     /* record file */
@@ -94,6 +95,9 @@ sysopt_release()
     if (sysopt.debugfiles)
         free((genericptr_t) sysopt.debugfiles),
         sysopt.debugfiles = (char *) 0;
+    if (sysopt.genericusers)
+        free((genericptr_t) sysopt.genericusers),
+        sysopt.genericusers = (char *) 0;
 #ifdef PANICTRACE
     if (sysopt.gdbpath)
         free((genericptr_t) sysopt.gdbpath), sysopt.gdbpath = (char *) 0;
index 85ab25bf741a06524eff8126ecfb12626cbd4a42..f7426f7857af72220e6fc859d1be3c5384b0b480 100644 (file)
@@ -30,6 +30,11 @@ EXPLORERS=*
 # Uses the same syntax as the WIZARDS and EXPLORERS options above.
 #SHELLERS=
 
+# If the user name is found in this list, prompt for username instead.
+# Uses the same syntax as the WIZARDS option above.
+# A public server should probably disable this.
+GENERICUSERS=play player game games nethack nethacker
+
 # Use the player name for matching WIZARDS, EXPLORERS and SHELLERS,
 # instead of the user's login name.
 #CHECK_PLNAME=1