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.
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
struct permonst *mptr;
struct fruit *f;
char c, *bonesid;
+ char whynot[BUFSZ];
/* caller has already checked `can_make_bones()' */
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);
}
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);
# 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.
*/
(void) chmod(file, FCMASK | 007); /* allow other users full access */
# endif /* VMS && !SECURE */
-#endif /* MICRO || WIN32*/
return fd;
}