remove SYSFLAGS and MFLOPPY code

A check into github issue 364 confirmed that
ba6edbe5dc
had incorrectly updated the bwrite sizeof entry for sysflags.

The SYSFLAGS and MFLOPPY code is all in the outdated part of the tree, so just
remove it rather than re-correct it.

Closes #364
Closes #207
This commit is contained in:
nhmall
2020-07-05 08:50:13 -04:00
parent 84bba3f099
commit 5a437b336a
25 changed files with 63 additions and 881 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 allmain.c $NHDT-Date: 1584405115 2020/03/17 00:31:55 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.143 $ */
/* NetHack 3.6 allmain.c $NHDT-Date: 1593953342 2020/07/05 12:49:02 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.144 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -597,10 +597,6 @@ newgame()
{
int i;
#ifdef MFLOPPY
gameDiskPrompt();
#endif
g.context.botlx = TRUE;
g.context.ident = 1;
g.context.stethoscope_move = -1L;

View File

@@ -1,14 +1,10 @@
/* NetHack 3.6 bones.c $NHDT-Date: 1571363147 2019/10/18 01:45:47 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.76 $ */
/* NetHack 3.6 bones.c $NHDT-Date: 1593953344 2020/07/05 12:49:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.100 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985,1993. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#ifdef MFLOPPY
extern long bytes_counted;
#endif
static boolean FDECL(no_bones_level, (d_level *));
static void FDECL(goodfruit, (int));
static void FDECL(resetobjs, (struct obj *, BOOLEAN_P));
@@ -531,43 +527,6 @@ struct obj *corpse;
}
c = (char) (strlen(bonesid) + 1);
#ifdef MFLOPPY /* check whether there is room */
if (iflags.checkspace) {
int savemode = nhfp->mode;
nhfp->mode = COUNTING;
savelev(nhfp, ledger_no(&u.uz));
/* savelev() initializes bytes_counted to 0, so it must come
* first here even though it does not in the real save. the
* resulting extra bflush() at the end of savelev() may increase
* bytes_counted by a couple over what the real usage will be.
*
* note it is safe to call store_version() here only because
* bufon() is null for ZEROCOMP, which MFLOPPY uses -- otherwise
* this code would have to know the size of the version
* information itself.
*/
store_version(nhfp);
store_savefileinfo(nhfp);
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &c, sizeof c);
bwrite(nhfp->fd, (genericptr_t) bonesid, (unsigned) c); /* DD.nnn */
}
savefruitchn(nhfp);
if (nhfp->structlevel)
bflush(nhfp->fd);
if (bytes_counted > freediskspace(bones)) { /* not enough room */
if (wizard)
pline("Insufficient space to create bones file.");
close_nhfile(nhfp);
cancel_bonesfile();
return;
}
co_false(); /* make sure stuff before savelev() gets written */
nhfp->mode = savemode;
}
#endif /* MFLOPPY */
nhfp->mode = WRITING | FREEING;
store_version(nhfp);
store_savefileinfo(nhfp);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 decl.c $NHDT-Date: 1591017417 2020/06/01 13:16:57 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.213 $ */
/* NetHack 3.6 decl.c $NHDT-Date: 1593953345 2020/07/05 12:49:05 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.214 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2009. */
/* NetHack may be freely redistributed. See license for details. */
@@ -22,9 +22,6 @@ const schar zdir[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, -1 };
NEARDATA struct flag flags;
NEARDATA boolean has_strong_rngseed = FALSE;
#ifdef SYSFLAGS
NEARDATA struct sysflag sysflags;
#endif
NEARDATA struct instance_flags iflags;
NEARDATA struct you u;
NEARDATA time_t ubirthday;
@@ -349,13 +346,6 @@ const struct instance_globals g_init = {
#ifdef MICRO
UNDEFINED_VALUES, /* levels */
#endif /* MICRO */
#ifdef MFLOPPY
UNDEFINED_VALUES, /* permbones */
FALSE, /*ramdisk */
TRUE, /* saveprompt */
"levels.*", /* alllevels */
"bones*.*", /* allbones */
#endif
UNDEFINED_VALUES, /* program_state */
/* detect.c */
@@ -744,9 +734,6 @@ decl_globals_init()
g.subrooms = &g.rooms[MAXNROFROOMS + 1];
ZERO(flags);
#ifdef SYSFLAGS
ZERO(sysflags);
#endif
ZERO(iflags);
ZERO(u);
ZERO(ubirthday);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 do.c $NHDT-Date: 1588191740 2020/04/29 20:22:20 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.243 $ */
/* NetHack 3.6 do.c $NHDT-Date: 1593953347 2020/07/05 12:49:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.246 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1157,9 +1157,6 @@ currentlevel_rewrite()
{
NHFILE *nhfp;
char whynot[BUFSZ];
#ifdef MFLOPPY
int savemode;
#endif
/* since level change might be a bit slow, flush any buffered screen
* output (like "you fall through a trap door") */
@@ -1178,18 +1175,6 @@ currentlevel_rewrite()
return (NHFILE *) 0;
}
#ifdef MFLOPPY
savemode = nhfp->mode;
nhfp->mode = COUNTING;
if (!savelev(nhfp, ledger_no(&u.uz))) {
close_nhfile(nhfp);
delete_levelfile(ledger_no(&u.uz));
pline("NetHack is out of disk space for making levels!");
You("can save, quit, or continue playing.");
return -1;
}
nhfp->mode = savemode;
#endif
return nhfp;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 files.c $NHDT-Date: 1590263451 2020/05/23 19:50:51 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.314 $ */
/* NetHack 3.7 files.c $NHDT-Date: 1593953349 2020/07/05 12:49:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.315 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -492,30 +492,6 @@ NHFILE *nhfp;
/* ---------- BEGIN LEVEL FILE HANDLING ----------- */
#ifdef MFLOPPY
/* Set names for bones[] and lock[] */
void
set_lock_and_bones()
{
if (!g.ramdisk) {
Strcpy(levels, g.permbones);
Strcpy(g.bones, g.permbones);
}
append_slash(g.permbones);
append_slash(g.levels);
#ifdef AMIGA
strncat(levels, bbs_id, PATHLEN);
#endif
append_slash(g.bones);
Strcat(g.bones, "bonesnn.*");
Strcpy(g.lock, g.levels);
#ifndef AMIGA
Strcat(g.lock, g.alllevels);
#endif
return;
}
#endif /* MFLOPPY */
/* Construct a file name for a level-type file, which is of the form
* something.level (with any old level stripped off).
* This assumes there is space on the end of 'file' to append
@@ -598,11 +574,6 @@ char errbuf[];
*errbuf = '\0';
set_levelfile_name(g.lock, lev);
fq_lock = fqname(g.lock, LEVELPREFIX, 0);
#ifdef MFLOPPY
/* If not currently accessible, swap it in. */
if (g.level_info[lev].where != ACTIVE)
swapin_file(lev);
#endif
nhfp = new_nhfile();
if (nhfp) {
nhfp->mode = READING;
@@ -651,29 +622,21 @@ int lev;
void
clearlocks()
{
int x;
#ifdef HANGUPHANDLING
if (g.program_state.preserve_locks)
return;
#endif
#if !defined(PC_LOCKING) && defined(MFLOPPY) && !defined(AMIGA)
eraseall(levels, g.alllevels);
if (g.ramdisk)
eraseall(g.permbones, g.alllevels);
#else
{
register int x;
#ifndef NO_SIGNAL
(void) signal(SIGINT, SIG_IGN);
(void) signal(SIGINT, SIG_IGN);
#endif
#if defined(UNIX) || defined(VMS)
sethanguphandler((void FDECL((*), (int) )) SIG_IGN);
sethanguphandler((void FDECL((*), (int) )) SIG_IGN);
#endif
/* can't access maxledgerno() before dungeons are created -dlc */
for (x = (g.n_dgns ? maxledgerno() : 0); x >= 0; x--)
delete_levelfile(x); /* not all levels need be present */
}
#endif /* ?PC_LOCKING,&c */
/* can't access maxledgerno() before dungeons are created -dlc */
for (x = (g.n_dgns ? maxledgerno() : 0); x >= 0; x--)
delete_levelfile(x); /* not all levels need be present */
}
#if defined(SELECTSAVED)
@@ -847,19 +810,6 @@ char errbuf[];
return nhfp;
}
#ifdef MFLOPPY
/* remove partial bonesfile in process of creation */
void
cancel_bonesfile()
{
const char *tempname;
tempname = set_bonestemp_name();
tempname = fqname(tempname, BONESPREFIX, 0);
(void) unlink(tempname);
}
#endif /* MFLOPPY */
/* move completed bones file to proper name */
void
commit_bonesfile(lev)
@@ -1201,10 +1151,6 @@ restore_saved_game()
NHFILE *nhfp = (NHFILE *) 0;
set_savefile_name(TRUE);
#ifdef MFLOPPY
if (!saveDiskPrompt(1))
return -1;
#endif /* MFLOPPY */
fq_save = fqname(g.SAVEF, SAVEPREFIX, 0);
nh_uncompress(fq_save);
@@ -2087,10 +2033,6 @@ const char *fname;
configfile[sizeof configfile - 1] = '\0';
}
#ifndef MFLOPPY
#define fopenp fopen
#endif
static FILE *
fopen_config_file(filename, src)
const char *filename;
@@ -2106,7 +2048,7 @@ int src;
/* SYSCF_FILE; if we can't open it, caller will bail */
if (filename && *filename) {
set_configfile_name(fqname(filename, SYSCONFPREFIX, 0));
fp = fopenp(configfile, "r");
fp = fopen(configfile, "r");
} else
fp = (FILE *) 0;
return fp;
@@ -2130,7 +2072,7 @@ int src;
/* fall through to standard names */
} else
#endif
if ((fp = fopenp(configfile, "r")) != (FILE *) 0) {
if ((fp = fopen(configfile, "r")) != (FILE *) 0) {
return fp;
#if defined(UNIX) || defined(VMS)
} else {
@@ -2145,20 +2087,20 @@ int src;
#if defined(MICRO) || defined(MAC) || defined(__BEOS__) || defined(WIN32)
set_configfile_name(fqname(default_configfile, CONFIGPREFIX, 0));
if ((fp = fopenp(configfile, "r")) != (FILE *) 0) {
if ((fp = fopen(configfile, "r")) != (FILE *) 0) {
return fp;
} else if (strcmp(default_configfile, configfile)) {
set_configfile_name(default_configfile);
if ((fp = fopenp(configfile, "r")) != (FILE *) 0)
if ((fp = fopen(configfile, "r")) != (FILE *) 0)
return fp;
}
#ifdef MSDOS
set_configfile_name(fqname(backward_compat_configfile, CONFIGPREFIX, 0));
if ((fp = fopenp(configfile, "r")) != (FILE *) 0) {
if ((fp = fopen(configfile, "r")) != (FILE *) 0) {
return fp;
} else if (strcmp(backward_compat_configfile, configfile)) {
set_configfile_name(backward_compat_configfile);
if ((fp = fopenp(configfile, "r")) != (FILE *) 0)
if ((fp = fopen(configfile, "r")) != (FILE *) 0)
return fp;
}
#endif
@@ -2167,10 +2109,10 @@ int src;
#ifdef VMS
/* no punctuation, so might be a logical name */
set_configfile_name("nethackini");
if ((fp = fopenp(configfile, "r")) != (FILE *) 0)
if ((fp = fopen(configfile, "r")) != (FILE *) 0)
return fp;
set_configfile_name("sys$login:nethack.ini");
if ((fp = fopenp(configfile, "r")) != (FILE *) 0)
if ((fp = fopen(configfile, "r")) != (FILE *) 0)
return fp;
envp = nh_getenv("HOME");
@@ -2181,7 +2123,7 @@ int src;
!index(":]>/", envp[strlen(envp) - 1]) ? "/" : "",
"NetHack.cnf");
set_configfile_name(tmp_config);
if ((fp = fopenp(configfile, "r")) != (FILE *) 0)
if ((fp = fopen(configfile, "r")) != (FILE *) 0)
return fp;
#else /* should be only UNIX left */
envp = nh_getenv("HOME");
@@ -2191,7 +2133,7 @@ int src;
Sprintf(tmp_config, "%s/%s", envp, ".nethackrc");
set_configfile_name(tmp_config);
if ((fp = fopenp(configfile, "r")) != (FILE *) 0)
if ((fp = fopen(configfile, "r")) != (FILE *) 0)
return fp;
#if defined(__APPLE__) /* UNIX+__APPLE__ => MacOSX */
/* try an alternative */
@@ -2200,13 +2142,13 @@ int src;
Sprintf(tmp_config, "%s/%s", envp,
"Library/Preferences/NetHack Defaults");
set_configfile_name(tmp_config);
if ((fp = fopenp(configfile, "r")) != (FILE *) 0)
if ((fp = fopen(configfile, "r")) != (FILE *) 0)
return fp;
/* may be easier for user to edit if filename has '.txt' suffix */
Sprintf(tmp_config, "%s/%s", envp,
"Library/Preferences/NetHack Defaults.txt");
set_configfile_name(tmp_config);
if ((fp = fopenp(configfile, "r")) != (FILE *) 0)
if ((fp = fopen(configfile, "r")) != (FILE *) 0)
return fp;
}
#endif /*__APPLE__*/
@@ -2507,19 +2449,6 @@ char *origbuf;
#ifdef MICRO
} else if (match_varname(buf, "HACKDIR", 4)) {
(void) strncpy(g.hackdir, bufp, PATHLEN - 1);
#ifdef MFLOPPY
} else if (match_varname(buf, "RAMDISK", 3)) {
/* The following ifdef is NOT in the wrong
* place. For now, we accept and silently
* ignore RAMDISK */
#ifndef AMIGA
if (strlen(bufp) >= PATHLEN)
bufp[PATHLEN - 1] = '\0';
Strcpy(levels, bufp);
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';
@@ -2532,16 +2461,7 @@ char *origbuf;
if ((ptr = index(bufp, ';')) != 0) {
*ptr = '\0';
#ifdef MFLOPPY
if (*(ptr + 1) == 'n' || *(ptr + 1) == 'N') {
g.saveprompt = FALSE;
}
#endif
}
#if defined(SYSFLAGS) && defined(MFLOPPY)
else
g.saveprompt = sysflags.asksavedisk;
#endif
(void) strncpy(g.SAVEP, bufp, SAVESIZE - 1);
append_slash(g.SAVEP);
@@ -2788,17 +2708,6 @@ char *origbuf;
int val = atoi(bufp);
amii_numcolors = 1L << min(DEPTH, val);
#ifdef SYSFLAGS
} else if (match_varname(buf, "DRIPENS", 7)) {
int i, val;
char *t;
for (i = 0, t = strtok(bufp, ",/"); t != (char *) 0;
i < 20 && (t = strtok((char *) 0, ",/")), ++i) {
sscanf(t, "%d", &val);
sysflags.amii_dripens[i] = val;
}
#endif
} else if (match_varname(buf, "SCREENMODE", 10)) {
extern long amii_scrnmode;
@@ -3103,7 +3012,7 @@ fopen_wizkit_file()
/* fall through to standard names */
} else
#endif
if ((fp = fopenp(g.wizkit, "r")) != (FILE *) 0) {
if ((fp = fopen(g.wizkit, "r")) != (FILE *) 0) {
return fp;
#if defined(UNIX) || defined(VMS)
} else {
@@ -3115,7 +3024,7 @@ fopen_wizkit_file()
}
#if defined(MICRO) || defined(MAC) || defined(__BEOS__) || defined(WIN32)
if ((fp = fopenp(fqname(g.wizkit, CONFIGPREFIX, 0), "r")) != (FILE *) 0)
if ((fp = fopen(fqname(g.wizkit, CONFIGPREFIX, 0), "r")) != (FILE *) 0)
return fp;
#else
#ifdef VMS
@@ -3124,7 +3033,7 @@ fopen_wizkit_file()
Sprintf(tmp_wizkit, "%s%s", envp, g.wizkit);
else
Sprintf(tmp_wizkit, "%s%s", "sys$login:", g.wizkit);
if ((fp = fopenp(tmp_wizkit, "r")) != (FILE *) 0)
if ((fp = fopen(tmp_wizkit, "r")) != (FILE *) 0)
return fp;
#else /* should be only UNIX left */
envp = nh_getenv("HOME");
@@ -3132,7 +3041,7 @@ fopen_wizkit_file()
Sprintf(tmp_wizkit, "%s/%s", envp, g.wizkit);
else
Strcpy(tmp_wizkit, g.wizkit);
if ((fp = fopenp(tmp_wizkit, "r")) != (FILE *) 0)
if ((fp = fopen(tmp_wizkit, "r")) != (FILE *) 0)
return fp;
else if (errno != ENOENT) {
/* e.g., problems when setuid NetHack can't search home
@@ -3728,7 +3637,7 @@ const char *dir UNUSED_if_not_OS2_CODEVIEW;
char tmp[PATHLEN];
#ifdef OS2_CODEVIEW /* explicit path on opening for OS/2 */
/* how does this work when there isn't an explicit path or fopenp
/* how does this work when there isn't an explicit path or fopen
* for later access to the file via fopen_datafile? ? */
(void) strncpy(tmp, dir, PATHLEN - 1);
tmp[PATHLEN - 1] = '\0';

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 mdlib.c $NHDT-Date: 1575161954 2019/12/01 00:59:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.6 $ */
/* NetHack 3.7 mdlib.c $NHDT-Date: 1593953352 2020/07/05 12:49:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.9 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. */
/* Copyright (c) M. Stephenson, 1990, 1991. */
@@ -228,13 +228,8 @@ make_version()
| ((unsigned long) sizeof(struct obj) << 17)
| ((unsigned long) sizeof(struct monst) << 10)
| ((unsigned long) sizeof(struct you)));
version.struct_sizes2 = (((unsigned long) sizeof(struct flag) << 10) |
version.struct_sizes2 = (((unsigned long) sizeof(struct flag) << 10));
/* free bits in here */
#ifdef SYSFLAGS
((unsigned long) sizeof(struct sysflag)));
#else
((unsigned long) 0L));
#endif
return;
}
@@ -439,9 +434,6 @@ static const char *build_opts[] = {
#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
"external program as a message handler",
#endif
#ifdef MFLOPPY
"floppy drive support",
#endif
#ifdef INSURANCE
"insurance files for recovering from crashes",
#endif

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 options.c $NHDT-Date: 1591476281 2020/06/06 20:44:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.466 $ */
/* NetHack 3.7 options.c $NHDT-Date: 1593953355 2020/07/05 12:49:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.467 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -8,9 +8,6 @@
#include "objclass.h"
#include "flag.h"
NEARDATA struct flag flags; /* provide linkage */
#ifdef SYSFLAGS
NEARDATA struct sysflag sysflags; /* provide linkage */
#endif
NEARDATA struct instance_flags iflags; /* provide linkage */
#define static
#else
@@ -5989,10 +5986,6 @@ initoptions_init()
*(allopt[i].addr) = allopt[i].initval;
}
#ifdef SYSFLAGS
Strcpy(sysflags.sysflagsid, "sysflags");
sysflags.sysflagsid[9] = (char) sizeof (struct sysflag);
#endif
flags.end_own = FALSE;
flags.end_top = 3;
flags.end_around = 2;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 restore.c $NHDT-Date: 1581886865 2020/02/16 21:01:05 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.163 $ */
/* NetHack 3.7 restore.c $NHDT-Date: 1593953357 2020/07/05 12:49:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.166 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2009. */
/* NetHack may be freely redistributed. See license for details. */
@@ -33,7 +33,7 @@ static void FDECL(freefruitchn, (struct fruit *));
static void FDECL(ghostfruit, (struct obj *));
static boolean FDECL(restgamestate, (NHFILE *, unsigned int *, unsigned int *));
static void FDECL(restlevelstate, (unsigned int, unsigned int));
static int FDECL(restlevelfile, (NHFILE *, XCHAR_P));
static int FDECL(restlevelfile, (XCHAR_P));
static void FDECL(restore_msghistory, (NHFILE *));
static void FDECL(reset_oattached_mids, (BOOLEAN_P));
static void FDECL(rest_levl, (NHFILE *, BOOLEAN_P));
@@ -548,9 +548,6 @@ NHFILE *nhfp;
unsigned int *stuckid, *steedid;
{
struct flag newgameflags;
#ifdef SYSFLAGS
struct sysflag newgamesysflags;
#endif
struct context_info newgamecontext; /* all 0, but has some pointers */
struct obj *otmp;
struct obj *bc_obj;
@@ -608,12 +605,6 @@ unsigned int *stuckid, *steedid;
/* specified by save file; check authorization now */
set_playmode();
}
#ifdef SYSFLAGS
newgamesysflags = sysflags;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &sysflags, sizeof(struct sysflag));
#endif
role_init(); /* Reset the initial role, race, gender, and alignment */
#ifdef AMII_GRAPHICS
amii_setpens(amii_numcolors); /* use colors from save file */
@@ -654,9 +645,6 @@ unsigned int *stuckid, *steedid;
iflags.deferred_X = FALSE;
iflags.perm_invent = defer_perm_invent;
flags = newgameflags;
#ifdef SYSFLAGS
sysflags = newgamesysflags;
#endif
g.context = newgamecontext;
g.youmonst = cg.zeromonst;
return FALSE;
@@ -776,66 +764,22 @@ unsigned int stuckid, steedid;
/*ARGSUSED*/
static int
restlevelfile(nhfp, ltmp)
NHFILE *nhfp; /* used in MFLOPPY only */
restlevelfile(ltmp)
xchar ltmp;
{
char whynot[BUFSZ];
#ifdef MFLOPPY
int savemode;
#endif
NHFILE *nnhfp = (NHFILE *) 0;
NHFILE *nhfp = (NHFILE *) 0;
#ifndef MFLOPPY
nhUse(nhfp);
#endif
nnhfp = create_levelfile(ltmp, whynot);
if (!nnhfp) {
nhfp = create_levelfile(ltmp, whynot);
if (!nhfp) {
/* BUG: should suppress any attempt to write a panic
save file if file creation is now failing... */
panic("restlevelfile: %s", whynot);
}
#ifdef MFLOPPY
savemode = nnhfp->mode;
nnhfp->mode = COUNTING;
if (!savelev(nnhfp, ltmp)) {
/* The savelev can't proceed because the size required
* is greater than the available disk space.
*/
pline("Not enough space on `%s' to restore your game.", levels);
/* Remove levels and bones that may have been created.
*/
close_nhfile(nnhfp);
#ifdef AMIGA
clearlocks();
#else /* !AMIGA */
eraseall(levels, g.alllevels);
eraseall(levels, g.allbones);
/* Perhaps the person would like to play without a
* RAMdisk.
*/
if (g.ramdisk) {
/* PlaywoRAMdisk may not return, but if it does
* it is certain that g.ramdisk will be 0.
*/
playwoRAMdisk();
/* Rewind save file and try again */
rewind_nhfile(nhfp);
(void) validate(nhfp, (char *) 0); /* skip version etc */
return dorecover(nhfp); /* 0 or 1 */
}
#endif /* ?AMIGA */
pline("Be seeing you...");
nh_terminate(EXIT_SUCCESS);
}
nnhfp->mode = savemode;
#endif /* MFLOPPY */
bufon(nnhfp->fd);
nnhfp->mode = WRITING | FREEING;
savelev(nnhfp, ltmp);
close_nhfile(nnhfp);
bufon(nhfp->fd);
nhfp->mode = WRITING | FREEING;
savelev(nhfp, ltmp);
close_nhfile(nhfp);
return 2;
}
@@ -870,7 +814,7 @@ NHFILE *nhfp;
#ifdef INSURANCE
savestateinlock();
#endif
rtmp = restlevelfile(nhfp, ledger_no(&u.uz));
rtmp = restlevelfile(ledger_no(&u.uz));
if (rtmp < 2)
return rtmp; /* dorecover called recursively */
@@ -924,7 +868,7 @@ NHFILE *nhfp;
}
mark_synch();
#endif
rtmp = restlevelfile(nhfp, ltmp);
rtmp = restlevelfile(ltmp);
if (rtmp < 2)
return rtmp; /* dorecover called recursively */
}
@@ -944,9 +888,6 @@ NHFILE *nhfp;
assign_graphics(ROGUESET);
#ifdef USE_TILES
substitute_tiles(&u.uz);
#endif
#ifdef MFLOPPY
gameDiskPrompt();
#endif
max_rank_sz(); /* to recompute g.mrank_sz (botl.c) */
/* take care of iron ball & chain */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 save.c $NHDT-Date: 1590263454 2020/05/23 19:50:54 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.158 $ */
/* NetHack 3.6 save.c $NHDT-Date: 1593953359 2020/07/05 12:49:19 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.159 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2009. */
/* NetHack may be freely redistributed. See license for details. */
@@ -12,11 +12,6 @@
#include <fcntl.h>
#endif
#ifdef MFLOPPY
long bytes_counted;
static int count_only;
#endif
#if defined(UNIX) || defined(WIN32)
#define USE_BUFFERING
#endif
@@ -39,12 +34,6 @@ static void FDECL(savetrapchn, (NHFILE *,struct trap *));
static void FDECL(savegamestate, (NHFILE *));
static void FDECL(save_msghistory, (NHFILE *));
#ifdef MFLOPPY
static void FDECL(savelev0, (NHFILE *, XCHAR_P, int));
static boolean NDECL(swapout_oldest);
static void FDECL(copyfile, (char *, char *));
#endif /* MFLOPPY */
#ifdef ZEROCOMP
static void FDECL(zerocomp_bufon, (int));
static void FDECL(zerocomp_bufoff, (int));
@@ -119,11 +108,6 @@ dosave0()
(void) signal(SIGINT, SIG_IGN);
#endif
#if defined(MICRO) && defined(MFLOPPY)
if (!saveDiskPrompt(0))
return 0;
#endif
HUP if (iflags.window_inited) {
nh_uncompress(fq_save);
nhfp = open_savefile();
@@ -165,36 +149,6 @@ dosave0()
if (!WINDOWPORT("X11"))
putstr(WIN_MAP, 0, "Saving:");
#endif
#ifdef MFLOPPY
/* make sure there is enough disk space */
if (iflags.checkspace) {
long fds, needed;
nhfp->mode = COUNTING;
savelev(nhfp, ledger_no(&u.uz));
savegamestate(nhfp);
needed = bytes_counted;
for (ltmp = 1; ltmp <= maxledgerno(); ltmp++)
if (ltmp != ledger_no(&u.uz) && g.level_info[ltmp].where)
needed += g.level_info[ltmp].size + (sizeof ltmp);
fds = freediskspace(fq_save);
if (needed > fds) {
HUP
{
There("is insufficient space on SAVE disk.");
pline("Require %ld bytes but only have %ld.", needed, fds);
}
flushout();
close_nhfile(nhfp);
(void) delete_savefile();
return 0;
}
co_false();
}
#endif /* MFLOPPY */
nhfp->mode = WRITING | FREEING;
store_version(nhfp);
store_savefileinfo(nhfp);
@@ -272,17 +226,11 @@ NHFILE *nhfp;
unsigned long uid;
struct obj * bc_objs = (struct obj *)0;
#ifdef MFLOPPY
count_only = (nhfp->mode & COUNTING);
#endif
uid = (unsigned long) getuid();
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &uid, sizeof uid);
bwrite(nhfp->fd, (genericptr_t) &g.context, sizeof g.context);
bwrite(nhfp->fd, (genericptr_t) &flags, sizeof flags);
#ifdef SYSFLAGS
bwrite(nhfp->fd, (genericptr_t) &sysflags, sysflags);
#endif
}
urealtime.finish_time = getnow();
urealtime.realtime += (long) (urealtime.finish_time
@@ -443,44 +391,8 @@ savestateinlock()
}
#endif
#ifdef MFLOPPY
boolean
savelev(nhfp, lev)
NHFILE *nhfp;
xchar lev;
{
if (nhfp->mode & COUNTING) {
int savemode = nhfp->mode;
bytes_counted = 0;
savelev0(nhfp, lev);
/* probably bytes_counted will be filled in again by an
* immediately following WRITE_SAVE anyway, but we'll
* leave it out of checkspace just in case */
if (iflags.checkspace) {
while (bytes_counted > freediskspace(levels))
if (!swapout_oldest())
return FALSE;
}
}
if (nhfp->mode & (WRITING | FREEING)) {
bytes_counted = 0;
savelev0(nhfp, lev);
}
if (nhfp->mode != FREEING) {
g.level_info[lev].where = ACTIVE;
g.level_info[lev].time = g.moves;
g.level_info[lev].size = bytes_counted;
}
return TRUE;
}
static void
savelev0(nhfp, lev)
#else
void
savelev(nhfp, lev)
#endif
NHFILE *nhfp;
xchar lev;
{
@@ -516,9 +428,6 @@ xchar lev;
if (!nhfp)
panic("Save on bad file!"); /* impossible */
#ifdef MFLOPPY
count_only = (nhfp->mode & COUNTING);
#endif
if (lev >= 0 && lev <= maxledgerno())
g.level_info[lev].flags |= VISITED;
if (nhfp->structlevel)
@@ -1167,97 +1076,4 @@ freedynamicdata()
return;
}
#ifdef MFLOPPY
boolean
swapin_file(lev)
int lev;
{
char to[PATHLEN], from[PATHLEN];
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) {
while (g.level_info[lev].size > freediskspace(to))
if (!swapout_oldest())
return FALSE;
}
if (wizard) {
pline("Swapping in `%s'.", from);
wait_synch();
}
copyfile(from, to);
(void) unlink(from);
g.level_info[lev].where = ACTIVE;
return TRUE;
}
static boolean
swapout_oldest()
{
char to[PATHLEN], from[PATHLEN];
int i, oldest;
long oldtime;
if (!g.ramdisk)
return FALSE;
for (i = 1, oldtime = 0, oldest = 0; i <= maxledgerno(); i++)
if (g.level_info[i].where == ACTIVE
&& (!oldtime || g.level_info[i].time < oldtime)) {
oldest = i;
oldtime = g.level_info[i].time;
}
if (!oldest)
return FALSE;
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) {
pline("Swapping out `%s'.", from);
wait_synch();
}
copyfile(from, to);
(void) unlink(from);
g.level_info[oldest].where = SWAPPED;
return TRUE;
}
static void
copyfile(from, to)
char *from, *to;
{
#ifdef TOS
if (_copyfile(from, to))
panic("Can't copy %s to %s", from, to);
#else
char buf[BUFSIZ]; /* this is system interaction, therefore
* BUFSIZ instead of NetHack's BUFSZ */
int nfrom, nto, fdfrom, fdto;
if ((fdfrom = open(from, O_RDONLY | O_BINARY, FCMASK)) < 0)
panic("Can't copy from %s !?", from);
if ((fdto = open(to, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, FCMASK)) < 0)
panic("Can't copy to %s", to);
do {
nfrom = read(fdfrom, buf, BUFSIZ);
nto = write(fdto, buf, nfrom);
if (nto != nfrom)
panic("Copyfile failed!");
} while (nfrom == BUFSIZ);
(void) nhclose(fdfrom);
(void) nhclose(fdto);
#endif /* TOS */
}
/* see comment in bones.c */
void
co_false()
{
count_only = FALSE;
return;
}
#endif /* MFLOPPY */
/*save.c*/

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 sfstruct.c $NHDT-Date: 1559994625 2019/06/08 11:50:25 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.121 $ */
/* NetHack 3.7 sfstruct.c $NHDT-Date: 1593953360 2020/07/05 12:49:20 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.3 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2009. */
/* NetHack may be freely redistributed. See license for details. */
@@ -212,11 +212,6 @@ register unsigned num;
int idx = getidx(fd, NOFLG);
if (idx >= 0) {
#ifdef MFLOPPY
bytes_counted += num;
if (count_only)
return;
#endif
#ifdef USE_BUFFERING
if (bw_buffered[idx] && bw_FILE[idx]) {
failed = (fwrite(loc, (int) num, 1, bw_FILE[idx]) != 1);