diff options
author | Justin Clark-Casey (justincc) | 2013-08-14 16:51:51 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-08-14 16:51:51 +0100 |
commit | 2146b201694a128764e66680d151b68d83610880 (patch) | |
tree | 2cd2d1edf438fe3b060fa399ac8a1c87000e70a5 | |
parent | BulletSim: move the creation of the avatar movement actor creating to (diff) | |
download | opensim-SC-2146b201694a128764e66680d151b68d83610880.zip opensim-SC-2146b201694a128764e66680d151b68d83610880.tar.gz opensim-SC-2146b201694a128764e66680d151b68d83610880.tar.bz2 opensim-SC-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/Bot.cs | 7 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/BotManager.cs | 60 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/pCampBot.cs | 36 |
3 files changed, 76 insertions, 27 deletions
diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index c56d29b..79344e8 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs | |||
@@ -97,6 +97,8 @@ namespace pCampBot | |||
97 | public string Name { get; private set; } | 97 | public string Name { get; private set; } |
98 | public string Password { get; private set; } | 98 | public string Password { get; private set; } |
99 | public string LoginUri { get; private set; } | 99 | public string LoginUri { get; private set; } |
100 | public string StartLocation { get; private set; } | ||
101 | |||
100 | public string saveDir; | 102 | public string saveDir; |
101 | public string wear; | 103 | public string wear; |
102 | 104 | ||
@@ -132,7 +134,7 @@ namespace pCampBot | |||
132 | /// <param name="behaviours"></param> | 134 | /// <param name="behaviours"></param> |
133 | public Bot( | 135 | public Bot( |
134 | BotManager bm, List<IBehaviour> behaviours, | 136 | BotManager bm, List<IBehaviour> behaviours, |
135 | string firstName, string lastName, string password, string loginUri) | 137 | string firstName, string lastName, string password, string startLocation, string loginUri) |
136 | { | 138 | { |
137 | ConnectionState = ConnectionState.Disconnected; | 139 | ConnectionState = ConnectionState.Disconnected; |
138 | 140 | ||
@@ -146,6 +148,7 @@ namespace pCampBot | |||
146 | Name = string.Format("{0} {1}", FirstName, LastName); | 148 | Name = string.Format("{0} {1}", FirstName, LastName); |
147 | Password = password; | 149 | Password = password; |
148 | LoginUri = loginUri; | 150 | LoginUri = loginUri; |
151 | StartLocation = startLocation; | ||
149 | 152 | ||
150 | Manager = bm; | 153 | Manager = bm; |
151 | Behaviours = behaviours; | 154 | Behaviours = behaviours; |
@@ -209,7 +212,7 @@ namespace pCampBot | |||
209 | 212 | ||
210 | ConnectionState = ConnectionState.Connecting; | 213 | ConnectionState = ConnectionState.Connecting; |
211 | 214 | ||
212 | if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) | 215 | if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", StartLocation, "Your name")) |
213 | { | 216 | { |
214 | ConnectionState = ConnectionState.Connected; | 217 | ConnectionState = ConnectionState.Connected; |
215 | 218 | ||
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; |
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index e43037d..9c9ed3b 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs | |||
@@ -86,8 +86,8 @@ namespace pCampBot | |||
86 | 86 | ||
87 | if (botConfig != null) | 87 | if (botConfig != null) |
88 | { | 88 | { |
89 | bm.BotsInitSendAgentUpdates | 89 | bm.InitBotSendAgentUpdates |
90 | = botConfig.GetBoolean("SendAgentUpdates", bm.BotsInitSendAgentUpdates); | 90 | = botConfig.GetBoolean("SendAgentUpdates", bm.InitBotSendAgentUpdates); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
@@ -119,6 +119,7 @@ namespace pCampBot | |||
119 | 119 | ||
120 | cs.AddSwitch("Startup", "botcount", "n"); | 120 | cs.AddSwitch("Startup", "botcount", "n"); |
121 | cs.AddSwitch("Startup", "loginuri", "l"); | 121 | cs.AddSwitch("Startup", "loginuri", "l"); |
122 | cs.AddSwitch("Startup", "start", "s"); | ||
122 | cs.AddSwitch("Startup", "firstname"); | 123 | cs.AddSwitch("Startup", "firstname"); |
123 | cs.AddSwitch("Startup", "lastname"); | 124 | cs.AddSwitch("Startup", "lastname"); |
124 | cs.AddSwitch("Startup", "password"); | 125 | cs.AddSwitch("Startup", "password"); |
@@ -137,22 +138,23 @@ namespace pCampBot | |||
137 | // name, to load an specific folder, or save, to save an avatar with some already existing wearables | 138 | // name, to load an specific folder, or save, to save an avatar with some already existing wearables |
138 | // worn to the folder MyAppearance/FirstName_LastName, and the load it. | 139 | // worn to the folder MyAppearance/FirstName_LastName, and the load it. |
139 | Console.WriteLine( | 140 | Console.WriteLine( |
140 | "usage: pCampBot <-loginuri loginuri> [OPTIONS]\n" + | 141 | "usage: pCampBot <-loginuri loginuri> [OPTIONS]\n" |
141 | "Spawns a set of bots to test an OpenSim region\n\n" + | 142 | + "Spawns a set of bots to test an OpenSim region\n\n" |
142 | " -l, -loginuri loginuri for sim to log into (required)\n" + | 143 | + " -l, -loginuri loginuri for grid/standalone (required)\n" |
143 | " -n, -botcount number of bots to start (default: 1)\n" + | 144 | + " -s, -start start location for bots. Can be \"last\", \"home\" or a specific location with or without co-ords (e.g. \"region1\" or \"region2/50/30/90\"\n" |
144 | " -firstname first name for the bots\n" + | 145 | + " -n, -botcount number of bots to start (default: 1)\n" |
145 | " -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" + | 146 | + " -firstname first name for the bots\n" |
146 | " -password password for the bots\n" + | 147 | + " -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" |
147 | " -b, behaviours behaviours for bots. Comma separated, e.g. p,g. Default is p\n" + | 148 | + " -password password for the bots\n" |
148 | " current options are:\n" + | 149 | + " -b, behaviours behaviours for bots. Comma separated, e.g. p,g. Default is p\n" |
149 | " p (physics - bots constantly move and jump around)\n" + | 150 | + " current options are:\n" |
150 | " g (grab - bots randomly click prims whether set clickable or not)\n" + | 151 | + " p (physics - bots constantly move and jump around)\n" |
151 | " n (none - bots do nothing)\n" + | 152 | + " g (grab - bots randomly click prims whether set clickable or not)\n" |
152 | " t (teleport - bots regularly teleport between regions on the grid)\n" + | 153 | + " n (none - bots do nothing)\n" |
154 | + " t (teleport - bots regularly teleport between regions on the grid)\n" | ||
153 | // " c (cross)" + | 155 | // " c (cross)" + |
154 | " -wear set appearance folder to load from (default: no)\n" + | 156 | + " -wear set appearance folder to load from (default: no)\n" |
155 | " -h, -help show this message"); | 157 | + " -h, -help show this message.\n"); |
156 | } | 158 | } |
157 | } | 159 | } |
158 | } | 160 | } |