aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/pCampBot/PhysicsBot.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-10-31 23:22:55 +0000
committerJustin Clark-Casey (justincc)2011-10-31 23:22:55 +0000
commitb951c7fb1e5a284a9bf95054cb168e64ebfe717d (patch)
tree229a10fb05ac5ee8e4c4f463e253f55320e108c6 /OpenSim/Tools/pCampBot/PhysicsBot.cs
parentRemove OpenSim.TestSuite (diff)
downloadopensim-SC_OLD-b951c7fb1e5a284a9bf95054cb168e64ebfe717d.zip
opensim-SC_OLD-b951c7fb1e5a284a9bf95054cb168e64ebfe717d.tar.gz
opensim-SC_OLD-b951c7fb1e5a284a9bf95054cb168e64ebfe717d.tar.bz2
opensim-SC_OLD-b951c7fb1e5a284a9bf95054cb168e64ebfe717d.tar.xz
Make bots share a cache so that asset downloads attempts are only made once instead of once for each bot
Diffstat (limited to '')
-rw-r--r--OpenSim/Tools/pCampBot/PhysicsBot.cs29
1 files changed, 13 insertions, 16 deletions
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs
index 0c399e3..2070bfd 100644
--- a/OpenSim/Tools/pCampBot/PhysicsBot.cs
+++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs
@@ -47,7 +47,9 @@ namespace pCampBot
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 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
50 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
51 53
52 public string FirstName { get; private set; } 54 public string FirstName { get; private set; }
53 public string LastName { get; private set; } 55 public string LastName { get; private set; }
@@ -60,11 +62,6 @@ namespace pCampBot
60 public event AnEvent OnConnected; 62 public event AnEvent OnConnected;
61 public event AnEvent OnDisconnected; 63 public event AnEvent OnDisconnected;
62 64
63 /// <summary>
64 /// Track the assets we have and have not received so we don't endlessly repeat requests.
65 /// </summary>
66 public Dictionary<UUID, bool> AssetsReceived { get; private set; }
67
68 protected Timer m_action; // Action Timer 65 protected Timer m_action; // Action Timer
69 protected List<uint> objectIDs = new List<uint>(); 66 protected List<uint> objectIDs = new List<uint>();
70 67
@@ -80,23 +77,23 @@ namespace pCampBot
80 /// <summary> 77 /// <summary>
81 /// Constructor 78 /// Constructor
82 /// </summary> 79 /// </summary>
83 /// <param name="bsconfig"></param> 80 /// <param name="bm"></param>
84 /// <param name="firstName"></param> 81 /// <param name="firstName"></param>
85 /// <param name="lastName"></param> 82 /// <param name="lastName"></param>
86 /// <param name="password"></param> 83 /// <param name="password"></param>
87 /// <param name="loginUri"></param> 84 /// <param name="loginUri"></param>
88 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)
89 { 86 {
90 FirstName = firstName; 87 FirstName = firstName;
91 LastName = lastName; 88 LastName = lastName;
92 Name = string.Format("{0} {1}", FirstName, LastName); 89 Name = string.Format("{0} {1}", FirstName, LastName);
93 Password = password; 90 Password = password;
94 LoginUri = loginUri; 91 LoginUri = loginUri;
95 startupConfig = bsconfig; 92
93 BotManager = bm;
94 startupConfig = bm.Config;
96 readconfig(); 95 readconfig();
97 talkarray = readexcuses(); 96 talkarray = readexcuses();
98
99 AssetsReceived = new Dictionary<UUID, bool>();
100 } 97 }
101 98
102 //We do our actions here. This is where one would 99 //We do our actions here. This is where one would
@@ -428,13 +425,13 @@ namespace pCampBot
428 425
429 private void GetTexture(UUID textureID) 426 private void GetTexture(UUID textureID)
430 { 427 {
431 lock (AssetsReceived) 428 lock (BotManager.AssetsReceived)
432 { 429 {
433 // Don't request assets more than once. 430 // Don't request assets more than once.
434 if (AssetsReceived.ContainsKey(textureID)) 431 if (BotManager.AssetsReceived.ContainsKey(textureID))
435 return; 432 return;
436 433
437 AssetsReceived[textureID] = false; 434 BotManager.AssetsReceived[textureID] = false;
438 client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture); 435 client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture);
439 } 436 }
440 } 437 }
@@ -447,8 +444,8 @@ namespace pCampBot
447 444
448 public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset) 445 public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset)
449 { 446 {
450 lock (AssetsReceived) 447 lock (BotManager.AssetsReceived)
451 AssetsReceived[asset.AssetID] = true; 448 BotManager.AssetsReceived[asset.AssetID] = true;
452 449
453// if (wear == "save") 450// if (wear == "save")
454// { 451// {