]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Replace the deprecated MAXBANS token with MAXLIST.
authorPeter Powell <petpow@saberuk.com>
Mon, 24 Jul 2017 13:44:36 +0000 (14:44 +0100)
committerPeter Powell <petpow@saberuk.com>
Mon, 24 Jul 2017 13:44:36 +0000 (14:44 +0100)
include/listmode.h
src/coremods/core_channel/core_channel.cpp
src/listmode.cpp
src/server.cpp

index 96a13a519b654103e2233687f10763b970a32cf3..f49c5b3c8ed825ab9df3be277fc41092eb699fa2 100644 (file)
@@ -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
index aba4d97690ddb28d6270cc05357850b68e4300b3..6fe6199dbd7ff321225797a2989a0ff036f128af 100644 (file)
@@ -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;
index b416d4a69e6c09dc23821c7255faadcbd7884426..23f98bf3fb616ed56347f895edd2b9f42220fccf 100644 (file)
@@ -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 &parameter, bool adding)
 {
        // Try and grab the list
index 2feb08f965c3bf51748778d4c2b71ebd0bdc39ad..6782187fe2989aaddbfbaf6ac48fbd8fb8e7158d 100644 (file)
@@ -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;