BONES_POOLS fix and bonesid fix
The BONES_POOLS implementation added an extra dot to the bones file name (only when enabled) which would be a problem on some filesystems. This changes the name from "bonD0.15.3" to "bon3D0.15" which avoids the second dot and also fits within 8.3 characters. To enforce that, the maximum value for BONES_POOLS is now 10 (yielding single-digit pool numbers 0 through 9). BONES_POOLS==1 will omit the pool number (that's not a change, just a reminder), yielding "bonD0.15" and so on. Right now, BONES_POOLS==0 is equivalent to BONES_POOLS=1, but it could be changed someday to mean that bones files shouldn't be used if we decide to support that. The pool number as a suffix was being included in content validation, so it wasn't possible to move "bonD0.15.3" to pool 2 by renaming it to "bonD0.15.2". I'm not sure whether that was intentional, but it seems overly draconian. "bon3D0.15" can be renamed to "bon2D0.15" and then be loaded by a game assigned to pool 2. Also, pre-pool bones can be retained by renaming to any valid pool and should still work. The three letter filecode for quest bones has made the bonesid be broken since 3.3.0 introduced it (the three letter code, not bones-id). "QArc.2" for level 2 of the Archeologist quest was being written into the bones file as "rc.2", but worked as intended because validation when loading bones had the same mistake. This fixes it to use "QArc.2" when saving and accept either "QArc.2" or "rc.2" when loading, so 3.6.0 bones files (and existing to-be-3.6.1 bones) will continue to work.
This commit is contained in:
14
src/bones.c
14
src/bones.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 bones.c $NHDT-Date: 1450432756 2015/12/18 09:59:16 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.68 $ */
|
||||
/* NetHack 3.6 bones.c $NHDT-Date: 1503309019 2017/08/21 09:50:19 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.70 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985,1993. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -549,7 +549,7 @@ getbones()
|
||||
{
|
||||
register int fd;
|
||||
register int ok;
|
||||
char c, *bonesid, oldbonesid[10];
|
||||
char c, *bonesid, oldbonesid[40]; /* was [10]; more should be safer */
|
||||
|
||||
if (discover) /* save bones files for real games */
|
||||
return 0;
|
||||
@@ -581,7 +581,15 @@ getbones()
|
||||
}
|
||||
mread(fd, (genericptr_t) &c, sizeof c); /* length incl. '\0' */
|
||||
mread(fd, (genericptr_t) oldbonesid, (unsigned) c); /* DD.nnn */
|
||||
if (strcmp(bonesid, oldbonesid) != 0) {
|
||||
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 because then we'd need patchlevel.h) */
|
||||
&& (strlen(bonesid) <= 2
|
||||
|| strcmp(bonesid + 2, oldbonesid) != 0)) {
|
||||
char errbuf[BUFSZ];
|
||||
|
||||
Sprintf(errbuf, "This is bones level '%s', not '%s'!", oldbonesid,
|
||||
|
||||
Reference in New Issue
Block a user