foxygit / doom Log in
commit 0a5d1795ce8fe46e20627f8a7b4ba348f2ec400e
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Mon Sep 8 17:53:36 2008 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Mon Sep 8 17:53:36 2008 +0000

    Fix disabled PC speaker sounds.

    Subversion-branch: /branches/raven-branch
    Subversion-revision: 1215
---
 src/i_pcsound.c | 36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/src/i_pcsound.c b/src/i_pcsound.c
index 500deb99..7ea545c4 100644
--- a/src/i_pcsound.c
+++ b/src/i_pcsound.c
@@ -142,6 +142,33 @@ static boolean CachePCSLump(sfxinfo_t *sfxinfo)
     return true;
 }

+// These Doom PC speaker sounds are not played - this can be seen in the
+// Heretic source code, where there are remnants of this left over
+// from Doom.
+
+static boolean IsDisabledSound(sfxinfo_t *sfxinfo)
+{
+    int i;
+    const char *disabled_sounds[] = {
+        "posact",
+        "bgact",
+        "dmact",
+        "dmpain",
+        "popain",
+        "sawidl",
+    };
+
+    for (i=0; i<arrlen(disabled_sounds); ++i)
+    {
+        if (!strcmp(sfxinfo->name, disabled_sounds[i]))
+        {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 static int I_PCS_StartSound(sfxinfo_t *sfxinfo,
                             int channel,
                             int vol,
@@ -154,17 +181,10 @@ static int I_PCS_StartSound(sfxinfo_t *sfxinfo,
         return -1;
     }

-/* TODO
-    // These PC speaker sounds are not played - this can be seen in the
-    // Heretic source code, where there are remnants of this left over
-    // from Doom.
-
-    if (id == sfx_posact || id == sfx_bgact || id == sfx_dmact
-     || id == sfx_dmpain || id == sfx_popain || id == sfx_sawidl)
+    if (IsDisabledSound(sfxinfo))
     {
         return -1;
     }
-    */

     if (SDL_LockMutex(sound_lock) < 0)
     {