#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 */
#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
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 */
--- /dev/null
+/* 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 */
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
# 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 \
#==========================================
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 \
#==========================================
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 \
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
#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
#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
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)
}
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)
}
/* save file should contain:
+ * format indicator and cmc
* version info
* savefile info
* player name
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);
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 '/'