aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/pCampBot/BotManager.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Tools/pCampBot/BotManager.cs32
1 files changed, 17 insertions, 15 deletions
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index 704770a..f5dd5e0 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -51,7 +51,6 @@ namespace pCampBot
51 protected CommandConsole m_console; 51 protected CommandConsole m_console;
52 protected List<Bot> m_lBot; 52 protected List<Bot> m_lBot;
53 protected Random somthing = new Random(Environment.TickCount); 53 protected Random somthing = new Random(Environment.TickCount);
54 protected int numbots = 0;
55 public IConfig Config { get; private set; } 54 public IConfig Config { get; private set; }
56 55
57 /// <summary> 56 /// <summary>
@@ -137,7 +136,7 @@ namespace pCampBot
137 if (behaviourSwitches.Contains("g")) 136 if (behaviourSwitches.Contains("g"))
138 behaviours.Add(new GrabbingBehaviour()); 137 behaviours.Add(new GrabbingBehaviour());
139 138
140 startupBot(i, this, behaviours, firstName, lastName, password, loginUri); 139 StartBot(this, behaviours, firstName, lastName, password, loginUri);
141 } 140 }
142 } 141 }
143 142
@@ -157,22 +156,21 @@ namespace pCampBot
157// int newlen = len + botcount; 156// int newlen = len + botcount;
158// for (int i = len; i < newlen; i++) 157// for (int i = len; i < newlen; i++)
159// { 158// {
160// startupBot(i, Config); 159// startupBot(Config);
161// } 160// }
162// } 161// }
163 162
164 /// <summary> 163 /// <summary>
165 /// This starts up the bot and stores the thread for the bot in the thread array 164 /// This starts up the bot and stores the thread for the bot in the thread array
166 /// </summary> 165 /// </summary>
167 /// <param name="pos">The position in the thread array to stick the bot's thread</param>
168 /// <param name="bm"></param> 166 /// <param name="bm"></param>
169 /// <param name="behaviours">Behaviours for this bot to perform.</param> 167 /// <param name="behaviours">Behaviours for this bot to perform.</param>
170 /// <param name="firstName">First name</param> 168 /// <param name="firstName">First name</param>
171 /// <param name="lastName">Last name</param> 169 /// <param name="lastName">Last name</param>
172 /// <param name="password">Password</param> 170 /// <param name="password">Password</param>
173 /// <param name="loginUri">Login URI</param> 171 /// <param name="loginUri">Login URI</param>
174 public void startupBot( 172 public void StartBot(
175 int pos, BotManager bm, List<IBehaviour> behaviours, 173 BotManager bm, List<IBehaviour> behaviours,
176 string firstName, string lastName, string password, string loginUri) 174 string firstName, string lastName, string password, string loginUri)
177 { 175 {
178 Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri); 176 Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);
@@ -200,16 +198,17 @@ namespace pCampBot
200 { 198 {
201 case EventType.CONNECTED: 199 case EventType.CONNECTED:
202 m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected"); 200 m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected");
203 numbots++;
204// m_log.InfoFormat("NUMBOTS {0}", numbots);
205 break; 201 break;
206 case EventType.DISCONNECTED: 202 case EventType.DISCONNECTED:
207 m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected"); 203 m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected");
208 numbots--; 204
209// m_log.InfoFormat("NUMBOTS {0}", numbots); 205 lock (m_lBot)
210 if (numbots <= 0) 206 {
211 Environment.Exit(0); 207 if (m_lBot.TrueForAll(b => !b.IsConnected))
212 break; 208 Environment.Exit(0);
209
210 break;
211 }
213 } 212 }
214 } 213 }
215 214
@@ -234,8 +233,11 @@ namespace pCampBot
234 233
235 private void HandleShutdown(string module, string[] cmd) 234 private void HandleShutdown(string module, string[] cmd)
236 { 235 {
237 m_log.Warn("[BOTMANAGER]: Shutting down bots"); 236 Util.FireAndForget(o =>
238 doBotShutdown(); 237 {
238 m_log.Warn("[BOTMANAGER]: Shutting down bots");
239 doBotShutdown();
240 });
239 } 241 }
240 242
241 private void HandleShowStatus(string module, string[] cmd) 243 private void HandleShowStatus(string module, string[] cmd)