]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Remove some debug
[user/henk/code/inspircd.git] / src / channels.cpp
index ea7edd71fbd2aac33a8cf07309e5bfdaff7769a2..5383f4aba2b39bed9cd95514896594a574641b17 100644 (file)
@@ -22,7 +22,7 @@
 chanrec::chanrec(InspIRCd* Instance) : ServerInstance(Instance)
 {
        *name = *topic = *setby = *key = 0;
-       created = topicset = limit = 0;
+       maxbans = created = topicset = limit = 0;
        memset(&modes,0,64);
        age = ServerInstance->Time(true);
 }
@@ -37,21 +37,12 @@ void chanrec::SetMode(char mode,bool mode_on)
 
 void chanrec::SetModeParam(char mode,const char* parameter,bool mode_on)
 {
-       ServerInstance->Log(DEBUG,"SetModeParam called");
-       
        CustomModeList::iterator n = custom_mode_params.find(mode);     
 
        if (mode_on)
        {
                if (n == custom_mode_params.end())
-               {
                        custom_mode_params[mode] = strdup(parameter);
-                       ServerInstance->Log(DEBUG,"Custom mode parameter %c %s added",mode,parameter);
-               }
-               else
-               {
-                       ServerInstance->Log(DEBUG, "Tried to set custom mode parameter for %c '%s' when it was already '%s'", mode, parameter, n->second);
-               }
        }
        else
        {
@@ -70,22 +61,18 @@ bool chanrec::IsModeSet(char mode)
 
 std::string chanrec::GetModeParameter(char mode)
 {
-       if (mode == 'k')
-       {
-               return this->key;
-       }
-       else if (mode == 'l')
-       {
-               return ConvToStr(this->limit);
-       }
-       else
+       switch (mode)
        {
-               CustomModeList::iterator n = custom_mode_params.find(mode);
-               if (n != custom_mode_params.end())
-               {
-                       return n->second;
-               }
-               return "";
+               case 'k':
+                       return this->key;
+               case 'l':
+                       return ConvToStr(this->limit);
+               default:
+                       CustomModeList::iterator n = custom_mode_params.find(mode);
+                       if (n != custom_mode_params.end())
+                               return n->second;
+                       return "";
+               break;
        }
 }
 
@@ -229,7 +216,6 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo
                *Ptr->topic = 0;
                *Ptr->setby = 0;
                Ptr->topicset = 0;
-               Instance->Log(DEBUG,"chanrec::JoinUser(): created: %s",cname);
                new_channel = true;
        }
        else
@@ -307,10 +293,6 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo
                                }
                        }
                }
-               else
-               {
-                       Instance->Log(DEBUG,"chanrec::JoinUser(): Overridden checks");
-               }
        }
 
        /* NOTE: If the user is an oper here, we can extend their user->chans by up to
@@ -339,7 +321,6 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo
 
        if (new_channel)
        {
-               Instance->Log(DEBUG,"BLAMMO, Whacking channel.");
                /* Things went seriously pear shaped, so take this away. bwahaha. */
                chan_hash::iterator n = Instance->chanlist->find(cname);
                if (n != Instance->chanlist->end())
@@ -385,13 +366,13 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr, userrec* user, con
                                 * must stick to ::find().
                                 */
                                case '@':
-                                       user->chans[Ptr] |= STATUS_OP;
+                                       user->chans[Ptr] |= UCMODE_OP;
                                break;
                                case '%':
-                                       user->chans[Ptr] |= STATUS_HOP;
+                                       user->chans[Ptr] |= UCMODE_HOP;
                                break;
                                case '+':
-                                       user->chans[Ptr] |= STATUS_VOICE;
+                                       user->chans[Ptr] |= UCMODE_VOICE;
                                break;
                        }
                }
@@ -468,7 +449,6 @@ long chanrec::PartUser(userrec *user, const char* reason)
                /* kill the record */
                if (iter != ServerInstance->chanlist->end())
                {
-                       ServerInstance->Log(DEBUG,"del_channel: destroyed: %s", this->name);
                        FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(this));
                        ServerInstance->chanlist->erase(iter);
                }
@@ -612,14 +592,18 @@ void chanrec::WriteChannel(userrec* user, char* text, ...)
 void chanrec::WriteChannel(userrec* user, const std::string &text)
 {
        CUList *ulist = this->GetUsers();
+       char tb[MAXBUF];
 
        if (!user)
                return;
 
+       snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
+       std::string out = tb;
+
        for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
        {
                if (IS_LOCAL(i->second))
-                       user->WriteTo(i->second,text);
+                       i->second->Write(out);
        }
 }
 
@@ -641,11 +625,15 @@ void chanrec::WriteChannelWithServ(const char* ServName, const char* text, ...)
 void chanrec::WriteChannelWithServ(const char* ServName, const std::string &text)
 {
        CUList *ulist = this->GetUsers();
+       char tb[MAXBUF];
+
+       snprintf(tb,MAXBUF,":%s %s",ServName ? ServName : ServerInstance->Config->ServerName, text.c_str());
+       std::string out = tb;
 
        for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
        {
                if (IS_LOCAL(i->second))
-                       i->second->WriteServ(text);
+                       i->second->Write(out);
        }
 }
 
@@ -684,6 +672,7 @@ void chanrec::WriteAllExcept(userrec* user, bool serversource, char status, CULi
 void chanrec::WriteAllExcept(userrec* user, bool serversource, char status, CUList &except_list, const std::string &text)
 {
        CUList *ulist;
+       char tb[MAXBUF];
 
        switch (status)
        {
@@ -701,6 +690,9 @@ void chanrec::WriteAllExcept(userrec* user, bool serversource, char status, CULi
                        break;
        }
 
+       snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
+       std::string out = tb;
+
        for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
        {
                if ((IS_LOCAL(i->second)) && (except_list.find(i->second) == except_list.end()))
@@ -708,7 +700,7 @@ void chanrec::WriteAllExcept(userrec* user, bool serversource, char status, CULi
                        if (serversource)
                                i->second->WriteServ(text);
                        else
-                               i->second->WriteFrom(user,text);
+                               i->second->Write(out);
                }
        }
 }
@@ -742,7 +734,7 @@ char* chanrec::ChanModes(bool showkey)
        static char scratch[MAXBUF];
        static char sparam[MAXBUF];
        char* offset = scratch;
-       std::string extparam = "";
+       std::string extparam;
 
        *scratch = '\0';
        *sparam = '\0';
@@ -801,12 +793,9 @@ void chanrec::UserList(userrec *user)
                return;
 
        FOREACH_RESULT(I_OnUserList,OnUserList(user, this));
-       ServerInstance->Log(DEBUG,"MOD_RESULT for UserList = %d",MOD_RESULT);
        if (MOD_RESULT == 1)
                return;
 
-       ServerInstance->Log(DEBUG,"Using builtin NAMES list generation");
-
        dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, this->name);
 
        int numusers = 0;
@@ -862,16 +851,29 @@ void chanrec::UserList(userrec *user)
 
 long chanrec::GetMaxBans()
 {
+       /* Return the cached value if there is one */
+       if (this->maxbans)
+               return this->maxbans;
+
+       /* If there isnt one, we have to do some O(n) hax to find it the first time. (ick) */
        for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
        {
                if (match(this->name,n->first.c_str()))
                {
+                       this->maxbans = n->second;
                        return n->second;
                }
        }
-       return 64;
+
+       /* Screw it, just return the default of 64 */
+       this->maxbans = 64;
+       return this->maxbans;
 }
 
+void chanrec::ResetMaxBans()
+{
+       this->maxbans = 0;
+}
 
 /* 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
@@ -1001,7 +1003,6 @@ void chanrec::SetPrefix(userrec* user, char prefix, unsigned int prefix_value, b
                                n->second.erase(x);
                }
        }
-       ServerInstance->Log(DEBUG,"Added prefix %c to %s for %s, prefixlist size is now %d", prefix, this->name, user->nick, prefixes.size());
 }
 
 void chanrec::RemoveAllPrefixes(userrec* user)
@@ -1009,7 +1010,6 @@ void chanrec::RemoveAllPrefixes(userrec* user)
        prefixlist::iterator n = prefixes.find(user);
        if (n != prefixes.end())
        {
-               ServerInstance->Log(DEBUG,"Removed prefixes from %s for %s, prefixlist size is now %d", this->name, user->nick, prefixes.size());
                prefixes.erase(n);
        }
 }