summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mode.cpp45
-rw-r--r--src/users.cpp6
2 files changed, 12 insertions, 39 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index 3da983627..b4bb72c42 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -613,6 +613,7 @@ bool ModeParser::AddMode(ModeHandler* mh)
return false;
modehandlers[pos] = mh;
+ RecreateModeListFor004Numeric();
return true;
}
@@ -655,6 +656,7 @@ bool ModeParser::DelMode(ModeHandler* mh)
}
modehandlers[pos] = NULL;
+ RecreateModeListFor004Numeric();
return true;
}
@@ -673,52 +675,25 @@ ModeHandler* ModeParser::FindMode(unsigned const char modeletter, ModeType mt)
return modehandlers[pos];
}
-std::string ModeParser::UserModeList()
+std::string ModeParser::CreateModeList(ModeType mt, bool needparam)
{
- char modestr[256];
- int pointer = 0;
+ std::string modestr;
+ unsigned char mask = ((mt == MODETYPE_CHANNEL) ? MASK_CHANNEL : MASK_USER);
for (unsigned char mode = 'A'; mode <= 'z'; mode++)
{
- unsigned char pos = (mode-65) | MASK_USER;
+ unsigned char pos = (mode-65) | mask;
- if (modehandlers[pos])
- modestr[pointer++] = mode;
+ if ((modehandlers[pos]) && ((!needparam) || (modehandlers[pos]->GetNumParams(true))))
+ modestr.push_back(mode);
}
- modestr[pointer++] = 0;
- return modestr;
-}
-
-std::string ModeParser::ChannelModeList()
-{
- char modestr[256];
- int pointer = 0;
-
- for (unsigned char mode = 'A'; mode <= 'z'; mode++)
- {
- unsigned char pos = (mode-65) | MASK_CHANNEL;
- if (modehandlers[pos])
- modestr[pointer++] = mode;
- }
- modestr[pointer++] = 0;
return modestr;
}
-std::string ModeParser::ParaModeList()
+void ModeParser::RecreateModeListFor004Numeric()
{
- char modestr[256];
- int pointer = 0;
-
- for (unsigned char mode = 'A'; mode <= 'z'; mode++)
- {
- unsigned char pos = (mode-65) | MASK_CHANNEL;
-
- if ((modehandlers[pos]) && (modehandlers[pos]->GetNumParams(true)))
- modestr[pointer++] = mode;
- }
- modestr[pointer++] = 0;
- return modestr;
+ Cached004ModeList = CreateModeList(MODETYPE_USER) + " " + CreateModeList(MODETYPE_CHANNEL) + " " + CreateModeList(MODETYPE_CHANNEL, true);
}
ModeHandler* ModeParser::FindPrefix(unsigned const char pfxletter)
diff --git a/src/users.cpp b/src/users.cpp
index 7e1df61fe..49c5c5e42 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -731,10 +731,8 @@ void LocalUser::FullConnect()
this->WriteNumeric(RPL_YOURHOSTIS, "%s :Your host is %s, running version %s",this->nick.c_str(),ServerInstance->Config->ServerName.c_str(),BRANCH);
this->WriteNumeric(RPL_SERVERCREATED, "%s :This server was created %s %s", this->nick.c_str(), __TIME__, __DATE__);
- std::string umlist = ServerInstance->Modes->UserModeList();
- std::string cmlist = ServerInstance->Modes->ChannelModeList();
- std::string pmlist = ServerInstance->Modes->ParaModeList();
- this->WriteNumeric(RPL_SERVERVERSION, "%s %s %s %s %s %s", this->nick.c_str(), ServerInstance->Config->ServerName.c_str(), BRANCH, umlist.c_str(), cmlist.c_str(), pmlist.c_str());
+ const std::string& modelist = ServerInstance->Modes->GetModeListFor004Numeric();
+ this->WriteNumeric(RPL_SERVERVERSION, "%s %s %s %s", this->nick.c_str(), ServerInstance->Config->ServerName.c_str(), BRANCH, modelist.c_str());
ServerInstance->ISupport.SendTo(this);
this->WriteNumeric(RPL_YOURUUID, "%s %s :your unique ID", this->nick.c_str(), this->uuid.c_str());