enable pluginsystem

This commit is contained in:
rexx 2023-04-23 22:28:16 +01:00
parent 59b685b7ee
commit 3eb660c9f7
5 changed files with 44 additions and 23 deletions

View File

@ -17,6 +17,7 @@
#include "networksystem/bansystem.h"
#include "ebisusdk/EbisuSDK.h"
#include "public/edict.h"
#include <pluginsystem/pluginsystem.h>
//---------------------------------------------------------------------------------
// Purpose: Gets the number of human players on the server
@ -139,6 +140,13 @@ CClient* CServer::ConnectClient(CServer* pServer, user_creds_s* pChallenge)
return nullptr;
CClient* pClient = v_CServer_ConnectClient(pServer, pChallenge);
for (auto& callback : !g_pPluginSystem->GetConnectClientCallbacks())
{
if (!callback(pServer, pClient, pChallenge))
return nullptr;
}
return pClient;
}

View File

@ -100,8 +100,8 @@ bool CModAppSystemGroup::StaticCreate(CModAppSystemGroup* pModAppSystemGroup)
g_pFactory->AddFactory(FACTORY_INTERFACE_VERSION, g_pFactory);
g_pFactory->AddFactory(INTERFACEVERSION_PLUGINSYSTEM, g_pPluginSystem);
//InitPluginSystem(pModAppSystemGroup);
//CALL_PLUGIN_CALLBACKS(g_pPluginSystem->GetCreateCallbacks(), pModAppSystemGroup);
InitPluginSystem(pModAppSystemGroup);
CALL_PLUGIN_CALLBACKS(g_pPluginSystem->GetCreateCallbacks(), pModAppSystemGroup);
g_pDebugOverlay = g_pFactory->GetFactoryPtr(VDEBUG_OVERLAY_INTERFACE_VERSION, false).RCast<CIVDebugOverlay*>();
#ifndef CLIENT_DLL

View File

@ -1,6 +1,25 @@
#pragma once
struct PluginHelpWithAnything_t;
struct PluginHelpWithAnything_t
{
enum class ePluginHelp : int16_t
{
PLUGIN_GET_FUNCTION = 0,
PLUGIN_REGISTER_CALLBACK,
PLUGIN_UNREGISTER_CALLBACK
};
enum class ePluginCallback : int16_t
{
CModAppSystemGroup_Create = 0,
CServer_ConnectClient
};
ePluginHelp m_nHelpID;
ePluginCallback m_nCallbackID;
const char* m_pszName;
void* m_pFunction;
};
abstract_class IPluginSystem
{

View File

@ -128,6 +128,11 @@ void CPluginSystem::AddPluginCallback(PluginHelpWithAnything_t* help)
ADD_PLUGIN_CALLBACK(CreateFn, GetCreateCallbacks(), help->m_pFunction);
break;
}
case PluginHelpWithAnything_t::ePluginCallback::CServer_ConnectClient:
{
ADD_PLUGIN_CALLBACK(ConnectClientFn, GetConnectClientCallbacks(), help->m_pFunction);
break;
}
default:
break;
}
@ -151,6 +156,11 @@ void CPluginSystem::RemovePluginCallback(PluginHelpWithAnything_t* help)
REMOVE_PLUGIN_CALLBACK(CreateFn, GetCreateCallbacks(), help->m_pFunction);
break;
}
case PluginHelpWithAnything_t::ePluginCallback::CServer_ConnectClient:
{
REMOVE_PLUGIN_CALLBACK(ConnectClientFn, GetConnectClientCallbacks(), help->m_pFunction);
break;
}
default:
break;
}

View File

@ -2,26 +2,9 @@
#include "ipluginsystem.h"
class CModAppSystemGroup;
struct PluginHelpWithAnything_t
{
enum class ePluginHelp : int16_t
{
PLUGIN_GET_FUNCTION = 0,
PLUGIN_REGISTER_CALLBACK,
PLUGIN_UNREGISTER_CALLBACK
};
enum class ePluginCallback : int16_t
{
CModAppSystemGroup_Create = 0
};
ePluginHelp m_nHelpID;
ePluginCallback m_nCallbackID;
const char* m_pszName;
void* m_pFunction;
};
class CServer;
class CClient;
struct user_creds_s;
template<typename T>
class CPluginCallbackList
@ -123,6 +106,7 @@ public:
#define CREATE_PLUGIN_CALLBACK(typeName, type, funcName, varName) public: using typeName = type; CPluginCallbackList<typeName>& funcName() { return varName; } private: CPluginCallbackList<typeName> varName;
CREATE_PLUGIN_CALLBACK(CreateFn, bool(*)(CModAppSystemGroup*), GetCreateCallbacks, createCallbacks);
CREATE_PLUGIN_CALLBACK(ConnectClientFn, bool(*)(CServer*, CClient*, user_creds_s*), GetConnectClientCallbacks, connectClientCallbacks);
#undef CREATE_PLUGIN_CALLBACK