X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fchannels.cpp;h=f79b5b89f56c37e221e7aee01f24862d64f660cb;hb=6447b7be822439cce2f8109ea5362edeec4c6255;hp=53a48c46970204d108f2eeba992bd6d429b296f2;hpb=3a3ff949670c61a4a8856e1391222e156eb1cd17;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/channels.cpp b/src/channels.cpp index 53a48c469..f79b5b89f 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -32,9 +32,6 @@ namespace ChanModeReference inviteonlymode(NULL, "inviteonly"); ChanModeReference keymode(NULL, "key"); ChanModeReference limitmode(NULL, "limit"); - ChanModeReference secretmode(NULL, "secret"); - ChanModeReference privatemode(NULL, "private"); - UserModeReference invisiblemode(NULL, "invisible"); } Channel::Channel(const std::string &cname, time_t ts) @@ -86,14 +83,13 @@ void Channel::CheckDestroy() if (res == MOD_RES_DENY) return; + // If the channel isn't in chanlist then it is already in the cull list, don't add it again chan_hash::iterator iter = ServerInstance->chanlist.find(this->name); - /* kill the record */ - if (iter != ServerInstance->chanlist.end()) - { - FOREACH_MOD(OnChannelDelete, (this)); - ServerInstance->chanlist.erase(iter); - } + if ((iter == ServerInstance->chanlist.end()) || (iter->second != this)) + return; + FOREACH_MOD(OnChannelDelete, (this)); + ServerInstance->chanlist.erase(iter); ClearInvites(); ServerInstance->GlobalCulls.AddItem(this); } @@ -345,16 +341,6 @@ Membership* Channel::ForceJoin(User* user, const std::string* privs, bool bursti this->WriteAllExcept(user, !ServerInstance->Config->CycleHostsFromUser, 0, except_list, "MODE %s +%s", this->name.c_str(), ms.c_str()); } - if (IS_LOCAL(user)) - { - if (this->topicset) - { - user->WriteNumeric(RPL_TOPIC, "%s :%s", this->name.c_str(), this->topic.c_str()); - user->WriteNumeric(RPL_TOPICTIME, "%s %s %lu", this->name.c_str(), this->setby.c_str(), (unsigned long)this->topicset); - } - this->UserList(user); - } - FOREACH_MOD(OnPostJoin, (memb)); return memb; } @@ -396,10 +382,10 @@ bool Channel::CheckBan(User* user, const std::string& mask) return false; const std::string nickIdent = user->nick + "!" + user->ident; - std::string prefix = mask.substr(0, at); + std::string prefix(mask, 0, at); if (InspIRCd::Match(nickIdent, prefix, NULL)) { - std::string suffix = mask.substr(at + 1); + std::string suffix(mask, at + 1); if (InspIRCd::Match(user->host, suffix, NULL) || InspIRCd::Match(user->dhost, suffix, NULL) || InspIRCd::MatchCIDR(user->GetIPString(), suffix, NULL)) @@ -587,66 +573,6 @@ const char* Channel::ChanModes(bool showkey) return scratch.c_str(); } -/* compile a userlist of a channel into a string, each nick seperated by - * spaces and op, voice etc status shown as @ and +, and send it to 'user' - */ -void Channel::UserList(User* user, bool has_user) -{ - bool has_privs = user->HasPrivPermission("channels/auspex"); - std::string list; - list.push_back(this->IsModeSet(secretmode) ? '@' : this->IsModeSet(privatemode) ? '*' : '='); - list.push_back(' '); - list.append(this->name).append(" :"); - std::string::size_type pos = list.size(); - - const size_t maxlen = ServerInstance->Config->Limits.MaxLine - 10 - ServerInstance->Config->ServerName.size(); - std::string prefixlist; - std::string nick; - for (MemberMap::iterator i = userlist.begin(); i != userlist.end(); ++i) - { - if ((!has_user) && (i->first->IsModeSet(invisiblemode)) && (!has_privs)) - { - /* - * user is +i, and source not on the channel, does not show - * nick in NAMES list - */ - continue; - } - - Membership* memb = i->second; - - prefixlist.clear(); - char prefix = memb->GetPrefixChar(); - if (prefix) - prefixlist.push_back(prefix); - nick = i->first->nick; - - ModResult res; - FIRST_MOD_RESULT(OnNamesListItem, res, (user, memb, prefixlist, nick)); - - // See if a module wants us to exclude this user from NAMES - if (res == MOD_RES_DENY) - continue; - - if (list.size() + prefixlist.length() + nick.length() + 1 > maxlen) - { - /* list overflowed into multiple numerics */ - user->WriteNumeric(RPL_NAMREPLY, list); - - // Erase all nicks, keep the constant part - list.erase(pos); - } - - list.append(prefixlist).append(nick).push_back(' '); - } - - // Only send the user list numeric if there is at least one user in it - if (list.size() != pos) - user->WriteNumeric(RPL_NAMREPLY, list); - - user->WriteNumeric(RPL_ENDOFNAMES, "%s :End of /NAMES list.", this->name.c_str()); -} - /* returns the status character for a given user on a channel, e.g. @ for op, * % for halfop etc. If the user has several modes set, the highest mode * the user has must be returned.