From c29324b5dcbf2fca996f841edc3404d5997ad18e Mon Sep 17 00:00:00 2001 From: rexx <67599507+r-ex@users.noreply.github.com> Date: Mon, 8 May 2023 19:12:52 +0100 Subject: [PATCH] rewrite PluginSystem_Init to use source filesystem --- r5dev/launcher/IApplication.cpp | 2 ++ r5dev/pluginsystem/pluginsystem.cpp | 41 +++++++++++++---------------- r5dev/vpc/interfaces.h | 1 + 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/r5dev/launcher/IApplication.cpp b/r5dev/launcher/IApplication.cpp index 5e0ee254..2f09e3e7 100644 --- a/r5dev/launcher/IApplication.cpp +++ b/r5dev/launcher/IApplication.cpp @@ -33,6 +33,7 @@ #include "windows/input.h" #endif // !DEDICATED #include "public/idebugoverlay.h" +#include //----------------------------------------------------------------------------- // Purpose: @@ -103,6 +104,7 @@ bool CModAppSystemGroup::StaticCreate(CModAppSystemGroup* pModAppSystemGroup) g_pFactory->GetFactoriesFromRegister(); g_pFactory->AddFactory(FACTORY_INTERFACE_VERSION, g_pFactory); g_pFactory->AddFactory(INTERFACEVERSION_PLUGINSYSTEM, g_pPluginSystem); + g_pFactory->AddFactory(KEYVALUESSYSTEM_INTERFACE_VERSION, g_pKeyValuesSystem); //InitPluginSystem(pModAppSystemGroup); //CALL_PLUGIN_CALLBACKS(g_pPluginSystem->GetCreateCallbacks(), pModAppSystemGroup); diff --git a/r5dev/pluginsystem/pluginsystem.cpp b/r5dev/pluginsystem/pluginsystem.cpp index 63c91773..d569ffe9 100644 --- a/r5dev/pluginsystem/pluginsystem.cpp +++ b/r5dev/pluginsystem/pluginsystem.cpp @@ -8,6 +8,8 @@ #include "core/stdafx.h" #include "pluginsystem.h" +#include +#include //----------------------------------------------------------------------------- // Purpose: initialize the plugin system @@ -15,33 +17,26 @@ //----------------------------------------------------------------------------- void CPluginSystem::PluginSystem_Init() { - const fs::path path("bin\\x64_retail\\plugins\\"); - const string pathString(path.u8string()); + FileSystem()->CreateDirHierarchy("bin\\x64_retail\\plugins"); - CreateDirectories(pathString); - if (fs::is_directory(path)) + CUtlVector< CUtlString > pluginPaths; + AddFilesToList(pluginPaths, "bin\\x64_retail\\plugins", NULL, "dll"); + + for (int i = 0; i < pluginPaths.Count(); ++i) { - for (auto& it : fs::directory_iterator(path)) + CUtlString& path = pluginPaths[i]; + + bool addInstance = true; + for (auto& inst : pluginInstances) { - if (!fs::is_regular_file(it)) - continue; - - if (auto path = it.path(); - path.has_filename() && - path.has_extension() && - path.extension().compare(".dll") == 0) - { - bool addInstance = true; - for (auto& inst : pluginInstances) - { - if (inst.m_svPluginFullPath.compare(pathString) == 0) - addInstance = false; - } - - if (addInstance) - pluginInstances.push_back(PluginInstance_t(path.filename().u8string(), pathString)); - } + if (inst.m_svPluginFullPath.compare(path.Get()) == 0) + addInstance = false; } + + const char* baseFileName = V_UnqualifiedFileName(path.Get()); + + if (addInstance) + pluginInstances.push_back(PluginInstance_t(baseFileName, path.Get())); } } diff --git a/r5dev/vpc/interfaces.h b/r5dev/vpc/interfaces.h index 4c177111..a6092af2 100644 --- a/r5dev/vpc/interfaces.h +++ b/r5dev/vpc/interfaces.h @@ -41,6 +41,7 @@ #define FACTORY_INTERFACE_VERSION "VFactorySystem001" #define FILESYSTEM_INTERFACE_VERSION "VFileSystem017" #define BASEFILESYSTEM_INTERFACE_VERSION "VBaseFileSystem011" +#define KEYVALUESSYSTEM_INTERFACE_VERSION "VKeyValuesSystem001" //----------------------------------------------------------------------------- // Class to hold all factories (interfaces)