]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Allow static build of inspircd without module support
[user/henk/code/inspircd.git] / src / channels.cpp
index d7f8f372e47b1645742027286aa4b5bee4d2bcf4..3f0fc4a36271077bc78b15f056b86a109210c6c7 100644 (file)
@@ -218,24 +218,23 @@ Channel* Channel::JoinUser(User *user, const char* cn, bool override, const char
         */
        if (IS_LOCAL(user) && !override)
        {
-               // Checking MyClass exists because we *may* get here with NULL, not 100% sure.
-               if (user->MyClass && user->MyClass->maxchans)
+               if (user->HasPrivPermission("channels/high-join-limit"))
                {
-                       if (user->HasPrivPermission("channels/high-join-limit"))
+                       if (user->chans.size() >= ServerInstance->Config->OperMaxChans)
                        {
-                               if (user->chans.size() >= ServerInstance->Config->OperMaxChans)
-                               {
-                                       user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
-                                       return NULL;
-                               }
+                               user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
+                               return NULL;
                        }
-                       else
+               }
+               else
+               {
+                       unsigned int maxchans = user->GetClass()->maxchans;
+                       if (!maxchans)
+                               maxchans = ServerInstance->Config->MaxChans;
+                       if (user->chans.size() >= maxchans)
                        {
-                               if (user->chans.size() >= user->MyClass->maxchans)
-                               {
-                                       user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
-                                       return NULL;
-                               }
+                               user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn);
+                               return NULL;
                        }
                }
        }
@@ -291,7 +290,7 @@ Channel* Channel::JoinUser(User *user, const char* cn, bool override, const char
                        else if (MOD_RESULT == MOD_RES_PASSTHRU)
                        {
                                std::string ckey = Ptr->GetModeParameter('k');
-                               bool invited = user->IsInvited(Ptr->name.c_str());
+                               bool invited = IS_LOCAL(user)->IsInvited(Ptr->name.c_str());
                                bool can_bypass = ServerInstance->Config->InvBypassModes && invited;
 
                                if (!ckey.empty())
@@ -338,7 +337,7 @@ Channel* Channel::JoinUser(User *user, const char* cn, bool override, const char
                                 */
                                if (invited)
                                {
-                                       user->RemoveInvite(Ptr->name.c_str());
+                                       IS_LOCAL(user)->RemoveInvite(Ptr->name.c_str());
                                }
                        }
                }
@@ -378,7 +377,9 @@ Channel* Channel::ForceChan(Channel* Ptr, User* user, const std::string &privs,
        Ptr->WriteAllExcept(user, false, 0, except_list, "JOIN :%s", Ptr->name.c_str());
 
        /* Theyre not the first ones in here, make sure everyone else sees the modes we gave the user */
-       std::string ms = ServerInstance->Modes->ModeString(user, Ptr);
+       std::string ms = memb->modes;
+       for(unsigned int i=0; i < memb->modes.length(); i++)
+               ms.append(" ").append(user->nick);
        if ((Ptr->GetUserCounter() > 1) && (ms.length()))
                Ptr->WriteAllExceptSender(user, true, 0, "MODE %s +%s", Ptr->name.c_str(), ms.c_str());
 
@@ -484,16 +485,6 @@ void Channel::PartUser(User *user, std::string &reason)
        this->DelUser(user);
 }
 
-void Channel::ServerKickUser(User* user, const char* reason, const std::string& servername)
-{
-       if (servername.empty() || !ServerInstance->Config->HideWhoisServer.empty())
-               ServerInstance->FakeClient->server = ServerInstance->Config->ServerName;
-       else
-               ServerInstance->FakeClient->server = servername;
-
-       KickUser(ServerInstance->FakeClient, user, reason);
-}
-
 void Channel::KickUser(User *src, User *user, const char* reason)
 {
        if (!src || !user || !reason)
@@ -655,19 +646,19 @@ void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList
 
 void Channel::RawWriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const std::string &out)
 {
-       char statmode = 0;
+       unsigned int minrank = 0;
        if (status)
        {
                ModeHandler* mh = ServerInstance->Modes->FindPrefix(status);
                if (mh)
-                       statmode = mh->GetModeChar();
+                       minrank = mh->GetPrefixRank();
        }
        for (UserMembIter i = userlist.begin(); i != userlist.end(); i++)
        {
-               if ((IS_LOCAL(i->first)) && (except_list.find(i->first) == except_list.end()))
+               if (IS_LOCAL(i->first) && (except_list.find(i->first) == except_list.end()))
                {
-                       /* User doesnt have the status we're after */
-                       if (statmode && !i->second->hasMode(statmode))
+                       /* User doesn't have the status we're after */
+                       if (minrank && i->second->getRank() < minrank)
                                continue;
 
                        i->first->Write(out);