]> granicus.if.org Git - nethack/commitdiff
win32gui: -s and -? on the command line
authornethack.allison <nethack.allison>
Sun, 14 Jul 2002 19:50:25 +0000 (19:50 +0000)
committernethack.allison <nethack.allison>
Sun, 14 Jul 2002 19:50:25 +0000 (19:50 +0000)
Since -s doesn't function properly under the WIN32
graphical interface as yet, disable it altogether.

Also clean up nhusage() so that it does work with
the WIN32 graphical interface.

sys/share/pcmain.c

index 58d87dd57d707c45cc61b6699af4286d96fb9cc8..93495158c0804768c9a2d2bf7e563e45cd4779f6 100644 (file)
@@ -217,12 +217,17 @@ char *argv[];
                 * may do a prscore().
                 */
                if (!strncmp(argv[1], "-s", 2)) {
-#ifdef CHDIR
+#if !defined(MSWIN_GRAPHICS)
+# ifdef CHDIR
                        chdirx(hackdir,0);
-#endif
+# endif
                        prscore(argc, argv);
+#else
+                       raw_printf("-s is not supported for the Graphical Interface\n");
+#endif /*MSWIN_GRAPHICS*/
                        nethack_exit(EXIT_SUCCESS);
                }
+               
                /* Don't initialize the window system just to print usage */
                if (!strncmp(argv[1], "-?", 2) || !strncmp(argv[1], "/?", 2)) {
                        nhusage();
@@ -555,39 +560,44 @@ char *argv[];
 STATIC_OVL void 
 nhusage()
 {
-       char buf1[BUFSZ];
+       char buf1[BUFSZ], buf2[BUFSZ], *bufptr;
+
+       buf1[0] = '\0';
+       bufptr = buf1;
+
+#define ADD_USAGE(s)   if (strlen(buf1) < ((BUFSZ - strlen(s)) + 1)) Strcat(bufptr, s);
 
        /* -role still works for those cases which aren't already taken, but
         * is deprecated and will not be listed here.
         */
-       (void) Sprintf(buf1,
-"\nUsage: %s [-d dir] -s [-r race] [-p profession] [maxrank] [name]...\n       or",
+       (void) Sprintf(buf2,
+"\nUsage:\n%s [-d dir] -s [-r race] [-p profession] [maxrank] [name]...\n       or",
                hname);
-       if (!iflags.window_inited)
-               raw_printf(buf1);
-       else
-               (void)  printf(buf1);
-       (void) Sprintf(buf1,
-        "\n       %s [-d dir] [-u name] [-r race] [-p profession] [-[DX]]",
+       ADD_USAGE(buf2);
+
+       (void) Sprintf(buf2,
+        "\n%s [-d dir] [-u name] [-r race] [-p profession] [-[DX]]",
                hname);
+       ADD_USAGE(buf2);
 #ifdef NEWS
-       Strcat(buf1," [-n]");
+       ADD_USAGE(" [-n]");
 #endif
 #ifndef AMIGA
-       Strcat(buf1," [-I] [-i] [-d]");
+       ADD_USAGE(" [-I] [-i] [-d]");
 #endif
 #ifdef MFLOPPY
 # ifndef AMIGA
-       Strcat(buf1," [-R]");
+       ADD_USAGE(" [-R]");
 # endif
 #endif
 #ifdef AMIGA
-       Strcat(buf1," [-[lL]]");
+       ADD_USAGE(" [-[lL]]");
 #endif
        if (!iflags.window_inited)
                raw_printf("%s\n",buf1);
        else
                (void) printf("%s\n",buf1);
+#undef ADD_USAGE
 }
 
 #ifdef CHDIR