diff --git a/Plugins/CaptionMod/exportfuncs.cpp b/Plugins/CaptionMod/exportfuncs.cpp index 99f2093d..bc1932d5 100644 --- a/Plugins/CaptionMod/exportfuncs.cpp +++ b/Plugins/CaptionMod/exportfuncs.cpp @@ -795,6 +795,7 @@ sfx_t *S_FindName(char *name, int *pfInCache) static bool g_bPlayingFMODSound = false; static bool g_bPlayedFMODSound = false; static int g_iCurrentPlayingFMODSoundLengthMs = 0; +static void* g_pFMODSystem = NULL; bool ScClient_StartSentence(const char* name, float distance, float avol) { @@ -915,6 +916,7 @@ void __fastcall ScClient_SoundEngine_PlayFMODSound(void* pSoundEngine, int, int { g_bPlayingFMODSound = true; g_iCurrentPlayingFMODSoundLengthMs = 0; + g_pFMODSystem = *(void **)((PUCHAR)pSoundEngine + 0x2004); gPrivateFuncs.ScClient_SoundEngine_PlayFMODSound(pSoundEngine, 0, flags, entindex, origin, channel, name, fvol, attenuation, extraflags, pitch, sentenceIndex, soundLength); @@ -954,7 +956,14 @@ void __fastcall ScClient_SoundEngine_PlayFMODSound(void* pSoundEngine, int, int if (!ignore && !name && sentenceIndex >= 0) { - //TODO: Sentence support + auto sentenceName = gPrivateFuncs.ScClient_SoundEngine_LookupSoundBySentenceIndex(pSoundEngine, sentenceIndex); + + if (sentenceName) + { + ScClient_StartWave(sentenceName, distance, avol, g_iCurrentPlayingFMODSoundLengthMs); + + ignore = true; + } } if (!ignore && name) @@ -970,7 +979,7 @@ void __fastcall ScClient_SoundEngine_PlayFMODSound(void* pSoundEngine, int, int int __stdcall FMOD_System_playSound(void* FMOD_System, int channelid, void* FMOD_Sound, bool paused, void** FMOD_Channel) { - if (g_bPlayingFMODSound) + if (g_bPlayingFMODSound && g_pFMODSystem == FMOD_System) { int duration = 0; gPrivateFuncs.FMOD_Sound_getLength(FMOD_Sound, &duration, 1); diff --git a/Plugins/CaptionMod/privatefuncs.cpp b/Plugins/CaptionMod/privatefuncs.cpp index 0ac70b6b..624d5295 100644 --- a/Plugins/CaptionMod/privatefuncs.cpp +++ b/Plugins/CaptionMod/privatefuncs.cpp @@ -1408,6 +1408,15 @@ void Client_FillAddress(void) gPrivateFuncs.ScClient_SoundEngine_PlayFMODSound = (decltype(gPrivateFuncs.ScClient_SoundEngine_PlayFMODSound))GetCallAddress(addr + Sig_Length(pattern) - 1); } + if (1) + { + char pattern[] = "\x8B\x54\x24\x04\x81\xFA\xFF\x0F\x00\x00\x2A\x2A\x83\x3C\x91\x00\x2A\x2A\x0F\xAE\xE8"; + auto addr = (PUCHAR)Search_Pattern_From_Size(ClientTextBase, ClientTextSize, pattern); + Sig_VarNotFound("ScClient_SoundEngine_LookupSoundBySentenceIndex"); + + gPrivateFuncs.ScClient_SoundEngine_LookupSoundBySentenceIndex = (decltype(gPrivateFuncs.ScClient_SoundEngine_LookupSoundBySentenceIndex))addr; + } + #if 0 #define SC_FINDSOUND_SIG "\x51\x55\x8B\x6C\x24\x0C\x89\x4C\x24\x04\x85\xED\x0F\x84\x2A\x2A\x2A\x2A\x80\x7D\x00\x00" { diff --git a/Plugins/CaptionMod/privatefuncs.h b/Plugins/CaptionMod/privatefuncs.h index 8fa2d153..efbc4d0c 100644 --- a/Plugins/CaptionMod/privatefuncs.h +++ b/Plugins/CaptionMod/privatefuncs.h @@ -47,7 +47,8 @@ typedef struct //int(__fastcall *ScClient_FindSoundEx)(void *pthis, int, const char *soundName); void (__fastcall*ScClient_SoundEngine_PlayFMODSound)(void *pSoundEngine, int, int flags, int entindex, float *origin, int channel, const char *name, float fvol, float attenuation, int extraflags, int pitch, int sentenceIndex, float soundLength); - + const char *(__thiscall* ScClient_SoundEngine_LookupSoundBySentenceIndex)(void* pSoundEngine, int sentenceIndex); + //FMOD int(__stdcall*FMOD_Sound_getLength)(void * FMOD_Sound, void* output, int type);//?getLength@Sound@FMOD@@QAG?AW4FMOD_RESULT@@PAII@Z