]> granicus.if.org Git - nethack/commitdiff
add MAXPLAYERS to SYSCF (trunk only)
authorkeni <keni>
Mon, 7 Apr 2008 22:27:18 +0000 (22:27 +0000)
committerkeni <keni>
Mon, 7 Apr 2008 22:27:18 +0000 (22:27 +0000)
Add MAXPLAYERS to SYSCF config file; deprecate (but continue to support)
 MAX_NR_OF_PLAYERS in nethack.sh since it is trivially overridden in many
 (all?) cases and isn't useful for ports that don't use nethack.sh.

include/config.h
include/sys.h
src/files.c
src/sys.c
sys/unix/hints/macosx
sys/unix/nethack.sh
sys/unix/unixmain.c

index 9cc1baa102a66ae41602370612a70480d89306e0..bdcf023f57c6ddfdd816ed7e96ae2124c063b7e1 100644 (file)
  *             available in a global config space, with the compiled-in
  *             entries as defaults:
  *             WIZARD          ( a value of * allows anyone to be wizard)
+ *             MAXPLAYERS      (see MAX_NR_OF_PLAYERS above and nethack.sh)
+ *             SUPPORT         (how to get local support)(no default)
+ *             RECOVER         (how to recover a game at your site)(no default)
  *
  *             The following options select how the config space is stored:
  *             SYSCF_FILE      in the named file
 
 /*
  * If it is desirable to limit the number of people that can play Hack
- * simultaneously, define HACKDIR, SECURE and MAX_NR_OF_PLAYERS.
+ * simultaneously, define HACKDIR, SECURE and MAX_NR_OF_PLAYERS (or use
+ * MAXPLAYERS under SYSCF).
  * #define MAX_NR_OF_PLAYERS 6
  */
 #endif /* CHDIR */
index 61209f452f9b861bc7883c3765d057558e4e2be5..7ec3db55b4729823d0c198e05b63dff555a8a0fe 100644 (file)
@@ -13,6 +13,7 @@ struct sysopt {
        char *support;  /* local support contact */
        char *recover;  /* how to run recover - may be overridden by win port */
        char *wizards;
+       int   maxplayers;
 };
 E struct sysopt sysopt;
 
index bddfc2131195e374b425eb3dd7944c49a991cc88..41197214510122bedec897c9b24a8332bd2940ff 100644 (file)
@@ -2078,6 +2078,15 @@ int              src;
            if(sysopt.recover) free(sysopt.recover);
            sysopt.recover = alloc(strlen(bufp));
            (void) strcpy(sysopt.recover, bufp);
+       } else if ( (src==SET_IN_SYS) && match_varname(buf, "MAXPLAYERS", 10)) {
+           int temp = atoi(bufp);
+               /* XXX to get more than 25, need to rewrite all lock code */
+           if(temp > 0 && temp <= 25){
+                   sysopt.maxplayers = temp;
+           } else {
+               raw_printf("Illegal value in MAXPLAYERS.");
+               return 0;
+           }
 #endif
        } else if (match_varname(buf, "BOULDER", 3)) {
            (void) get_uchars(fp, buf, bufp, &iflags.bouldersym, TRUE,
index 3a950132c03b32fcddef72fe4e0ad4f98939f7b2..895c7343886b7ace47450b18f09f5616230dee55 100644 (file)
--- a/src/sys.c
+++ b/src/sys.c
@@ -14,5 +14,6 @@ sys_early_init(){
        /* replace use of WIZARD vs WIZARD_NAME vs KR1ED, by filling this in */
 #endif
        sysopt.wizards = NULL;
+       sysopt.maxplayers = 0;  /* XXX eventually replace MAX_NR_OF_PLAYERS */
 }
 
index 2b93c341f56509698e54b13c94b79f3ed2318565..c6778f4e5ed3bd47a2fee100ea3675240dd377e6 100644 (file)
@@ -18,8 +18,9 @@ HACKDIR=$(PREFIX)/nethackdir
 CC=gcc -W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN
 
 # XXX -g vs -O should go here, -I../include goes in the makefile
-CFLAGS=-g -I../include $(CFLAGS2)
+CFLAGS=-g -I../include $(CFLAGS2) $(CFLAGS3)
 CFLAGS2=-DNOCLIPPING -DNOMAIL -DNOTPARMDECL -DHACKDIR=\"$(HACKDIR)\"
+CFLAGS3=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
 
 WINSRC = $(WINTTYSRC)
 WINOBJ = $(WINTTYOBJ)
index ebf4ede75f19404d576d192e51764d7a146e58c2..3966fb63bc09bc665c202a56b7f5a91b00ee3996 100644 (file)
@@ -4,6 +4,7 @@
 HACKDIR=/usr/games/lib/nethackdir
 export HACKDIR
 HACK=$HACKDIR/nethack
+# NB: MAXNROFPLAYERS is deprecated in favor of MAXPLAYERS in SYSCF.
 MAXNROFPLAYERS=4
 
 # Since Nethack.ad is installed in HACKDIR, add it to XUSERFILESEARCHPATH
index fd0b27d0b0ab8beaffa54a7c3065ce90eeae29bd..773cda08fa4c44c33a21d8d2cf3603aaba4f67ac 100644 (file)
@@ -7,6 +7,7 @@
 #include "hack.h"
 #include "dlb.h"
 
+#include <ctype.h>
 #include <sys/stat.h>
 #include <signal.h>
 #include <pwd.h>
@@ -373,12 +374,20 @@ char *argv[];
                }
        }
 
+       /* XXX This is deprecated in favor of SYSCF with MAXPLAYERS.  Make
+        * an error in next release. */
        if(argc > 1)
                locknum = atoi(argv[1]);
 #ifdef MAX_NR_OF_PLAYERS
+               /* limit to compile-time limit */
        if(!locknum || locknum > MAX_NR_OF_PLAYERS)
                locknum = MAX_NR_OF_PLAYERS;
 #endif
+#ifdef SYSCF
+               /* let syscf override compile-time limit */
+       if(!locknum || (sysopt.maxplayers && locknum > sysopt.maxplayers))
+               locknum = sysopt.maxplayers;
+#endif
 }
 
 #ifdef CHDIR