From 9ce3949248e40302b8474b49a42f778e933b0627 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Tue, 28 Jul 2009 05:40:26 +0000 Subject: Generalized solution to the "disconnect at --more--" problem (e.g., disconnect at the more after "You have lost your religion!" to avoid the negative consequences of excommunication): when a HUP signal is received, instead of immediately saving the game, close the stdin stream, which will cause all of the Curses calls which normal block on key-presses to unblock, so that the code after a more() call will execute before the disconnected game is saved (which will happen in _input() in acr.cc). This only affects Curses (non-tiles/console) UNIX builds which have both USE_UNIX_SIGNALS and SIGHUP_SAVE defined. Exceptions to the above: * If HUP is received during a call to yesno() with safeanswer == 0, then the game will be saved immediately, since there's no way for the function to tell which answer is safe to give automatically. * If HUP is received while selecting the target for a controlled teleport then the teleport will be canceled, since otherwise a target other than the intended one might be the one under the cursor when the disconnect happened. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10443 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'crawl-ref/source/acr.cc') diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index d325db5194..585ddc1b8f 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -885,6 +885,11 @@ static void _center_cursor() // static void _input() { +#if defined(USE_UNIX_SIGNALS) && defined(SIGHUP_SAVE) && defined(USE_CURSES) + if (crawl_state.seen_hups) + sighup_save_and_exit(); +#endif + crawl_state.clear_mon_acting(); religion_turn_start(); @@ -1029,6 +1034,11 @@ static void _input() #endif const command_type cmd = _get_next_cmd(); +#if defined(USE_UNIX_SIGNALS) && defined(SIGHUP_SAVE) && defined(USE_CURSES) + if (crawl_state.seen_hups) + sighup_save_and_exit(); +#endif + crawl_state.waiting_for_command = false; if (cmd != CMD_PREV_CMD_AGAIN && cmd != CMD_REPEAT_CMD @@ -2479,6 +2489,7 @@ static void _check_banished() if (you.level_type != LEVEL_ABYSS) { mpr("You are cast into the Abyss!"); + more(); banished(DNGN_ENTER_ABYSS, you.banished_by); } you.banished_by.clear(); -- cgit v1.2.3-54-g00ecf