Make show bots pCampbot console command print connected, connecting, etc. bot totals at end.

0.7.6-extended
Justin Clark-Casey (justincc) 2013-08-12 22:49:17 +01:00
parent 377fe63c60
commit c49ea491a3
1 changed files with 13 additions and 0 deletions

View File

@ -330,17 +330,30 @@ namespace pCampBot
string outputFormat = "{0,-30} {1, -30} {2,-14}"; string outputFormat = "{0,-30} {1, -30} {2,-14}";
MainConsole.Instance.OutputFormat(outputFormat, "Name", "Region", "Status"); MainConsole.Instance.OutputFormat(outputFormat, "Name", "Region", "Status");
Dictionary<ConnectionState, int> totals = new Dictionary<ConnectionState, int>();
foreach (object o in Enum.GetValues(typeof(ConnectionState)))
totals[(ConnectionState)o] = 0;
lock (m_lBot) lock (m_lBot)
{ {
foreach (Bot pb in m_lBot) foreach (Bot pb in m_lBot)
{ {
Simulator currentSim = pb.Client.Network.CurrentSim; Simulator currentSim = pb.Client.Network.CurrentSim;
totals[pb.ConnectionState]++;
MainConsole.Instance.OutputFormat( MainConsole.Instance.OutputFormat(
outputFormat, outputFormat,
pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.ConnectionState); pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.ConnectionState);
} }
} }
ConsoleDisplayList cdl = new ConsoleDisplayList();
foreach (KeyValuePair<ConnectionState, int> kvp in totals)
cdl.AddRow(kvp.Key, kvp.Value);
MainConsole.Instance.OutputFormat("\n{0}", cdl.ToString());
} }
/* /*