diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 5789b56c4..3a3d66001 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.249 $ $NHDT-Date: 1594771373 2020/07/15 00:02:53 $ +$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.250 $ $NHDT-Date: 1595006054 2020/07/17 17:14:14 $ General Fixes and Modified Features ----------------------------------- @@ -492,3 +492,7 @@ relocated unmaintained code to outdated folder, specifically sys/amiga, include/wceconf.h removed SYSFLAGS conditional code removed MFLOPPY conditional code +get rid of 3.6.1 workaround needed to retain compatibility with 3.6.0 bones + files after fix for 3.3.0 through 3.6.0 bug for invalid 'bonesid' + designation in bones of quest levels + diff --git a/src/bones.c b/src/bones.c index 21fc01534..90d29fd60 100644 --- a/src/bones.c +++ b/src/bones.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 bones.c $NHDT-Date: 1593953344 2020/07/05 12:49:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.100 $ */ +/* NetHack 3.6 bones.c $NHDT-Date: 1595006054 2020/07/17 17:14:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.102 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985,1993. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -531,8 +531,10 @@ struct obj *corpse; store_version(nhfp); store_savefileinfo(nhfp); if (nhfp->structlevel) { + /* if a bones pool digit is in use, it precedes the bonesid + string and isn't recorded in the file */ bwrite(nhfp->fd, (genericptr_t) &c, sizeof c); - bwrite(nhfp->fd, (genericptr_t) bonesid, (unsigned) c); /* DD.nnn */ + bwrite(nhfp->fd, (genericptr_t) bonesid, (unsigned) c); /* DD.nn */ savefruitchn(nhfp); } update_mlstmv(); /* update monsters for eventual restoration */ @@ -585,22 +587,18 @@ getbones() } } if (nhfp->structlevel) { - mread(nhfp->fd, (genericptr_t) &c, sizeof c); /* length incl. '\0' */ - mread(nhfp->fd, (genericptr_t) oldbonesid, (unsigned) c); /* DD.nnn */ + /* if a bones pool digit is in use, it precedes the bonesid + string and wasn't recorded in the file */ + mread(nhfp->fd, (genericptr_t) &c, + sizeof c); /* length including terminating '\0' */ + mread(nhfp->fd, (genericptr_t) oldbonesid, + (unsigned) c); /* DD.nn or Qrrr.n for role rrr */ } - if (strcmp(bonesid, oldbonesid) != 0 - /* from 3.3.0 through 3.6.0, bones in the quest branch stored - a bogus bonesid in the file; 3.6.1 fixed that, but for - 3.6.0 bones to remain compatible, we need an extra test; - once compatibility with 3.6.x goes away, this can too - (we don't try to make this conditional upon the value of - VERSION_COMPATIBILITY) */ - && (strlen(bonesid) <= 2 - || strcmp(bonesid + 2, oldbonesid) != 0)) { + if (strcmp(bonesid, oldbonesid) != 0) { char errbuf[BUFSZ]; - Sprintf(errbuf, "This is bones level '%s', not '%s'!", oldbonesid, - bonesid); + Sprintf(errbuf, "This is bones level '%s', not '%s'!", + oldbonesid, bonesid); if (wizard) { pline1(errbuf); ok = FALSE; /* won't die of trickery */ diff --git a/src/files.c b/src/files.c index d106ed4f3..690f88580 100644 --- a/src/files.c +++ b/src/files.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 files.c $NHDT-Date: 1593953349 2020/07/05 12:49:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.315 $ */ +/* NetHack 3.7 files.c $NHDT-Date: 1595006057 2020/07/17 17:14:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.316 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -686,12 +686,12 @@ d_level *lev; char *dptr; /* - * "bonD0.nn.le" = bones for level nn in the main dungeon; - * "bonM0.T.le" = bones for Minetown; - * "bonQBar.n.le" = bones for level n in the Barbarian quest; - * "bon3D0.nn.le" = \ - * "bon3M0.T.le" = > same as above, but for bones pool #3. - * "bon3QBar.n.le" = / + * "bonD0.nn" = bones for level nn in the main dungeon; + * "bonM0.T" = bones for Minetown; + * "bonQBar.n" = bones for level n in the Barbarian quest; + * "bon3D0.nn" = \ + * "bon3M0.T" = > same as above, but for bones pool #3. + * "bon3QBar.n" = / * * Return value for content validation skips "bon" and the * pool number (if present), making it feasible for the admin @@ -707,15 +707,9 @@ d_level *lev; Sprintf(eos(file), "%u", poolnum); } #endif - dptr = eos(file); /* this used to be after the following Sprintf() - and the return value was (dptr - 2) */ + dptr = eos(file); /* when this naming scheme was adopted, 'filecode' was one letter; - 3.3.0 turned it into a three letter string (via roles[] in role.c); - from that version through 3.6.0, 'dptr' pointed past the filecode - and the return value of (dptr - 2) was wrong for bones produced - in the quest branch, skipping the boneid character 'Q' and the - first letter of the role's filecode; bones loading still worked - because the bonesid used for validation had the same error */ + 3.3.0 turned it into a three letter string for quest levels */ Sprintf(dptr, "%c%s", g.dungeons[lev->dnum].boneid, In_quest(lev) ? g.urole.filecode : "0"); if ((sptr = Is_special(lev)) != 0) @@ -779,7 +773,8 @@ char errbuf[]; /* Use O_TRUNC to force the file to be shortened if it already * exists and is currently longer. */ - nhfp->fd = open(file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, FCMASK); + nhfp->fd = open(file, + O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, FCMASK); #else #ifdef MAC nhfp->fd = maccreat(file, BONE_TYPE);