aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/pCampBot/BotManager.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-08-14 16:51:51 +0100
committerJustin Clark-Casey (justincc)2013-08-14 16:51:51 +0100
commit2146b201694a128764e66680d151b68d83610880 (patch)
tree2cd2d1edf438fe3b060fa399ac8a1c87000e70a5 /OpenSim/Tools/pCampBot/BotManager.cs
parentBulletSim: move the creation of the avatar movement actor creating to (diff)
downloadopensim-SC_OLD-2146b201694a128764e66680d151b68d83610880.zip
opensim-SC_OLD-2146b201694a128764e66680d151b68d83610880.tar.gz
opensim-SC_OLD-2146b201694a128764e66680d151b68d83610880.tar.bz2
opensim-SC_OLD-2146b201694a128764e66680d151b68d83610880.tar.xz
Add the ability to explicitly specify a login start location to pCampbot via the -start parameter
Diffstat (limited to '')
-rw-r--r--OpenSim/Tools/pCampBot/BotManager.cs60
1 files changed, 52 insertions, 8 deletions
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index 16b02b9..57bd737 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -65,7 +65,7 @@ namespace pCampBot
65 /// <summary> 65 /// <summary>
66 /// Controls whether bots start out sending agent updates on connection. 66 /// Controls whether bots start out sending agent updates on connection.
67 /// </summary> 67 /// </summary>
68 public bool BotsInitSendAgentUpdates { get; set; } 68 public bool InitBotSendAgentUpdates { get; set; }
69 69
70 /// <summary> 70 /// <summary>
71 /// Created bots, whether active or inactive. 71 /// Created bots, whether active or inactive.
@@ -92,7 +92,7 @@ namespace pCampBot
92 /// </summary> 92 /// </summary>
93 public BotManager() 93 public BotManager()
94 { 94 {
95 BotsInitSendAgentUpdates = true; 95 InitBotSendAgentUpdates = true;
96 96
97 LoginDelay = DefaultLoginDelay; 97 LoginDelay = DefaultLoginDelay;
98 98
@@ -156,21 +156,25 @@ namespace pCampBot
156 string lastNameStem = startupConfig.GetString("lastname"); 156 string lastNameStem = startupConfig.GetString("lastname");
157 string password = startupConfig.GetString("password"); 157 string password = startupConfig.GetString("password");
158 string loginUri = startupConfig.GetString("loginuri"); 158 string loginUri = startupConfig.GetString("loginuri");
159 string startLocation = startupConfig.GetString("start", "last");
159 string wearSetting = startupConfig.GetString("wear", "no"); 160 string wearSetting = startupConfig.GetString("wear", "no");
160 161
162 string startUri = ParseInputStartLocationToUri(startLocation);
163
161 HashSet<string> behaviourSwitches = new HashSet<string>(); 164 HashSet<string> behaviourSwitches = new HashSet<string>();
162 Array.ForEach<string>( 165 Array.ForEach<string>(
163 startupConfig.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b)); 166 startupConfig.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
164 167
165 MainConsole.Instance.OutputFormat( 168 MainConsole.Instance.OutputFormat(
166 "[BOT MANAGER]: Starting {0} bots connecting to {1}, named {2} {3}_<n>", 169 "[BOT MANAGER]: Starting {0} bots connecting to {1}, location {2}, named {3} {4}_<n>",
167 botcount, 170 botcount,
168 loginUri, 171 loginUri,
172 startUri,
169 firstName, 173 firstName,
170 lastNameStem); 174 lastNameStem);
171 175
172 MainConsole.Instance.OutputFormat("[BOT MANAGER]: Delay between logins is {0}ms", LoginDelay); 176 MainConsole.Instance.OutputFormat("[BOT MANAGER]: Delay between logins is {0}ms", LoginDelay);
173 MainConsole.Instance.OutputFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", BotsInitSendAgentUpdates); 177 MainConsole.Instance.OutputFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", InitBotSendAgentUpdates);
174 178
175 for (int i = 0; i < botcount; i++) 179 for (int i = 0; i < botcount; i++)
176 { 180 {
@@ -195,8 +199,47 @@ namespace pCampBot
195 if (behaviourSwitches.Contains("t")) 199 if (behaviourSwitches.Contains("t"))
196 behaviours.Add(new TeleportBehaviour()); 200 behaviours.Add(new TeleportBehaviour());
197 201
198 StartBot(this, behaviours, firstName, lastName, password, loginUri, wearSetting); 202 StartBot(this, behaviours, firstName, lastName, password, loginUri, startUri, wearSetting);
203 }
204 }
205
206 /// <summary>
207 /// Parses the command line start location to a start string/uri that the login mechanism will recognize.
208 /// </summary>
209 /// <returns>
210 /// The input start location to URI.
211 /// </returns>
212 /// <param name='startLocation'>
213 /// Start location.
214 /// </param>
215 private string ParseInputStartLocationToUri(string startLocation)
216 {
217 if (startLocation == "home" || startLocation == "last")
218 return startLocation;
219
220 string regionName;
221
222 // Just a region name or only one (!) extra component. Like a viewer, we will stick 128/128/0 on the end
223 Vector3 startPos = new Vector3(128, 128, 0);
224
225 string[] startLocationComponents = startLocation.Split('/');
226
227 regionName = startLocationComponents[0];
228
229 if (startLocationComponents.Length >= 2)
230 {
231 float.TryParse(startLocationComponents[1], out startPos.X);
232
233 if (startLocationComponents.Length >= 3)
234 {
235 float.TryParse(startLocationComponents[2], out startPos.Y);
236
237 if (startLocationComponents.Length >= 4)
238 float.TryParse(startLocationComponents[3], out startPos.Z);
239 }
199 } 240 }
241
242 return string.Format("uri:{0}&{1}&{2}&{3}", regionName, startPos.X, startPos.Y, startPos.Z);
200 } 243 }
201 244
202// /// <summary> 245// /// <summary>
@@ -228,18 +271,19 @@ namespace pCampBot
228 /// <param name="lastName">Last name</param> 271 /// <param name="lastName">Last name</param>
229 /// <param name="password">Password</param> 272 /// <param name="password">Password</param>
230 /// <param name="loginUri">Login URI</param> 273 /// <param name="loginUri">Login URI</param>
274 /// <param name="startLocation">Location to start the bot. Can be "last", "home" or a specific sim name.</param>
231 /// <param name="wearSetting"></param> 275 /// <param name="wearSetting"></param>
232 public void StartBot( 276 public void StartBot(
233 BotManager bm, List<IBehaviour> behaviours, 277 BotManager bm, List<IBehaviour> behaviours,
234 string firstName, string lastName, string password, string loginUri, string wearSetting) 278 string firstName, string lastName, string password, string loginUri, string startLocation, string wearSetting)
235 { 279 {
236 MainConsole.Instance.OutputFormat( 280 MainConsole.Instance.OutputFormat(
237 "[BOT MANAGER]: Starting bot {0} {1}, behaviours are {2}", 281 "[BOT MANAGER]: Starting bot {0} {1}, behaviours are {2}",
238 firstName, lastName, string.Join(",", behaviours.ConvertAll<string>(b => b.Name).ToArray())); 282 firstName, lastName, string.Join(",", behaviours.ConvertAll<string>(b => b.Name).ToArray()));
239 283
240 Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri); 284 Bot pb = new Bot(bm, behaviours, firstName, lastName, password, startLocation, loginUri);
241 pb.wear = wearSetting; 285 pb.wear = wearSetting;
242 pb.Client.Settings.SEND_AGENT_UPDATES = BotsInitSendAgentUpdates; 286 pb.Client.Settings.SEND_AGENT_UPDATES = InitBotSendAgentUpdates;
243 287
244 pb.OnConnected += handlebotEvent; 288 pb.OnConnected += handlebotEvent;
245 pb.OnDisconnected += handlebotEvent; 289 pb.OnDisconnected += handlebotEvent;