r5sdk/r5dev/codecs/Miles/miles_impl.cpp
Kawe Mazidjatari 144d5f62e1 IDetour: code refactor
Utilize the new IDetour::DetourSetup() code, IDetour::Attach and IDetour::Detach have been removed in favor of this (significantly reduces chance of user error). Since the template check happens in the idetour header, it is much more aggressive on type mismatches, such as a difference in parameter types, between the function and detour, will now raise a compile time error. As a result, some type mismatches have been fixed in this commit as well.
2024-04-05 16:41:09 +02:00

62 lines
2.1 KiB
C++

#include "core/stdafx.h"
#include "miles_impl.h"
#include "tier0/fasttimer.h"
#include "tier1/cvar.h"
//-----------------------------------------------------------------------------
// Purpose: logs debug output emitted from the Miles Sound System
// Input : nLogLevel -
// pszMessage -
//-----------------------------------------------------------------------------
void AIL_LogFunc(int64_t nLogLevel, const char* pszMessage)
{
Msg(eDLL_T::AUDIO, "%s\n", pszMessage);
v_AIL_LogFunc(nLogLevel, pszMessage);
}
//-----------------------------------------------------------------------------
// Purpose: initializes the miles sound system
// Output : true on success, false otherwise
//-----------------------------------------------------------------------------
bool Miles_Initialize()
{
const char* pszLanguage = miles_language->GetString();
if (!pszLanguage[0])
{
pszLanguage = MILES_DEFAULT_LANGUAGE;
}
Msg(eDLL_T::AUDIO, "%s: initializing MSS with language: '%s'\n", __FUNCTION__, pszLanguage);
CFastTimer initTimer;
initTimer.Start();
bool bResult = v_Miles_Initialize();
initTimer.End();
Msg(eDLL_T::AUDIO, "%s: %s ('%f' seconds)\n", __FUNCTION__, bResult ? "success" : "failure", initTimer.GetDuration().GetSeconds());
return bResult;
}
void MilesQueueEventRun(Miles::Queue* queue, const char* eventName)
{
if(miles_debug->GetBool())
Msg(eDLL_T::AUDIO, "%s: running event: '%s'\n", __FUNCTION__, eventName);
v_MilesQueueEventRun(queue, eventName);
}
void MilesBankPatch(Miles::Bank* bank, char* streamPatch, char* localizedStreamPatch)
{
// TODO [REXX]: add print for patch loading when Miles::Bank struct is mapped out a bit better with file name
v_MilesBankPatch(bank, streamPatch, localizedStreamPatch);
}
///////////////////////////////////////////////////////////////////////////////
void MilesCore::Detour(const bool bAttach) const
{
DetourSetup(&v_AIL_LogFunc, &AIL_LogFunc, bAttach);
DetourSetup(&v_Miles_Initialize, &Miles_Initialize, bAttach);
DetourSetup(&v_MilesQueueEventRun, &MilesQueueEventRun, bAttach);
DetourSetup(&v_MilesBankPatch, &MilesBankPatch, bAttach);
}