r5sdk/r5dev/vpc/interfaces.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

64 lines
2.1 KiB
C++

//===========================================================================//
//
// Purpose: A higher level link library for general use in the game and SDK.
//
//===========================================================================//
#include "core/stdafx.h"
#include "vpc/interfaces.h"
#include "tier1/interface.h"
//---------------------------------------------------------------------------------
// Purpose: register a new factory
// Input : createFn -
// *pName -
//---------------------------------------------------------------------------------
void CFactorySystem::AddFactory(InstantiateInterfaceFn createFn, const char* pName) const
{
InterfaceReg(createFn, pName);
}
//---------------------------------------------------------------------------------
// Purpose: get a factory by name
// Input : *pName -
//---------------------------------------------------------------------------------
void* CFactorySystem::GetFactory(const char* pName) const
{
for (InterfaceReg* it = *s_ppInterfaceRegs;
it; it = it->m_pNext) // Loop till we go out of scope.
{
if (V_strcmp(it->m_pName, pName) == NULL)
return it->m_CreateFn();
}
// No dice.
return nullptr;
}
//---------------------------------------------------------------------------------
// Purpose: get the factory system's interface version
// Input : *pName -
//---------------------------------------------------------------------------------
const char* CFactorySystem::GetVersion(void) const
{
return FACTORY_INTERFACE_VERSION;
}
//---------------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------------
void* CreateInterface(const char* pName, int* pReturnCode)
{
return v_CreateInterfaceInternal(pName, pReturnCode);
}
//---------------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------------
IFactorySystem* GetFactorySystem()
{
return g_pFactorySystem;
}
CFactorySystem* g_pFactorySystem = new CFactorySystem();