From: Attila Molnar Date: Fri, 14 Mar 2014 11:56:20 +0000 (+0100) Subject: Add InspIRCd::GetChans(), remove ChannelCount() X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=146d85b5dea9ecb803a9a47c68b5489905634125;p=user%2Fhenk%2Fcode%2Finspircd.git Add InspIRCd::GetChans(), remove ChannelCount() --- diff --git a/include/inspircd.h b/include/inspircd.h index d1a457cf3..cda15e619 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -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 */ diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp index ceffae43a..505b0764c 100644 --- a/src/coremods/core_list.cpp +++ b/src/coremods/core_list.cpp @@ -68,7 +68,8 @@ CmdResult CommandList::Handle (const std::vector& 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(); diff --git a/src/coremods/core_lusers.cpp b/src/coremods/core_lusers.cpp index e56b1c0bb..206d969d1 100644 --- a/src/coremods/core_lusers.cpp +++ b/src/coremods/core_lusers.cpp @@ -93,7 +93,7 @@ CmdResult CommandLusers::Handle (const std::vector&, 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); diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp index 8e74b8376..df0c12725 100644 --- a/src/coremods/core_stats.cpp +++ b/src/coremods/core_stats.cpp @@ -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; diff --git a/src/listmode.cpp b/src/listmode.cpp index 2e6703df3..0f139bb01 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -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) diff --git a/src/mode.cpp b/src/mode.cpp index 1a02b5ec7..ee6b1cae5 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -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; } diff --git a/src/modules.cpp b/src/modules.cpp index 3723b09c3..62c3aa213 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -390,7 +390,8 @@ void ModuleManager::DoSafeUnload(Module* mod) std::vector > 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; diff --git a/src/modules/m_channames.cpp b/src/modules/m_channames.cpp index a9ef6729e..69b501792 100644 --- a/src/modules/m_channames.cpp +++ b/src/modules/m_channames.cpp @@ -66,7 +66,8 @@ class ModuleChannelNames : public Module { badchan = true; std::vector 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); diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 8a90074a9..75be402be 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -105,7 +105,7 @@ class ModuleHttpStats : public Module data << ""; data << "" << ServerInstance->Users->clientlist->size() << ""; - data << "" << ServerInstance->chanlist->size() << ""; + data << "" << ServerInstance->GetChans().size() << ""; data << "" << ServerInstance->Users->all_opers.size() << ""; data << "" << (SocketEngine::GetUsedFds()) << "" << SocketEngine::GetMaxFds() << "" INSPIRCD_SOCKETENGINE_NAME ""; @@ -150,9 +150,10 @@ class ModuleHttpStats : public Module } data << ""; - 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 << ""; data << "" << c->GetUsers()->size() << "" << Sanitize(c->name) << ""; diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index a4fc6bd09..d23af04bc 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -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 << "" << 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)) diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index aa25fcf68..93b4d72f4 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -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();