diff options
author | Justin Clark-Casey (justincc) | 2011-10-31 22:52:49 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-10-31 22:52:49 +0000 |
commit | d366a08ebbc861a9db8ab27dd7f375a349d297ff (patch) | |
tree | 03bb30cf729a00bfe8624dd7a2216335bb4a2e05 /OpenSim/Tools/pCampBot/PhysicsBot.cs | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-d366a08ebbc861a9db8ab27dd7f375a349d297ff.zip opensim-SC-d366a08ebbc861a9db8ab27dd7f375a349d297ff.tar.gz opensim-SC-d366a08ebbc861a9db8ab27dd7f375a349d297ff.tar.bz2 opensim-SC-d366a08ebbc861a9db8ab27dd7f375a349d297ff.tar.xz |
Stop individual bots attempting to download the same asset more than once
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Tools/pCampBot/PhysicsBot.cs | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 03c6f85..0344a82 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs | |||
@@ -56,6 +56,11 @@ namespace pCampBot | |||
56 | public event AnEvent OnConnected; | 56 | public event AnEvent OnConnected; |
57 | public event AnEvent OnDisconnected; | 57 | public event AnEvent OnDisconnected; |
58 | 58 | ||
59 | /// <summary> | ||
60 | /// Track the assets we have and have not received so we don't endlessly repeat requests. | ||
61 | /// </summary> | ||
62 | public Dictionary<UUID, bool> AssetsReceived { get; private set; } | ||
63 | |||
59 | protected Timer m_action; // Action Timer | 64 | protected Timer m_action; // Action Timer |
60 | protected List<uint> objectIDs = new List<uint>(); | 65 | protected List<uint> objectIDs = new List<uint>(); |
61 | 66 | ||
@@ -86,6 +91,8 @@ namespace pCampBot | |||
86 | startupConfig = bsconfig; | 91 | startupConfig = bsconfig; |
87 | readconfig(); | 92 | readconfig(); |
88 | talkarray = readexcuses(); | 93 | talkarray = readexcuses(); |
94 | |||
95 | AssetsReceived = new Dictionary<UUID, bool>(); | ||
89 | } | 96 | } |
90 | 97 | ||
91 | //We do our actions here. This is where one would | 98 | //We do our actions here. This is where one would |
@@ -164,7 +171,7 @@ namespace pCampBot | |||
164 | client.Network.SimConnected += this.Network_SimConnected; | 171 | client.Network.SimConnected += this.Network_SimConnected; |
165 | client.Network.Disconnected += this.Network_OnDisconnected; | 172 | client.Network.Disconnected += this.Network_OnDisconnected; |
166 | client.Objects.ObjectUpdate += Objects_NewPrim; | 173 | client.Objects.ObjectUpdate += Objects_NewPrim; |
167 | //client.Assets.OnAssetReceived += Asset_ReceivedCallback; | 174 | |
168 | if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) | 175 | if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) |
169 | { | 176 | { |
170 | if (OnConnected != null) | 177 | if (OnConnected != null) |
@@ -227,7 +234,7 @@ namespace pCampBot | |||
227 | { | 234 | { |
228 | if (asset.Decode()) | 235 | if (asset.Decode()) |
229 | { | 236 | { |
230 | File.WriteAllBytes(Path.Combine(saveDir, String.Format("{1}.{0}", | 237 | File.WriteAllBytes(Path.Combine(saveDir, String.Format("{1}.{0}", |
231 | asset.AssetType.ToString().ToLower(), | 238 | asset.AssetType.ToString().ToLower(), |
232 | asset.WearableType)), asset.AssetData); | 239 | asset.WearableType)), asset.AssetData); |
233 | } | 240 | } |
@@ -393,40 +400,55 @@ namespace pCampBot | |||
393 | { | 400 | { |
394 | if (prim.Textures.DefaultTexture.TextureID != UUID.Zero) | 401 | if (prim.Textures.DefaultTexture.TextureID != UUID.Zero) |
395 | { | 402 | { |
396 | client.Assets.RequestImage(prim.Textures.DefaultTexture.TextureID, ImageType.Normal, Asset_TextureCallback_Texture); | 403 | GetTexture(prim.Textures.DefaultTexture.TextureID); |
397 | } | 404 | } |
398 | 405 | ||
399 | for (int i = 0; i < prim.Textures.FaceTextures.Length; i++) | 406 | for (int i = 0; i < prim.Textures.FaceTextures.Length; i++) |
400 | { | 407 | { |
401 | if (prim.Textures.FaceTextures[i] != null) | 408 | UUID textureID = prim.Textures.FaceTextures[i].TextureID; |
409 | |||
410 | if (textureID != null && textureID != UUID.Zero) | ||
402 | { | 411 | { |
403 | if (prim.Textures.FaceTextures[i].TextureID != UUID.Zero) | 412 | GetTexture(textureID); |
404 | { | ||
405 | client.Assets.RequestImage(prim.Textures.FaceTextures[i].TextureID, ImageType.Normal, Asset_TextureCallback_Texture); | ||
406 | } | ||
407 | } | 413 | } |
408 | } | 414 | } |
409 | } | 415 | } |
410 | 416 | ||
411 | if (prim.Sculpt.SculptTexture != UUID.Zero) | 417 | if (prim.Sculpt.SculptTexture != UUID.Zero) |
412 | { | 418 | { |
413 | client.Assets.RequestImage(prim.Sculpt.SculptTexture, ImageType.Normal, Asset_TextureCallback_Texture); | 419 | GetTexture(prim.Sculpt.SculptTexture); |
414 | } | 420 | } |
415 | } | 421 | } |
416 | } | 422 | } |
417 | 423 | ||
424 | private void GetTexture(UUID textureID) | ||
425 | { | ||
426 | lock (AssetsReceived) | ||
427 | { | ||
428 | // Don't request assets more than once. | ||
429 | if (AssetsReceived.ContainsKey(textureID)) | ||
430 | return; | ||
431 | |||
432 | AssetsReceived[textureID] = false; | ||
433 | client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture); | ||
434 | } | ||
435 | } | ||
436 | |||
418 | 437 | ||
419 | public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture) | 438 | public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture) |
420 | { | 439 | { |
421 | //TODO: Implement texture saving and applying | 440 | //TODO: Implement texture saving and applying |
422 | } | 441 | } |
423 | 442 | ||
424 | public void Asset_ReceivedCallback(AssetDownload transfer,Asset asset) | 443 | public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset) |
425 | { | 444 | { |
426 | if (wear == "save") | 445 | lock (AssetsReceived) |
427 | { | 446 | AssetsReceived[asset.AssetID] = true; |
428 | SaveAsset((AssetWearable) asset); | 447 | |
429 | } | 448 | // if (wear == "save") |
449 | // { | ||
450 | // SaveAsset((AssetWearable) asset); | ||
451 | // } | ||
430 | } | 452 | } |
431 | 453 | ||
432 | public string[] readexcuses() | 454 | public string[] readexcuses() |