- matrix[t][0] = '\0';
- }
-
- line = 0;
-
- // The only recursive bit is called here.
- ShowMap(Utils->TreeRoot,user,0,matrix,totusers,totservers);
-
- // Process each line one by one. The algorithm has a limit of
- // 128 servers (which is far more than a spanning tree should have
- // anyway, so we're ok). This limit can be raised simply by making
- // the character matrix deeper, 128 rows taking 10k of memory.
- for (int l = 1; l < line; l++)
- {
- // scan across the line looking for the start of the
- // servername (the recursive part of the algorithm has placed
- // the servers at indented positions depending on what they
- // are related to)
- int first_nonspace = 0;
-
- while (matrix[l][first_nonspace] == ' ')
- {
- first_nonspace++;
- }
-
- first_nonspace--;
-
- // Draw the `- (corner) section: this may be overwritten by
- // another L shape passing along the same vertical pane, becoming
- // a |- (branch) section instead.
-
- matrix[l][first_nonspace] = '-';
- matrix[l][first_nonspace-1] = '`';
- int l2 = l - 1;
-
- // Draw upwards until we hit the parent server, causing possibly
- // other corners (`-) to become branches (|-)
- while ((matrix[l2][first_nonspace-1] == ' ') || (matrix[l2][first_nonspace-1] == '`'))
- {
- matrix[l2][first_nonspace-1] = '|';
- l2--;
- }
- }
-
- float avg_users = totusers / totservers;
-
- // dump the whole lot to the user.
- if (IS_LOCAL(user))
- {
- ServerInstance->Logs->Log("map",DEBUG,"local");
- for (int t = 0; t < line; t++)
- {
- user->WriteNumeric(6, "%s :%s",user->nick.c_str(),&matrix[t][0]);
- }
- user->WriteNumeric(270, "%s :%.0f server%s and %.0f user%s, average %.2f users per server",user->nick.c_str(),totservers,(totservers > 1 ? "s" : ""),totusers,(totusers > 1 ? "s" : ""),avg_users);
- user->WriteNumeric(7, "%s :End of /MAP",user->nick.c_str());