ignoring features when checking version compat

The nomakedefs stuff for cross-compiling support broke the code to
treat enabling or disabling some optional features as not breaking
save and bones file compatibility.  It was relying on a macro whose
definition was local to mdlib.c rather than propagated among files.
makedefs still constructs date.h with a value indicating the ignored
features but the actual compatability check doesn't use that anymore.
Toggling SCORE_ON_BOTL shouldn't have caused existing files to be
rejected but they were.
This commit is contained in:
PatR
2022-06-16 11:00:53 -07:00
parent 479945257b
commit 3806dae153
5 changed files with 45 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.949 $ $NHDT-Date: 1655065133 2022/06/12 20:18:53 $
HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.951 $ $NHDT-Date: 1655402422 2022/06/16 18:00:22 $
General Fixes and Modified Features
-----------------------------------
@@ -1254,6 +1254,8 @@ earlier fix for prices of unpaid objects going away in persistent inventory
display when hero bought something during itemized billing didn't work
if paying for a used-up shop item--prices of any unpaid items vanished
when inventory got updated to reflect transfer of hero's gold to shk
save files created with SCORE_ON_BOTL disabled were erroneously being rejected
if the program was rebuilt with it enabled and vice versa
curses: 'msg_window' option wasn't functional for curses unless the binary
also included tty support

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 date.c $NHDT-Date: 1645393645 2022/02/20 21:47:25 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.2 $ */
/* NetHack 3.7 date.c $NHDT-Date: 1655402414 2022/06/16 18:00:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.3 $ */
/* Copyright (c) Michael Allison, 2021. */
/* NetHack may be freely redistributed. See license for details. */
@@ -12,6 +12,7 @@ void free_nomakedefs(void);
nh_snprintf(__func__, __LINE__, str, size, __VA_ARGS__)
extern void nh_snprintf(const char *func, int line, char *str, size_t size,
const char *fmt, ...);
extern unsigned long md_ignored_features(void);
extern char *mdlib_version_string(char *, const char *);
extern char *version_id_string(char *, int, const char *);
extern char *bannerc_string(char *, int, const char *);
@@ -108,9 +109,7 @@ populate_nomakedefs(struct version_info *version)
nomakedefs.version_number = version->incarnation;
nomakedefs.version_features = version->feature_set;
#ifdef MD_IGNORED_FEATURES
nomakedefs.ignored_features = MD_IGNORED_FEATURES;
#endif
nomakedefs.ignored_features = md_ignored_features();
nomakedefs.version_sanity1 = version->entity_count;
nomakedefs.version_sanity2 = version->struct_sizes1;
nomakedefs.version_sanity3 = version->struct_sizes2;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 mdlib.c $NHDT-Date: 1644524060 2022/02/10 20:14:20 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.27 $ */
/* NetHack 3.7 mdlib.c $NHDT-Date: 1655402414 2022/06/16 18:00:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.31 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. */
/* Copyright (c) M. Stephenson, 1990, 1991. */
@@ -53,6 +53,7 @@
/* REPRODUCIBLE_BUILD will change this to TRUE */
static boolean date_via_env = FALSE;
extern unsigned long md_ignored_features(void);
char *mdlib_version_string(char *, const char *);
char *version_id_string(char *, int, const char *);
char *bannerc_string(char *, int, const char *);
@@ -169,13 +170,15 @@ static struct win_info window_opts[] = {
* That check is done in src/restore.c now.
*
*/
#ifndef MD_IGNORED_FEATURES
#define MD_IGNORED_FEATURES \
(0L | (1L << 19) /* SCORE_ON_BOTL */ \
| (1L << 27) /* ZEROCOMP */ \
| (1L << 28) /* RLECOMP */ \
)
#endif /* MD_IGNORED_FEATUES */
unsigned long
md_ignored_features(void)
{
return (0UL
| (1UL << 19) /* SCORE_ON_BOTL */
| (1UL << 27) /* ZEROCOMP */
| (1UL << 28) /* RLECOMP */
);
}
static void
make_version(void)
@@ -454,6 +457,9 @@ static const char *const build_opts[] = {
"data librarian with a version-dependent name",
#endif
#endif
#ifdef EDIT_GETLIN
"edit getlin - some prompts remember previous response",
#endif
#ifdef DUMPLOG
"end-of-game dumplogs",
#endif
@@ -473,6 +479,9 @@ static const char *const build_opts[] = {
#ifdef INSURANCE
"insurance files for recovering from crashes",
#endif
#ifdef LIVELOG
"live logging support",
#endif
#ifdef LOGFILE
"log file",
#endif
@@ -485,6 +494,9 @@ static const char *const build_opts[] = {
#ifdef MAIL
"mail daemon",
#endif
#ifdef MONITOR_HEAP
"monitor heap - record memory usage for later analysis",
#endif
#if defined(GNUDOS) || defined(__DJGPP__)
"MSDOS protected mode",
#endif

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 version.c $NHDT-Date: 1654069065 2022/06/01 07:37:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.91 $ */
/* NetHack 3.7 version.c $NHDT-Date: 1655402415 2022/06/16 18:00:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.92 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2018. */
/* NetHack may be freely redistributed. See license for details. */
@@ -295,11 +295,14 @@ comp_times(long filetime)
#endif
boolean
check_version(struct version_info *version_data, const char *filename,
boolean complain, unsigned long utdflags)
check_version(
struct version_info *version_data,
const char *filename,
boolean complain,
unsigned long utdflags)
{
if (
#ifdef VERSION_COMPATIBILITY
#ifdef VERSION_COMPATIBILITY /* patchlevel.h */
version_data->incarnation < VERSION_COMPATIBILITY
|| version_data->incarnation > nomakedefs.version_number
#else
@@ -312,18 +315,15 @@ check_version(struct version_info *version_data, const char *filename,
}
return FALSE;
} else if (
#ifndef IGNORED_FEATURES
version_data->feature_set != nomakedefs.version_features
#else
(version_data->feature_set & ~nomakedefs.ignored_features)
!= (VERSION_FEATURES & ~nomakedefs.ignored_features)
#endif
!= (nomakedefs.version_features & ~nomakedefs.ignored_features)
|| ((utdflags & UTD_SKIP_SANITY1) == 0
&& version_data->entity_count != nomakedefs.version_sanity1)
|| ((utdflags & UTD_CHECKSIZES) != 0
&& version_data->struct_sizes1 != nomakedefs.version_sanity2)
|| ((utdflags & UTD_CHECKSIZES) != 0
&& version_data->struct_sizes2 != nomakedefs.version_sanity3)) {
&& version_data->struct_sizes2 != nomakedefs.version_sanity3)
) {
if (complain) {
pline("Configuration incompatibility for file \"%s\".", filename);
display_nhwindow(WIN_MESSAGE, TRUE);
@@ -390,7 +390,7 @@ void
store_version(NHFILE *nhfp)
{
struct version_info version_data = {
0UL,0UL,0UL,0UL,0Ul
0UL, 0UL, 0UL, 0UL, 0UL
};
/* actual version number */
@@ -408,7 +408,7 @@ store_version(NHFILE *nhfp)
bufoff(nhfp->fd);
/* bwrite() before bufon() uses plain write() */
store_formatindicator(nhfp);
bwrite(nhfp->fd,(genericptr_t) &version_data,
bwrite(nhfp->fd, (genericptr_t) &version_data,
(unsigned) (sizeof version_data));
bufon(nhfp->fd);
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 makedefs.c $NHDT-Date: 1645393932 2022/02/20 21:52:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.211 $ */
/* NetHack 3.7 makedefs.c $NHDT-Date: 1655402416 2022/06/16 18:00:16 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.215 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. */
/* Copyright (c) M. Stephenson, 1990, 1991. */
@@ -1285,10 +1285,12 @@ do_date(void)
ul_sfx);
Fprintf(ofp, "#define VERSION_FEATURES 0x%08lx%s\n", version.feature_set,
ul_sfx);
#ifdef MD_IGNORED_FEATURES
Fprintf(ofp, "#define IGNORED_FEATURES 0x%08lx%s\n",
(unsigned long) MD_IGNORED_FEATURES, ul_sfx);
#endif
{
unsigned long ignored_features = md_ignored_features();
Fprintf(ofp, "#define IGNORED_FEATURES 0x%08lx%s\n",
ignored_features, ul_sfx);
}
Fprintf(ofp, "#define VERSION_SANITY1 0x%08lx%s\n", version.entity_count,
ul_sfx);
#ifndef __EMSCRIPTEN__