]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix m_nopartmsg to work via API modification, involves a string copy that won't last...
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 11 Jul 2008 14:44:17 +0000 (14:44 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 11 Jul 2008 14:44:17 +0000 (14:44 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9953 e03df62e-2008-0410-955e-edbf42e46eb7

include/modules.h
src/channels.cpp
src/modules.cpp
src/modules/m_auditorium.cpp
src/modules/m_chanprotect.cpp
src/modules/m_delayjoin.cpp
src/modules/m_foobar.cpp
src/modules/m_invisible.cpp
src/modules/m_nopartmsg.cpp
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/main.h

index 7ae620752abb1edebaf566f162bbd56386a8facb..ca331e33481eb7e4bcdc9f190f17bb0cb3a0b436 100644 (file)
@@ -498,11 +498,11 @@ class CoreExport Module : public Extensible
         * and the details of the channel they have left is available in the variable Channel *channel
         * @param user The user who is parting
         * @param channel The channel being parted
-        * @param partmessage The part message, or an empty string
+        * @param partmessage The part message, or an empty string (may be modified)
         * @param silent Change this to true if you want to conceal the PART command from the other users
         * of the channel (useful for modules such as auditorium)
         */
-       virtual void OnUserPart(User* user, Channel* channel, const std::string &partmessage, bool &silent);
+       virtual void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent);
 
        /** Called on rehash.
         * This method is called prior to a /REHASH or when a SIGHUP is received from the operating
index 219979dc93cdf96ebc3f24b15a25520eee5b433b..fbec272b37623b826ac5bd42206b695e22c084b9 100644 (file)
@@ -482,10 +482,18 @@ bool Channel::IsExtBanned(User *user, char type)
 /* Channel::PartUser
  * remove a channel from a users record, and return the number of users left.
  * Therefore, if this function returns 0 the caller should delete the Channel.
+ *
+ * XXX: bleh, string copy of reason, fixme! -- w00t
  */
 long Channel::PartUser(User *user, const char* reason)
 {
        bool silent = false;
+       std::string freason;
+
+       if (reason)
+               freason = reason;
+       else
+               freason = "";
 
        if (!user)
                return this->GetUserCounter();
@@ -493,7 +501,7 @@ long Channel::PartUser(User *user, const char* reason)
        UCListIter i = user->chans.find(this);
        if (i != user->chans.end())
        {
-               FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason ? reason : "", silent));
+               FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, freason, silent));
 
                if (!silent)
                        this->WriteChannel(user, "PART %s%s%s", this->name.c_str(), reason ? " :" : "", reason ? reason : "");
index 0867390fd25d54f37125ab6ed79e53a96c4ee4b1..e25f4bf108637fd231b3aa080d20487d47accecf 100644 (file)
@@ -111,7 +111,7 @@ void                Module::OnUserQuit(User*, const std::string&, const std::string&) { }
 void           Module::OnUserDisconnect(User*) { }
 void           Module::OnUserJoin(User*, Channel*, bool, bool&) { }
 void           Module::OnPostJoin(User*, Channel*) { }
-void           Module::OnUserPart(User*, Channel*, const std::string&, bool&) { }
+void           Module::OnUserPart(User*, Channel*, std::string&, bool&) { }
 void           Module::OnRehash(User*, const std::string&) { }
 void           Module::OnServerRaw(std::string&, bool, User*) { }
 int            Module::OnUserPreJoin(User*, Channel*, const char*, std::string&, const std::string&) { return 0; }
index cba99d4716e5938af3d0d3b54e7396583ae74fcd..c1da8ca8c64ccfee38b97b647454f7ef2ba44292 100644 (file)
@@ -126,7 +126,7 @@ class ModuleAuditorium : public Module
                }
        }
 
-       void OnUserPart(User* user, Channel* channel, const std::string &partmessage, bool &silent)
+       void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent)
        {
                if (channel->IsModeSet('u'))
                {
index cd84d9c5f2629cc5cb497a58ef8dc03a2fbbc809..0145907452901a96f1fbecc413ad591b6f3774ff 100644 (file)
@@ -329,7 +329,7 @@ class ModuleChanProtect : public Module
                user->Shrink("cm_protect_"+std::string(chan->name));
        }
 
-       virtual void OnUserPart(User* user, Channel* channel, const std::string &partreason, bool &silent)
+       virtual void OnUserPart(User* user, Channel* channel, std::string &partreason, bool &silent)
        {
                // FIX: when someone parts a channel we must remove their Extensibles!
                user->Shrink("cm_founder_"+std::string(channel->name));
index f8a1d0e9f5ca2d7ea199449b092976e4d889cdb3..6b6f0c5a158ad9751bb20ed38b21d0d5ac7e5705 100644 (file)
@@ -117,7 +117,7 @@ class ModuleDelayJoin : public Module
                }
        }
 
-       void OnUserPart(User* user, Channel* channel, const std::string &partmessage, bool &silent)
+       void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent)
        {
                if (channel->IsModeSet('D'))
                {
index 7a8ac8e3234e6774fe557e5ac7435aabe72b3843..1f8d0c3bdb1744f90717153584a866d255766c17 100644 (file)
@@ -77,7 +77,7 @@ class ModuleFoobar : public Module
                ServerInstance->Logs->Log("m_foobar",DEBUG,"Foobar: User "+b+" joined "+c);
        }
 
-       virtual void OnUserPart(User* user, Channel* channel, const std::string &partreason, bool &silent)
+       virtual void OnUserPart(User* user, Channel* channel, std::string &partreason, bool &silent)
        {
                // method called when a user parts a channel
 
index 999151f7994be0108fcf4e03b41db48979386e9f..f8aae9cb5a55b32495cef9ad8ae6171cd763c04e 100644 (file)
@@ -205,7 +205,7 @@ class ModuleInvisible : public Module
                conf = new ConfigReader(ServerInstance);
        }
 
-       void OnUserPart(User* user, Channel* channel, const std::string &partmessage, bool &silent)
+       void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent)
        {
                if (user->IsModeSet('Q'))
                {
index 648626a2392929ca808814df0305e834e90f71a2..46b79b51f09523ce741877d6fcf6a004507bd5ca 100644 (file)
@@ -35,15 +35,13 @@ class ModulePartMsgBan : public Module
        }
 
 
-    virtual void OnUserPart(User* user, Channel* channel, const std::string &partmessage, bool &silent)
+    virtual void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent)
        {
                if (!IS_LOCAL(user))
                        return;
 
-#if 0
                if (channel->IsExtBanned(user, 'p'))
                        partmessage = "";
-#endif
 
                return;
        }
index 9688cfb7dab10414fae80ce25c72ee34a5d3da86..91c13e5593a90822a1fc0f65ef94e0772da609e3 100644 (file)
@@ -610,7 +610,7 @@ void ModuleSpanningTree::OnChangeName(User* user, const std::string &gecos)
        Utils->DoOneToMany(user->uuid,"FNAME",params);
 }
 
-void ModuleSpanningTree::OnUserPart(User* user, Channel* channel, const std::string &partmessage, bool &silent)
+void ModuleSpanningTree::OnUserPart(User* user, Channel* channel,  std::string &partmessage, bool &silent)
 {
        if (IS_LOCAL(user))
        {
index f62b9e779adc969446135b0a3b9d7dc5cf3940b5..98294b9fda7babbd67c7f4fec51ef462123f7d23 100644 (file)
@@ -160,7 +160,7 @@ class ModuleSpanningTree : public Module
        virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent);
        virtual void OnChangeHost(User* user, const std::string &newhost);
        virtual void OnChangeName(User* user, const std::string &gecos);
-       virtual void OnUserPart(User* user, Channel* channel, const std::string &partmessage, bool &silent);
+       virtual void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent);
        virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
        virtual void OnUserPostNick(User* user, const std::string &oldnick);
        virtual void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent);