savefile changes - part 1
This is the first of several savefile-related changes to follow later. This one is groundwork for those later changes. Remove internal compression schemes (RLECOMP and ZEROCOMP) and discard the savefile_info struct that was primarily used to convey which internal compression schemes had been in use. Relocate some struct definitions into appropriate header files for use by code to come in later changes. Remove the two struct size-related fields from version_info and from the nmakedefs_s. Instead, include a series of bytes near the beginning of the savefile, representing the size of each struct or base data type that impacts the historical savefile content. Those are referred to as the "critical bytes". (Related note: the "you" struct required two bytes, low and high, due to its size). Compare those critical bytes in a savefile against the NetHack build that is reading the savefile. This allows mismatch detection early in the savefile-reading process, and a clean exit, rather than proceeding to read nonsensical values from the file. Include some feedback on what the first mismatch was when encountering one. For arrays stored in the savefile, use loop-logic in the core to write/read the array elements one at a time, rather than in a single blob. This will be required for changes to follow later. (impacts artiexist[], artidisco[], svd.dungeons[], svl.level_info[], svl.level.locations[][], msrooms[] field of mapseen, svb.bases[], svb.disco[] objects[], svm.mvitals[], svs.spl_book[], svd.doors[], go.oracle_loc[], utrack[], wgrowtime[]) This also adds data model to the long version information. This invalidates existing save and bones files due to the changes in the information at the start of the file.
This commit is contained in:
34
src/bones.c
34
src/bones.c
@@ -610,14 +610,14 @@ savebones(int how, time_t when, struct obj *corpse)
|
||||
|
||||
nhfp->mode = WRITING;
|
||||
store_version(nhfp);
|
||||
store_savefileinfo(nhfp);
|
||||
|
||||
/* if a bones pool digit is in use, it precedes the bonesid
|
||||
string and isn't recorded in the file */
|
||||
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.nn */
|
||||
savefruitchn(nhfp);
|
||||
}
|
||||
savefruitchn(nhfp);
|
||||
update_mlstmv(); /* update monsters for eventual restoration */
|
||||
savelev(nhfp, ledger_no(&u.uz));
|
||||
close_nhfile(nhfp);
|
||||
@@ -668,23 +668,25 @@ getbones(void)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* if a bones pool digit is in use, it precedes the bonesid
|
||||
string and wasn't recorded in the file */
|
||||
if (nhfp->structlevel) {
|
||||
/* 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' */
|
||||
if ((unsigned) c <= sizeof oldbonesid) {
|
||||
}
|
||||
if ((unsigned) c <= sizeof oldbonesid) {
|
||||
if (nhfp->structlevel) {
|
||||
mread(nhfp->fd, (genericptr_t) oldbonesid,
|
||||
(unsigned) c); /* DD.nn or Qrrr.n for role rrr */
|
||||
} else {
|
||||
if (wizard)
|
||||
debugpline2("Abandoning bones , %u > %u.",
|
||||
(unsigned) c, (unsigned) sizeof oldbonesid);
|
||||
close_nhfile(nhfp);
|
||||
compress_bonesfile();
|
||||
/* ToDo: maybe unlink these problematic bones? */
|
||||
return 0;
|
||||
(unsigned) c); /* DD.nn or Qrrr.n for role rrr */
|
||||
}
|
||||
} else {
|
||||
if (wizard)
|
||||
debugpline2("Abandoning bones , %u > %u.", (unsigned) c,
|
||||
(unsigned) sizeof oldbonesid);
|
||||
close_nhfile(nhfp);
|
||||
compress_bonesfile();
|
||||
/* ToDo: maybe unlink these problematic bones? */
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(bonesid, oldbonesid) != 0) {
|
||||
char errbuf[BUFSZ];
|
||||
|
||||
Reference in New Issue
Block a user