diff options
-rw-r--r-- | OpenSim/Tools/pCampBot/BotManager.cs | 30 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/PhysicsBot.cs | 37 |
2 files changed, 45 insertions, 22 deletions
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index d2b7ded..b05bd6d 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs | |||
@@ -93,6 +93,11 @@ namespace pCampBot | |||
93 | "Shutdown bots and exit", | 93 | "Shutdown bots and exit", |
94 | HandleShutdown); | 94 | HandleShutdown); |
95 | 95 | ||
96 | m_console.Commands.AddCommand("bot", false, "show status", | ||
97 | "show status", | ||
98 | "Shows the status of all bots", | ||
99 | HandleShowStatus); | ||
100 | |||
96 | // m_console.Commands.AddCommand("bot", false, "add bots", | 101 | // m_console.Commands.AddCommand("bot", false, "add bots", |
97 | // "add bots <number>", | 102 | // "add bots <number>", |
98 | // "Add more bots", HandleAddBots); | 103 | // "Add more bots", HandleAddBots); |
@@ -157,7 +162,8 @@ namespace pCampBot | |||
157 | pb.OnConnected += handlebotEvent; | 162 | pb.OnConnected += handlebotEvent; |
158 | pb.OnDisconnected += handlebotEvent; | 163 | pb.OnDisconnected += handlebotEvent; |
159 | 164 | ||
160 | m_lBot.Add(pb); | 165 | lock (m_lBot) |
166 | m_lBot.Add(pb); | ||
161 | 167 | ||
162 | Thread pbThread = new Thread(pb.startup); | 168 | Thread pbThread = new Thread(pb.startup); |
163 | pbThread.Name = pb.Name; | 169 | pbThread.Name = pb.Name; |
@@ -194,10 +200,9 @@ namespace pCampBot | |||
194 | /// </summary> | 200 | /// </summary> |
195 | public void doBotShutdown() | 201 | public void doBotShutdown() |
196 | { | 202 | { |
197 | foreach (PhysicsBot pb in m_lBot) | 203 | lock (m_lBot) |
198 | { | 204 | foreach (PhysicsBot pb in m_lBot) |
199 | pb.shutdown(); | 205 | pb.shutdown(); |
200 | } | ||
201 | } | 206 | } |
202 | 207 | ||
203 | /// <summary> | 208 | /// <summary> |
@@ -215,6 +220,21 @@ namespace pCampBot | |||
215 | doBotShutdown(); | 220 | doBotShutdown(); |
216 | } | 221 | } |
217 | 222 | ||
223 | private void HandleShowStatus(string module, string[] cmd) | ||
224 | { | ||
225 | string outputFormat = "{0,-30} {1,-14}"; | ||
226 | MainConsole.Instance.OutputFormat(outputFormat, "Name", "Status"); | ||
227 | |||
228 | lock (m_lBot) | ||
229 | { | ||
230 | foreach (PhysicsBot pb in m_lBot) | ||
231 | { | ||
232 | MainConsole.Instance.OutputFormat( | ||
233 | outputFormat, pb.Name, (pb.IsConnected ? "Connected" : "Disconnected")); | ||
234 | } | ||
235 | } | ||
236 | } | ||
237 | |||
218 | /* | 238 | /* |
219 | private void HandleQuit(string module, string[] cmd) | 239 | private void HandleQuit(string module, string[] cmd) |
220 | { | 240 | { |
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 5bcd35d..14e9cca 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs | |||
@@ -51,6 +51,11 @@ namespace pCampBot | |||
51 | public BotManager BotManager { get; private set; } | 51 | public BotManager BotManager { get; private set; } |
52 | private IConfig startupConfig; // bot config, passed from BotManager | 52 | private IConfig startupConfig; // bot config, passed from BotManager |
53 | 53 | ||
54 | /// <summary> | ||
55 | /// Is this bot connected to the grid? | ||
56 | /// </summary> | ||
57 | public bool IsConnected { get; private set; } | ||
58 | |||
54 | public string FirstName { get; private set; } | 59 | public string FirstName { get; private set; } |
55 | public string LastName { get; private set; } | 60 | public string LastName { get; private set; } |
56 | public string Name { get; private set; } | 61 | public string Name { get; private set; } |
@@ -181,24 +186,23 @@ namespace pCampBot | |||
181 | 186 | ||
182 | if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) | 187 | if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) |
183 | { | 188 | { |
184 | if (OnConnected != null) | 189 | IsConnected = true; |
185 | { | 190 | |
186 | Thread.Sleep(somthing.Next(1000, 10000)); | 191 | Thread.Sleep(somthing.Next(1000, 10000)); |
187 | m_actionThread = new Thread(Action); | 192 | m_actionThread = new Thread(Action); |
188 | m_actionThread.Start(); | 193 | m_actionThread.Start(); |
189 | 194 | ||
190 | // OnConnected(this, EventType.CONNECTED); | 195 | // OnConnected(this, EventType.CONNECTED); |
191 | if (wear == "save") | 196 | if (wear == "save") |
192 | { | 197 | { |
193 | client.Appearance.SetPreviousAppearance(); | 198 | client.Appearance.SetPreviousAppearance(); |
194 | SaveDefaultAppearance(); | 199 | SaveDefaultAppearance(); |
195 | } | ||
196 | else if (wear != "no") | ||
197 | { | ||
198 | MakeDefaultAppearance(wear); | ||
199 | } | ||
200 | client.Self.Jump(true); | ||
201 | } | 200 | } |
201 | else if (wear != "no") | ||
202 | { | ||
203 | MakeDefaultAppearance(wear); | ||
204 | } | ||
205 | client.Self.Jump(true); | ||
202 | } | 206 | } |
203 | else | 207 | else |
204 | { | 208 | { |
@@ -392,8 +396,6 @@ namespace pCampBot | |||
392 | { | 396 | { |
393 | // m_log.ErrorFormat("Fired Network_OnDisconnected"); | 397 | // m_log.ErrorFormat("Fired Network_OnDisconnected"); |
394 | 398 | ||
395 | // Only pass on the disconnect message when we receive a SimShutdown type shutdown. We have to ignore | ||
396 | // the earlier ClientInitiated shutdown callback. | ||
397 | // if ( | 399 | // if ( |
398 | // (args.Reason == NetworkManager.DisconnectType.SimShutdown | 400 | // (args.Reason == NetworkManager.DisconnectType.SimShutdown |
399 | // || args.Reason == NetworkManager.DisconnectType.NetworkTimeout) | 401 | // || args.Reason == NetworkManager.DisconnectType.NetworkTimeout) |
@@ -406,6 +408,7 @@ namespace pCampBot | |||
406 | && OnDisconnected != null) | 408 | && OnDisconnected != null) |
407 | // if (OnDisconnected != null) | 409 | // if (OnDisconnected != null) |
408 | { | 410 | { |
411 | IsConnected = false; | ||
409 | OnDisconnected(this, EventType.DISCONNECTED); | 412 | OnDisconnected(this, EventType.DISCONNECTED); |
410 | } | 413 | } |
411 | } | 414 | } |