level file handling and trickery feedback
1) consolidate all core usage of `errno' in files.c; 2) give more feedback for any failure by create_levelfile or open_levelfile, similar to what was being done for problems during level change; 3) include trickery info in paniclog (many instances of "trickery" seem to be due to disk or quota problems rather than user misbehavior...). The create_levelfile call in pcmain probably ought to be changed to use error feedback, but in the meantime this should continue working. Perhaps error() should be modified to update paniclog too, but I didn't want to go through all its port-specific incarnations making changes.
This commit is contained in:
29
src/save.c
29
src/save.c
@@ -1,9 +1,10 @@
|
||||
/* SCCS Id: @(#)save.c 3.4 2002/01/19 */
|
||||
/* SCCS Id: @(#)save.c 3.4 2002/08/22 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "hack.h"
|
||||
#include "lev.h"
|
||||
#include "quest.h"
|
||||
|
||||
#ifndef NO_SIGNAL
|
||||
#include <signal.h>
|
||||
@@ -12,8 +13,6 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "quest.h"
|
||||
|
||||
#ifdef MFLOPPY
|
||||
long bytes_counted;
|
||||
static int count_only;
|
||||
@@ -117,6 +116,7 @@ dosave0()
|
||||
register int fd, ofd;
|
||||
xchar ltmp;
|
||||
d_level uz_save;
|
||||
char whynot[BUFSZ];
|
||||
|
||||
if (!SAVEF[0])
|
||||
return 0;
|
||||
@@ -150,7 +150,6 @@ dosave0()
|
||||
HUP mark_synch(); /* flush any buffered screen output */
|
||||
|
||||
fd = create_savefile();
|
||||
|
||||
if(fd < 0) {
|
||||
HUP pline("Cannot open save file.");
|
||||
(void) delete_savefile(); /* ab@unido */
|
||||
@@ -243,11 +242,12 @@ dosave0()
|
||||
}
|
||||
mark_synch();
|
||||
#endif
|
||||
ofd = open_levelfile(ltmp);
|
||||
ofd = open_levelfile(ltmp, whynot);
|
||||
if (ofd < 0) {
|
||||
HUP pline("Cannot read level %d.", ltmp);
|
||||
HUP pline("%s", whynot);
|
||||
(void) close(fd);
|
||||
(void) delete_savefile();
|
||||
HUP killer = whynot;
|
||||
HUP done(TRICKED);
|
||||
return(0);
|
||||
}
|
||||
@@ -328,6 +328,7 @@ savestateinlock()
|
||||
{
|
||||
int fd, hpid;
|
||||
static boolean havestate = TRUE;
|
||||
char whynot[BUFSZ];
|
||||
|
||||
/* When checkpointing is on, the full state needs to be written
|
||||
* on each checkpoint. When checkpointing is off, only the pid
|
||||
@@ -347,24 +348,30 @@ savestateinlock()
|
||||
* to any internal compression schemes since they must be
|
||||
* readable by an external utility
|
||||
*/
|
||||
fd = open_levelfile(0);
|
||||
fd = open_levelfile(0, whynot);
|
||||
if (fd < 0) {
|
||||
pline("Cannot open level 0.");
|
||||
pline("%s", whynot);
|
||||
pline("Probably someone removed it.");
|
||||
killer = whynot;
|
||||
done(TRICKED);
|
||||
return;
|
||||
}
|
||||
|
||||
(void) read(fd, (genericptr_t) &hpid, sizeof(hpid));
|
||||
if (hackpid != hpid) {
|
||||
pline("Level 0 pid bad!");
|
||||
Sprintf(whynot,
|
||||
"Level #0 pid (%d) doesn't match ours (%d)!",
|
||||
hpid, hackpid);
|
||||
pline("%s", whynot);
|
||||
killer = whynot;
|
||||
done(TRICKED);
|
||||
}
|
||||
(void) close(fd);
|
||||
|
||||
fd = create_levelfile(0);
|
||||
fd = create_levelfile(0, whynot);
|
||||
if (fd < 0) {
|
||||
pline("Cannot rewrite level 0.");
|
||||
pline("%s", whynot);
|
||||
killer = whynot;
|
||||
done(TRICKED);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user