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

31 lines
1.1 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::Detour(const bool bAttach) const
{
#ifndef DEDICATED
DetourSetup(&v_CStaticProp_Init, &CStaticProp_Init, bAttach);
#endif // !DEDICATED
}