SoundInterface: port SI2 into WoW/Source/SoundInterface

232 SI2 functions (0x4C5900-0x4D2780 plus the DSP, voice chat, zone sound,
advanced kit property and internal code), in files named after the 12340
__FILE__ strings (SoundInterface2*.cpp) and best-guess splits after the
Mac SI3 files. Replaces the _Triage shells. External WoW callees are
declared only (GameTime, DBClient, Unit_C, Item_C, ObjectMgrClient,
ChatFrame, GameUI, CGWorldStateInfo, ComSatClient, SFile name overloads)
and tracked as open items.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Saty
2026-09-27 03:07:31 +02:00
co-authored by Claude Opus 5.5
parent 432e950eee
commit 9243e0507a
62 changed files with 6043 additions and 92 deletions
+1
View File
@@ -87,6 +87,7 @@ add_subdirectory(WoW/Source/Net)
add_subdirectory(WoW/Source/Object)
add_subdirectory(WoW/Source/ObjectAlloc)
add_subdirectory(WoW/Source/ObjectMgrClient)
add_subdirectory(WoW/Source/SoundInterface)
add_subdirectory(WoW/Source/UIUtil)
add_subdirectory(WoW/Source/Ui)
add_subdirectory(WoW/Source/WorldClient)
+2
View File
@@ -71,6 +71,7 @@ class SFile {
static int32_t STORMAPI FileExists(const char* name);
static int32_t STORMAPI FileExistsEx(const char* name, uint32_t flags);
static int32_t STORMAPI FileGetIsLocalAmount(const char* name, int64_t& local, int64_t& total);
static int32_t STORMAPI FileIsLocal(const char* name, int32_t flags);
static int32_t STORMAPI FileIsLocal(SFileImpl* file, int32_t flags);
static int32_t STORMAPI GetActualFileName(SFileImpl* file, char* buffer, uint32_t size);
static int32_t STORMAPI GetBasePath(char* path, uint32_t size);
@@ -80,6 +81,7 @@ class SFile {
static int32_t IsStreamingMode();
static int32_t IsTrial();
static int32_t STORMAPI LoadFile(const char* name, void** data, uint32_t* size, uint32_t extra, SOVERLAPPED* overlapped);
static int32_t STORMAPI MakeFileLocal(const char* name, int32_t priority, bool wait);
static int32_t STORMAPI MakeFileLocal(SFileImpl* file, int32_t priority, bool wait);
static int32_t STORMAPI OpenArchive(const char* path, int32_t priority, uint32_t flags, SArchive** archive);
static int32_t STORMAPI OpenEx(SArchive* archive, const char* name, uint32_t flags, SFileImpl** result);
+1
View File
@@ -59,6 +59,7 @@ target_link_libraries(Wow
Object
ObjectAlloc
ObjectMgrClient
SoundInterface
UIUtil
Ui
WorldClient
+2
View File
@@ -484,6 +484,8 @@ extern WowClientDB_RLE<LightFloatBandRec> g_lightFloatBandDB;
extern WowClientDB<LightParamsRec> g_lightParamsDB;
extern WowClientDB<LightRec> g_lightDB;
int32_t ClientDBGetNumWeaponSubClasses();
int32_t ClientDBGetUnarmedWeapon();
void ClientDBInitialize();
void GameTablesInitialize();
void InitLights(int32_t mode);
+16
View File
@@ -1,4 +1,20 @@
#ifndef WOW_SOURCE_GAME_GAMECLIENT_COMSATCLIENT_H
#define WOW_SOURCE_GAME_GAMECLIENT_COMSATCLIENT_H
#include <cstddef>
#include <cstdint>
struct CVar;
void ComSatClient_SetCaptureDevice(int32_t index);
void ComSatClient_SetOutputDevice(int32_t index);
bool EnableMicrophoneHandler(CVar* var, const char* oldValue, const char* value, void* arg);
bool EnableVoiceChatHandler(CVar* var, const char* oldValue, const char* value, void* arg);
bool InboundChatVolumeHandler(CVar* var, const char* oldValue, const char* value, void* arg);
bool OutboundChatVolumeHandler(CVar* var, const char* oldValue, const char* value, void* arg);
bool PushToTalkButtonHandler(CVar* var, const char* oldValue, const char* value, void* arg);
bool SelfMuteHandler(CVar* var, const char* oldValue, const char* value, void* arg);
bool VoiceActivationSensitivityHandler(CVar* var, const char* oldValue, const char* value, void* arg);
bool VoiceChatModeHandler(CVar* var, const char* oldValue, const char* value, void* arg);
#endif
+5
View File
@@ -20,6 +20,11 @@ class CGameTime : public WowTime {
/* 0044 */ float m_baseMinuteOfDay;
/* 0048 */ float unk_0048;
/* 004C */ float unk_004C;
float GameTimeGetDayProgression();
bool IsDaytime();
};
extern CGameTime g_clientGameTime;
#endif
+2
View File
@@ -8,6 +8,8 @@
class CGItem_C : public CGObject_C, public CGItem {
public:
static int32_t IsMetal(int32_t materialId);
/* 00D8 */ void* unk_00D8;
/* 00DC */ uint32_t unk_00DC [192];
/* 03DC */ uint8_t unk_03DC [4];
+2
View File
@@ -197,6 +197,8 @@ class CGUnit_C : public CGObject_C, public CGUnit {
/* 0F68 */ uint32_t m_objectclass1 [38];
/* 1000 */ uint32_t unk_1000;
/* 1004 */ uint8_t unk_1004 [4];
bool IsActivePlayer();
};
class CAnimKitManager {
@@ -45,4 +45,6 @@ class ObjectMgr {
/* 00D4 */ CMovementGlobals* m_movementGlobal;
};
uint64_t ClntObjMgrGetActivePlayer();
#endif
+10
View File
@@ -0,0 +1,10 @@
file(GLOB_RECURSE PRIVATE_SOURCES CONFIGURE_DEPENDS "*.cpp")
add_library(SoundInterface STATIC
${PRIVATE_SOURCES}
)
target_include_directories(SoundInterface
PUBLIC
${CMAKE_SOURCE_DIR}
)
File diff suppressed because it is too large Load Diff
+246
View File
@@ -0,0 +1,246 @@
#ifndef WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2_H
#define WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2_H
#include <cstddef>
#include <cstdint>
#include "Engine/Source/SoundEngine/SoundEngine.h"
#include "Engine/Source/Storm/H/stpl.h"
#include "Engine/Source/Tempest/C3Vector.h"
class CGUnit_C;
class CGUnitVirtualItem;
class CVar;
class SoundEntriesAdvancedRec;
class SE2SoundKitObject;
class SE2SoundKitProperties;
class VSOUNDKITDEF;
class SE2SoundKitProperties {
public:
/* 0000 */ int32_t m_group;
/* 0004 */ float m_volume;
/* 0008 */ float m_volumeScale;
/* 000C */ int32_t m_fileIndex;
/* 0010 */ float m_fadeInTime;
/* 0014 */ float m_fadeOutTime;
/* 0018 */ int32_t m_selectMode;
/* 001C */ int32_t m_loopMode;
/* 0020 */ int32_t m_priority;
/* 0024 */ int32_t m_suppressorMode;
/* 0028 */ uint32_t m_decodeBufferSize;
/* 002C */ float m_maxDistance;
/* 0030 */ int32_t m_maxAudibleBehavior;
/* 0034 */ float m_muteFadeSpeed;
/* 0038 */ bool m_streaming;
/* 003C */ int32_t m_reverb;
/* 0040 */ int32_t m_noRandomStart;
/* 0044 */ int32_t m_blockMusicFiles;
/* 0048 */ int32_t m_software;
/* 004C */ float m_coneInsideAngle;
/* 0050 */ float m_coneOutsideAngle;
/* 0054 */ float m_coneOutsideVolume;
/* 0058 */ const C3Vector* m_coneOrientation;
/* 005C */ int32_t m_checkStreaming;
/* 0060 */ int32_t m_useDspChain;
/* 0064 */ char m_dspChainName[128];
/* 00E4 */ int32_t m_forceLoop;
void ResetToDefaults();
};
class SE2SoundKitObject {
public:
/* 0000 */ TSLink<SE2SoundKitObject> m_link;
/* 0008 */ SESound m_sound;
/* 000C */ uint32_t m_advancedId;
/* 0010 */ uint32_t unk_0010;
SE2SoundKitObject();
~SE2SoundKitObject();
};
class SI2SoundUserData : public SESoundUserData {
public:
/* 0004 */ const char* m_name;
/* 0008 */ int32_t m_soundKitId;
/* 000C */ VSOUNDKITDEF* m_def;
/* 0010 */ int32_t m_group;
/* 0014 */ uint32_t unk_0014;
/* 0018 */ uint32_t m_advancedId;
virtual ~SI2SoundUserData();
virtual void Release();
SI2SoundUserData();
};
class SI2 {
public:
static const char s_channelGroupNames[18][32];
static const int32_t s_channelGroupMaxSounds[18];
static int32_t s_channelGroupNumSounds[18];
static TSGrowableArray<uint32_t> s_suppressors;
static int32_t sm_bPlayerInside;
static int32_t sm_bCameraIsUnderwater;
static int32_t sm_bUnderwaterChanged;
static uint32_t sm_nextZoneMusicTime;
static int32_t sm_bLuaMusicPlaying;
static TSGrowableArray<uint32_t> sm_aIntroMusicNextValidPlayTime;
static int32_t AddAdvancedSound(SoundEntriesAdvancedRec* rec, int32_t soundKitId, const C3Vector* position, const C3Vector* orientation, SE2SoundKitObject* object, int32_t quickFade, int32_t a7, int32_t checkDistance, int32_t forceLoop);
static void AIMusicFinished(SESound* sound, void* param);
static void ApplyReverbSettings();
static int32_t AttachToObject(SE2SoundKitObject* object, uint64_t guid);
static int32_t ChaosModeUpdate(const void* data, void* param);
static void ClearSuppressors();
static void ClearSuppressorSounds();
static void CreateSoundGroups();
static void CreateVSoundLookup();
static int32_t CreditsMusicUpdate(const void* data, void* param);
static void DestroyVSoundLookup();
static void Detach(SE2SoundKitObject* object);
static void DSP_AttachCustomDspChain(FMOD::Channel* channel, char* name);
static void DSP_CreateDsp(const char* name, int32_t type, const float* params);
static void DSP_Init();
static void DSP_MakeDSPsExpire(float elapsed);
static void DSP_ShutDown();
static void FreeEmoteSounds();
static void FreeFootstepSounds();
static void FreeSoundKitDefs();
static void FreeWorldStateZoneSoundOverrides();
static void FreeZoneIntros();
static void FreeZoneSoundOverrides();
static float GetChannelGroupVolume(int32_t group);
static int32_t GetDesiredAmbienceKitID(int32_t* type);
static int32_t GetDesiredMusicKitID(int32_t* type, int32_t* silenceMin, int32_t* silenceMax);
static bool GetInputDriverName(int32_t index, char* name, int32_t nameLength, int32_t chatSystem);
static bool GetInputDriverName_Cached(int32_t index, char* name, int32_t nameLength, int32_t chatSystem);
static int32_t GetListenerPosition(C3Vector* position);
static int32_t GetNumInputDrivers(int32_t chatSystem);
static int32_t GetNumInputDrivers_Cached(int32_t chatSystem);
static int32_t GetNumOutputDrivers(int32_t chatSystem);
static int32_t GetNumOutputDrivers_Cached(int32_t chatSystem);
static int32_t GetNumSoundsInSoundKit(int32_t soundKitId);
static bool GetObjectPosition(uint64_t guid, C3Vector* position);
static bool GetOutputDriverName(int32_t index, char* name, int32_t nameLength, int32_t chatSystem);
static bool GetOutputDriverName_Cached(int32_t index, char* name, int32_t nameLength, int32_t chatSystem);
static VSOUNDKITDEF* GetSoundKitDef(int32_t soundKitId);
static int32_t GetSoundKitUsage(int32_t soundKitId);
static float GetSoundVolume(SESoundUserData* userData);
static int32_t GetTextEmoteSoundID(uint32_t emotesTextId, uint32_t race, uint32_t sex);
static int32_t GetTextEmoteSoundIndex(uint32_t emotesTextId, uint32_t race, uint32_t sex);
static int32_t GetZoneReverb();
static int32_t GetZoneSoundOverride(int32_t mapId, int32_t chunkX, int32_t chunkY, int32_t subchunkX, int32_t subchunkY, int32_t* zoneIntroMusicId, int32_t* zoneMusicId, int32_t* soundAmbienceId, int32_t* soundProviderPreferencesId);
static int32_t GlueMusicUpdate(const void* data, void* param);
static int32_t HandleSoundDeviceChange(const void* data, void* param);
static int32_t HandleWaterSounds(const void* data, void* param);
static int32_t Init(int32_t restart);
static void InitEmoteSounds();
static void InitFootstepSounds();
static void InitSoundKitLookup();
static void InitVocalErrorSounds(int32_t race, uint32_t sex);
static void InitWeaponImpactCombatSounds();
static void InitWeaponSwingCombatSounds();
static void InitWorldStateZoneSoundOverrides();
static void InitZoneIntros();
static void InitZoneSoundOverrides();
static void InitZoneSoundsHandler();
static void IntroMusicFinished(SESound* sound, void* param);
static int32_t IntroMusicOkToPlay(int32_t soundKitId, int32_t type);
static int32_t IsAdvancedSoundNear(int32_t soundKitId, const C3Vector* position);
static bool IsLooping(SE2SoundKitObject* object);
static bool IsPlaying(SE2SoundKitObject* object);
static uint32_t IsSoundKitLooping(int32_t soundKitId);
static int32_t IsTooCloseToExistingSoundKit(int32_t soundKitId, const C3Vector* position);
static int32_t IsUnderwater();
static int32_t LookupSoundKitId(const char* name);
static void MarkAdvancedSoundStopped(uint32_t id);
static int32_t OnFocusChanged(const void* data, void* param);
static void PlayAIMusic(int32_t soundKitId);
static int32_t PlayFoleySound(int32_t materialId, const C3Vector* position, int32_t self);
static void PlayFootstepSound(int32_t footstepId, const C3Vector* position, int32_t terrainType, int32_t splash, int32_t loud, CGUnit_C* unit);
static void PlayHitSound(const CGUnitVirtualItem* weapon, int32_t impactType, int32_t crit, const C3Vector* position, int32_t self);
static void PlayItemSound(int32_t type, int32_t displayId);
static int32_t PlayMissedSound(bool oneHand, const C3Vector* position, int32_t self);
static void PlayParrySound(const CGUnitVirtualItem* weapon, const CGUnitVirtualItem* defender, int32_t crit, const C3Vector* position, int32_t self);
static int32_t PlaySheatheSound(const CGUnitVirtualItem* item, int32_t sheathe, const C3Vector* position, int32_t self);
static int32_t PlaySoundFile(const char* filename, int32_t group);
static int32_t PlaySoundKit(const char* name, const C3Vector* position, SE2SoundKitObject* object, SE2SoundKitProperties* properties);
static int32_t PlaySoundKit(int32_t soundKitId, const C3Vector* position, SE2SoundKitObject* object, SE2SoundKitProperties* properties, uint32_t advancedId, uint32_t* soundId, int32_t checkDistance, int32_t keepPlaying);
static int32_t PlayUISound(int32_t soundKitId);
static int32_t PlayWeaponSwooshSound(int32_t type, int32_t crit, const C3Vector* position, int32_t quiet, int32_t self);
static void RegisterCVars();
static void RegisterDeviceChangeHandler();
static void RegisterScriptFunctions();
static void RegisterSoundEngineCVars();
static void ReleaseSoundGroups();
static int32_t ResetSoundKitVariants(const char* name);
static int32_t Set3DPosition(SE2SoundKitObject* object, const C3Vector* position);
static void SetAdvancedSoundPosition(uint32_t id, const C3Vector* position);
static void SetChannelGroupVolume(int32_t group, float volume);
static int32_t SetListenerAttributes(const C3Vector* position, const C3Vector* forward, const C3Vector* up, const C3Vector* velocity);
static void SetOverrideZoneSounds(int32_t soundAmbienceId, int32_t zoneMusicId);
static void SetPitch(SE2SoundKitObject* object, float pitch);
static void SetPlayerInside(bool inside);
static void SetUnderwaterStatus(int32_t underwater);
static int32_t SetVolume(SE2SoundKitObject* object, float volume);
static void SetWeatherKitID(int32_t soundKitId);
static void SetZoneAmbienceID(int32_t type, int32_t soundAmbienceId);
static void SetZoneIntroMusicID(int32_t type, int32_t zoneIntroMusicId);
static void SetZoneMusicID(int32_t type, int32_t zoneMusicId);
static void SetZoneReverb(int32_t type, int32_t reverb);
static void SetZoneUnderwaterReverb(int32_t reverb);
static int32_t ShutDown(int32_t restart);
static void ShutdownZoneSoundsHandler();
static void SoundFinished(SESound* sound, void* param);
static void StartCreditsMusic(const char* name);
static void StartGlueAmbience(const char* name, float fadeInTime);
static void StartGlueMusic(const char* name);
static void StopAdvancedSound(uint32_t id);
static void StopAdvancedSound(uint32_t id, int32_t remove, float fadeOutTime);
static void StopAIMusic();
static void StopAllMusic();
static void StopAllSounds();
static void StopAllSounds(float fadeOutTime);
static void StopCreditsMusic();
static void StopGlueAmbience(float fadeOutTime);
static void StopGlueMusic(float fadeOutTime);
static void StopLuaMusic();
static int32_t StopSound(SE2SoundKitObject* object, int32_t immediate, float fadeOutTime, int32_t stopAdvanced);
static void StopZoneAmbience();
static void UnregisterScriptFunctions();
static int32_t UpdateAdvancedSounds(const void* data, void* param);
static int32_t UpdateZoneSoundsForWorldState(int32_t areaId, int32_t zoneId, int32_t wmoAreaId, int32_t wmoGroupAreaId, int32_t inside);
static void UpdateDucking(int32_t elapsed);
static void UpdateReverb();
static void ValidateOutputDriver();
static void ValidateVoiceChatInputDriver();
static void ValidateVoiceChatOutputDriver();
static void VoiceChat_ActivatePrimaryCaptureCallback();
static void VoiceChat_AmplifyMicrophoneInput(int16_t* data, uint32_t samples);
static void VoiceChat_CleanUpLoopbackSound();
static int32_t VoiceChat_CreateChatSound(SE2SoundKitObject* object, SEStreamCallbacks* callbacks, int32_t chatSystem);
static void VoiceChat_DestroyChatSystem();
static int32_t VoiceChat_GetCurrentMicrophoneSignalLevel();
static void VoiceChat_InitCapture(float sampleRate);
static bool VoiceChat_IsPlayingLoopbackSound();
static bool VoiceChat_IsRecordingLoopbackSound();
static int32_t VoiceChat_IsVoiceChatInitialized();
static int32_t VoiceChat_Play(SE2SoundKitObject* object);
static void VoiceChat_PlayLoopbackSound();
static void VoiceChat_RecordLoopbackSound(int32_t seconds);
static void VoiceChat_SetCaptureDevice(int32_t index);
static void VoiceChat_SetOutputDevice(int32_t index);
static void VoiceChat_SetPrimaryCaptureCallback(SECaptureCallbacks* callbacks);
static void VoiceChat_ShutDownCapture();
static void VoiceChat_StartCapture();
static void VoiceChat_StopCapture();
static void VoiceChat_StopPlayingLoopbackSound();
static void VoiceChat_StopRecordingLoopbackSound();
static void WaterShutdown();
static int32_t ZoneMusicDelayElapsed(int32_t type);
static void ZoneMusicFinished(SESound* sound, void* param);
static int32_t ZoneSoundsUpdate(const void* data, void* param);
};
#endif
@@ -0,0 +1,781 @@
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <new>
#include "WoW/Source/SoundInterface/SoundInterface2AdvancedKitProperties.h"
#include "Engine/Source/SoundEngine/SoundEngine.h"
#include "Engine/Source/Storm/H/storm.h"
#include "Engine/Source/Tempest/CRandom.h"
#include "WoW/Source/DB/DBClient/DBClient.h"
#include "WoW/Source/Game/GameTime.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
#include "WoW/Source/SoundInterface/SoundInterface2Internal.h"
// STATIC: 0x00AC390C
static uint32_t s_nextAdvancedId = 1;
// STATIC: 0x00AC3924
static TSList<SuppressorSound, TSGetLink<SuppressorSound> > s_suppressorSounds;
// STATIC: 0x00B4AD24
static HASHKEY_NONE s_vsoundKey;
// STATIC: 0x00B4AD28
static int32_t s_dayTime;
// STATIC: 0x00B4AD2C
static TSHashTable<VSOUND_LOOKUP, HASHKEY_NONE>* s_vsoundLookup;
// STATIC: 0x00B4AD38
static int32_t s_lastDayTime;
// VERIFY: 3271634f auto
// OFFSET: 0x004C9CD0
void SI2::DestroyVSoundLookup() {
if (s_vsoundLookup) {
delete s_vsoundLookup;
s_vsoundLookup = nullptr;
}
}
// VERIFY: 80cb0ed8 auto
// OFFSET: 0x004C9CF0
static int32_t IsInTimeWindow(SI2AdvancedSound* sound) {
int32_t offset = sound->m_randomOffset;
int32_t now = s_dayTime;
if (sound->m_timeD + offset >= 86400000 && now < offset + sound->m_timeA) {
now += 86400000;
}
return (sound->m_timeA + offset <= now && sound->m_timeD + offset >= now) || (!sound->m_timeA && !sound->m_timeB && !sound->m_timeC && !sound->m_timeD);
}
// VERIFY: 42218333 auto
// OFFSET: 0x004C9D50
static void StopAdvancedSoundObject(SI2AdvancedSound* sound, int32_t immediate) {
if (!sound) {
return;
}
sound->m_stopped = 1;
if (sound->m_object) {
SI2::StopSound(sound->m_object, immediate, -1.0f, 0);
}
}
// VERIFY: b3211280 manual
// OFFSET: 0x004C9D90
static int32_t RandomBetween(int32_t min, int32_t max) {
if (max > min) {
return min + static_cast<int32_t>((static_cast<uint64_t>(static_cast<uint32_t>(max - min)) * CRandom::uint32_(g_rndSeed)) >> 32);
}
return max;
}
// VERIFY: 3233d57a auto
// OFFSET: 0x004C9DC0
int32_t SI2AdvancedSound::Play() {
SE2SoundKitProperties properties;
if (this->m_usage) {
if (static_cast<uint32_t>(this->m_usage - 1) > 1) {
return 0;
}
properties.ResetToDefaults();
properties.m_fadeInTime = 0.01f;
properties.m_fadeOutTime = 0.01f;
properties.m_group = this->m_volumeSliderCategory;
properties.m_coneInsideAngle = this->m_insideAngle;
properties.m_loopMode = 2;
properties.m_coneOutsideAngle = this->m_outsideAngle;
properties.m_maxAudibleBehavior = 1;
properties.m_streaming = false;
properties.m_coneOutsideVolume = this->m_outsideVolume;
properties.m_software = 1;
properties.m_coneOrientation = (0.0f == this->m_orientation.x && 0.0f == this->m_orientation.y && 0.0f == this->m_orientation.z) ? nullptr : &this->m_orientation;
const C3Vector* position = (0.0f == this->m_position.x && 0.0f == this->m_position.y && 0.0f == this->m_position.z) ? nullptr : &this->m_position;
return SI2::PlaySoundKit(this->m_soundKitId, position, this->m_object, &properties, this->m_id, &this->m_soundId, 1, 1);
}
properties.ResetToDefaults();
properties.m_loopMode = 1;
properties.m_maxAudibleBehavior = 0;
properties.m_streaming = true;
properties.m_software = 1;
float fade = this->m_quickFade ? 0.7f : 3.0f;
properties.m_fadeInTime = fade;
properties.m_fadeOutTime = fade;
properties.m_group = this->m_volumeSliderCategory;
properties.m_coneInsideAngle = this->m_insideAngle;
properties.m_coneOutsideAngle = this->m_outsideAngle;
properties.m_coneOutsideVolume = this->m_outsideVolume;
properties.m_coneOrientation = (0.0f == this->m_orientation.x && 0.0f == this->m_orientation.y && 0.0f == this->m_orientation.z) ? nullptr : &this->m_orientation;
return SI2::PlaySoundKit(this->m_soundKitId, &this->m_position, this->m_object, &properties, this->m_id, &this->m_soundId, 1, 1);
}
// VERIFY: 762dbd2f manual
// OFFSET: 0x004C9FE0
static float GetDuckVolume(int32_t group, SI2AdvancedSound* exclude) {
float volume = 1.0f;
for (SuppressorSound* node = s_suppressorSounds.Head(); node; node = s_suppressorSounds.Next(node)) {
if (node->m_sound && node->m_sound == exclude) {
volume = 1.0f;
} else if (node->m_volume[group] < volume) {
volume = node->m_volume[group];
}
}
return volume;
}
// VERIFY: 4f46a9dd auto
// OFFSET: 0x004CA040
SI2AdvancedSound::SI2AdvancedSound() {
this->m_position.x = 0.0f;
this->m_position.y = 0.0f;
this->m_position.z = 0.0f;
this->m_orientation.x = 0.0f;
this->m_orientation.y = 0.0f;
this->m_orientation.z = 0.0f;
this->m_soundId = 0;
this->m_stopped = 0;
this->m_finished = 0;
this->m_innerRadius2d = 0.0f;
this->m_outerRadius2d = 0.0f;
}
// VERIFY: d2749ee6 manual
// OFFSET: 0x004CA080
SI2AdvancedSound::~SI2AdvancedSound() {
this->m_inRange = 0;
for (SuppressorSound* node = s_suppressorSounds.Head(); node;) {
SuppressorSound* next = s_suppressorSounds.Next(node);
if (node->m_sound == this) {
node->m_sound = nullptr;
}
node = next;
}
if (this->m_object) {
this->m_object->m_advancedId = 0;
}
SE2SoundKitObject* object = this->m_object;
if (object && !this->m_externalObject) {
delete object;
this->m_object = nullptr;
}
}
// VERIFY: 1ee25e28 auto
// OFFSET: 0x004CA130
int32_t SI2::IsAdvancedSoundNear(int32_t soundKitId, const C3Vector* position) {
if (!s_vsoundLookup) {
return 1;
}
SE2::LockSoundList();
for (VSOUND_LOOKUP* node = s_vsoundLookup->m_fulllist.Head(); node; node = s_vsoundLookup->m_fulllist.Next(node)) {
SI2AdvancedSound* sound = node->m_sound;
if (sound->m_rec->m_id == soundKitId) {
float dx = position->x - sound->m_position.x;
float dy = position->y - sound->m_position.y;
float dz = position->z - sound->m_position.z;
if (dz * dz + dy * dy + dx * dx < 6.0f) {
SE2::UnlockSoundList();
return 1;
}
}
}
SE2::UnlockSoundList();
return 0;
}
// VERIFY: 5e6aafa6 manual
// OFFSET: 0x004CA1E0
void SI2AdvancedSound::AddSuppressor() {
if ((this->m_duck[0] >= 0.0f && this->m_duck[0] < 1.0f) || (this->m_duck[1] >= 0.0f && this->m_duck[1] < 1.0f) || (this->m_duck[2] >= 0.0f && this->m_duck[2] < 1.0f)) {
for (SuppressorSound* node = s_suppressorSounds.Head(); node; node = s_suppressorSounds.Next(node)) {
if (node->m_sound == this) {
return;
}
}
SuppressorSound* node = new (SMemAlloc(sizeof(SuppressorSound), __FILE__, __LINE__, 0)) SuppressorSound();
node->m_sound = this;
node->m_fadeTime = this->m_timeToUnduck;
s_suppressorSounds.LinkToTail(node);
}
}
// VERIFY: e5be26cc auto
// OFFSET: 0x004CA4E0
void SI2::ClearSuppressors() {
s_suppressorSounds.Clear();
}
// VERIFY: bdd84a6b manual
// OFFSET: 0x004CA4F0
void SI2::UpdateDucking(int32_t elapsed) {
C3Vector listener;
listener.x = 0.0f;
listener.y = 0.0f;
listener.z = 0.0f;
SE2::GetListenerPosition(&listener);
for (SuppressorSound* node = s_suppressorSounds.Head(); node;) {
SuppressorSound* next = s_suppressorSounds.Next(node);
for (int32_t i = 0; i < 3; i++) {
SI2AdvancedSound* sound = node->m_sound;
float* volume = &node->m_volume[i];
if (sound) {
bool atOrigin = 0.0f == sound->m_position.x && 0.0f == sound->m_position.y && 0.0f == sound->m_position.z;
float dx = listener.x - sound->m_position.x;
float dy = listener.y - sound->m_position.y;
float dz = listener.z - sound->m_position.z;
float distance = sqrt(dz * dz + dy * dy + dx * dx);
node->m_distance = distance;
if (atOrigin || distance < sound->m_innerRadiusOfInfluence || (distance < sound->m_outerRadiusOfInfluence && sound->m_inRange)) {
if (sound->m_duck[i] != *volume) {
int32_t time = sound->m_timeToDuck;
if (time > 0) {
*volume = *volume - static_cast<float>(elapsed) / time;
if (*volume < node->m_sound->m_duck[i]) {
*volume = node->m_sound->m_duck[i];
node->m_sound->m_inRange = 1;
continue;
}
} else {
*volume = sound->m_duck[i];
}
}
node->m_sound->m_inRange = 1;
} else {
sound->m_inRange = 0;
SI2AdvancedSound* removed = node->m_sound;
for (SuppressorSound* other = s_suppressorSounds.Head(); other;) {
SuppressorSound* otherNext = s_suppressorSounds.Next(other);
if (other->m_sound == removed) {
other->m_sound = nullptr;
}
other = otherNext;
}
}
} else if (1.0f != *volume) {
int32_t time = node->m_fadeTime;
if (time <= 0 || (*volume = static_cast<float>(elapsed) / time + *volume) > 1.0f) {
*volume = 1.0f;
}
}
}
if (!node->m_sound && 1.0f == node->m_volume[0] && 1.0f == node->m_volume[1] && 1.0f == node->m_volume[2]) {
delete node;
}
node = next;
}
}
// VERIFY: 2e8555db manual
// OFFSET: 0x004CA7B0
int32_t SI2::UpdateAdvancedSounds(const void* data, void* param) {
int32_t now = static_cast<int32_t>(g_clientGameTime.GameTimeGetDayProgression() * 86400000.0f);
int32_t elapsed = now - s_lastDayTime;
s_dayTime = now;
if (elapsed < 0) {
elapsed = 0;
}
s_lastDayTime = now;
SI2::UpdateDucking(elapsed);
int32_t created = 0;
SE2::LockSoundList();
VSOUND_LOOKUP* node = s_vsoundLookup->m_fulllist.Head();
while (node) {
SI2AdvancedSound* sound = node->m_sound;
if (sound->m_finished) {
VSOUND_LOOKUP* next = s_vsoundLookup->m_fulllist.Next(node);
s_vsoundLookup->DeleteNode(node);
node = next;
continue;
}
SESound* object = sound->m_object ? &sound->m_object->m_sound : nullptr;
created = 0;
if (object && object->IsPlaying()) {
if (!IsInTimeWindow(sound)) {
node = s_vsoundLookup->m_fulllist.Next(node);
if (sound->m_usage) {
continue;
}
int32_t immediate = sound->m_volume <= 0.0f;
sound->m_stopped = 1;
if (sound->m_object) {
SI2::StopSound(sound->m_object, immediate, -1.0f, 0);
}
continue;
}
SI2SoundUserData* userData = static_cast<SI2SoundUserData*>(sound->m_object->m_sound.GetUserData());
if (!sound->m_usage && userData && userData->m_def->m_numFiles > 1 && sound->m_intervalMin > 0.0f && sound->m_intervalMax > 0.0f) {
sound->m_nextInterval -= elapsed;
if (sound->m_nextInterval < 0) {
StopAdvancedSoundObject(sound, 0);
sound->Play();
sound->m_nextInterval = RandomBetween(sound->m_intervalMin, sound->m_intervalMax);
}
}
SESound* live = SE2::GetSoundFromID(node->m_sound->m_soundId, &created);
if (live) {
float pan = 1.0f;
if (node->m_sound->m_outerRadius2d > 0.0f) {
C3Vector listener;
listener.x = 0.0f;
listener.y = 0.0f;
listener.z = 0.0f;
SI2::GetListenerPosition(&listener);
SI2AdvancedSound* advanced = node->m_sound;
float dx = listener.x - advanced->m_position.x;
float dy = listener.y - advanced->m_position.y;
float dz = listener.z - advanced->m_position.z;
float distanceSq = dz * dz + dy * dy + dx * dx;
float level;
if (advanced->m_innerRadius2d * advanced->m_innerRadius2d < distanceSq) {
level = node->m_sound->m_outerRadius2d * node->m_sound->m_outerRadius2d < distanceSq ? 1.0f : (sqrt(distanceSq) - node->m_sound->m_innerRadius2d) / (node->m_sound->m_outerRadius2d - node->m_sound->m_innerRadius2d);
} else {
level = 0.0f;
}
pan = level;
if (!(node->m_sound->m_innerRadiusOfInfluence * node->m_sound->m_innerRadiusOfInfluence < distanceSq)) {
node->m_sound->AddSuppressor();
pan = level;
}
}
live->Set3DPanLevel(pan);
if (created) {
live->Detach();
delete live;
}
}
if (sound->m_usage != 2 && (sound->m_timeA || sound->m_timeB || sound->m_timeC || sound->m_timeD)) {
int32_t offset = sound->m_randomOffset;
int32_t time = s_dayTime;
if (sound->m_timeD + offset >= 86400000 && time < offset + sound->m_timeA) {
time += 86400000;
}
if (time < offset + sound->m_timeB) {
sound->m_volume = static_cast<float>(time - sound->m_timeA) / (sound->m_timeB - sound->m_timeA);
if (sound->m_volume > 1.0f) {
sound->m_volume = 1.0f;
}
if (sound->m_volume < 0.0f) {
sound->m_volume = 0.0f;
}
} else if (time < offset + sound->m_timeC) {
sound->m_volume = 1.0f;
} else {
sound->m_volume = 1.0f - static_cast<float>(time - sound->m_timeC) / (sound->m_timeD - sound->m_timeC);
if (sound->m_volume > 1.0f) {
sound->m_volume = 1.0f;
}
if (sound->m_volume < 0.0f) {
sound->m_volume = 0.0f;
}
}
}
node = s_vsoundLookup->m_fulllist.Next(node);
continue;
}
SI2AdvancedSound* advanced = node->m_sound;
int32_t usage = advanced->m_usage;
if (!advanced->m_object || usage == 2 || (!usage && advanced->m_stopped)) {
VSOUND_LOOKUP* next = s_vsoundLookup->m_fulllist.Next(node);
s_vsoundLookup->DeleteNode(node);
node = next;
continue;
}
if (IsInTimeWindow(advanced)) {
if (!usage) {
node->m_sound->Play();
} else if (usage == 1) {
node->m_sound->m_nextInterval -= elapsed;
if (node->m_sound->m_nextInterval < 0) {
node->m_sound->Play();
sound->m_nextInterval = RandomBetween(sound->m_intervalMin, sound->m_intervalMax);
}
}
}
node = s_vsoundLookup->m_fulllist.Next(node);
}
SE2::UnlockSoundList();
return 1;
}
// VERIFY: 3a7d0c7f manual
// OFFSET: 0x004CB160
void SI2::CreateVSoundLookup() {
if (!s_vsoundLookup) {
s_vsoundLookup = new (SMemAlloc(sizeof(TSHashTable<VSOUND_LOOKUP, HASHKEY_NONE>), __FILE__, __LINE__, 0)) TSHashTable<VSOUND_LOOKUP, HASHKEY_NONE>();
}
}
// VERIFY: 00aa6854 auto
// OFFSET: 0x004CB1A0
void SI2::MarkAdvancedSoundStopped(uint32_t id) {
SE2::LockSoundList();
VSOUND_LOOKUP* node = s_vsoundLookup->Ptr(id, s_vsoundKey);
if (node) {
node->m_sound->m_finished = 1;
}
SE2::UnlockSoundList();
}
// VERIFY: 4e03a953 auto
// OFFSET: 0x004CB1D0
void SI2::StopAdvancedSound(uint32_t id) {
if (!id || !s_vsoundLookup) {
return;
}
SE2::LockSoundList();
TSHashTable<VSOUND_LOOKUP, HASHKEY_NONE>* lookup = s_vsoundLookup;
VSOUND_LOOKUP* node = lookup->Ptr(id, s_vsoundKey);
if (node) {
lookup->DeleteNode(node);
}
SE2::UnlockSoundList();
}
// VERIFY: 9c993a65 auto
// OFFSET: 0x004CB220
float SI2::GetSoundVolume(SESoundUserData* userData) {
if (!userData) {
return 1.0f;
}
SI2SoundUserData* data = static_cast<SI2SoundUserData*>(userData);
float volume = 1.0f;
SI2AdvancedSound* sound;
if (s_vsoundLookup) {
SE2::LockSoundList();
VSOUND_LOOKUP* node = s_vsoundLookup->Ptr(data->m_advancedId, s_vsoundKey);
SE2::UnlockSoundList();
if (node) {
sound = node->m_sound;
if (sound) {
volume = sound->m_volume;
}
} else {
sound = nullptr;
}
} else {
sound = nullptr;
}
int32_t group = data->m_group;
if (!group || group >= 7) {
return GetDuckVolume(0, sound) * volume;
}
if (group == 1) {
return GetDuckVolume(1, sound) * volume;
}
if (group == 2) {
return GetDuckVolume(2, sound) * volume;
}
return volume;
}
// VERIFY: c3f6bde5 manual
// OFFSET: 0x004CB2D0
void SI2::SetAdvancedSoundPosition(uint32_t id, const C3Vector* position) {
SE2::LockSoundList();
VSOUND_LOOKUP* node = s_vsoundLookup->Ptr(id, s_vsoundKey);
if (node) {
node->m_sound->m_position = *position;
}
SE2::UnlockSoundList();
}
// VERIFY: 4e1ff068 auto
// OFFSET: 0x004CB3B0
void SI2::ClearSuppressorSounds() {
s_suppressorSounds.Clear();
if (!s_vsoundLookup) {
return;
}
SE2::LockSoundList();
TSHashTable<VSOUND_LOOKUP, HASHKEY_NONE>* lookup = s_vsoundLookup;
for (VSOUND_LOOKUP* node = lookup->m_fulllist.Head(); node; node = lookup->m_fulllist.Head()) {
uint32_t id = node->m_sound->m_id;
if (id && lookup) {
SI2::StopAdvancedSound(id);
lookup = s_vsoundLookup;
}
}
SE2::UnlockSoundList();
}
// VERIFY: 524c166b auto
// OFFSET: 0x004CB440
void SI2AdvancedSound::Stop(int32_t remove, float fadeOutTime) {
if (remove) {
SI2::StopAdvancedSound(this->m_id);
return;
}
this->m_stopped = 1;
if (this->m_object) {
if (fadeOutTime >= 0.0f) {
this->m_object->m_sound.SetFadeOutTime(fadeOutTime);
}
this->m_object->m_sound.FadeOutNow();
}
}
// VERIFY: 8741a1fc auto
// OFFSET: 0x004CB4E0
void SI2::StopAdvancedSound(uint32_t id, int32_t remove, float fadeOutTime) {
SE2::LockSoundList();
VSOUND_LOOKUP* node = s_vsoundLookup->Ptr(id, s_vsoundKey);
if (node) {
node->m_sound->Stop(remove, fadeOutTime);
}
SE2::UnlockSoundList();
}
// VERIFY: 87c34bf4 manual
// OFFSET: 0x004CB580
int32_t SI2::AddAdvancedSound(SoundEntriesAdvancedRec* rec, int32_t soundKitId, const C3Vector* position, const C3Vector* orientation, SE2SoundKitObject* object, int32_t quickFade, int32_t a7, int32_t checkDistance, int32_t forceLoop) {
if (!rec) {
return 24;
}
if (!s_vsoundLookup) {
return 17;
}
C3Vector zero;
zero.x = 0.0f;
zero.y = 0.0f;
zero.z = 0.0f;
if (!orientation) {
orientation = &zero;
}
if (position && !quickFade && checkDistance && SI2::IsAdvancedSoundNear(rec->m_id, position)) {
return 15;
}
SI2AdvancedSound* sound = new (SMemAlloc(sizeof(SI2AdvancedSound), __FILE__, __LINE__, 0)) SI2AdvancedSound();
if (!sound) {
return 22;
}
if (object) {
sound->m_object = object;
sound->m_externalObject = 1;
} else {
sound->m_externalObject = 0;
sound->m_object = new (SMemAlloc(sizeof(SE2SoundKitObject), __FILE__, __LINE__, 0)) SE2SoundKitObject();
if (!sound->m_object) {
sound->~SI2AdvancedSound();
SMemFree(sound, "delete", -1, 0);
return 22;
}
}
sound->m_quickFade = quickFade;
sound->m_rec = rec;
sound->m_soundKitId = soundKitId;
sound->m_innerRadius2d = rec->m_innerRadius2d;
sound->m_outerRadius2d = rec->m_outerRadius2d;
sound->m_timeA = rec->m_timeA;
sound->m_timeB = rec->m_timeB;
sound->m_timeC = rec->m_timeC;
sound->m_timeD = rec->m_timeD;
if (sound->m_timeB < sound->m_timeA) {
sound->m_timeB = rec->m_timeB + 86400000;
}
if (sound->m_timeC < sound->m_timeB) {
sound->m_timeC = rec->m_timeC + 86400000;
}
if (sound->m_timeD < sound->m_timeC) {
sound->m_timeD += 86400000;
}
sound->m_randomOffsetRange = rec->m_randomOffsetRange;
sound->m_volume = 1.0f;
sound->m_randomOffset = RandomBetween(0, sound->m_randomOffsetRange);
sound->m_usage = forceLoop ? 0 : rec->m_usage;
sound->m_intervalMin = rec->m_timeIntervalMin;
sound->m_intervalMax = rec->m_timeIntervalMax;
sound->m_nextInterval = RandomBetween(sound->m_intervalMin, sound->m_intervalMax);
sound->m_volumeSliderCategory = rec->m_volumeSliderCategory;
sound->m_duck[0] = (rec->m_duckToSfx < 0.0f || rec->m_duckToSfx > 1.0f) ? 1.0f : rec->m_duckToSfx;
sound->m_duck[1] = (rec->m_duckToMusic < 0.0f || rec->m_duckToMusic > 1.0f) ? 1.0f : rec->m_duckToMusic;
sound->m_duck[2] = (rec->m_duckToAmbience < 0.0f || rec->m_duckToAmbience > 1.0f) ? 1.0f : rec->m_duckToAmbience;
sound->m_innerRadiusOfInfluence = rec->m_innerRadiusOfInfluence;
sound->m_outerRadiusOfInfluence = rec->m_outerRadiusOfInfluence;
if (sound->m_outerRadiusOfInfluence < sound->m_innerRadiusOfInfluence) {
sound->m_innerRadiusOfInfluence = sound->m_outerRadiusOfInfluence;
}
sound->m_inRange = 0;
sound->m_timeToDuck = rec->m_timeToDuck;
sound->m_timeToUnduck = rec->m_timeToUnduck;
sound->m_insideAngle = rec->m_insideAngle;
sound->m_outsideAngle = rec->m_outsideAngle;
if (sound->m_outsideAngle < sound->m_insideAngle) {
sound->m_insideAngle = sound->m_outsideAngle;
}
sound->m_outsideVolume = rec->m_outsideVolume;
if (position) {
sound->m_position = *position;
} else {
sound->m_position.x = 0.0f;
sound->m_position.y = 0.0f;
sound->m_position.z = 0.0f;
}
sound->m_orientation = *orientation;
sound->unk_0008 = a7;
sound->m_id = s_nextAdvancedId;
sound->m_object->m_advancedId = s_nextAdvancedId;
s_nextAdvancedId++;
uint32_t id = sound->m_id;
VSOUND_LOOKUP* node = s_vsoundLookup->InternalNewNode(id, 0, 0);
node->m_hashval = id;
node->m_sound = sound;
if (sound->m_usage == 2) {
sound->Play();
if (SI2::IsPlaying(sound->m_object)) {
sound->AddSuppressor();
}
}
return 0;
}
// INLINED
SuppressorSound::SuppressorSound() {
this->m_volume[0] = 1.0f;
this->m_volume[1] = 1.0f;
this->m_volume[2] = 1.0f;
this->m_sound = nullptr;
this->m_distance = 0.0f;
this->m_fadeTime = 1000;
}
// INLINED
VSOUND_LOOKUP::~VSOUND_LOOKUP() {
if (this->m_sound) {
delete this->m_sound;
this->m_sound = nullptr;
}
}
@@ -0,0 +1,75 @@
#ifndef WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2ADVANCEDKITPROPERTIES_H
#define WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2ADVANCEDKITPROPERTIES_H
#include <cstddef>
#include <cstdint>
#include "Engine/Source/Storm/H/stpl.h"
#include "Engine/Source/Tempest/C3Vector.h"
class SE2SoundKitObject;
class SI2AdvancedSound;
class SoundEntriesAdvancedRec;
class SI2AdvancedSound {
public:
/* 0000 */ TSLink<SI2AdvancedSound> m_link;
/* 0008 */ int32_t unk_0008;
/* 000C */ int32_t m_stopped;
/* 0010 */ int32_t m_finished;
/* 0014 */ SE2SoundKitObject* m_object;
/* 0018 */ int32_t m_externalObject;
/* 001C */ SoundEntriesAdvancedRec* m_rec;
/* 0020 */ int32_t m_soundKitId;
/* 0024 */ uint32_t m_soundId;
/* 0028 */ C3Vector m_position;
/* 0034 */ float m_innerRadius2d;
/* 0038 */ float m_outerRadius2d;
/* 003C */ int32_t m_timeA;
/* 0040 */ int32_t m_timeB;
/* 0044 */ int32_t m_timeC;
/* 0048 */ int32_t m_timeD;
/* 004C */ int32_t m_randomOffsetRange;
/* 0050 */ int32_t m_randomOffset;
/* 0054 */ float m_volume;
/* 0058 */ int32_t m_usage;
/* 005C */ int32_t m_nextInterval;
/* 0060 */ int32_t m_intervalMin;
/* 0064 */ int32_t m_intervalMax;
/* 0068 */ int32_t m_volumeSliderCategory;
/* 006C */ float m_duck[3];
/* 0078 */ float m_innerRadiusOfInfluence;
/* 007C */ float m_outerRadiusOfInfluence;
/* 0080 */ int32_t m_inRange;
/* 0084 */ int32_t m_timeToDuck;
/* 0088 */ int32_t m_timeToUnduck;
/* 008C */ float m_insideAngle;
/* 0090 */ float m_outsideAngle;
/* 0094 */ float m_outsideVolume;
/* 0098 */ C3Vector m_orientation;
/* 00A4 */ int32_t m_quickFade;
/* 00A8 */ uint32_t m_id;
SI2AdvancedSound();
~SI2AdvancedSound();
void AddSuppressor();
int32_t Play();
void Stop(int32_t remove, float fadeOutTime);
};
class SuppressorSound : public TSLinkedNode<SuppressorSound> {
public:
/* 0008 */ SI2AdvancedSound* m_sound;
/* 000C */ float m_volume[3];
/* 0018 */ float m_distance;
/* 001C */ int32_t m_fadeTime;
SuppressorSound();
};
struct VSOUND_LOOKUP : public TSHashObject<VSOUND_LOOKUP, HASHKEY_NONE> {
/* 0018 */ SI2AdvancedSound* m_sound;
~VSOUND_LOOKUP();
};
#endif
@@ -0,0 +1,331 @@
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include "Engine/Source/Base/CmdLine.h"
#include "Engine/Source/ConsoleBase/ConsoleVar.h"
#include "Engine/Source/ConsoleBase/IConsole.h"
#include "Engine/Source/Os/System.h"
#include "Engine/Source/SoundEngine/SoundEngine.h"
#include "Engine/Source/Storm/H/storm.h"
#include "WoW/Source/Game/GameClient/ComSatClient.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
#include "WoW/Source/Ui/GameUI.h"
// VERIFY: 416b0558 auto
// OFFSET: 0x004D0BC0
static bool EnableReverbHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
if (SStrToInt(value)) {
SE2::EnableReverb(1);
SI2::ApplyReverbSettings();
} else {
FMOD_REVERB_PROPERTIES properties = FMOD_PRESET_OFF;
SE2::SetReverb(&properties);
SE2::EnableReverb(0);
}
return true;
}
// VERIFY: 5dc4640a manual
// OFFSET: 0x004D0CB0
static bool VoiceChatInputDriverIndexHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
int32_t index = SStrToInt(value);
char name[256];
memset(name, 0, sizeof(name));
if (SE2::GetInputDriverName(index, name, sizeof(name), 1)) {
static CVar* s_inputDriverName = CVar::Lookup("Sound_VoiceChatInputDriverName");
s_inputDriverName->Set(name, true, false, false, true);
}
return true;
}
// VERIFY: e67c8f37 manual
// OFFSET: 0x004D0D40
static bool VoiceChatOutputDriverIndexHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
int32_t index = SStrToInt(value);
char name[256];
memset(name, 0, sizeof(name));
if (SE2::GetOutputDriverName(index, name, sizeof(name), 1)) {
static CVar* s_outputDriverName = CVar::Lookup("Sound_VoiceChatOutputDriverName");
s_outputDriverName->Set(name, true, false, false, true);
}
return true;
}
// VERIFY: 82450cd2 manual
// OFFSET: 0x004D0DD0
static bool OutputDriverIndexHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
int32_t index = SStrToInt(value);
char name[256];
memset(name, 0, sizeof(name));
if (SE2::GetOutputDriverName(index, name, sizeof(name), 0)) {
static CVar* s_outputDriverName = CVar::Lookup("Sound_OutputDriverName");
s_outputDriverName->Set(name, true, false, false, true);
}
return true;
}
// VERIFY: 65821b05 auto
// OFFSET: 0x004D0E60
static bool MasterVolumeHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
SE2::SetMasterVolume(SStrToFloat(value));
return true;
}
// VERIFY: 1f180752 auto
// OFFSET: 0x004D0E80
static bool SFXVolumeHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
SE2::SetChannelGroupVolume(SI2::s_channelGroupNames[0], SStrToFloat(value));
return true;
}
// VERIFY: 8c1f3d6b auto
// OFFSET: 0x004D0EB0
static bool MusicVolumeHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
SE2::SetChannelGroupVolume("MUSIC", SStrToFloat(value));
SE2::SetChannelGroupVolume("SCRIPTMUSIC", SStrToFloat(value));
return true;
}
// VERIFY: de0d919f auto
// OFFSET: 0x004D0EF0
static bool AmbienceVolumeHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
SE2::SetChannelGroupVolume("AMBIENCE", SStrToFloat(value));
return true;
}
// VERIFY: 8140baa9 auto
// OFFSET: 0x004D0F20
static bool ChaosModeHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
ConsolePrintf("CHAOS!!");
ConsolePrintf("Modes:");
ConsolePrintf("0: Off");
ConsolePrintf("1: Generate 1 random 3d sound per frame");
ConsolePrintf("2: Generate 2 random 3d sounds per frame");
ConsolePrintf("3: Start and stop 1 2d and 1 3d sound every frame");
ConsolePrintf("4: Start and stop 2 2d and 2 3d sounds every frame");
ConsolePrintf("5: Play the same random sound x20 (in 2d) every second");
ConsolePrintf("6: Play the same random sound x20 (in 3d) every second");
ConsolePrintf("7: Play the same random looping sound x20 (in 3d) every second");
ConsolePrintf("8: Play Alert.mp3 from Data folder a lot");
ConsolePrintf("9: Restart game sound system (NOT INCLUDING VOICE CHAT SYSTEM) every 10 seconds");
ConsolePrintf(" ALERT! This mode breaks voice chat, and will cause a crash on game exit.");
ConsolePrintf("10: Mode 2 + Mode 9");
ConsolePrintf("11: Generate 1 random 2d sound per frame");
ConsolePrintf("12: Generate 2 random 2d sounds per frame");
ConsolePrintf("13: Generate 2 random 2d sounds AND 2 random 3d sounds per frame");
ConsolePrintf("14: Mode 10 + Mode 6");
int32_t mode = atol(value);
static CVar* s_disableStreams = CVar::Lookup("Sound_DisableStreams");
if (s_disableStreams) {
if (!mode) {
s_disableStreams->Set("0", true, false, false, true);
return true;
}
s_disableStreams->Set("1", true, false, false, true);
}
return true;
}
// VERIFY: 9f0ddfd9 auto
// OFFSET: 0x004D1050
void SI2::RegisterSoundEngineCVars() {
CVar::Register("StartTalkingDelay", "", 0, "0.0", nullptr, 5, false, nullptr, false);
CVar::Register("StartTalkingTime", "", 0, "1.0", nullptr, 5, false, nullptr, false);
CVar::Register("StopTalkingDelay", "", 0, "0.0", nullptr, 5, false, nullptr, false);
CVar::Register("StopTalkingTime", "", 0, "2.0", nullptr, 5, false, nullptr, false);
CVar::Register("OutboundChatVolume", "The software amplification factor (0.0 - 2.0)", 0, "1.0", OutboundChatVolumeHandler, 5, false, nullptr, false);
CVar::Register("InboundChatVolume", "The volume of all other chat you hear (0.0 - 1.0)", 0, "1.0", InboundChatVolumeHandler, 5, false, nullptr, false);
CVar::Register("VoiceChatMode", "Push to talk(0) or voice activation(1)", 0, "0", VoiceChatModeHandler, 5, false, nullptr, false);
CVar::Register("VoiceActivationSensitivity", "Sensitivity of the microphone (0.0 - 1.0)", 0, "0.4", VoiceActivationSensitivityHandler, 5, false, nullptr, false);
CVar::Register("EnableMicrophone", "Enables the microphone so you can speak.", 0, "1", EnableMicrophoneHandler, 5, false, nullptr, false);
CVar::Register("EnableVoiceChat", "Enables the voice chat feature.", 0, "0", EnableVoiceChatHandler, 5, false, nullptr, false);
CVar::Register("VoiceChatSelfMute", "Turn off your ability to talk.", 0, "0", SelfMuteHandler, 5, false, nullptr, false);
CVar::Register("PushToTalkButton", "String representation of the Push-To-Talk button.", 0, "`", PushToTalkButtonHandler, 5, false, nullptr, false);
CVar::Register("Sound_OutputQuality", "sound quality, default 1 (medium)", 0, "1", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_NumChannels", "number of sound channels", 0, "32", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_EnableReverb", "", 0, "0", EnableReverbHandler, 7, false, nullptr, false);
CVar::Register("Sound_EnableSoftwareHRTF", "", 0, "0", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_VoiceChatInputDriverIndex", "", 0, "0", VoiceChatInputDriverIndexHandler, 7, false, nullptr, false);
CVar::Register("Sound_VoiceChatInputDriverName", "", 0, "Primary Sound Capture Driver", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_VoiceChatOutputDriverIndex", "", 0, "0", VoiceChatOutputDriverIndexHandler, 7, false, nullptr, false);
CVar::Register("Sound_VoiceChatOutputDriverName", "", 0, "Primary Sound Driver", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_OutputDriverIndex", "", 0, "0", OutputDriverIndexHandler, 7, false, nullptr, false);
CVar::Register("Sound_OutputDriverName", "", 0, "Primary Sound Driver", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_DSPBufferSize", "sound buffer size, default 0", 0, "0", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_EnableHardware", "Enables Hardware", 0, "0", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_EnableMode2", "test", 0, "0", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_EnableMixMode2", "test", 0, "0", nullptr, 7, false, nullptr, false);
}
// VERIFY: 3f7da3da auto
// OFFSET: 0x004D13E0
static bool EnableAllSoundHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
if (SStrToInt(value)) {
static CVar* s_enableSFX = CVar::Lookup("Sound_EnableSFX");
static CVar* s_enableMusic = CVar::Lookup("Sound_EnableMusic");
static CVar* s_enableAmbience = CVar::Lookup("Sound_EnableAmbience");
SE2::MuteChannelGroup(SI2::s_channelGroupNames[0], s_enableSFX->m_intValue == 0);
SE2::MuteChannelGroup("MUSIC", s_enableMusic->m_intValue == 0);
SE2::MuteChannelGroup("AMBIENCE", s_enableAmbience->m_intValue == 0);
return true;
}
SE2::MuteChannelGroup(SI2::s_channelGroupNames[0], true);
SE2::MuteChannelGroup("MUSIC", true);
SE2::MuteChannelGroup("AMBIENCE", true);
return true;
}
// VERIFY: d8927d35 manual
// OFFSET: 0x004D14E0
static bool EnableSFXHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
CVar* enableAllSound = CVar::Lookup("Sound_EnableAllSound");
if (enableAllSound) {
SE2::MuteChannelGroup(SI2::s_channelGroupNames[0], !SStrToInt(value) || !enableAllSound->m_intValue);
}
return true;
}
// VERIFY: 34387ca8 manual
// OFFSET: 0x004D1530
static bool EnableAmbienceHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
CVar* enableAllSound = CVar::Lookup("Sound_EnableAllSound");
if (enableAllSound) {
bool mute = !SStrToInt(value) || !enableAllSound->m_intValue || CGGameUI::m_inMovie;
SE2::MuteChannelGroup("AMBIENCE", mute);
if (mute) {
SI2::StopZoneAmbience();
}
}
return true;
}
// VERIFY: c5c182ec auto
// OFFSET: 0x004D1590
static bool EnableMusicHandler(CVar* var, const char* oldValue, const char* value, void* arg) {
CVar* enableAllSound = CVar::Lookup("Sound_EnableAllSound");
if (enableAllSound) {
bool mute = !SStrToInt(value) || !enableAllSound->m_intValue || CGGameUI::m_inMovie;
SE2::MuteChannelGroup("MUSIC", mute);
if (mute) {
SI2::StopAllMusic();
SI2::StopAIMusic();
SI2::StopLuaMusic();
}
}
return true;
}
// VERIFY: 7b1b9794 auto
// OFFSET: 0x004D1600
void SI2::RegisterCVars() {
CVar::Register("ChatMusicVolume", "music volume (0.0 to 1.0)", 0, "0.3", nullptr, 7, false, nullptr, false);
CVar::Register("ChatSoundVolume", "sound volume (0.0 to 1.0)", 0, "0.4", nullptr, 7, false, nullptr, false);
CVar::Register("ChatAmbienceVolume", "Ambience Volume (0.0 to 1.0)", 0, "0.3", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_EnableSFX", "", 0, "1", EnableSFXHandler, 7, false, nullptr, false);
CVar::Register("Sound_EnableAmbience", "Enable Ambience", 0, "1", EnableAmbienceHandler, 7, false, nullptr, false);
CVar::Register("Sound_EnableErrorSpeech", "error speech", 0, "1", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_EnableMusic", "Enables music", 0, "1", EnableMusicHandler, 7, false, nullptr, false);
CVar::Register("Sound_EnableAllSound", "", 0, "1", EnableAllSoundHandler, 7, false, nullptr, false);
CVar::Register("Sound_MasterVolume", "master volume (0.0 to 1.0)", 0, "1.0", MasterVolumeHandler, 7, false, nullptr, false);
CVar::Register("Sound_SFXVolume", "sound volume (0.0 to 1.0)", 0, "1.0", SFXVolumeHandler, 7, false, nullptr, false);
CVar::Register("Sound_MusicVolume", "music volume (0.0 to 1.0)", 0, "0.4", MusicVolumeHandler, 7, false, nullptr, false);
CVar::Register("Sound_AmbienceVolume", "Ambience Volume (0.0 to 1.0)", 0, "0.6", AmbienceVolumeHandler, 7, false, nullptr, false);
CVar::Register("Sound_ListenerAtCharacter", "lock listener at character", 0, "1", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_EnableEmoteSounds", "", 0, "1", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_ZoneMusicNoDelay", "", 0, "0", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_EnableArmorFoleySoundForSelf", "", 0, "1", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_EnableArmorFoleySoundForOthers", "", 0, "1", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_EnableDSPEffects", "", 0, OsGetNumberOfProcessors() <= 1 ? "0" : "1", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_EnablePetSounds", "Enables pet sounds", 0, "1", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_EnableSoundWhenGameIsInBG", "Enable Sound When Game Is In Background", 0, "0", nullptr, 7, false, nullptr, false);
if (CmdLineGetBool(static_cast<CMDOPT>(27))) {
CVar::Register("Sound_ChaosMode", "Testing to break sound engine", 0, "0", ChaosModeHandler, 7, false, nullptr, false);
CVar::Lookup("Sound_ChaosMode")->Set("0", true, false, false, true);
}
CVar::Register("Sound_MaxCacheSizeInBytes", "Max cache size in bytes", 0, "16777216", nullptr, 7, false, nullptr, false);
CVar::Register("Sound_MaxCacheableSizeInBytes", "Max sound size that will be cached, larger files will be streamed instead", 0, "1048576", nullptr, 7, false, nullptr, false);
static CVar* s_enableAllSound = CVar::Lookup("Sound_EnableAllSound");
static CVar* s_enableSFX = CVar::Lookup("Sound_EnableSFX");
static CVar* s_enableErrorSpeech = CVar::Lookup("Sound_EnableErrorSpeech");
static CVar* s_enableEmoteSounds = CVar::Lookup("Sound_EnableEmoteSounds");
static CVar* s_enableMusic = CVar::Lookup("Sound_EnableMusic");
static CVar* s_zoneMusicNoDelay = CVar::Lookup("Sound_ZoneMusicNoDelay");
static CVar* s_enableAmbience = CVar::Lookup("Sound_EnableAmbience");
static CVar* s_listenerAtCharacter = CVar::Lookup("Sound_ListenerAtCharacter");
static CVar* s_enableSoundWhenGameIsInBG = CVar::Lookup("Sound_EnableSoundWhenGameIsInBG");
static CVar* s_enableReverb = CVar::Lookup("Sound_EnableReverb");
static CVar* s_enableSoftwareHRTF = CVar::Lookup("Sound_EnableSoftwareHRTF");
static CVar* s_outputQuality = CVar::Lookup("Sound_OutputQuality");
static CVar* s_numChannels = CVar::Lookup("Sound_NumChannels");
static CVar* s_enableHardware = CVar::Lookup("Sound_EnableHardware");
static CVar* s_masterVolume = CVar::Lookup("Sound_MasterVolume");
static CVar* s_sfxVolume = CVar::Lookup("Sound_SFXVolume");
static CVar* s_musicVolume = CVar::Lookup("Sound_MusicVolume");
static CVar* s_ambienceVolume = CVar::Lookup("Sound_AmbienceVolume");
static CVar* s_enableMixMode2 = CVar::Lookup("Sound_EnableMixMode2");
static CVar* s_armorFoleySelf = CVar::Lookup("Sound_EnableArmorFoleySoundForSelf");
static CVar* s_armorFoleyOthers = CVar::Lookup("Sound_EnableArmorFoleySoundForOthers");
static CVar* s_dspBufferSize = CVar::Lookup("Sound_DSPBufferSize");
SE2::Log_Write("=> User Settings Report:");
SE2::Log_Write(" - ========= PLAYBACK =========");
SE2::Log_Write(" - Enable All Sound [%d]", s_enableAllSound->m_intValue);
SE2::Log_Write(" - Enable SFX [%d]", s_enableSFX->m_intValue);
SE2::Log_Write(" --- Enable Error Speech [%d]", s_enableErrorSpeech->m_intValue);
SE2::Log_Write(" --- Enable Emote Sounds [%d]", s_enableEmoteSounds->m_intValue);
SE2::Log_Write(" - Enable Music [%d]", s_enableMusic->m_intValue);
SE2::Log_Write(" --- Loop Music [%d]", s_zoneMusicNoDelay->m_intValue);
SE2::Log_Write(" - Enable Ambient Sounds [%d]", s_enableAmbience->m_intValue);
SE2::Log_Write(" - Sound at Character [%d]", s_listenerAtCharacter->m_intValue);
SE2::Log_Write(" - Sound in Background [%d]", s_enableSoundWhenGameIsInBG->m_intValue);
SE2::Log_Write(" - Enable Reverb [%d]", s_enableReverb->m_intValue);
SE2::Log_Write(" - Enable Software HRTF [%d]", s_enableSoftwareHRTF->m_intValue);
SE2::Log_Write(" - Sound Quality [%d]", s_outputQuality->m_intValue);
SE2::Log_Write(" -");
SE2::Log_Write(" - ========== VOLUME ==========");
SE2::Log_Write(" - Master Volume [%.2f]", s_masterVolume->m_floatValue);
SE2::Log_Write(" - SFX Volume [%.2f]", s_sfxVolume->m_floatValue);
SE2::Log_Write(" - Music Volume [%.2f]", s_musicVolume->m_floatValue);
SE2::Log_Write(" - Ambience Volume [%.2f]", s_ambienceVolume->m_floatValue);
SE2::Log_Write(" -");
SE2::Log_Write(" - =========== MISC ===========");
SE2::Log_Write(" - Sound Channels [%d]", s_numChannels->m_intValue);
SE2::Log_Write(" - Use Hardware [%d]", s_enableHardware->m_intValue);
SE2::Log_Write(" - Mix Mode 2 [%d]", s_enableMixMode2->m_intValue);
if (s_dspBufferSize->m_intValue) {
SE2::Log_Write(" - DSP Buffer Size [%d]", s_enableAmbience->m_intValue);
} else {
SE2::Log_Write(" - DSP Buffer Size [AUTO]");
}
SE2::Log_Write(" - Armor Foley SFX (Self) [%d]", s_armorFoleySelf->m_intValue);
SE2::Log_Write(" - Armor Foley SFX (Others) [%d]", s_armorFoleyOthers->m_intValue);
SE2::Log_Write("=> End of User Settings Report");
}
@@ -0,0 +1,214 @@
#include <cstddef>
#include <cstdint>
#include "WoW/Source/SoundInterface/SoundInterface2Combat.h"
#include "Engine/Source/Storm/H/stpl.h"
#include "WoW/Source/DB/DBClient/DBClient.h"
#include "WoW/Source/Object/ObjectClient/Item_C.h"
#include "WoW/Source/Object/ObjectClient/Unit_C.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
// STATIC: 0x00B4AE7C
static TSFixedArray<IMPACTSOUNDARRAY> s_impactSounds;
// STATIC: 0x00B4AE88
static int32_t s_swingSounds[3][2];
// VERIFY: 647f0380 auto
// OFFSET: 0x007DA1F0
IMPACTSOUND::IMPACTSOUND() {
this->m_soundId = 0;
this->m_critSoundId = 0;
}
// VERIFY: 2250fb03 manual
// OFFSET: 0x004D0380
static void InitWeaponImpactSound(WeaponImpactSoundsRec* rec) {
if (!s_impactSounds.m_count) {
return;
}
IMPACTSOUNDARRAY* sounds = &s_impactSounds.m_data[rec->m_weaponSubClassID];
for (int32_t i = 0; i < 10; i++) {
sounds->m_sounds[i][rec->m_parrySoundType].m_soundId = rec->m_impactSoundID[i];
sounds->m_sounds[i][rec->m_parrySoundType].m_critSoundId = rec->m_critImpactSoundID[i];
}
}
// VERIFY: d720637a auto
// OFFSET: 0x004D04E0
void SI2::InitWeaponSwingCombatSounds() {
for (int32_t i = g_weaponSwingSounds2DB.m_numRecords; i;) {
i--;
WeaponSwingSounds2Rec* rec = (i < 0 || i >= g_weaponSwingSounds2DB.m_numRecords) ? nullptr : &g_weaponSwingSounds2DB.m_records[i];
if (rec && rec->m_swingType < 3 && rec->m_crit < 2) {
s_swingSounds[rec->m_swingType][rec->m_crit != 0] = rec->m_soundID;
}
}
}
// VERIFY: df290633 manual
// OFFSET: 0x004D0540
void SI2::PlayParrySound(const CGUnitVirtualItem* weapon, const CGUnitVirtualItem* defender, int32_t crit, const C3Vector* position, int32_t self) {
if (!s_impactSounds.m_count) {
return;
}
int32_t subclass;
int32_t metal;
if (weapon) {
subclass = weapon->m_soundOverrideSubclassID;
if (subclass == 0xFF) {
subclass = weapon->m_subclassID;
}
metal = CGItem_C::IsMetal(weapon->m_material);
} else {
metal = 0;
subclass = ClientDBGetUnarmedWeapon();
}
int32_t type = 6;
if (defender) {
if (defender->m_classID == 2) {
type = 6 - CGItem_C::IsMetal(defender->m_material);
} else if (defender->m_classID == 4) {
type = 4 - CGItem_C::IsMetal(defender->m_material);
}
}
IMPACTSOUND* sound = &s_impactSounds.m_data[subclass].m_sounds[type][metal];
C3Vector soundPosition;
soundPosition.x = position->x;
soundPosition.y = position->y;
soundPosition.z = position->z + 2.0f;
SE2SoundKitProperties properties;
properties.ResetToDefaults();
properties.m_group = 14;
if (self) {
properties.m_priority = 110;
}
SI2::PlaySoundKit(crit != 0 ? sound->m_critSoundId : sound->m_soundId, &soundPosition, nullptr, &properties, 0, nullptr, 1, 0);
}
// VERIFY: 4ec94dcc manual
// OFFSET: 0x004D0660
void SI2::PlayHitSound(const CGUnitVirtualItem* weapon, int32_t impactType, int32_t crit, const C3Vector* position, int32_t self) {
if (!s_impactSounds.m_count) {
return;
}
int32_t subclass;
int32_t metal;
if (weapon) {
subclass = weapon->m_soundOverrideSubclassID;
if (subclass == 0xFF) {
subclass = weapon->m_subclassID;
}
metal = CGItem_C::IsMetal(weapon->m_material);
} else {
metal = 0;
subclass = ClientDBGetUnarmedWeapon();
}
IMPACTSOUND* sound = &s_impactSounds.m_data[subclass].m_sounds[impactType][metal];
SE2SoundKitProperties properties;
properties.ResetToDefaults();
properties.m_group = 14;
if (self) {
properties.m_priority = 110;
}
SI2::PlaySoundKit(crit != 0 ? sound->m_critSoundId : sound->m_soundId, position, nullptr, &properties, 0, nullptr, 1, 0);
}
// VERIFY: 1275dcb8 manual
// OFFSET: 0x004D0720
int32_t SI2::PlayWeaponSwooshSound(int32_t type, int32_t crit, const C3Vector* position, int32_t quiet, int32_t self) {
if (type >= 3) {
return 0;
}
float volume = quiet ? 0.5f : 1.0f;
SE2SoundKitProperties properties;
properties.ResetToDefaults();
properties.m_volume = volume;
properties.m_group = 10;
if (self) {
properties.m_priority = 110;
}
return SI2::PlaySoundKit(s_swingSounds[type][crit != 0], position, nullptr, &properties, 0, nullptr, 1, 0);
}
// VERIFY: 4281e82d manual
// OFFSET: 0x004D07B0
int32_t SI2::PlaySheatheSound(const CGUnitVirtualItem* item, int32_t sheathe, const C3Vector* position, int32_t self) {
if (!item) {
return 0;
}
MaterialRec* material = g_materialDB.GetRecord(item->m_material);
if (!material) {
return 0;
}
C3Vector soundPosition;
soundPosition.x = position->x;
soundPosition.y = position->y;
soundPosition.z = position->z + 2.0f;
int32_t soundKitId = sheathe ? material->m_sheatheSoundID : material->m_unsheatheSoundID;
SE2SoundKitProperties properties;
properties.ResetToDefaults();
if (self) {
properties.m_priority = 110;
}
return SI2::PlaySoundKit(soundKitId, &soundPosition, nullptr, &properties, 0, nullptr, 1, 0);
}
// VERIFY: c557bfee auto
// OFFSET: 0x004D0850
int32_t SI2::PlayMissedSound(bool oneHand, const C3Vector* position, int32_t self) {
SE2SoundKitProperties properties;
properties.ResetToDefaults();
if (self) {
properties.m_priority = 110;
}
return SI2::PlaySoundKit(oneHand ? "(DONOTRENAME)Combat Miss 1H" : "(DONOTRENAME)Combat Miss 2H", position, nullptr, &properties);
}
// VERIFY: 3aee2ee4 manual
// OFFSET: 0x004D0B70
void SI2::InitWeaponImpactCombatSounds() {
s_impactSounds.SetCount(ClientDBGetNumWeaponSubClasses());
for (int32_t i = g_weaponImpactSoundsDB.m_numRecords; i;) {
i--;
WeaponImpactSoundsRec* rec = (i < 0 || i >= g_weaponImpactSoundsDB.m_numRecords) ? nullptr : &g_weaponImpactSoundsDB.m_records[i];
InitWeaponImpactSound(rec);
}
}
@@ -0,0 +1,18 @@
#ifndef WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2COMBAT_H
#define WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2COMBAT_H
#include <cstddef>
#include <cstdint>
struct IMPACTSOUND {
/* 0000 */ int32_t m_soundId;
/* 0004 */ int32_t m_critSoundId;
IMPACTSOUND();
};
struct IMPACTSOUNDARRAY {
/* 0000 */ IMPACTSOUND m_sounds[10][2];
};
#endif
@@ -0,0 +1,215 @@
#include <cstddef>
#include <cstdint>
#include <new>
#include "WoW/Source/SoundInterface/SoundInterface2DSP.h"
#include "Engine/Source/ConsoleBase/ConsoleVar.h"
#include "Engine/Source/SoundEngine/SoundEngine.h"
#include "Engine/Source/Storm/H/storm.h"
#include "WoW/Source/DB/DBClient/DBClient.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
// STATIC: 0x00B4ADB4
static TSHashTable<DSP_CHAIN_HEAD_LOOKUP, HASHKEY_STRI> s_dspChains;
// VERIFY: 4b244940 auto
// OFFSET: 0x004CD9D0
static FMOD_DSP_TYPE TranslateDspType(int32_t type) {
switch (type) {
case SI2_DSP_TYPE_PITCHSHIFT:
return FMOD_DSP_TYPE_PITCHSHIFT;
case SI2_DSP_TYPE_HIGHPASS:
return FMOD_DSP_TYPE_HIGHPASS;
case SI2_DSP_TYPE_LOWPASS:
return FMOD_DSP_TYPE_LOWPASS;
case SI2_DSP_TYPE_CHORUS:
return FMOD_DSP_TYPE_CHORUS;
case SI2_DSP_TYPE_ECHO:
return FMOD_DSP_TYPE_ECHO;
default:
return FMOD_DSP_TYPE_UNKNOWN;
}
}
// INLINED
SI2DspNode::SI2DspNode() {
this->m_dsp = nullptr;
this->m_type = -1;
}
// INLINED
SI2DspChainHead::SI2DspChainHead() {
this->m_expireTime = 0.1f;
}
// VERIFY: 3a7e7c8c manual
// OFFSET: 0x004CDC80
void SI2::DSP_MakeDSPsExpire(float elapsed) {
for (DSP_CHAIN_HEAD_LOOKUP* head = s_dspChains.m_fulllist.Head(); head; head = s_dspChains.m_fulllist.Next(head)) {
if (SE2::GetChannelGroupNumChannels(head->m_chain.m_channelGroup)) {
continue;
}
if (head->m_chain.m_expireTime > 0.0f && head->m_chain.m_expireTime - elapsed <= 0.0f) {
for (SI2DspNode* node = head->m_chain.m_nodes.Head(); node; node = head->m_chain.m_nodes.Next(node)) {
SE2::EnableDSP(node->m_dsp, false);
}
}
head->m_chain.m_expireTime -= elapsed;
if (head->m_chain.m_expireTime < 0.0f) {
head->m_chain.m_expireTime = 0.0f;
}
}
}
// VERIFY: 427289d5 manual
// OFFSET: 0x004CDD40
void SI2::DSP_ShutDown() {
for (DSP_CHAIN_HEAD_LOOKUP* head = s_dspChains.m_fulllist.Head(); head; head = s_dspChains.m_fulllist.Next(head)) {
for (SI2DspNode* node = head->m_chain.m_nodes.Head(); node; node = head->m_chain.m_nodes.Next(node)) {
SE2::DspDestroy(node->m_dsp);
node->m_dsp = nullptr;
}
head->m_chain.m_nodes.Clear();
if (head->m_chain.m_channelGroup) {
SE2::DestroyChannelGroup(head->m_chain.m_channelGroup);
head->m_chain.m_channelGroup = nullptr;
}
}
s_dspChains.Clear();
}
// VERIFY: 015e69f4 manual
// OFFSET: 0x004CDF70
void SI2::DSP_CreateDsp(const char* name, int32_t type, const float* params) {
static CVar* s_enableDSPEffects = CVar::Lookup("Sound_EnableDSPEffects");
if (!s_enableDSPEffects->m_intValue) {
return;
}
SI2DspNode* node = new (SMemAlloc(sizeof(SI2DspNode), __FILE__, __LINE__, 0)) SI2DspNode();
if (type != SI2_DSP_TYPE_VOLUME && SE2::CreateDSPByType(TranslateDspType(type), &node->m_dsp)) {
if (node) {
delete node;
}
return;
}
DSP_CHAIN_HEAD_LOOKUP* head = s_dspChains.Ptr(name);
head->m_chain.m_nodes.LinkToTail(node);
node->m_type = type;
switch (type) {
case SI2_DSP_TYPE_PITCHSHIFT:
SE2::SetDspParam(node->m_dsp, 0, params[1]);
SE2::SetDspParam(node->m_dsp, 1, 512.0f);
break;
case SI2_DSP_TYPE_HIGHPASS:
case SI2_DSP_TYPE_LOWPASS:
SE2::SetDspParam(node->m_dsp, 0, params[1]);
SE2::SetDspParam(node->m_dsp, 1, params[2]);
break;
case SI2_DSP_TYPE_CHORUS:
SE2::SetDspParam(node->m_dsp, 0, params[1]);
SE2::SetDspParam(node->m_dsp, 1, params[2]);
SE2::SetDspParam(node->m_dsp, 2, params[3]);
SE2::SetDspParam(node->m_dsp, 3, params[4]);
SE2::SetDspParam(node->m_dsp, 4, params[5]);
SE2::SetDspParam(node->m_dsp, 5, params[6]);
SE2::SetDspParam(node->m_dsp, 6, params[7]);
SE2::SetDspParam(node->m_dsp, 7, params[8]);
break;
case SI2_DSP_TYPE_ECHO:
SE2::SetDspParam(node->m_dsp, 0, params[1]);
SE2::SetDspParam(node->m_dsp, 1, params[2]);
SE2::SetDspParam(node->m_dsp, 3, params[3]);
SE2::SetDspParam(node->m_dsp, 4, params[4]);
break;
case SI2_DSP_TYPE_VOLUME:
if (params[0] > 0.0f) {
SE2::SetFMODChannelGroupVolume(head->m_chain.m_channelGroup, params[1]);
}
break;
default:
break;
}
if (type != SI2_DSP_TYPE_VOLUME) {
SE2::BypassDsp(node->m_dsp, 0.0f == params[0]);
SE2::ConnectDspToChannelGroup(node->m_dsp, head->m_chain.m_channelGroup);
}
}
// VERIFY: e4c6f172 manual
// OFFSET: 0x004CE250
void SI2::DSP_AttachCustomDspChain(FMOD::Channel* channel, char* name) {
DSP_CHAIN_HEAD_LOOKUP* head = s_dspChains.Ptr(name);
if (!head) {
return;
}
for (SI2DspNode* node = head->m_chain.m_nodes.Head(); node; node = head->m_chain.m_nodes.Next(node)) {
SE2::EnableDSP(node->m_dsp, true);
}
head->m_chain.m_expireTime = 3.0f;
SE2::AddChannelToChannelGroup(channel, head->m_chain.m_channelGroup);
}
// VERIFY: 1f3d2404 manual
// OFFSET: 0x004CE7C0
void SI2::DSP_Init() {
for (int32_t i = 0; i < g_soundFilterDB.m_numRecords; i++) {
SoundFilterRec* rec = (i < 0 || i >= g_soundFilterDB.m_numRecords) ? nullptr : &g_soundFilterDB.m_records[i];
if (s_dspChains.Ptr(rec->m_name)) {
continue;
}
const char* name = rec->m_name;
DSP_CHAIN_HEAD_LOOKUP* head = s_dspChains.New(name, 0, 0);
for (SI2DspNode* node = head->m_chain.m_nodes.Head(); node; node = head->m_chain.m_nodes.Next(node)) {
SE2::DspDestroy(node->m_dsp);
node->m_dsp = nullptr;
}
head->m_chain.m_nodes.Clear();
if (!head->m_chain.m_channelGroup) {
head->m_chain.m_channelGroup = SE2::CreateChannelGroup(rec->m_name);
}
}
for (int32_t i = 0; i < g_soundFilterElemDB.m_numRecords; i++) {
SoundFilterElemRec* elem = (i < 0 || i >= g_soundFilterElemDB.m_numRecords) ? nullptr : &g_soundFilterElemDB.m_records[i];
SoundFilterRec* filter = g_soundFilterDB.GetRecord(elem->m_soundFilterID);
SI2::DSP_CreateDsp(filter->m_name, elem->m_filterType, elem->m_params);
}
for (DSP_CHAIN_HEAD_LOOKUP* head = s_dspChains.m_fulllist.Head(); head; head = s_dspChains.m_fulllist.Next(head)) {
for (SI2DspNode* node = head->m_chain.m_nodes.Head(); node; node = head->m_chain.m_nodes.Next(node)) {
SE2::EnableDSP(node->m_dsp, false);
}
}
}
@@ -0,0 +1,31 @@
#ifndef WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2DSP_H
#define WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2DSP_H
#include <cstddef>
#include <cstdint>
#include "Engine/Source/SoundEngine/fmodex/src/fmod.hpp"
#include "Engine/Source/Storm/H/stpl.h"
#include "WoW/Source/SoundInterface/Types.h"
class SI2DspNode : public TSLinkedNode<SI2DspNode> {
public:
/* 0008 */ FMOD::DSP* m_dsp;
/* 000C */ int32_t m_type;
SI2DspNode();
};
class SI2DspChainHead {
public:
/* 0000 */ TSList<SI2DspNode, TSGetLink<SI2DspNode> > m_nodes;
/* 000C */ FMOD::ChannelGroup* m_channelGroup;
/* 0010 */ float m_expireTime;
SI2DspChainHead();
};
struct DSP_CHAIN_HEAD_LOOKUP : public TSHashObject<DSP_CHAIN_HEAD_LOOKUP, HASHKEY_STRI> {
/* 0018 */ SI2DspChainHead m_chain;
};
#endif
@@ -0,0 +1,110 @@
#include <cstddef>
#include <cstdint>
#include <cstring>
#include "WoW/Source/SoundInterface/SoundInterface2Emotes.h"
#include "Engine/Source/Storm/H/stpl.h"
#include "WoW/Source/DB/DBClient/DBClient.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
#include "WoW/Source/SoundInterface/SoundInterface2Internal.h"
// STATIC: 0x00B4ADE4
static TSGrowableArray<TEXTEMOTELOOKUP> s_textEmoteLookups;
// STATIC: 0x00B4ADF0
static int32_t s_numTextEmotes;
// STATIC: 0x00B4ADF4
static TSGrowableArray<TEXTEMOTELOOKUP*> s_textEmoteLookupById;
// INLINED
TEXTEMOTELOOKUP::TEXTEMOTELOOKUP() {
this->m_emotesTextId = 0;
memset(this->m_soundIds, 0, sizeof(this->m_soundIds));
}
// VERIFY: b8c12fce auto
// OFFSET: 0x004CEB30
int32_t SI2::GetTextEmoteSoundID(uint32_t emotesTextId, uint32_t race, uint32_t sex) {
TEXTEMOTELOOKUP* lookup;
if (emotesTextId < s_textEmoteLookupById.Count() && (lookup = s_textEmoteLookupById[emotesTextId]) != nullptr && race < 22 && sex < 2) {
return lookup->m_soundIds[race][sex];
}
return 0;
}
// VERIFY: 8c9fb06d auto
// OFFSET: 0x004CEB70
int32_t SI2::GetTextEmoteSoundIndex(uint32_t emotesTextId, uint32_t race, uint32_t sex) {
TEXTEMOTELOOKUP* lookup;
int32_t soundKitId;
if (emotesTextId < s_textEmoteLookupById.Count() && (lookup = s_textEmoteLookupById[emotesTextId]) != nullptr && race < 22 && sex < 2) {
soundKitId = lookup->m_soundIds[race][sex];
} else {
soundKitId = 0;
}
VSOUNDKITDEF* def = SI2::GetSoundKitDef(soundKitId);
if (!def || !def->m_numFiles) {
return -1;
}
int32_t index = 0;
def->SelectFile(2, &index, -1, 5);
return index;
}
// VERIFY: bf97a618 auto
// OFFSET: 0x004CECB0
void SI2::InitEmoteSounds() {
if (!g_emotesTextDB.m_numRecords || !g_emotesTextSoundDB.m_numRecords) {
return;
}
s_textEmoteLookupById.SetCount(g_emotesTextDB.m_maxID + 1);
memset(s_textEmoteLookupById.Ptr(), 0, sizeof(TEXTEMOTELOOKUP*) * s_textEmoteLookupById.Count());
int32_t last = -1;
int32_t count = 0;
for (int32_t i = 0; i < g_emotesTextSoundDB.m_numRecords; i++) {
EmotesTextSoundRec* rec = (i < 0 || i >= g_emotesTextSoundDB.m_numRecords) ? nullptr : &g_emotesTextSoundDB.m_records[i];
if (last == -1 || last != rec->m_emotesTextID) {
last = rec->m_emotesTextID;
count++;
}
}
s_numTextEmotes = count;
for (int32_t i = 0; i < g_emotesTextSoundDB.m_numRecords; i++) {
EmotesTextSoundRec* rec = (i < 0 || i >= g_emotesTextSoundDB.m_numRecords) ? nullptr : &g_emotesTextSoundDB.m_records[i];
uint32_t id = rec->m_emotesTextID;
if (id >= s_textEmoteLookupById.Count()) {
continue;
}
TEXTEMOTELOOKUP** slot = &s_textEmoteLookupById[id];
if (!*slot) {
*slot = s_textEmoteLookups.New();
(*slot)->m_emotesTextId = rec->m_emotesTextID;
}
if (static_cast<uint32_t>(rec->m_raceID) < 22 && static_cast<uint32_t>(rec->m_sexID) < 2) {
(*slot)->m_soundIds[rec->m_raceID][rec->m_sexID] = rec->m_soundID;
}
}
}
// VERIFY: cf5849ee manual
// OFFSET: 0x004CEDF0
void SI2::FreeEmoteSounds() {
s_textEmoteLookups.Clear();
s_textEmoteLookupById.Clear();
}
@@ -0,0 +1,14 @@
#ifndef WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2EMOTES_H
#define WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2EMOTES_H
#include <cstddef>
#include <cstdint>
struct TEXTEMOTELOOKUP {
/* 0000 */ int32_t m_soundIds[22][2];
/* 00B0 */ int32_t m_emotesTextId;
TEXTEMOTELOOKUP();
};
#endif
@@ -0,0 +1,119 @@
#include <cstddef>
#include <cstdint>
#include "Engine/Source/ConsoleBase/ConsoleVar.h"
#include "Engine/Source/SoundEngine/SoundEngine.h"
#include "WoW/Source/DB/DBClient/DBClient.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
#include "WoW/Source/Ui/ChatFrame.h"
// STATIC: 0x00B4AE40
int32_t CGChat::m_paused;
// VERIFY: 88e41fa1 auto
// OFFSET: 0x004CFB50
void SI2::SetPitch(SE2SoundKitObject* object, float pitch) {
object->m_sound.SetPitch(pitch);
}
// VERIFY: f573d0ba auto
// OFFSET: 0x004CFB70
void SI2::Detach(SE2SoundKitObject* object) {
object->m_sound.Detach();
}
// VERIFY: f6cf06fb auto
// OFFSET: 0x004CFB80
void CGChat::LeaveWorld() {
CGChat::m_paused++;
}
// VERIFY: 62ef2d2f auto
// OFFSET: 0x004CFB90
void CGChat::Resume() {
CGChat::m_paused--;
}
// VERIFY: 7732767c auto
// OFFSET: 0x004CFBA0
int32_t CGChat::IsPaused() {
return CGChat::m_paused;
}
// VERIFY: f4fa7734 manual
// OFFSET: 0x004CFC10
int32_t SI2::PlayFoleySound(int32_t materialId, const C3Vector* position, int32_t self) {
MaterialRec* material = g_materialDB.GetRecord(materialId);
if (!material || !material->m_foleySoundID) {
return 0;
}
C3Vector soundPosition;
soundPosition.x = position->x;
soundPosition.y = position->y;
soundPosition.z = position->z + 2.0f;
if (!self) {
return SI2::PlaySoundKit(material->m_foleySoundID, &soundPosition, nullptr, nullptr, 0, nullptr, 1, 0);
}
static CVar* s_listenerAtCharacter = CVar::Lookup("Sound_ListenerAtCharacter");
int32_t listenerAtCharacter = s_listenerAtCharacter->m_intValue;
SE2SoundKitProperties properties;
properties.ResetToDefaults();
if (listenerAtCharacter) {
properties.m_volumeScale = 0.65f;
}
properties.m_priority = 110;
return SI2::PlaySoundKit(material->m_foleySoundID, listenerAtCharacter == 0 ? &soundPosition : nullptr, nullptr, &properties, 0, nullptr, 1, 0);
}
// VERIFY: 9dd45739 manual
// OFFSET: 0x004CFE00
int32_t SI2::IsTooCloseToExistingSoundKit(int32_t soundKitId, const C3Vector* position) {
SEChannelInfo info[512];
uint32_t hardwareCount;
uint32_t softwareCount;
uint32_t virtualCount;
uint32_t loadingCount;
uint32_t otherCount;
int32_t count = SE2::GetChannelInfo(info, 512, 1, 1, 0, 0, &hardwareCount, &softwareCount, &virtualCount, &loadingCount, &otherCount);
for (int32_t i = 0; i < count; i++) {
SI2SoundUserData* userData = static_cast<SI2SoundUserData*>(info[i].m_userData);
if (userData && userData->m_soundKitId == soundKitId) {
float dx = position->x - info[i].m_position.x;
float dy = position->y - info[i].m_position.y;
float dz = position->z - info[i].m_position.z;
if (dx * dx + dz * dz + dy * dy < 6.0f) {
return 1;
}
}
}
return 0;
}
// VERIFY: fc148494 manual
// OFFSET: 0x004D0090
void SI2::PlayItemSound(int32_t type, int32_t displayId) {
ItemDisplayInfoRec display;
if (!g_itemDisplayInfoDB.GetRecord(displayId, &display)) {
return;
}
ItemGroupSoundsRec* sounds = g_itemGroupSoundsDB.GetRecord(display.m_groupSoundIndex);
if (sounds) {
SI2::PlaySoundKit(sounds->m_sound[type], nullptr, nullptr, nullptr, 0, nullptr, 1, 0);
}
}
@@ -0,0 +1,135 @@
#include <cstddef>
#include <cstdint>
#include "WoW/Source/SoundInterface/SoundInterface2Footsteps.h"
#include "Engine/Source/ConsoleBase/ConsoleVar.h"
#include "WoW/Source/DB/DBClient/DBClient.h"
#include "WoW/Source/Object/ObjectClient/Unit_C.h"
#include "WoW/Source/ObjectMgrClient/ObjectMgrClient.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
// STATIC: 0x00B4AE04
static HASHKEY_NONE s_footstepKey;
// STATIC: 0x00B4AE10
static TSHashTable<FOOTSTEPSNDCACHE, HASHKEY_NONE> s_footstepSounds;
// VERIFY: 3cde8edb auto
// OFFSET: 0x004CEE50
bool CGUnit_C::IsActivePlayer() {
return (static_cast<uint64_t>(this->m_obj->m_guid.m_guidHigh) << 32 | this->m_obj->m_guid.m_guidLow) == ClntObjMgrGetActivePlayer();
}
// VERIFY: 1432f0e0 manual
// OFFSET: 0x004CF060
void SI2::FreeFootstepSounds() {
s_footstepSounds.Clear();
}
// VERIFY: 8151ef99 manual
// OFFSET: 0x004CF100
static uint32_t GetFootstepSound(int32_t terrainType, int32_t footstepId, int32_t splash) {
TerrainTypeRec* terrain = g_terrainTypeDB.GetRecord(terrainType);
if (!terrain) {
return 0;
}
int32_t index = terrain->m_soundID;
FOOTSTEPSNDCACHE* cache = s_footstepSounds.Ptr(footstepId, s_footstepKey);
if (!cache) {
return 0;
}
if (splash) {
return cache->m_splashSounds[index];
}
return cache->m_sounds[index];
}
// VERIFY: 508a3422 manual
// OFFSET: 0x004CF170
void SI2::PlayFootstepSound(int32_t footstepId, const C3Vector* position, int32_t terrainType, int32_t splash, int32_t loud, CGUnit_C* unit) {
if (!unit) {
return;
}
static CVar* s_listenerAtCharacter = CVar::Lookup("Sound_ListenerAtCharacter");
if (!s_listenerAtCharacter) {
return;
}
uint32_t soundKitId = GetFootstepSound(terrainType, footstepId, splash);
if (!soundKitId) {
soundKitId = GetFootstepSound(0, footstepId, splash);
if (!soundKitId) {
return;
}
}
SE2SoundKitProperties properties;
if ((unit->m_obj->m_type & TYPEMASK_PLAYER) && unit->IsActivePlayer() && s_listenerAtCharacter->m_intValue) {
properties.ResetToDefaults();
properties.m_maxDistance = loud ? 50.0f : 20.0f;
properties.m_volumeScale = 0.65f;
properties.m_group = 17;
properties.m_priority = 115;
SI2::PlaySoundKit(soundKitId, nullptr, nullptr, &properties, 0, nullptr, 1, 0);
} else if ((unit->m_obj->m_type & TYPEMASK_PLAYER) && unit->IsActivePlayer()) {
properties.ResetToDefaults();
properties.m_group = 17;
properties.m_priority = 115;
SI2::PlaySoundKit(soundKitId, position, nullptr, &properties, 0, nullptr, 1, 0);
} else {
properties.ResetToDefaults();
properties.m_group = 13;
properties.m_maxAudibleBehavior = 0;
SI2::PlaySoundKit(soundKitId, position, nullptr, &properties, 0, nullptr, 1, 0);
}
}
// VERIFY: 25b83170 auto
// OFFSET: 0x004CF490
FOOTSTEPSNDCACHE::FOOTSTEPSNDCACHE() {
this->m_sounds.Clear();
this->m_splashSounds.Clear();
}
// VERIFY: b9aab4ae manual
// OFFSET: 0x004CF990
void SI2::InitFootstepSounds() {
s_footstepSounds.Clear();
uint32_t count = g_terrainTypeSoundsDB.m_maxID + 1;
for (int32_t i = g_footstepTerrainLookupDB.m_numRecords; i;) {
i--;
FootstepTerrainLookupRec* rec = (i < 0 || i >= g_footstepTerrainLookupDB.m_numRecords) ? nullptr : &g_footstepTerrainLookupDB.m_records[i];
if (!rec || rec->m_terrainSoundID < 0) {
continue;
}
FOOTSTEPSNDCACHE* cache = s_footstepSounds.Ptr(rec->m_creatureFootstepID, s_footstepKey);
if (!cache) {
cache = s_footstepSounds.New(rec->m_creatureFootstepID, s_footstepKey, 0, 0);
cache->m_sounds.SetCount(count);
cache->m_splashSounds.SetCount(count);
for (uint32_t j = 0; j < count; j++) {
cache->m_sounds[j] = 0;
cache->m_splashSounds[j] = 0;
}
}
cache->m_sounds[rec->m_terrainSoundID] = rec->m_soundID;
cache->m_splashSounds[rec->m_terrainSoundID] = rec->m_soundIdsplash;
}
}
@@ -0,0 +1,15 @@
#ifndef WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2FOOTSTEPS_H
#define WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2FOOTSTEPS_H
#include <cstddef>
#include <cstdint>
#include "Engine/Source/Storm/H/stpl.h"
struct FOOTSTEPSNDCACHE : public TSHashObject<FOOTSTEPSNDCACHE, HASHKEY_NONE> {
/* 0018 */ TSGrowableArray<uint32_t> m_sounds;
/* 0028 */ TSGrowableArray<uint32_t> m_splashSounds;
FOOTSTEPSNDCACHE();
};
#endif
@@ -0,0 +1,169 @@
#include <cstddef>
#include <cstdint>
#include "Engine/Source/Event/Event.h"
#include "Engine/Source/Storm/H/storm.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
#include "WoW/Source/SoundInterface/SoundInterface2Internal.h"
// STATIC: 0x00DCE8E8
static char s_creditsMusicName[128];
// STATIC: 0x00DCE968
static char s_glueMusicName[128];
// STATIC: 0x00DCE9E8
static char s_glueAmbienceName[128];
// STATIC: 0x00DCEA68
static SE2SoundKitObject s_creditsMusic;
// STATIC: 0x00DCEA7C
static SE2SoundKitObject s_glueMusic;
// STATIC: 0x00DCEA90
static SE2SoundKitObject s_glueAmbience;
// VERIFY: f19203b8 auto
// OFFSET: 0x00985F70
void SI2::StopGlueAmbience(float fadeOutTime) {
if (fadeOutTime < 0.0f) {
fadeOutTime = -1.0f;
}
SI2::StopSound(&s_glueAmbience, 0, fadeOutTime, 1);
}
// VERIFY: 57028033 auto
// OFFSET: 0x00985FB0
void SI2::StartGlueAmbience(const char* name, float fadeInTime) {
if (SI2::IsPlaying(&s_glueAmbience)) {
VSOUNDKITDEF* def = SI2::GetSoundKitDef(SI2::LookupSoundKitId(name));
SI2SoundUserData* userData = static_cast<SI2SoundUserData*>(s_glueAmbience.m_sound.GetUserData());
if (def && userData && def->m_id == userData->m_soundKitId) {
return;
}
}
SI2::StopSound(&s_glueAmbience, 0, 3.0f, 1);
if (!name) {
return;
}
SStrCopy(s_glueAmbienceName, name, sizeof(s_glueAmbienceName));
SE2SoundKitProperties properties;
properties.ResetToDefaults();
properties.m_fadeInTime = fadeInTime;
properties.m_group = 2;
properties.m_loopMode = 1;
properties.m_decodeBufferSize = 0;
SI2::PlaySoundKit(s_glueAmbienceName, nullptr, &s_glueAmbience, &properties);
}
// VERIFY: ba080d04 auto
// OFFSET: 0x00986080
int32_t SI2::GlueMusicUpdate(const void* data, void* param) {
if (!SI2::IsPlaying(&s_glueMusic)) {
SE2SoundKitProperties properties;
properties.ResetToDefaults();
properties.m_group = 1;
properties.m_decodeBufferSize = 0;
SI2::PlaySoundKit(s_glueMusicName, nullptr, &s_glueMusic, &properties);
}
return 1;
}
// VERIFY: 6c059ee6 auto
// OFFSET: 0x009860E0
void SI2::StopGlueMusic(float fadeOutTime) {
EventUnregister(EVENT_ID_POLL, SI2::GlueMusicUpdate);
s_glueMusicName[0] = '\0';
if (fadeOutTime < 0.0f) {
fadeOutTime = -1.0f;
}
SI2::StopSound(&s_glueMusic, 0, fadeOutTime, 1);
}
// VERIFY: 8d99a4e4 auto
// OFFSET: 0x00986130
int32_t SI2::CreditsMusicUpdate(const void* data, void* param) {
if (!SI2::IsPlaying(&s_creditsMusic)) {
SE2SoundKitProperties properties;
properties.ResetToDefaults();
properties.m_group = 1;
properties.m_selectMode = 0;
SI2::PlaySoundKit(s_creditsMusicName, nullptr, &s_creditsMusic, &properties);
}
return 1;
}
// VERIFY: c72e61eb auto
// OFFSET: 0x00986190
void SI2::StopCreditsMusic() {
EventUnregister(EVENT_ID_POLL, SI2::CreditsMusicUpdate);
SI2::StopSound(&s_creditsMusic, 0, 3.0f, 1);
}
// VERIFY: b62c8d0a auto
// OFFSET: 0x009861C0
void SI2::StartGlueMusic(const char* name) {
if (SI2::IsPlaying(&s_glueMusic)) {
VSOUNDKITDEF* def = SI2::GetSoundKitDef(SI2::LookupSoundKitId(name));
SI2SoundUserData* userData = static_cast<SI2SoundUserData*>(s_glueMusic.m_sound.GetUserData());
if (def && userData && def->m_id == userData->m_soundKitId) {
return;
}
}
EventUnregister(EVENT_ID_POLL, SI2::CreditsMusicUpdate);
SI2::StopSound(&s_creditsMusic, 0, 3.0f, 1);
if (!name || !SStrCmpI(name, s_glueMusicName, 0x7FFFFFFF)) {
return;
}
SI2::StopGlueMusic(-1.0f);
SStrCopy(s_glueMusicName, name, sizeof(s_glueMusicName));
SE2SoundKitProperties properties;
properties.ResetToDefaults();
properties.m_group = 1;
properties.m_decodeBufferSize = 0;
SI2::PlaySoundKit(s_glueMusicName, nullptr, &s_glueMusic, &properties);
EventRegister(EVENT_ID_POLL, SI2::GlueMusicUpdate);
}
// VERIFY: f023fa69 auto
// OFFSET: 0x009862C0
void SI2::StartCreditsMusic(const char* name) {
EventUnregister(EVENT_ID_POLL, SI2::CreditsMusicUpdate);
SI2::StopSound(&s_creditsMusic, 0, 3.0f, 1);
EventUnregister(EVENT_ID_POLL, SI2::GlueMusicUpdate);
s_glueMusicName[0] = '\0';
SI2::StopSound(&s_glueMusic, 0, 3.0f, 1);
if (!name) {
return;
}
SStrCopy(s_creditsMusicName, name, sizeof(s_creditsMusicName));
SI2::ResetSoundKitVariants(s_creditsMusicName);
SE2SoundKitProperties properties;
properties.ResetToDefaults();
properties.m_selectMode = 0;
SI2::PlaySoundKit(s_creditsMusicName, nullptr, &s_creditsMusic, &properties);
EventRegister(EVENT_ID_POLL, SI2::CreditsMusicUpdate);
}
@@ -0,0 +1,533 @@
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <new>
#include "WoW/Source/SoundInterface/SoundInterface2Internal.h"
#include "Engine/Source/BlizzardCore/SFile2-Core.h"
#include "Engine/Source/Storm/H/storm.h"
#include "Engine/Source/Tempest/CRandom.h"
#include "WoW/Source/DB/DBClient/DBClient.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
#include "WoW/Source/SoundInterface/SoundInterface2ZoneSounds.h"
#include "WoW/Source/Ui/CGWorldStateInfo.h"
// STATIC: 0x00B4AD3C
static TSGrowableArray<VSOUNDKITDEF*> s_soundKitDefs;
// STATIC: 0x00B4AD4C
static TSHashTable<SOUNDKITLOOKUP, HASHKEY_STRI> s_soundKitLookup;
// STATIC: 0x00B4AD74
static TSGrowableArray<WorldStateZoneSoundOverride*> s_worldStateZoneSoundOverrides;
// STATIC: 0x00B4AD84
static TSHashTable<ZONESOUNDOVERRIDELOOKUP, HASHKEY_STRI> s_zoneSoundOverrides;
// VERIFY: 14413abb auto
// OFFSET: 0x004CB8C0
VSOUNDKITDEF::~VSOUNDKITDEF() {
for (int32_t i = 0; i < 10; i++) {
if (this->m_files[i]) {
free(this->m_files[i]);
this->m_files[i] = nullptr;
}
}
}
// VERIFY: cca97730 auto
// OFFSET: 0x004CB8F0
void VSOUNDKITDEF::ResetWeights() {
for (int32_t i = 0; i < 10; i++) {
this->m_weights[i] = 0;
}
}
// VERIFY: eb26f6c8 auto
// OFFSET: 0x004CBA50
VSOUNDKITDEF::VSOUNDKITDEF() {
this->m_numFiles = 0;
this->m_advancedId = 0;
for (int32_t i = 0; i < 10; i++) {
this->m_files[i] = nullptr;
}
for (int32_t i = 0; i < 10; i++) {
this->m_weights[i] = 0;
}
this->m_lastIndex = -1;
this->m_pendingIndex = -1;
this->m_downloadPending = 0;
}
// VERIFY: 229de6de manual
// OFFSET: 0x004CBAC0
const char* VSOUNDKITDEF::SelectFile(uint32_t mode, int32_t* index, int32_t fileIndex, int32_t priority) {
if (mode > 2) {
return nullptr;
}
if (this->m_numFiles <= 0) {
return nullptr;
}
if (this->m_downloadPending) {
if (this->m_lastIndex < 0) {
this->m_lastIndex = 0;
}
return this->m_files[this->m_lastIndex];
}
if (fileIndex > -1) {
int32_t selected = this->m_numFiles - 1;
if (fileIndex < selected) {
selected = fileIndex;
}
this->m_lastIndex = selected;
if (index) {
*index = selected;
}
return this->m_files[selected];
}
if (this->m_numFiles == 1) {
this->m_lastIndex = 0;
if (index) {
*index = 0;
}
return this->m_files[0];
}
int32_t total;
for (int32_t pass = 0;; pass++) {
total = 0;
if (pass == 2) {
this->m_lastIndex = -1;
} else if (pass >= 3) {
return nullptr;
}
for (int32_t i = 0; i < this->m_numFiles; i++) {
if (i != this->m_lastIndex) {
total += this->m_weights[i];
}
}
if (total) {
break;
}
if (mode == 0) {
for (int32_t i = 0; i < 10; i++) {
this->m_weights[i] = 1;
}
} else if (mode == 1 || mode == 2) {
for (int32_t i = 0; i < this->m_numFiles; i++) {
this->m_weights[i] = this->m_frequencies[i];
}
} else {
break;
}
}
int32_t roll = mode ? static_cast<int32_t>((static_cast<uint64_t>(static_cast<uint32_t>(total)) * CRandom::uint32_(g_rndSeed)) >> 32) : 0;
int32_t state = 1;
if (this->m_pendingIndex >= 0) {
state = SFile::FileIsLocal(this->m_files[this->m_pendingIndex], priority);
if (state && state != 2) {
this->m_pendingIndex = -1;
}
}
int32_t selected = -1;
int32_t i;
for (i = 0; i < this->m_numFiles; i++) {
if (i != this->m_lastIndex) {
roll -= this->m_weights[i];
}
if (roll < 0) {
break;
}
}
if (i < this->m_numFiles) {
if (SFile::IsStreamingMode()) {
state = SFile::FileIsLocal(this->m_files[i], priority);
}
if (state && state != 2) {
this->m_weights[i]--;
selected = i;
} else {
if (this->m_pendingIndex < 0) {
SFile::MakeFileLocal(this->m_files[i], priority, false);
this->m_pendingIndex = i;
}
int32_t fallback = i;
if (SFile::IsStreamingMode()) {
for (int32_t j = i - 1; j >= 0; j--) {
int32_t local = SFile::FileIsLocal(this->m_files[j], priority);
if (local && local != 2) {
fallback = j;
break;
}
}
}
selected = fallback;
}
} else {
selected = 0;
}
if (mode == 1) {
for (int32_t k = 0; k < 10; k++) {
this->m_weights[k] = 0;
}
}
this->m_lastIndex = selected;
if (index) {
*index = selected;
}
return this->m_files[selected];
}
// VERIFY: b9dea2b7 auto
// OFFSET: 0x004CBDB0
void SI2::CreateSoundGroups() {
for (uint32_t i = 0; i < s_soundKitDefs.Count(); i++) {
VSOUNDKITDEF* def = s_soundKitDefs[i];
if (def && def->m_name) {
def->m_loadSoundGroup = SE2::CreateSoundGroup(def->m_name, 3);
def->m_soundGroup = SE2::CreateSoundGroup(def->m_name, 3);
}
}
}
// VERIFY: c9a76bad manual
// OFFSET: 0x004CBE00
void SI2::ReleaseSoundGroups() {
for (uint32_t i = 0; i < s_soundKitDefs.Count(); i++) {
VSOUNDKITDEF* def = s_soundKitDefs[i];
if (def) {
if (def->m_loadSoundGroup) {
SE2::ReleaseSoundGroup(def->m_loadSoundGroup);
def->m_loadSoundGroup = nullptr;
}
if (def->m_soundGroup) {
SE2::ReleaseSoundGroup(def->m_soundGroup);
def->m_soundGroup = nullptr;
}
}
}
}
// VERIFY: b21cd78a manual
// OFFSET: 0x004CBE70
int32_t SI2::UpdateZoneSoundsForWorldState(int32_t areaId, int32_t zoneId, int32_t wmoAreaId, int32_t wmoGroupAreaId, int32_t inside) {
int32_t count = s_worldStateZoneSoundOverrides.Count();
int32_t found = 0;
if (inside) {
for (int32_t i = 0; i < count; i++) {
WorldStateZoneSoundOverride* entry = s_worldStateZoneSoundOverrides[i];
if ((wmoAreaId > 0 && wmoAreaId == entry->m_wmoAreaId) || (wmoGroupAreaId > 0 && wmoGroupAreaId == entry->m_wmoAreaId)) {
if (GetWorldState(entry->m_worldStateId) == entry->m_worldStateValue) {
SI2::SetZoneReverb(1, s_worldStateZoneSoundOverrides[i]->m_soundProviderPreferencesId);
SI2::SetZoneAmbienceID(1, s_worldStateZoneSoundOverrides[i]->m_soundAmbienceId);
SI2::SetZoneIntroMusicID(6, s_worldStateZoneSoundOverrides[i]->m_zoneIntroMusicId);
SI2::SetZoneMusicID(1, s_worldStateZoneSoundOverrides[i]->m_zoneMusicId);
found = 1;
if (wmoGroupAreaId == s_worldStateZoneSoundOverrides[i]->m_wmoAreaId) {
return 1;
}
}
}
}
if (found) {
return 1;
}
} else if (wmoAreaId > 0 || wmoGroupAreaId > 0) {
int32_t best = 4;
for (int32_t i = 0; i < count; i++) {
WorldStateZoneSoundOverride* entry = s_worldStateZoneSoundOverrides[i];
int32_t rank = 4;
if (areaId > 0 && areaId == entry->m_areaId) {
rank = 3;
}
if (zoneId > 0 && zoneId == entry->m_areaId) {
rank = 2;
}
if (wmoGroupAreaId > 0 && wmoGroupAreaId == entry->m_wmoAreaId) {
rank = 0;
}
if (rank < best && GetWorldState(entry->m_worldStateId) == entry->m_worldStateValue) {
SI2::SetZoneReverb(1, s_worldStateZoneSoundOverrides[i]->m_soundProviderPreferencesId);
SI2::SetZoneAmbienceID(1, s_worldStateZoneSoundOverrides[i]->m_soundAmbienceId);
SI2::SetZoneIntroMusicID(6, s_worldStateZoneSoundOverrides[i]->m_zoneIntroMusicId);
SI2::SetZoneMusicID(1, s_worldStateZoneSoundOverrides[i]->m_zoneMusicId);
found = 1;
best = rank;
if (!rank) {
return 1;
}
}
}
if (found) {
return 1;
}
} else {
for (int32_t i = 0; i < count; i++) {
WorldStateZoneSoundOverride* entry = s_worldStateZoneSoundOverrides[i];
if ((areaId > 0 && areaId == entry->m_areaId) || (zoneId > 0 && zoneId == entry->m_areaId)) {
if (GetWorldState(entry->m_worldStateId) == entry->m_worldStateValue) {
SI2::SetZoneReverb(1, s_worldStateZoneSoundOverrides[i]->m_soundProviderPreferencesId);
SI2::SetZoneAmbienceID(1, s_worldStateZoneSoundOverrides[i]->m_soundAmbienceId);
SI2::SetZoneIntroMusicID(6, s_worldStateZoneSoundOverrides[i]->m_zoneIntroMusicId);
SI2::SetZoneMusicID(1, s_worldStateZoneSoundOverrides[i]->m_zoneMusicId);
found = 1;
if (zoneId == s_worldStateZoneSoundOverrides[i]->m_areaId) {
return 1;
}
}
}
}
if (found) {
return 1;
}
}
SI2::SetZoneReverb(1, -1);
SI2::SetZoneAmbienceID(1, -1);
SI2::SetZoneIntroMusicID(6, -1);
SI2::SetZoneMusicID(1, -1);
return 0;
}
// VERIFY: 6f1b3998 auto
// OFFSET: 0x004CC180
VSOUNDKITDEF* SI2::GetSoundKitDef(int32_t soundKitId) {
if (soundKitId >= static_cast<int32_t>(s_soundKitDefs.Count()) || soundKitId <= 0) {
return nullptr;
}
return s_soundKitDefs[soundKitId];
}
// VERIFY: 76ad8733 manual
// OFFSET: 0x004CC1B0
void SI2::InitWorldStateZoneSoundOverrides() {
uint32_t count = g_worldStateZoneSoundsDB.m_numRecords;
s_worldStateZoneSoundOverrides.SetCount(count);
memset(s_worldStateZoneSoundOverrides.Ptr(), 0, sizeof(WorldStateZoneSoundOverride*) * count);
for (uint32_t i = 0; i < s_worldStateZoneSoundOverrides.Count(); i++) {
s_worldStateZoneSoundOverrides[i] = static_cast<WorldStateZoneSoundOverride*>(SMemAlloc(sizeof(WorldStateZoneSoundOverride), __FILE__, __LINE__, 0));
WorldStateZoneSoundsRec* rec = (static_cast<int32_t>(i) < 0 || static_cast<int32_t>(i) >= g_worldStateZoneSoundsDB.m_numRecords) ? nullptr : &g_worldStateZoneSoundsDB.m_records[i];
s_worldStateZoneSoundOverrides[i]->m_areaId = rec->m_areaID;
s_worldStateZoneSoundOverrides[i]->m_wmoAreaId = rec->m_wmoareaID;
s_worldStateZoneSoundOverrides[i]->m_worldStateId = rec->m_worldStateID;
s_worldStateZoneSoundOverrides[i]->m_worldStateValue = rec->m_worldStateValue;
s_worldStateZoneSoundOverrides[i]->m_zoneIntroMusicId = rec->m_zoneIntroMusicID;
s_worldStateZoneSoundOverrides[i]->m_zoneMusicId = rec->m_zoneMusicID;
s_worldStateZoneSoundOverrides[i]->m_soundAmbienceId = rec->m_soundAmbienceID;
s_worldStateZoneSoundOverrides[i]->m_soundProviderPreferencesId = rec->m_soundProviderPreferencesID;
}
}
// VERIFY: 21e9b526 manual
// OFFSET: 0x004CC2F0
void SI2::FreeWorldStateZoneSoundOverrides() {
for (uint32_t i = 0; i < s_worldStateZoneSoundOverrides.Count(); i++) {
if (s_worldStateZoneSoundOverrides[i]) {
delete s_worldStateZoneSoundOverrides[i];
}
}
s_worldStateZoneSoundOverrides.Clear();
}
// VERIFY: 6baa66d7 manual
// OFFSET: 0x004CC620
void SI2::FreeSoundKitDefs() {
for (uint32_t i = 0; i < s_soundKitDefs.Count(); i++) {
if (s_soundKitDefs[i]) {
delete s_soundKitDefs[i];
}
}
s_soundKitDefs.Clear();
s_soundKitLookup.Clear();
}
// VERIFY: b1c83b1a manual
// OFFSET: 0x004CC6E0
void SI2::FreeZoneSoundOverrides() {
s_zoneSoundOverrides.Clear();
}
// VERIFY: 47a145e0 auto
// OFFSET: 0x004CCA30
int32_t SI2::GetZoneSoundOverride(int32_t mapId, int32_t chunkX, int32_t chunkY, int32_t subchunkX, int32_t subchunkY, int32_t* zoneIntroMusicId, int32_t* zoneMusicId, int32_t* soundAmbienceId, int32_t* soundProviderPreferencesId) {
char key[64];
SStrPrintf(key, sizeof(key), "%010d_%010d_%010d_%010d_%010d", mapId, chunkX, chunkY, subchunkX, subchunkY);
ZONESOUNDOVERRIDELOOKUP* lookup = s_zoneSoundOverrides.Ptr(key);
if (!lookup) {
return 0;
}
*zoneIntroMusicId = lookup->m_zoneIntroMusicId;
*zoneMusicId = lookup->m_zoneMusicId;
*soundAmbienceId = lookup->m_soundAmbienceId;
*soundProviderPreferencesId = lookup->m_soundProviderPreferencesId;
return 1;
}
// VERIFY: 6d857c47 auto
// OFFSET: 0x004CCAA0
int32_t SI2::LookupSoundKitId(const char* name) {
SOUNDKITLOOKUP* lookup = s_soundKitLookup.Ptr(name);
if (!lookup) {
return 0;
}
return lookup->m_soundKitId;
}
// VERIFY: 9c167174 manual
// OFFSET: 0x004CD4A0
void SI2::InitSoundKitLookup() {
uint32_t count = g_soundEntriesDB.m_maxID + 1;
s_soundKitDefs.SetCount(count);
memset(s_soundKitDefs.Ptr(), 0, sizeof(VSOUNDKITDEF*) * count);
for (int32_t i = 0; i < g_soundEntriesDB.m_numRecords; i++) {
SoundEntriesRec* rec = (i < 0 || i >= g_soundEntriesDB.m_numRecords) ? nullptr : &g_soundEntriesDB.m_records[i];
if (!rec) {
continue;
}
VSOUNDKITDEF* def = new (SMemAlloc(sizeof(VSOUNDKITDEF), __FILE__, __LINE__, 0)) VSOUNDKITDEF();
for (int32_t j = 0; j < 10; j++) {
const char* file = rec->m_file[j];
if (!file || !*file) {
break;
}
size_t length = strlen(file) + 1;
if (*rec->m_directoryBase) {
length += strlen(rec->m_directoryBase) + 1;
}
def->m_files[j] = static_cast<char*>(calloc(1, length));
if (*rec->m_directoryBase) {
bool slash = rec->m_directoryBase[strlen(rec->m_directoryBase) - 1] == '\\';
sprintf(def->m_files[j], "%s", rec->m_directoryBase);
if (!slash) {
strcat(def->m_files[j], "\\");
}
}
strcat(def->m_files[j], rec->m_file[j]);
def->m_numFiles++;
def->m_frequencies[j] = rec->m_freq[j];
}
def->m_flags = rec->m_flags;
def->m_name = rec->m_name;
def->m_minDistance = rec->m_minDistance;
def->m_distanceCutoff = rec->m_distanceCutoff;
def->m_volume = rec->m_volumeFloat;
def->m_id = rec->m_id;
def->m_advancedId = rec->m_soundEntriesAdvancedID;
def->m_advanced = nullptr;
if (def->m_advancedId) {
def->m_advanced = g_soundEntriesAdvancedDB.GetRecord(def->m_advancedId);
}
s_soundKitDefs[rec->m_id] = def;
SOUNDKITLOOKUP* lookup = s_soundKitLookup.Ptr(rec->m_name);
if (!lookup) {
lookup = s_soundKitLookup.New(rec->m_name, 0, 0);
}
lookup->m_soundKitId = rec->m_id;
}
}
// VERIFY: 17a0acc4 manual
// OFFSET: 0x004CD870
void SI2::InitZoneSoundOverrides() {
char key[64];
for (int32_t i = 0; i < g_worldChunkSoundsDB.m_numRecords; i++) {
WorldChunkSoundsRec* rec = (i < 0 || i >= g_worldChunkSoundsDB.m_numRecords) ? nullptr : &g_worldChunkSoundsDB.m_records[i];
SStrPrintf(key, sizeof(key), "%010d_%010d_%010d_%010d_%010d", rec->m_id, rec->m_chunkX, rec->m_chunkY, rec->m_subchunkX, rec->m_subchunkY);
ZONESOUNDOVERRIDELOOKUP* lookup = s_zoneSoundOverrides.Ptr(key);
if (!lookup) {
lookup = s_zoneSoundOverrides.New(key, 0, 0);
}
lookup->m_zoneIntroMusicId = rec->m_zoneIntroMusicID;
lookup->m_zoneMusicId = rec->m_zoneMusicID;
lookup->m_soundAmbienceId = rec->m_soundAmbienceID;
lookup->m_soundProviderPreferencesId = rec->m_soundProviderPreferencesID;
}
}
@@ -0,0 +1,60 @@
#ifndef WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2INTERNAL_H
#define WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2INTERNAL_H
#include <cstddef>
#include <cstdint>
#include "Engine/Source/SoundEngine/fmodex/src/fmod.hpp"
#include "Engine/Source/Storm/H/stpl.h"
class SoundEntriesAdvancedRec;
class VSOUNDKITDEF {
public:
/* 0000 */ const char* m_name;
/* 0004 */ char* m_files[10];
/* 002C */ float m_minDistance;
/* 0030 */ float m_distanceCutoff;
/* 0034 */ float m_volume;
/* 0038 */ int32_t m_id;
/* 003C */ uint32_t m_flags;
/* 0040 */ int32_t m_numFiles;
/* 0044 */ int32_t m_lastIndex;
/* 0048 */ int32_t m_frequencies[10];
/* 0070 */ int32_t m_weights[10];
/* 0098 */ FMOD::SoundGroup* m_loadSoundGroup;
/* 009C */ FMOD::SoundGroup* m_soundGroup;
/* 00A0 */ int32_t m_pendingIndex;
/* 00A4 */ int32_t m_downloadPending;
/* 00A8 */ int32_t m_advancedId;
/* 00AC */ SoundEntriesAdvancedRec* m_advanced;
VSOUNDKITDEF();
~VSOUNDKITDEF();
void ResetWeights();
const char* SelectFile(uint32_t mode, int32_t* index, int32_t fileIndex, int32_t priority);
};
struct SOUNDKITLOOKUP : public TSHashObject<SOUNDKITLOOKUP, HASHKEY_STRI> {
/* 0018 */ int32_t m_soundKitId;
};
struct ZONESOUNDOVERRIDELOOKUP : public TSHashObject<ZONESOUNDOVERRIDELOOKUP, HASHKEY_STRI> {
/* 0018 */ int32_t m_zoneIntroMusicId;
/* 001C */ int32_t m_zoneMusicId;
/* 0020 */ int32_t m_soundAmbienceId;
/* 0024 */ int32_t m_soundProviderPreferencesId;
};
class WorldStateZoneSoundOverride {
public:
/* 0000 */ int32_t m_areaId;
/* 0004 */ int32_t m_wmoAreaId;
/* 0008 */ int32_t m_worldStateId;
/* 000C */ int32_t m_worldStateValue;
/* 0010 */ int32_t m_zoneIntroMusicId;
/* 0014 */ int32_t m_zoneMusicId;
/* 0018 */ int32_t m_soundAmbienceId;
/* 001C */ int32_t m_soundProviderPreferencesId;
};
#endif
@@ -0,0 +1,77 @@
#include <cstddef>
#include <cstdint>
#include <cstring>
#include "Engine/Source/SoundEngine/SoundEngine.h"
#include "WoW/Source/DB/DBClient/DBClient.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
// STATIC: 0x00B4AF2C
static const char* s_reverbDescription;
// VERIFY: b61935df manual
// OFFSET: 0x004D1EC0
static void GetReverbProperties(SoundProviderPreferencesRec* rec, FMOD_REVERB_PROPERTIES* properties) {
if (!properties) {
return;
}
FMOD_REVERB_PROPERTIES off = FMOD_PRESET_OFF;
if (!rec) {
memcpy(properties, &off, sizeof(FMOD_REVERB_PROPERTIES));
s_reverbDescription = nullptr;
return;
}
properties->Instance = 0;
properties->Environment = rec->m_eaxenvironmentSelection;
properties->EnvSize = rec->m_eax2EnvironmentSize;
properties->EnvDiffusion = rec->m_eax2EnvironmentDiffusion;
properties->Room = rec->m_eax2Room;
properties->RoomHF = rec->m_eax2RoomHf;
properties->RoomLF = rec->m_eax3RoomLf;
properties->DecayTime = rec->m_eaxdecayTime;
properties->DecayHFRatio = rec->m_eax2DecayHfratio;
properties->DecayLFRatio = rec->m_eax3DecayLfratio;
properties->Reflections = rec->m_eax2Reflections;
properties->ReflectionsDelay = rec->m_eax2ReflectionsDelay;
properties->Reverb = rec->m_eax2Reverb;
properties->ReverbDelay = rec->m_eax2ReverbDelay;
properties->EchoTime = rec->m_eax3EchoTime;
properties->EchoDepth = rec->m_eax3EchoDepth;
properties->ModulationTime = rec->m_eax3ModulationTime;
properties->ModulationDepth = rec->m_eax3ModulationDepth;
properties->AirAbsorptionHF = rec->m_eax2AirAbsorption;
properties->HFReference = rec->m_eax3Hfreference;
properties->LFReference = rec->m_eax3Lfreference;
properties->Flags = 0x4FF;
properties->RoomRolloffFactor = rec->m_eax2RoomRolloff;
properties->Diffusion = 100.0f;
properties->Density = 100.0f;
properties->ReflectionsPan[0] = 0.0f;
properties->ReflectionsPan[1] = 0.0f;
properties->ReflectionsPan[2] = 0.0f;
properties->ReverbPan[0] = 0.0f;
properties->ReverbPan[1] = 0.0f;
properties->ReverbPan[2] = 0.0f;
s_reverbDescription = rec->m_description;
}
// VERIFY: 881e694d manual
// OFFSET: 0x004D2050
void SI2::ApplyReverbSettings() {
if (!SE2::IsReverbEnabled()) {
return;
}
FMOD_REVERB_PROPERTIES properties;
GetReverbProperties(g_soundProviderPreferencesDB.GetRecord(SI2::GetZoneReverb()), &properties);
SE2::SetReverb(&properties);
}
// VERIFY: 8f6ff286 auto
// OFFSET: 0x004D20A0
void SI2::UpdateReverb() {
SI2::ApplyReverbSettings();
}
@@ -0,0 +1,26 @@
#include <cstddef>
#include <cstdint>
#include <cstring>
#include "WoW/Source/DB/DBClient/DBClient.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
// STATIC: 0x00DCEAF8
static int32_t s_vocalErrorSounds[68];
// VERIFY: 2b3e2ff2 manual
// OFFSET: 0x00986C90
void SI2::InitVocalErrorSounds(int32_t race, uint32_t sex) {
memset(s_vocalErrorSounds, 0, sizeof(s_vocalErrorSounds));
if (sex > 1) {
return;
}
for (int32_t i = 0; i < g_vocalUISoundsDB.m_numRecords; i++) {
VocalUISoundsRec* rec = (i < 0 || i >= g_vocalUISoundsDB.m_numRecords) ? nullptr : &g_vocalUISoundsDB.m_records[i];
if (rec && rec->m_vocalUienum < 68 && rec->m_raceID == race) {
s_vocalErrorSounds[rec->m_vocalUienum] = rec->m_normalSoundID[sex];
}
}
}
@@ -0,0 +1,392 @@
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <new>
#include "WoW/Source/SoundInterface/SoundInterface2VoiceChat.h"
#include "Engine/Source/Base/CmdLine.h"
#include "Engine/Source/ConsoleBase/ConsoleVar.h"
#include "Engine/Source/Event/Event.h"
#include "Engine/Source/Storm/H/storm.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
// STATIC: 0x00B2D9E4
static SI2LoopbackCapture s_loopbackCapture;
// STATIC: 0x00DCEAA4
static int32_t s_microphoneSignalLevel;
// STATIC: 0x00DCEAA8
static uint8_t* s_loopbackBuffer;
// STATIC: 0x00DCEAAC
static uint8_t* s_loopbackWrite;
// STATIC: 0x00DCEAB0
static uint32_t s_loopbackSize;
// STATIC: 0x00DCEAB4
static SE2SoundKitObject s_loopbackSound;
// VERIFY: 5c71868e auto
// OFFSET: 0x00986390
void SI2::VoiceChat_ShutDownCapture() {
SE2::ShutDownCapture();
}
// VERIFY: 92720538 manual
// OFFSET: 0x009863A0
void SI2::VoiceChat_CleanUpLoopbackSound() {
SI2::StopSound(&s_loopbackSound, 1, -1.0f, 1);
if (s_loopbackBuffer) {
SMemFree(s_loopbackBuffer, __FILE__, __LINE__, 0);
s_loopbackBuffer = nullptr;
s_loopbackSize = 0;
}
}
// VERIFY: 313d6efe auto
// OFFSET: 0x009863F0
void SI2::VoiceChat_StopPlayingLoopbackSound() {
SI2::StopSound(&s_loopbackSound, 1, -1.0f, 1);
}
// VERIFY: a69f50c4 auto
// OFFSET: 0x00986410
bool SI2::VoiceChat_IsPlayingLoopbackSound() {
return SI2::IsPlaying(&s_loopbackSound);
}
// VERIFY: 992daf2d manual
// OFFSET: 0x00986420
void SI2::VoiceChat_SetCaptureDevice(int32_t index) {
static CVar* s_inputDriverIndex = CVar::Lookup("Sound_VoiceChatInputDriverIndex");
if (s_inputDriverIndex) {
char value[32];
SStrPrintf(value, sizeof(value), "%d", index);
s_inputDriverIndex->Set(value, true, false, false, true);
}
}
// VERIFY: f9cebc61 manual
// OFFSET: 0x00986490
void SI2::VoiceChat_SetOutputDevice(int32_t index) {
static CVar* s_outputDriverIndex = CVar::Lookup("Sound_VoiceChatOutputDriverIndex");
if (s_outputDriverIndex) {
char value[32];
SStrPrintf(value, sizeof(value), "%d", index);
s_outputDriverIndex->Set(value, true, false, false, true);
}
}
// VERIFY: c0b92063 auto
// OFFSET: 0x00986500
void SI2::VoiceChat_DestroyChatSystem() {
SE2::DestroyChatSystem();
}
// VERIFY: b52bb4f6 auto
// OFFSET: 0x00986510
int32_t SI2::VoiceChat_IsVoiceChatInitialized() {
return SE2::IsChatSoundInitialized();
}
// VERIFY: 2b6fed5c auto
// OFFSET: 0x00986520
void SI2::VoiceChat_AmplifyMicrophoneInput(int16_t* data, uint32_t samples) {
if (!SE2::IsChatSoundInitialized()) {
return;
}
static CVar* s_outboundChatVolume = CVar::Lookup("OutboundChatVolume");
if (!s_outboundChatVolume) {
return;
}
float volume = s_outboundChatVolume->m_floatValue;
if (1.0f == volume) {
return;
}
for (uint32_t i = 0; i < samples; i++) {
int32_t value = static_cast<int32_t>(data[i] * volume);
if (value < -32768) {
value = -32768;
} else if (value > 32767) {
value = 32767;
}
data[i] = static_cast<int16_t>(value);
}
}
// VERIFY: d56d0331 manual
// OFFSET: 0x009865C0
static void ComputeAverageLevel(float* data, uint32_t count) {
if (!SE2::IsChatSoundInitialized()) {
return;
}
float sum = 0.0f;
for (uint32_t i = 0; i < count; i++) {
sum += fabs(data[i]);
}
s_microphoneSignalLevel = static_cast<int32_t>(sqrt(sum / count) * 100.0f);
}
// VERIFY: 0f8f8550 auto
// OFFSET: 0x00986670
int32_t SI2::VoiceChat_GetCurrentMicrophoneSignalLevel() {
return SE2::IsChatSoundInitialized() != 0 ? s_microphoneSignalLevel : 0;
}
// VERIFY: 124ffd5f auto
// OFFSET: 0x00986680
int32_t SI2::VoiceChat_CreateChatSound(SE2SoundKitObject* object, SEStreamCallbacks* callbacks, int32_t chatSystem) {
if (!SE2::IsChatSoundInitialized()) {
return 17;
}
object->m_sound.CreateChatSound(callbacks, chatSystem);
return 0;
}
// VERIFY: 73c312f2 auto
// OFFSET: 0x009866B0
int32_t SI2::VoiceChat_Play(SE2SoundKitObject* object) {
if (!SE2::IsChatSoundInitialized()) {
return 17;
}
object->m_sound.Play();
return 0;
}
// VERIFY: eec71328 auto
// OFFSET: 0x009866E0
static void MonitorCallback(float* data, uint32_t count) {
if (SE2::IsChatSoundInitialized()) {
ComputeAverageLevel(data, count);
}
}
// VERIFY: e6a66d96 auto
// OFFSET: 0x00986700
void SI2::VoiceChat_InitCapture(float sampleRate) {
if (CmdLineGetBool(static_cast<CMDOPT>(26))) {
return;
}
int32_t outputDriverIndex = 0;
static CVar* s_outputDriverIndex = CVar::Lookup("Sound_VoiceChatOutputDriverIndex");
if (s_outputDriverIndex) {
outputDriverIndex = s_outputDriverIndex->m_intValue;
}
const char* outputDriverName = "";
static CVar* s_outputDriverName = CVar::Lookup("Sound_VoiceChatOutputDriverName");
if (s_outputDriverName) {
outputDriverName = s_outputDriverName->m_stringValue.m_str;
}
int32_t inputDriverIndex = 0;
static CVar* s_inputDriverIndex = CVar::Lookup("Sound_VoiceChatInputDriverIndex");
if (s_inputDriverIndex) {
inputDriverIndex = s_inputDriverIndex->m_intValue;
}
const char* inputDriverName = "";
static CVar* s_inputDriverName = CVar::Lookup("Sound_VoiceChatInputDriverName");
if (s_inputDriverName) {
inputDriverName = s_inputDriverName->m_stringValue.m_str;
}
SE2::InitCapture(&outputDriverIndex, outputDriverName, &inputDriverIndex, inputDriverName, sampleRate);
char value[32];
if (s_outputDriverIndex) {
SStrPrintf(value, sizeof(value), "%d", outputDriverIndex);
s_outputDriverIndex->Set(value, true, false, false, true);
}
if (s_inputDriverName) {
SStrPrintf(value, sizeof(value), "%d", inputDriverIndex);
s_inputDriverIndex->Set(value, true, false, false, true);
}
SE2::SetUserMonitorDSPCallback(MonitorCallback);
}
// VERIFY: d0c59c8d auto
// OFFSET: 0x009868A0
void SI2::VoiceChat_SetPrimaryCaptureCallback(SECaptureCallbacks* callbacks) {
if (SE2::IsChatSoundInitialized()) {
SE2::SetPrimaryCaptureCallback(callbacks);
}
}
// VERIFY: 57b84183 manual
// OFFSET: 0x009868C0
void SI2::VoiceChat_StartCapture() {
if (SE2::IsChatSoundInitialized()) {
SE2::StartCapture();
}
}
// VERIFY: 77221e3b manual
// OFFSET: 0x009868D0
void SI2::VoiceChat_StopCapture() {
if (SE2::IsChatSoundInitialized()) {
SE2::StopCapture();
}
}
// VERIFY: 67c97745 manual
// OFFSET: 0x009868E0
static void ComputeMicrophoneLevel(int16_t* data, uint32_t samples) {
if (!SE2::IsChatSoundInitialized()) {
return;
}
uint32_t sum = 0;
for (uint32_t i = 0; i < samples; i++) {
sum += abs(data[i]);
}
s_microphoneSignalLevel = static_cast<int32_t>(sqrt(static_cast<float>(sum / samples) * 0.000030517578f) * 100.0f);
}
// VERIFY: a6e75762 manual
// OFFSET: 0x00986960
SI2LoopbackCapture::~SI2LoopbackCapture() {
}
// VERIFY: 9fa225c6 auto
// OFFSET: 0x00986990
bool SI2::VoiceChat_IsRecordingLoopbackSound() {
if (!SE2::IsChatSoundInitialized()) {
return false;
}
return SE2::IsCapturing() && SE2::AlternateCaptureCallbackIsActive();
}
// VERIFY: eec9034f manual
// OFFSET: 0x009869C0
void SI2::VoiceChat_ActivatePrimaryCaptureCallback() {
if (SE2::IsChatSoundInitialized()) {
SE2::ActivatePrimaryCaptureCallback();
}
}
// VERIFY: 887239cf auto
// OFFSET: 0x009869D0
void SI2::VoiceChat_StopRecordingLoopbackSound() {
if (SE2::IsChatSoundInitialized()) {
SI2::VoiceChat_ActivatePrimaryCaptureCallback();
}
}
// VERIFY: 075fee4d manual
// OFFSET: 0x009869F0
void SI2LoopbackCapture::ProcessData(int16_t* data, uint32_t samples) {
if (!s_loopbackBuffer) {
return;
}
SI2::VoiceChat_AmplifyMicrophoneInput(data, samples);
ComputeMicrophoneLevel(data, samples);
uint8_t* write = s_loopbackWrite;
uint32_t remaining = static_cast<uint32_t>(s_loopbackBuffer + s_loopbackSize - write);
uint32_t bytes = 2 * samples;
if (bytes >= remaining) {
bytes = remaining;
}
memcpy(write, data, 2 * (bytes >> 1));
s_loopbackWrite = write + bytes;
if (!remaining && SE2::IsChatSoundInitialized()) {
SI2::VoiceChat_ActivatePrimaryCaptureCallback();
}
}
// VERIFY: 0dc037b8 auto
// OFFSET: 0x00986A70
static int32_t DetectRecordingFinished(const void* data, void* param) {
if (!SE2::IsChatSoundInitialized() || !SE2::IsCapturing() || !SE2::AlternateCaptureCallbackIsActive()) {
EventUnregister(EVENT_ID_POLL, DetectRecordingFinished);
}
return 1;
}
// VERIFY: 0741bfdd manual
// OFFSET: 0x00986AA0
void SI2::VoiceChat_RecordLoopbackSound(int32_t seconds) {
if (!SE2::IsChatSoundInitialized()) {
return;
}
SI2::VoiceChat_CleanUpLoopbackSound();
s_loopbackSize = 16000 * seconds + 44;
uint32_t* header = static_cast<uint32_t*>(SMemAlloc(16000 * seconds + 44, __FILE__, __LINE__, SMEM_FLAG_ZEROMEMORY));
header[0] = 'FFIR';
header[1] = 16000 * seconds + 32;
header[2] = 'EVAW';
header[3] = ' tmf';
header[4] = 16;
header[5] = 0x10001;
s_loopbackBuffer = reinterpret_cast<uint8_t*>(header);
header[6] = 8000;
header[7] = 16000;
header[8] = 0x100002;
header[9] = 'atad';
header[10] = 16000 * seconds;
s_loopbackWrite = reinterpret_cast<uint8_t*>(&header[11]);
SE2::SetAlternateCaptureCallback(&s_loopbackCapture);
SE2::ActivateAlternateCaptureCallback();
EventRegister(EVENT_ID_POLL, DetectRecordingFinished);
}
// VERIFY: ef5b70e1 manual
// OFFSET: 0x00986BC0
void SI2::VoiceChat_PlayLoopbackSound() {
if (!SE2::IsChatSoundInitialized() || !s_loopbackBuffer) {
return;
}
s_loopbackSound.m_sound.PlaySoundFromMemory(reinterpret_cast<const char*>(s_loopbackBuffer), s_loopbackSize, 1);
SI2SoundUserData* userData = new (SMemAlloc(sizeof(SI2SoundUserData), __FILE__, __LINE__, 0)) SI2SoundUserData();
userData->m_name = "<Voice Chat Loopback Sound>";
userData->m_soundKitId = 0;
userData->m_def = nullptr;
userData->m_group = 3;
s_loopbackSound.m_sound.SetUserData(userData);
s_loopbackSound.m_sound.SetFinishedCallback(SI2::SoundFinished, nullptr);
s_loopbackSound.m_sound.SetChannelGroup(SI2::s_channelGroupNames[userData->m_group], userData->m_group != 3);
SE2::AttachMonitorDSP(&s_loopbackSound.m_sound);
s_loopbackSound.m_sound.Play();
}
@@ -0,0 +1,14 @@
#ifndef WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2VOICECHAT_H
#define WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2VOICECHAT_H
#include <cstddef>
#include <cstdint>
#include "Engine/Source/SoundEngine/SoundEngine.h"
class SI2LoopbackCapture : public SECaptureCallbacks {
public:
virtual ~SI2LoopbackCapture();
virtual void ProcessData(int16_t* data, uint32_t samples);
};
#endif
@@ -0,0 +1,15 @@
#include <cstddef>
#include <cstdint>
#include "WoW/Source/SoundInterface/SoundInterface2Water.h"
#include "Engine/Source/Event/Event.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
// STATIC: 0x00B4AF5C
static SI2WaterSound s_nearestWaterSounds[1];
// VERIFY: cf194119 auto
// OFFSET: 0x004D2750
void SI2::WaterShutdown() {
SI2::StopSound(&s_nearestWaterSounds[0].m_object, 0, -1.0f, 1);
EventUnregister(EVENT_ID_IDLE, SI2::HandleWaterSounds);
}
@@ -0,0 +1,18 @@
#ifndef WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2WATER_H
#define WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2WATER_H
#include <cstddef>
#include <cstdint>
#include "Engine/Source/Tempest/C3Vector.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
struct SI2WaterSound {
/* 0000 */ float m_distanceSq;
/* 0004 */ C3Vector m_position;
/* 0010 */ int32_t m_soundKitId;
/* 0014 */ SE2SoundKitObject m_object;
/* 0028 */ int32_t m_valid;
/* 002C */ int32_t m_moved;
};
#endif
@@ -0,0 +1,660 @@
#include <cstddef>
#include <cstdint>
#include <new>
#include "WoW/Source/SoundInterface/SoundInterface2ZoneSounds.h"
#include "Engine/Source/BlizzardCore/SFile2-Core.h"
#include "Engine/Source/ConsoleBase/ConsoleVar.h"
#include "Engine/Source/Event/Event.h"
#include "Engine/Source/Os/TimeManager.h"
#include "Engine/Source/Storm/H/storm.h"
#include "Engine/Source/Tempest/CRandom.h"
#include "WoW/Source/DB/DBClient/DBClient.h"
#include "WoW/Source/Game/GameTime.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
#include "WoW/Source/Ui/GameUI.h"
// STATIC: 0x00AC3878
static int32_t s_zoneSoundTimeOfDay = 1;
// STATIC: 0x00B4AAB0
static SI2ZoneSoundInfo s_zoneSounds[11];
// STATIC: 0x00B4AC3C
static SE2SoundKitObject s_scriptMusic;
// STATIC: 0x00B4AC50
static SI2ZoneSoundPair s_zoneAmbience;
// STATIC: 0x00B4AC90
static SI2ZoneSoundPair s_zoneMusic;
// STATIC: 0x00B4ACD0
TSGrowableArray<uint32_t> SI2::sm_aIntroMusicNextValidPlayTime;
// VERIFY: e6578ba5 manual
// OFFSET: 0x004C8590
int32_t SI2::GetZoneReverb() {
for (int32_t i = 10; i >= 0; i--) {
if (s_zoneSounds[i].m_reverb < 0) {
continue;
}
if (i == 9) {
if (!SI2::sm_bCameraIsUnderwater) {
continue;
}
} else if (i == 8 && SI2::sm_bPlayerInside) {
continue;
}
return s_zoneSounds[i].m_reverb;
}
return 0;
}
// VERIFY: 368f23da auto
// OFFSET: 0x004C85F0
void SI2::StopZoneAmbience() {
s_zoneAmbience.Stop(1);
}
// VERIFY: 481f5672 auto
// OFFSET: 0x004C8600
void SI2::SetPlayerInside(bool inside) {
SI2::sm_bPlayerInside = inside;
}
// VERIFY: b619fbdd auto
// OFFSET: 0x004C8610
void SI2::SetWeatherKitID(int32_t soundKitId) {
s_zoneSounds[8].m_ambience[0] = soundKitId;
s_zoneSounds[8].m_ambience[1] = soundKitId;
}
// VERIFY: 92518c26 auto
// OFFSET: 0x004C8630
void SI2::SetUnderwaterStatus(int32_t underwater) {
int32_t unchanged = underwater == SI2::sm_bCameraIsUnderwater;
SI2::sm_bCameraIsUnderwater = underwater;
s_zoneSounds[9].m_ambience[0] = underwater ? 4209 : -1;
s_zoneSounds[9].m_ambience[1] = s_zoneSounds[9].m_ambience[0];
SI2::sm_bUnderwaterChanged = !unchanged;
SI2::UpdateReverb();
}
// VERIFY: 8cc2bd07 auto
// OFFSET: 0x004C8670
int32_t SI2::IsUnderwater() {
return SI2::sm_bCameraIsUnderwater;
}
// VERIFY: 3dfce48c auto
// OFFSET: 0x004C8680
void SI2::StopLuaMusic() {
SI2::StopSound(&s_scriptMusic, 0, 0.5f, 1);
SI2::sm_bLuaMusicPlaying = 0;
}
// VERIFY: 527bb7b0 auto
// OFFSET: 0x004C86B0
void SI2::SetZoneReverb(int32_t type, int32_t reverb) {
s_zoneSounds[type].m_reverb = reverb;
SI2::ApplyReverbSettings();
}
// VERIFY: 53308ceb auto
// OFFSET: 0x004C86D0
void SI2::SetZoneUnderwaterReverb(int32_t reverb) {
s_zoneSounds[9].m_reverb = reverb;
SI2::ApplyReverbSettings();
}
// VERIFY: a9775166 auto
// OFFSET: 0x004C86F0
int32_t SI2::GetDesiredAmbienceKitID(int32_t* type) {
static CVar* s_enableAllSound = CVar::Lookup("Sound_EnableAllSound");
static CVar* s_enableAmbience = CVar::Lookup("Sound_EnableAmbience");
if ((s_enableAllSound && !s_enableAllSound->m_intValue) || (s_enableAmbience && !s_enableAmbience->m_intValue) || CGGameUI::m_inMovie) {
if (type) {
*type = 14;
}
return 0;
}
for (int32_t i = 10; i >= 0; i--) {
if (s_zoneSounds[i].m_ambience[s_zoneSoundTimeOfDay] < 0 || (i == 8 && SI2::sm_bPlayerInside)) {
continue;
}
if (type) {
*type = i;
}
return s_zoneSounds[i].m_ambience[s_zoneSoundTimeOfDay];
}
return 0;
}
// VERIFY: 40642125 auto
// OFFSET: 0x004C87D0
int32_t SI2::ZoneMusicDelayElapsed(int32_t type) {
if (type && type != 2 && type != 1) {
return 1;
}
static CVar* s_zoneMusicNoDelay = CVar::Lookup("Sound_ZoneMusicNoDelay");
return (s_zoneMusicNoDelay && s_zoneMusicNoDelay->m_intValue) || OsGetAsyncTimeMs() >= SI2::sm_nextZoneMusicTime;
}
// VERIFY: 97d2bfe2 auto
// OFFSET: 0x004C8830
int32_t SI2::IntroMusicOkToPlay(int32_t soundKitId, int32_t type) {
if (soundKitId == s_zoneMusic.GetPlayingSoundKitId() || (type != 5 && type != 7 && type != 6)) {
return 1;
}
if (s_zoneMusic.GetCurrentType() == 5) {
return 0;
}
if (s_zoneMusic.GetCurrentType() == 7) {
return 0;
}
if (s_zoneMusic.GetCurrentType() == 6) {
return 0;
}
uint32_t now = OsGetAsyncTimeMs();
if (static_cast<uint32_t>(soundKitId) >= SI2::sm_aIntroMusicNextValidPlayTime.Count()) {
return 0;
}
return now >= SI2::sm_aIntroMusicNextValidPlayTime[soundKitId];
}
// VERIFY: 17672894 auto
// OFFSET: 0x004C88B0
int32_t SI2::GetDesiredMusicKitID(int32_t* type, int32_t* silenceMin, int32_t* silenceMax) {
static CVar* s_enableAllSound = CVar::Lookup("Sound_EnableAllSound");
static CVar* s_enableMusic = CVar::Lookup("Sound_EnableMusic");
if ((s_enableAllSound && !s_enableAllSound->m_intValue) || (s_enableMusic && !s_enableMusic->m_intValue) || CGGameUI::m_inMovie) {
if (type) {
*type = 14;
}
if (silenceMin) {
*silenceMin = 0;
}
if (silenceMax) {
*silenceMax = 0;
}
return 0;
}
for (int32_t i = 10; i >= 0; i--) {
if ((i == 5 || i == 7 || i == 6) && s_zoneMusic.IsPlaying() && (s_zoneMusic.GetCurrentType() == 5 || s_zoneMusic.GetCurrentType() == 7 || s_zoneMusic.GetCurrentType() == 6)) {
if (i == 8 && SI2::sm_bPlayerInside) {
continue;
}
if (type) {
*type = s_zoneMusic.GetCurrentType();
}
if (silenceMin) {
*silenceMin = 0;
}
if (silenceMax) {
*silenceMax = 0;
}
return s_zoneMusic.GetPlayingSoundKitId();
}
if (s_zoneSounds[i].m_music[s_zoneSoundTimeOfDay] < 0) {
continue;
}
if (!SI2::ZoneMusicDelayElapsed(i)) {
if (type) {
*type = 12;
}
if (silenceMin) {
*silenceMin = 0;
}
if (silenceMax) {
*silenceMax = 0;
}
return -1111;
}
if (!SI2::IntroMusicOkToPlay(s_zoneSounds[i].m_music[s_zoneSoundTimeOfDay], i)) {
continue;
}
if (type) {
*type = i;
}
if (silenceMin) {
*silenceMin = s_zoneSounds[i].m_silenceMin[s_zoneSoundTimeOfDay];
}
if (silenceMax) {
*silenceMax = s_zoneSounds[i].m_silenceMax[s_zoneSoundTimeOfDay];
}
return s_zoneSounds[i].m_music[s_zoneSoundTimeOfDay];
}
return 0;
}
// VERIFY: e4136c86 manual
// OFFSET: 0x004C8AB0
void SI2::ZoneMusicFinished(SESound* sound, void* param) {
SI2ZoneMusicTimer* timer = static_cast<SI2ZoneMusicTimer*>(param);
uint32_t now = OsGetAsyncTimeMs();
if (SI2::GetDesiredMusicKitID(nullptr, nullptr, nullptr) == timer->m_soundKitId) {
uint32_t silenceMax = timer->m_silenceMax;
uint32_t silenceMin = timer->m_silenceMin;
if (silenceMax > silenceMin) {
static CRndSeed s_seed(0);
SI2::sm_nextZoneMusicTime = now + silenceMin + static_cast<uint32_t>((static_cast<uint64_t>(silenceMax - silenceMin) * CRandom::uint32_(s_seed)) >> 32);
} else {
SI2::sm_nextZoneMusicTime = now + silenceMax;
}
} else {
SI2::sm_nextZoneMusicTime = 0;
}
delete timer;
}
// VERIFY: 4b8e2a85 manual
// OFFSET: 0x004C8C90
void SI2::SetZoneAmbienceID(int32_t type, int32_t soundAmbienceId) {
SoundAmbienceRec* rec = g_soundAmbienceDB.GetRecord(soundAmbienceId);
if (rec) {
s_zoneSounds[type].m_ambience[0] = rec->m_ambienceID[0];
s_zoneSounds[type].m_ambience[1] = rec->m_ambienceID[1];
} else {
s_zoneSounds[type].m_ambience[0] = -1;
s_zoneSounds[type].m_ambience[1] = -1;
}
}
// VERIFY: 436a05e0 manual
// OFFSET: 0x004C8CF0
void SI2::SetZoneIntroMusicID(int32_t type, int32_t zoneIntroMusicId) {
ZoneIntroMusicTableRec* rec = g_zoneIntroMusicTableDB.GetRecord(zoneIntroMusicId);
if (rec) {
s_zoneSounds[type].m_music[0] = rec->m_soundID;
s_zoneSounds[type].m_music[1] = rec->m_soundID;
s_zoneSounds[type].m_silenceMin[0] = rec->m_minDelayMinutes;
s_zoneSounds[type].m_silenceMin[1] = rec->m_minDelayMinutes;
} else {
s_zoneSounds[type].m_music[0] = -1;
s_zoneSounds[type].m_music[1] = -1;
s_zoneSounds[type].m_silenceMin[0] = 0;
s_zoneSounds[type].m_silenceMin[1] = 0;
s_zoneSounds[type].m_silenceMax[0] = 0;
s_zoneSounds[type].m_silenceMax[1] = 0;
}
}
// VERIFY: 8c58a8a2 manual
// OFFSET: 0x004C8D80
void SI2::SetZoneMusicID(int32_t type, int32_t zoneMusicId) {
ZoneMusicRec* rec = g_zoneMusicDB.GetRecord(zoneMusicId);
if (!rec) {
s_zoneSounds[type].m_music[0] = -1;
s_zoneSounds[type].m_music[1] = -1;
s_zoneSounds[type].m_silenceMin[0] = 0;
s_zoneSounds[type].m_silenceMin[1] = 0;
s_zoneSounds[type].m_silenceMax[0] = 0;
s_zoneSounds[type].m_silenceMax[1] = 0;
if (zoneMusicId > 0) {
SI2::sm_nextZoneMusicTime = 0;
}
return;
}
s_zoneSounds[type].m_music[0] = rec->m_sounds[0];
s_zoneSounds[type].m_music[1] = rec->m_sounds[1];
s_zoneSounds[type].m_silenceMin[0] = rec->m_silenceIntervalMin[0];
s_zoneSounds[type].m_silenceMin[1] = rec->m_silenceIntervalMin[1];
s_zoneSounds[type].m_silenceMax[0] = rec->m_silenceIntervalMax[0];
s_zoneSounds[type].m_silenceMax[1] = rec->m_silenceIntervalMax[1];
int32_t desired = SI2::GetDesiredMusicKitID(nullptr, nullptr, nullptr);
if (desired != s_zoneMusic.GetPlayingSoundKitId() && (type > 2 || desired != -1111)) {
SI2::sm_nextZoneMusicTime = 0;
}
}
// VERIFY: c27c3281 manual
// OFFSET: 0x004C8FA0
void SI2::SetOverrideZoneSounds(int32_t soundAmbienceId, int32_t zoneMusicId) {
SI2::SetZoneAmbienceID(10, soundAmbienceId);
SI2::SetZoneMusicID(10, zoneMusicId);
}
// VERIFY: 039f2ed0 auto
// OFFSET: 0x004C8FC0
int32_t SI2::PlayUISound(int32_t soundKitId) {
static int32_t s_voiceChatOn = SI2::LookupSoundKitId("VoiceChatOn");
static int32_t s_voiceChatOff = SI2::LookupSoundKitId("VoiceChatOff");
SE2SoundKitProperties properties;
properties.ResetToDefaults();
if (soundKitId == s_voiceChatOn || soundKitId == s_voiceChatOff) {
properties.m_group = 3;
}
properties.m_priority = 128;
properties.m_suppressorMode = 2;
properties.m_reverb = 0;
return SI2::PlaySoundKit(soundKitId, nullptr, nullptr, &properties, 0, nullptr, 1, 0);
}
// VERIFY: cf1057e2 manual
// OFFSET: 0x004C9080
void SI2::IntroMusicFinished(SESound* sound, void* param) {
SI2ZoneMusicTimer* timer = static_cast<SI2ZoneMusicTimer*>(param);
int32_t minutes = timer->m_silenceMin;
uint32_t soundKitId = timer->m_soundKitId;
uint32_t now = OsGetAsyncTimeMs();
if (soundKitId < SI2::sm_aIntroMusicNextValidPlayTime.Count()) {
SI2::sm_aIntroMusicNextValidPlayTime[soundKitId] = now + 60000 * minutes;
}
delete timer;
}
// VERIFY: a0e10314 manual
// OFFSET: 0x004C90C0
void SI2::AIMusicFinished(SESound* sound, void* param) {
s_zoneSounds[3].m_music[0] = -1;
s_zoneSounds[3].m_music[1] = -1;
s_zoneSounds[3].m_silenceMin[0] = 0;
s_zoneSounds[3].m_silenceMin[1] = 0;
s_zoneSounds[3].m_silenceMax[0] = 0;
s_zoneSounds[3].m_silenceMax[1] = 0;
s_zoneSounds[3].m_ambience[0] = -1;
s_zoneSounds[3].m_ambience[1] = -1;
s_zoneSounds[3].m_reverb = -1;
if (param) {
delete static_cast<SI2ZoneMusicTimer*>(param);
}
}
// VERIFY: 26708b3b manual
// OFFSET: 0x004C9110
int32_t SI2::PlaySoundFile(const char* filename, int32_t group) {
static CVar* s_enableAllSound = CVar::Lookup("Sound_EnableAllSound");
if (!s_enableAllSound || !s_enableAllSound->m_intValue || CGGameUI::m_inMovie) {
return 17;
}
if (group == 5) {
static CVar* s_enableMusic = CVar::Lookup("Sound_EnableMusic");
if (!s_enableMusic || !s_enableMusic->m_intValue) {
return 10;
}
}
SESound localSound;
SESound* sound = group == 5 ? &s_scriptMusic.m_sound : &localSound;
sound->Create2D(filename, group != 4, nullptr, nullptr, false, false, 0, group != 5 ? 128 : 100, 0xFFFFFFFF);
sound->SetChannelGroup(SI2::s_channelGroupNames[group], true);
SI2SoundUserData* userData = new (SMemAlloc(sizeof(SI2SoundUserData), __FILE__, __LINE__, 0)) SI2SoundUserData();
if (userData) {
userData->m_name = group != 4 ? "<SCRIPT MUSIC>" : "<SCRIPT SOUND>";
userData->m_soundKitId = 0;
sound->SetUserData(userData);
}
sound->SetVolume(1.0f);
sound->CompleteNonBlockingLoad();
sound->Play();
if (sound->IsPlaying() && group == 5) {
SI2::sm_bLuaMusicPlaying = 1;
s_zoneMusic.Stop(0);
}
return 0;
}
// VERIFY: 14578d5d auto
// OFFSET: 0x004C92B0
void SI2::PlayAIMusic(int32_t soundKitId) {
s_zoneSounds[3].m_silenceMin[0] = 0;
s_zoneSounds[3].m_silenceMin[1] = 0;
s_zoneSounds[3].m_silenceMax[0] = 0;
s_zoneSounds[3].m_silenceMax[1] = 0;
s_zoneSounds[3].m_ambience[0] = -1;
s_zoneSounds[3].m_ambience[1] = -1;
s_zoneSounds[3].m_reverb = -1;
s_zoneSounds[3].m_music[0] = soundKitId;
s_zoneSounds[3].m_music[1] = soundKitId;
}
// VERIFY: 759593c5 auto
// OFFSET: 0x004C92F0
void SI2::StopAIMusic() {
s_zoneSounds[3].m_music[0] = -1;
s_zoneSounds[3].m_music[1] = -1;
s_zoneSounds[3].m_silenceMin[0] = 0;
s_zoneSounds[3].m_silenceMin[1] = 0;
s_zoneSounds[3].m_silenceMax[0] = 0;
s_zoneSounds[3].m_silenceMax[1] = 0;
s_zoneSounds[3].m_ambience[0] = -1;
s_zoneSounds[3].m_ambience[1] = -1;
s_zoneSounds[3].m_reverb = -1;
}
// VERIFY: 373e56ae manual
// OFFSET: 0x004C9330
void SI2::InitZoneIntros() {
uint32_t count = g_soundEntriesDB.m_maxID + 1;
SI2::sm_aIntroMusicNextValidPlayTime.SetCount(count);
for (uint32_t i = 0; i < count; i++) {
SI2::sm_aIntroMusicNextValidPlayTime[i] = 0;
}
}
// VERIFY: 65b668bf auto
// OFFSET: 0x004C93B0
void SI2::StopAllMusic() {
s_zoneMusic.Stop(1);
SI2::StopSound(&s_scriptMusic, 0, 0.5f, 1);
SI2::sm_bLuaMusicPlaying = 0;
s_zoneSounds[3].m_silenceMin[0] = 0;
s_zoneSounds[3].m_silenceMin[1] = 0;
s_zoneSounds[3].m_silenceMax[0] = 0;
s_zoneSounds[3].m_silenceMax[1] = 0;
SI2::sm_nextZoneMusicTime = 0;
s_zoneSounds[3].m_music[0] = -1;
s_zoneSounds[3].m_music[1] = -1;
s_zoneSounds[3].m_ambience[0] = -1;
s_zoneSounds[3].m_ambience[1] = -1;
s_zoneSounds[3].m_reverb = -1;
}
// VERIFY: 7a4f127b auto
// OFFSET: 0x004C9420
void SI2::FreeZoneIntros() {
SI2::sm_aIntroMusicNextValidPlayTime.Clear();
}
// VERIFY: c8ca0148 manual
// OFFSET: 0x004C9460
SI2ZoneSoundPair::SI2ZoneSoundPair() {
this->m_current = 0;
this->m_next = 1;
}
// VERIFY: 28bfbf51 manual
// OFFSET: 0x004C94B0
SI2ZoneSoundPair::~SI2ZoneSoundPair() {
}
// INLINED
SI2ZoneSound::SI2ZoneSound() {
this->m_soundKitId = 0;
this->m_type = 13;
}
// VERIFY: d03f2e4b manual
// OFFSET: 0x004C9910
int32_t SI2::ZoneSoundsUpdate(const void* data, void* param) {
int32_t timeOfDay = g_clientGameTime.IsDaytime() ? 0 : 1;
if (s_zoneSoundTimeOfDay != timeOfDay) {
s_zoneSoundTimeOfDay = timeOfDay;
}
SE2SoundKitProperties properties;
int32_t type = 13;
int32_t ambienceKitId = SI2::GetDesiredAmbienceKitID(&type);
if (!s_zoneAmbience.IsPlaying() || ambienceKitId != s_zoneAmbience.GetPlayingSoundKitId()) {
properties.ResetToDefaults();
properties.m_group = 2;
properties.m_loopMode = 1;
properties.m_priority = 100;
properties.m_reverb = 0;
if (SFile::IsStreamingMode()) {
properties.m_checkStreaming = 1;
}
int32_t immediate = 0;
if (SI2::sm_bUnderwaterChanged) {
immediate = 1;
properties.m_fadeInTime = 0.0f;
} else {
properties.m_fadeInTime = 5.0f;
}
s_zoneAmbience.Transition(ambienceKitId, type, &properties, immediate, 5.0f);
}
type = 13;
int32_t silenceMin = 0;
int32_t silenceMax = 0;
int32_t musicKitId = SI2::GetDesiredMusicKitID(&type, &silenceMin, &silenceMax);
if (SI2::sm_bLuaMusicPlaying) {
return 1;
}
if (s_zoneMusic.IsPlaying() && s_zoneMusic.GetPlayingSoundKitId() == musicKitId) {
return 1;
}
if (musicKitId == -1111 || CGGameUI::CameraMusicIsPlaying() || CGGameUI::SequenceMusicIsPlaying()) {
return 1;
}
properties.ResetToDefaults();
properties.m_group = 1;
properties.m_selectMode = 2;
properties.m_fadeInTime = s_zoneMusic.IsPlaying() ? 4.0f : 0.01f;
properties.m_fadeOutTime = 4.0f;
properties.m_priority = 100;
properties.m_reverb = 0;
if (SFile::IsStreamingMode()) {
properties.m_checkStreaming = 1;
}
if (s_zoneMusic.Transition(musicKitId, type, &properties, 0, -1.0f)) {
return 1;
}
SI2ZoneMusicTimer* timer = static_cast<SI2ZoneMusicTimer*>(SMemAlloc(sizeof(SI2ZoneMusicTimer), __FILE__, __LINE__, 0));
timer->m_soundKitId = musicKitId;
switch (type) {
case 0:
case 1:
case 2:
timer->m_silenceMax = silenceMax;
timer->m_silenceMin = silenceMin;
s_zoneMusic.SetFinishedCallback(SI2::ZoneMusicFinished, timer);
break;
case 3:
timer->m_silenceMax = silenceMax;
timer->m_silenceMin = silenceMin;
s_zoneMusic.SetFinishedCallback(SI2::AIMusicFinished, timer);
break;
case 5:
case 6:
case 7:
timer->m_silenceMin = silenceMin;
timer->m_silenceMax = 0;
s_zoneMusic.SetFinishedCallback(SI2::IntroMusicFinished, timer);
break;
default:
delete timer;
break;
}
return 1;
}
// VERIFY: cf894244 auto
// OFFSET: 0x004C9BD0
void SI2::InitZoneSoundsHandler() {
EventRegister(EVENT_ID_IDLE, SI2::ZoneSoundsUpdate);
EventRegister(EVENT_ID_IDLE, SI2::HandleWaterSounds);
}
// VERIFY: 3ebdde4f manual
// OFFSET: 0x004C9BF0
void SI2::ShutdownZoneSoundsHandler() {
EventUnregister(EVENT_ID_IDLE, SI2::ZoneSoundsUpdate);
s_zoneAmbience.Stop(1);
SI2::StopAllMusic();
SI2::WaterShutdown();
SE2::SetReverb(nullptr);
}
@@ -0,0 +1,50 @@
#ifndef WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2ZONESOUNDS_H
#define WOW_SOURCE_SOUNDINTERFACE_SOUNDINTERFACE2ZONESOUNDS_H
#include <cstddef>
#include <cstdint>
#include "Engine/Source/Storm/H/stpl.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
class SE2SoundKitProperties;
struct SI2ZoneSoundInfo {
/* 0000 */ int32_t m_music[2];
/* 0008 */ int32_t m_silenceMin[2];
/* 0010 */ int32_t m_silenceMax[2];
/* 0018 */ int32_t m_ambience[2];
/* 0020 */ int32_t m_reverb;
};
struct SI2ZoneMusicTimer {
/* 0000 */ int32_t m_soundKitId;
/* 0004 */ int32_t m_silenceMin;
/* 0008 */ int32_t m_silenceMax;
};
class SI2ZoneSound {
public:
/* 0000 */ int32_t m_soundKitId;
/* 0004 */ int32_t m_type;
/* 0008 */ SE2SoundKitObject m_object;
SI2ZoneSound();
};
class SI2ZoneSoundPair {
public:
/* 0000 */ SI2ZoneSound m_sounds[2];
/* 0038 */ uint32_t m_current;
/* 003C */ uint32_t m_next;
SI2ZoneSoundPair();
~SI2ZoneSoundPair();
int32_t GetCurrentType();
int32_t GetPlayingSoundKitId();
bool IsPlaying();
void SetFinishedCallback(void (*callback)(SESound*, void*), void* param);
void Stop(int32_t immediate);
int32_t Transition(int32_t soundKitId, int32_t type, SE2SoundKitProperties* properties, int32_t immediate, float fadeOutTime);
};
#endif
@@ -0,0 +1,288 @@
#include <cstddef>
#include <cstdint>
#include <cstring>
#include "Engine/Source/ConsoleBase/ConsoleVar.h"
#include "Engine/Source/FrameScript/FrameScript.h"
#include "Engine/Source/FrameScript/FrameScript_Object.h"
#include "Engine/Source/Os/TimeManager.h"
#include "Engine/Source/Storm/H/storm.h"
#include "Engine/Source/lua-5.1/src/lauxlib.h"
#include "Engine/Source/lua-5.1/src/lua.h"
#include "WoW/Source/SoundInterface/SoundInterface2.h"
#include "WoW/Source/Ui/ChatFrame.h"
// VERIFY: 1ef15c2e auto
// OFFSET: 0x009858B0
static int32_t Script_PlaySound(lua_State* L) {
if (lua_isnumber(L, 1)) {
SI2::PlayUISound(static_cast<int32_t>(lua_tonumber(L, 1)));
return 0;
}
if (!lua_isstring(L, 1)) {
lua_pushfstring(L, "Usage: PlaySound(\"sound\")");
lua_error(L);
}
char name[256];
SStrCopy(name, lua_tolstring(L, 1, nullptr), sizeof(name));
SI2::PlayUISound(SI2::LookupSoundKitId(name));
return 0;
}
// VERIFY: 4858a8e8 auto
// OFFSET: 0x00985950
static int32_t Script_PlayMusic(lua_State* L) {
if (!lua_isstring(L, 1)) {
lua_pushfstring(L, "Usage: PlayMusic(\"musicfile\")");
lua_error(L);
}
SI2::PlaySoundFile(lua_tolstring(L, 1, nullptr), 5);
lua_pushnumber(L, 1.0);
return 1;
}
// VERIFY: ca4839d7 auto
// OFFSET: 0x009859B0
static int32_t Script_PlaySoundFile(lua_State* L) {
if (!lua_isstring(L, 1)) {
lua_pushfstring(L, "Usage: PlaySoundFile(\"soundfile\")");
lua_error(L);
}
SI2::PlaySoundFile(lua_tolstring(L, 1, nullptr), 4);
lua_pushnumber(L, 1.0);
return 1;
}
// VERIFY: 006891da auto
// OFFSET: 0x00985A10
static int32_t Script_StopMusic(lua_State* L) {
SI2::StopLuaMusic();
return 0;
}
// VERIFY: 07bc13b7 auto
// OFFSET: 0x00985A20
static int32_t Script_Sound_ChatSystem_GetNumInputDrivers(lua_State* L) {
lua_pushnumber(L, SI2::GetNumInputDrivers_Cached(1));
return 1;
}
// VERIFY: 03a1d415 manual
// OFFSET: 0x00985A50
static int32_t Script_Sound_ChatSystem_GetInputDriverNameByIndex(lua_State* L) {
if (!lua_isnumber(L, 1)) {
luaL_error(L, "Usage: Sound_ChatSystem_GetInputDriverNameByIndex(InputDriverIndex)");
}
int32_t index = static_cast<int32_t>(lua_tointeger(L, 1));
char name[2048];
memset(name, 0, sizeof(name));
SI2::GetInputDriverName_Cached(index, name, sizeof(name), 1);
lua_pushstring(L, name);
return 1;
}
// VERIFY: 3a2f5e79 auto
// OFFSET: 0x00985AE0
static int32_t Script_Sound_ChatSystem_GetNumOutputDrivers(lua_State* L) {
lua_pushnumber(L, SI2::GetNumOutputDrivers_Cached(1));
return 1;
}
// VERIFY: cc26c99f manual
// OFFSET: 0x00985B10
static int32_t Script_Sound_ChatSystem_GetOutputDriverNameByIndex(lua_State* L) {
if (!lua_isnumber(L, 1)) {
luaL_error(L, "Usage: Sound_ChatSystem_GetOutputDriverNameByIndex(OutputDriverIndex)");
}
int32_t index = static_cast<int32_t>(lua_tointeger(L, 1));
char name[2048];
memset(name, 0, sizeof(name));
if (index >= 0 && index <= SI2::GetNumOutputDrivers_Cached(1)) {
SI2::GetOutputDriverName_Cached(index, name, sizeof(name), 1);
}
lua_pushstring(L, name);
return 1;
}
// VERIFY: f89b7f68 auto
// OFFSET: 0x00985BB0
static int32_t Script_Sound_GameSystem_GetNumInputDrivers(lua_State* L) {
lua_pushnumber(L, SI2::GetNumInputDrivers(0));
return 1;
}
// VERIFY: 7778bea0 manual
// OFFSET: 0x00985BE0
static int32_t Script_Sound_GameSystem_GetInputDriverNameByIndex(lua_State* L) {
if (!lua_isnumber(L, 1)) {
luaL_error(L, "Usage: Sound_GameSystem_GetInputDriverNameByIndex(InputDriverIndex)");
}
int32_t index = static_cast<int32_t>(lua_tointeger(L, 1));
char name[2048];
memset(name, 0, sizeof(name));
SI2::GetInputDriverName(index, name, sizeof(name), 0);
lua_pushstring(L, name);
return 1;
}
// VERIFY: a4609b4f auto
// OFFSET: 0x00985C70
static int32_t Script_Sound_GameSystem_GetNumOutputDrivers(lua_State* L) {
lua_pushnumber(L, SI2::GetNumOutputDrivers_Cached(0));
return 1;
}
// VERIFY: d8b04f4a manual
// OFFSET: 0x00985CA0
static int32_t Script_Sound_GameSystem_GetOutputDriverNameByIndex(lua_State* L) {
if (!lua_isnumber(L, 1)) {
luaL_error(L, "Usage: Sound_GetOutputDriverNameByIndex(OutputDriverIndex)");
}
int32_t index = static_cast<int32_t>(lua_tointeger(L, 1));
char name[2048];
memset(name, 0, sizeof(name));
SI2::GetOutputDriverName_Cached(index, name, sizeof(name), 0);
lua_pushstring(L, name);
return 1;
}
// VERIFY: 423ee834 auto
// OFFSET: 0x00985D30
static int32_t Script_Sound_GameSystem_RestartSoundSystem(lua_State* L) {
SI2::ShutDown(1);
OsSleep(200);
SI2::Init(1);
return 0;
}
// VERIFY: 984c78e6 auto
// OFFSET: 0x00985D50
static int32_t Script_VoiceChat_StopCapture(lua_State* L) {
SI2::VoiceChat_StopCapture();
return 0;
}
// VERIFY: ec24934e manual
// OFFSET: 0x00985D60
static int32_t Script_VoiceChat_RecordLoopbackSound(lua_State* L) {
if (!lua_isnumber(L, 1)) {
luaL_error(L, "Usage: VoiceChat_RecordLoopbackSound(MaxRecordTimeInSeconds)");
}
SI2::VoiceChat_RecordLoopbackSound(static_cast<int32_t>(lua_tonumber(L, 1)));
return 0;
}
// VERIFY: e7a90da2 auto
// OFFSET: 0x00985DD0
static int32_t Script_VoiceChat_StopRecordingLoopbackSound(lua_State* L) {
SI2::VoiceChat_StopRecordingLoopbackSound();
return 0;
}
// VERIFY: 6b24a31b auto
// OFFSET: 0x00985DE0
static int32_t Script_VoiceChat_PlayLoopbackSound(lua_State* L) {
SI2::VoiceChat_PlayLoopbackSound();
return 0;
}
// VERIFY: 2be65d3f auto
// OFFSET: 0x00985DF0
static int32_t Script_VoiceChat_StopPlayingLoopbackSound(lua_State* L) {
SI2::VoiceChat_StopPlayingLoopbackSound();
return 0;
}
// VERIFY: 86215d48 auto
// OFFSET: 0x00985E00
static int32_t Script_VoiceChat_IsRecordingLoopbackSound(lua_State* L) {
lua_pushnumber(L, SI2::VoiceChat_IsRecordingLoopbackSound());
return 1;
}
// VERIFY: 54e707f8 auto
// OFFSET: 0x00985E30
static int32_t Script_VoiceChat_IsPlayingLoopbackSound(lua_State* L) {
lua_pushnumber(L, SI2::VoiceChat_IsPlayingLoopbackSound());
return 1;
}
// VERIFY: 19bda182 auto
// OFFSET: 0x00985E60
static int32_t Script_VoiceChat_GetCurrentMicrophoneSignalLevel(lua_State* L) {
lua_pushnumber(L, SI2::VoiceChat_GetCurrentMicrophoneSignalLevel());
return 1;
}
// VERIFY: 8173801c auto
// OFFSET: 0x00985E90
static int32_t Script_VoiceChat_ActivatePrimaryCaptureCallback(lua_State* L) {
SI2::VoiceChat_ActivatePrimaryCaptureCallback();
return 0;
}
// VERIFY: 7e048fcd auto
// OFFSET: 0x00985EF0
static int32_t Script_VoiceChat_StartCapture(lua_State* L) {
static CVar* s_enableMicrophone = CVar::Lookup("EnableMicrophone");
static CVar* s_enableVoiceChat = CVar::Lookup("EnableVoiceChat");
if (s_enableVoiceChat && s_enableVoiceChat->m_intValue && s_enableMicrophone && s_enableMicrophone->m_intValue && CGChat::IsVoiceChatAllowed()) {
SI2::VoiceChat_StartCapture();
}
return 0;
}
// STATIC: 0x00B2D928
static FrameScript_Method s_ScriptFunctions[] = {
{ "PlaySound", &Script_PlaySound },
{ "PlayMusic", &Script_PlayMusic },
{ "PlaySoundFile", &Script_PlaySoundFile },
{ "StopMusic", &Script_StopMusic },
{ "Sound_GameSystem_GetNumInputDrivers", &Script_Sound_GameSystem_GetNumInputDrivers },
{ "Sound_GameSystem_GetInputDriverNameByIndex", &Script_Sound_GameSystem_GetInputDriverNameByIndex },
{ "Sound_GameSystem_GetNumOutputDrivers", &Script_Sound_GameSystem_GetNumOutputDrivers },
{ "Sound_GameSystem_GetOutputDriverNameByIndex", &Script_Sound_GameSystem_GetOutputDriverNameByIndex },
{ "Sound_GameSystem_RestartSoundSystem", &Script_Sound_GameSystem_RestartSoundSystem },
{ "Sound_ChatSystem_GetNumInputDrivers", &Script_Sound_ChatSystem_GetNumInputDrivers },
{ "Sound_ChatSystem_GetInputDriverNameByIndex", &Script_Sound_ChatSystem_GetInputDriverNameByIndex },
{ "Sound_ChatSystem_GetNumOutputDrivers", &Script_Sound_ChatSystem_GetNumOutputDrivers },
{ "Sound_ChatSystem_GetOutputDriverNameByIndex", &Script_Sound_ChatSystem_GetOutputDriverNameByIndex },
{ "VoiceChat_StartCapture", &Script_VoiceChat_StartCapture },
{ "VoiceChat_StopCapture", &Script_VoiceChat_StopCapture },
{ "VoiceChat_RecordLoopbackSound", &Script_VoiceChat_RecordLoopbackSound },
{ "VoiceChat_StopRecordingLoopbackSound", &Script_VoiceChat_StopRecordingLoopbackSound },
{ "VoiceChat_PlayLoopbackSound", &Script_VoiceChat_PlayLoopbackSound },
{ "VoiceChat_StopPlayingLoopbackSound", &Script_VoiceChat_StopPlayingLoopbackSound },
{ "VoiceChat_IsRecordingLoopbackSound", &Script_VoiceChat_IsRecordingLoopbackSound },
{ "VoiceChat_IsPlayingLoopbackSound", &Script_VoiceChat_IsPlayingLoopbackSound },
{ "VoiceChat_GetCurrentMicrophoneSignalLevel", &Script_VoiceChat_GetCurrentMicrophoneSignalLevel },
{ "VoiceChat_ActivatePrimaryCaptureCallback", &Script_VoiceChat_ActivatePrimaryCaptureCallback },
};
// VERIFY: db289b49 auto
// OFFSET: 0x00985EA0
void SI2::RegisterScriptFunctions() {
for (uint32_t i = 0; i < sizeof(s_ScriptFunctions) / sizeof(s_ScriptFunctions[0]); i++) {
FrameScript_RegisterFunction(s_ScriptFunctions[i].m_name, s_ScriptFunctions[i].m_method);
}
}
// VERIFY: bd7c6065 auto
// OFFSET: 0x00985ED0
void SI2::UnregisterScriptFunctions() {
for (uint32_t i = 0; i < sizeof(s_ScriptFunctions) / sizeof(s_ScriptFunctions[0]); i++) {
FrameScript_UnregisterFunction(s_ScriptFunctions[i].m_name);
}
}
+17
View File
@@ -0,0 +1,17 @@
#ifndef WOW_SOURCE_SOUNDINTERFACE_TYPES_H
#define WOW_SOURCE_SOUNDINTERFACE_TYPES_H
#include <cstddef>
#include <cstdint>
enum SI2_DSP_TYPE {
SI2_DSP_TYPE_NONE = 0,
SI2_DSP_TYPE_PITCHSHIFT = 1,
SI2_DSP_TYPE_HIGHPASS = 2,
SI2_DSP_TYPE_LOWPASS = 3,
SI2_DSP_TYPE_CHORUS = 4,
SI2_DSP_TYPE_ECHO = 5,
SI2_DSP_TYPE_VOLUME = 6,
};
#endif
+5
View File
@@ -1,4 +1,9 @@
#ifndef WOW_SOURCE_UI_CGWORLDSTATEINFO_H
#define WOW_SOURCE_UI_CGWORLDSTATEINFO_H
#include <cstddef>
#include <cstdint>
int32_t GetWorldState(int32_t id);
#endif
+13
View File
@@ -4,6 +4,19 @@
#include <cstddef>
#include <cstdint>
class CGChat {
public:
static int32_t m_paused;
static int32_t GetActiveVoiceSession();
static const char* GetChannelStringForDisplay(int32_t session, int32_t* type);
static int32_t IsPaused();
static bool IsVoiceChatAllowed();
static void LeaveWorld();
static void Resume();
static void SetActiveVoiceSession(const char* channel, int32_t type, int32_t index);
};
class PENDINGCHAT {
public:
/* 0000 */ uint32_t unk_0000;
+8 -1
View File
@@ -8,7 +8,14 @@
#include "Engine/Source/Tempest/C3Vector.h"
#include "WoW/Source/Object/WGUID.h"
class CGGameUI;
class CGGameUI {
public:
static int32_t m_initialized;
static int32_t m_inMovie;
static int32_t CameraMusicIsPlaying();
static int32_t SequenceMusicIsPlaying();
};
class CSpriteClickEvent {
public:
-1
View File
@@ -1 +0,0 @@
#include "DNameNode.h"
-4
View File
@@ -1,4 +0,0 @@
#ifndef _TRIAGE_DNAMENODE_H
#define _TRIAGE_DNAMENODE_H
#endif
-1
View File
@@ -1 +0,0 @@
#include "FOOTSTEPSNDCACHE.h"
-14
View File
@@ -1,14 +0,0 @@
#ifndef _TRIAGE_FOOTSTEPSNDCACHE_H
#define _TRIAGE_FOOTSTEPSNDCACHE_H
#include <cstddef>
#include <cstdint>
class FOOTSTEPSNDCACHE {
public:
/* 0000 */ uint8_t unk_0000[24];
/* 0018 */ uint32_t unk_0018[6];
/* 0030 */ uint32_t unk_0030[6];
};
#endif
-1
View File
@@ -1 +0,0 @@
#include "SE2SoundKitProperties.h"
-9
View File
@@ -1,9 +0,0 @@
#ifndef _TRIAGE_SE2SOUNDKITPROPERTIES_H
#define _TRIAGE_SE2SOUNDKITPROPERTIES_H
#include <cstddef>
#include <cstdint>
class SE2SoundKitProperties;
#endif
-1
View File
@@ -1 +0,0 @@
#include "SI.h"
-4
View File
@@ -1,4 +0,0 @@
#ifndef _TRIAGE_SI_H
#define _TRIAGE_SI_H
#endif
-1
View File
@@ -1 +0,0 @@
#include "SI2DspChainHead.h"
-4
View File
@@ -1,4 +0,0 @@
#ifndef _TRIAGE_SI2DSPCHAINHEAD_H
#define _TRIAGE_SI2DSPCHAINHEAD_H
#endif
-1
View File
@@ -1 +0,0 @@
#include "SoundInterface2.h"
-20
View File
@@ -1,20 +0,0 @@
#ifndef _TRIAGE_SOUNDINTERFACE2_H
#define _TRIAGE_SOUNDINTERFACE2_H
#include <cstddef>
#include <cstdint>
class SI3 {
public:
/* 0000 */ uint32_t unk_0000;
/* 0004 */ uint8_t unk_0004[204];
/* 00D0 */ uint32_t unk_00D0;
/* 00D4 */ uint8_t unk_00D4[2044];
/* 08D0 */ uint32_t unk_08D0;
/* 08D4 */ uint8_t unk_08D4[1676];
/* 0F60 */ uint32_t unk_0F60;
/* 0F64 */ uint8_t unk_0F64[164];
/* 1008 */ uint32_t unk_1008[1026];
};
#endif
@@ -1 +0,0 @@
#include "SoundInterface2AdvancedKitProperties.h"
@@ -1,4 +0,0 @@
#ifndef _TRIAGE_SOUNDINTERFACE2ADVANCEDKITPROPERTIES_H
#define _TRIAGE_SOUNDINTERFACE2ADVANCEDKITPROPERTIES_H
#endif
-1
View File
@@ -1 +0,0 @@
#include "SoundInterface2DSP.h"
-9
View File
@@ -1,9 +0,0 @@
#ifndef _TRIAGE_SOUNDINTERFACE2DSP_H
#define _TRIAGE_SOUNDINTERFACE2DSP_H
#include <cstddef>
#include <cstdint>
class SI2;
#endif
-1
View File
@@ -1 +0,0 @@
#include "SoundInterface2Internal.h"
-4
View File
@@ -1,4 +0,0 @@
#ifndef _TRIAGE_SOUNDINTERFACE2INTERNAL_H
#define _TRIAGE_SOUNDINTERFACE2INTERNAL_H
#endif
-1
View File
@@ -1 +0,0 @@
#include "SoundInterface2VoiceChat.h"
-4
View File
@@ -1,4 +0,0 @@
#ifndef _TRIAGE_SOUNDINTERFACE2VOICECHAT_H
#define _TRIAGE_SOUNDINTERFACE2VOICECHAT_H
#endif
-1
View File
@@ -1 +0,0 @@
#include "SoundInterface2ZoneSounds.h"
-4
View File
@@ -1,4 +0,0 @@
#ifndef _TRIAGE_SOUNDINTERFACE2ZONESOUNDS_H
#define _TRIAGE_SOUNDINTERFACE2ZONESOUNDS_H
#endif