]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
Removal of ancient TRUE/FALSE #defines (C-ish stuff)
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index a9e3c01101dde8faee2856dacc0bb14885b9a2f8..c910e0f2b89f38fdbbadd456d50f2562c7141c5d 100644 (file)
@@ -689,7 +689,7 @@ void ChanExceptSender_NoFormat(chanrec* Ptr, userrec* user, char status, const c
        }
 }
 
-std::string& GetServerDescription(char* servername)
+std::string GetServerDescription(char* servername)
 {
        std::string description = "";
 
@@ -956,7 +956,6 @@ void WriteCommonExcept_NoFormat(userrec *u, const char* text)
 void WriteOpers(char* text, ...)
 {
        char textbuffer[MAXBUF];
-       char formatbuffer[MAXBUF];
        va_list argsPtr;
 
        if (!text)
@@ -969,8 +968,6 @@ void WriteOpers(char* text, ...)
        vsnprintf(textbuffer, MAXBUF, text, argsPtr);
        va_end(argsPtr);
 
-       snprintf(formatbuffer,MAXBUF,"NOTICE %s :%s",a->nick,textbuffer);
-
        for (std::vector<userrec*>::iterator i = all_opers.begin(); i != all_opers.end(); i++)
        {
                userrec* a = *i;
@@ -980,7 +977,7 @@ void WriteOpers(char* text, ...)
                        if (a->modebits & UM_SERVERNOTICE)
                        {
                                // send server notices to all with +s
-                               WriteServ_NoFormat(a->fd,formatbuffer);
+                               WriteServ(a->fd,"NOTICE %s :%s",a->nick,textbuffer);
                        }
                }
        }
@@ -1031,7 +1028,6 @@ void ServerPrivmsgAll(char* text, ...)
 void WriteMode(const char* modes, int flags, const char* text, ...)
 {
        char textbuffer[MAXBUF];
-       char formatbuffer[MAXBUF];
        int modelen;
        va_list argsPtr;
 
@@ -1046,8 +1042,6 @@ void WriteMode(const char* modes, int flags, const char* text, ...)
        va_end(argsPtr);
        modelen = strlen(modes);
 
-       snprintf(formatbuffer,MAXBUF,"NOTICE %s :%s",t->nick,textbuffer);
-
        for (std::vector<userrec*>::const_iterator i = local_users.begin(); i != local_users.end(); i++)
        {
                userrec* t = (userrec*)(*i);
@@ -1082,7 +1076,7 @@ void WriteMode(const char* modes, int flags, const char* text, ...)
 
                if (send_to_user)
                {
-                       WriteServ_NoFormat(t->fd,formatbuffer);
+                       WriteServ(t->fd,"NOTICE %s :%s",t->nick,textbuffer);
                }
        }
 }
@@ -1266,6 +1260,7 @@ char* chanmodes(chanrec *chan, bool showkey)
        static char scratch[MAXBUF];
        static char sparam[MAXBUF];
        char* offset = scratch;
+       std::string extparam = "";
 
        if (!chan)
        {
@@ -1277,43 +1272,33 @@ char* chanmodes(chanrec *chan, bool showkey)
        *scratch = '\0';
        *sparam = '\0';
 
-       if (chan->binarymodes & CM_NOEXTERNAL)
-               *offset++ = 'n';
-       if (chan->binarymodes & CM_TOPICLOCK)
-               *offset++ = 't';
-       if (*chan->key)
-               *offset++ = 'k';
-       if (chan->limit)
-               *offset++ = 'l';
-       if (chan->binarymodes & CM_INVITEONLY)
-               *offset++ = 'i';
-       if (chan->binarymodes & CM_MODERATED)
-               *offset++ = 'm';
-       if (chan->binarymodes & CM_SECRET)
-               *offset++ = 's';
-       if (chan->binarymodes & CM_PRIVATE)
-               *offset++ = 'p';
-
-       if (*chan->key)
-       {
-               snprintf(sparam,MAXBUF," %s",showkey ? chan->key : "<key>");
-       }
-
-       if (chan->limit)
-       {
-               char foo[24];
-               sprintf(foo," %lu",(unsigned long)chan->limit);
-               strlcat(sparam,foo,MAXBUF);
-       }
-
        /* This was still iterating up to 190, chanrec::custom_modes is only 64 elements -- Om */
        for(int n = 0; n < 64; n++)
        {
-               if(chan->custom_modes[n])
+               if(chan->modes[n])
                {
                        *offset++ = n+65;
-                       std::string extparam = chan->GetModeParameter(n+65);
-
+                       extparam = "";
+                       switch (n)
+                       {
+                               case CM_KEY:
+                                       extparam = (showkey ? chan->key : "<key>");
+                               break;
+                               case CM_LIMIT:
+                                       extparam = ConvToStr(chan->limit);
+                               break;
+                               case CM_NOEXTERNAL:
+                               case CM_TOPICLOCK:
+                               case CM_INVITEONLY:
+                               case CM_MODERATED:
+                               case CM_SECRET:
+                               case CM_PRIVATE:
+                                       /* We know these have no parameters */
+                               break;
+                               default:
+                                       extparam = chan->GetModeParameter(n+65);
+                               break;
+                       }
                        if (extparam != "")
                        {
                                charlcat(sparam,' ',MAXBUF);