diff --git a/r5dev/engine/server/server.cpp b/r5dev/engine/server/server.cpp index a41f3a19..52f4777c 100644 --- a/r5dev/engine/server/server.cpp +++ b/r5dev/engine/server/server.cpp @@ -17,6 +17,7 @@ #include "networksystem/bansystem.h" #include "ebisusdk/EbisuSDK.h" #include "public/edict.h" +#include //--------------------------------------------------------------------------------- // 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; } diff --git a/r5dev/launcher/IApplication.cpp b/r5dev/launcher/IApplication.cpp index a8d0c3b3..cedb6e02 100644 --- a/r5dev/launcher/IApplication.cpp +++ b/r5dev/launcher/IApplication.cpp @@ -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(); #ifndef CLIENT_DLL diff --git a/r5dev/pluginsystem/ipluginsystem.h b/r5dev/pluginsystem/ipluginsystem.h index 13c7a5dd..1f68da72 100644 --- a/r5dev/pluginsystem/ipluginsystem.h +++ b/r5dev/pluginsystem/ipluginsystem.h @@ -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 { diff --git a/r5dev/pluginsystem/pluginsystem.cpp b/r5dev/pluginsystem/pluginsystem.cpp index 79c414b6..0b4e71ec 100644 --- a/r5dev/pluginsystem/pluginsystem.cpp +++ b/r5dev/pluginsystem/pluginsystem.cpp @@ -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; } diff --git a/r5dev/pluginsystem/pluginsystem.h b/r5dev/pluginsystem/pluginsystem.h index eb39f745..38bb5f1b 100644 --- a/r5dev/pluginsystem/pluginsystem.h +++ b/r5dev/pluginsystem/pluginsystem.h @@ -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 class CPluginCallbackList @@ -123,6 +106,7 @@ public: #define CREATE_PLUGIN_CALLBACK(typeName, type, funcName, varName) public: using typeName = type; CPluginCallbackList& funcName() { return varName; } private: CPluginCallbackList 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