]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree.cpp
Added <oper:swhois> to m_swhois, which will override <type:swhois> if specified
[user/henk/code/inspircd.git] / src / modules / m_spanningtree.cpp
index 3fcf5e5a2316a5c5dcccb9b78f768fa6d1be380d..ae68115c5074a61c6c9c0b97663707fb696f3bc7 100644 (file)
 
 /** If you make a change which breaks the protocol, increment this.
  * If you  completely change the protocol, completely change the number.
+ *
+ * IMPORTANT: If you make changes, document your changes here, without fail:
+ * http://www.inspircd.org/wiki/List_of_protocol_changes_between_versions
+ *
+ * Failure to document your protocol changes will result in a painfully
+ * painful death by pain. You have been warned.
  */
-const long ProtocolVersion = 1101;
+const long ProtocolVersion = 1102;
 
 /*
  * The server list in InspIRCd is maintained as two structures
@@ -1921,6 +1927,25 @@ class TreeSocket : public InspSocket
                if (numusers)
                        buffer.append(list).append("\r\n");
 
+               /* Sorry for the hax. Because newly created channels assume +nt,
+                * if this channel doesnt have +nt, explicitly send -n and -t for the missing modes.
+                */
+               bool inverted = false;
+               if (!c->IsModeSet('n'))
+               {
+                       modes.append("-n");
+                       inverted = true;
+               }
+               if (!c->IsModeSet('t'))
+               {
+                       modes.append("-t");
+                       inverted = true;
+               }
+               if (inverted)
+               {
+                       modes.append("+");
+               }
+
                for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++)
                {
                        modes.append("b");
@@ -4132,14 +4157,33 @@ class ModuleSpanningTree : public Module
                if (n_users > max_global)
                        max_global = n_users;
 
-               user->WriteServ("251 %s :There are %d users and %d invisible on %d servers",user->nick,n_users-ServerInstance->InvisibleUserCount(),ServerInstance->InvisibleUserCount(),this->CountServs());
+               unsigned int ulined_count = 0;
+               unsigned int ulined_local_count = 0;
+
+               /* If ulined are hidden and we're not an oper, count the number of ulined servers hidden,
+                * locally and globally (locally means directly connected to us)
+                */
+               if ((Utils->HideULines) && (!*user->oper))
+               {
+                       for (server_hash::iterator q = Utils->serverlist.begin(); q != Utils->serverlist.end(); q++)
+                       {
+                               if (ServerInstance->ULine(q->second->GetName().c_str()))
+                               {
+                                       ulined_count++;
+                                       if (q->second->GetParent() == Utils->TreeRoot)
+                                               ulined_local_count++;
+                               }
+                       }
+               }
+
+               user->WriteServ("251 %s :There are %d users and %d invisible on %d servers",user->nick,n_users-ServerInstance->InvisibleUserCount(),ServerInstance->InvisibleUserCount(),ulined_count ? this->CountServs() - ulined_count : this->CountServs());
                if (ServerInstance->OperCount())
                        user->WriteServ("252 %s %d :operator(s) online",user->nick,ServerInstance->OperCount());
                if (ServerInstance->UnregisteredUserCount())
                        user->WriteServ("253 %s %d :unknown connections",user->nick,ServerInstance->UnregisteredUserCount());
                if (ServerInstance->ChannelCount())
                        user->WriteServ("254 %s %d :channels formed",user->nick,ServerInstance->ChannelCount());
-               user->WriteServ("254 %s :I have %d clients and %d servers",user->nick,ServerInstance->LocalUserCount(),this->CountLocalServs());
+               user->WriteServ("254 %s :I have %d clients and %d servers",user->nick,ServerInstance->LocalUserCount(),ulined_local_count ? this->CountLocalServs() - ulined_local_count : this->CountLocalServs());
                user->WriteServ("265 %s :Current Local Users: %d  Max: %d",user->nick,ServerInstance->LocalUserCount(),max_local);
                user->WriteServ("266 %s :Current Global Users: %d  Max: %d",user->nick,n_users,max_global);
                return;
@@ -4842,6 +4886,14 @@ class ModuleSpanningTree : public Module
                        params.push_back(ConvToStr(channel->age));
                        params.push_back(std::string(channel->GetAllPrefixChars(user))+","+std::string(user->nick));
                        Utils->DoOneToMany(ServerInstance->Config->ServerName,"FJOIN",params);
+                       if (channel->GetUserCounter() == 1)
+                       {
+                               /* First user in, sync the modes for the channel */
+                               params.pop_back();
+                               /* This is safe, all inspircd servers default to +nt */
+                               params.push_back("+nt");
+                               Utils->DoOneToMany(ServerInstance->Config->ServerName,"FMODE",params);
+                       }
                }
        }