diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-02-11 16:06:47 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-02-11 16:06:47 +0100 |
commit | e37add3fab8f39b18a69453ee1533e09e7f156de (patch) | |
tree | 967d8a7fbe98b63c5b7fda580a6cc8edeff1f88e /src | |
parent | eeb18ee6e3b1b07574a7f0fda2c0c20ac3f773df (diff) |
Allow dynrefs to have an OnCapture() hook
Diffstat (limited to 'src')
-rw-r--r-- | src/modules.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/modules.cpp b/src/modules.cpp index 6510c9423..55d41674b 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -655,7 +655,7 @@ ServiceProvider* ModuleManager::FindService(ServiceType type, const std::string& } dynamic_reference_base::dynamic_reference_base(Module* Creator, const std::string& Name) - : name(Name), value(NULL), creator(Creator) + : name(Name), hook(NULL), value(NULL), creator(Creator) { if (!dynrefs) dynrefs = new insp::intrusive_list<dynamic_reference_base>; @@ -688,7 +688,15 @@ void dynamic_reference_base::resolve() // to ensure a dynref with the same name as another one resolves to the same object std::multimap<std::string, ServiceProvider*>::iterator i = ServerInstance->Modules.DataProviders.lower_bound(name); if ((i != ServerInstance->Modules.DataProviders.end()) && (i->first == this->name)) - value = static_cast<DataProvider*>(i->second); + { + ServiceProvider* newvalue = i->second; + if (value != newvalue) + { + value = newvalue; + if (hook) + hook->OnCapture(); + } + } else value = NULL; } |