r5sdk/r5dev/engine/staticpropmgr.cpp
Kawe Mazidjatari abe68def03 CMDLCache code improvements
Slightly mapped out the CMDLCache class, to the point the pointers to its members are no longer needed. Also fixed a bug were the studiodata pointer was dereferenced before checking if its not null, this check did exist, but was performed too late. Fully implemented the CUtlDict class for m_MDLDict. Slightly optimized the initialization of the error model handles.
2023-06-19 13:53:56 +02:00

38 lines
1.3 KiB
C++

#include "core/stdafx.h"
#include "datacache/mdlcache.h"
#include "engine/staticpropmgr.h"
//-----------------------------------------------------------------------------
// Purpose: initialises static props from the static prop gamelump
//-----------------------------------------------------------------------------
void* __fastcall CStaticProp_Init(int64_t thisptr, int64_t a2, unsigned int idx, unsigned int a4, StaticPropLump_t* lump, int64_t a6, int64_t a7)
{
MDLHandle_t handle = *reinterpret_cast<uint16_t*>(a7 + 0x140);
studiohdr_t* pStudioHdr = g_pMDLCache->FindMDL(g_pMDLCache, handle, nullptr);
if (lump->m_Skin >= pStudioHdr->numskinfamilies)
{
Error(eDLL_T::ENGINE, NO_ERROR,
"Invalid skin index for static prop #%i with model '%s' (got %i, max %i)\n",
idx, pStudioHdr->name, lump->m_Skin, pStudioHdr->numskinfamilies-1);
lump->m_Skin = 0;
}
return v_CStaticProp_Init(thisptr, a2, idx, a4, lump, a6, a7);
}
void VStaticPropMgr::Attach() const
{
#ifndef DEDICATED
DetourAttach((LPVOID*)&v_CStaticProp_Init, &CStaticProp_Init);
#endif // !DEDICATED
}
void VStaticPropMgr::Detach() const
{
#ifndef DEDICATED
DetourDetach((LPVOID*)&v_CStaticProp_Init, &CStaticProp_Init);
#endif // !DEDICATED
}