Self-recover for linux
Compile-time option SELF_RECOVER was implemented for Windows; add it to unix systems too, with it being on by default when compiling with the linux hints file.
This commit is contained in:
@@ -2211,6 +2211,7 @@ sound: add 'qtsound' soundlib implementation for use on any platform
|
|||||||
documentation: when building plain text Guidebook.txt from Guidebook.mn, avoid
|
documentation: when building plain text Guidebook.txt from Guidebook.mn, avoid
|
||||||
attempting to use CR font; change doesn't affect building Guidebook.ps
|
attempting to use CR font; change doesn't affect building Guidebook.ps
|
||||||
which utilizes CR to get various instances of fixed-width text
|
which utilizes CR to get various instances of fixed-width text
|
||||||
|
Unix: implement SELF_RECOVER compile-time option, on by default on linux
|
||||||
|
|
||||||
|
|
||||||
General New Features
|
General New Features
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ NHCFLAGS+=-DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\"
|
|||||||
#NHCFLAGS+=-DTTY_SOUND_ESCCODES
|
#NHCFLAGS+=-DTTY_SOUND_ESCCODES
|
||||||
#NHCFLAGS+=-DNO_CHRONICLE
|
#NHCFLAGS+=-DNO_CHRONICLE
|
||||||
#NHCFLAGS+=-DLIVELOG
|
#NHCFLAGS+=-DLIVELOG
|
||||||
|
NHCFLAGS+=-DSELF_RECOVER
|
||||||
ifdef WANT_WIN_CURSES
|
ifdef WANT_WIN_CURSES
|
||||||
ifeq "$(HAVE_NCURSESW)" "1"
|
ifeq "$(HAVE_NCURSESW)" "1"
|
||||||
NHCFLAGS+=-DCURSES_UNICODE
|
NHCFLAGS+=-DCURSES_UNICODE
|
||||||
|
|||||||
@@ -276,6 +276,9 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (gp.program_state.in_self_recover) {
|
||||||
|
gp.program_state.in_self_recover = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resuming) {
|
if (!resuming) {
|
||||||
|
|||||||
@@ -102,8 +102,10 @@ eraseoldlocks(void)
|
|||||||
void
|
void
|
||||||
getlock(void)
|
getlock(void)
|
||||||
{
|
{
|
||||||
|
#ifndef SELF_RECOVER
|
||||||
static const char destroy_old_game_prompt[] =
|
static const char destroy_old_game_prompt[] =
|
||||||
"There is already a game in progress under your name. Destroy old game?";
|
"There is already a game in progress under your name. Destroy old game?";
|
||||||
|
#endif
|
||||||
int i = 0, fd, c, too_old;
|
int i = 0, fd, c, too_old;
|
||||||
const char *fq_lock;
|
const char *fq_lock;
|
||||||
|
|
||||||
@@ -176,10 +178,27 @@ getlock(void)
|
|||||||
if (too_old && eraseoldlocks())
|
if (too_old && eraseoldlocks())
|
||||||
goto gotlock;
|
goto gotlock;
|
||||||
|
|
||||||
|
/* drop the "perm" lock while the user decides */
|
||||||
|
unlock_file(HLOCK);
|
||||||
if (iflags.window_inited) {
|
if (iflags.window_inited) {
|
||||||
|
#ifdef SELF_RECOVER
|
||||||
|
c = yn_function("Old game in progress. Destroy [y], Recover [r], or Cancel [n]?", "ynr", 'n', FALSE);
|
||||||
|
#else
|
||||||
/* this is a candidate for paranoid_confirmation */
|
/* this is a candidate for paranoid_confirmation */
|
||||||
c = y_n(destroy_old_game_prompt);
|
c = y_n(destroy_old_game_prompt);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef SELF_RECOVER
|
||||||
|
(void) raw_printf("\nThere is already a game in progress under your name. Do what?\n");
|
||||||
|
(void) raw_printf("\n y - Destroy old game");
|
||||||
|
(void) raw_printf("\n r - Try to recover it");
|
||||||
|
(void) raw_printf("\n n - Cancel");
|
||||||
|
(void) raw_printf("\n\n => ");
|
||||||
|
(void) fflush(stdout);
|
||||||
|
do {
|
||||||
|
c = getchar();
|
||||||
|
} while (!strchr("rRyYnN", c) && c != -1);
|
||||||
|
#else
|
||||||
(void) raw_printf("\n%s [yn] ", destroy_old_game_prompt);
|
(void) raw_printf("\n%s [yn] ", destroy_old_game_prompt);
|
||||||
(void) fflush(stdout);
|
(void) fflush(stdout);
|
||||||
if ((c = getchar()) != EOF) {
|
if ((c = getchar()) != EOF) {
|
||||||
@@ -190,7 +209,20 @@ getlock(void)
|
|||||||
while ((tmp = getchar()) != '\n' && tmp != EOF)
|
while ((tmp = getchar()) != '\n' && tmp != EOF)
|
||||||
; /* eat rest of line and newline */
|
; /* eat rest of line and newline */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef SELF_RECOVER
|
||||||
|
if (c == 'r' || c == 'R') {
|
||||||
|
if (recover_savefile() && gp.program_state.in_self_recover) {
|
||||||
|
set_levelfile_name(gl.lock, 0);
|
||||||
|
fq_lock = fqname(gl.lock, LEVELPREFIX, 0);
|
||||||
|
goto gotlock;
|
||||||
|
} else {
|
||||||
|
unlock_file(HLOCK);
|
||||||
|
error("Couldn't recover old game.");
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
if (c == 'y' || c == 'Y') {
|
if (c == 'y' || c == 'Y') {
|
||||||
if (eraseoldlocks()) {
|
if (eraseoldlocks()) {
|
||||||
goto gotlock;
|
goto gotlock;
|
||||||
|
|||||||
Reference in New Issue
Block a user