]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add InspIRCd::GetChans(), remove ChannelCount()
authorAttila Molnar <attilamolnar@hush.com>
Fri, 14 Mar 2014 11:56:20 +0000 (12:56 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Fri, 14 Mar 2014 11:56:20 +0000 (12:56 +0100)
include/inspircd.h
src/coremods/core_list.cpp
src/coremods/core_lusers.cpp
src/coremods/core_stats.cpp
src/listmode.cpp
src/mode.cpp
src/modules.cpp
src/modules/m_channames.cpp
src/modules/m_httpd_stats.cpp
src/modules/m_permchannels.cpp
src/modules/m_spanningtree/netburst.cpp

index d1a457cf3367b17ec2403384a9f37ad1021d0e58..cda15e61971fa5513f64a07f8db465c05d6ed993 100644 (file)
@@ -460,6 +460,11 @@ class CoreExport InspIRCd
         */
        Channel* FindChan(const std::string &chan);
 
+       /** Get a hash map containing all channels, keyed by their name
+        * @return A hash map mapping channel names to Channel pointers
+        */
+       chan_hash& GetChans() { return *chanlist; }
+
        /** Return true if a channel name is valid
         * @param chname A channel name to verify
         * @return True if the name is valid
@@ -502,11 +507,6 @@ class CoreExport InspIRCd
        static const char* Format(const char* formatString, ...) CUSTOM_PRINTF(1, 2);
        static const char* Format(va_list &vaList, const char* formatString) CUSTOM_PRINTF(2, 0);
 
-       /** Return a count of channels on the network
-        * @return The number of channels
-        */
-       long ChannelCount() const { return chanlist->size(); }
-
        /** Send an error notice to all local users, opered and unopered
         * @param s The error string to send
         */
index ceffae43a5606de859e07a0f0f03787c10547da6..505b0764caa2e0fe1b82471689fb904d5abe01a2 100644 (file)
@@ -68,7 +68,8 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User
                }
        }
 
-       for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); i++)
+       const chan_hash& chans = ServerInstance->GetChans();
+       for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
        {
                // attempt to match a glob pattern
                long users = i->second->GetUserCounter();
index e56b1c0bb06bd56bd2b56bddb42ecd491a4bf57c..206d969d19dcdc1fee13eabd25887fc7e824f34f 100644 (file)
@@ -93,7 +93,7 @@ CmdResult CommandLusers::Handle (const std::vector<std::string>&, User *user)
        if (ServerInstance->Users->UnregisteredUserCount())
                user->WriteNumeric(RPL_LUSERUNKNOWN, "%d :unknown connections", ServerInstance->Users->UnregisteredUserCount());
 
-       user->WriteNumeric(RPL_LUSERCHANNELS, "%ld :channels formed", ServerInstance->ChannelCount());
+       user->WriteNumeric(RPL_LUSERCHANNELS, "%lu :channels formed", (unsigned long)ServerInstance->GetChans().size());
        user->WriteNumeric(RPL_LUSERME, ":I have %d clients and %d servers", ServerInstance->Users->LocalUserCount(),n_local_servs);
        user->WriteNumeric(RPL_LOCALUSERS, ":Current Local Users: %d  Max: %d", ServerInstance->Users->LocalUserCount(), counters.max_local);
        user->WriteNumeric(RPL_GLOBALUSERS, ":Current Global Users: %d  Max: %d", n_users, counters.max_global);
index 8e74b8376e142cd6acac5e2efe1669bcfad9a8c1..df0c12725c8f381af35bafa51c7e24f993c0e798 100644 (file)
@@ -202,7 +202,7 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results)
                case 'z':
                {
                        results.push_back("249 "+user->nick+" :Users: "+ConvToStr(ServerInstance->Users->clientlist->size()));
-                       results.push_back("249 "+user->nick+" :Channels: "+ConvToStr(ServerInstance->chanlist->size()));
+                       results.push_back("249 "+user->nick+" :Channels: "+ConvToStr(ServerInstance->GetChans().size()));
                        results.push_back("249 "+user->nick+" :Commands: "+ConvToStr(ServerInstance->Parser->cmdlist.size()));
 
                        float kbitpersec_in, kbitpersec_out, kbitpersec_total;
index 2e6703df38bc62394fbc033b4e78f91c91fde59d..0f139bb0129c42a2d44f5dcf6ecc499723fc8c82 100644 (file)
@@ -81,7 +81,8 @@ void ListModeBase::DoRehash()
        if (oldlimits == chanlimits)
                return;
 
-       for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); ++i)
+       const chan_hash& chans = ServerInstance->GetChans();
+       for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
        {
                ChanData* cd = extItem.get(i->second);
                if (cd)
index 1a02b5ec727a3ba29869d2995244be23cc032ac7..ee6b1cae51fe6a6bf3f99b2f3e6e30cb6d11db79 100644 (file)
@@ -701,7 +701,9 @@ bool ModeParser::DelMode(ModeHandler* mh)
                        }
                break;
                case MODETYPE_CHANNEL:
-                       for (chan_hash::iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); )
+               {
+                       const chan_hash& chans = ServerInstance->GetChans();
+                       for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); )
                        {
                                // The channel may not be in the hash after RemoveMode(), see m_permchannels
                                Channel* chan = i->second;
@@ -718,6 +720,7 @@ bool ModeParser::DelMode(ModeHandler* mh)
                                        stackresult.erase(stackresult.begin() + 1, stackresult.end());
                                }
                        }
+               }
                break;
        }
 
index 3723b09c333ed537fbb8f0504681b912c2a49ba5..62c3aa213a38e0a45c959ff305fc87669f4890e8 100644 (file)
@@ -390,7 +390,8 @@ void ModuleManager::DoSafeUnload(Module* mod)
        std::vector<reference<ExtensionItem> > items;
        ServerInstance->Extensions.BeginUnregister(modfind->second, items);
        /* Give the module a chance to tidy out all its metadata */
-       for (chan_hash::iterator c = ServerInstance->chanlist->begin(); c != ServerInstance->chanlist->end(); )
+       const chan_hash& chans = ServerInstance->GetChans();
+       for (chan_hash::const_iterator c = chans.begin(); c != chans.end(); )
        {
                Channel* chan = c->second;
                ++c;
index a9ef6729ea7a0cb5a8ab1a30bc7afa6abc897862..69b501792c77830bf407ecb7549e048d4ccdaff5 100644 (file)
@@ -66,7 +66,8 @@ class ModuleChannelNames : public Module
        {
                badchan = true;
                std::vector<Channel*> chanvec;
-               for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); ++i)
+               const chan_hash& chans = ServerInstance->GetChans();
+               for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
                {
                        if (!ServerInstance->IsChannel(i->second->name))
                                chanvec.push_back(i->second);
index 8a90074a96a50b4dd1e55be444f632942d77d025..75be402becd916a0ed36a0a74976691c6b898559 100644 (file)
@@ -105,7 +105,7 @@ class ModuleHttpStats : public Module
 
                                data << "<general>";
                                data << "<usercount>" << ServerInstance->Users->clientlist->size() << "</usercount>";
-                               data << "<channelcount>" << ServerInstance->chanlist->size() << "</channelcount>";
+                               data << "<channelcount>" << ServerInstance->GetChans().size() << "</channelcount>";
                                data << "<opercount>" << ServerInstance->Users->all_opers.size() << "</opercount>";
                                data << "<socketcount>" << (SocketEngine::GetUsedFds()) << "</socketcount><socketmax>" << SocketEngine::GetMaxFds() << "</socketmax><socketengine>" INSPIRCD_SOCKETENGINE_NAME "</socketengine>";
 
@@ -150,9 +150,10 @@ class ModuleHttpStats : public Module
                                }
                                data << "</modulelist><channellist>";
 
-                               for (chan_hash::const_iterator a = ServerInstance->chanlist->begin(); a != ServerInstance->chanlist->end(); ++a)
+                               const chan_hash& chans = ServerInstance->GetChans();
+                               for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
                                {
-                                       Channel* c = a->second;
+                                       Channel* c = i->second;
 
                                        data << "<channel>";
                                        data << "<usercount>" << c->GetUsers()->size() << "</usercount><channelname>" << Sanitize(c->name) << "</channelname>";
index a4fc6bd099630c52851d49e87eddc3a2d1849449..d23af04bcc53b22a56d6f8fe4646a94ffda4fccd 100644 (file)
@@ -74,7 +74,8 @@ static bool WriteDatabase(PermChannel& permchanmode, Module* mod, bool save_list
        stream << "# This file is automatically generated by m_permchannels. Any changes will be overwritten." << std::endl
                << "<config format=\"xml\">" << std::endl;
 
-       for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); i++)
+       const chan_hash& chans = ServerInstance->GetChans();
+       for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
        {
                Channel* chan = i->second;
                if (!chan->IsModeSet(permchanmode))
index aa25fcf680a6cde6e7f0c2bcc6bc86c1d5dbe042..93b4d72f49bec6e427dccf5bb0206979e6d0c33c 100644 (file)
@@ -118,7 +118,8 @@ void TreeSocket::DoBurst(TreeServer* s)
        /* Send users and their oper status */
        this->SendUsers(bs);
 
-       for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); ++i)
+       const chan_hash& chans = ServerInstance->GetChans();
+       for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
                SyncChannel(i->second, bs);
 
        this->SendXLines();