]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Added /stats T
[user/henk/code/inspircd.git] / src / channels.cpp
index 379339c47c656c084cf9973b500d9ad51f51f4ee..fcc1c732d3d1912244fb4923c15d72576c1317bb 100644 (file)
@@ -104,6 +104,7 @@ extern serverrec* me[32];
 
 extern FILE *log_file;
 
+extern time_t TIME;
 
 using namespace std;
 
@@ -116,14 +117,15 @@ chanrec::chanrec()
        strcpy(topic,"");
        strcpy(setby,"");
        strcpy(key,"");
-       created = topicset = limit = 0;
+       created = topicset = limit = users = 0;
        topiclock = noexternal = inviteonly = moderated = secret = c_private = false;
+       internal_userlist.clear();
 }
 
 void chanrec::SetCustomMode(char mode,bool mode_on)
 {
        if (mode_on) {
-               char m[3];
+               static char m[3];
                m[0] = mode;
                m[1] = '\0';
                if (!strchr(this->custom_modes,mode))
@@ -196,3 +198,46 @@ std::string chanrec::GetModeParameter(char mode)
        }
        return std::string("");
 }
+
+void chanrec::IncUserCounter()
+{
+       this->users++;
+       log(DEBUG,"Incremented channel user count for %s to %lu",name,(unsigned long)users);
+}
+
+void chanrec::DecUserCounter()
+{
+       if (this->users > 0)
+               this->users--;
+       log(DEBUG,"Decremented channel user count for %s to %lu",name,(unsigned long)users);
+}
+
+long chanrec::GetUserCounter()
+{
+       return (this->users);
+}
+
+void chanrec::AddUser(char* castuser)
+{
+       internal_userlist.push_back(castuser);
+       log(DEBUG,"Added casted user to channel's internal list");
+}
+
+void chanrec::DelUser(char* castuser)
+{
+       for (std::vector<char*>::iterator a = internal_userlist.begin(); a < internal_userlist.end(); a++)
+       {
+               if (*a == castuser)
+               {
+                       log(DEBUG,"Removed casted user from channel's internal list");
+                       internal_userlist.erase(a);
+                       return;
+               }
+       }
+       log(DEBUG,"BUG BUG BUG! Attempt to remove an uncasted user from the internal list of %s!",name);
+}
+
+std::vector<char*> *chanrec::GetUsers()
+{
+       return &internal_userlist;
+}