aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools
diff options
context:
space:
mode:
authorDan Lake2011-10-31 16:42:50 -0700
committerDan Lake2011-10-31 16:42:50 -0700
commit9d214d4903755e0c681c4458166b44c78b1ca677 (patch)
treeeaa54bd49923d432fc4e039c6c02d602b16d829d /OpenSim/Tools
parentRemoved unused show commands from Scene.cs and SceneBase.cs. The show modules... (diff)
parentMake bots share a cache so that asset downloads attempts are only made once i... (diff)
downloadopensim-SC_OLD-9d214d4903755e0c681c4458166b44c78b1ca677.zip
opensim-SC_OLD-9d214d4903755e0c681c4458166b44c78b1ca677.tar.gz
opensim-SC_OLD-9d214d4903755e0c681c4458166b44c78b1ca677.tar.bz2
opensim-SC_OLD-9d214d4903755e0c681c4458166b44c78b1ca677.tar.xz
Merge branch 'master' of git://opensimulator.org/git/opensim
Diffstat (limited to 'OpenSim/Tools')
-rw-r--r--OpenSim/Tools/pCampBot/BotManager.cs19
-rw-r--r--OpenSim/Tools/pCampBot/PhysicsBot.cs64
2 files changed, 58 insertions, 25 deletions
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index 0aaa226..03bb820 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -53,13 +53,20 @@ 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 private IConfig Config; 56 public IConfig Config { get; private set; }
57
58 /// <summary>
59 /// Track the assets we have and have not received so we don't endlessly repeat requests.
60 /// </summary>
61 public Dictionary<UUID, bool> AssetsReceived { get; private set; }
57 62
58 /// <summary> 63 /// <summary>
59 /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data 64 /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data
60 /// </summary> 65 /// </summary>
61 public BotManager() 66 public BotManager()
62 { 67 {
68 AssetsReceived = new Dictionary<UUID, bool>();
69
63 m_console = CreateConsole(); 70 m_console = CreateConsole();
64 MainConsole.Instance = m_console; 71 MainConsole.Instance = m_console;
65 72
@@ -113,7 +120,7 @@ namespace pCampBot
113 for (int i = 0; i < botcount; i++) 120 for (int i = 0; i < botcount; i++)
114 { 121 {
115 string lastName = string.Format("{0}_{1}", lastNameStem, i); 122 string lastName = string.Format("{0}_{1}", lastNameStem, i);
116 startupBot(i, cs, firstName, lastName, password, loginUri); 123 startupBot(i, this, firstName, lastName, password, loginUri);
117 } 124 }
118 } 125 }
119 126
@@ -146,9 +153,9 @@ namespace pCampBot
146 /// <param name="lastName">Last name</param> 153 /// <param name="lastName">Last name</param>
147 /// <param name="password">Password</param> 154 /// <param name="password">Password</param>
148 /// <param name="loginUri">Login URI</param> 155 /// <param name="loginUri">Login URI</param>
149 public void startupBot(int pos, IConfig cs, string firstName, string lastName, string password, string loginUri) 156 public void startupBot(int pos, BotManager bm, string firstName, string lastName, string password, string loginUri)
150 { 157 {
151 PhysicsBot pb = new PhysicsBot(cs, firstName, lastName, password, loginUri); 158 PhysicsBot pb = new PhysicsBot(bm, firstName, lastName, password, loginUri);
152 159
153 pb.OnConnected += handlebotEvent; 160 pb.OnConnected += handlebotEvent;
154 pb.OnDisconnected += handlebotEvent; 161 pb.OnDisconnected += handlebotEvent;
@@ -165,18 +172,20 @@ namespace pCampBot
165 /// </summary> 172 /// </summary>
166 /// <param name="callbot"></param> 173 /// <param name="callbot"></param>
167 /// <param name="eventt"></param> 174 /// <param name="eventt"></param>
168 public void handlebotEvent(PhysicsBot callbot, EventType eventt) 175 private void handlebotEvent(PhysicsBot callbot, EventType eventt)
169 { 176 {
170 switch (eventt) 177 switch (eventt)
171 { 178 {
172 case EventType.CONNECTED: 179 case EventType.CONNECTED:
173 m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected"); 180 m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected");
174 numbots++; 181 numbots++;
182// m_log.InfoFormat("NUMBOTS {0}", numbots);
175 break; 183 break;
176 case EventType.DISCONNECTED: 184 case EventType.DISCONNECTED:
177 m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected"); 185 m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected");
178 m_td[m_lBot.IndexOf(callbot)].Abort(); 186 m_td[m_lBot.IndexOf(callbot)].Abort();
179 numbots--; 187 numbots--;
188// m_log.InfoFormat("NUMBOTS {0}", numbots);
180 if (numbots <= 0) 189 if (numbots <= 0)
181 Environment.Exit(0); 190 Environment.Exit(0);
182 break; 191 break;
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs
index 1531b27..2070bfd 100644
--- a/OpenSim/Tools/pCampBot/PhysicsBot.cs
+++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs
@@ -29,21 +29,27 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using System.IO; 31using System.IO;
32using System.Reflection;
32using System.Threading; 33using System.Threading;
33using System.Timers; 34using System.Timers;
35using log4net;
34using OpenMetaverse; 36using OpenMetaverse;
35using OpenMetaverse.Assets; 37using OpenMetaverse.Assets;
36using Nini.Config; 38using Nini.Config;
37using OpenSim.Framework; 39using OpenSim.Framework;
38using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
39using Timer=System.Timers.Timer; 41using Timer = System.Timers.Timer;
40 42
41namespace pCampBot 43namespace pCampBot
42{ 44{
43 public class PhysicsBot 45 public class PhysicsBot
44 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
45 public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events 49 public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events
46 public IConfig startupConfig; // bot config, passed from BotManager 50
51 public BotManager BotManager { get; private set; }
52 private IConfig startupConfig; // bot config, passed from BotManager
47 53
48 public string FirstName { get; private set; } 54 public string FirstName { get; private set; }
49 public string LastName { get; private set; } 55 public string LastName { get; private set; }
@@ -71,19 +77,21 @@ namespace pCampBot
71 /// <summary> 77 /// <summary>
72 /// Constructor 78 /// Constructor
73 /// </summary> 79 /// </summary>
74 /// <param name="bsconfig"></param> 80 /// <param name="bm"></param>
75 /// <param name="firstName"></param> 81 /// <param name="firstName"></param>
76 /// <param name="lastName"></param> 82 /// <param name="lastName"></param>
77 /// <param name="password"></param> 83 /// <param name="password"></param>
78 /// <param name="loginUri"></param> 84 /// <param name="loginUri"></param>
79 public PhysicsBot(IConfig bsconfig, string firstName, string lastName, string password, string loginUri) 85 public PhysicsBot(BotManager bm, string firstName, string lastName, string password, string loginUri)
80 { 86 {
81 FirstName = firstName; 87 FirstName = firstName;
82 LastName = lastName; 88 LastName = lastName;
83 Name = string.Format("{0} {1}", FirstName, LastName); 89 Name = string.Format("{0} {1}", FirstName, LastName);
84 Password = password; 90 Password = password;
85 LoginUri = loginUri; 91 LoginUri = loginUri;
86 startupConfig = bsconfig; 92
93 BotManager = bm;
94 startupConfig = bm.Config;
87 readconfig(); 95 readconfig();
88 talkarray = readexcuses(); 96 talkarray = readexcuses();
89 } 97 }
@@ -162,9 +170,9 @@ namespace pCampBot
162 client.Throttle.Total = 400000; 170 client.Throttle.Total = 400000;
163 client.Network.LoginProgress += this.Network_LoginProgress; 171 client.Network.LoginProgress += this.Network_LoginProgress;
164 client.Network.SimConnected += this.Network_SimConnected; 172 client.Network.SimConnected += this.Network_SimConnected;
165// client.Network.Disconnected += this.Network_OnDisconnected; 173 client.Network.Disconnected += this.Network_OnDisconnected;
166 client.Objects.ObjectUpdate += Objects_NewPrim; 174 client.Objects.ObjectUpdate += Objects_NewPrim;
167 //client.Assets.OnAssetReceived += Asset_ReceivedCallback; 175
168 if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) 176 if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name"))
169 { 177 {
170 if (OnConnected != null) 178 if (OnConnected != null)
@@ -227,7 +235,7 @@ namespace pCampBot
227 { 235 {
228 if (asset.Decode()) 236 if (asset.Decode())
229 { 237 {
230 File.WriteAllBytes(Path.Combine(saveDir, String.Format("{1}.{0}", 238 File.WriteAllBytes(Path.Combine(saveDir, String.Format("{1}.{0}",
231 asset.AssetType.ToString().ToLower(), 239 asset.AssetType.ToString().ToLower(),
232 asset.WearableType)), asset.AssetData); 240 asset.WearableType)), asset.AssetData);
233 } 241 }
@@ -377,6 +385,7 @@ namespace pCampBot
377 385
378 public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) 386 public void Network_OnDisconnected(object sender, DisconnectedEventArgs args)
379 { 387 {
388// m_log.ErrorFormat("Fired Network_OnDisconnected");
380 if (OnDisconnected != null) 389 if (OnDisconnected != null)
381 { 390 {
382 OnDisconnected(this, EventType.DISCONNECTED); 391 OnDisconnected(this, EventType.DISCONNECTED);
@@ -393,40 +402,55 @@ namespace pCampBot
393 { 402 {
394 if (prim.Textures.DefaultTexture.TextureID != UUID.Zero) 403 if (prim.Textures.DefaultTexture.TextureID != UUID.Zero)
395 { 404 {
396 client.Assets.RequestImage(prim.Textures.DefaultTexture.TextureID, ImageType.Normal, Asset_TextureCallback_Texture); 405 GetTexture(prim.Textures.DefaultTexture.TextureID);
397 } 406 }
398 407
399 for (int i = 0; i < prim.Textures.FaceTextures.Length; i++) 408 for (int i = 0; i < prim.Textures.FaceTextures.Length; i++)
400 { 409 {
401 if (prim.Textures.FaceTextures[i] != null) 410 UUID textureID = prim.Textures.FaceTextures[i].TextureID;
411
412 if (textureID != null && textureID != UUID.Zero)
402 { 413 {
403 if (prim.Textures.FaceTextures[i].TextureID != UUID.Zero) 414 GetTexture(textureID);
404 {
405 client.Assets.RequestImage(prim.Textures.FaceTextures[i].TextureID, ImageType.Normal, Asset_TextureCallback_Texture);
406 }
407 } 415 }
408 } 416 }
409 } 417 }
410 418
411 if (prim.Sculpt.SculptTexture != UUID.Zero) 419 if (prim.Sculpt.SculptTexture != UUID.Zero)
412 { 420 {
413 client.Assets.RequestImage(prim.Sculpt.SculptTexture, ImageType.Normal, Asset_TextureCallback_Texture); 421 GetTexture(prim.Sculpt.SculptTexture);
414 } 422 }
415 } 423 }
416 } 424 }
417 425
426 private void GetTexture(UUID textureID)
427 {
428 lock (BotManager.AssetsReceived)
429 {
430 // Don't request assets more than once.
431 if (BotManager.AssetsReceived.ContainsKey(textureID))
432 return;
433
434 BotManager.AssetsReceived[textureID] = false;
435 client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture);
436 }
437 }
438
418 439
419 public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture) 440 public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture)
420 { 441 {
421 //TODO: Implement texture saving and applying 442 //TODO: Implement texture saving and applying
422 } 443 }
423 444
424 public void Asset_ReceivedCallback(AssetDownload transfer,Asset asset) 445 public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset)
425 { 446 {
426 if (wear == "save") 447 lock (BotManager.AssetsReceived)
427 { 448 BotManager.AssetsReceived[asset.AssetID] = true;
428 SaveAsset((AssetWearable) asset); 449
429 } 450// if (wear == "save")
451// {
452// SaveAsset((AssetWearable) asset);
453// }
430 } 454 }
431 455
432 public string[] readexcuses() 456 public string[] readexcuses()