Browse Source

Allow passing of player number to FMOD for split-screen purposes. Not used for anything yet, but it's handy to have it in there already.

console
Nico de Poel 5 years ago
parent
commit
11cdaf7a75
  1. 2
      Assets/Scripts/UniQuake.Interop.cs
  2. 7
      engine/Quake/snd_fmod.c
  3. 4
      engine/UniQuake/uniquake.c

2
Assets/Scripts/UniQuake.Interop.cs

@ -30,7 +30,7 @@ public partial class UniQuake
private UniQuake_ShutdownFunc UniQuake_Shutdown; private UniQuake_ShutdownFunc UniQuake_Shutdown;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void UniQuake_SetFmodSystemFunc(IntPtr fmodSystem);
private delegate void UniQuake_SetFmodSystemFunc(IntPtr fmodSystem, int playerNumber = 0);
private UniQuake_SetFmodSystemFunc UniQuake_SetFmodSystem; private UniQuake_SetFmodSystemFunc UniQuake_SetFmodSystem;
private void LoadLibrary() private void LoadLibrary()

7
engine/Quake/snd_fmod.c

@ -9,6 +9,8 @@ extern sfx_t *known_sfx;
extern int num_sfx; extern int num_sfx;
FMOD_SYSTEM *fmod_system = NULL; FMOD_SYSTEM *fmod_system = NULL;
int fmod_playernumber = 0;
static qboolean fmod_ownership = false; static qboolean fmod_ownership = false;
static int fmod_samplerate; static int fmod_samplerate;
static float old_volume = -1.0f; static float old_volume = -1.0f;
@ -334,7 +336,7 @@ static void S_UpdateAmbientSounds()
mleaf_t *leaf; mleaf_t *leaf;
float vol, channel_vol; float vol, channel_vol;
if (cl.worldmodel && cl.worldmodel->nodes)
if (cls.state == ca_connected && cl.worldmodel && cl.worldmodel->nodes)
leaf = Mod_PointInLeaf(listener_origin, cl.worldmodel); leaf = Mod_PointInLeaf(listener_origin, cl.worldmodel);
else else
leaf = NULL; leaf = NULL;
@ -566,8 +568,7 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
FMOD_VectorCopy(forward, fmod_forward); FMOD_VectorCopy(forward, fmod_forward);
FMOD_VectorCopy(up, fmod_up); FMOD_VectorCopy(up, fmod_up);
// TODO: set listener number based on player ID (for split-screen)
FMOD_System_Set3DListenerAttributes(fmod_system, 0, &fmod_pos, NULL, &fmod_forward, &fmod_up);
FMOD_System_Set3DListenerAttributes(fmod_system, fmod_playernumber, &fmod_pos, NULL, &fmod_forward, &fmod_up);
FMOD_ChannelGroup_SetVolume(sfx_channelGroup, sfxvolume.value); FMOD_ChannelGroup_SetVolume(sfx_channelGroup, sfxvolume.value);

4
engine/UniQuake/uniquake.c

@ -5,10 +5,12 @@
#if USE_FMOD #if USE_FMOD
typedef struct FMOD_SYSTEM FMOD_SYSTEM; typedef struct FMOD_SYSTEM FMOD_SYSTEM;
extern FMOD_SYSTEM *fmod_system; extern FMOD_SYSTEM *fmod_system;
extern int fmod_playernumber;
UNIQUAKE_API void UniQuake_SetFmodSystem(FMOD_SYSTEM *system)
UNIQUAKE_API void UniQuake_SetFmodSystem(FMOD_SYSTEM *system, int playernumber)
{ {
fmod_system = system; fmod_system = system;
fmod_playernumber = playernumber;
} }
#endif #endif

Loading…
Cancel
Save