r5sdk/r5dev/localize/localize.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

48 lines
1.1 KiB
C++

#include "core/stdafx.h"
#include "tier1/utlvector.h"
#include "localize/localize.h"
#include "pluginsystem/modsystem.h"
bool Localize_LoadLocalizationFileLists(CLocalize* thisptr)
{
v_CLocalize__LoadLocalizationFileLists(thisptr);
const CUtlVector<CModSystem::ModInstance_t*>&
modList = g_pModSystem->GetModList();
FOR_EACH_VEC(modList, i)
{
const CModSystem::ModInstance_t* mod =
modList.Element(i);
if (!mod->IsEnabled())
continue;
FOR_EACH_VEC(mod->m_LocalizationFiles, j)
{
const char* localizationFile = mod->m_LocalizationFiles.Element(j).Get();
if (!v_CLocalize__AddFile(thisptr, localizationFile, "PLATFORM"))
Warning(eDLL_T::ENGINE, "Failed to add localization file '%s'\n", localizationFile);
}
}
return true;
}
bool Localize_IsLanguageSupported(const char* pLocaleName)
{
for (int i = 0; i < SDK_ARRAYSIZE(g_LanguageNames); ++i)
{
if (strcmp(pLocaleName, g_LanguageNames[i]) == NULL)
return true;
}
return false;
}
void VLocalize::Detour(const bool bAttach) const
{
DetourSetup(&v_CLocalize__LoadLocalizationFileLists, &Localize_LoadLocalizationFileLists, bAttach);
}