globals from files.c moved to instance globals.

This commit is contained in:
Bart House
2018-12-25 12:56:27 -08:00
parent b1ab64db43
commit c67f7e5122
15 changed files with 181 additions and 167 deletions

View File

@@ -279,7 +279,7 @@ saveDiskPrompt(start)
BPTR fileLock;
if (sysflags.asksavedisk) {
/* Don't prompt if you can find the save file */
if (fileLock = Lock(SAVEF, SHARED_LOCK)) {
if (fileLock = Lock(g.SAVEF, SHARED_LOCK)) {
UnLock(fileLock);
#if defined(TTY_GRAPHICS)
if (windowprocs.win_init_nhwindows
@@ -294,7 +294,7 @@ saveDiskPrompt(start)
return 1;
}
pline("If save file is on a SAVE disk, put that disk in now.");
if (strlen(SAVEF) > QBUFSZ - 25 - 22)
if (strlen(g.SAVEF) > QBUFSZ - 25 - 22)
panic("not enough buffer space for prompt");
/* THIS IS A HACK */
#if defined(TTY_GRAPHICS)
@@ -305,7 +305,7 @@ saveDiskPrompt(start)
#endif
#if defined(AMII_GRAPHICS)
if (windowprocs.win_init_nhwindows == amii_procs.win_init_nhwindows) {
getlind("File name ?", buf, SAVEF);
getlind("File name ?", buf, g.SAVEF);
clear_nhwindow(WIN_BASE);
}
#endif
@@ -314,11 +314,11 @@ saveDiskPrompt(start)
return 0;
/* Strip any whitespace. Also, if nothing was entered except
* whitespace, do not change the value of SAVEF.
* whitespace, do not change the value of g.SAVEF.
*/
for (bp = buf; *bp; bp++) {
if (!isspace(*bp)) {
strncpy(SAVEF, bp, PATHLEN);
strncpy(g.SAVEF, bp, PATHLEN);
break;
}
}

View File

@@ -88,7 +88,7 @@ attempt_restore:
if (yn("Do you want to keep the save file?") == 'n')
(void) delete_savefile();
else {
nh_compress(fqname(SAVEF, SAVEPREFIX, 0));
nh_compress(fqname(g.SAVEF, SAVEPREFIX, 0));
}
}
}

View File

@@ -102,7 +102,7 @@ attempt_restore:
if (yn("Do you want to keep the save file?") == 'n')
(void) delete_savefile();
else {
nh_compress(fqname(SAVEF, SAVEPREFIX, 0));
nh_compress(fqname(g.SAVEF, SAVEPREFIX, 0));
}
}
}
@@ -227,7 +227,7 @@ process_openfile(short src_vol, long src_dir, Str255 fName, OSType ftype)
Str255 save_f_p;
P2C(*(StringHandle) name, g.plname);
set_savefile_name(TRUE);
C2P(fqname(SAVEF, SAVEPREFIX, 0), save_f_p);
C2P(fqname(g.SAVEF, SAVEPREFIX, 0), save_f_p);
force_hdelete(theDirs.dataRefNum, theDirs.dataDirID,
save_f_p);

View File

@@ -489,7 +489,7 @@ attempt_restore:
if (yn("Do you want to keep the save file?") == 'n')
(void) delete_savefile();
else {
nh_compress(fqname(SAVEF, SAVEPREFIX, 0));
nh_compress(fqname(g.SAVEF, SAVEPREFIX, 0));
}
}
}

View File

@@ -285,7 +285,7 @@ int start;
clear_nhwindow(WIN_MESSAGE);
pline("If save file is on a save disk, insert that disk now.");
mark_synch();
Sprintf(qbuf, "File name (default \"%s\"%s) ?", SAVEF,
Sprintf(qbuf, "File name (default \"%s\"%s) ?", g.SAVEF,
start ? "" : ", <Esc> cancels save");
getlin(qbuf, buf);
clear_nhwindow(WIN_MESSAGE);
@@ -293,11 +293,11 @@ int start;
return 0;
/* Strip any whitespace. Also, if nothing was entered except
* whitespace, do not change the value of SAVEF.
* whitespace, do not change the value of g.SAVEF.
*/
for (bp = buf; *bp; bp++)
if (!isspace((uchar) *bp)) {
strncpy(SAVEF, bp, PATHLEN);
strncpy(g.SAVEF, bp, PATHLEN);
break;
}
}

View File

@@ -281,7 +281,7 @@ attempt_restore:
}
if (*g.plname && (fd = restore_saved_game()) >= 0) {
const char *fq_save = fqname(SAVEF, SAVEPREFIX, 1);
const char *fq_save = fqname(g.SAVEF, SAVEPREFIX, 1);
(void) chmod(fq_save, 0); /* disallow parallel restores */
#ifndef NO_SIGNAL

View File

@@ -176,7 +176,7 @@ char *argv[];
*/
attempt_restore:
if ((fd = restore_saved_game()) >= 0) {
const char *fq_save = fqname(SAVEF, SAVEPREFIX, 1);
const char *fq_save = fqname(g.SAVEF, SAVEPREFIX, 1);
(void) chmod(fq_save, 0); /* disallow parallel restores */
(void) signal(SIGINT, (SIG_RET_TYPE) done1);

View File

@@ -564,7 +564,7 @@ char ***outarray;
char *charname, wildcard[255 + 1], filename[255 + 1];
genericptr_t context = 0;
Strcpy(wildcard, savetemplate); /* plname_from_file overwrites SAVEF */
Strcpy(wildcard, savetemplate); /* plname_from_file overwrites g.SAVEF */
in.mbz = 0; /* class and type; leave them unspecified */
in.len = (unsigned short) strlen(wildcard);
in.adr = wildcard;

View File

@@ -301,7 +301,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
(void) fname_encode(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.", '%',
fnamebuf, encodedfnamebuf, BUFSZ);
Sprintf(lock, "%s", encodedfnamebuf);
Sprintf(g.lock, "%s", encodedfnamebuf);
/* regularize(lock); */ /* we encode now, rather than substitute */
getlock();
@@ -343,7 +343,7 @@ attempt_restore:
if (yn("Do you want to keep the save file?") == 'n')
(void) delete_savefile();
else {
nh_compress(fqname(SAVEF, SAVEPREFIX, 0));
nh_compress(fqname(g.SAVEF, SAVEPREFIX, 0));
}
}
}
@@ -755,14 +755,14 @@ eraseoldlocks()
*/
for (i = 1; i <= MAXDUNGEON * MAXLEVEL + 1; i++) {
/* try to remove all */
set_levelfile_name(lock, i);
(void) unlink(fqname(lock, LEVELPREFIX, 0));
set_levelfile_name(g.lock, i);
(void) unlink(fqname(g.lock, LEVELPREFIX, 0));
}
set_levelfile_name(lock, 0);
set_levelfile_name(g.lock, 0);
#ifdef HOLD_LOCKFILE_OPEN
really_close();
#endif
if (unlink(fqname(lock, LEVELPREFIX, 0)))
if (unlink(fqname(g.lock, LEVELPREFIX, 0)))
return 0; /* cannot remove it */
return (1); /* success! */
}
@@ -787,9 +787,9 @@ getlock()
}
/* regularize(lock); */ /* already done in pcmain */
Sprintf(tbuf, "%s", fqname(lock, LEVELPREFIX, 0));
set_levelfile_name(lock, 0);
fq_lock = fqname(lock, LEVELPREFIX, 1);
Sprintf(tbuf, "%s", fqname(g.lock, LEVELPREFIX, 0));
set_levelfile_name(g.lock, 0);
fq_lock = fqname(g.lock, LEVELPREFIX, 1);
if ((fd = open(fq_lock, 0)) == -1) {
if (errno == ENOENT)
goto gotlock; /* no such file */