summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/directn.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-07-28 05:40:26 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-07-28 05:40:26 +0000
commit9ce3949248e40302b8474b49a42f778e933b0627 (patch)
tree94438e6811566834e0d210e3eaa1e71bf266a724 /crawl-ref/source/directn.cc
parent72c1249ae7f4841dc8b335cb3a0a5ce81cb45887 (diff)
downloadcrawl-ref-9ce3949248e40302b8474b49a42f778e933b0627.tar.gz
crawl-ref-9ce3949248e40302b8474b49a42f778e933b0627.zip
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
Diffstat (limited to 'crawl-ref/source/directn.cc')
-rw-r--r--crawl-ref/source/directn.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 092e6b14b0..1e162049f6 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -138,6 +138,19 @@ void direction_choose_compass( dist& moves, targeting_behaviour *beh)
{
const command_type key_command = beh->get_command();
+#if defined(USE_UNIX_SIGNALS) && defined(SIGHUP_SAVE) && defined(USE_CURSES)
+ // If we've received a HUP signal then the user can't choose a
+ // target.
+ if (crawl_state.seen_hups)
+ {
+ moves.isValid = false;
+ moves.isCancel = true;
+
+ mpr("Targetting interrupted by HUP signal.", MSGCH_ERROR);
+ return;
+ }
+#endif
+
#ifdef USE_TILE
if (key_command == CMD_TARGET_MOUSE_MOVE)
{
@@ -1064,6 +1077,19 @@ void direction(dist& moves, targeting_type restricts,
while (true)
{
+#if defined(USE_UNIX_SIGNALS) && defined(SIGHUP_SAVE) && defined(USE_CURSES)
+ // If we've received a HUP signal then the user can't choose a
+ // target.
+ if (crawl_state.seen_hups)
+ {
+ moves.isValid = false;
+ moves.isCancel = true;
+
+ mpr("Targetting interrupted by HUP signal.", MSGCH_ERROR);
+ return;
+ }
+#endif
+
bool allow_out_of_range = false;
// Prompts might get scrolled off if you have too few lines available.