File tree 3 files changed +17
-11
lines changed
3 files changed +17
-11
lines changed Original file line number Diff line number Diff line change 1
1
#include " pluginmanager.h"
2
2
3
3
#include < regex>
4
+ #include < ranges>
4
5
#include " plugins.h"
5
6
#include " config/profile.h"
6
7
#include " core/convar/concommand.h"
@@ -111,13 +112,14 @@ bool PluginManager::LoadPlugins(bool reloaded)
111
112
112
113
void PluginManager::ReloadPlugins ()
113
114
{
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)
115
118
{
116
- plugin.Unload ();
119
+ std::string name = plugin.GetName ();
120
+ if (plugin.Reload ())
121
+ NS::log ::PLUGINSYS->info (" Reloaded {}" , name);
117
122
}
118
-
119
- this ->plugins .clear ();
120
- this ->LoadPlugins (true );
121
123
}
122
124
123
125
void PluginManager::RemovePlugin (HMODULE handle)
Original file line number Diff line number Diff line change @@ -138,9 +138,9 @@ bool Plugin::Unload() const
138
138
139
139
if (IsValid ())
140
140
{
141
- bool unloaded = m_callbacks->Unload ();
141
+ bool shouldUnload = m_callbacks->Unload ();
142
142
143
- if (!unloaded )
143
+ if (!shouldUnload )
144
144
return false ;
145
145
}
146
146
@@ -154,14 +154,18 @@ bool Plugin::Unload() const
154
154
return true ;
155
155
}
156
156
157
- void Plugin::Reload () const
157
+ bool Plugin::Reload () const
158
158
{
159
+ std::string location = m_location;
160
+
159
161
bool unloaded = Unload ();
160
162
161
163
if (!unloaded)
162
- return ;
164
+ return false ;
163
165
164
- g_pPluginManager->LoadPlugin (fs::path (m_location), true );
166
+ g_pPluginManager->LoadPlugin (fs::path (location), true );
167
+
168
+ return true ;
165
169
}
166
170
167
171
void Plugin::Log (spdlog::level::level_enum level, char * msg) const
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ class Plugin
28
28
29
29
Plugin (std::string path);
30
30
bool Unload () const ;
31
- void Reload () const ;
31
+ bool Reload () const ;
32
32
33
33
// sys
34
34
void Log (spdlog::level::level_enum level, char * msg) const ;
You can’t perform that action at this time.
0 commit comments