ModeParser::InsertMode is no longer required -- this is auto-generated by the ModeParser based on what modes are registered and wether or not they have certain attributes

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5007 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2006-08-23 22:34:58 +00:00
parent 932f1a6bc5
commit 3382adb9e9
25 changed files with 54 additions and 51 deletions

View File

@ -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.

View File

@ -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));
}

View File

@ -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;
}

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -139,7 +139,6 @@ class ModuleCensor : public Module
virtual void On005Numeric(std::string &output)
{
ServerInstance->Modes->InsertMode(output,"G",4);
}
virtual ~ModuleCensor()

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -245,7 +245,6 @@ class ModuleJoinFlood : public Module
virtual void On005Numeric(std::string &output)
{
ServerInstance->Modes->InsertMode(output, "j", 3);
}
virtual ~ModuleJoinFlood()

View File

@ -168,7 +168,6 @@ public:
virtual void On005Numeric(std::string &output)
{
ServerInstance->Modes->InsertMode(output, "J", 3);
}
virtual ~ModuleKickNoRejoin()

View File

@ -125,7 +125,6 @@ class ModuleKnock : public Module
virtual void On005Numeric(std::string &output)
{
ServerInstance->Modes->InsertMode(output,"K",4);
}
virtual ~ModuleKnock()

View File

@ -265,7 +265,6 @@ class ModuleMsgFlood : public Module
virtual void On005Numeric(std::string &output)
{
ServerInstance->Modes->InsertMode(output, "f", 3);
}
virtual ~ModuleMsgFlood()

View File

@ -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)

View File

@ -76,7 +76,6 @@ class ModuleNoInvite : public Module
virtual void On005Numeric(std::string &output)
{
ServerInstance->Modes->InsertMode(output,"V",4);
}

View File

@ -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)

View File

@ -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)

View File

@ -98,7 +98,6 @@ class ModuleNoNotice : public Module
virtual void On005Numeric(std::string &output)
{
ServerInstance->Modes->InsertMode(output,"T",4);
}
virtual ~ModuleNoNotice()

View File

@ -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)

View File

@ -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)

View File

@ -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 */

View File

@ -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 */

View File

@ -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)

View File

@ -120,7 +120,6 @@ class ModuleStripColor : public Module
virtual void On005Numeric(std::string &output)
{
ServerInstance->Modes->InsertMode(output,"S",4);
}
virtual ~ModuleStripColor()