From cebc6a13b6c0027148f8c66d63aac6738123d059 Mon Sep 17 00:00:00 2001 From: Marvin D <41352111+IcePixelx@users.noreply.github.com> Date: Sat, 20 Aug 2022 11:42:22 +0200 Subject: [PATCH] Merge PluginSystem_Reload and PluginSystem_Init together --- r5dev/pluginsystem/pluginsystem.cpp | 26 ++++---------------------- r5dev/pluginsystem/pluginsystem.h | 4 ++-- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/r5dev/pluginsystem/pluginsystem.cpp b/r5dev/pluginsystem/pluginsystem.cpp index f42c8dcd..1bde135c 100644 --- a/r5dev/pluginsystem/pluginsystem.cpp +++ b/r5dev/pluginsystem/pluginsystem.cpp @@ -15,27 +15,7 @@ //----------------------------------------------------------------------------- void CPluginSystem::PluginSystem_Init() { - CreateDirectories("bin\\x64_plugins\\."); - - for (auto& it : fs::directory_iterator("bin\\x64_plugins")) - { - if (!it.is_regular_file()) - continue; - - if (auto path = it.path(); path.has_filename() && path.has_extension() && path.extension().compare(".dll") == 0) - { - pluginInstances.push_back(PluginInstance(path.filename().u8string(), path.u8string())); - } - } -} - -//----------------------------------------------------------------------------- -// Purpose: reload the plugin system -// Input : -//----------------------------------------------------------------------------- -void CPluginSystem::PluginSystem_Reload() -{ - CreateDirectories("bin\\x64_plugins\\."); + CreateDirectories("bin\\x64_plugins\\"); for (auto& it : fs::directory_iterator("bin\\x64_plugins")) { @@ -131,4 +111,6 @@ bool CPluginSystem::ReloadPluginInstance(PluginInstance& pluginInst) vector& CPluginSystem::GetPluginInstances() { return pluginInstances; -} \ No newline at end of file +} + +CPluginSystem* g_pPluginSystem = new CPluginSystem(); \ No newline at end of file diff --git a/r5dev/pluginsystem/pluginsystem.h b/r5dev/pluginsystem/pluginsystem.h index ec9c3ad2..2da6212a 100644 --- a/r5dev/pluginsystem/pluginsystem.h +++ b/r5dev/pluginsystem/pluginsystem.h @@ -5,7 +5,7 @@ class CPluginSystem public: struct PluginInstance { - PluginInstance(string svPluginName, string svPluginFullPath) : m_svPluginName(svPluginName), m_svPluginFullPath(svPluginFullPath), m_svDescription(std::string()), m_nVersion(0), m_hModule(""), m_bIsLoaded(false) {}; + PluginInstance(string svPluginName, string svPluginFullPath) : m_svPluginName(svPluginName), m_svPluginFullPath(svPluginFullPath), m_svDescription(std::string()), m_nVersion(0), m_bIsLoaded(false) {}; // Might wanna make a status code system. typedef void(*OnLoad)(CModule, CModule); @@ -23,7 +23,6 @@ public: }; void PluginSystem_Init(); - void PluginSystem_Reload(); bool ReloadPluginInstance(PluginInstance& pluginInst); bool LoadPluginInstance(PluginInstance& pluginInst); bool UnloadPluginInstance(PluginInstance& pluginInst); @@ -32,3 +31,4 @@ public: private: vector pluginInstances; }; +extern CPluginSystem* g_pPluginSystem;