From 291972d0389cc24265975523b04072c3d81845c8 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 26 Apr 2026 22:58:26 -0400 Subject: [PATCH 1/3] wizmode wizshowuuid to view the game's NHUUID --- include/extern.h | 1 + src/cmd.c | 2 ++ src/wizcmds.c | 7 +++++++ 3 files changed, 10 insertions(+) diff --git a/include/extern.h b/include/extern.h index d17497325..0550b63b8 100644 --- a/include/extern.h +++ b/include/extern.h @@ -3889,6 +3889,7 @@ extern void wizcustom_callback(winid win, int glyphnum, char *id); extern int wiz_display_macros(void); extern int wiz_mon_diff(void); extern int wiz_objprobs(void); +extern int wiz_show_nhuuid(void); #endif extern void sanity_check(void); diff --git a/src/cmd.c b/src/cmd.c index 93edbe4b9..c1ef88b1d 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1989,6 +1989,8 @@ struct ext_func_tab extcmdlist[] = { wiz_rumor_check, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, { '\0', "wizseenv", "show map locations' seen vectors", wiz_show_seenv, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, + { '\0', "wizshownhuuid", "show NHUUID for this game", + wiz_show_nhuuid, AUTOCOMPLETE | WIZMODECMD, NULL }, { '\0', "wizsmell", "smell monster", wiz_smell, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, { '\0', "wiztelekinesis", "telekinesis", diff --git a/src/wizcmds.c b/src/wizcmds.c index 0bee2da86..c4c89f750 100644 --- a/src/wizcmds.c +++ b/src/wizcmds.c @@ -1777,6 +1777,13 @@ wiz_display_macros(void) return ECMD_OK; } +/* the #wizshownhuuid command */ +int +wiz_show_nhuuid(void) +{ + pline("The NHUUID for this game is { %s }.", svn.nhuuid); +} + /* the #wizmondiff command */ int wiz_mon_diff(void) From 9098c2142111e89876da1d89a59c8be572c57110 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 27 Apr 2026 10:22:07 +0300 Subject: [PATCH 2/3] wizshowuuid return value --- src/wizcmds.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wizcmds.c b/src/wizcmds.c index c4c89f750..2c8554a8a 100644 --- a/src/wizcmds.c +++ b/src/wizcmds.c @@ -1782,6 +1782,7 @@ int wiz_show_nhuuid(void) { pline("The NHUUID for this game is { %s }.", svn.nhuuid); + return ECMD_OK; } /* the #wizmondiff command */ From b7f66f972305b0ad9d0c5804057ce2b8e9847526 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 27 Apr 2026 14:50:01 -0400 Subject: [PATCH 3/3] fix an issue with internal recover (Windows) --- src/files.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/files.c b/src/files.c index a55616382..ad9c62ef6 100644 --- a/src/files.c +++ b/src/files.c @@ -660,8 +660,9 @@ create_levelfile(int lev, char errbuf[]) Sprintf(errbuf, "Cannot create file \"%s\" for level %d (errno %d).", gl.lock, lev, errno); -#if defined(MSDOS) - setmode(nhfp->fd, O_BINARY); +#if defined(MSDOS) || defined(WIN32) + if (nhfp->fd >= 0) + (void) setmode(nhfp->fd, O_BINARY); #endif } nhfp = viable_nhfile(nhfp); @@ -705,8 +706,9 @@ open_levelfile(int lev, char errbuf[]) Sprintf(errbuf, "Cannot open file \"%s\" for level %d (errno %d).", gl.lock, lev, errno); -#if defined(MSDOS) - setmode(nhfp->fd, O_BINARY); +#if defined(MSDOS) || defined(WIN32) + if (nhfp->fd >= 0) + (void) setmode(nhfp->fd, O_BINARY); #endif } nhfp = viable_nhfile(nhfp); @@ -883,8 +885,9 @@ create_bonesfile(d_level *lev, char **bonesid, char errbuf[]) #endif /* ?MICRO || WIN32 */ if (nhfp->fd < 0) failed = errno; -#if defined(MSDOS) - setmode(nhfp->fd, O_BINARY); +#if defined(MSDOS) || defined(WIN32) + if (nhfp->fd >= 0) + (void) setmode(nhfp->fd, O_BINARY); #endif } if (failed && errbuf) /* failure explanation */ @@ -976,8 +979,9 @@ open_bonesfile(d_level *lev, char **bonesid) #else nhfp->fd = open(fq_bones, O_RDONLY | O_BINARY, 0); #endif -#if defined(MSDOS) - setmode(nhfp->fd, O_BINARY); +#if defined(MSDOS) || defined(WIN32) + if (nhfp->fd >= 0) + (void) setmode(nhfp->fd, O_BINARY); #endif } } @@ -1188,8 +1192,8 @@ create_savefile(void) #endif #endif /* MICRO || WIN32 */ #if defined(MSDOS) || defined(WIN32) - if (nhfp->fd >= 0) - (void) setmode(nhfp->fd, O_BINARY); + if (nhfp->fd >= 0) + (void) setmode(nhfp->fd, O_BINARY); #endif } } @@ -2989,6 +2993,9 @@ recover_savefile(void) if (savewrite_failure) goto cleanup; + if (snhfp->structlevel) + bufoff(snhfp->fd); + /* TODO: this is not a single byte, so a big-endian byte swap * might be necessary here, if anyone is concerned about big-endian */ Sfo_int(snhfp, &pltmpsiz, "plname-size"); @@ -3041,6 +3048,8 @@ recover_savefile(void) } } } + if (snhfp->structlevel) + bufon(snhfp->fd); close_nhfile(snhfp); /* * We have a successful savefile!