+
+ if (IsHidden(user, child))
+ continue;
+
+ bool last = true;
+ for (TreeServer::ChildServers::const_iterator j = i + 1; last && j != servers.end(); ++j)
+ if (!IsHidden(user, *j))
+ last = false;
+
+ unsigned int next_len;
+
+ if (user->IsOper() || !Utils->FlatLinks)
+ {
+ // This child is indented by us, so remove the depth from the max length to align the users properly
+ next_len = max_len - 2;
+ }
+ else
+ {
+ // This user can not see depth, so max_len remains constant
+ next_len = max_len;
+ }
+
+ // Build the map for this child
+ std::vector<std::string> child_map = GetMap(user, child, next_len, depth + 1);
+
+ for (std::vector<std::string>::const_iterator j = child_map.begin(); j != child_map.end(); ++j)
+ {
+ const char* prefix;
+
+ if (user->IsOper() || !Utils->FlatLinks)
+ {
+ // If this server is not the root child
+ if (j != child_map.begin())
+ {
+ // If this child is not my last child, then add |
+ // to be able to "link" the next server in my list to me, and to indent this childs servers
+ if (!last)
+ prefix = "| ";
+ // Otherwise this is my last child, so just use a space as theres nothing else linked to me below this
+ else
+ prefix = " ";
+ }
+ // If we get here, this server must be the root child
+ else
+ {
+ // If this is the last child, it gets a `-
+ if (last)
+ prefix = "`-";
+ // Otherwise this isn't the last child, so it gets |-
+ else
+ prefix = "|-";
+ }
+ }
+ else
+ // User can't see depth, so use no prefix
+ prefix = "";
+
+ // Add line to the map
+ map.push_back(prefix + *j);