+void ISupportManager::Build()
+{
+ /**
+ * This is currently the neatest way we can build the initial ISUPPORT map. In
+ * the future we can use an initializer list here.
+ */
+ std::map<std::string, std::string> tokens;
+
+ tokens["AWAYLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxAway);
+ tokens["CASEMAPPING"] = "rfc1459";
+ tokens["CHANMODES"] = ServerInstance->Modes->GiveModeList(MASK_CHANNEL);
+ tokens["CHANNELLEN"] = ConvToStr(ServerInstance->Config->Limits.ChanMax);
+ tokens["CHANTYPES"] = "#";
+ tokens["CHARSET"] = "ascii";
+ tokens["ELIST"] = "MU";
+ tokens["KICKLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxKick);
+ tokens["MAXBANS"] = "64"; // TODO: make this a config setting.
+ tokens["MAXCHANNELS"] = ConvToStr(ServerInstance->Config->MaxChans);
+ tokens["MAXTARGETS"] = ConvToStr(ServerInstance->Config->MaxTargets);
+ tokens["MODES"] = ConvToStr(ServerInstance->Config->Limits.MaxModes);
+ tokens["NETWORK"] = ServerInstance->Config->Network;
+ tokens["NICKLEN"] = ConvToStr(ServerInstance->Config->Limits.NickMax);
+ tokens["PREFIX"] = ServerInstance->Modes->BuildPrefixes();
+ tokens["STATUSMSG"] = ServerInstance->Modes->BuildPrefixes(false);
+ tokens["TOPICLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxTopic);
+
+ tokens["FNC"] = tokens["MAP"] = tokens["VBANLIST"] =
+ tokens["WALLCHOPS"] = tokens["WALLVOICES"];
+
+ // Modules can add new tokens and also edit or remove existing tokens
+ FOREACH_MOD(I_On005Numeric, On005Numeric(tokens));
+
+ // EXTBAN is a special case as we need to sort it and prepend a comma.
+ std::map<std::string, std::string>::iterator extban = tokens.find("EXTBAN");
+ if (extban != tokens.end())
+ {
+ sort(extban->second.begin(), extban->second.end());
+ extban->second.insert(0, ",");
+ }
+
+ // Transform the map into a list of lines, ready to be sent to clients
+ std::vector<std::string>& lines = this->Lines;
+ std::string line;
+ unsigned int token_count = 0;
+ lines.clear();
+
+ for (std::map<std::string, std::string>::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
+ {
+ line.append(it->first);
+
+ // If this token has a value then append a '=' char after the name and then the value itself
+ if (!it->second.empty())
+ line.append(1, '=').append(it->second);
+
+ // Always append a space, even if it's the last token because all lines will be suffixed
+ line.push_back(' ');
+ token_count++;