UNIX, VMS, DEF_PAGER, MICRO and MFLOPPY globals moved to g.

This commit is contained in:
Bart House
2018-12-25 09:34:24 -08:00
parent 0763046c38
commit 16db7498d0
14 changed files with 108 additions and 109 deletions

View File

@@ -8,13 +8,6 @@
#define E extern
#if defined(UNIX) || defined(VMS)
E int locknum;
#endif
#ifdef DEF_PAGER
E char *catmore;
#endif /* DEF_PAGER */
E char SAVEF[];
#ifdef MICRO
E char SAVEP[];
@@ -704,6 +697,22 @@ struct instance_globals {
struct obj zeroobj; /* used to zero out a struct obj */
struct monst zeromonst; /* used to zero out a struct monst */
anything zeroany; /* used to zero out union any */
#if defined(UNIX) || defined(VMS)
int locknum; /* max num of simultaneous users */
#endif
#ifdef DEF_PAGER
char *catmore; /* default pager */
#endif
#ifdef MICRO
char levels[PATHLEN]; /* where levels are */
#endif /* MICRO */
#ifdef MFLOPPY
char permbones[PATHLEN]; /* where permanent copy of bones go */
int ramdisk = FALSE; /* whether to copy bones to levels or not */
int saveprompt = TRUE;
const char *alllevels = "levels.*";
const char *allbones = "bones*.*";
#endif
/* dig.c */

View File

@@ -7,11 +7,6 @@
#ifndef MICRO_H
#define MICRO_H
extern const char *alllevels, *allbones;
extern char levels[], bones[], permbones[], hackdir[];
extern int ramdisk;
#ifndef C
#define C(c) (0x1f & (c))
#endif

View File

@@ -6,12 +6,6 @@
#include "hack.h"
/* from xxxmain.c */
#if defined(UNIX) || defined(VMS)
int locknum = 0; /* max num of simultaneous users */
#endif
#ifdef DEF_PAGER
char *catmore = 0; /* default pager */
#endif
const char quitchars[] = " \r\n\033";
const char vowels[] = "aeiouAEIOU";
@@ -23,18 +17,6 @@ NEARDATA long yn_number = 0L;
const char disclosure_options[] = "iavgco";
#ifdef MICRO
char levels[PATHLEN]; /* where levels are */
#endif /* MICRO */
#ifdef MFLOPPY
char permbones[PATHLEN]; /* where permanent copy of bones go */
int ramdisk = FALSE; /* whether to copy bones to levels or not */
int saveprompt = TRUE;
const char *alllevels = "levels.*";
const char *allbones = "bones*.*";
#endif
NEARDATA struct sinfo program_state;
/* x/y/z deltas for the 10 movement directions (8 compass pts, 2 up/down) */
@@ -298,6 +280,22 @@ const struct instance_globals g_init = {
DUMMY, /* zeroobj */
DUMMY, /* zeromonst */
DUMMY, /* zeronay */
#if defined(UNIX) || defined(VMS)
0, /* locknum */
#endif
#ifdef DEF_PAGER
NULL, /* catmore */
#endif
#ifdef MICRO
UNDEFINED_VALUES, /* levels */
#endif /* MICRO */
#ifdef MFLOPPY
UNDEFINED_VALUES, /* permbones */
FALSE, /*ramdisk */
TRUE, /* saveprompt */
"levels.*", /* alllevels */
"bones*.*", /* allbones */
#endif
/* dig.c */
UNDEFINED_VALUE, /* did_dig_msg */

View File

@@ -433,20 +433,20 @@ int prefix;
void
set_lock_and_bones()
{
if (!ramdisk) {
Strcpy(levels, permbones);
Strcpy(bones, permbones);
if (!g.ramdisk) {
Strcpy(levels, g.permbones);
Strcpy(bones, g.permbones);
}
append_slash(permbones);
append_slash(levels);
append_slash(g.permbones);
append_slash(g.levels);
#ifdef AMIGA
strncat(levels, bbs_id, PATHLEN);
#endif
append_slash(bones);
Strcat(bones, "bonesnn.*");
Strcpy(lock, levels);
Strcpy(lock, g.levels);
#ifndef AMIGA
Strcat(lock, alllevels);
Strcat(lock, g.alllevels);
#endif
return;
}
@@ -581,9 +581,9 @@ clearlocks()
return;
#endif
#if !defined(PC_LOCKING) && defined(MFLOPPY) && !defined(AMIGA)
eraseall(levels, alllevels);
if (ramdisk)
eraseall(permbones, alllevels);
eraseall(levels, g.alllevels);
if (g.ramdisk)
eraseall(g.permbones, g.alllevels);
#else
{
register int x;
@@ -2323,34 +2323,31 @@ char *origbuf;
if (strlen(bufp) >= PATHLEN)
bufp[PATHLEN - 1] = '\0';
Strcpy(levels, bufp);
ramdisk = (strcmp(permbones, levels) != 0);
g.ramdisk = (strcmp(g.permbones, levels) != 0);
ramdisk_specified = TRUE;
#endif
#endif
} else if (match_varname(buf, "LEVELS", 4)) {
if (strlen(bufp) >= PATHLEN)
bufp[PATHLEN - 1] = '\0';
Strcpy(permbones, bufp);
Strcpy(g.permbones, bufp);
if (!ramdisk_specified || !*levels)
Strcpy(levels, bufp);
ramdisk = (strcmp(permbones, levels) != 0);
g.ramdisk = (strcmp(g.permbones, levels) != 0);
} else if (match_varname(buf, "SAVE", 4)) {
#ifdef MFLOPPY
extern int saveprompt;
#endif
char *ptr;
if ((ptr = index(bufp, ';')) != 0) {
*ptr = '\0';
#ifdef MFLOPPY
if (*(ptr + 1) == 'n' || *(ptr + 1) == 'N') {
saveprompt = FALSE;
g.g.saveprompt = FALSE;
}
#endif
}
#if defined(SYSFLAGS) && defined(MFLOPPY)
else
saveprompt = sysflags.asksavedisk;
g.g.g.saveprompt = sysflags.asksavedisk;
#endif
(void) strncpy(SAVEP, bufp, SAVESIZE - 1);

View File

@@ -762,15 +762,15 @@ xchar ltmp;
#ifdef AMIGA
clearlocks();
#else /* !AMIGA */
eraseall(levels, alllevels);
eraseall(levels, allbones);
eraseall(levels, g.alllevels);
eraseall(levels, g.allbones);
/* Perhaps the person would like to play without a
* RAMdisk.
*/
if (ramdisk) {
if (g.ramdisk) {
/* PlaywoRAMdisk may not return, but if it does
* it is certain that ramdisk will be 0.
* it is certain that g.ramdisk will be 0.
*/
playwoRAMdisk();
/* Rewind save file and try again */

View File

@@ -1419,8 +1419,8 @@ int lev;
{
char to[PATHLEN], from[PATHLEN];
Sprintf(from, "%s%s", permbones, alllevels);
Sprintf(to, "%s%s", levels, alllevels);
Sprintf(from, "%s%s", g.permbones, g.alllevels);
Sprintf(to, "%s%s", levels, g.alllevels);
set_levelfile_name(from, lev);
set_levelfile_name(to, lev);
if (iflags.checkspace) {
@@ -1445,7 +1445,7 @@ swapout_oldest()
int i, oldest;
long oldtime;
if (!ramdisk)
if (!g.ramdisk)
return FALSE;
for (i = 1, oldtime = 0, oldest = 0; i <= maxledgerno(); i++)
if (g.level_info[i].where == ACTIVE
@@ -1455,8 +1455,8 @@ swapout_oldest()
}
if (!oldest)
return FALSE;
Sprintf(from, "%s%s", levels, alllevels);
Sprintf(to, "%s%s", permbones, alllevels);
Sprintf(from, "%s%s", levels, g.alllevels);
Sprintf(to, "%s%s", g.permbones, g.alllevels);
set_levelfile_name(from, oldest);
set_levelfile_name(to, oldest);
if (wizard) {

View File

@@ -211,7 +211,7 @@ const char *path, *files;
struct FileInfoBlock *fibp;
int chklen;
#ifdef BETA
if(files != alllevels)panic("eraseall");
if(files != g.alllevels)panic("eraseall");
#endif
chklen=(int)index(files,'*')-(int)files;

View File

@@ -628,7 +628,7 @@ char *argv[];
/* Player doesn't want to use a RAM disk
*/
case 'R':
ramdisk = FALSE;
g.ramdisk = FALSE;
break;
#endif
#endif

View File

@@ -167,18 +167,18 @@ int mode;
char copy[8], *comspec;
#endif
if (!ramdisk)
if (!g.ramdisk)
return;
/* Find the name of the last file to be transferred
*/
frompath = (mode != TOPERM) ? permbones : levels;
frompath = (mode != TOPERM) ? g.permbones : g.levels;
foundfile = foundfile_buffer();
last[0] = '\0';
Sprintf(from, "%s%s", frompath, allbones);
topath = (mode == TOPERM) ? permbones : levels;
Sprintf(from, "%s%s", frompath, g.allbones);
topath = (mode == TOPERM) ? g.permbones : g.levels;
#ifdef TOS
eraseall(topath, allbones);
eraseall(topath, g.allbones);
#endif
if (findfirst(from))
do {
@@ -199,10 +199,10 @@ int mode;
/* Remove any bones files in `to' directory.
*/
eraseall(topath, allbones);
eraseall(topath, g.allbones);
/* Copy `from' to `to' */
Sprintf(to, "%s%s", topath, allbones);
Sprintf(to, "%s%s", topath, g.allbones);
comspec = getcomspec();
status = spawnl(P_WAIT, comspec, comspec, copy, from, to, "> nul",
(char *) 0);
@@ -216,7 +216,7 @@ int mode;
Sprintf(to, "%s%s", topath, last);
if (findfirst(to)) {
if (mode == TOPERM)
eraseall(frompath, allbones);
eraseall(frompath, g.allbones);
return;
}
@@ -225,7 +225,7 @@ error_copying:
#endif
/* Last file didn't get there.
*/
Sprintf(to, "%s%s", topath, allbones);
Sprintf(to, "%s%s", topath, g.allbones);
msmsg("Can't copy \"%s\" to \"%s\" -- ", from, to);
#ifndef TOS
if (status < 0)
@@ -236,10 +236,10 @@ error_copying:
? "insufficient disk space."
: "bad path(s)?");
if (mode == TOPERM) {
msmsg("Bones will be left in \"%s\"\n", *levels ? levels : hackdir);
msmsg("Bones will be left in \"%s\"\n", *g.levels ? g.levels : hackdir);
} else {
/* Remove all bones files on the RAMdisk */
eraseall(levels, allbones);
eraseall(g.levels, g.allbones);
playwoRAMdisk();
}
return;
@@ -252,10 +252,10 @@ playwoRAMdisk()
msmsg("Do you wish to play without a RAMdisk? [yn] (n)");
/* Set ramdisk false *before* exit-ing (because msexit calls
/* Set g.ramdisk false *before* exit-ing (because msexit calls
* copybones)
*/
ramdisk = FALSE;
g.ramdisk = FALSE;
c = tgetch();
if (c == 'Y')
c = 'y';
@@ -504,7 +504,7 @@ msexit()
enable_ctrlP(); /* in case this wasn't done */
#endif
#ifdef MFLOPPY
if (ramdisk)
if (g.ramdisk)
copybones(TOPERM);
#endif
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)

View File

@@ -209,9 +209,9 @@ char *argv[];
#endif
#ifdef DEF_PAGER
if (!(catmore = nh_getenv("HACKPAGER"))
&& !(catmore = nh_getenv("PAGER")))
catmore = DEF_PAGER;
if (!(g.catmore = nh_getenv("HACKPAGER"))
&& !(g.catmore = nh_getenv("PAGER")))
g.catmore = DEF_PAGER;
#endif
#ifdef MAIL
getmailstatus();
@@ -241,7 +241,7 @@ char *argv[];
if (wizard) {
/* use character name rather than lock letter for file names */
locknum = 0;
g.lockum = 0;
} else {
/* suppress interrupts while processing lock file */
(void) signal(SIGQUIT, SIG_IGN);
@@ -266,14 +266,14 @@ attempt_restore:
/*
* getlock() complains and quits if there is already a game
* in progress for current character name (when locknum == 0)
* or if there are too many active games (when locknum > 0).
* in progress for current character name (when g.lockum == 0)
* or if there are too many active games (when g.lockum > 0).
* When proceeding, it creates an empty <lockname>.0 file to
* designate the current game.
* getlock() constructs <lockname> based on the character
* name (for !locknum) or on first available of alock, block,
* name (for !g.lockum) or on first available of alock, block,
* clock, &c not currently in use in the playground directory
* (for locknum > 0).
* (for g.lockum > 0).
*/
if (*g.plname) {
getlock();
@@ -327,7 +327,7 @@ attempt_restore:
if locking alphabetically, the existing lock file
can still be used; otherwise, discard current one
and create another for the new character name */
if (!locknum) {
if (!g.lockum) {
delete_levelfile(0); /* remove empty lock file */
getlock();
}
@@ -452,17 +452,17 @@ char *argv[];
#else
/* XXX This is deprecated in favor of SYSCF with MAXPLAYERS */
if (argc > 1)
locknum = atoi(argv[1]);
g.lockum = atoi(argv[1]);
#endif
#ifdef MAX_NR_OF_PLAYERS
/* limit to compile-time limit */
if (!locknum || locknum > MAX_NR_OF_PLAYERS)
locknum = MAX_NR_OF_PLAYERS;
if (!g.lockum || g.lockum > MAX_NR_OF_PLAYERS)
g.lockum = MAX_NR_OF_PLAYERS;
#endif
#ifdef SYSCF
/* let syscf override compile-time limit */
if (!locknum || (sysopt.maxplayers && locknum > sysopt.maxplayers))
locknum = sysopt.maxplayers;
if (!g.lockum || (sysopt.maxplayers && g.lockum > sysopt.maxplayers))
g.lockum = sysopt.maxplayers;
#endif
}

View File

@@ -119,15 +119,15 @@ getlock()
/* default value of lock[] is "1lock" where '1' gets changed to
'a','b',&c below; override the default and use <uid><charname>
if we aren't restricting the number of simultaneous games */
if (!locknum)
if (!g.lockum)
Sprintf(lock, "%u%s", (unsigned) getuid(), g.plname);
regularize(lock);
set_levelfile_name(lock, 0);
if (locknum) {
if (locknum > 25)
locknum = 25;
if (g.lockum) {
if (g.lockum > 25)
g.lockum = 25;
do {
lock[0] = 'a' + i++;
@@ -145,7 +145,7 @@ getlock()
if (veryold(fd) && eraseoldlocks())
goto gotlock;
(void) close(fd);
} while (i < locknum);
} while (i < g.lockum);
unlock_file(HLOCK);
error("Too many hacks running now.");

View File

@@ -141,7 +141,7 @@ char *argv[];
if (wizard) {
/* use character name rather than lock letter for file names */
locknum = 0;
g.lockum = 0;
} else {
/* suppress interrupts while processing lock file */
(void) signal(SIGQUIT, SIG_IGN);
@@ -149,14 +149,14 @@ char *argv[];
}
/*
* getlock() complains and quits if there is already a game
* in progress for current character name (when locknum == 0)
* or if there are too many active games (when locknum > 0).
* in progress for current character name (when g.lockum == 0)
* or if there are too many active games (when g.lockum > 0).
* When proceeding, it creates an empty <lockname>.0 file to
* designate the current game.
* getlock() constructs <lockname> based on the character
* name (for !locknum) or on first available of alock, block,
* name (for !g.lockum) or on first available of alock, block,
* clock, &c not currently in use in the playground directory
* (for locknum > 0).
* (for g.lockum > 0).
*/
getlock();
@@ -212,7 +212,7 @@ attempt_restore:
if locking alphabetically, the existing lock file
can still be used; otherwise, discard current one
and create another for the new character name */
if (!locknum) {
if (!g.lockum) {
delete_levelfile(0); /* remove empty lock file */
getlock();
}
@@ -315,10 +315,10 @@ char *argv[];
}
if (argc > 1)
locknum = atoi(argv[1]);
g.lockum = atoi(argv[1]);
#ifdef MAX_NR_OF_PLAYERS
if (!locknum || locknum > MAX_NR_OF_PLAYERS)
locknum = MAX_NR_OF_PLAYERS;
if (!g.lockum || g.lockum > MAX_NR_OF_PLAYERS)
g.lockum = MAX_NR_OF_PLAYERS;
#endif
}

View File

@@ -109,16 +109,16 @@ getlock()
/* default value of lock[] is "1lock" where '1' gets changed to
'a','b',&c below; override the default and use <uid><charname>
if we aren't restricting the number of simultaneous games */
if (!locknum)
if (!g.lockum)
Sprintf(lock, "_%u%s", (unsigned) getuid(), plname);
regularize(lock);
set_levelfile_name(lock, 0);
if (locknum > 25)
locknum = 25;
if (g.lockum > 25)
g.lockum = 25;
do {
if (locknum)
if (g.lockum)
lock[0] = 'a' + i++;
if ((fd = open(lock, 0, 0)) == -1) {
@@ -132,10 +132,10 @@ getlock()
if (veryold(fd)) /* if true, this closes fd and unlinks lock */
goto gotlock;
(void) close(fd);
} while (i < locknum);
} while (i < g.lockum);
unlock_file(HLOCK);
error(locknum ? "Too many hacks running now."
error(g.lockum ? "Too many hacks running now."
: "There is a game in progress under your name.");
gotlock:

View File

@@ -2722,9 +2722,9 @@ boolean complain;
if (complain)
raw_printf("Cannot open %s as stdin.", fname);
} else {
(void) execlp(catmore, "page", (char *) 0);
(void) execlp(g.catmore, "page", (char *) 0);
if (complain)
raw_printf("Cannot exec %s.", catmore);
raw_printf("Cannot exec %s.", g.catmore);
}
if (complain)
sleep(10); /* want to wait_synch() but stdin is gone */