From b1b33ef23133b45208b380cdd5fbfda84edc588c Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Mon, 16 Dec 2019 09:19:04 +0100
Subject: [PATCH] - fixed hang with skill sound on game start.

This waits inside code where S_Update wasn't called. To make things clearer the waiting loop was moved closer to where it gets played.
---
 source/duke3d/src/d_menu.cpp   | 11 ++++++++---
 source/duke3d/src/game.h       |  2 +-
 source/duke3d/src/premap.cpp   |  7 -------
 source/duke3d/src/savegame.cpp |  1 -
 4 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/source/duke3d/src/d_menu.cpp b/source/duke3d/src/d_menu.cpp
index 497db18f1..50d42d6af 100644
--- a/source/duke3d/src/d_menu.cpp
+++ b/source/duke3d/src/d_menu.cpp
@@ -568,10 +568,15 @@ void GameInterface::StartGame(FGameStartup& gs)
 	}
 
 	ud.m_player_skill = gs.Skill + 1;
-	if (menu_sounds)
+	if (menu_sounds && skillsound >= 0 && SoundEnabled())
 	{
-		ud.skill_voice = skillsound;
-		S_PlaySound(skillsound);
+		S_PlaySound(skillsound, CHAN_UI);
+
+		while (S_CheckSoundPlaying(skillsound))
+		{
+			S_Update();
+			gameHandleEvents();
+		}
 	}
 	ud.m_respawn_monsters = (gs.Skill == 3);
 	ud.m_monsters_off = ud.monsters_off = 0;
diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h
index 4b77984cf..4c03b754a 100644
--- a/source/duke3d/src/game.h
+++ b/source/duke3d/src/game.h
@@ -157,7 +157,7 @@ typedef struct {
     int32_t m_respawn_items,m_respawn_monsters,m_respawn_inventory,m_monsters_off;
     int32_t ffire,m_player_skill,m_level_number,m_volume_number,multimode;
     int32_t player_skill,level_number,volume_number,marker;
-    int32_t music_episode, music_level, skill_voice;
+    int32_t music_episode, music_level;
 
     int32_t playerbest;
 
diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp
index 3ddb516bc..62a75daa4 100644
--- a/source/duke3d/src/premap.cpp
+++ b/source/duke3d/src/premap.cpp
@@ -1320,12 +1320,6 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum)
 
     gameHandleEvents();
 
-    if (ud.skill_voice > 0 && SoundEnabled())
-    {
-        while (S_CheckSoundPlaying(ud.skill_voice))
-            gameHandleEvents();
-    }
-
     ready2send = 0;
 
     if (m_recstat != 2 && ud.last_level != -1 && !VM_OnEventWithReturn(EVENT_EXITGAMESCREEN, g_player[myconnectindex].ps->i, myconnectindex, 0)
@@ -1339,7 +1333,6 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum)
     ud.level_number  = levelNum;
     ud.player_skill  = skillNum;
     ud.secretlevel   = 0;
-    ud.skill_voice   = -1;
     ud.volume_number = volumeNum;
 
     // we don't want the intro to play after the multiplayer setup screen
diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp
index 9c62f961a..7321deede 100644
--- a/source/duke3d/src/savegame.cpp
+++ b/source/duke3d/src/savegame.cpp
@@ -313,7 +313,6 @@ int32_t G_LoadPlayer(FSaveGameNode *sv)
             ud.level_number  = level;
             ud.player_skill  = skill;
             ud.secretlevel   = 0;
-            ud.skill_voice   = -1;
             ud.volume_number = volume;
 
 #ifdef EDUKE32_TOUCH_DEVICES