diff options
-rw-r--r-- | OpenSim/Tools/pCampBot/BotManager.cs | 107 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/PhysicsBot.cs | 45 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/README.txt | 25 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/pCampBot.cs | 6 |
4 files changed, 89 insertions, 94 deletions
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index c9d1446..0aaa226 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs | |||
@@ -53,7 +53,7 @@ namespace pCampBot | |||
53 | protected bool m_verbose = true; | 53 | protected bool m_verbose = true; |
54 | protected Random somthing = new Random(Environment.TickCount); | 54 | protected Random somthing = new Random(Environment.TickCount); |
55 | protected int numbots = 0; | 55 | protected int numbots = 0; |
56 | protected IConfig Previous_config; | 56 | private IConfig Config; |
57 | 57 | ||
58 | /// <summary> | 58 | /// <summary> |
59 | /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data | 59 | /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data |
@@ -102,72 +102,65 @@ namespace pCampBot | |||
102 | /// <param name="cs">The configuration for the bots to use</param> | 102 | /// <param name="cs">The configuration for the bots to use</param> |
103 | public void dobotStartup(int botcount, IConfig cs) | 103 | public void dobotStartup(int botcount, IConfig cs) |
104 | { | 104 | { |
105 | Previous_config = cs; | 105 | Config = cs; |
106 | m_td = new Thread[botcount]; | 106 | m_td = new Thread[botcount]; |
107 | |||
108 | string firstName = cs.GetString("firstname"); | ||
109 | string lastNameStem = cs.GetString("lastname"); | ||
110 | string password = cs.GetString("password"); | ||
111 | string loginUri = cs.GetString("loginuri"); | ||
112 | |||
107 | for (int i = 0; i < botcount; i++) | 113 | for (int i = 0; i < botcount; i++) |
108 | { | 114 | { |
109 | startupBot(i, cs); | 115 | string lastName = string.Format("{0}_{1}", lastNameStem, i); |
116 | startupBot(i, cs, firstName, lastName, password, loginUri); | ||
110 | } | 117 | } |
111 | } | 118 | } |
112 | 119 | ||
113 | /// <summary> | 120 | // /// <summary> |
114 | /// Add additional bots (and threads) to our bot pool | 121 | // /// Add additional bots (and threads) to our bot pool |
115 | /// </summary> | 122 | // /// </summary> |
116 | /// <param name="botcount">How Many of them to add</param> | 123 | // /// <param name="botcount">How Many of them to add</param> |
117 | public void addbots(int botcount) | 124 | // public void addbots(int botcount) |
118 | { | 125 | // { |
119 | int len = m_td.Length; | 126 | // int len = m_td.Length; |
120 | Thread[] m_td2 = new Thread[len + botcount]; | 127 | // Thread[] m_td2 = new Thread[len + botcount]; |
121 | for (int i = 0; i < len; i++) | 128 | // for (int i = 0; i < len; i++) |
122 | { | 129 | // { |
123 | m_td2[i] = m_td[i]; | 130 | // m_td2[i] = m_td[i]; |
124 | } | 131 | // } |
125 | m_td = m_td2; | 132 | // m_td = m_td2; |
126 | int newlen = len + botcount; | 133 | // int newlen = len + botcount; |
127 | for (int i = len; i < newlen; i++) | 134 | // for (int i = len; i < newlen; i++) |
128 | { | 135 | // { |
129 | startupBot(i, Previous_config); | 136 | // startupBot(i, Config); |
130 | } | 137 | // } |
131 | } | 138 | // } |
132 | 139 | ||
133 | /// <summary> | 140 | /// <summary> |
134 | /// This starts up the bot and stores the thread for the bot in the thread array | 141 | /// This starts up the bot and stores the thread for the bot in the thread array |
135 | /// </summary> | 142 | /// </summary> |
136 | /// <param name="pos">The position in the thread array to stick the bot's thread</param> | 143 | /// <param name="pos">The position in the thread array to stick the bot's thread</param> |
137 | /// <param name="cs">Configuration of the bot</param> | 144 | /// <param name="cs">Configuration of the bot</param> |
138 | public void startupBot(int pos, IConfig cs) | 145 | /// <param name="firstName">First name</param> |
146 | /// <param name="lastName">Last name</param> | ||
147 | /// <param name="password">Password</param> | ||
148 | /// <param name="loginUri">Login URI</param> | ||
149 | public void startupBot(int pos, IConfig cs, string firstName, string lastName, string password, string loginUri) | ||
139 | { | 150 | { |
140 | PhysicsBot pb = new PhysicsBot(cs); | 151 | PhysicsBot pb = new PhysicsBot(cs, firstName, lastName, password, loginUri); |
141 | 152 | ||
142 | pb.OnConnected += handlebotEvent; | 153 | pb.OnConnected += handlebotEvent; |
143 | pb.OnDisconnected += handlebotEvent; | 154 | pb.OnDisconnected += handlebotEvent; |
144 | if (cs.GetString("firstname", "random") == "random") pb.firstname = CreateRandomName(); | ||
145 | if (cs.GetString("lastname", "random") == "random") pb.lastname = CreateRandomName(); | ||
146 | 155 | ||
147 | m_td[pos] = new Thread(pb.startup); | 156 | m_td[pos] = new Thread(pb.startup); |
148 | m_td[pos].Name = "CampBot_" + pos; | 157 | m_td[pos].Name = pb.Name; |
149 | m_td[pos].IsBackground = true; | 158 | m_td[pos].IsBackground = true; |
150 | m_td[pos].Start(); | 159 | m_td[pos].Start(); |
151 | m_lBot.Add(pb); | 160 | m_lBot.Add(pb); |
152 | } | 161 | } |
153 | 162 | ||
154 | /// <summary> | 163 | /// <summary> |
155 | /// Creates a random name for the bot | ||
156 | /// </summary> | ||
157 | /// <returns></returns> | ||
158 | private string CreateRandomName() | ||
159 | { | ||
160 | string returnstring = ""; | ||
161 | string chars = "abcdefghijklmnopqrstuvwxyz0123456789"; | ||
162 | |||
163 | for (int i = 0; i < 7; i++) | ||
164 | { | ||
165 | returnstring += chars.Substring(somthing.Next(chars.Length),1); | ||
166 | } | ||
167 | return returnstring; | ||
168 | } | ||
169 | |||
170 | /// <summary> | ||
171 | /// High level connnected/disconnected events so we can keep track of our threads by proxy | 164 | /// High level connnected/disconnected events so we can keep track of our threads by proxy |
172 | /// </summary> | 165 | /// </summary> |
173 | /// <param name="callbot"></param> | 166 | /// <param name="callbot"></param> |
@@ -177,11 +170,11 @@ namespace pCampBot | |||
177 | switch (eventt) | 170 | switch (eventt) |
178 | { | 171 | { |
179 | case EventType.CONNECTED: | 172 | case EventType.CONNECTED: |
180 | m_log.Info("[" + callbot.firstname + " " + callbot.lastname + "]: Connected"); | 173 | m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected"); |
181 | numbots++; | 174 | numbots++; |
182 | break; | 175 | break; |
183 | case EventType.DISCONNECTED: | 176 | case EventType.DISCONNECTED: |
184 | m_log.Info("[" + callbot.firstname + " " + callbot.lastname + "]: Disconnected"); | 177 | m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected"); |
185 | m_td[m_lBot.IndexOf(callbot)].Abort(); | 178 | m_td[m_lBot.IndexOf(callbot)].Abort(); |
186 | numbots--; | 179 | numbots--; |
187 | if (numbots <= 0) | 180 | if (numbots <= 0) |
@@ -223,17 +216,17 @@ namespace pCampBot | |||
223 | Environment.Exit(0); | 216 | Environment.Exit(0); |
224 | } | 217 | } |
225 | */ | 218 | */ |
226 | 219 | // | |
227 | private void HandleAddBots(string module, string[] cmd) | 220 | // private void HandleAddBots(string module, string[] cmd) |
228 | { | 221 | // { |
229 | int newbots = 0; | 222 | // int newbots = 0; |
230 | 223 | // | |
231 | if (cmd.Length > 2) | 224 | // if (cmd.Length > 2) |
232 | { | 225 | // { |
233 | Int32.TryParse(cmd[2], out newbots); | 226 | // Int32.TryParse(cmd[2], out newbots); |
234 | } | 227 | // } |
235 | if (newbots > 0) | 228 | // if (newbots > 0) |
236 | addbots(newbots); | 229 | // addbots(newbots); |
237 | } | 230 | // } |
238 | } | 231 | } |
239 | } | 232 | } |
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index de54836..1531b27 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs | |||
@@ -45,10 +45,11 @@ namespace pCampBot | |||
45 | public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events | 45 | public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events |
46 | public IConfig startupConfig; // bot config, passed from BotManager | 46 | public IConfig startupConfig; // bot config, passed from BotManager |
47 | 47 | ||
48 | public string firstname; | 48 | public string FirstName { get; private set; } |
49 | public string lastname; | 49 | public string LastName { get; private set; } |
50 | public string password; | 50 | public string Name { get; private set; } |
51 | public string loginURI; | 51 | public string Password { get; private set; } |
52 | public string LoginUri { get; private set; } | ||
52 | public string saveDir; | 53 | public string saveDir; |
53 | public string wear; | 54 | public string wear; |
54 | 55 | ||
@@ -60,16 +61,28 @@ namespace pCampBot | |||
60 | 61 | ||
61 | protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here | 62 | protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here |
62 | 63 | ||
63 | //New instance of a SecondLife client | 64 | /// <summary> |
65 | /// New instance of a SecondLife client | ||
66 | /// </summary> | ||
64 | public GridClient client = new GridClient(); | 67 | public GridClient client = new GridClient(); |
65 | 68 | ||
66 | protected string[] talkarray; | 69 | protected string[] talkarray; |
70 | |||
67 | /// <summary> | 71 | /// <summary> |
68 | /// | 72 | /// Constructor |
69 | /// </summary> | 73 | /// </summary> |
70 | /// <param name="bsconfig">nini config for the bot</param> | 74 | /// <param name="bsconfig"></param> |
71 | public PhysicsBot(IConfig bsconfig) | 75 | /// <param name="firstName"></param> |
76 | /// <param name="lastName"></param> | ||
77 | /// <param name="password"></param> | ||
78 | /// <param name="loginUri"></param> | ||
79 | public PhysicsBot(IConfig bsconfig, string firstName, string lastName, string password, string loginUri) | ||
72 | { | 80 | { |
81 | FirstName = firstName; | ||
82 | LastName = lastName; | ||
83 | Name = string.Format("{0} {1}", FirstName, LastName); | ||
84 | Password = password; | ||
85 | LoginUri = loginUri; | ||
73 | startupConfig = bsconfig; | 86 | startupConfig = bsconfig; |
74 | readconfig(); | 87 | readconfig(); |
75 | talkarray = readexcuses(); | 88 | talkarray = readexcuses(); |
@@ -116,10 +129,6 @@ namespace pCampBot | |||
116 | /// </summary> | 129 | /// </summary> |
117 | public void readconfig() | 130 | public void readconfig() |
118 | { | 131 | { |
119 | firstname = startupConfig.GetString("firstname", "random"); | ||
120 | lastname = startupConfig.GetString("lastname", "random"); | ||
121 | password = startupConfig.GetString("password", "12345"); | ||
122 | loginURI = startupConfig.GetString("loginuri"); | ||
123 | wear = startupConfig.GetString("wear","no"); | 132 | wear = startupConfig.GetString("wear","no"); |
124 | } | 133 | } |
125 | 134 | ||
@@ -136,7 +145,7 @@ namespace pCampBot | |||
136 | /// </summary> | 145 | /// </summary> |
137 | public void startup() | 146 | public void startup() |
138 | { | 147 | { |
139 | client.Settings.LOGIN_SERVER = loginURI; | 148 | client.Settings.LOGIN_SERVER = LoginUri; |
140 | client.Settings.ALWAYS_DECODE_OBJECTS = false; | 149 | client.Settings.ALWAYS_DECODE_OBJECTS = false; |
141 | client.Settings.AVATAR_TRACKING = false; | 150 | client.Settings.AVATAR_TRACKING = false; |
142 | client.Settings.OBJECT_TRACKING = false; | 151 | client.Settings.OBJECT_TRACKING = false; |
@@ -153,10 +162,10 @@ namespace pCampBot | |||
153 | client.Throttle.Total = 400000; | 162 | client.Throttle.Total = 400000; |
154 | client.Network.LoginProgress += this.Network_LoginProgress; | 163 | client.Network.LoginProgress += this.Network_LoginProgress; |
155 | client.Network.SimConnected += this.Network_SimConnected; | 164 | client.Network.SimConnected += this.Network_SimConnected; |
156 | client.Network.Disconnected += this.Network_OnDisconnected; | 165 | // client.Network.Disconnected += this.Network_OnDisconnected; |
157 | client.Objects.ObjectUpdate += Objects_NewPrim; | 166 | client.Objects.ObjectUpdate += Objects_NewPrim; |
158 | //client.Assets.OnAssetReceived += Asset_ReceivedCallback; | 167 | //client.Assets.OnAssetReceived += Asset_ReceivedCallback; |
159 | if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name")) | 168 | if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) |
160 | { | 169 | { |
161 | if (OnConnected != null) | 170 | if (OnConnected != null) |
162 | { | 171 | { |
@@ -180,7 +189,9 @@ namespace pCampBot | |||
180 | } | 189 | } |
181 | else | 190 | else |
182 | { | 191 | { |
183 | MainConsole.Instance.Output(firstname + " " + lastname + " Can't login: " + client.Network.LoginMessage); | 192 | MainConsole.Instance.OutputFormat( |
193 | "{0} {1} cannot login: {2}", FirstName, LastName, client.Network.LoginMessage); | ||
194 | |||
184 | if (OnDisconnected != null) | 195 | if (OnDisconnected != null) |
185 | { | 196 | { |
186 | OnDisconnected(this, EventType.DISCONNECTED); | 197 | OnDisconnected(this, EventType.DISCONNECTED); |
@@ -190,7 +201,7 @@ namespace pCampBot | |||
190 | 201 | ||
191 | public void SaveDefaultAppearance() | 202 | public void SaveDefaultAppearance() |
192 | { | 203 | { |
193 | saveDir = "MyAppearance/" + firstname + "_" + lastname; | 204 | saveDir = "MyAppearance/" + FirstName + "_" + LastName; |
194 | if (!Directory.Exists(saveDir)) | 205 | if (!Directory.Exists(saveDir)) |
195 | { | 206 | { |
196 | Directory.CreateDirectory(saveDir); | 207 | Directory.CreateDirectory(saveDir); |
diff --git a/OpenSim/Tools/pCampBot/README.txt b/OpenSim/Tools/pCampBot/README.txt index 7ecbde1..c4fcf33 100644 --- a/OpenSim/Tools/pCampBot/README.txt +++ b/OpenSim/Tools/pCampBot/README.txt | |||
@@ -1,10 +1,13 @@ | |||
1 | This is the PhysicsCamperbot libslBot tester. | 1 | This is the PhysicsCamperbot libslBot tester. |
2 | 2 | ||
3 | This is designed to be run in standalone mode with authorize accounts | 3 | This is designed to stress test the simulator. It creates <N> |
4 | turned off as a way to stress test the simulator. It creates <N> | 4 | clients that log in, randomly jump/walk around, and can say excuses from |
5 | clients that log in, randomly jump/walk around, and say excuses from | ||
6 | the BOFH. | 5 | the BOFH. |
7 | 6 | ||
7 | Bots must have accounts already created. Each bot will have the same firstname and password | ||
8 | but their lastname will be appended with _<bot-number> starting from 0. So if you have two bots called ima bot, their | ||
9 | first names will be ima_bot_0 and ima_bot_1. | ||
10 | |||
8 | *** WARNING *** | 11 | *** WARNING *** |
9 | Using this bot on a public grid could get you banned permanently, so | 12 | Using this bot on a public grid could get you banned permanently, so |
10 | just say No! to griefing! | 13 | just say No! to griefing! |
@@ -21,19 +24,8 @@ pCampBot.exe will end up in the regular opensim/bin folder | |||
21 | 24 | ||
22 | ----- Running the bot ----- | 25 | ----- Running the bot ----- |
23 | 26 | ||
24 | windows: pCampBot.exe -botcount <N> -loginuri <URI> | 27 | windows: pCampBot.exe -botcount <N> -loginuri <URI> -firstname <bot-first-name> -lastname <bot-last-name-stem> -password <bot-password> |
25 | *nix: mono pCampBot.exe -botcount <N> -loginuri <URI> | 28 | *nix: mono pCampBot.exe -botcount <N> -loginuri <URI> -firstname <bot-first-name> -lastname <bot-last-name-stem> -password <bot-password> |
26 | |||
27 | The names it produces are random by default, however, you can specify | ||
28 | either a firstname or a lastname in the command line also. | ||
29 | |||
30 | ex: pCampBot.exe -botcount <N> -loginuri <URI> -lastname <lastname> | ||
31 | |||
32 | If you specify both a firstname *and* a lastname, you'll likely run | ||
33 | into trouble unless you're only running a single bot. In that case, | ||
34 | there's also a password option. | ||
35 | |||
36 | pCampBot.exe -botcount 1 -loginuri http://somegrid.com:8002 -firstname SomeDude -lastname SomeDude -password GobbleDeGook | ||
37 | 29 | ||
38 | ----- Commands ----- | 30 | ----- Commands ----- |
39 | 31 | ||
@@ -41,4 +33,3 @@ The bot has console commands: | |||
41 | help - lists the console commands and what they do | 33 | help - lists the console commands and what they do |
42 | shutdown - gracefully shuts down the bots | 34 | shutdown - gracefully shuts down the bots |
43 | quit - forcefully shuts things down leaving stuff unclean | 35 | quit - forcefully shuts things down leaving stuff unclean |
44 | addbots N - adds N number of random bots. (replace 'N' with a number) | ||
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index 77110bf..a69fbf0 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs | |||
@@ -95,9 +95,9 @@ namespace pCampBot | |||
95 | "Spawns a set of bots to test an OpenSim region\n\n" + | 95 | "Spawns a set of bots to test an OpenSim region\n\n" + |
96 | " -l, -loginuri loginuri for sim to log into (required)\n" + | 96 | " -l, -loginuri loginuri for sim to log into (required)\n" + |
97 | " -n, -botcount number of bots to start (default: 1)\n" + | 97 | " -n, -botcount number of bots to start (default: 1)\n" + |
98 | " -firstname first name for the bot(s) (default: random string)\n" + | 98 | " -firstname first name for the bots\n" + |
99 | " -lastname lastname for the bot(s) (default: random string)\n" + | 99 | " -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" + |
100 | " -password password for the bots(s) (default: random string)\n" + | 100 | " -password password for the bots\n" + |
101 | " -wear set appearance folder to load from (default: no)\n" + | 101 | " -wear set appearance folder to load from (default: no)\n" + |
102 | " -h, -help show this message" | 102 | " -h, -help show this message" |
103 | ); | 103 | ); |