diff options
Diffstat (limited to 'OpenSim/Tools/pCampBot/BotManager.cs')
-rw-r--r-- | OpenSim/Tools/pCampBot/BotManager.cs | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 13912ae..5c3835b 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs | |||
@@ -203,13 +203,16 @@ namespace pCampBot | |||
203 | HandleStand); | 203 | HandleStand); |
204 | 204 | ||
205 | m_console.Commands.AddCommand( | 205 | m_console.Commands.AddCommand( |
206 | "bot", false, "set bots", "set bots <key> <value>", "Set a setting for all bots.", HandleSetBots); | ||
207 | |||
208 | m_console.Commands.AddCommand( | ||
206 | "bot", false, "show regions", "show regions", "Show regions known to bots", HandleShowRegions); | 209 | "bot", false, "show regions", "show regions", "Show regions known to bots", HandleShowRegions); |
207 | 210 | ||
208 | m_console.Commands.AddCommand( | 211 | m_console.Commands.AddCommand( |
209 | "bot", false, "show bots", "show bots", "Shows the status of all bots", HandleShowBotsStatus); | 212 | "bot", false, "show bots", "show bots", "Shows the status of all bots", HandleShowBotsStatus); |
210 | 213 | ||
211 | m_console.Commands.AddCommand( | 214 | m_console.Commands.AddCommand( |
212 | "bot", false, "show bot", "show bot <first-name> <last-name>", | 215 | "bot", false, "show bot", "show bot <n>", |
213 | "Shows the detailed status and settings of a particular bot.", HandleShowBotStatus); | 216 | "Shows the detailed status and settings of a particular bot.", HandleShowBotStatus); |
214 | 217 | ||
215 | m_bots = new List<Bot>(); | 218 | m_bots = new List<Bot>(); |
@@ -274,11 +277,11 @@ namespace pCampBot | |||
274 | connectBotThread.Start(); | 277 | connectBotThread.Start(); |
275 | } | 278 | } |
276 | 279 | ||
277 | private void ConnectBotsInternal(int botcount) | 280 | private void ConnectBotsInternal(int botCount) |
278 | { | 281 | { |
279 | MainConsole.Instance.OutputFormat( | 282 | MainConsole.Instance.OutputFormat( |
280 | "[BOT MANAGER]: Starting {0} bots connecting to {1}, location {2}, named {3} {4}_<n>", | 283 | "[BOT MANAGER]: Starting {0} bots connecting to {1}, location {2}, named {3} {4}_<n>", |
281 | botcount, | 284 | botCount, |
282 | m_loginUri, | 285 | m_loginUri, |
283 | m_startUri, | 286 | m_startUri, |
284 | m_firstName, | 287 | m_firstName, |
@@ -288,7 +291,9 @@ namespace pCampBot | |||
288 | MainConsole.Instance.OutputFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", InitBotSendAgentUpdates); | 291 | MainConsole.Instance.OutputFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", InitBotSendAgentUpdates); |
289 | MainConsole.Instance.OutputFormat("[BOT MANAGER]: InitBotRequestObjectTextures is {0}", InitBotRequestObjectTextures); | 292 | MainConsole.Instance.OutputFormat("[BOT MANAGER]: InitBotRequestObjectTextures is {0}", InitBotRequestObjectTextures); |
290 | 293 | ||
291 | for (int i = 0; i < botcount; i++) | 294 | int connectedBots = 0; |
295 | |||
296 | for (int i = 0; i < m_bots.Count; i++) | ||
292 | { | 297 | { |
293 | lock (m_bots) | 298 | lock (m_bots) |
294 | { | 299 | { |
@@ -299,11 +304,18 @@ namespace pCampBot | |||
299 | break; | 304 | break; |
300 | } | 305 | } |
301 | 306 | ||
302 | m_bots[i].Connect(); | 307 | if (m_bots[i].ConnectionState == ConnectionState.Disconnected) |
303 | } | 308 | { |
309 | m_bots[i].Connect(); | ||
310 | connectedBots++; | ||
304 | 311 | ||
305 | // Stagger logins | 312 | if (connectedBots >= botCount) |
306 | Thread.Sleep(LoginDelay); | 313 | break; |
314 | |||
315 | // Stagger logins | ||
316 | Thread.Sleep(LoginDelay); | ||
317 | } | ||
318 | } | ||
307 | } | 319 | } |
308 | 320 | ||
309 | ConnectingBots = false; | 321 | ConnectingBots = false; |
@@ -518,6 +530,30 @@ namespace pCampBot | |||
518 | Environment.Exit(0); | 530 | Environment.Exit(0); |
519 | } | 531 | } |
520 | 532 | ||
533 | private void HandleSetBots(string module, string[] cmd) | ||
534 | { | ||
535 | string key = cmd[2]; | ||
536 | string rawValue = cmd[3]; | ||
537 | |||
538 | if (key == "SEND_AGENT_UPDATES") | ||
539 | { | ||
540 | bool newSendAgentUpdatesSetting; | ||
541 | |||
542 | if (!ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, rawValue, out newSendAgentUpdatesSetting)) | ||
543 | return; | ||
544 | |||
545 | MainConsole.Instance.OutputFormat( | ||
546 | "Setting SEND_AGENT_UPDATES to {0} for all bots", newSendAgentUpdatesSetting); | ||
547 | |||
548 | lock (m_bots) | ||
549 | m_bots.ForEach(b => b.Client.Settings.SEND_AGENT_UPDATES = newSendAgentUpdatesSetting); | ||
550 | } | ||
551 | else | ||
552 | { | ||
553 | MainConsole.Instance.Output("Error: Only setting currently available is SEND_AGENT_UPDATES"); | ||
554 | } | ||
555 | } | ||
556 | |||
521 | private void HandleShowRegions(string module, string[] cmd) | 557 | private void HandleShowRegions(string module, string[] cmd) |
522 | { | 558 | { |
523 | string outputFormat = "{0,-30} {1, -20} {2, -5} {3, -5}"; | 559 | string outputFormat = "{0,-30} {1, -20} {2, -5} {3, -5}"; |
@@ -569,13 +605,18 @@ namespace pCampBot | |||
569 | 605 | ||
570 | private void HandleShowBotStatus(string module, string[] cmd) | 606 | private void HandleShowBotStatus(string module, string[] cmd) |
571 | { | 607 | { |
572 | if (cmd.Length != 4) | 608 | if (cmd.Length != 3) |
573 | { | 609 | { |
574 | MainConsole.Instance.Output("Usage: show bot <first-name> <last-name>"); | 610 | MainConsole.Instance.Output("Usage: show bot <n>"); |
575 | return; | 611 | return; |
576 | } | 612 | } |
577 | 613 | ||
578 | string name = string.Format("{0} {1}", cmd[2], cmd[3]); | 614 | int botNumber; |
615 | |||
616 | if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, cmd[2], out botNumber)) | ||
617 | return; | ||
618 | |||
619 | string name = string.Format("{0} {1}_{2}", m_firstName, m_lastNameStem, botNumber); | ||
579 | 620 | ||
580 | Bot bot; | 621 | Bot bot; |
581 | 622 | ||