summaryrefslogtreecommitdiff
path: root/src/modmanager_static.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modmanager_static.cpp')
-rw-r--r--src/modmanager_static.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/modmanager_static.cpp b/src/modmanager_static.cpp
index e267a2c90..d9ee07a25 100644
--- a/src/modmanager_static.cpp
+++ b/src/modmanager_static.cpp
@@ -85,12 +85,19 @@ bool ModuleManager::Load(const char* name)
return false;
}
-bool ModuleManager::Unload(Module* mod)
-{
- return false;
-}
-
namespace {
+ struct UnloadAction : public HandlerBase0<void>
+ {
+ Module* const mod;
+ UnloadAction(Module* m) : mod(m) {}
+ void Call()
+ {
+ ServerInstance->Modules->DoSafeUnload(mod);
+ ServerInstance->GlobalCulls.Apply();
+ ServerInstance->GlobalCulls.AddItem(this);
+ }
+ };
+
struct ReloadAction : public HandlerBase0<void>
{
Module* const mod;
@@ -109,6 +116,14 @@ namespace {
};
}
+bool ModuleManager::Unload(Module* mod)
+{
+ if (!CanUnload(mod))
+ return false;
+ ServerInstance->AtomicActions.AddAction(new UnloadAction(mod));
+ return true;
+}
+
void ModuleManager::Reload(Module* mod, HandlerBase1<void, bool>* callback)
{
if (CanUnload(mod))
@@ -127,6 +142,7 @@ void ModuleManager::LoadAll()
{
c = (*(**i).init)();
c->ModuleSourceFile = (**i).name;
+ c->ModuleDLLManager = NULL;
Modules[(**i).name] = c;
c->init();
FOREACH_MOD(I_OnLoadModule,OnLoadModule(c));