From: nethack.allison Date: Sat, 24 Aug 2002 23:25:40 +0000 (+0000) Subject: bones file diagnostics X-Git-Tag: MOVE2GIT~2463 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d1da0e7398bfe3572984176cdecec7dabb0695e3;p=nethack bones file diagnostics 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. --- diff --git a/include/extern.h b/include/extern.h index d1429d6d5..ecf83601c 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 diff --git a/src/bones.c b/src/bones.c index 79f5f0dfe..e10b9ae11 100644 --- a/src/bones.c +++ b/src/bones.c @@ -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); diff --git a/src/files.c b/src/files.c index d44824ef6..afe838eaf 100644 --- a/src/files.c +++ b/src/files.c @@ -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; }