diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-11-04 16:50:50 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-11-04 16:50:50 +0000 |
commit | 9b131bef322a4ed592d53e8c8eec8759287944a5 (patch) | |
tree | d00bedc6e1211c98571a865910ddca4529bc8479 | |
parent | f6bd92ab87208b104baba2eaa99236d0b03d8552 (diff) |
More craq
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8507 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/modules.h | 2 | ||||
-rw-r--r-- | src/modules.cpp | 13 | ||||
-rw-r--r-- | src/modules/m_hostchange.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_securelist.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 2 | ||||
-rw-r--r-- | src/modules/m_uhnames.cpp | 5 |
7 files changed, 26 insertions, 10 deletions
diff --git a/include/modules.h b/include/modules.h index 27fec9010..a42292ad1 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1589,6 +1589,8 @@ class CoreExport ModuleManager : public classbase bool SetPriority(Module* mod, Implementation i, PriorityState s, Module** modules = NULL, size_t sz = 1); + bool SetPriority(Module* mod, PriorityState s); + /** Attach an event to a module * @param i Event type to attach * @param mod Module to attach event to diff --git a/src/modules.cpp b/src/modules.cpp index ae6767765..3a916e8a6 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -231,21 +231,32 @@ void ModuleManager::DetachAll(Module* mod) Detach((Implementation)n, mod); } +bool ModuleManager::SetPriority(Module* mod, PriorityState s) +{ + for (size_t n = I_BEGIN + 1; n != I_END; ++n) + SetPriority(mod, (Implementation)n, s); +} + bool ModuleManager::SetPriority(Module* mod, Implementation i, PriorityState s, Module** modules, size_t sz) { size_t swap_pos; - size_t source; + size_t source = 0; bool swap = true; + bool found = false; for (size_t x = 0; x != EventHandlers[i].size(); ++x) { if (EventHandlers[i][x] == mod) { source = x; + found = true; break; } } + if (!found) + return false; + switch (s) { case PRIO_DONTCARE: diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp index 17c597e71..222d68dca 100644 --- a/src/modules/m_hostchange.cpp +++ b/src/modules/m_hostchange.cpp @@ -52,9 +52,10 @@ class ModuleHostChange : public Module hostchanges.clear(); } - Priority Prioritize() + void Prioritize() { - return (Priority)ServerInstance->Modules->PriorityAfter("m_cloaking.so"); + Module* cloak = ServerInstance->Modules->Find("m_cloaking.so"); + ServerInstance->Modules->SetPriority(this, I_OnUserConnect, PRIO_AFTER, &cloak); } void Implements(char* List) diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index 30b339630..01c8cb826 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -86,9 +86,10 @@ class ModuleSecureList : public Module output.append(" SECURELIST"); } - virtual Priority Prioritize() + void Prioritize() { - return (Priority)ServerInstance->Modules->PriorityBefore("m_safelist.so"); + Module* safelist = ServerInstance->Modules->Find("m_safelist.so"); + ServerInstance->Modules->SetPriority(this, I_OnPreCommand, PRIO_BEFORE, &safelist); } }; diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 9497d25d0..1fc2968b4 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -1007,9 +1007,9 @@ void ModuleSpanningTree::Implements(char* List) * Therefore, we return PRIORITY_LAST to make sure we end up at the END of * the module call queue. */ -Priority ModuleSpanningTree::Prioritize() +void ModuleSpanningTree::Prioritize() { - return PRIORITY_LAST; + ServerInstance->Modules->SetPriority(this, PRIO_LAST); } MODULE_INIT(ModuleSpanningTree) diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 77b4d52ed..7374dd000 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -190,7 +190,7 @@ class ModuleSpanningTree : public Module virtual ~ModuleSpanningTree(); virtual Version GetVersion(); void Implements(char* List); - Priority Prioritize(); + void Prioritize(); }; #endif diff --git a/src/modules/m_uhnames.cpp b/src/modules/m_uhnames.cpp index 830be12e8..574f90741 100644 --- a/src/modules/m_uhnames.cpp +++ b/src/modules/m_uhnames.cpp @@ -52,9 +52,10 @@ class ModuleUHNames : public Module output.append(" UHNAMES"); } - Priority Prioritize() + void Prioritize() { - return (Priority)ServerInstance->Modules->PriorityBefore("m_namesx.so"); + Module* namesx = ServerInstance->Modules->Find("m_namesx.so"); + ServerInstance->Modules->SetPriority(this, I_OnUserList, PRIO_BEFORE, &namesx); } virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, User *user, bool validated, const std::string &original_line) |