From e93303eae4ca605d116a4c281541c55d53e67da9 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Fri, 19 Jan 2007 03:02:05 +0000 Subject: [PATCH] hangup tweaks (trunk only) Fix a typo in some conditional (NOSAVEONHANGUP) code, and tweak SAFERHANGUP so that it doesn't defer hangup handling if the game hasn't started yet or has already finished (it's possible to be waiting for a --More-- prompt at end of game code before the hangup handler is reset, so the regular handler could be called in that state). Also, undefine SAFERHANGUP if NOSAVEONHANGUP is defined, since there's no point in deferring hangup for the latter. --- include/global.h | 2 +- src/cmd.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/global.h b/include/global.h index f98c53936..24d94b74f 100644 --- a/include/global.h +++ b/include/global.h @@ -272,7 +272,7 @@ typedef char nhptext; #if defined(UNIX) || defined(VMS) || defined(__EMX__) || defined(WIN32) # define HANGUPHANDLING #endif -#if defined(SAFERHANGUP) && !defined(HANGUPHANDLING) +#if defined(SAFERHANGUP) && (defined(NOSAVEONHANGUP) || !defined(HANGUPHANDLING)) # undef SAFERHANGUP #endif diff --git a/src/cmd.c b/src/cmd.c index 9d6f43f99..e123aeb86 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -2798,6 +2798,9 @@ parse() } #ifdef HANGUPHANDLING +/* some very old systems, or descendents of such systems, expect signal + handlers to have return type `int', but they don't actually inspect + the return value so we should be safe using `void' unconditionally */ /*ARGUSED*/ void hangup(sig_unused) /* called as signal() handler, so sent at least one arg */ @@ -2812,16 +2815,17 @@ int sig_unused; but also potentially riskier because the disconnected program must continue running longer before attempting a hangup save. */ program_state.done_hup++; -# else + /* defer hangup iff game appears to be in progress */ + if (program_state.something_worth_saving) return; +# endif /* SAFERHANGUP */ end_of_input(); -# endif /* ?SAFERHANGUP */ } void end_of_input() { # ifdef NOSAVEONHANGUP - program_state_something_worth_saving = 0; + program_state.something_worth_saving = 0; # endif # ifndef SAFERHANGUP if (!program_state.done_hup++)