add some foundational work for uplifts

Be able to carry out uplifts during minor release
lifetimes.

Document a way to be able to uplift struct content
without incrementing EDITLEVEL and breaking existing savefiles.
Use the mechanics outlined to uplift the contents instead, where
it is feasible to do so. The uplift is currently one-way only. An
uplifted savefile cannot be used with an earlier build of NetHack
, one built with a lower SAVEFILE_REVISION_LEVEL, than the one which
wrote the savefile.

The final byte (byte 79) of the 80 critical bytes in the savefile,
of which 10 are reserved for future expansion and not currently
used, will now be used for holding the savefile revision level
(SAVEFILE_REVISION_LEVEL in include/patchlevel.h) at the time
the savefile was written.

That leaves 9 of the bytes available for future use.
This commit is contained in:
nhmall
2026-05-27 16:14:20 -04:00
parent e352048612
commit ce31feb231
21 changed files with 526 additions and 117 deletions
+13 -1
View File
@@ -184,6 +184,10 @@ extern void sfi_int(NHFILE *, int *, const char *);
extern void sfi_unsigned(NHFILE *, unsigned *, const char *);
extern void sfi_long(NHFILE *, long *, const char *);
extern void sfi_ulong(NHFILE *, ulong *, const char *);
#ifdef DEMO_UPLIFTS
extern void sfi_mystruct(NHFILE *, struct mystruct *, const char *);
extern void sfi_mystruct_rev0(NHFILE *, struct mystruct_rev0 *, const char *);
#endif
#if NH_C < 202300L
#define Sfo_aligntyp(a,b,c) sfo_aligntyp(a, b, c)
#define Sfo_any(a,b,c) sfo_any(a, b, c)
@@ -315,6 +319,10 @@ extern void sfi_ulong(NHFILE *, ulong *, const char *);
#define Sfi_unsigned(a, b, c) sfi_unsigned(a, b, c);
#define Sfi_xint8(a, b, c) sfi_xint8(a, b, c);
#define Sfi_xint16(a, b, c) sfi_xint16(a, b, c);
#ifdef DEMO_UPLIFTS
#define Sfi_mystruct(a, b, c) sfi_mystruct(a, b, c)
#define Sfi_mystruct_rev0(a, b, c) sfi_mystruct_rev0(a, b, c)
#endif
#else
#define sfo(nhfp, dt, tag) \
@@ -553,7 +561,7 @@ extern void sfi_ulong(NHFILE *, ulong *, const char *);
#define Sfi_dest_area(a,b,c) sfi(a, b, c)
#define Sfi_levelflags(a,b,c) sfi(a, b, c)
#define Sfi_rm(a,b,c) sfi(a, b, c)
#define Sfi_cemetery(a,b,c) sfi(a, b, c)
#define Sfi_cemetery(a,b,c) sfi_cemetery(a, b, c)
#define Sfi_damage(a,b,c) sfi(a, b, c)
#define Sfi_stairway(a,b,c) sfi(a, b, c)
#define Sfi_obj(a,b,c) sfi(a, b, c)
@@ -575,6 +583,10 @@ extern void sfi_ulong(NHFILE *, ulong *, const char *);
#define Sfi_unsigned(a, b, c) sfi(a, b, c)
#define Sfi_xint8(a, b, c) sfi(a, b, c)
#define Sfi_xint16(a, b, c) sfi(a, b, c)
#ifdef DEMO_UPLIFTS
#define Sfi_mystruct(a, b, c) sfi(a, b, c)
#define Sfi_mystruct_rev0(a, b, c) sfi(a, b, c)
#endif
#endif
/* not in _Generic */