From 7441bf156b377619a9af0c95110ce7b72986a89b Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 29 Apr 2022 22:11:35 +0200 Subject: [PATCH] Return proper studio hardware for mdl/error.rmdl Now mdl/error.rmdl draws properly --- r5dev/datacache/mdlcache.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/r5dev/datacache/mdlcache.cpp b/r5dev/datacache/mdlcache.cpp index d3b915af..2a77b564 100644 --- a/r5dev/datacache/mdlcache.cpp +++ b/r5dev/datacache/mdlcache.cpp @@ -174,7 +174,6 @@ studiohdr_t* CMDLCache::GetStudioHDR(CMDLCache* pMDLCache, MDLHandle_t handle) __int64 v2; // rbx __int64 v3; // rbx __int64 v4; // rdx - __int64 v5; // rdi studiohdr_t* result = nullptr; // rax if (!handle) @@ -190,12 +189,11 @@ studiohdr_t* CMDLCache::GetStudioHDR(CMDLCache* pMDLCache, MDLHandle_t handle) EnterCriticalSection(reinterpret_cast(&*m_MDLMutex)); v3 = *(_QWORD*)(m_MDLDict.Deref().GetPtr() + 24 * v2 + 16); LeaveCriticalSection(reinterpret_cast(&*m_MDLMutex)); - v4 = *(_QWORD*)(v3); - if (v4) + if (*(_QWORD*)(v3)) { - v5 = *(_QWORD*)(*(_QWORD*)(*(_QWORD*)v3 + 8i64) + 24i64); - if (v5) - result = (studiohdr_t*)(v5 + 16); + v4 = *(_QWORD*)(*(_QWORD*)(*(_QWORD*)v3 + 8i64) + 24i64); + if (v4) + result = (studiohdr_t*)(v4 + 16); } return result; } @@ -222,7 +220,12 @@ CStudioHWDataRef* CMDLCache::GetStudioHardwareRef(CMDLCache* cache, MDLHandle_t if (!v3) { - return nullptr; + if (!g_pMDLFallback->m_hErrorMDL) + { + Error(eDLL_T::ENGINE, "Studio hardware with handle \"%hu\" not found and \"%s\" couldn't be loaded.\n", handle, ERROR_MODEL); + return nullptr; + } + v3 = *(_QWORD*)(m_MDLDict.Deref().GetPtr() + 24 * g_pMDLFallback->m_hErrorMDL + 16); } if (*(_QWORD*)v3)