mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
rewrite PluginSystem_Init to use source filesystem
This commit is contained in:
parent
fc16e61deb
commit
c29324b5dc
@ -33,6 +33,7 @@
|
||||
#include "windows/input.h"
|
||||
#endif // !DEDICATED
|
||||
#include "public/idebugoverlay.h"
|
||||
#include <vstdlib/keyvaluessystem.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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);
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#include "core/stdafx.h"
|
||||
#include "pluginsystem.h"
|
||||
#include <filesystem/filesystem.h>
|
||||
#include <tier2/fileutils.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user