]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Convert API to use std::string, fixes my slight bug from earlier and looks tidier
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 11 Jul 2008 21:15:02 +0000 (21:15 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 11 Jul 2008 21:15:02 +0000 (21:15 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9956 e03df62e-2008-0410-955e-edbf42e46eb7

include/channels.h
src/channels.cpp
src/commands/cmd_part.cpp
src/modules/m_cycle.cpp
src/modules/m_remove.cpp
src/modules/m_sapart.cpp
src/modules/m_spanningtree/svspart.cpp

index bf06e760a98ab0445771b87bd4044eec0af8a361..67a76f73be3ff5458f66f2f025f6138c2de24341 100644 (file)
@@ -349,11 +349,11 @@ class CoreExport Channel : public Extensible
        /** Part a user from this channel with the given reason.
         * If the reason field is NULL, no reason will be sent.
         * @param user The user who is parting (must be on this channel)
-        * @param reason The (optional) part reason
+        * @param reason The part reason
         * @return The number of users left on the channel. If this is zero
         * when the method returns, you MUST delete the Channel immediately!
         */
-       long PartUser(User *user, const char* reason = NULL);
+       long PartUser(User *user, std::string &reason);
 
        /* Join a user to a channel. May be a channel that doesnt exist yet.
         * @param user The user to join to the channel.
index fbec272b37623b826ac5bd42206b695e22c084b9..47dfd91b6b84cea07a6b846c7a51fa39026b082f 100644 (file)
@@ -485,15 +485,9 @@ bool Channel::IsExtBanned(User *user, char type)
  *
  * XXX: bleh, string copy of reason, fixme! -- w00t
  */
-long Channel::PartUser(User *user, const char* reason)
+long Channel::PartUser(User *user, std::string &reason)
 {
        bool silent = false;
-       std::string freason;
-
-       if (reason)
-               freason = reason;
-       else
-               freason = "";
 
        if (!user)
                return this->GetUserCounter();
@@ -501,10 +495,10 @@ 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, freason, silent));
+               FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason, silent));
 
                if (!silent)
-                       this->WriteChannel(user, "PART %s%s%s", this->name.c_str(), reason ? " :" : "", reason ? reason : "");
+                       this->WriteChannel(user, "PART %s%s%s", this->name.c_str(), reason.empty() ? "" : ":", reason.c_str());
 
                user->chans.erase(i);
                this->RemoveAllPrefixes(user);
index 352b967b59b6e7a8aa0839f68b31186dd4458272..dcc50609bf4aab4b11c2670b9094f84ca27de058 100644 (file)
@@ -47,8 +47,7 @@ CmdResult CommandPart::Handle (const std::vector<std::string>& parameters, User
        
        if (c)
        {
-               const char *rreason = reason.empty() ? NULL : reason.c_str();
-               if (!c->PartUser(user, rreason))
+               if (!c->PartUser(user, reason))
                        /* Arse, who stole our channel! :/ */
                        delete c;
        }
index 037e570f61fd6be13930bc89a109b1d82888cbf1..5b562631d9a3ff06aa8a1e7fe9e1218b5acac950 100644 (file)
@@ -59,7 +59,7 @@ class CommandCycle : public Command
                                }
 
                                /* XXX in the future, this may move to a static Channel method (the delete.) -- w00t */
-                               if (!channel->PartUser(user, reason.c_str()))
+                               if (!channel->PartUser(user, reason))
                                        delete channel;
 
                                Channel::JoinUser(ServerInstance, user, parameters[0].c_str(), true, "", false, ServerInstance->Time());
index 4dfa0bfb5c18300f3807c3b49953649f90da4e1e..d35f1f8ddf1f9aeb8cbd9e3408328fd416c128e3 100644 (file)
@@ -180,7 +180,7 @@ class RemoveBase
                                channel->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s removed %s from the channel", channel->name.c_str(), user->nick.c_str(), target->nick.c_str());
                                target->WriteServ("NOTICE %s :*** %s removed you from %s with the message: %s", target->nick.c_str(), user->nick.c_str(), channel->name.c_str(), reasonparam.c_str());
 
-                               if (!channel->PartUser(target, reason.c_str()))
+                               if (!channel->PartUser(target, reason))
                                        delete channel;
                        }
                        else
index 1baabc463e116eb6b6eb3c751bc39cff6573df0c..f01cb1564c7325a019918e58c5af4747f3934ff3 100644 (file)
@@ -31,7 +31,7 @@ class CommandSapart : public Command
        {
                User* dest = ServerInstance->FindNick(parameters[0]);
                Channel* channel = ServerInstance->FindChan(parameters[1]);
-               std::string reason;
+               std::string reason = "";
 
                if (dest && channel)
                {
@@ -50,7 +50,7 @@ class CommandSapart : public Command
                         */
                        if (IS_LOCAL(dest))
                        {
-                               if (!channel->PartUser(dest, reason.empty() ? NULL : reason.c_str()))
+                               if (!channel->PartUser(dest, reason))
                                        delete channel;
 
                                Channel* n = ServerInstance->FindChan(parameters[1]);
index 639792be9cfea6cb4f8590618265ccb75ad521bb..bcb73741ba87351dfb84dc50d18eebe6b1b26a19 100644 (file)
@@ -35,6 +35,11 @@ bool TreeSocket::ServicePart(const std::string &prefix, std::deque<std::string>
        if (params.size() < 2)
                return true;
 
+       std::string reason = "Services forced part";
+
+       if (params.size() == 3)
+               reason = params[2];
+
        User* u = this->Instance->FindNick(params[0]);
        Channel* c = this->Instance->FindChan(params[1]);
 
@@ -42,7 +47,7 @@ bool TreeSocket::ServicePart(const std::string &prefix, std::deque<std::string>
        {
                /* only part if it's local, otherwise just pass it on! */
                if (IS_LOCAL(u))
-                       if (!c->PartUser(u, "Services forced part"))
+                       if (!c->PartUser(u, reason))
                                delete c;
                Utils->DoOneToAllButSender(prefix,"SVSPART",params,prefix);
        }