]> granicus.if.org Git - nethack/commitdiff
\#version warning fix
authorPatR <rankin@nethack.org>
Thu, 26 Jan 2023 17:10:24 +0000 (09:10 -0800)
committerPatR <rankin@nethack.org>
Thu, 26 Jan 2023 17:10:24 +0000 (09:10 -0800)
Avoid #ifdef/#else/#endif inside expansion of Strcat() macro.

Also, change constructed
|soundlib_nosound, soundlib_macsound, and soundlib_qtsound, user sounds.
to be
|nosound, macsound, qtsound, and user sounds.

OPTIONS=soundlib:somelib doesn't--or won't, when finished being
implemented--include the "soundlib_" prefix in the user-visible
value, and placement of "and" vs "user sounds" was odd.

The code should probably be reorganized so that makedefs can put that
into dat/options or at least have it put a placeholder for the missing
paragraph.

src/mdlib.c

index 0136dfe36f2efaa39523d4e7ff0a287af1055ee4..0afae3b0736f132657d84dfe390afde66334d03f 100644 (file)
@@ -861,26 +861,28 @@ build_options(void)
     optbuf[0] = '\0';
     length = COLNO + 1; /* force 1st item onto new line */
 
+#ifdef USER_SOUNDS
+    soundlibcnt += 1;
+#endif
     for (i = 0; i < SIZE(soundlib_opts) - 1; i++) {
+        const char *soundlib;
+
         if (!soundlib_opts[i].valid)
             continue;
-        Sprintf(buf, "\"%s\"", soundlib_opts[i].text_id);
+        soundlib = soundlib_opts[i].text_id;
+        if (!strncmp(soundlib, "soundlib_", 9))
+            soundlib += 9;
+        Sprintf(buf, "\"%s\"", soundlib);
         /*
          * 1 : foo.
-         * 2 : foo and bar,
-         * 3+: for, bar, and quux,
-         *
-         * 2+ will be followed by " with a default of..."
+         * 2 : foo and bar.
+         * 3+: for, bar, and quux.
          */
-        Strcat(buf, (soundlibcnt == 1) ? "." /* no 'default' */
+        Strcat(buf, (soundlibcnt == 1 || cnt == soundlibcnt - 1)
+                    ? "." /* no 'with default' */
                     : (soundlibcnt == 2 && cnt == 0) ? " and"
                       : (cnt == soundlibcnt - 2) ? ", and"
-#ifdef USER_SOUNDS
-                        : ","
-#else
-                        : "."
-#endif
-        );
+                        : ",");
         opt_out_words(buf, &length);
         cnt++;
     }