]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Tidy up some of the internals a bit, making things a bit more extensible and future...
[user/henk/code/inspircd.git] / src / users.cpp
index b749b4788f9aab419b2ee497895fcfaeaa293610..01a973deae90a7b444736f0572cdc25b78377a8b 100644 (file)
@@ -158,16 +158,28 @@ void User::SetMode(unsigned char m, bool value)
        modes[m-65] = value;
 }
 
-const char* User::FormatModes()
+const char* User::FormatModes(bool showparameters)
 {
        static char data[MAXBUF];
+       std::string params;
        int offset = 0;
-       for (int n = 0; n < 64; n++)
+
+       for (unsigned char n = 0; n < 64; n++)
        {
                if (modes[n])
-                       data[offset++] = n+65;
+               {
+                       data[offset++] = n + 65;
+                       ModeHandler* mh = ServerInstance->Modes->FindMode(n + 65, MODETYPE_USER);
+                       if (showparameters && mh && mh->GetNumParams(true))
+                       {
+                               std::string p = mh->GetUserParameter(this);
+                               if (p.length())
+                                       params.append(" ").append(p);
+                       }
+               }
        }
        data[offset] = 0;
+       strlcat(data, params.c_str(), MAXBUF);
        return data;
 }
 
@@ -204,7 +216,6 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance
        Visibility = NULL;
        ip = NULL;
        MyClass = NULL;
-       io = NULL;
        AllowedUserModes = NULL;
        AllowedChanModes = NULL;
        AllowedOperCommands = NULL;
@@ -1268,14 +1279,14 @@ void User::Write(std::string text)
                return;
        }
 
-       if (this->io)
+       if (this->GetIOHook())
        {
                /* XXX: The lack of buffering here is NOT a bug, modules implementing this interface have to
                 * implement their own buffering mechanisms
                 */
                try
                {
-                       this->io->OnRawSocketWrite(this->fd, text.data(), text.length());
+                       this->GetIOHook()->OnRawSocketWrite(this->fd, text.data(), text.length());
                }
                catch (CoreException& modexcept)
                {