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:
nethack.rankin
2002-08-23 14:52:25 +00:00
parent c3125ec0f9
commit b00a9dcd4a
7 changed files with 103 additions and 71 deletions

View File

@@ -484,10 +484,14 @@ xchar ltmp;
#endif
{
register int nfd;
char whynot[BUFSZ];
nfd = create_levelfile(ltmp);
if (nfd < 0) panic("Cannot open temp level %d!", ltmp);
nfd = create_levelfile(ltmp, whynot);
if (nfd < 0) {
/* BUG: should suppress any attempt to write a panic
save file if file creation is now failing... */
panic("restlevelfile: %s", whynot);
}
#ifdef MFLOPPY
if (!savelev(nfd, ltmp, COUNT_SAVE)) {
@@ -675,11 +679,13 @@ register int fd;
}
void
trickery()
trickery(reason)
char *reason;
{
pline("Strange, this map is not as I remember it.");
pline("Somebody is trying some trickery here...");
pline("This game is void.");
killer = reason;
done(TRICKED);
}
@@ -719,16 +725,18 @@ boolean ghostly;
#else
mread(fd, (genericptr_t) &dlvl, sizeof(dlvl));
#endif
if((pid && pid != hpid) || (lev && dlvl != lev)) {
if ((pid && pid != hpid) || (lev && dlvl != lev)) {
char trickbuf[BUFSZ];
if (pid && pid != hpid)
Sprintf(trickbuf, "PID (%d) doesn't match saved PID (%d)!",
hpid, pid);
else
Sprintf(trickbuf, "This is level %d, not %d!", dlvl, lev);
#ifdef WIZARD
if (wizard) {
if (pid && pid != hpid)
pline("PID (%d) doesn't match saved PID (%d)!", hpid, pid);
else if (lev && dlvl != lev)
pline("This is level %d, not %d!", dlvl, lev);
}
if (wizard) pline(trickbuf);
#endif
trickery();
trickery(trickbuf);
}
#ifdef RLECOMP