diff options
author | Peter Powell <petpow@saberuk.com> | 2017-07-24 14:44:36 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2017-07-24 14:44:36 +0100 |
commit | 60658d0bdbc8d047c3dbfc19abb005e147b5b2b9 (patch) | |
tree | ea49869ba451ebbeb824ee1f6496a55f75ebfaff | |
parent | d2b5c7d1fcda74a72c93937cc58b5b7ff80e2a0a (diff) |
Replace the deprecated MAXBANS token with MAXLIST.
-rw-r--r-- | include/listmode.h | 4 | ||||
-rw-r--r-- | src/coremods/core_channel/core_channel.cpp | 25 | ||||
-rw-r--r-- | src/listmode.cpp | 11 | ||||
-rw-r--r-- | src/server.cpp | 1 |
4 files changed, 40 insertions, 1 deletions
diff --git a/include/listmode.h b/include/listmode.h index 96a13a519..f49c5b3c8 100644 --- a/include/listmode.h +++ b/include/listmode.h @@ -126,6 +126,10 @@ class CoreExport ListModeBase : public ModeHandler */ unsigned int GetLimit(Channel* channel); + /** Gets the lower list limit for this listmode. + */ + unsigned int GetLowerLimit(); + /** Retrieves the list of all modes set on the given channel * @param channel Channel to get the list from * @return A list with all modes of this type set on the given channel, can be NULL diff --git a/src/coremods/core_channel/core_channel.cpp b/src/coremods/core_channel/core_channel.cpp index aba4d9769..6fe6199db 100644 --- a/src/coremods/core_channel/core_channel.cpp +++ b/src/coremods/core_channel/core_channel.cpp @@ -20,6 +20,7 @@ #include "inspircd.h" #include "core_channel.h" #include "invite.h" +#include "listmode.h" class CoreModChannel : public Module { @@ -58,6 +59,30 @@ class CoreModChannel : public Module } } + void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE + { + // Build a map of limits to their mode character. + insp::flat_map<int, std::string> limits; + const ModeParser::ListModeList& listmodes = ServerInstance->Modes->GetListModes(); + for (ModeParser::ListModeList::const_iterator iter = listmodes.begin(); iter != listmodes.end(); ++iter) + { + const unsigned int limit = (*iter)->GetLowerLimit(); + limits[limit].push_back((*iter)->GetModeChar()); + } + + // Generate the MAXLIST token from the limits map. + std::string& buffer = tokens["MAXLIST"]; + for (insp::flat_map<int, std::string>::const_iterator iter = limits.begin(); iter != limits.end(); ++iter) + { + if (!buffer.empty()) + buffer.push_back(','); + + buffer.append(iter->second); + buffer.push_back(':'); + buffer.append(ConvToStr(iter->first)); + } + } + void OnPostJoin(Membership* memb) CXX11_OVERRIDE { Channel* const chan = memb->chan; diff --git a/src/listmode.cpp b/src/listmode.cpp index b416d4a69..23f98bf3f 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -121,6 +121,17 @@ unsigned int ListModeBase::GetLimit(Channel* channel) return GetLimitInternal(channel->name, cd); } +unsigned int ListModeBase::GetLowerLimit() +{ + unsigned int limit = UINT_MAX; + for (limitlist::iterator iter = chanlimits.begin(); iter != chanlimits.end(); ++iter) + { + if (iter->limit < limit) + limit = iter->limit; + } + return limit == UINT_MAX ? DEFAULT_LIST_SIZE : limit; +} + ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding) { // Try and grab the list diff --git a/src/server.cpp b/src/server.cpp index 2feb08f96..6782187fe 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -171,7 +171,6 @@ void ISupportManager::Build() tokens["CHANTYPES"] = "#"; tokens["ELIST"] = "MU"; tokens["KICKLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxKick); - tokens["MAXBANS"] = "64"; // TODO: make this a config setting. tokens["MAXTARGETS"] = ConvToStr(ServerInstance->Config->MaxTargets); tokens["MODES"] = ConvToStr(ServerInstance->Config->Limits.MaxModes); tokens["NETWORK"] = ServerInstance->Config->Network; |