summaryrefslogtreecommitdiff
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-01-25 16:31:05 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-01-25 16:31:05 +0000
commitcdaf7ac3781a0ea1bfbfac85c4a428ddea7725f9 (patch)
tree84758aa082957cf9c19fa59df9b55d06e33fb9dd /src/inspircd.cpp
parent51fff2f99dc4692cfbb14eda789d615280d79365 (diff)
Added PRIORITY_BEFORE and PRIORITY_AFTER (see src/modules/m_hostchange.cpp for how it works, function Prioritize())
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2889 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index ac94b6f90..6b43ab921 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -329,6 +329,40 @@ void InspIRCd::MoveTo(std::string modulename,int slot)
}
}
+void InspIRCd::MoveAfter(std::string modulename, std::string after)
+{
+ log(DEBUG,"Move %s after %s...",modulename.c_str(),after.c_str());
+ for (unsigned int v = 0; v < Config->module_names.size(); v++)
+ {
+ log(DEBUG,"Curr=%s after=%s v=%d",Config->module_names[v].c_str(),after.c_str(),v);
+ if (Config->module_names[v] == after)
+ {
+ MoveTo(modulename, v);
+ return;
+ }
+ }
+}
+
+void InspIRCd::MoveBefore(std::string modulename, std::string before)
+{
+ log(DEBUG,"Move %s before %s...",modulename.c_str(),before.c_str());
+ for (unsigned int v = 0; v < Config->module_names.size(); v++)
+ {
+ if (Config->module_names[v] == before)
+ {
+ if (v > 0)
+ {
+ MoveTo(modulename, v-1);
+ }
+ else
+ {
+ MoveTo(modulename, v);
+ }
+ return;
+ }
+ }
+}
+
void InspIRCd::MoveToFirst(std::string modulename)
{
MoveTo(modulename,0);
@@ -492,6 +526,8 @@ bool InspIRCd::LoadModule(const char* filename)
// and if they do, move them there.
std::vector<std::string> put_to_back;
std::vector<std::string> put_to_front;
+ std::map<std::string,std::string> put_before;
+ std::map<std::string,std::string> put_after;
for (unsigned int j = 0; j < Config->module_names.size(); j++)
{
if (modules[j]->Prioritize() == PRIORITY_LAST)
@@ -502,6 +538,18 @@ bool InspIRCd::LoadModule(const char* filename)
{
put_to_front.push_back(Config->module_names[j]);
}
+ else if ((modules[j]->Prioritize() & 0xFF) == PRIORITY_BEFORE)
+ {
+ log(DEBUG,"Module %d wants PRIORITY_BEFORE",j);
+ put_before[Config->module_names[j]] = Config->module_names[modules[j]->Prioritize() >> 8];
+ log(DEBUG,"Before: %s",Config->module_names[modules[j]->Prioritize() >> 8].c_str());
+ }
+ else if ((modules[j]->Prioritize() & 0xFF) == PRIORITY_AFTER)
+ {
+ log(DEBUG,"Module %d wants PRIORITY_AFTER",j);
+ put_after[Config->module_names[j]] = Config->module_names[modules[j]->Prioritize() >> 8];
+ log(DEBUG,"After: %s",Config->module_names[modules[j]->Prioritize() >> 8].c_str());
+ }
}
for (unsigned int j = 0; j < put_to_back.size(); j++)
{
@@ -511,6 +559,14 @@ bool InspIRCd::LoadModule(const char* filename)
{
MoveToFirst(put_to_front[j]);
}
+ for (std::map<std::string,std::string>::iterator j = put_before.begin(); j != put_before.end(); j++)
+ {
+ MoveBefore(j->first,j->second);
+ }
+ for (std::map<std::string,std::string>::iterator j = put_after.begin(); j != put_after.end(); j++)
+ {
+ MoveAfter(j->first,j->second);
+ }
BuildISupport();
return true;
}