Optimize the finding of fallback models

Don't construct a new string, just test the mdl strings right away using 'V_ComparePath'.
This commit is contained in:
Kawe Mazidjatari 2023-07-10 19:17:00 +02:00
parent dbb18e586d
commit 3391b1b1f0

View File

@ -38,27 +38,15 @@ studiohdr_t* CMDLCache::FindMDL(CMDLCache* cache, MDLHandle_t handle, void* a3)
{
studiohdr_t* pStudioHDR = **reinterpret_cast<studiohdr_t***>(pStudioData);
if (!g_pMDLFallback->m_hErrorMDL)
if (!g_pMDLFallback->m_hErrorMDL && V_ComparePath(pStudioHDR->name, ERROR_MODEL))
{
CUtlString studioPathFixed(pStudioHDR->name);
studioPathFixed.FixSlashes(INCORRECT_PATH_SEPARATOR);
if (studioPathFixed.IsEqual_CaseInsensitive(ERROR_MODEL))
{
g_pMDLFallback->m_pErrorHDR = pStudioHDR;
g_pMDLFallback->m_hErrorMDL = handle;
}
g_pMDLFallback->m_pErrorHDR = pStudioHDR;
g_pMDLFallback->m_hErrorMDL = handle;
}
else if (!g_pMDLFallback->m_hEmptyMDL)
else if (!g_pMDLFallback->m_hEmptyMDL && V_ComparePath(pStudioHDR->name, EMPTY_MODEL))
{
CUtlString studioPathFixed(pStudioHDR->name);
studioPathFixed.FixSlashes(INCORRECT_PATH_SEPARATOR);
if (studioPathFixed.IsEqual_CaseInsensitive(EMPTY_MODEL))
{
g_pMDLFallback->m_pEmptyHDR = pStudioHDR;
g_pMDLFallback->m_hEmptyMDL = handle;
}
g_pMDLFallback->m_pEmptyHDR = pStudioHDR;
g_pMDLFallback->m_hEmptyMDL = handle;
}
}
}