]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/mode.cpp
Add <hostchange:ports> to the m_hostchange module to implement feature in bug #363
[user/henk/code/inspircd.git] / src / mode.cpp
index 874d8bef41be410222bf3807a239ce342885deb6..d04b7df975bdb69484544f2ccb8a8ece48d94103 100644 (file)
@@ -79,6 +79,7 @@ unsigned int ModeHandler::GetCount()
 void ModeHandler::ChangeCount(int modifier)
 {
        count += modifier;
+       ServerInstance->Log(DEBUG,"Change count for mode %c is now %d", mode, count);
 }
 
 ModeType ModeHandler::GetModeType()
@@ -280,7 +281,7 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
        chanrec* targetchannel = ServerInstance->FindChan(parameters[0]);
        userrec* targetuser  = ServerInstance->FindNick(parameters[0]);
 
-       LastParse = "";
+       LastParse.clear();
 
        /* Special case for displaying the list for listmodes,
         * e.g. MODE #chan b, or MODE #chan +b without a parameter
@@ -411,9 +412,9 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
                }
 
                std::string mode_sequence = parameters[1];
-               std::string parameter = "";
+               std::string parameter;
                std::ostringstream parameter_list;
-               std::string output_sequence = "";
+               std::string output_sequence;
                bool adding = true, state_change = false;
                unsigned char handler_id = 0;
                int parameter_counter = 2; /* Index of first parameter */
@@ -484,7 +485,7 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
 
                                                                        /* Yerk, invalid! */
                                                                        if ((parameter.find(':') == 0) || (parameter.rfind(' ') != std::string::npos))
-                                                                               parameter = "";
+                                                                               parameter.clear();
                                                                }
                                                                else
                                                                {
@@ -564,6 +565,8 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
                                                                /* Add the mode letter */
                                                                output_sequence.push_back(modechar);
 
+                                                               modehandlers[handler_id]->ChangeCount(adding ? 1 : -1);
+
                                                                /* Is there a valid parameter for this mode? If so add it to the parameter list */
                                                                if ((modehandlers[handler_id]->GetNumParams(adding)) && (!parameter.empty()))
                                                                {
@@ -691,7 +694,7 @@ bool ModeParser::AddMode(ModeHandler* mh, unsigned const char modeletter)
         * If they do that, thats their problem, and if i ever EVER see an
         * official InspIRCd developer do that, i'll beat them with a paddle!
         */
-       if ((mh->GetModeChar() < 'A') || (mh->GetModeChar() > 'z'))
+       if ((mh->GetModeChar() < 'A') || (mh->GetModeChar() > 'z') || (mh->GetPrefix() > 126))
                return false;
 
        /* A mode prefix of ',' is not acceptable, it would fuck up server to server.
@@ -783,6 +786,9 @@ std::string ModeParser::ChannelModeList()
 
        for (unsigned char mode = 'A'; mode <= 'z'; mode++)
        {
+               if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
+                       continue;
+
                unsigned char pos = (mode-65) | MASK_CHANNEL;
 
                if (modehandlers[pos])
@@ -799,6 +805,9 @@ std::string ModeParser::ParaModeList()
 
        for (unsigned char mode = 'A'; mode <= 'z'; mode++)
        {
+               if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
+                       continue;
+
                unsigned char pos = (mode-65) | MASK_CHANNEL;
 
                if ((modehandlers[pos]) && (modehandlers[pos]->GetNumParams(true)))
@@ -859,6 +868,9 @@ std::string ModeParser::ChanModes()
 
        for (unsigned char mode = 'A'; mode <= 'z'; mode++)
        {
+               if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
+                       continue;
+
                unsigned char pos = (mode-65) | MASK_CHANNEL;
                 /* One parameter when adding */
                if (modehandlers[pos])
@@ -905,13 +917,16 @@ bool ModeParser::PrefixComparison(prefixtype one, prefixtype two)
 
 std::string ModeParser::BuildPrefixes()
 {
-       std::string mletters = "";
-       std::string mprefixes = "";
+       std::string mletters;
+       std::string mprefixes;
        pfxcontainer pfx;
        std::map<char,char> prefix_to_mode;
 
        for (unsigned char mode = 'A'; mode <= 'z'; mode++)
        {
+               if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
+                       continue;
+
                unsigned char pos = (mode-65) | MASK_CHANNEL;
 
                if ((modehandlers[pos]) && (modehandlers[pos]->GetPrefix()))
@@ -1046,7 +1061,7 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance)
        memset(modewatchers, 0, sizeof(modewatchers));
 
        /* Last parse string */
-       LastParse = "";
+       LastParse.clear();
 
        /* Initialise the RFC mode letters */
        for (int index = 0; modes[index].modechar; index++)