add MAXPLAYERS to SYSCF (trunk only)

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.
This commit is contained in:
keni
2008-04-07 22:27:18 +00:00
parent 47d1eea0dd
commit 97abafd41a
7 changed files with 28 additions and 2 deletions

View File

@@ -149,6 +149,9 @@
* 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
@@ -270,7 +273,8 @@
/*
* 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 */

View 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;

View 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,

View File

@@ -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 */
}

View 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)

View 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

View 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