summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mode.h9
-rw-r--r--src/inspircd.cpp2
-rw-r--r--src/mode.cpp72
-rw-r--r--src/modules/m_banexception.cpp1
-rw-r--r--src/modules/m_blockcaps.cpp1
-rw-r--r--src/modules/m_blockcolor.cpp1
-rw-r--r--src/modules/m_censor.cpp1
-rw-r--r--src/modules/m_chanfilter.cpp1
-rw-r--r--src/modules/m_chanprotect.cpp1
-rw-r--r--src/modules/m_inviteexception.cpp1
-rw-r--r--src/modules/m_joinflood.cpp1
-rw-r--r--src/modules/m_kicknorejoin.cpp1
-rw-r--r--src/modules/m_knock.cpp1
-rw-r--r--src/modules/m_messageflood.cpp1
-rw-r--r--src/modules/m_noctcp.cpp1
-rw-r--r--src/modules/m_noinvite.cpp1
-rw-r--r--src/modules/m_nokicks.cpp1
-rw-r--r--src/modules/m_nonicks.cpp1
-rw-r--r--src/modules/m_nonotice.cpp1
-rw-r--r--src/modules/m_operchans.cpp1
-rw-r--r--src/modules/m_redirect.cpp1
-rw-r--r--src/modules/m_services.cpp1
-rw-r--r--src/modules/m_services_account.cpp1
-rw-r--r--src/modules/m_sslmodes.cpp1
-rw-r--r--src/modules/m_stripcolor.cpp1
25 files changed, 54 insertions, 51 deletions
diff --git a/include/mode.h b/include/mode.h
index 22109d0ac..b26c0d9c3 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -435,15 +435,16 @@ class ModeParser : public classbase
*/
std::string ParaModeList();
+ /** Generates the CHANMODES= 005 sequence
+ */
+ std::string ChanModes();
+ /** Used by this class internally during std::sort and 005 generation
+ */
static bool ModeParser::PrefixComparison(const prefixtype one, const prefixtype two);
/** This returns the PREFIX=(ohv)@%+ section of the 005 numeric.
*/
std::string BuildPrefixes();
-
- /** Used to parse the CHANMODES= parameter of a 005 numeric.
- */
- bool InsertMode(std::string &output, const char* mode, unsigned short section);
};
/** Command handler class for the MODE command.
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 4679c8acd..dd111f9ba 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -473,7 +473,7 @@ void InspIRCd::BuildISupport()
std::stringstream v;
v << "WALLCHOPS WALLVOICES MODES=" << MAXMODES << " CHANTYPES=# PREFIX=" << this->Modes->BuildPrefixes() << " MAP MAXCHANNELS=" << MAXCHANS << " MAXBANS=60 VBANLIST NICKLEN=" << NICKMAX-1;
v << " CASEMAPPING=rfc1459 STATUSMSG=@%+ CHARSET=ascii TOPICLEN=" << MAXTOPIC << " KICKLEN=" << MAXKICK << " MAXTARGETS=" << Config->MaxTargets << " AWAYLEN=";
- v << MAXAWAY << " CHANMODES=b,k,l,psmnti FNC NETWORK=" << Config->Network << " MAXPARA=32";
+ v << MAXAWAY << " CHANMODES=" << this->Modes->ChanModes() << " FNC NETWORK=" << Config->Network << " MAXPARA=32";
Config->data005 = v.str();
FOREACH_MOD_I(this,I_On005Numeric,On005Numeric(Config->data005));
}
diff --git a/src/mode.cpp b/src/mode.cpp
index c7d66cd46..dfda8a8b7 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -662,6 +662,54 @@ ModeHandler* ModeParser::FindPrefix(unsigned const char pfxletter)
return NULL;
}
+std::string ModeParser::ChanModes()
+{
+ std::string type1; /* Listmodes EXCEPT those with a prefix */
+ std::string type2; /* Modes that take a param when adding or removing */
+ std::string type3; /* Modes that only take a param when adding */
+ std::string type4; /* Modes that dont take a param */
+
+ for (unsigned char mode = 'A'; mode <= 'z'; mode++)
+ {
+ unsigned char pos = (mode-65) | MASK_CHANNEL;
+ /* One parameter when adding */
+ if (modehandlers[pos])
+ {
+ if (modehandlers[pos]->GetNumParams(true))
+ {
+ if ((modehandlers[pos]->IsListMode()) && (!modehandlers[pos]->GetPrefix()))
+ {
+ type1 += modehandlers[pos]->GetModeChar();
+ }
+ else
+ {
+ /* ... and one parameter when removing */
+ if (modehandlers[pos]->GetNumParams(false))
+ {
+ /* But not a list mode */
+ if (!modehandlers[pos]->GetPrefix())
+ {
+ type2 += modehandlers[pos]->GetModeChar();
+ }
+ }
+ else
+ {
+ /* No parameters when removing */
+ type3 += modehandlers[pos]->GetModeChar();
+ }
+ }
+ }
+ else
+ {
+ type4 += modehandlers[pos]->GetModeChar();
+ }
+ }
+
+ }
+
+ return type1 + "," + type2 + "," + type3 + "," + type4;
+}
+
bool ModeParser::PrefixComparison(const prefixtype one, const prefixtype two)
{
return one.second > two.second;
@@ -775,27 +823,3 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance)
this->AddMode(new ModeUserServerNoticeMask(Instance), 'n');
}
-bool ModeParser::InsertMode(std::string &output, const char* mode, unsigned short section)
-{
- unsigned short currsection = 1;
- unsigned int pos = output.find("CHANMODES=", 0) + 10; // +10 for the length of "CHANMODES="
-
- if(section > 4 || section == 0)
- {
- ServerInstance->Log(DEBUG, "InsertMode: CHANMODES doesn't have a section %dh :/", section);
- return false;
- }
-
- for(; pos < output.size(); pos++)
- {
- if(section == currsection)
- break;
-
- if(output[pos] == ',')
- currsection++;
- }
-
- output.insert(pos, mode);
- return true;
-}
-
diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp
index 82939231f..5f2f6f92a 100644
--- a/src/modules/m_banexception.cpp
+++ b/src/modules/m_banexception.cpp
@@ -49,7 +49,6 @@ public:
virtual void On005Numeric(std::string &output)
{
output.append(" EXCEPTS=e");
- ServerInstance->Modes->InsertMode(output, "e", 1);
}
virtual int OnCheckBan(userrec* user, chanrec* chan)
diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp
index b105e1dc5..a5a2ae5ff 100644
--- a/src/modules/m_blockcaps.cpp
+++ b/src/modules/m_blockcaps.cpp
@@ -74,7 +74,6 @@ public:
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output, "P", 4);
}
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp
index 978c72e52..2c73da3fc 100644
--- a/src/modules/m_blockcolor.cpp
+++ b/src/modules/m_blockcolor.cpp
@@ -76,7 +76,6 @@ class ModuleBlockColour : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output,"c",4);
}
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp
index a1aba037d..bbf148657 100644
--- a/src/modules/m_censor.cpp
+++ b/src/modules/m_censor.cpp
@@ -139,7 +139,6 @@ class ModuleCensor : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output,"G",4);
}
virtual ~ModuleCensor()
diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp
index 693b1788d..52ba5c0a0 100644
--- a/src/modules/m_chanfilter.cpp
+++ b/src/modules/m_chanfilter.cpp
@@ -86,7 +86,6 @@ class ModuleChanFilter : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output,"g",1);
}
virtual void OnChannelDelete(chanrec* chan)
diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp
index 981f14f2e..832798b1f 100644
--- a/src/modules/m_chanprotect.cpp
+++ b/src/modules/m_chanprotect.cpp
@@ -273,7 +273,6 @@ class ModuleChanProtect : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output,"qa",1);
}
virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason)
diff --git a/src/modules/m_inviteexception.cpp b/src/modules/m_inviteexception.cpp
index ba582555d..234f7bfbc 100644
--- a/src/modules/m_inviteexception.cpp
+++ b/src/modules/m_inviteexception.cpp
@@ -48,7 +48,6 @@ public:
virtual void On005Numeric(std::string &output)
{
output.append(" INVEX=I");
- ServerInstance->Modes->InsertMode(output, "I", 1);
}
virtual int OnCheckInvite(userrec* user, chanrec* chan)
diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp
index 7f12d5cce..7fc978e4c 100644
--- a/src/modules/m_joinflood.cpp
+++ b/src/modules/m_joinflood.cpp
@@ -245,7 +245,6 @@ class ModuleJoinFlood : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output, "j", 3);
}
virtual ~ModuleJoinFlood()
diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp
index 35aecc894..353d62ead 100644
--- a/src/modules/m_kicknorejoin.cpp
+++ b/src/modules/m_kicknorejoin.cpp
@@ -168,7 +168,6 @@ public:
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output, "J", 3);
}
virtual ~ModuleKickNoRejoin()
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index 092ce999f..de9010f89 100644
--- a/src/modules/m_knock.cpp
+++ b/src/modules/m_knock.cpp
@@ -125,7 +125,6 @@ class ModuleKnock : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output,"K",4);
}
virtual ~ModuleKnock()
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index 5a4f03340..dc2513f3d 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -265,7 +265,6 @@ class ModuleMsgFlood : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output, "f", 3);
}
virtual ~ModuleMsgFlood()
diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp
index 885f2dd54..008fdae5e 100644
--- a/src/modules/m_noctcp.cpp
+++ b/src/modules/m_noctcp.cpp
@@ -77,7 +77,6 @@ class ModuleNoCTCP : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output,"C",4);
}
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
diff --git a/src/modules/m_noinvite.cpp b/src/modules/m_noinvite.cpp
index 9e4d37ff1..158dec8b2 100644
--- a/src/modules/m_noinvite.cpp
+++ b/src/modules/m_noinvite.cpp
@@ -76,7 +76,6 @@ class ModuleNoInvite : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output,"V",4);
}
diff --git a/src/modules/m_nokicks.cpp b/src/modules/m_nokicks.cpp
index abf4f8034..5936d4ccd 100644
--- a/src/modules/m_nokicks.cpp
+++ b/src/modules/m_nokicks.cpp
@@ -77,7 +77,6 @@ class ModuleNoKicks : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output,"Q",4);
}
virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type)
diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp
index 9d2a3d9eb..c3caf576a 100644
--- a/src/modules/m_nonicks.cpp
+++ b/src/modules/m_nonicks.cpp
@@ -89,7 +89,6 @@ class ModuleNoNickChange : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output,"N",4);
}
virtual int OnUserPreNick(userrec* user, const std::string &newnick)
diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp
index c6de6dbdf..978353229 100644
--- a/src/modules/m_nonotice.cpp
+++ b/src/modules/m_nonotice.cpp
@@ -98,7 +98,6 @@ class ModuleNoNotice : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output,"T",4);
}
virtual ~ModuleNoNotice()
diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp
index 2bb1299c9..c4c95bcdc 100644
--- a/src/modules/m_operchans.cpp
+++ b/src/modules/m_operchans.cpp
@@ -76,7 +76,6 @@ class ModuleOperChans : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output,"O",4);
}
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp
index efe780989..34961e013 100644
--- a/src/modules/m_redirect.cpp
+++ b/src/modules/m_redirect.cpp
@@ -125,7 +125,6 @@ class ModuleRedirect : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output, "L", 3);
}
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
diff --git a/src/modules/m_services.cpp b/src/modules/m_services.cpp
index 0a7e3adff..aad54ffa2 100644
--- a/src/modules/m_services.cpp
+++ b/src/modules/m_services.cpp
@@ -191,7 +191,6 @@ class ModuleServices : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output, "rRM", 4);
}
/* <- :stitch.chatspike.net 307 w00t w00t :is a registered nick */
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index 5ddbbb979..aff73dde5 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -133,7 +133,6 @@ class ModuleServicesAccount : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output, "RM", 4);
}
/* <- :twisted.oscnet.org 330 w00t2 w00t2 w00t :is logged in as */
diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp
index 9cc3f2872..7e26de8c2 100644
--- a/src/modules/m_sslmodes.cpp
+++ b/src/modules/m_sslmodes.cpp
@@ -76,7 +76,6 @@ class ModuleSSLModes : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output, "z", 4);
}
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp
index 293b5ee13..d3372d848 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -120,7 +120,6 @@ class ModuleStripColor : public Module
virtual void On005Numeric(std::string &output)
{
- ServerInstance->Modes->InsertMode(output,"S",4);
}
virtual ~ModuleStripColor()