]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Init the sequence indicator to avoid undefined behaviour. Thx owine.
[user/henk/code/inspircd.git] / src / channels.cpp
index 2793843c7f5e1a47c15a6ad6824af99e0af74c4e..b44a863b4fc501eb8e4ae1a92b2d503ddcd86e98 100644 (file)
@@ -11,9 +11,9 @@
  * ---------------------------------------------------
  */
 
+#include "inspircd.h"
 #include <stdarg.h>
 #include "configreader.h"
-#include "inspircd.h"
 #include "users.h"
 #include "modules.h"
 #include "wildcard.h"
@@ -172,6 +172,31 @@ CUList* chanrec::GetVoicedUsers()
        return &internal_voice_userlist;
 }
 
+void chanrec::SetDefaultModes()
+{
+       irc::spacesepstream list(ServerInstance->Config->DefaultModes);
+       std::string modeseq = list.GetToken();
+       std::string parameter;
+       userrec* dummyuser = new userrec(ServerInstance);
+       dummyuser->SetFd(FD_MAGIC_NUMBER);
+
+       for (std::string::iterator n = modeseq.begin(); n != modeseq.end(); ++n)
+       {
+               ModeHandler* mode = ServerInstance->Modes->FindMode(*n, MODETYPE_CHANNEL);
+               if (mode)
+               {
+                       if (mode->GetNumParams(true))
+                               parameter = list.GetToken().c_str();
+                       else
+                               parameter.clear();
+
+                       mode->OnModeChange(dummyuser, dummyuser, this, parameter, true);
+               }
+       }
+
+       delete dummyuser;
+}
+
 /* 
  * add a channel to a user, creating the record for it if needed and linking
  * it to the user record 
@@ -213,7 +238,7 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo
 
                /* As spotted by jilles, dont bother to set this on remote users */
                if (IS_LOCAL(user))
-                       Ptr->modes[CM_TOPICLOCK] = Ptr->modes[CM_NOEXTERNAL] = 1;
+                       Ptr->SetDefaultModes();
 
                Ptr->created = TS ? TS : Instance->Time();
                Ptr->age = Ptr->created;
@@ -765,7 +790,7 @@ char* chanrec::ChanModes(bool showkey)
                if(this->modes[n])
                {
                        *offset++ = n + 65;
-                       extparam = "";
+                       extparam.clear();
                        switch (n)
                        {
                                case CM_KEY:
@@ -786,7 +811,7 @@ char* chanrec::ChanModes(bool showkey)
                                        extparam = this->GetModeParameter(n + 65);
                                break;
                        }
-                       if (extparam != "")
+                       if (!extparam.empty())
                        {
                                charlcat(sparam,' ',MAXBUF);
                                strlcat(sparam,extparam.c_str(),MAXBUF);