mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Removed all extraneous copies by adding the class 'InterfaceReg' which will construct a new interface, and link it to the engine's static register. The Source Engine macro 'EXPOSE_INTERFACE_FN' will help utilizing this. The game module from the plugin is not obtained through the process environment block, so the executable is no longer sensitive to names.
64 lines
2.1 KiB
C++
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 CreateInterfaceInternal(pName, pReturnCode);
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------
|
|
// Purpose:
|
|
//---------------------------------------------------------------------------------
|
|
IFactorySystem* GetFactorySystem()
|
|
{
|
|
return g_pFactorySystem;
|
|
}
|
|
|
|
CFactorySystem* g_pFactorySystem = new CFactorySystem();
|