Browse Source

Minor bits:

- Consolidate FMOD closing code into a single method
- Added some experimental (commented-out) code to test running multiple instances of Quake
- Extra validation checks in FMOD music code
- Removed QuakeSpasm "feature" that skipped the demo reel at startup
console
Nico de Poel 5 years ago
parent
commit
548b72aed1
  1. 14
      Assets/Scripts/AudioManager.cs
  2. 8
      Assets/Scripts/UniQuake.cs
  3. 6
      engine/Quake/bgmusic.c
  4. 7
      engine/Quake/host_cmd.c

14
Assets/Scripts/AudioManager.cs

@ -54,22 +54,22 @@ public class AudioManager : MonoBehaviour
result = fmodSystem.init(MaxChannels, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
CheckFmodResult(result, "FMOD.System.init");
}
void OnDestroy()
{
CloseFmod();
}
private void CheckFmodResult(FMOD.RESULT result, string cause)
{
if (result != FMOD.RESULT.OK)
{
if (fmodSystem.hasHandle())
{
fmodSystem.close();
fmodSystem.release();
fmodSystem.clearHandle();
}
CloseFmod();
throw new Exception($"[FMOD] Initialization failed : {cause} : {result.ToString()} : {FMOD.Error.String(result)}");
}
}
private void OnDestroy()
private void CloseFmod()
{
if (fmodSystem.hasHandle())
{

8
Assets/Scripts/UniQuake.cs

@ -169,6 +169,14 @@ public class UniQuake: MonoBehaviour
private void LoadLibrary()
{
string dllFile = Path.Combine(Application.dataPath, DllPath);
// Experimental code to allow running multiple instances of Quake next to each other
// string dllName = Path.GetFileNameWithoutExtension(dllFile);
// string dllExt = Path.GetExtension(dllFile);
// string dllCopy = Path.Combine(Application.persistentDataPath, $"{dllName}{GetInstanceID()}{dllExt}");
// File.Copy(dllFile, dllCopy, true);
// dllFile = dllCopy;
libraryHandle = SystemLibrary.LoadLibrary(dllFile);
if (libraryHandle == IntPtr.Zero)
{

6
engine/Quake/bgmusic.c

@ -141,6 +141,12 @@ static qboolean BGM_PlayStream(const char *filename)
FMOD_CREATESOUNDEXINFO exinfo;
FMOD_RESULT result;
if (!fmod_system || !bgm_channelGroup)
{
Con_Printf("FMOD System not initialized, cannot play BGM\n");
return false;
}
len = COM_FOpenFile(filename, &f, NULL);
fclose(f);
if (len < 1)

7
engine/Quake/host_cmd.c

@ -2230,13 +2230,6 @@ void Host_Startdemos_f (void)
if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
{
cls.demonum = 0;
if (!fitzmode)
{ /* QuakeSpasm customization: */
/* go straight to menu, no CL_NextDemo */
cls.demonum = -1;
Cbuf_InsertText("menu_main\n");
return;
}
CL_NextDemo ();
}
else

Loading…
Cancel
Save