recover fix
recover had deviated somewhat from NetHack in its file expectations: 1) A couple of 3.7 fields needed to be accommodated. 2) hard-coded file size values had deviated. The file sizes are now in an added header file named "filesize.h", which is included at the bottom of config.h. There will likely be another commit to write the filename size ahead of the file name so that the precise number of characters can be read, but since that will break existing saves, it can go in along with another save-breaking commit. This commit doesn't not alter savefiles written by nethack so does not require an editlevel bump. It does alter the read-in expectation in recover to match the game and this get recover working again.
This commit is contained in:
@@ -579,5 +579,6 @@ typedef unsigned char uchar;
|
||||
#endif
|
||||
|
||||
#include "global.h" /* Define everything else according to choices above */
|
||||
#include "filesize.h" /* Define file sizes shared between nethack and recover */
|
||||
|
||||
#endif /* CONFIG_H */
|
||||
|
||||
@@ -7,70 +7,6 @@
|
||||
#define DECL_H
|
||||
|
||||
#define E extern
|
||||
#if !defined(MICRO) && !defined(VMS) && !defined(WIN32)
|
||||
#define LOCKNAMESIZE (PL_NSIZ + 14) /* long enough for uid+name+.99 */
|
||||
#define LOCKNAMEINIT "1lock"
|
||||
#define BONESINIT "bonesnn.xxx.le"
|
||||
#define BONESSIZE sizeof(BONESINIT)
|
||||
#else
|
||||
#if defined(MICRO)
|
||||
#define LOCKNAMESIZE FILENAME
|
||||
#define LOCKNAMEINIT ""
|
||||
#define BONESINIT ""
|
||||
#define BONESSIZE FILENAME
|
||||
#endif
|
||||
#if defined(VMS)
|
||||
#define LOCKNAMESIZE (PL_NSIZ + 17) /* long enough for _uid+name+.99;1 */
|
||||
#define LOCKNAMEINIT "1lock"
|
||||
#define BONESINIT "bonesnn.xxx_le;1"
|
||||
#define BONESSIZE sizeof(BONESINIT)
|
||||
#endif
|
||||
#if defined(WIN32)
|
||||
#define LOCKNAMESIZE (PL_NSIZ + 25) /* long enough for username+-+name+.99 */
|
||||
#define LOCKNAMEINIT ""
|
||||
#define BONESINIT "bonesnn.xxx.le"
|
||||
#define BONESSIZE sizeof(BONESINIT)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define INDEXT ".xxxxxx" /* largest indicator suffix */
|
||||
#define INDSIZE sizeof(INDEXT)
|
||||
|
||||
#if defined(UNIX) || defined(__BEOS__)
|
||||
#define SAVEX "save/99999.e"
|
||||
#ifndef SAVE_EXTENSION
|
||||
#define SAVE_EXTENSION ""
|
||||
#endif
|
||||
#else /* UNIX || __BEOS__ */
|
||||
#ifdef VMS
|
||||
#define SAVEX "[.save]nnnnn.e;1"
|
||||
#ifndef SAVE_EXTENSION
|
||||
#define SAVE_EXTENSION ""
|
||||
#endif
|
||||
#else /* VMS */
|
||||
#if defined(WIN32) || defined(MICRO)
|
||||
#define SAVEX ""
|
||||
#if !defined(SAVE_EXTENSION)
|
||||
#ifdef MICRO
|
||||
#define SAVE_EXTENSION ".svh"
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
#define SAVE_EXTENSION ".NetHack-saved-game"
|
||||
#endif
|
||||
#endif /* !SAVE_EXTENSION */
|
||||
#endif /* WIN32 || MICRO */
|
||||
#endif /* else !VMS */
|
||||
#endif /* else !(UNIX || __BEOS__) */
|
||||
|
||||
#ifndef SAVE_EXTENSION
|
||||
#define SAVE_EXTENSION ""
|
||||
#endif
|
||||
|
||||
#ifndef MICRO
|
||||
#define SAVESIZE (PL_NSIZ + sizeof(SAVEX) + sizeof(SAVE_EXTENSION) + INDSIZE)
|
||||
#else
|
||||
#define SAVESIZE FILENAME
|
||||
#endif
|
||||
|
||||
/* max size of a windowtype option */
|
||||
#define WINTYPELEN 16
|
||||
@@ -945,6 +881,7 @@ struct instance_globals {
|
||||
boolean chosen_symset_start;
|
||||
boolean chosen_symset_end;
|
||||
int symset_which_set;
|
||||
/* SAVESIZE, BONESSIZE, LOCKNAMESIZE are defined in "filesize.h" */
|
||||
char SAVEF[SAVESIZE]; /* holds relative path of save file from playground */
|
||||
#ifdef MICRO
|
||||
char SAVEP[SAVESIZE]; /* holds path of directory for save file */
|
||||
|
||||
79
include/filesize.h
Normal file
79
include/filesize.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* NetHack 3.7 filesize.h $NHDT-Date: 1575245033 2019/12/02 00:03:53 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.126 $ */
|
||||
/*-Copyright (c) Michael Allison, 2020. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef FILESIZE_H
|
||||
#define FILESIZE_H
|
||||
|
||||
/*
|
||||
* Declarations for some file sizes, some of which need to be shared
|
||||
* between NetHack and recover. By placing them in here, there is less
|
||||
* chance of deviation between the two.
|
||||
*/
|
||||
|
||||
#if !defined(MICRO) && !defined(VMS) && !defined(WIN32)
|
||||
#define LOCKNAMESIZE (PL_NSIZ + 14) /* long enough for uid+name+.99 */
|
||||
#define LOCKNAMEINIT "1lock"
|
||||
#define BONESINIT "bonesnn.xxx.le"
|
||||
#define BONESSIZE sizeof(BONESINIT)
|
||||
#else
|
||||
#if defined(MICRO)
|
||||
#define LOCKNAMESIZE FILENAME
|
||||
#define LOCKNAMEINIT ""
|
||||
#define BONESINIT ""
|
||||
#define BONESSIZE FILENAME
|
||||
#endif
|
||||
#if defined(VMS)
|
||||
#define LOCKNAMESIZE (PL_NSIZ + 17) /* long enough for _uid+name+.99;1 */
|
||||
#define LOCKNAMEINIT "1lock"
|
||||
#define BONESINIT "bonesnn.xxx_le;1"
|
||||
#define BONESSIZE sizeof(BONESINIT)
|
||||
#endif
|
||||
#if defined(WIN32)
|
||||
#define LOCKNAMESIZE (PL_NSIZ + 25) /* long enough for username+-+name+.99 */
|
||||
#define LOCKNAMEINIT ""
|
||||
#define BONESINIT "bonesnn.xxx.le"
|
||||
#define BONESSIZE sizeof(BONESINIT)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define INDEXT ".xxxxxx" /* largest indicator suffix */
|
||||
#define INDSIZE sizeof(INDEXT)
|
||||
|
||||
#if defined(UNIX) || defined(__BEOS__)
|
||||
#define SAVEX "save/99999.e"
|
||||
#ifndef SAVE_EXTENSION
|
||||
#define SAVE_EXTENSION ""
|
||||
#endif
|
||||
#else /* UNIX || __BEOS__ */
|
||||
#ifdef VMS
|
||||
#define SAVEX "[.save]nnnnn.e;1"
|
||||
#ifndef SAVE_EXTENSION
|
||||
#define SAVE_EXTENSION ""
|
||||
#endif
|
||||
#else /* VMS */
|
||||
#if defined(WIN32) || defined(MICRO)
|
||||
#define SAVEX ""
|
||||
#if !defined(SAVE_EXTENSION)
|
||||
#ifdef MICRO
|
||||
#define SAVE_EXTENSION ".svh"
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
#define SAVE_EXTENSION ".NetHack-saved-game"
|
||||
#endif
|
||||
#endif /* !SAVE_EXTENSION */
|
||||
#endif /* WIN32 || MICRO */
|
||||
#endif /* else !VMS */
|
||||
#endif /* else !(UNIX || __BEOS__) */
|
||||
|
||||
#ifndef SAVE_EXTENSION
|
||||
#define SAVE_EXTENSION ""
|
||||
#endif
|
||||
|
||||
#ifndef MICRO
|
||||
#define SAVESIZE (PL_NSIZ + sizeof(SAVEX) + sizeof(SAVE_EXTENSION) + INDSIZE)
|
||||
#else
|
||||
#define SAVESIZE FILENAME
|
||||
#endif
|
||||
|
||||
#endif /* FILESIZE_H */
|
||||
@@ -424,8 +424,8 @@ YOU_H = $(MONST_H) $(YOUPROP_H) $(INCL)/align.h \
|
||||
DISPLAY_H = $(MONDATA_H) $(INCL)/vision.h $(INCL)/display.h
|
||||
PCCONF_H = $(INCL)/micro.h $(INCL)/system.h $(INCL)/pcconf.h \
|
||||
$(MSYS)/pcvideo.h
|
||||
CONFIG_H = $(GLOBAL_H) $(INCL)/tradstdc.h $(INCL)/config1.h \
|
||||
$(INCL)/config.h
|
||||
CONFIG_H = $(GLOBAL_H) $(INCL)/filesize.h $(INCL)/tradstdc.h \
|
||||
$(INCL)/config1.h $(INCL)/config.h
|
||||
DECL_H = $(YOU_H) $(INCL)/spell.h $(INCL)/color.h \
|
||||
$(INCL)/obj.h $(INCL)/onames.h $(INCL)/pm.h \
|
||||
$(INCL)/decl.h
|
||||
|
||||
@@ -729,11 +729,12 @@ depend: ../sys/unix/depend.awk \
|
||||
|
||||
# config.h timestamp
|
||||
$(CONFIG_H): ../include/config.h ../include/config1.h ../include/tradstdc.h \
|
||||
../include/global.h ../include/coord.h ../include/vmsconf.h \
|
||||
../include/system.h ../include/nhlua.h ../include/unixconf.h \
|
||||
../include/os2conf.h ../include/micro.h ../include/pcconf.h \
|
||||
../include/tosconf.h ../include/amiconf.h ../include/macconf.h \
|
||||
../include/beconf.h ../include/wceconf.h ../include/ntconf.h
|
||||
../include/global.h ../include/filesize.h ../include/coord.h \
|
||||
../include/vmsconf.h ../include/system.h ../include/nhlua.h \
|
||||
../include/unixconf.h ../include/os2conf.h ../include/micro.h \
|
||||
../include/pcconf.h ../include/tosconf.h ../include/amiconf.h \
|
||||
../include/macconf.h ../include/beconf.h ../include/wceconf.h \
|
||||
../include/ntconf.h
|
||||
touch $(CONFIG_H)
|
||||
# hack.h timestamp
|
||||
$(HACK_H): ../include/hack.h $(CONFIG_H) ../include/lint.h ../include/align.h \
|
||||
|
||||
@@ -469,11 +469,11 @@ endif
|
||||
#==========================================
|
||||
|
||||
CONFIG_H = $(INCL)/config.h $(INCL)/config1.h $(INCL)/tradstdc.h \
|
||||
$(INCL)/global.h $(INCL)/coord.h $(INCL)/vmsconf.h \
|
||||
$(INCL)/system.h $(INCL)/unixconf.h $(INCL)/os2conf.h \
|
||||
$(INCL)/micro.h $(INCL)/pcconf.h $(INCL)/tosconf.h \
|
||||
$(INCL)/amiconf.h $(INCL)/macconf.h $(INCL)/beconf.h \
|
||||
$(INCL)/ntconf.h
|
||||
$(INCL)/global.h $(INCL)/filesize.h $(INCL)/coord.h \
|
||||
$(INCL)/vmsconf.h $(INCL)/system.h $(INCL)/unixconf.h \
|
||||
$(INCL)/os2conf.h $(INCL)/micro.h $(INCL)/pcconf.h \
|
||||
$(INCL)/tosconf.h $(INCL)/amiconf.h $(INCL)/macconf.h \
|
||||
$(INCL)/beconf.h $(INCL)/ntconf.h
|
||||
|
||||
HACK_H = $(INCL)/hack.h $(CONFIG_H) $(INCL)/align.h $(INCL)/context.h \
|
||||
$(INCL)/dungeon.h $(INCL)/monsym.h $(INCL)/mkroom.h \
|
||||
|
||||
@@ -485,11 +485,12 @@ PDCLIB =
|
||||
#==========================================
|
||||
|
||||
CONFIG_H = $(INCL)\config.h $(INCL)\config1.h $(INCL)\tradstdc.h \
|
||||
$(INCL)\global.h $(INCL)\coord.h $(INCL)\vmsconf.h \
|
||||
$(INCL)\system.h $(INCL)\nhlua.h $(INCL)\unixconf.h \
|
||||
$(INCL)\os2conf.h $(INCL)\micro.h $(INCL)\pcconf.h \
|
||||
$(INCL)\tosconf.h $(INCL)\amiconf.h $(INCL)\macconf.h \
|
||||
$(INCL)\beconf.h $(INCL)\wceconf.h $(INCL)\ntconf.h
|
||||
$(INCL)\global.h $(INCL)\filesize.h $(INCL)\coord.h \
|
||||
$(INCL)\vmsconf.h $(INCL)\system.h $(INCL)\nhlua.h \
|
||||
$(INCL)\unixconf.h $(INCL)\os2conf.h $(INCL)\micro.h \
|
||||
$(INCL)\pcconf.h $(INCL)\tosconf.h $(INCL)\amiconf.h \
|
||||
$(INCL)\macconf.h $(INCL)\beconf.h $(INCL)\wceconf.h \
|
||||
$(INCL)\ntconf.h
|
||||
|
||||
HACK_H = $(INCL)\hack.h $(CONFIG_H) $(INCL)\lint.h $(INCL)\align.h \
|
||||
$(INCL)\dungeon.h $(INCL)\monsym.h $(INCL)\mkroom.h \
|
||||
|
||||
@@ -27,6 +27,7 @@ void FDECL(set_levelfile_name, (int));
|
||||
int FDECL(open_levelfile, (int));
|
||||
int NDECL(create_savefile);
|
||||
void FDECL(copy_bytes, (int, int));
|
||||
static void FDECL(store_formatindicator, (int));
|
||||
|
||||
#ifndef WIN_CE
|
||||
#define Fprintf (void) fprintf
|
||||
@@ -37,20 +38,6 @@ static void nhce_message(FILE *, const char *, ...);
|
||||
|
||||
#define Close (void) close
|
||||
|
||||
#ifdef UNIX
|
||||
#define SAVESIZE (PL_NSIZ + 13) /* save/99999player.e */
|
||||
#else
|
||||
#ifdef VMS
|
||||
#define SAVESIZE (PL_NSIZ + 22) /* [.save]<uid>player.e;1 */
|
||||
#else
|
||||
#ifdef WIN32
|
||||
#define SAVESIZE (PL_NSIZ + 40) /* username-player.NetHack-saved-game */
|
||||
#else
|
||||
#define SAVESIZE FILENAME /* from macconf.h or pcconf.h */
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(EXEPATH)
|
||||
char *FDECL(exepath, (char *));
|
||||
#endif
|
||||
@@ -58,6 +45,8 @@ char *FDECL(exepath, (char *));
|
||||
#if defined(__BORLANDC__) && !defined(_WIN32)
|
||||
extern unsigned _stklen = STKSIZ;
|
||||
#endif
|
||||
|
||||
/* SAVESIZE is defined in "filesize.h" */
|
||||
char savename[SAVESIZE]; /* holds relative path of save file from playground */
|
||||
|
||||
int
|
||||
@@ -216,11 +205,11 @@ restore_savefile(basename)
|
||||
char *basename;
|
||||
{
|
||||
int gfd, lfd, sfd;
|
||||
int res = 0, lev, savelev, hpid, pltmpsiz;
|
||||
int res = 0, lev, savelev, hpid, pltmpsiz, filecmc;
|
||||
xchar levc;
|
||||
struct version_info version_data;
|
||||
struct savefile_info sfi;
|
||||
char plbuf[PL_NSIZ];
|
||||
char plbuf[PL_NSIZ], indicator;
|
||||
|
||||
/* level 0 file contains:
|
||||
* pid of creating process (ignored here)
|
||||
@@ -265,6 +254,10 @@ char *basename;
|
||||
}
|
||||
if ((read(gfd, (genericptr_t) savename, sizeof savename)
|
||||
!= sizeof savename)
|
||||
|| (read(gfd, (genericptr_t) &indicator, sizeof indicator)
|
||||
!= sizeof indicator)
|
||||
|| (read(gfd, (genericptr_t) &filecmc, sizeof filecmc)
|
||||
!= sizeof filecmc)
|
||||
|| (read(gfd, (genericptr_t) &version_data, sizeof version_data)
|
||||
!= sizeof version_data)
|
||||
|| (read(gfd, (genericptr_t) &sfi, sizeof sfi) != sizeof sfi)
|
||||
@@ -277,6 +270,7 @@ char *basename;
|
||||
}
|
||||
|
||||
/* save file should contain:
|
||||
* format indicator and cmc
|
||||
* version info
|
||||
* savefile info
|
||||
* player name
|
||||
@@ -299,6 +293,7 @@ char *basename;
|
||||
return -1;
|
||||
}
|
||||
|
||||
store_formatindicator(sfd);
|
||||
if (write(sfd, (genericptr_t) &version_data, sizeof version_data)
|
||||
!= sizeof version_data) {
|
||||
Fprintf(stderr, "Error writing %s; recovery failed.\n", savename);
|
||||
@@ -394,6 +389,19 @@ char *basename;
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
store_formatindicator(fd)
|
||||
int fd;
|
||||
{
|
||||
char indicate = 'h'; /* historical */
|
||||
int cmc = 0;
|
||||
|
||||
write(fd, (genericptr_t) &indicate, sizeof indicate);
|
||||
write(fd, (genericptr_t) &cmc, sizeof cmc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef EXEPATH
|
||||
#ifdef __DJGPP__
|
||||
#define PATH_SEPARATOR '/'
|
||||
|
||||
Reference in New Issue
Block a user