]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Release v3.0.0 alpha 5.
[user/henk/code/inspircd.git] / src / users.cpp
index f7cd00a07c539bdb149d5b74ce1ebc013ec0d086..41caa5c5a4b8a69cef4c8e6d97a5abc92cdc550c 100644 (file)
@@ -63,7 +63,7 @@ std::string User::GetModeLetters(bool includeparams) const
        return ret;
 }
 
-User::User(const std::string& uid, Server* srv, int type)
+User::User(const std::string& uid, Server* srv, UserType type)
        : age(ServerInstance->Time())
        , signon(0)
        , uuid(uid)
@@ -688,7 +688,7 @@ const std::string& User::GetRealHost() const
 
 irc::sockets::cidr_mask User::GetCIDRMask()
 {
-       int range = 0;
+       unsigned char range = 0;
        switch (client_sa.sa.sa_family)
        {
                case AF_INET6:
@@ -1018,15 +1018,27 @@ bool User::ChangeDisplayedHost(const std::string& shost)
 
 void User::ChangeRealHost(const std::string& host, bool resetdisplay)
 {
-       if (displayhost == host)
+       // If the real host is the new host and we are not resetting the
+       // display host then we have nothing to do.
+       const bool changehost = (realhost != host);
+       if (!changehost && !resetdisplay)
                return;
        
+       // If the displayhost is not set and we are not resetting it then
+       // we need to copy it to the displayhost field.
        if (displayhost.empty() && !resetdisplay)
                displayhost = realhost;
 
+       // If the displayhost is the new host or we are resetting it then
+       // we clear its contents to save memory.
        else if (displayhost == host || resetdisplay)
                displayhost.clear();
 
+       // If we are just resetting the display host then we don't need to
+       // do anything else.
+       if (!changehost)
+               return;
+
        realhost = host;
        this->InvalidateCache();
 }
@@ -1163,15 +1175,15 @@ void User::PurgeEmptyChannels()
 
 const std::string& FakeUser::GetFullHost()
 {
-       if (!ServerInstance->Config->HideWhoisServer.empty())
-               return ServerInstance->Config->HideWhoisServer;
+       if (!ServerInstance->Config->HideServer.empty())
+               return ServerInstance->Config->HideServer;
        return server->GetName();
 }
 
 const std::string& FakeUser::GetFullRealHost()
 {
-       if (!ServerInstance->Config->HideWhoisServer.empty())
-               return ServerInstance->Config->HideWhoisServer;
+       if (!ServerInstance->Config->HideServer.empty())
+               return ServerInstance->Config->HideServer;
        return server->GetName();
 }
 
@@ -1188,7 +1200,32 @@ ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, cons
        Update(&parent);
        name = "unnamed";
        type = t;
-       config = tag;
+       host = mask;
+
+       // Connect classes can inherit from each other but this is problematic for modules which can't use
+       // ConnectClass::Update so we build a hybrid tag containing all of the values set on this class as
+       // well as the parent class.
+       ConfigItems* items = NULL;
+       config = ConfigTag::create(tag->tag, tag->src_name, tag->src_line, items);
+
+       const ConfigItems& parentkeys = parent.config->getItems();
+       for (ConfigItems::const_iterator piter = parentkeys.begin(); piter != parentkeys.end(); ++piter)
+       {
+               // The class name and parent name are not inherited
+               if (piter->first == "name" || piter->first == "parent")
+                       continue;
+
+               // Store the item in the config tag. If this item also
+               // exists in the child it will be overwritten.
+               (*items)[piter->first] = piter->second;
+       }
+
+       const ConfigItems& childkeys = tag->getItems();
+       for (ConfigItems::const_iterator citer = childkeys.begin(); citer != childkeys.end(); ++citer)
+       {
+               // This will overwrite the parent value if present.
+               (*items)[citer->first] = citer->second;
+       }
 }
 
 void ConnectClass::Update(const ConnectClass* src)