2022-11-27 17:27:35 +01:00
|
|
|
#include "core/stdafx.h"
|
|
|
|
#include "miles_impl.h"
|
2023-02-12 00:05:27 +01:00
|
|
|
#include "tier0/fasttimer.h"
|
2022-11-27 20:44:17 +00:00
|
|
|
#include "tier1/cvar.h"
|
2022-11-27 17:27:35 +01:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: logs debug output emitted from the Miles Sound System
|
|
|
|
// Input : nLogLevel -
|
|
|
|
// pszMessage -
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void AIL_LogFunc(int64_t nLogLevel, const char* pszMessage)
|
|
|
|
{
|
2023-04-01 10:24:08 +02:00
|
|
|
DevMsg(eDLL_T::AUDIO, "%s\n", pszMessage);
|
2022-11-27 17:27:35 +01:00
|
|
|
v_AIL_LogFunc(nLogLevel, pszMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: initializes the miles sound system
|
|
|
|
// Output : true on success, false otherwise
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
bool Miles_Initialize()
|
|
|
|
{
|
2023-02-12 00:05:27 +01:00
|
|
|
const char* pszLanguage = miles_language->GetString();
|
|
|
|
if (!pszLanguage[0])
|
|
|
|
{
|
|
|
|
pszLanguage = MILES_DEFAULT_LANGUAGE;
|
|
|
|
}
|
2022-11-27 20:44:17 +00:00
|
|
|
|
2023-02-12 00:05:27 +01:00
|
|
|
DevMsg(eDLL_T::AUDIO, "%s: initializing MSS with language: '%s'\n", __FUNCTION__, pszLanguage);
|
|
|
|
CFastTimer initTimer;
|
2022-11-27 17:27:35 +01:00
|
|
|
|
2023-02-12 00:05:27 +01:00
|
|
|
initTimer.Start();
|
|
|
|
bool bResult = v_Miles_Initialize();
|
|
|
|
initTimer.End();
|
2022-11-27 17:27:35 +01:00
|
|
|
|
2023-02-12 00:05:27 +01:00
|
|
|
DevMsg(eDLL_T::AUDIO, "%s: %s ('%f' seconds)\n", __FUNCTION__, bResult ? "success" : "failure", initTimer.GetDuration().GetSeconds());
|
2022-11-27 17:41:03 +01:00
|
|
|
return bResult;
|
2022-11-27 17:27:35 +01:00
|
|
|
}
|
|
|
|
|
2022-11-27 20:44:17 +00:00
|
|
|
void MilesQueueEventRun(Miles::Queue* queue, const char* eventName)
|
|
|
|
{
|
|
|
|
if(miles_debug->GetBool())
|
2023-02-12 00:05:27 +01:00
|
|
|
DevMsg(eDLL_T::AUDIO, "%s: running event: '%s'\n", __FUNCTION__, eventName);
|
2022-11-27 20:44:17 +00:00
|
|
|
|
|
|
|
v_MilesQueueEventRun(queue, eventName);
|
|
|
|
}
|
2022-11-27 20:44:37 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2022-11-27 17:27:35 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2023-01-25 02:26:52 +01:00
|
|
|
void MilesCore::Attach() const
|
2022-11-27 17:27:35 +01:00
|
|
|
{
|
|
|
|
DetourAttach(&v_AIL_LogFunc, &AIL_LogFunc);
|
|
|
|
DetourAttach(&v_Miles_Initialize, &Miles_Initialize);
|
2022-11-27 20:44:17 +00:00
|
|
|
DetourAttach(&v_MilesQueueEventRun, &MilesQueueEventRun);
|
2022-11-27 20:44:37 +00:00
|
|
|
DetourAttach(&v_MilesBankPatch, &MilesBankPatch);
|
2022-11-27 17:27:35 +01:00
|
|
|
}
|
|
|
|
|
2023-01-25 02:26:52 +01:00
|
|
|
void MilesCore::Detach() const
|
2022-11-27 17:27:35 +01:00
|
|
|
{
|
|
|
|
DetourDetach(&v_AIL_LogFunc, &AIL_LogFunc);
|
|
|
|
DetourDetach(&v_Miles_Initialize, &Miles_Initialize);
|
2022-11-27 20:44:17 +00:00
|
|
|
DetourDetach(&v_MilesQueueEventRun, &MilesQueueEventRun);
|
2022-11-27 20:44:37 +00:00
|
|
|
DetourDetach(&v_MilesBankPatch, &MilesBankPatch);
|
2022-11-27 17:27:35 +01:00
|
|
|
}
|