- got it to start, cannot hear anything...

This commit is contained in:
Christoph Oelckers 2019-12-15 17:16:11 +01:00
parent d7ddd620e4
commit 38dc39b8cd
6 changed files with 32 additions and 14 deletions

View file

@ -273,6 +273,13 @@ void I_StartupJoysticks();
void I_ShutdownInput(); void I_ShutdownInput();
int RunGame(); int RunGame();
void ShutdownSystem()
{
Mus_Stop();
if (soundEngine) delete soundEngine;
I_ShutdownInput();
}
int GameMain() int GameMain()
{ {
// Set up the console before anything else so that it can receive text. // Set up the console before anything else so that it can receive text.
@ -295,6 +302,8 @@ int GameMain()
} }
catch (const std::runtime_error & err) catch (const std::runtime_error & err)
{ {
// shut down critical systems before showing a message box.
ShutdownSystem();
wm_msgbox("Error", "%s", err.what()); wm_msgbox("Error", "%s", err.what());
return 3; return 3;
} }
@ -303,7 +312,7 @@ int GameMain()
// Just let the rest of the function execute. // Just let the rest of the function execute.
r = exit.Reason(); r = exit.Reason();
} }
I_ShutdownInput(); ShutdownSystem();
G_SaveConfig(); G_SaveConfig();
#ifndef NETCODE_DISABLE #ifndef NETCODE_DISABLE
if (gHaveNetworking) enet_deinitialize(); if (gHaveNetworking) enet_deinitialize();
@ -550,7 +559,7 @@ void CONFIG_InitMouseAndController()
CCMD(snd_reset) CCMD(snd_reset)
{ {
Mus_Stop(); Mus_Stop();
soundEngine->Reset(); if (soundEngine) soundEngine->Reset();
MUS_ResumeSaved(); MUS_ResumeSaved();
} }

View file

@ -1705,4 +1705,4 @@ void SoundEngine::AddRandomSound(int Owner, TArray<uint32_t> list)
S_sfx[Owner].link = index; S_sfx[Owner].link = index;
S_sfx[Owner].bRandomHeader = true; S_sfx[Owner].bRandomHeader = true;
S_sfx[Owner].NearLimit = -1; S_sfx[Owner].NearLimit = -1;
} }

View file

@ -5807,6 +5807,7 @@ int GameInterface::app_main()
{ {
I_Error("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr); I_Error("app_main: There was a problem initializing the Build engine: %s\n", engineerrstr);
} }
S_InitSound();
g_logFlushWindow = 0; g_logFlushWindow = 0;

View file

@ -2255,6 +2255,7 @@ static void scriptUpdateOpcodeForVariableType(intptr_t *ins)
static bool C_ParseCommand(bool loop /*= false*/) static bool C_ParseCommand(bool loop /*= false*/)
{ {
int32_t i, j=0, k=0, tw; int32_t i, j=0, k=0, tw;
TArray<char> buffer;
do do
{ {
@ -4960,10 +4961,10 @@ repeatcase:
i = 0; i = 0;
{ {
TArray<char> build; buffer.Clear();
while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0)
{ {
build.Push(*textptr); buffer.Push(*textptr);
textptr++, i++; textptr++, i++;
if (EDUKE32_PREDICT_FALSE(*textptr != 0x0a && *textptr != 0x0d && ispecial(*textptr))) if (EDUKE32_PREDICT_FALSE(*textptr != 0x0a && *textptr != 0x0d && ispecial(*textptr)))
{ {
@ -4974,8 +4975,8 @@ repeatcase:
break; break;
} }
} }
build.Push(0); buffer.Push(0);
C_CON_SetButtonAlias(j, build.Data()); C_CON_SetButtonAlias(j, buffer.Data());
} }
continue; continue;
@ -5246,7 +5247,7 @@ repeatcase:
scriptSkipSpaces(); scriptSkipSpaces();
TArray<char> buffer; buffer.Clear();
while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0)
{ {
buffer.Push(*textptr); buffer.Push(*textptr);
@ -5362,7 +5363,6 @@ repeatcase:
case CON_DEFINESOUND: case CON_DEFINESOUND:
{ {
FString filename;
int ps, pe, vo, pr, m; int ps, pe, vo, pr, m;
float volume; float volume;
@ -5390,7 +5390,7 @@ repeatcase:
i = 0; i = 0;
C_SkipComments(); C_SkipComments();
TArray<char> buffer; buffer.Clear();
if (*textptr == '\"') if (*textptr == '\"')
{ {
@ -5421,7 +5421,7 @@ repeatcase:
vo = g_scriptPtr[-1]; vo = g_scriptPtr[-1];
g_scriptPtr -= 5; g_scriptPtr -= 5;
int res = S_DefineSound(k, filename, ps, pe, pr, m, vo, 1.f); int res = S_DefineSound(k, buffer.Data(), ps, pe, pr, m, vo, 1.f);
volume = 1.f; volume = 1.f;

View file

@ -47,6 +47,11 @@ public:
} }
}; };
void S_InitSound()
{
soundEngine = new DukeSoundEngine;
}
//========================================================================== //==========================================================================
// //
// This is to avoid hardscoding the dependency on Wads into the sound engine // This is to avoid hardscoding the dependency on Wads into the sound engine
@ -78,10 +83,12 @@ void S_PauseSounds(bool paused)
void cacheAllSounds(void) void cacheAllSounds(void)
{ {
for (int i=0, j=0; i < MAXSOUNDS; ++i) auto& sfx = soundEngine->GetSounds();
int i = 0;
for(auto &snd : sfx)
{ {
soundEngine->CacheSound(i); soundEngine->CacheSound(&snd);
if ((i&31) == 0) if (((++i)&31) == 0)
gameHandleEvents(); gameHandleEvents();
} }
} }

View file

@ -66,6 +66,7 @@ void S_Update(void);
void S_ChangeSoundPitch(int soundNum, int spriteNum, int pitchoffset); void S_ChangeSoundPitch(int soundNum, int spriteNum, int pitchoffset);
int S_GetUserFlags(int sndnum); int S_GetUserFlags(int sndnum);
int S_DefineSound(unsigned index, const char* filename, int ps, int pe, int pr, int m, int vo, float vol); int S_DefineSound(unsigned index, const char* filename, int ps, int pe, int pr, int m, int vo, float vol);
void S_InitSound();
static inline bool S_IsAmbientSFX(int spriteNum) static inline bool S_IsAmbientSFX(int spriteNum)
{ {