]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Made it compile :p
[user/henk/code/inspircd.git] / src / users.cpp
index 83800e01d7e65d42a2f1765e9c79012a18c6f019..13146a08653709414942cd8160d37afd05f8fdbf 100644 (file)
@@ -107,16 +107,29 @@ userrec::userrec()
        server = (char*)FindServerNamePtr(Config->ServerName);
        reset_due = TIME;
        lines_in = fd = lastping = signon = idle_lastmsg = nping = registered = 0;
-       timeout = flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
+       modebits = timeout = flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
        haspassed = dns_done = false;
        recvq = "";
        sendq = "";
        chans.clear();
        invites.clear();
+        chans.resize(MAXCHANS);
+        for (unsigned int n = 0; n < MAXCHANS; n++)
+        {
+               ucrec* x = new ucrec();
+               chans[n] = x;
+               x->channel = NULL;
+               x->uc_modes = 0;
+        }
 }
 
 userrec::~userrec()
 {
+       for (std::vector<ucrec*>::iterator n = chans.begin(); n != chans.end(); n++)
+       {
+               ucrec* x = (ucrec*)*n;
+               delete x;
+       }
 }
 
 void userrec::MakeHost(char* nhost)
@@ -233,7 +246,7 @@ void userrec::RemoveInvite(irc::string &channel)
                }
 }
 
-bool userrec::HasPermission(std::string &command)
+bool userrec::HasPermission(const std::string &command)
 {
        char* mycmd;
        char* savept;
@@ -282,7 +295,7 @@ bool userrec::HasPermission(std::string &command)
 }
 
 
-bool userrec::AddBuffer(std::string a)
+bool userrec::AddBuffer(const std::string &a)
 {
         std::string b = "";
        char* n = (char*)a.c_str();
@@ -342,9 +355,9 @@ std::string userrec::GetBuffer()
         return ret;
 }
 
-void userrec::AddWriteBuf(std::string data)
+void userrec::AddWriteBuf(const std::string &data)
 {
-       if (this->GetWriteError() != "")
+       if (*this->GetWriteError())
                return;
        if (sendq.length() + data.length() > (unsigned)this->sendqmax)
        {
@@ -384,7 +397,7 @@ void userrec::FlushWriteBuf()
        }
 }
 
-void userrec::SetWriteError(std::string error)
+void userrec::SetWriteError(const std::string &error)
 {
        log(DEBUG,"Setting error string for %s to '%s'",this->nick,error.c_str());
        // don't try to set the error twice, its already set take the first string.
@@ -392,9 +405,9 @@ void userrec::SetWriteError(std::string error)
                this->WriteError = error;
 }
 
-std::string userrec::GetWriteError()
+const char* userrec::GetWriteError()
 {
-       return this->WriteError;
+       return this->WriteError.c_str();
 }
 
 void AddOper(userrec* user)
@@ -518,6 +531,8 @@ void AddWhoWas(userrec* u)
                whowas_set* group = (whowas_set*)iter->second;
                if (group->size() > 10)
                {
+                       WhoWasGroup *a = (WhoWasGroup*)*(group->begin());
+                       delete a;
                        group->pop_front();
                }
                WhoWasGroup *a = new WhoWasGroup(u);
@@ -614,11 +629,6 @@ void AddClient(int socket, int port, bool iscached, in_addr ip4)
         clientlist[tempnick]->sendqmax = class_sqmax;
         clientlist[tempnick]->recvqmax = class_rqmax;
 
-        ucrec a;
-        a.channel = NULL;
-        a.uc_modes = 0;
-       clientlist[tempnick]->chans.resize(MAXCHANS);
-
        fd_ref_table[socket] = clientlist[tempnick];
        local_users.push_back(clientlist[tempnick]);
 
@@ -839,4 +849,3 @@ void force_nickchange(userrec* user,const char* newnick)
                 }
         }
 }
-