]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
Fixed usercounts to not screw up on remote users
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index d6df39dbbab8ad49f184543c36a1b611fb983b78..ea7b1f9dc574c84ae7e482fad24eebb84b9a04d7 100644 (file)
@@ -36,7 +36,6 @@ using namespace std;
 #include <stdarg.h>
 #include "connection.h"
 #include "users.h"
-#include "servers.h"
 #include "ctables.h"
 #include "globals.h"
 #include "modules.h"
@@ -66,7 +65,7 @@ extern int LogLevel;
 
 extern std::stringstream config_f;
 
-extern serverrec* me[32];
+
 
 extern FILE *log_file;
 extern userrec* fd_ref_table[65536];
@@ -378,20 +377,16 @@ void ChanExceptSender(chanrec* Ptr, userrec* user, char* text, ...)
 
 std::string GetServerDescription(char* servername)
 {
-        for (int j = 0; j < 32; j++)
-        {
-                if (me[j] != NULL)
-                {
-                        for (unsigned int k = 0; k < me[j]->connectors.size(); k++)
-                        {
-                                if (!strcasecmp(me[j]->connectors[k].GetServerName().c_str(),servername))
-                                {
-                                        return me[j]->connectors[k].GetDescription();
-                                }
-                        }
-                }
-        }
-       return ServerDesc; // not a remote server that can be found, it must be me.
+       std::string description = "";
+       FOREACH_MOD OnGetServerDescription(servername,description);
+       if (description != "")
+       {
+               return description;
+       }
+       else
+       {
+               return ServerDesc; // not a remote server that can be found, it must be me.
+       }
 }
 
 /* write a formatted string to all users who share at least one common
@@ -1051,7 +1046,7 @@ int registered_usercount(void)
         int c = 0;
         for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
         {
-                if ((i->second->fd) && (isnick(i->second->nick))) c++;
+                if (i->second->registered == 7) c++;
         }
         return c;
 }
@@ -1059,10 +1054,9 @@ int registered_usercount(void)
 int usercount_invisible(void)
 {
         int c = 0;
-
         for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
         {
-                if ((i->second->fd) && (isnick(i->second->nick)) && (strchr(i->second->modes,'i'))) c++;
+                if ((isnick(i->second->nick)) && (strchr(i->second->modes,'i'))) c++;
         }
         return c;
 }
@@ -1070,10 +1064,9 @@ int usercount_invisible(void)
 int usercount_opers(void)
 {
         int c = 0;
-
         for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
         {
-                if ((i->second->fd) && (isnick(i->second->nick)) && (strchr(i->second->modes,'o'))) c++;
+                if ((isnick(i->second->nick)) && (strchr(i->second->modes,'o'))) c++;
         }
         return c;
 }
@@ -1097,21 +1090,7 @@ long chancount(void)
 
 long count_servs(void)
 {
-        int c = 0;
-        for (int i = 0; i < 32; i++)
-        {
-                if (me[i] != NULL)
-                {
-                        for (vector<ircd_connector>::iterator j = me[i]->connectors.begin(); j != me[i]->connectors.end(); j++)
-                        {
-                                if (strcasecmp(j->GetServerName().c_str(),ServerName))
-                                {
-                                        c++;
-                                }
-                        }
-                }
-        }
-        return c;
+        return 0;
 }
 
 long servercount(void)
@@ -1183,25 +1162,7 @@ bool AllModulesReportReady(userrec* user)
 
 char islast(const char* s)
 {
-        char c = '`';
-        for (int j = 0; j < 32; j++)
-        {
-                if (me[j] != NULL)
-                {
-                        for (unsigned int k = 0; k < me[j]->connectors.size(); k++)
-                        {
-                                if (strcasecmp(me[j]->connectors[k].GetServerName().c_str(),s))
-                                {
-                                        c = '|';
-                                }
-                                if (!strcasecmp(me[j]->connectors[k].GetServerName().c_str(),s))
-                                {
-                                        c = '`';
-                                }
-                        }
-                }
-        }
-        return c;
+        return '+';
 }
 
 long map_count(const char* s)