]> granicus.if.org Git - nethack/commitdiff
SAFERHANGUP win ce (from <Someone>)
authornethack.allison <nethack.allison>
Tue, 30 Sep 2003 03:41:02 +0000 (03:41 +0000)
committernethack.allison <nethack.allison>
Tue, 30 Sep 2003 03:41:02 +0000 (03:41 +0000)
include/wceconf.h
sys/wince/mhinput.c
sys/wince/mhmain.c

index deb285997ff7145309f499fd1f1a6c85f3ad2741..bdea4bc81ed45ef76ebe6da6114d6339e1a57cb7 100644 (file)
 
 #define PORT_HELP      "porthelp"
 
+#define SAFERHANGUP /* Define SAFERHANGUP to delay hangup processing
+                     * until the main command loop. 'safer' because it
+                     * avoids certain cheats and also avoids losing
+                     * objects being thrown when the hangup occurs.
+                     */
+
 #if defined(WIN_CE_POCKETPC)
 #      define PORT_CE_PLATFORM "Pocket PC"
 #elif defined(WIN_CE_PS2xx)
index 53ca65d93feb6d681e3ef813ea6db00a561c2ad5..55959e9e60df989e981160d642477a9c4757803b 100644 (file)
@@ -33,7 +33,12 @@ void mswin_nh_input_init()
 /* check for input */
 int    mswin_have_input()
 {
-       return (nhi_read_pos!=nhi_write_pos);
+       return
+#ifdef SAFERHANGUP
+               /* we always have input (ESC) if hangup was requested */
+               program_state.done_hup || 
+#endif
+               (nhi_read_pos!=nhi_write_pos);
 }
 
 /* add event to the queue */
@@ -57,6 +62,16 @@ PMSNHEvent mswin_input_pop()
 {
        PMSNHEvent retval;
 
+#ifdef SAFERHANGUP
+       /* always return ESC when hangup was requested */
+       if( program_state.done_hup ) {
+               static MSNHEvent hangup_event;
+               hangup_event.type = NHEVENT_CHAR;
+               hangup_event.kbd.ch = '\033';
+               return &hangup_event;
+       }
+#endif
+
        if( !nhi_init_input ) mswin_nh_input_init();
 
        if( nhi_read_pos!=nhi_write_pos ) {
@@ -74,6 +89,16 @@ PMSNHEvent mswin_input_peek()
 {
        PMSNHEvent retval;
 
+#ifdef SAFERHANGUP
+       /* always return ESC when hangup was requested */
+       if( program_state.done_hup ) {
+               static MSNHEvent hangup_event;
+               hangup_event.type = NHEVENT_CHAR;
+               hangup_event.kbd.ch = '\033';
+               return &hangup_event;
+       }
+#endif
+
        if( !nhi_init_input ) mswin_nh_input_init();
 
        if( nhi_read_pos!=nhi_write_pos ) {
index 31e3ba69cb1fda147d5c1cac7630daf1e1815969..6edc8755bb488ae44a30d8cc42cd11665f7bb0c0 100644 (file)
@@ -480,7 +480,18 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
                case WM_CLOSE: 
                {
                        /* exit gracefully */
+#ifdef SAFERHANGUP
+                       /* destroy popup window - it has its own loop and we need to 
+                          return control to NetHack core at this point */
+                       if( IsWindow( GetNHApp()->hPopupWnd ) )
+                               SendMessage( GetNHApp()->hPopupWnd, WM_COMMAND, IDCANCEL, 0);
+
+                       /* tell NetHack core that "hangup" is requested */
+                       hangup(1);
+#else
                        dosave0();
+                       terminate(EXIT_SUCCESS);
+#endif
                } return 0;
 
                /*-----------------------------------------------------------------------*/