diff options
author | Justin Clark-Casey (justincc) | 2011-11-03 21:16:24 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-11-03 21:16:24 +0000 |
commit | 66c60c56a0bac01e0f4f2a9d5c673a48ff94642b (patch) | |
tree | a76c17cdc4a65b46b1ba308e95d0b37d216fc68e /OpenSim/Tools/pCampBot | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-66c60c56a0bac01e0f4f2a9d5c673a48ff94642b.zip opensim-SC_OLD-66c60c56a0bac01e0f4f2a9d5c673a48ff94642b.tar.gz opensim-SC_OLD-66c60c56a0bac01e0f4f2a9d5c673a48ff94642b.tar.bz2 opensim-SC_OLD-66c60c56a0bac01e0f4f2a9d5c673a48ff94642b.tar.xz |
Separate out physics testing actions into a separate PhysicsBehaviour class
Diffstat (limited to 'OpenSim/Tools/pCampBot')
-rw-r--r-- | OpenSim/Tools/pCampBot/BotManager.cs | 16 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs | 37 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/PhysicsBehaviour.cs | 97 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/PhysicsBot.cs | 152 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/pCampBot.cs | 14 |
5 files changed, 221 insertions, 95 deletions
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index b05bd6d..0505c97 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs | |||
@@ -37,6 +37,7 @@ using log4net.Repository; | |||
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Console; | 39 | using OpenSim.Framework.Console; |
40 | using pCampBot.Interfaces; | ||
40 | 41 | ||
41 | namespace pCampBot | 42 | namespace pCampBot |
42 | { | 43 | { |
@@ -119,10 +120,14 @@ namespace pCampBot | |||
119 | string password = cs.GetString("password"); | 120 | string password = cs.GetString("password"); |
120 | string loginUri = cs.GetString("loginuri"); | 121 | string loginUri = cs.GetString("loginuri"); |
121 | 122 | ||
123 | // Hardcoded for new | ||
124 | List<IBehaviour> behaviours = new List<IBehaviour>(); | ||
125 | behaviours.Add(new PhysicsBehaviour()); | ||
126 | |||
122 | for (int i = 0; i < botcount; i++) | 127 | for (int i = 0; i < botcount; i++) |
123 | { | 128 | { |
124 | string lastName = string.Format("{0}_{1}", lastNameStem, i); | 129 | string lastName = string.Format("{0}_{1}", lastNameStem, i); |
125 | startupBot(i, this, firstName, lastName, password, loginUri); | 130 | startupBot(i, this, behaviours, firstName, lastName, password, loginUri); |
126 | } | 131 | } |
127 | } | 132 | } |
128 | 133 | ||
@@ -150,14 +155,17 @@ namespace pCampBot | |||
150 | /// This starts up the bot and stores the thread for the bot in the thread array | 155 | /// This starts up the bot and stores the thread for the bot in the thread array |
151 | /// </summary> | 156 | /// </summary> |
152 | /// <param name="pos">The position in the thread array to stick the bot's thread</param> | 157 | /// <param name="pos">The position in the thread array to stick the bot's thread</param> |
153 | /// <param name="cs">Configuration of the bot</param> | 158 | /// <param name="bm"></param> |
159 | /// <param name="behaviours">Behaviours for this bot to perform.</param> | ||
154 | /// <param name="firstName">First name</param> | 160 | /// <param name="firstName">First name</param> |
155 | /// <param name="lastName">Last name</param> | 161 | /// <param name="lastName">Last name</param> |
156 | /// <param name="password">Password</param> | 162 | /// <param name="password">Password</param> |
157 | /// <param name="loginUri">Login URI</param> | 163 | /// <param name="loginUri">Login URI</param> |
158 | public void startupBot(int pos, BotManager bm, string firstName, string lastName, string password, string loginUri) | 164 | public void startupBot( |
165 | int pos, BotManager bm, List<IBehaviour> behaviours, | ||
166 | string firstName, string lastName, string password, string loginUri) | ||
159 | { | 167 | { |
160 | PhysicsBot pb = new PhysicsBot(bm, firstName, lastName, password, loginUri); | 168 | PhysicsBot pb = new PhysicsBot(bm, behaviours, firstName, lastName, password, loginUri); |
161 | 169 | ||
162 | pb.OnConnected += handlebotEvent; | 170 | pb.OnConnected += handlebotEvent; |
163 | pb.OnDisconnected += handlebotEvent; | 171 | pb.OnDisconnected += handlebotEvent; |
diff --git a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs new file mode 100644 index 0000000..f9eaa1c --- /dev/null +++ b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using pCampBot; | ||
29 | using System; | ||
30 | |||
31 | namespace pCampBot.Interfaces | ||
32 | { | ||
33 | public interface IBehaviour | ||
34 | { | ||
35 | void Action(PhysicsBot bot); | ||
36 | } | ||
37 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tools/pCampBot/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/PhysicsBehaviour.cs new file mode 100644 index 0000000..e76c0b3 --- /dev/null +++ b/OpenSim/Tools/pCampBot/PhysicsBehaviour.cs | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Threading; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using pCampBot.Interfaces; | ||
34 | |||
35 | namespace pCampBot | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// This is a behaviour designed to stress physics by moving and bouncing around bots a whole lot. | ||
39 | /// </summary> | ||
40 | /// <remarks> | ||
41 | /// TODO: talkarray should be in a separate behaviour. | ||
42 | /// </remarks> | ||
43 | public class PhysicsBehaviour : IBehaviour | ||
44 | { | ||
45 | private string[] talkarray; | ||
46 | |||
47 | public PhysicsBehaviour() | ||
48 | { | ||
49 | talkarray = readexcuses(); | ||
50 | } | ||
51 | |||
52 | public void Action(PhysicsBot bot) | ||
53 | { | ||
54 | int walkorrun = bot.Random.Next(4); // Randomize between walking and running. The greater this number, | ||
55 | // the greater the bot's chances to walk instead of run. | ||
56 | bot.Client.Self.Jump(false); | ||
57 | if (walkorrun == 0) | ||
58 | { | ||
59 | bot.Client.Self.Movement.AlwaysRun = true; | ||
60 | } | ||
61 | else | ||
62 | { | ||
63 | bot.Client.Self.Movement.AlwaysRun = false; | ||
64 | } | ||
65 | |||
66 | // TODO: unused: Vector3 pos = client.Self.SimPosition; | ||
67 | Vector3 newpos = new Vector3(bot.Random.Next(1, 254), bot.Random.Next(1, 254), bot.Random.Next(1, 254)); | ||
68 | bot.Client.Self.Movement.TurnToward(newpos); | ||
69 | |||
70 | bot.Client.Self.Movement.AtPos = true; | ||
71 | Thread.Sleep(bot.Random.Next(3000, 13000)); | ||
72 | bot.Client.Self.Movement.AtPos = false; | ||
73 | bot.Client.Self.Jump(true); | ||
74 | |||
75 | string randomf = talkarray[bot.Random.Next(talkarray.Length)]; | ||
76 | if (talkarray.Length > 1 && randomf.Length > 1) | ||
77 | bot.Client.Self.Chat(randomf, 0, ChatType.Normal); | ||
78 | |||
79 | Thread.Sleep(bot.Random.Next(1000, 10000)); | ||
80 | } | ||
81 | |||
82 | private string[] readexcuses() | ||
83 | { | ||
84 | string allexcuses = ""; | ||
85 | |||
86 | string file = Path.Combine(Util.configDir(), "pCampBotSentences.txt"); | ||
87 | if (File.Exists(file)) | ||
88 | { | ||
89 | StreamReader csr = File.OpenText(file); | ||
90 | allexcuses = csr.ReadToEnd(); | ||
91 | csr.Close(); | ||
92 | } | ||
93 | |||
94 | return allexcuses.Split(Environment.NewLine.ToCharArray()); | ||
95 | } | ||
96 | } | ||
97 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index a8b2426..c1bd49f 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs | |||
@@ -36,6 +36,7 @@ using log4net; | |||
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenMetaverse.Assets; | 37 | using OpenMetaverse.Assets; |
38 | using Nini.Config; | 38 | using Nini.Config; |
39 | using pCampBot.Interfaces; | ||
39 | using OpenSim.Framework; | 40 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Console; | 41 | using OpenSim.Framework.Console; |
41 | using Timer = System.Timers.Timer; | 42 | using Timer = System.Timers.Timer; |
@@ -52,6 +53,11 @@ namespace pCampBot | |||
52 | private IConfig startupConfig; // bot config, passed from BotManager | 53 | private IConfig startupConfig; // bot config, passed from BotManager |
53 | 54 | ||
54 | /// <summary> | 55 | /// <summary> |
56 | /// Behaviours implemented by this bot. | ||
57 | /// </summary> | ||
58 | public List<IBehaviour> Behaviours { get; private set; } | ||
59 | |||
60 | /// <summary> | ||
55 | /// Is this bot connected to the grid? | 61 | /// Is this bot connected to the grid? |
56 | /// </summary> | 62 | /// </summary> |
57 | public bool IsConnected { get; private set; } | 63 | public bool IsConnected { get; private set; } |
@@ -74,25 +80,33 @@ namespace pCampBot | |||
74 | 80 | ||
75 | protected List<uint> objectIDs = new List<uint>(); | 81 | protected List<uint> objectIDs = new List<uint>(); |
76 | 82 | ||
77 | protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here | 83 | /// <summary> |
84 | /// Random number generator. | ||
85 | /// </summary> | ||
86 | public Random Random { get; private set; } | ||
78 | 87 | ||
79 | /// <summary> | 88 | /// <summary> |
80 | /// New instance of a SecondLife client | 89 | /// New instance of a SecondLife client |
81 | /// </summary> | 90 | /// </summary> |
82 | public GridClient client = new GridClient(); | 91 | public GridClient Client { get; private set; } |
83 | |||
84 | protected string[] talkarray; | ||
85 | 92 | ||
86 | /// <summary> | 93 | /// <summary> |
87 | /// Constructor | 94 | /// Constructor |
88 | /// </summary> | 95 | /// </summary> |
89 | /// <param name="bm"></param> | 96 | /// <param name="bm"></param> |
97 | /// <param name="behaviours">Behaviours for this bot to perform</param> | ||
90 | /// <param name="firstName"></param> | 98 | /// <param name="firstName"></param> |
91 | /// <param name="lastName"></param> | 99 | /// <param name="lastName"></param> |
92 | /// <param name="password"></param> | 100 | /// <param name="password"></param> |
93 | /// <param name="loginUri"></param> | 101 | /// <param name="loginUri"></param> |
94 | public PhysicsBot(BotManager bm, string firstName, string lastName, string password, string loginUri) | 102 | /// <param name="behaviours"></param> |
103 | public PhysicsBot( | ||
104 | BotManager bm, List<IBehaviour> behaviours, | ||
105 | string firstName, string lastName, string password, string loginUri) | ||
95 | { | 106 | { |
107 | Client = new GridClient(); | ||
108 | |||
109 | Random = new Random(Environment.TickCount);// We do stuff randomly here | ||
96 | FirstName = firstName; | 110 | FirstName = firstName; |
97 | LastName = lastName; | 111 | LastName = lastName; |
98 | Name = string.Format("{0} {1}", FirstName, LastName); | 112 | Name = string.Format("{0} {1}", FirstName, LastName); |
@@ -102,7 +116,8 @@ namespace pCampBot | |||
102 | BotManager = bm; | 116 | BotManager = bm; |
103 | startupConfig = bm.Config; | 117 | startupConfig = bm.Config; |
104 | readconfig(); | 118 | readconfig(); |
105 | talkarray = readexcuses(); | 119 | |
120 | Behaviours = behaviours; | ||
106 | } | 121 | } |
107 | 122 | ||
108 | //We do our actions here. This is where one would | 123 | //We do our actions here. This is where one would |
@@ -110,34 +125,7 @@ namespace pCampBot | |||
110 | private void Action() | 125 | private void Action() |
111 | { | 126 | { |
112 | while (true) | 127 | while (true) |
113 | { | 128 | Behaviours.ForEach(b => b.Action(this)); |
114 | int walkorrun = somthing.Next(4); // Randomize between walking and running. The greater this number, | ||
115 | // the greater the bot's chances to walk instead of run. | ||
116 | client.Self.Jump(false); | ||
117 | if (walkorrun == 0) | ||
118 | { | ||
119 | client.Self.Movement.AlwaysRun = true; | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | client.Self.Movement.AlwaysRun = false; | ||
124 | } | ||
125 | |||
126 | // TODO: unused: Vector3 pos = client.Self.SimPosition; | ||
127 | Vector3 newpos = new Vector3(somthing.Next(1, 254), somthing.Next(1, 254), somthing.Next(1, 254)); | ||
128 | client.Self.Movement.TurnToward(newpos); | ||
129 | |||
130 | client.Self.Movement.AtPos = true; | ||
131 | Thread.Sleep(somthing.Next(3000, 13000)); | ||
132 | client.Self.Movement.AtPos = false; | ||
133 | client.Self.Jump(true); | ||
134 | |||
135 | string randomf = talkarray[somthing.Next(talkarray.Length)]; | ||
136 | if (talkarray.Length > 1 && randomf.Length > 1) | ||
137 | client.Self.Chat(randomf, 0, ChatType.Normal); | ||
138 | |||
139 | Thread.Sleep(somthing.Next(1000, 10000)); | ||
140 | } | ||
141 | } | 129 | } |
142 | 130 | ||
143 | /// <summary> | 131 | /// <summary> |
@@ -145,7 +133,7 @@ namespace pCampBot | |||
145 | /// </summary> | 133 | /// </summary> |
146 | public void readconfig() | 134 | public void readconfig() |
147 | { | 135 | { |
148 | wear = startupConfig.GetString("wear","no"); | 136 | wear = startupConfig.GetString("wear", "no"); |
149 | } | 137 | } |
150 | 138 | ||
151 | /// <summary> | 139 | /// <summary> |
@@ -156,7 +144,7 @@ namespace pCampBot | |||
156 | if (m_actionThread != null) | 144 | if (m_actionThread != null) |
157 | m_actionThread.Abort(); | 145 | m_actionThread.Abort(); |
158 | 146 | ||
159 | client.Network.Logout(); | 147 | Client.Network.Logout(); |
160 | } | 148 | } |
161 | 149 | ||
162 | /// <summary> | 150 | /// <summary> |
@@ -164,50 +152,50 @@ namespace pCampBot | |||
164 | /// </summary> | 152 | /// </summary> |
165 | public void startup() | 153 | public void startup() |
166 | { | 154 | { |
167 | client.Settings.LOGIN_SERVER = LoginUri; | 155 | Client.Settings.LOGIN_SERVER = LoginUri; |
168 | client.Settings.ALWAYS_DECODE_OBJECTS = false; | 156 | Client.Settings.ALWAYS_DECODE_OBJECTS = false; |
169 | client.Settings.AVATAR_TRACKING = false; | 157 | Client.Settings.AVATAR_TRACKING = false; |
170 | client.Settings.OBJECT_TRACKING = false; | 158 | Client.Settings.OBJECT_TRACKING = false; |
171 | client.Settings.SEND_AGENT_THROTTLE = true; | 159 | Client.Settings.SEND_AGENT_THROTTLE = true; |
172 | client.Settings.SEND_PINGS = true; | 160 | Client.Settings.SEND_PINGS = true; |
173 | client.Settings.STORE_LAND_PATCHES = false; | 161 | Client.Settings.STORE_LAND_PATCHES = false; |
174 | client.Settings.USE_ASSET_CACHE = false; | 162 | Client.Settings.USE_ASSET_CACHE = false; |
175 | client.Settings.MULTIPLE_SIMS = true; | 163 | Client.Settings.MULTIPLE_SIMS = true; |
176 | client.Throttle.Asset = 100000; | 164 | Client.Throttle.Asset = 100000; |
177 | client.Throttle.Land = 100000; | 165 | Client.Throttle.Land = 100000; |
178 | client.Throttle.Task = 100000; | 166 | Client.Throttle.Task = 100000; |
179 | client.Throttle.Texture = 100000; | 167 | Client.Throttle.Texture = 100000; |
180 | client.Throttle.Wind = 100000; | 168 | Client.Throttle.Wind = 100000; |
181 | client.Throttle.Total = 400000; | 169 | Client.Throttle.Total = 400000; |
182 | client.Network.LoginProgress += this.Network_LoginProgress; | 170 | Client.Network.LoginProgress += this.Network_LoginProgress; |
183 | client.Network.SimConnected += this.Network_SimConnected; | 171 | Client.Network.SimConnected += this.Network_SimConnected; |
184 | client.Network.Disconnected += this.Network_OnDisconnected; | 172 | Client.Network.Disconnected += this.Network_OnDisconnected; |
185 | client.Objects.ObjectUpdate += Objects_NewPrim; | 173 | Client.Objects.ObjectUpdate += Objects_NewPrim; |
186 | 174 | ||
187 | if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) | 175 | if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) |
188 | { | 176 | { |
189 | IsConnected = true; | 177 | IsConnected = true; |
190 | 178 | ||
191 | Thread.Sleep(somthing.Next(1000, 10000)); | 179 | Thread.Sleep(Random.Next(1000, 10000)); |
192 | m_actionThread = new Thread(Action); | 180 | m_actionThread = new Thread(Action); |
193 | m_actionThread.Start(); | 181 | m_actionThread.Start(); |
194 | 182 | ||
195 | // OnConnected(this, EventType.CONNECTED); | 183 | // OnConnected(this, EventType.CONNECTED); |
196 | if (wear == "save") | 184 | if (wear == "save") |
197 | { | 185 | { |
198 | client.Appearance.SetPreviousAppearance(); | 186 | Client.Appearance.SetPreviousAppearance(); |
199 | SaveDefaultAppearance(); | 187 | SaveDefaultAppearance(); |
200 | } | 188 | } |
201 | else if (wear != "no") | 189 | else if (wear != "no") |
202 | { | 190 | { |
203 | MakeDefaultAppearance(wear); | 191 | MakeDefaultAppearance(wear); |
204 | } | 192 | } |
205 | client.Self.Jump(true); | 193 | Client.Self.Jump(true); |
206 | } | 194 | } |
207 | else | 195 | else |
208 | { | 196 | { |
209 | MainConsole.Instance.OutputFormat( | 197 | MainConsole.Instance.OutputFormat( |
210 | "{0} {1} cannot login: {2}", FirstName, LastName, client.Network.LoginMessage); | 198 | "{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage); |
211 | 199 | ||
212 | if (OnDisconnected != null) | 200 | if (OnDisconnected != null) |
213 | { | 201 | { |
@@ -227,11 +215,11 @@ namespace pCampBot | |||
227 | Array wtypes = Enum.GetValues(typeof(WearableType)); | 215 | Array wtypes = Enum.GetValues(typeof(WearableType)); |
228 | foreach (WearableType wtype in wtypes) | 216 | foreach (WearableType wtype in wtypes) |
229 | { | 217 | { |
230 | UUID wearable = client.Appearance.GetWearableAsset(wtype); | 218 | UUID wearable = Client.Appearance.GetWearableAsset(wtype); |
231 | if (wearable != UUID.Zero) | 219 | if (wearable != UUID.Zero) |
232 | { | 220 | { |
233 | client.Assets.RequestAsset(wearable, AssetType.Clothing, false, Asset_ReceivedCallback); | 221 | Client.Assets.RequestAsset(wearable, AssetType.Clothing, false, Asset_ReceivedCallback); |
234 | client.Assets.RequestAsset(wearable, AssetType.Bodypart, false, Asset_ReceivedCallback); | 222 | Client.Assets.RequestAsset(wearable, AssetType.Bodypart, false, Asset_ReceivedCallback); |
235 | } | 223 | } |
236 | } | 224 | } |
237 | } | 225 | } |
@@ -306,11 +294,11 @@ namespace pCampBot | |||
306 | UUID assetID = UUID.Random(); | 294 | UUID assetID = UUID.Random(); |
307 | AssetClothing asset = new AssetClothing(assetID, File.ReadAllBytes(clothing[i])); | 295 | AssetClothing asset = new AssetClothing(assetID, File.ReadAllBytes(clothing[i])); |
308 | asset.Decode(); | 296 | asset.Decode(); |
309 | asset.Owner = client.Self.AgentID; | 297 | asset.Owner = Client.Self.AgentID; |
310 | asset.WearableType = GetWearableType(clothing[i]); | 298 | asset.WearableType = GetWearableType(clothing[i]); |
311 | asset.Encode(); | 299 | asset.Encode(); |
312 | transid = client.Assets.RequestUpload(asset,true); | 300 | transid = Client.Assets.RequestUpload(asset,true); |
313 | client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing, | 301 | Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing, |
314 | transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) | 302 | transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) |
315 | { | 303 | { |
316 | if (success) | 304 | if (success) |
@@ -328,11 +316,11 @@ namespace pCampBot | |||
328 | UUID assetID = UUID.Random(); | 316 | UUID assetID = UUID.Random(); |
329 | AssetBodypart asset = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i])); | 317 | AssetBodypart asset = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i])); |
330 | asset.Decode(); | 318 | asset.Decode(); |
331 | asset.Owner = client.Self.AgentID; | 319 | asset.Owner = Client.Self.AgentID; |
332 | asset.WearableType = GetWearableType(bodyparts[i]); | 320 | asset.WearableType = GetWearableType(bodyparts[i]); |
333 | asset.Encode(); | 321 | asset.Encode(); |
334 | transid = client.Assets.RequestUpload(asset,true); | 322 | transid = Client.Assets.RequestUpload(asset,true); |
335 | client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart, | 323 | Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart, |
336 | transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) | 324 | transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) |
337 | { | 325 | { |
338 | if (success) | 326 | if (success) |
@@ -352,7 +340,7 @@ namespace pCampBot | |||
352 | else | 340 | else |
353 | { | 341 | { |
354 | MainConsole.Instance.Output(String.Format("Sending {0} wearables...",listwearables.Count)); | 342 | MainConsole.Instance.Output(String.Format("Sending {0} wearables...",listwearables.Count)); |
355 | client.Appearance.WearOutfit(listwearables, false); | 343 | Client.Appearance.WearOutfit(listwearables, false); |
356 | } | 344 | } |
357 | } | 345 | } |
358 | catch (Exception ex) | 346 | catch (Exception ex) |
@@ -363,8 +351,8 @@ namespace pCampBot | |||
363 | 351 | ||
364 | public InventoryFolder FindClothingFolder() | 352 | public InventoryFolder FindClothingFolder() |
365 | { | 353 | { |
366 | UUID rootfolder = client.Inventory.Store.RootFolder.UUID; | 354 | UUID rootfolder = Client.Inventory.Store.RootFolder.UUID; |
367 | List<InventoryBase> listfolders = client.Inventory.Store.GetContents(rootfolder); | 355 | List<InventoryBase> listfolders = Client.Inventory.Store.GetContents(rootfolder); |
368 | InventoryFolder clothfolder = new InventoryFolder(UUID.Random()); | 356 | InventoryFolder clothfolder = new InventoryFolder(UUID.Random()); |
369 | foreach (InventoryBase folder in listfolders) | 357 | foreach (InventoryBase folder in listfolders) |
370 | { | 358 | { |
@@ -453,10 +441,9 @@ namespace pCampBot | |||
453 | return; | 441 | return; |
454 | 442 | ||
455 | BotManager.AssetsReceived[textureID] = false; | 443 | BotManager.AssetsReceived[textureID] = false; |
456 | client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture); | 444 | Client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture); |
457 | } | 445 | } |
458 | } | 446 | } |
459 | |||
460 | 447 | ||
461 | public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture) | 448 | public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture) |
462 | { | 449 | { |
@@ -473,20 +460,5 @@ namespace pCampBot | |||
473 | // SaveAsset((AssetWearable) asset); | 460 | // SaveAsset((AssetWearable) asset); |
474 | // } | 461 | // } |
475 | } | 462 | } |
476 | |||
477 | public string[] readexcuses() | ||
478 | { | ||
479 | string allexcuses = ""; | ||
480 | |||
481 | string file = Path.Combine(Util.configDir(), "pCampBotSentences.txt"); | ||
482 | if (File.Exists(file)) | ||
483 | { | ||
484 | StreamReader csr = File.OpenText(file); | ||
485 | allexcuses = csr.ReadToEnd(); | ||
486 | csr.Close(); | ||
487 | } | ||
488 | |||
489 | return allexcuses.Split(Environment.NewLine.ToCharArray()); | ||
490 | } | ||
491 | } | 463 | } |
492 | } | 464 | } |
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index a69fbf0..cae96e1 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs | |||
@@ -26,6 +26,8 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | ||
30 | using log4net; | ||
29 | using Nini.Config; | 31 | using Nini.Config; |
30 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
31 | using OpenSim.Framework.Console; | 33 | using OpenSim.Framework.Console; |
@@ -44,6 +46,8 @@ namespace pCampBot | |||
44 | 46 | ||
45 | public class pCampBot | 47 | public class pCampBot |
46 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
47 | [STAThread] | 51 | [STAThread] |
48 | public static void Main(string[] args) | 52 | public static void Main(string[] args) |
49 | { | 53 | { |
@@ -60,9 +64,17 @@ namespace pCampBot | |||
60 | 64 | ||
61 | //startup specified number of bots. 1 is the default | 65 | //startup specified number of bots. 1 is the default |
62 | bm.dobotStartup(botcount, config); | 66 | bm.dobotStartup(botcount, config); |
67 | |||
63 | while (true) | 68 | while (true) |
64 | { | 69 | { |
65 | MainConsole.Instance.Prompt(); | 70 | try |
71 | { | ||
72 | MainConsole.Instance.Prompt(); | ||
73 | } | ||
74 | catch (Exception e) | ||
75 | { | ||
76 | m_log.ErrorFormat("Command error: {0}", e); | ||
77 | } | ||
66 | } | 78 | } |
67 | } | 79 | } |
68 | } | 80 | } |