feat(sound): add SI2::InitSoundKitGroups

This commit is contained in:
fallenoak 2025-11-22 13:32:45 -06:00
parent a83a70c0e5
commit 55e67b0dbf
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
5 changed files with 39 additions and 3 deletions

View File

@ -18,6 +18,23 @@ void FSoundFreeCallback(void* ptr, FMOD_MEMORY_TYPE type, const char *sourcestr)
SMemFree(ptr, "FMod", 0, 0x0); SMemFree(ptr, "FMod", 0, 0x0);
} }
FMOD::SoundGroup* SESound::CreateSoundGroup(const char* name, int32_t maxAudible) {
FMOD::SoundGroup* group = nullptr;
FMOD_RESULT result;
result = SESound::s_pGameSystem->createSoundGroup(name, &group);
if (result != FMOD_OK && result != FMOD_ERR_CHANNEL_STOLEN && result != FMOD_ERR_INVALID_HANDLE && result != FMOD_ERR_OUTPUT_DRIVERCALL) {
LOG_WRITE(result, "");
}
result = group->setMaxAudible(maxAudible);
if (result != FMOD_OK && result != FMOD_ERR_CHANNEL_STOLEN && result != FMOD_ERR_INVALID_HANDLE && result != FMOD_ERR_OUTPUT_DRIVERCALL) {
LOG_WRITE(result, "");
}
return group;
}
void SESound::Init(int32_t maxChannels, int32_t* a2, int32_t enableReverb, int32_t enableSoftwareHRTF, int32_t* numChannels, int32_t* outputDriverIndex, const char* outputDriverName, void* a8, int32_t a9) { void SESound::Init(int32_t maxChannels, int32_t* a2, int32_t enableReverb, int32_t enableSoftwareHRTF, int32_t* numChannels, int32_t* outputDriverIndex, const char* outputDriverName, void* a8, int32_t a9) {
// TODO // TODO

View File

@ -10,6 +10,7 @@ class SESound {
static FMOD::System* s_pGameSystem; static FMOD::System* s_pGameSystem;
// Static functions // Static functions
static FMOD::SoundGroup* CreateSoundGroup(const char* name, int32_t maxAudible);
static void Init(int32_t maxChannels, int32_t (*a2), int32_t enableReverb, int32_t enableSoftwareHRTF, int32_t* numChannels, int32_t* outputDriverIndex, const char* outputDriverName, void (*a8), int32_t a9); static void Init(int32_t maxChannels, int32_t (*a2), int32_t enableReverb, int32_t enableSoftwareHRTF, int32_t* numChannels, int32_t* outputDriverIndex, const char* outputDriverName, void (*a8), int32_t a9);
static void Log_Write(int32_t line, const char* file, FMOD_RESULT result, const char* fmt, ...); static void Log_Write(int32_t line, const char* file, FMOD_RESULT result, const char* fmt, ...);
}; };

View File

@ -97,8 +97,11 @@ int32_t SI2::Init(int32_t a1) {
if (!a1) { if (!a1) {
SI2::InitSoundKitDefs(); SI2::InitSoundKitDefs();
// TODO
} }
SI2::InitSoundKitGroups();
// TODO // TODO
return 0; return 0;
@ -176,6 +179,17 @@ void SI2::InitSoundKitDefs() {
} }
} }
void SI2::InitSoundKitGroups() {
for (uint32_t i = 0; i < SI2::s_SoundKitDefs.Count(); i++) {
auto soundKitDef = SI2::s_SoundKitDefs[i];
if (soundKitDef && soundKitDef->name) {
soundKitDef->soundGroup1 = SESound::CreateSoundGroup(soundKitDef->name, 3);
soundKitDef->soundGroup2 = SESound::CreateSoundGroup(soundKitDef->name, 3);
}
}
}
void SI2::RegisterCVars() { void SI2::RegisterCVars() {
CVar::Register( CVar::Register(
"StartTalkingDelay", "StartTalkingDelay",

View File

@ -1,15 +1,15 @@
#ifndef SOUND_SI2_HPP #ifndef SOUND_SI2_HPP
#define SOUND_SI2_HPP #define SOUND_SI2_HPP
#include "SOUNDKITLOOKUP.hpp"
#include "sound/SI2Script.hpp" #include "sound/SI2Script.hpp"
#include "storm/hash/Hashkey.hpp" #include "storm/hash/Hashkey.hpp"
#include "storm/hash/TSHashTable.hpp" #include "storm/hash/TSHashTable.hpp"
#include "ui/Types.hpp" #include "ui/Types.hpp"
#include <cstdint>
#include <storm/Array.hpp> #include <storm/Array.hpp>
#include <cstdint>
class SOUNDKITDEF; class SOUNDKITDEF;
struct SOUNDKITLOOKUP;
class SI2 { class SI2 {
public: public:
@ -21,6 +21,7 @@ class SI2 {
// Static functions // Static functions
static int32_t Init(int32_t a1); static int32_t Init(int32_t a1);
static void InitSoundKitDefs(); static void InitSoundKitDefs();
static void InitSoundKitGroups();
static void RegisterCVars(); static void RegisterCVars();
static void RegisterScriptFunctions(); static void RegisterScriptFunctions();
}; };

View File

@ -2,9 +2,12 @@
#define SOUND_SOUND_KIT_DEF_HPP #define SOUND_SOUND_KIT_DEF_HPP
#include "db/Db.hpp" #include "db/Db.hpp"
#include <fmod.hpp>
#include <cstdint> #include <cstdint>
namespace FMOD {
class SoundGroup;
}
class SOUNDKITDEF { class SOUNDKITDEF {
public: public:
const char* name; const char* name;