- return (" [Up: " + TimeToStr(secs_up) + " Lag: "+ConvToStr(Current->rtt)+"ms]");
-}
-
-// WARNING: NOT THREAD SAFE - DONT GET ANY SMART IDEAS.
-void ModuleSpanningTree::ShowMap(TreeServer* Current, User* user, int depth, char matrix[128][128], float &totusers, float &totservers)
-{
- if (line < 128)
- {
- for (int t = 0; t < depth; t++)
- {
- matrix[line][t] = ' ';
- }
- // For Aligning, we need to work out exactly how deep this thing is, and produce
- // a 'Spacer' String to compensate.
- char spacer[40];
- memset(spacer,' ',40);
- if ((40 - Current->GetName().length() - depth) > 1) {
- spacer[40 - Current->GetName().length() - depth] = '\0';
- }
- else
- {
- spacer[5] = '\0';
- }
- float percent;
- char text[128];
- /* Neat and tidy default values, as we're dealing with a matrix not a simple string */
- memset(text, 0, 128);
-
- if (ServerInstance->clientlist->size() == 0) {
- // If there are no users, WHO THE HELL DID THE /MAP?!?!?!
- percent = 0;
- }
- else
- {
- percent = ((float)Current->GetUserCount() / (float)ServerInstance->clientlist->size()) * 100;
- }
- const std::string operdata = IS_OPER(user) ? MapOperInfo(Current) : "";
- snprintf(text, 126, "%s %s%5d [%5.2f%%]%s", Current->GetName().c_str(), spacer, Current->GetUserCount(), percent, operdata.c_str());
- totusers += Current->GetUserCount();
- totservers++;
- strlcpy(&matrix[line][depth],text,126);
- line++;
- for (unsigned int q = 0; q < Current->ChildCount(); q++)
- {
- if ((Current->GetChild(q)->Hidden) || ((Utils->HideULines) && (ServerInstance->ULine(Current->GetChild(q)->GetName().c_str()))))
- {
- if (*user->oper)
- {
- ShowMap(Current->GetChild(q),user,(Utils->FlatLinks && (!*user->oper)) ? depth : depth+2,matrix,totusers,totservers);
- }
- }
- else
- {
- ShowMap(Current->GetChild(q),user,(Utils->FlatLinks && (!*user->oper)) ? depth : depth+2,matrix,totusers,totservers);
- }
+ return " [Up: " + TimeToStr(secs_up) + (Current->rtt == 0 ? "]" : " Lag: " + ConvToStr(Current->rtt) + "ms]");
+}
+
+void ModuleSpanningTree::ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats)
+{
+ ServerInstance->Logs->Log("map",DEBUG,"ShowMap depth %d on line %d", depth, line);
+ float percent;
+
+ if (ServerInstance->Users->clientlist->size() == 0)
+ {
+ // If there are no users, WHO THE HELL DID THE /MAP?!?!?!
+ percent = 0;
+ }
+ else
+ {
+ percent = Current->GetUserCount() * 100.0 / ServerInstance->Users->clientlist->size();
+ }
+
+ const std::string operdata = IS_OPER(user) ? MapOperInfo(Current) : "";
+
+ char* myname = names + 100 * line;
+ char* mystat = stats + 50 * line;
+ memset(myname, ' ', depth);
+ int w = depth;
+
+ std::string servername = Current->GetName();
+ if (IS_OPER(user))
+ {
+ w += snprintf(myname + depth, 99 - depth, "%s (%s)", servername.c_str(), Current->GetID().c_str());
+ }
+ else
+ {
+ w += snprintf(myname + depth, 99 - depth, "%s", servername.c_str());
+ }
+ memset(myname + w, ' ', 100 - w);
+ if (w > maxnamew)
+ maxnamew = w;
+ snprintf(mystat, 49, "%5d [%5.2f%%]%s", Current->GetUserCount(), percent, operdata.c_str());
+
+ line++;
+
+ if (IS_OPER(user) || !Utils->FlatLinks)
+ depth = depth + 2;
+ for (unsigned int q = 0; q < Current->ChildCount(); q++)
+ {
+ TreeServer* child = Current->GetChild(q);
+ if (!IS_OPER(user)) {
+ if (child->Hidden)
+ continue;
+ if ((Utils->HideULines) && (ServerInstance->ULine(child->GetName())))
+ continue;