X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusers.cpp;h=41caa5c5a4b8a69cef4c8e6d97a5abc92cdc550c;hb=e336c3dfa9be7fd2f571b58f03745e23f4544513;hp=c2ff9c5be0f97444d3b57e5b7ae8502d662cdac0;hpb=36040be2952186d56a6646ee7d972aaafdd4e31a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/users.cpp b/src/users.cpp index c2ff9c5be..41caa5c5a 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -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)