unix check_panic_save

Inspired by self-recover, sort of.  Enabled for unix by default; can
be disabled by commenting out '#define CHECK_PANIC_SAVE' in unixconf.h.

When starting the game, if there is no save file to restore and no
lock/level files to recover, check whether a panic save file exists.
If there is one, tell the player that it's there and that it might be
viable, then ask whether to start a new game.

It doesn't convert the panic save into a reconverable one (rename by
nethack, then continue trying to restore) or tell the player how to
make it viable (rename to remove ".e" by game admin), just whether it
is present.  If player opts to start a new game, the panic save is
left alone and will trigger the "there's a panic save file" situation
again once the new game finishes and player starts another.
This commit is contained in:
PatR
2024-03-23 10:11:35 -07:00
parent 4d206c1c40
commit ef17c7ac2b
5 changed files with 129 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 extern.h $NHDT-Date: 1710792423 2024/03/18 20:07:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1398 $ */
/* NetHack 3.7 extern.h $NHDT-Date: 1711213872 2024/03/23 17:11:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1400 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1010,6 +1010,12 @@ extern NHFILE *create_savefile(void);
extern NHFILE *open_savefile(void);
extern int delete_savefile(void);
extern NHFILE *restore_saved_game(void);
extern int check_panic_save(void);
#ifdef SELECTSAVED
extern char *plname_from_file(const char *, boolean) NONNULLARG1;
#endif
extern char **get_saved_games(void);
extern void free_saved_games(char **);
extern void nh_compress(const char *);
extern void nh_uncompress(const char *);
extern boolean lock_file(const char *, int, int) NONNULLARG1;
@@ -1032,11 +1038,6 @@ extern int read_sym_file(int);
extern void paniclog(const char *, const char *) NONNULLPTRS;
extern void testinglog(const char *, const char *, const char *);
extern int validate_prefix_locations(char *);
#ifdef SELECTSAVED
extern char *plname_from_file(const char *, boolean) NONNULLARG1;
#endif
extern char **get_saved_games(void);
extern void free_saved_games(char **);
#ifdef SELF_RECOVER
extern boolean recover_savefile(void);
extern void assure_syscf_file(void);
@@ -3325,6 +3326,7 @@ extern void tty_utf8graphics_fixup(void);
#ifdef UNIX
extern void getlock(void);
extern void ask_about_panic_save(void);
extern void regularize(char *) NONNULLARG1;
#if defined(TIMED_DELAY) && !defined(msleep) && defined(SYSV)
extern void msleep(unsigned);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 unixconf.h $NHDT-Date: 1607461111 2020/12/08 20:58:31 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.49 $ */
/* NetHack 3.7 unixconf.h $NHDT-Date: 1711213886 2024/03/23 17:11:26 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.57 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Pasi Kallinen, 2018. */
/* NetHack may be freely redistributed. See license for details. */
@@ -118,6 +118,21 @@
#define TIMED_DELAY
#endif
/*
* At start of game, if there are lock and level files for current
* character in the playground directory, ask whether to recover them
* (into a save file).
*/
/* #define SELF_RECOVER */
/*
* At start of game, if there is no save file to restore or lock and
* level files to recover but there is a panic save file for the current
* character, tell the player that it exists and ask whether to start a
* new game. Does not attempt to rename and restore the panic save file.
*/
#define CHECK_PANIC_SAVE
/* #define AVOID_WIN_IOCTL */ /* ensure USE_WIN_IOCTL remains undefined */
/*