]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
Fixed /connect bug
[user/henk/code/inspircd.git] / src / inspircd.cpp
index 1b1da19ad2b83077d24b04cb5b4be47041093eae..e5a47fde3681fbc9d5b87eecbb6dec862a0d1137 100644 (file)
@@ -4903,23 +4903,45 @@ int usercount_unknown(void)
        return c;
 }
 
-int chancount(void)
+long chancount(void)
 {
        return chanlist.size();
 }
 
-int servercount(void)
+long count_servs(void)
 {
-       return 1;
+       int c = 0;
+       for (int j = 0; j < 255; j++)
+       {
+               if (servers[j] != NULL)
+                       c++;
+       }
+       return c;
+}
+
+long servercount(void)
+{
+       return count_servs()+1;
 }
 
+long local_count()
+{
+       int c = 0;
+       for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
+       {
+               if ((i->second->fd) && (isnick(i->second->nick)) && (!strcasecmp(i->second->server,ServerName))) c++;
+       }
+       return c;
+}
+
+
 void handle_lusers(char **parameters, int pcnt, userrec *user)
 {
        WriteServ(user->fd,"251 %s :There are %d users and %d invisible on %d servers",user->nick,usercnt()-usercount_invisible(),usercount_invisible(),servercount());
        WriteServ(user->fd,"252 %s %d :operator(s) online",user->nick,usercount_opers());
        WriteServ(user->fd,"253 %s %d :unknown connections",user->nick,usercount_unknown());
        WriteServ(user->fd,"254 %s %d :channels formed",user->nick,chancount());
-       WriteServ(user->fd,"254 %s :I have %d clients and 0 servers",user->nick,usercnt());
+       WriteServ(user->fd,"254 %s :I have %d clients and %d servers",user->nick,local_count(),count_servs());
 }
 
 void handle_admin(char **parameters, int pcnt, userrec *user)
@@ -5320,6 +5342,7 @@ void handle_connect(char **parameters, int pcnt, userrec *user)
                LinkPort = atoi(Link_Port);
                if (match(Link_ServerName,parameters[0])) {
                        found = true;
+                       break;
                }
        }
        
@@ -5340,6 +5363,7 @@ void handle_connect(char **parameters, int pcnt, userrec *user)
                for (int j = 0; j < 255; j++) {
                        if (servers[j] == NULL) {
                                servers[j] = new serverrec;
+                               //servers[j]->initiator = true;
                                strcpy(servers[j]->internal_addr,Link_IPAddr);
                                servers[j]->internal_port = LinkPort;
                                strcpy(servers[j]->name,Link_ServerName);
@@ -5386,7 +5410,7 @@ long map_count(serverrec* s)
        int c = 0;
        for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
        {
-               if ((i->second->fd) && (isnick(i->second->nick)) && (strcasecmp(i->second->server,s->name))) c++;
+               if ((i->second->fd) && (isnick(i->second->nick)) && (!strcasecmp(i->second->server,s->name))) c++;
        }
        return c;
 }
@@ -5406,16 +5430,19 @@ void handle_links(char **parameters, int pcnt, userrec *user)
 
 void handle_map(char **parameters, int pcnt, userrec *user)
 {
-       WriteServ(user->fd,"006 %s :%s",user->nick,ServerName);
+       char line[MAXBUF];
+       snprintf(line,MAXBUF,"006 %s :%s",user->nick,ServerName);
+       while (strlen(line) < 50)
+               strcat(line," ");
+       WriteServ(user->fd,"%s%d (%.2f%%)",line,local_count(),(float)(((float)local_count()/(float)usercnt())*100));
        for (int j = 0; j < 255; j++)
        {
                if (servers[j] != NULL)
                {
-                       char line[MAXBUF];
                        snprintf(line,MAXBUF,"006 %s :%c-%s",user->nick,islast(servers[j]),servers[j]->name);
-                       while (strlen(line) < 40)
+                       while (strlen(line) < 50)
                                strcat(line," ");
-                       WriteServ(user->fd,"%s%d",line,map_count(servers[j]));
+                       WriteServ(user->fd,"%s%d (%.2f%%)",line,map_count(servers[j]),(float)(((float)map_count(servers[j])/(float)usercnt())*100));
                }
        }
        WriteServ(user->fd,"007 %s :End of /MAP",user->nick);
@@ -6536,6 +6563,7 @@ void handle_link_packet(long theirkey, char* udp_msg, char* udp_host, int udp_po
                                                                strcpy(servers[j]->description,serverdesc);
                                                                servers[j]->internal_port = udp_port;
                                                                // create a server record for this server
+                                                               WriteOpers("Server %s authenticated, exchanging server keys...",servername);
                                                                snprintf(response,10240,"O %d",MyKey);
                                                                serv->SendPacket(response,udp_host,udp_port,0);
                                                                return;
@@ -6868,7 +6896,7 @@ int InspIRCd(void)
        {
 
                fd_set sfd;
-               struct timeval tval;
+               timeval tval;
                FD_ZERO(&sfd);
 
                user_hash::iterator count2 = clientlist.begin();