]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
m_spanningtree Remove duplicate code for sending channel messages from RouteCommand()
[user/henk/code/inspircd.git] / src / channels.cpp
index 505ef479aaf09da2e74d2c05fd24244f6fe76d58..afc56990923434372947b37822f90c01d945cfad 100644 (file)
@@ -36,18 +36,14 @@ namespace
        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)
+       : name(cname), age(ts), topicset(0)
 {
        if (!ServerInstance->chanlist->insert(std::make_pair(cname, this)).second)
                throw CoreException("Cannot create duplicate channel " + cname);
-
-       this->name = cname;
-       this->age = ts ? ts : ServerInstance->Time();
-
-       topicset = 0;
-       modes.reset();
 }
 
 void Channel::SetMode(ModeHandler* mh, bool on)
@@ -85,7 +81,7 @@ void Channel::SetTopic(User* u, const std::string& ntopic)
        this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
        this->topicset = ServerInstance->Time();
 
-       FOREACH_MOD(I_OnPostTopicChange,OnPostTopicChange(u, this, this->topic));
+       FOREACH_MOD(OnPostTopicChange, (u, this, this->topic));
 }
 
 Membership* Channel::AddUser(User* user)
@@ -119,7 +115,7 @@ void Channel::CheckDestroy()
        /* kill the record */
        if (iter != ServerInstance->chanlist->end())
        {
-               FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
+               FOREACH_MOD(OnChannelDelete, (this));
                ServerInstance->chanlist->erase(iter);
        }
 
@@ -161,6 +157,9 @@ void Channel::SetDefaultModes()
                ModeHandler* mode = ServerInstance->Modes->FindMode(*n, MODETYPE_CHANNEL);
                if (mode)
                {
+                       if (mode->GetPrefixRank())
+                               continue;
+
                        if (mode->GetNumParams(true))
                                list.GetToken(parameter);
                        else
@@ -222,7 +221,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co
 
        if (!chan)
        {
-               privs = "o";
+               privs = ServerInstance->Config->DefaultModes.substr(0, ServerInstance->Config->DefaultModes.find(' '));
 
                if (override == false)
                {
@@ -338,11 +337,10 @@ void Channel::ForceJoin(User* user, const std::string* privs, bool bursting, boo
        {
                // If the user was granted prefix modes (in the OnUserPreJoin hook, or he's a
                // remote user and his own server set the modes), then set them internally now
-               memb->modes = *privs;
                for (std::string::const_iterator i = privs->begin(); i != privs->end(); ++i)
                {
                        ModeHandler* mh = ServerInstance->Modes->FindMode(*i, MODETYPE_CHANNEL);
-                       if (mh)
+                       if (mh && mh->GetPrefixRank())
                        {
                                std::string nick = user->nick;
                                /* Set, and make sure that the mode handler knows this mode was now set */
@@ -354,7 +352,7 @@ void Channel::ForceJoin(User* user, const std::string* privs, bool bursting, boo
 
        // Tell modules about this join, they have the chance now to populate except_list with users we won't send the JOIN (and possibly MODE) to
        CUList except_list;
-       FOREACH_MOD(I_OnUserJoin,OnUserJoin(memb, bursting, created_by_local, except_list));
+       FOREACH_MOD(OnUserJoin, (memb, bursting, created_by_local, except_list));
 
        this->WriteAllExcept(user, false, 0, except_list, "JOIN :%s", this->name.c_str());
 
@@ -379,7 +377,7 @@ void Channel::ForceJoin(User* user, const std::string* privs, bool bursting, boo
                this->UserList(user);
        }
 
-       FOREACH_MOD(I_OnPostJoin,OnPostJoin(memb));
+       FOREACH_MOD(OnPostJoin, (memb));
 }
 
 bool Channel::IsBanned(User* user)
@@ -464,7 +462,7 @@ void Channel::PartUser(User *user, std::string &reason)
        {
                Membership* memb = membiter->second;
                CUList except_list;
-               FOREACH_MOD(I_OnUserPart,OnUserPart(memb, reason, except_list));
+               FOREACH_MOD(OnUserPart, (memb, reason, except_list));
 
                WriteAllExcept(user, false, 0, except_list, "PART %s%s%s", this->name.c_str(), reason.empty() ? "" : " :", reason.c_str());
 
@@ -519,7 +517,7 @@ void Channel::KickUser(User* src, User* victim, const std::string& reason, Membe
        }
 
        CUList except_list;
-       FOREACH_MOD(I_OnUserKick,OnUserKick(src, memb, reason, except_list));
+       FOREACH_MOD(OnUserKick, (src, memb, reason, except_list));
 
        WriteAllExcept(src, false, 0, except_list, "KICK %s %s :%s", name.c_str(), victim->nick.c_str(), reason.c_str());
 
@@ -683,7 +681,7 @@ void Channel::UserList(User *user)
        {
                if (i->first->quitting)
                        continue;
-               if ((!has_user) && (i->first->IsModeSet('i')))
+               if ((!has_user) && (i->first->IsModeSet(invisiblemode)))
                {
                        /*
                         * user is +i, and source not on the channel, does not show
@@ -695,7 +693,7 @@ void Channel::UserList(User *user)
                prefixlist = this->GetPrefixChar(i->first);
                nick = i->first->nick;
 
-               FOREACH_MOD(I_OnNamesListItem, OnNamesListItem(user, i->second, prefixlist, nick));
+               FOREACH_MOD(OnNamesListItem, (user, i->second, prefixlist, nick));
 
                /* Nick was nuked, a module wants us to skip it */
                if (nick.empty())