From 184653fc25bf88970f5e1343086adc335035e963 Mon Sep 17 00:00:00 2001
From: helixhorned <helixhorned@1a8010ca-5511-0410-912e-c29ae57300e0>
Date: Sat, 19 Apr 2014 22:42:20 +0000
Subject: [PATCH] Keep displaying difficulty menu for as long as the *voice*
 plays.

Previously, the check was for the hard-coded sound number. This made it
impossible to change difficulty selection sounds via EVENT_SOUND.

git-svn-id: https://svn.eduke32.com/eduke32@4449 1a8010ca-5511-0410-912e-c29ae57300e0
---
 polymer/eduke32/source/menus.c  | 14 ++++++++------
 polymer/eduke32/source/menus.h  |  1 -
 polymer/eduke32/source/premap.c |  7 ++++---
 polymer/eduke32/source/sounds.h |  2 +-
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c
index c1117e35a..2b831276f 100644
--- a/polymer/eduke32/source/menus.c
+++ b/polymer/eduke32/source/menus.c
@@ -43,7 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include <sys/stat.h>
 
 extern char inputloc;
-int16_t g_skillSoundID=-1;
+int32_t g_skillSoundVoice = -1;
 int32_t probey=0; // the row number on which the menu cursor is positioned
 static int32_t lastsavehead=0,last_menu_pos=0,last_menu,sh,onbar,buttonstat;
 static int32_t last_main,last_main_ingame,last_episode,last_options,last_load = 0;
@@ -2446,23 +2446,25 @@ cheat_for_port_credits2:
         x = M_Probe(margin,ybase,19,g_numSkills);
         if (x >= 0)
         {
+            int32_t skillsound = 0;
+
             switch (x)
             {
             case 0:
-                g_skillSoundID = JIBBED_ACTOR6;
+                skillsound = JIBBED_ACTOR6;
                 break;
             case 1:
-                g_skillSoundID = BONUS_SPEECH1;
+                skillsound = BONUS_SPEECH1;
                 break;
             case 2:
-                g_skillSoundID = DUKE_GETWEAPON2;
+                skillsound = DUKE_GETWEAPON2;
                 break;
             case 3:
-                g_skillSoundID = JIBBED_ACTOR5;
+                skillsound = JIBBED_ACTOR5;
                 break;
             }
 
-            S_PlaySound(g_skillSoundID);
+            g_skillSoundVoice = S_PlaySound(skillsound);
 
             ud.m_player_skill = x+1;
             if (x == 3) ud.m_respawn_monsters = 1;
diff --git a/polymer/eduke32/source/menus.h b/polymer/eduke32/source/menus.h
index 951bfdbf6..14d8b7aab 100644
--- a/polymer/eduke32/source/menus.h
+++ b/polymer/eduke32/source/menus.h
@@ -136,7 +136,6 @@ enum MenuIndex_t {
 
 };
 extern char inputloc;
-extern int16_t g_skillSoundID;
 extern int32_t g_lastSaveSlot;
 extern int32_t g_quitDeadline;
 extern int32_t probey;
diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c
index 2306d1278..a59b1d654 100644
--- a/polymer/eduke32/source/premap.c
+++ b/polymer/eduke32/source/premap.c
@@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "gamedef.h"
 #include "premap.h"
 #include "sounds.h"
+#include "fx_man.h"
 #include "gameexec.h"
 #include "anim.h"
 #include "menus.h"
@@ -1368,13 +1369,13 @@ void G_NewGame(int32_t vn, int32_t ln, int32_t sk)
 
     G_HandleAsync();
 
-    if (g_skillSoundID >= 0 && ud.config.FXDevice >= 0 && ud.config.SoundToggle)
+    if (g_skillSoundVoice >= 0 && ud.config.FXDevice >= 0 && ud.config.SoundToggle)
     {
-        while (S_CheckSoundPlaying(-1, g_skillSoundID))
+        while (FX_SoundActive(g_skillSoundVoice))
             G_HandleAsync();
     }
 
-    g_skillSoundID = -1;
+    g_skillSoundVoice = -1;
 
     ready2send = 0;
 
diff --git a/polymer/eduke32/source/sounds.h b/polymer/eduke32/source/sounds.h
index 159691ec9..b07c93938 100644
--- a/polymer/eduke32/source/sounds.h
+++ b/polymer/eduke32/source/sounds.h
@@ -74,7 +74,7 @@ typedef struct
 
 extern volatile char g_soundlocks[MAXSOUNDS];
 extern sound_t g_sounds[MAXSOUNDS];
-extern int16_t g_skillSoundID;
+extern int32_t g_skillSoundVoice;
 extern int32_t g_numEnvSoundsPlaying,g_maxSoundPos;
 
 int32_t A_CheckSoundPlaying(int32_t i,int32_t num);