diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-02-12 16:35:02 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-02-12 16:35:02 +0100 |
commit | ae6967b8b30ebc956e3158127ecba5d01dc09204 (patch) | |
tree | b0940ea9cbd75acfdaa655b3a9975f67e3f8ae48 /src/modules.cpp | |
parent | a7aa76f17ac22897e08558f0f78d891d3d4f7de6 (diff) | |
parent | 7918febc630d7d6f94fda1a918fe7b98c2d0e742 (diff) |
Merge branch 'master+crossmodevents'
Diffstat (limited to 'src/modules.cpp')
-rw-r--r-- | src/modules.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/modules.cpp b/src/modules.cpp index d7aa534ab..1c33785b0 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -52,13 +52,6 @@ Version::Version(const std::string &desc, int flags, const std::string& linkdata { } -Event::Event(Module* src, const std::string &eventid) : source(src), id(eventid) { } - -void Event::Send() -{ - FOREACH_MOD(OnEvent, (*this)); -} - // These declarations define the behavours of the base class Module (which does nothing at all) Module::Module() { } @@ -119,7 +112,6 @@ ModResult Module::OnStats(char, User*, string_list&) { DetachEvent(I_OnStats); r ModResult Module::OnChangeLocalUserHost(LocalUser*, const std::string&) { DetachEvent(I_OnChangeLocalUserHost); return MOD_RES_PASSTHRU; } ModResult Module::OnChangeLocalUserGECOS(LocalUser*, const std::string&) { DetachEvent(I_OnChangeLocalUserGECOS); return MOD_RES_PASSTHRU; } ModResult Module::OnPreTopicChange(User*, Channel*, const std::string&) { DetachEvent(I_OnPreTopicChange); return MOD_RES_PASSTHRU; } -void Module::OnEvent(Event&) { DetachEvent(I_OnEvent); } ModResult Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { DetachEvent(I_OnPassCompare); return MOD_RES_PASSTHRU; } void Module::OnPostConnect(User*) { DetachEvent(I_OnPostConnect); } void Module::OnUserMessage(User*, void*, int, const std::string&, char, const CUList&, MessageType) { DetachEvent(I_OnUserMessage); } @@ -655,7 +647,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>; @@ -684,9 +676,19 @@ void dynamic_reference_base::SetProvider(const std::string& newname) void dynamic_reference_base::resolve() { - std::multimap<std::string, ServiceProvider*>::iterator i = ServerInstance->Modules->DataProviders.find(name); - if (i != ServerInstance->Modules->DataProviders.end()) - value = static_cast<DataProvider*>(i->second); + // Because find() may return any element with a matching key in case count(key) > 1 use lower_bound() + // 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)) + { + ServiceProvider* newvalue = i->second; + if (value != newvalue) + { + value = newvalue; + if (hook) + hook->OnCapture(); + } + } else value = NULL; } |