]> granicus.if.org Git - nethack/commitdiff
more startup tweaking for Windows
authornhmall <nhmall@nethack.org>
Sun, 9 Dec 2018 02:17:34 +0000 (21:17 -0500)
committernhmall <nhmall@nethack.org>
Sun, 9 Dec 2018 02:17:34 +0000 (21:17 -0500)
sys/winnt/windmain.c
sys/winnt/winnt.c
win/win32/winhack.c

index 9768a8e6ffe48b427eaf28e2f7b4a4fc8822b65c..72bf24c1140ff94b2e93e0d2a4975ff97de3654a 100644 (file)
@@ -241,16 +241,20 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
             Strcpy(hackdir, dir);
         }
         if (argc > 1) {
+#if 0
 #if !defined(TTY_GRAPHICS)
             int sfd = 0;
             boolean tmpconsole = FALSE;
             hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
 #endif
+#endif /* 0 */
+
             /*
              * Now we know the directory containing 'record' and
              * may do a prscore().
              */
             if (!strncmp(argv[1], "-s", 2)) {
+#if 0
 #if !defined(TTY_GRAPHICS)
                 /*
                  * Check to see if we're redirecting to a file.
@@ -264,11 +268,13 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
                     nethack_exit(EXIT_SUCCESS);
                 }
 #endif
+#endif /* 0 */
 #ifdef SYSCF
                 initoptions();
 #endif
                 prscore(argc, argv);
 
+#if 0
 #if !defined(TTY_GRAPHICS)
                 if (tmpconsole) {
                     getreturn("to exit");
@@ -276,25 +282,26 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
                     tmpconsole = FALSE;
                 }
 #endif
+#endif /* 0 */
                 nethack_exit(EXIT_SUCCESS);
             }
-
-#if defined(MSWIN_GRAPHICS)
-            if (!strncmpi(argv[1], "-clearreg", 6)) { /* clear registry */
-                mswin_destroy_reg();
-                nethack_exit(EXIT_SUCCESS);
+            if (GUILaunched) {
+                if (!strncmpi(argv[1], "-clearreg", 6)) { /* clear registry */
+                    mswin_destroy_reg();
+                    nethack_exit(EXIT_SUCCESS);
+                }
             }
-#endif
-            /* Don't initialize the window system just to print usage */
+            /* Don't initialize the full window system just to print usage */
             if (!strncmp(argv[1], "-?", 2) || !strncmp(argv[1], "/?", 2)) {
                 nhusage();
-
+#if 0
 #if !defined(TTY_GRAPHICS)
                 if (tmpconsole) {
                     getreturn("to exit");
                     freefakeconsole();
                     tmpconsole = FALSE;
                 }
+#endif
 #endif
                 nethack_exit(EXIT_SUCCESS);
             }
@@ -313,18 +320,19 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
 
     if (argc >= 1
         && !strcmpi(default_window_sys, "mswin")
-        && strstri(argv[0], "nethackw.exe"))
+        && (strstri(argv[0], "nethackw.exe") || GUILaunched))
             iflags.windowtype_locked = TRUE;
 
+    if (!iflags.windowtype_locked) {
 #if defined(TTY_GRAPHICS)
-    if (!iflags.windowtype_locked)
         Strcpy(default_window_sys, "tty");
 #else
 #if defined(CURSES_GRAPHICS)
-    if (!iflags.windowtype_locked)
         Strcpy(default_window_sys, "curses");    
-#endif
-#endif
+#endif /* CURSES */
+#endif /* TTY */
+    }
+
     choose_windows(default_window_sys);
     if (!dlb_init()) {
         pline(
index f5121bddcd9905d3f924236687f650336650ae00..c5c214f19a4791f06ce00ffeed363ecb3e9682af 100644 (file)
@@ -495,12 +495,12 @@ void nhassert_failed(const char * exp, const char * file, int line)
     error(message);
 }
 
-/* nethack_enter_winnt() is the first thing called from main */
+/* nethack_enter_winnt() is called from main immediately after
+   initializing the window port */
 void nethack_enter_winnt()
 {
-#ifdef TTY_GRAPHICS
-    nethack_enter_nttty();
-#endif
+       if (WINDOWPORT("tty"))
+               nethack_enter_nttty();
 }
 
 /* CP437 to Unicode mapping according to the Unicode Consortium */
index 6796a5ce6990fb179490d89abbd3d86c5411aaac..c6941d7c05a2d723db318c4932a3baaa69fefdde 100644 (file)
@@ -63,6 +63,8 @@ _nhapply_image_transparent(HDC hDC, int x, int y, int width, int height,
 
 // Global Variables:
 NHWinApp _nethack_app;
+extern int GUILaunched;     /* We tell shared startup code in windmain.c
+                               that the GUI was launched via this */
 
 #ifdef __BORLANDC__
 #define _stricmp(s1, s2) stricmp(s1, s2)
@@ -233,7 +235,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
         }
         free(savefile);
     }
-
+    GUILaunched = 1;
     /* let main do the argument processing */
     (void) main(argc, argv);
     return 0;