r5sdk/r5dev/engine/staticpropmgr.cpp
Kawe Mazidjatari edc52ad669 IDetour: remove extraneous pointer assignments
Originally, we store the search results in a CMemory instance which we then assign to the actual function pointer. CMemory is just a pointer class; we can assign the results directly to the actual function pointer. This commit reduces a lot of code verbosity, and also reduced roughly 2KiB worth of static pointers in the resulting executable. This commit also officially deprecates the support for any GameDLL's below S3 (Season 3), since it makes more sense to port the assets from earlier/later games back to the version this SDK supports.
2024-04-05 17:19:32 +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* CStaticProp::Init(CStaticProp* 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 CStaticProp__Init(thisptr, a2, idx, a4, lump, a6, a7);
}
void VStaticPropMgr::Detour(const bool bAttach) const
{
#ifndef DEDICATED
DetourSetup(&CStaticProp__Init, &CStaticProp::Init, bAttach);
#endif // !DEDICATED
}