Merge PluginSystem_Reload and PluginSystem_Init together

This commit is contained in:
Marvin D 2022-08-20 11:42:22 +02:00
parent 0a8a463245
commit cebc6a13b6
2 changed files with 6 additions and 24 deletions

View File

@ -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::PluginInstance>& CPluginSystem::GetPluginInstances()
{
return pluginInstances;
}
}
CPluginSystem* g_pPluginSystem = new CPluginSystem();

View File

@ -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<PluginInstance> pluginInstances;
};
extern CPluginSystem* g_pPluginSystem;