]> granicus.if.org Git - nethack/commitdiff
bones file diagnostics
authornethack.allison <nethack.allison>
Sat, 24 Aug 2002 23:25:40 +0000 (23:25 +0000)
committernethack.allison <nethack.allison>
Sat, 24 Aug 2002 23:25:40 +0000 (23:25 +0000)
Pat added some error information to create_levelfile.
This does the same for create_bonesfile, but the
only place it is logged is in the paniclog, unless
you're in wizard mode.  If bones file creation is
silently failing for someone and they aren't getting
bones files, this provides a way to diagnose why.

include/extern.h
src/bones.c
src/files.c

index d1429d6d510bb61536dd586786dd2cc6d68a8e20..ecf83601c47adb3356ce314243bdeafc9913479f 100644 (file)
@@ -609,7 +609,7 @@ E int FDECL(create_levelfile, (int,char *));
 E int FDECL(open_levelfile, (int,char *));
 E void FDECL(delete_levelfile, (int));
 E void NDECL(clearlocks);
-E int FDECL(create_bonesfile, (d_level*,char **));
+E int FDECL(create_bonesfile, (d_level*,char **, char *));
 #ifdef MFLOPPY
 E void NDECL(cancel_bonesfile);
 #endif
index 79f5f0dfe4ce96ff19597cd2d02637d5678d253e..e10b9ae11e9770d727cb250164cbc9fb23d311ed 100644 (file)
@@ -194,6 +194,7 @@ struct obj *corpse;
        struct permonst *mptr;
        struct fruit *f;
        char c, *bonesid;
+       char whynot[BUFSZ];
 
        /* caller has already checked `can_make_bones()' */
 
@@ -308,12 +309,16 @@ struct obj *corpse;
            levl[x][y].glyph = cmap_to_glyph(S_stone);
        }
 
-       fd = create_bonesfile(&u.uz, &bonesid);
+       fd = create_bonesfile(&u.uz, &bonesid, whynot);
        if(fd < 0) {
 #ifdef WIZARD
                if(wizard)
-                       pline("Cannot create bones file - create failed");
+                       pline("%s", whynot);
 #endif
+               /* bones file creation problems are silent to the player.
+                * Keep it that way, but place a clue into the paniclog.
+                */
+               paniclog("savebones", whynot);
                return;
        }
        c = (char) (strlen(bonesid) + 1);
index d44824ef68f01bf90694b33ad24a1dd1dc9ed69e..afe838eafe0462e395026812f268366f8a678e5e 100644 (file)
@@ -633,13 +633,15 @@ set_bonestemp_name()
 }
 
 int
-create_bonesfile(lev, bonesid)
+create_bonesfile(lev, bonesid, errbuf)
 d_level *lev;
 char **bonesid;
+char errbuf[];
 {
        const char *file;
        int fd;
 
+       if (errbuf) *errbuf = '\0';
        *bonesid = set_bonesfile_name(bones, lev);
        file = set_bonestemp_name();
        file = fqname(file, BONESPREFIX, 0);
@@ -655,6 +657,12 @@ char **bonesid;
 # else
        fd = creat(file, FCMASK);
 # endif
+#endif
+       if (fd < 0 && errbuf) /* failure explanation */
+           Sprintf(errbuf,
+                   "Cannot create bones \"%s\", id %s (errno %d).",
+                   lock, *bonesid, errno);
+
 # if defined(VMS) && !defined(SECURE)
        /*
           Re-protect bones file with world:read+write+execute+delete access.
@@ -666,7 +674,6 @@ char **bonesid;
         */
        (void) chmod(file, FCMASK | 007);  /* allow other users full access */
 # endif /* VMS && !SECURE */
-#endif /* MICRO || WIN32*/
 
        return fd;
 }