Skip to content

Commit 05b7d8d

Browse files
authored
Merge branch 'main' into refactor/mod-information-file-export
2 parents ebaba26 + f98f6b9 commit 05b7d8d

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

primedev/plugins/pluginmanager.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "pluginmanager.h"
22

33
#include <regex>
4+
#include <ranges>
45
#include "plugins.h"
56
#include "config/profile.h"
67
#include "core/convar/concommand.h"
@@ -111,13 +112,14 @@ bool PluginManager::LoadPlugins(bool reloaded)
111112

112113
void PluginManager::ReloadPlugins()
113114
{
114-
for (const Plugin& plugin : this->GetLoadedPlugins())
115+
NS::log::PLUGINSYS->info("Reloading plugins");
116+
117+
for (const Plugin& plugin : this->plugins | std::views::reverse)
115118
{
116-
plugin.Unload();
119+
std::string name = plugin.GetName();
120+
if (plugin.Reload())
121+
NS::log::PLUGINSYS->info("Reloaded {}", name);
117122
}
118-
119-
this->plugins.clear();
120-
this->LoadPlugins(true);
121123
}
122124

123125
void PluginManager::RemovePlugin(HMODULE handle)

primedev/plugins/plugins.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ bool Plugin::Unload() const
138138

139139
if (IsValid())
140140
{
141-
bool unloaded = m_callbacks->Unload();
141+
bool shouldUnload = m_callbacks->Unload();
142142

143-
if (!unloaded)
143+
if (!shouldUnload)
144144
return false;
145145
}
146146

@@ -154,14 +154,18 @@ bool Plugin::Unload() const
154154
return true;
155155
}
156156

157-
void Plugin::Reload() const
157+
bool Plugin::Reload() const
158158
{
159+
std::string location = m_location;
160+
159161
bool unloaded = Unload();
160162

161163
if (!unloaded)
162-
return;
164+
return false;
163165

164-
g_pPluginManager->LoadPlugin(fs::path(m_location), true);
166+
g_pPluginManager->LoadPlugin(fs::path(location), true);
167+
168+
return true;
165169
}
166170

167171
void Plugin::Log(spdlog::level::level_enum level, char* msg) const

primedev/plugins/plugins.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Plugin
2828

2929
Plugin(std::string path);
3030
bool Unload() const;
31-
void Reload() const;
31+
bool Reload() const;
3232

3333
// sys
3434
void Log(spdlog::level::level_enum level, char* msg) const;

0 commit comments

Comments
 (0)