aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/pCampBot/PhysicsBot.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tools/pCampBot/PhysicsBot.cs')
-rw-r--r--OpenSim/Tools/pCampBot/PhysicsBot.cs64
1 files changed, 44 insertions, 20 deletions
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()