diff options
author | Tom | 2011-09-04 07:06:36 -0700 |
---|---|---|
committer | Tom | 2011-09-04 07:06:36 -0700 |
commit | 66dec3b8742eff04fbbcc6e3249fe4ba87986500 (patch) | |
tree | 76cc708a821d35fac5cdbbce2de304b47064e732 /OpenSim/Region/CoreModules | |
parent | Guard another nullref (diff) | |
parent | Fixed BulletSim config files for Linux *.so libraries. (diff) | |
download | opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.zip opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.gz opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.bz2 opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.xz |
Resolve merge commits, stage 1
Diffstat (limited to 'OpenSim/Region/CoreModules')
46 files changed, 2150 insertions, 954 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index d85d727..a0648f7 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -316,6 +316,12 @@ namespace Flotsam.RegionModules.AssetCache | |||
316 | LogException(e); | 316 | LogException(e); |
317 | } | 317 | } |
318 | } | 318 | } |
319 | catch (Exception e) | ||
320 | { | ||
321 | m_log.ErrorFormat( | ||
322 | "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", | ||
323 | asset.ID, e.Message, e.StackTrace); | ||
324 | } | ||
319 | } | 325 | } |
320 | 326 | ||
321 | public void Cache(AssetBase asset) | 327 | public void Cache(AssetBase asset) |
@@ -368,13 +374,13 @@ namespace Flotsam.RegionModules.AssetCache | |||
368 | 374 | ||
369 | asset = (AssetBase)bformatter.Deserialize(stream); | 375 | asset = (AssetBase)bformatter.Deserialize(stream); |
370 | 376 | ||
371 | UpdateMemoryCache(id, asset); | ||
372 | |||
373 | m_DiskHits++; | 377 | m_DiskHits++; |
374 | } | 378 | } |
375 | catch (System.Runtime.Serialization.SerializationException e) | 379 | catch (System.Runtime.Serialization.SerializationException e) |
376 | { | 380 | { |
377 | LogException(e); | 381 | m_log.ErrorFormat( |
382 | "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", | ||
383 | filename, id, e.Message, e.StackTrace); | ||
378 | 384 | ||
379 | // If there was a problem deserializing the asset, the asset may | 385 | // If there was a problem deserializing the asset, the asset may |
380 | // either be corrupted OR was serialized under an old format | 386 | // either be corrupted OR was serialized under an old format |
@@ -384,7 +390,9 @@ namespace Flotsam.RegionModules.AssetCache | |||
384 | } | 390 | } |
385 | catch (Exception e) | 391 | catch (Exception e) |
386 | { | 392 | { |
387 | LogException(e); | 393 | m_log.ErrorFormat( |
394 | "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", | ||
395 | filename, id, e.Message, e.StackTrace); | ||
388 | } | 396 | } |
389 | finally | 397 | finally |
390 | { | 398 | { |
@@ -393,7 +401,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
393 | } | 401 | } |
394 | } | 402 | } |
395 | 403 | ||
396 | |||
397 | #if WAIT_ON_INPROGRESS_REQUESTS | 404 | #if WAIT_ON_INPROGRESS_REQUESTS |
398 | // Check if we're already downloading this asset. If so, try to wait for it to | 405 | // Check if we're already downloading this asset. If so, try to wait for it to |
399 | // download. | 406 | // download. |
@@ -416,7 +423,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
416 | m_RequestsForInprogress++; | 423 | m_RequestsForInprogress++; |
417 | } | 424 | } |
418 | #endif | 425 | #endif |
419 | |||
420 | return asset; | 426 | return asset; |
421 | } | 427 | } |
422 | 428 | ||
@@ -428,9 +434,15 @@ namespace Flotsam.RegionModules.AssetCache | |||
428 | 434 | ||
429 | if (m_MemoryCacheEnabled) | 435 | if (m_MemoryCacheEnabled) |
430 | asset = GetFromMemoryCache(id); | 436 | asset = GetFromMemoryCache(id); |
431 | else if (m_FileCacheEnabled) | 437 | |
438 | if (asset == null && m_FileCacheEnabled) | ||
439 | { | ||
432 | asset = GetFromFileCache(id); | 440 | asset = GetFromFileCache(id); |
433 | 441 | ||
442 | if (m_MemoryCacheEnabled && asset != null) | ||
443 | UpdateMemoryCache(id, asset); | ||
444 | } | ||
445 | |||
434 | if (((m_LogLevel >= 1)) && (m_HitRateDisplay != 0) && (m_Requests % m_HitRateDisplay == 0)) | 446 | if (((m_LogLevel >= 1)) && (m_HitRateDisplay != 0) && (m_Requests % m_HitRateDisplay == 0)) |
435 | { | 447 | { |
436 | m_HitRateFile = (double)m_DiskHits / m_Requests * 100.0; | 448 | m_HitRateFile = (double)m_DiskHits / m_Requests * 100.0; |
@@ -445,7 +457,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
445 | } | 457 | } |
446 | 458 | ||
447 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0} unnessesary requests due to requests for assets that are currently downloading.", m_RequestsForInprogress); | 459 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0} unnessesary requests due to requests for assets that are currently downloading.", m_RequestsForInprogress); |
448 | |||
449 | } | 460 | } |
450 | 461 | ||
451 | return asset; | 462 | return asset; |
@@ -459,7 +470,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
459 | public void Expire(string id) | 470 | public void Expire(string id) |
460 | { | 471 | { |
461 | if (m_LogLevel >= 2) | 472 | if (m_LogLevel >= 2) |
462 | m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Expiring Asset {0}.", id); | 473 | m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Expiring Asset {0}", id); |
463 | 474 | ||
464 | try | 475 | try |
465 | { | 476 | { |
@@ -477,7 +488,9 @@ namespace Flotsam.RegionModules.AssetCache | |||
477 | } | 488 | } |
478 | catch (Exception e) | 489 | catch (Exception e) |
479 | { | 490 | { |
480 | LogException(e); | 491 | m_log.ErrorFormat( |
492 | "[FLOTSAM ASSET CACHE]: Failed to expire cached file {0}. Exception {1} {2}", | ||
493 | id, e.Message, e.StackTrace); | ||
481 | } | 494 | } |
482 | } | 495 | } |
483 | 496 | ||
@@ -597,31 +610,59 @@ namespace Flotsam.RegionModules.AssetCache | |||
597 | 610 | ||
598 | try | 611 | try |
599 | { | 612 | { |
600 | if (!Directory.Exists(directory)) | 613 | try |
601 | { | 614 | { |
602 | Directory.CreateDirectory(directory); | 615 | if (!Directory.Exists(directory)) |
616 | { | ||
617 | Directory.CreateDirectory(directory); | ||
618 | } | ||
619 | |||
620 | stream = File.Open(tempname, FileMode.Create); | ||
621 | BinaryFormatter bformatter = new BinaryFormatter(); | ||
622 | bformatter.Serialize(stream, asset); | ||
603 | } | 623 | } |
624 | catch (IOException e) | ||
625 | { | ||
626 | m_log.ErrorFormat( | ||
627 | "[FLOTSAM ASSET CACHE]: Failed to write asset {0} to temporary location {1} (final {2}) on cache in {3}. Exception {4} {5}.", | ||
628 | asset.ID, tempname, filename, directory, e.Message, e.StackTrace); | ||
604 | 629 | ||
605 | stream = File.Open(tempname, FileMode.Create); | 630 | return; |
606 | BinaryFormatter bformatter = new BinaryFormatter(); | 631 | } |
607 | bformatter.Serialize(stream, asset); | 632 | finally |
608 | stream.Close(); | 633 | { |
609 | 634 | if (stream != null) | |
610 | // Now that it's written, rename it so that it can be found. | 635 | stream.Close(); |
611 | File.Move(tempname, filename); | 636 | } |
612 | 637 | ||
613 | if (m_LogLevel >= 2) | 638 | try |
614 | m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Cache Stored :: {0}", asset.ID); | 639 | { |
615 | } | 640 | // Now that it's written, rename it so that it can be found. |
616 | catch (Exception e) | 641 | // |
617 | { | 642 | // File.Copy(tempname, filename, true); |
618 | LogException(e); | 643 | // File.Delete(tempname); |
644 | // | ||
645 | // For a brief period, this was done as a separate copy and then temporary file delete operation to | ||
646 | // avoid an IOException caused by move if some competing thread had already written the file. | ||
647 | // However, this causes exceptions on Windows when other threads attempt to read a file | ||
648 | // which is still being copied. So instead, go back to moving the file and swallow any IOException. | ||
649 | // | ||
650 | // This situation occurs fairly rarely anyway. We assume in this that moves are atomic on the | ||
651 | // filesystem. | ||
652 | File.Move(tempname, filename); | ||
653 | |||
654 | if (m_LogLevel >= 2) | ||
655 | m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Cache Stored :: {0}", asset.ID); | ||
656 | } | ||
657 | catch (IOException) | ||
658 | { | ||
659 | // If we see an IOException here it's likely that some other competing thread has written the | ||
660 | // cache file first, so ignore. Other IOException errors (e.g. filesystem full) should be | ||
661 | // signally by the earlier temporary file writing code. | ||
662 | } | ||
619 | } | 663 | } |
620 | finally | 664 | finally |
621 | { | 665 | { |
622 | if (stream != null) | ||
623 | stream.Close(); | ||
624 | |||
625 | // Even if the write fails with an exception, we need to make sure | 666 | // Even if the write fails with an exception, we need to make sure |
626 | // that we release the lock on that file, otherwise it'll never get | 667 | // that we release the lock on that file, otherwise it'll never get |
627 | // cached | 668 | // cached |
@@ -635,22 +676,9 @@ namespace Flotsam.RegionModules.AssetCache | |||
635 | waitEvent.Set(); | 676 | waitEvent.Set(); |
636 | } | 677 | } |
637 | #else | 678 | #else |
638 | if (m_CurrentlyWriting.Contains(filename)) | 679 | m_CurrentlyWriting.Remove(filename); |
639 | { | ||
640 | m_CurrentlyWriting.Remove(filename); | ||
641 | } | ||
642 | #endif | 680 | #endif |
643 | } | 681 | } |
644 | |||
645 | } | ||
646 | } | ||
647 | |||
648 | private static void LogException(Exception e) | ||
649 | { | ||
650 | string[] text = e.ToString().Split(new char[] { '\n' }); | ||
651 | foreach (string t in text) | ||
652 | { | ||
653 | m_log.ErrorFormat("[FLOTSAM ASSET CACHE]: {0} ", t); | ||
654 | } | 682 | } |
655 | } | 683 | } |
656 | 684 | ||
@@ -706,8 +734,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
706 | s.ForEachSOG(delegate(SceneObjectGroup e) | 734 | s.ForEachSOG(delegate(SceneObjectGroup e) |
707 | { | 735 | { |
708 | gatherer.GatherAssetUuids(e, assets); | 736 | gatherer.GatherAssetUuids(e, assets); |
709 | } | 737 | }); |
710 | ); | ||
711 | } | 738 | } |
712 | 739 | ||
713 | foreach (UUID assetID in assets.Keys) | 740 | foreach (UUID assetID in assets.Keys) |
@@ -740,7 +767,9 @@ namespace Flotsam.RegionModules.AssetCache | |||
740 | } | 767 | } |
741 | catch (Exception e) | 768 | catch (Exception e) |
742 | { | 769 | { |
743 | LogException(e); | 770 | m_log.ErrorFormat( |
771 | "[FLOTSAM ASSET CACHE]: Couldn't clear asset cache directory {0} from {1}. Exception {2} {3}", | ||
772 | dir, m_CacheDirectory, e.Message, e.StackTrace); | ||
744 | } | 773 | } |
745 | } | 774 | } |
746 | 775 | ||
@@ -752,7 +781,9 @@ namespace Flotsam.RegionModules.AssetCache | |||
752 | } | 781 | } |
753 | catch (Exception e) | 782 | catch (Exception e) |
754 | { | 783 | { |
755 | LogException(e); | 784 | m_log.ErrorFormat( |
785 | "[FLOTSAM ASSET CACHE]: Couldn't clear asset cache file {0} from {1}. Exception {1} {2}", | ||
786 | file, m_CacheDirectory, e.Message, e.StackTrace); | ||
756 | } | 787 | } |
757 | } | 788 | } |
758 | } | 789 | } |
@@ -778,7 +809,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
778 | 809 | ||
779 | foreach (string s in Directory.GetFiles(m_CacheDirectory, "*.fac")) | 810 | foreach (string s in Directory.GetFiles(m_CacheDirectory, "*.fac")) |
780 | { | 811 | { |
781 | m_log.Info("[FLOTSAM ASSET CACHE]: Deep Scans were performed on the following regions:"); | 812 | m_log.Info("[FLOTSAM ASSET CACHE]: Deep scans have previously been performed on the following regions:"); |
782 | 813 | ||
783 | string RegionID = s.Remove(0,s.IndexOf("_")).Replace(".fac",""); | 814 | string RegionID = s.Remove(0,s.IndexOf("_")).Replace(".fac",""); |
784 | DateTime RegionDeepScanTMStamp = File.GetLastWriteTime(s); | 815 | DateTime RegionDeepScanTMStamp = File.GetLastWriteTime(s); |
@@ -849,7 +880,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
849 | Util.FireAndForget(delegate { | 880 | Util.FireAndForget(delegate { |
850 | int assetsCached = CacheScenes(); | 881 | int assetsCached = CacheScenes(); |
851 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Completed Scene Caching, {0} assets found.", assetsCached); | 882 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Completed Scene Caching, {0} assets found.", assetsCached); |
852 | |||
853 | }); | 883 | }); |
854 | 884 | ||
855 | break; | 885 | break; |
@@ -904,7 +934,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
904 | 934 | ||
905 | #region IAssetService Members | 935 | #region IAssetService Members |
906 | 936 | ||
907 | |||
908 | public AssetMetadata GetMetadata(string id) | 937 | public AssetMetadata GetMetadata(string id) |
909 | { | 938 | { |
910 | AssetBase asset = Get(id); | 939 | AssetBase asset = Get(id); |
@@ -934,7 +963,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
934 | Cache(asset); | 963 | Cache(asset); |
935 | 964 | ||
936 | return asset.ID; | 965 | return asset.ID; |
937 | |||
938 | } | 966 | } |
939 | 967 | ||
940 | public bool UpdateContent(string id, byte[] data) | 968 | public bool UpdateContent(string id, byte[] data) |
diff --git a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs index 63b0c31..2ff1920 100644 --- a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs +++ b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs | |||
@@ -65,18 +65,18 @@ namespace OpenSim.Region.CoreModules.Asset.Tests | |||
65 | config.Configs["AssetCache"].Set("MemoryCacheEnabled", "true"); | 65 | config.Configs["AssetCache"].Set("MemoryCacheEnabled", "true"); |
66 | 66 | ||
67 | m_cache = new FlotsamAssetCache(); | 67 | m_cache = new FlotsamAssetCache(); |
68 | m_scene = SceneSetupHelpers.SetupScene(); | 68 | m_scene = SceneHelpers.SetupScene(); |
69 | SceneSetupHelpers.SetupSceneModules(m_scene, config, m_cache); | 69 | SceneHelpers.SetupSceneModules(m_scene, config, m_cache); |
70 | } | 70 | } |
71 | 71 | ||
72 | [Test] | 72 | [Test] |
73 | public void TestCacheAsset() | 73 | public void TestCacheAsset() |
74 | { | 74 | { |
75 | TestHelper.InMethod(); | 75 | TestHelpers.InMethod(); |
76 | // log4net.Config.XmlConfigurator.Configure(); | 76 | // log4net.Config.XmlConfigurator.Configure(); |
77 | 77 | ||
78 | AssetBase asset = AssetHelpers.CreateAsset(); | 78 | AssetBase asset = AssetHelpers.CreateAsset(); |
79 | asset.ID = TestHelper.ParseTail(0x1).ToString(); | 79 | asset.ID = TestHelpers.ParseTail(0x1).ToString(); |
80 | 80 | ||
81 | // Check we don't get anything before the asset is put in the cache | 81 | // Check we don't get anything before the asset is put in the cache |
82 | AssetBase retrievedAsset = m_cache.Get(asset.ID.ToString()); | 82 | AssetBase retrievedAsset = m_cache.Get(asset.ID.ToString()); |
@@ -93,11 +93,11 @@ namespace OpenSim.Region.CoreModules.Asset.Tests | |||
93 | [Test] | 93 | [Test] |
94 | public void TestExpireAsset() | 94 | public void TestExpireAsset() |
95 | { | 95 | { |
96 | TestHelper.InMethod(); | 96 | TestHelpers.InMethod(); |
97 | // log4net.Config.XmlConfigurator.Configure(); | 97 | // log4net.Config.XmlConfigurator.Configure(); |
98 | 98 | ||
99 | AssetBase asset = AssetHelpers.CreateAsset(); | 99 | AssetBase asset = AssetHelpers.CreateAsset(); |
100 | asset.ID = TestHelper.ParseTail(0x2).ToString(); | 100 | asset.ID = TestHelpers.ParseTail(0x2).ToString(); |
101 | 101 | ||
102 | m_cache.Store(asset); | 102 | m_cache.Store(asset); |
103 | 103 | ||
@@ -110,11 +110,11 @@ namespace OpenSim.Region.CoreModules.Asset.Tests | |||
110 | [Test] | 110 | [Test] |
111 | public void TestClearCache() | 111 | public void TestClearCache() |
112 | { | 112 | { |
113 | TestHelper.InMethod(); | 113 | TestHelpers.InMethod(); |
114 | // log4net.Config.XmlConfigurator.Configure(); | 114 | // log4net.Config.XmlConfigurator.Configure(); |
115 | 115 | ||
116 | AssetBase asset = AssetHelpers.CreateAsset(); | 116 | AssetBase asset = AssetHelpers.CreateAsset(); |
117 | asset.ID = TestHelper.ParseTail(0x2).ToString(); | 117 | asset.ID = TestHelpers.ParseTail(0x2).ToString(); |
118 | 118 | ||
119 | m_cache.Store(asset); | 119 | m_cache.Store(asset); |
120 | 120 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 47476a9..8be0455 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -47,7 +47,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
47 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | protected Scene m_scene = null; | 50 | private Scene m_scene; |
51 | private IDialogModule m_dialogModule; | ||
51 | 52 | ||
52 | public string Name { get { return "Attachments Module"; } } | 53 | public string Name { get { return "Attachments Module"; } } |
53 | public Type ReplaceableInterface { get { return null; } } | 54 | public Type ReplaceableInterface { get { return null; } } |
@@ -57,6 +58,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
57 | public void AddRegion(Scene scene) | 58 | public void AddRegion(Scene scene) |
58 | { | 59 | { |
59 | m_scene = scene; | 60 | m_scene = scene; |
61 | m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>(); | ||
60 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); | 62 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); |
61 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; | 63 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; |
62 | // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI | 64 | // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI |
@@ -81,7 +83,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
81 | client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachmentsFromInventory; | 83 | client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachmentsFromInventory; |
82 | client.OnObjectAttach += AttachObject; | 84 | client.OnObjectAttach += AttachObject; |
83 | client.OnObjectDetach += DetachObject; | 85 | client.OnObjectDetach += DetachObject; |
84 | client.OnDetachAttachmentIntoInv += ShowDetachInUserInventory; | 86 | client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; |
87 | client.OnObjectDrop += DetachSingleAttachmentToGround; | ||
85 | } | 88 | } |
86 | 89 | ||
87 | public void UnsubscribeFromClientEvents(IClientAPI client) | 90 | public void UnsubscribeFromClientEvents(IClientAPI client) |
@@ -90,7 +93,77 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
90 | client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachmentsFromInventory; | 93 | client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachmentsFromInventory; |
91 | client.OnObjectAttach -= AttachObject; | 94 | client.OnObjectAttach -= AttachObject; |
92 | client.OnObjectDetach -= DetachObject; | 95 | client.OnObjectDetach -= DetachObject; |
93 | client.OnDetachAttachmentIntoInv -= ShowDetachInUserInventory; | 96 | client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; |
97 | client.OnObjectDrop -= DetachSingleAttachmentToGround; | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
101 | /// RezAttachments. This should only be called upon login on the first region. | ||
102 | /// Attachment rezzings on crossings and TPs are done in a different way. | ||
103 | /// </summary> | ||
104 | public void RezAttachments(IScenePresence sp) | ||
105 | { | ||
106 | if (null == sp.Appearance) | ||
107 | { | ||
108 | m_log.WarnFormat("[ATTACHMENTS MODULE]: Appearance has not been initialized for agent {0}", sp.UUID); | ||
109 | return; | ||
110 | } | ||
111 | |||
112 | List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); | ||
113 | foreach (AvatarAttachment attach in attachments) | ||
114 | { | ||
115 | uint p = (uint)attach.AttachPoint; | ||
116 | |||
117 | // m_log.DebugFormat( | ||
118 | // "[ATTACHMENTS MODULE]: Doing initial rez of attachment with itemID {0}, assetID {1}, point {2} for {3} in {4}", | ||
119 | // attach.ItemID, attach.AssetID, p, sp.Name, m_scene.RegionInfo.RegionName); | ||
120 | |||
121 | // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down | ||
122 | // But they're not used anyway, the item is being looked up for now, so let's proceed. | ||
123 | //if (UUID.Zero == assetID) | ||
124 | //{ | ||
125 | // m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID); | ||
126 | // continue; | ||
127 | //} | ||
128 | |||
129 | try | ||
130 | { | ||
131 | // If we're an NPC then skip all the item checks and manipulations since we don't have an | ||
132 | // inventory right now. | ||
133 | if (sp.PresenceType == PresenceType.Npc) | ||
134 | RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p); | ||
135 | else | ||
136 | RezSingleAttachmentFromInventory(sp.ControllingClient, attach.ItemID, p); | ||
137 | } | ||
138 | catch (Exception e) | ||
139 | { | ||
140 | m_log.ErrorFormat("[ATTACHMENTS MODULE]: Unable to rez attachment: {0}{1}", e.Message, e.StackTrace); | ||
141 | } | ||
142 | } | ||
143 | } | ||
144 | |||
145 | public void SaveChangedAttachments(IScenePresence sp) | ||
146 | { | ||
147 | foreach (SceneObjectGroup grp in sp.GetAttachments()) | ||
148 | { | ||
149 | if (grp.HasGroupChanged) // Resizer scripts? | ||
150 | { | ||
151 | grp.IsAttachment = false; | ||
152 | grp.AbsolutePosition = grp.RootPart.AttachedPos; | ||
153 | UpdateKnownItem(sp.ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID); | ||
154 | grp.IsAttachment = true; | ||
155 | } | ||
156 | } | ||
157 | } | ||
158 | |||
159 | public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent) | ||
160 | { | ||
161 | foreach (SceneObjectGroup sop in sp.GetAttachments()) | ||
162 | { | ||
163 | sop.Scene.DeleteSceneObject(sop, silent); | ||
164 | } | ||
165 | |||
166 | sp.ClearAttachments(); | ||
94 | } | 167 | } |
95 | 168 | ||
96 | /// <summary> | 169 | /// <summary> |
@@ -102,10 +175,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
102 | /// <param name="silent"></param> | 175 | /// <param name="silent"></param> |
103 | public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) | 176 | public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) |
104 | { | 177 | { |
105 | m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); | 178 | // m_log.DebugFormat( |
179 | // "[ATTACHMENTS MODULE]: Attaching object local id {0} to {1} point {2} from ground (silent = {3})", | ||
180 | // objectLocalID, remoteClient.Name, AttachmentPt, silent); | ||
106 | 181 | ||
107 | try | 182 | try |
108 | { | 183 | { |
184 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | ||
185 | |||
186 | if (sp == null) | ||
187 | { | ||
188 | m_log.ErrorFormat( | ||
189 | "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId); | ||
190 | return; | ||
191 | } | ||
192 | |||
109 | // If we can't take it, we can't attach it! | 193 | // If we can't take it, we can't attach it! |
110 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectLocalID); | 194 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectLocalID); |
111 | if (part == null) | 195 | if (part == null) |
@@ -131,7 +215,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
131 | AttachmentPt &= 0x7f; | 215 | AttachmentPt &= 0x7f; |
132 | 216 | ||
133 | // Calls attach with a Zero position | 217 | // Calls attach with a Zero position |
134 | if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false)) | 218 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) |
135 | { | 219 | { |
136 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); | 220 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); |
137 | 221 | ||
@@ -144,73 +228,94 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
144 | } | 228 | } |
145 | catch (Exception e) | 229 | catch (Exception e) |
146 | { | 230 | { |
147 | m_log.DebugFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}", e); | 231 | m_log.ErrorFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}{1}", e.Message, e.StackTrace); |
148 | } | 232 | } |
149 | } | 233 | } |
150 | 234 | ||
151 | public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent) | 235 | public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent) |
152 | { | 236 | { |
237 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | ||
238 | |||
239 | if (sp == null) | ||
240 | { | ||
241 | m_log.ErrorFormat( | ||
242 | "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId); | ||
243 | return false; | ||
244 | } | ||
245 | |||
246 | return AttachObject(sp, group, AttachmentPt, silent); | ||
247 | } | ||
248 | |||
249 | private bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent) | ||
250 | { | ||
251 | // m_log.DebugFormat( | ||
252 | // "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", | ||
253 | // group.Name, group.LocalId, sp.Name, AttachmentPt, silent); | ||
254 | |||
255 | if (sp.GetAttachments(attachmentPt).Contains(group)) | ||
256 | { | ||
257 | // m_log.WarnFormat( | ||
258 | // "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached", | ||
259 | // group.Name, group.LocalId, sp.Name, AttachmentPt); | ||
260 | |||
261 | return false; | ||
262 | } | ||
263 | |||
153 | Vector3 attachPos = group.AbsolutePosition; | 264 | Vector3 attachPos = group.AbsolutePosition; |
154 | 265 | ||
155 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | 266 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should |
156 | // be removed when that functionality is implemented in opensim | 267 | // be removed when that functionality is implemented in opensim |
157 | AttachmentPt &= 0x7f; | 268 | attachmentPt &= 0x7f; |
158 | 269 | ||
159 | // If the attachment point isn't the same as the one previously used | 270 | // If the attachment point isn't the same as the one previously used |
160 | // set it's offset position = 0 so that it appears on the attachment point | 271 | // set it's offset position = 0 so that it appears on the attachment point |
161 | // and not in a weird location somewhere unknown. | 272 | // and not in a weird location somewhere unknown. |
162 | if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint()) | 273 | if (attachmentPt != 0 && attachmentPt != group.AttachmentPoint) |
163 | { | 274 | { |
164 | attachPos = Vector3.Zero; | 275 | attachPos = Vector3.Zero; |
165 | } | 276 | } |
166 | 277 | ||
167 | // AttachmentPt 0 means the client chose to 'wear' the attachment. | 278 | // AttachmentPt 0 means the client chose to 'wear' the attachment. |
168 | if (AttachmentPt == 0) | 279 | if (attachmentPt == 0) |
169 | { | 280 | { |
170 | // Check object for stored attachment point | 281 | // Check object for stored attachment point |
171 | AttachmentPt = (uint)group.GetAttachmentPoint(); | 282 | attachmentPt = group.AttachmentPoint; |
172 | } | 283 | } |
173 | 284 | ||
174 | // if we still didn't find a suitable attachment point....... | 285 | // if we still didn't find a suitable attachment point....... |
175 | if (AttachmentPt == 0) | 286 | if (attachmentPt == 0) |
176 | { | 287 | { |
177 | // Stick it on left hand with Zero Offset from the attachment point. | 288 | // Stick it on left hand with Zero Offset from the attachment point. |
178 | AttachmentPt = (uint)AttachmentPoint.LeftHand; | 289 | attachmentPt = (uint)AttachmentPoint.LeftHand; |
179 | attachPos = Vector3.Zero; | 290 | attachPos = Vector3.Zero; |
180 | } | 291 | } |
181 | 292 | ||
182 | group.SetAttachmentPoint((byte)AttachmentPt); | 293 | group.AttachmentPoint = attachmentPt; |
183 | group.AbsolutePosition = attachPos; | 294 | group.AbsolutePosition = attachPos; |
184 | 295 | ||
185 | // Remove any previous attachments | 296 | // Remove any previous attachments |
186 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | ||
187 | UUID itemID = UUID.Zero; | 297 | UUID itemID = UUID.Zero; |
188 | if (sp != null) | ||
189 | { | ||
190 | foreach (SceneObjectGroup grp in sp.Attachments) | ||
191 | { | ||
192 | if (grp.GetAttachmentPoint() == (byte)AttachmentPt) | ||
193 | { | ||
194 | itemID = grp.GetFromItemID(); | ||
195 | break; | ||
196 | } | ||
197 | } | ||
198 | if (itemID != UUID.Zero) | ||
199 | DetachSingleAttachmentToInv(itemID, remoteClient); | ||
200 | } | ||
201 | 298 | ||
202 | if (group.GetFromItemID() == UUID.Zero) | 299 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); |
203 | { | 300 | |
204 | m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemID); | 301 | // At the moment we can only deal with a single attachment |
205 | } | 302 | // We also don't want to do any of the inventory operations for an NPC. |
206 | else | 303 | if (sp.PresenceType != PresenceType.Npc) |
207 | { | 304 | { |
305 | if (attachments.Count != 0) | ||
306 | itemID = attachments[0].GetFromItemID(); | ||
307 | |||
308 | if (itemID != UUID.Zero) | ||
309 | DetachSingleAttachmentToInv(itemID, sp); | ||
310 | |||
208 | itemID = group.GetFromItemID(); | 311 | itemID = group.GetFromItemID(); |
312 | if (itemID == UUID.Zero) | ||
313 | itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID; | ||
314 | |||
315 | ShowAttachInUserInventory(sp, attachmentPt, itemID, group); | ||
209 | } | 316 | } |
210 | 317 | ||
211 | ShowAttachInUserInventory(remoteClient, AttachmentPt, itemID, group); | 318 | AttachToAgent(sp, group, attachmentPt, attachPos, silent); |
212 | |||
213 | AttachToAgent(sp, group, AttachmentPt, attachPos, silent); | ||
214 | 319 | ||
215 | return true; | 320 | return true; |
216 | } | 321 | } |
@@ -226,12 +331,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
226 | } | 331 | } |
227 | } | 332 | } |
228 | 333 | ||
229 | public UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | 334 | public ISceneEntity RezSingleAttachmentFromInventory( |
335 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | ||
230 | { | 336 | { |
231 | return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true); | 337 | return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true); |
232 | } | 338 | } |
233 | 339 | ||
234 | public UUID RezSingleAttachmentFromInventory( | 340 | public ISceneEntity RezSingleAttachmentFromInventory( |
235 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus) | 341 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus) |
236 | { | 342 | { |
237 | return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true, null); | 343 | return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true, null); |
@@ -239,7 +345,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
239 | 345 | ||
240 | public UUID RezSingleAttachmentFromInventory( | 346 | public UUID RezSingleAttachmentFromInventory( |
241 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc) | 347 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc) |
348 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | ||
349 | |||
242 | { | 350 | { |
351 | if (sp == null) { m_log.ErrorFormat( "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezSingleAttachmentFromInventory()", remoteClient.Name, remoteClient.AgentId); return null; } | ||
243 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | 352 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should |
244 | // be removed when that functionality is implemented in opensim | 353 | // be removed when that functionality is implemented in opensim |
245 | AttachmentPt &= 0x7f; | 354 | AttachmentPt &= 0x7f; |
@@ -249,15 +358,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
249 | if (updateInventoryStatus) | 358 | if (updateInventoryStatus) |
250 | { | 359 | { |
251 | if (att == null) | 360 | if (att == null) |
252 | ShowDetachInUserInventory(itemID, remoteClient); | 361 | DetachSingleAttachmentToInv(itemID, sp.ControllingClient); |
253 | else | 362 | else |
254 | ShowAttachInUserInventory(att, remoteClient, itemID, AttachmentPt); | 363 | ShowAttachInUserInventory(att, sp, itemID, AttachmentPt); |
255 | } | 364 | } |
256 | 365 | ||
257 | if (null == att) | 366 | return att; |
258 | return UUID.Zero; | ||
259 | else | ||
260 | return att.UUID; | ||
261 | } | 367 | } |
262 | 368 | ||
263 | protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( | 369 | protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( |
@@ -266,12 +372,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
266 | IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); | 372 | IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); |
267 | if (invAccess != null) | 373 | if (invAccess != null) |
268 | { | 374 | { |
269 | SceneObjectGroup objatt = invAccess.RezObject(remoteClient, | 375 | SceneObjectGroup objatt; |
270 | itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, | 376 | |
271 | false, false, remoteClient.AgentId, true); | 377 | if (itemID != UUID.Zero) |
378 | objatt = invAccess.RezObject(sp.ControllingClient, | ||
379 | itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, | ||
380 | false, false, sp.UUID, true); | ||
381 | else | ||
382 | objatt = invAccess.RezObject(sp.ControllingClient, | ||
383 | null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, | ||
384 | false, false, sp.UUID, true); | ||
272 | 385 | ||
273 | // m_log.DebugFormat( | 386 | // m_log.DebugFormat( |
274 | // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", | 387 | // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", |
275 | // objatt.Name, remoteClient.Name, AttachmentPt); | 388 | // objatt.Name, remoteClient.Name, AttachmentPt); |
276 | 389 | ||
277 | if (objatt != null) | 390 | if (objatt != null) |
@@ -281,17 +394,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
281 | // since scripts aren't running yet. So, clear it here. | 394 | // since scripts aren't running yet. So, clear it here. |
282 | objatt.HasGroupChanged = false; | 395 | objatt.HasGroupChanged = false; |
283 | bool tainted = false; | 396 | bool tainted = false; |
284 | if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) | 397 | if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) |
285 | tainted = true; | 398 | tainted = true; |
286 | 399 | ||
287 | // This will throw if the attachment fails | 400 | // This will throw if the attachment fails |
288 | try | 401 | try |
289 | { | 402 | { |
290 | AttachObject(remoteClient, objatt, AttachmentPt, false); | 403 | AttachObject(sp, objatt, attachmentPt, false); |
291 | } | 404 | } |
292 | catch | 405 | catch (Exception e) |
293 | { | 406 | { |
407 | m_log.ErrorFormat( | ||
408 | "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", | ||
409 | objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); | ||
410 | |||
294 | // Make sure the object doesn't stick around and bail | 411 | // Make sure the object doesn't stick around and bail |
412 | sp.RemoveAttachment(objatt); | ||
295 | m_scene.DeleteSceneObject(objatt, false); | 413 | m_scene.DeleteSceneObject(objatt, false); |
296 | return null; | 414 | return null; |
297 | } | 415 | } |
@@ -311,13 +429,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
311 | objatt.ResumeScripts(); | 429 | objatt.ResumeScripts(); |
312 | 430 | ||
313 | // Do this last so that event listeners have access to all the effects of the attachment | 431 | // Do this last so that event listeners have access to all the effects of the attachment |
314 | //m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); | 432 | m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID); |
315 | } | 433 | } |
316 | else | 434 | else |
317 | { | 435 | { |
318 | m_log.WarnFormat( | 436 | m_log.WarnFormat( |
319 | "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", | 437 | "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", |
320 | itemID, remoteClient.Name, AttachmentPt); | 438 | itemID, sp.Name, attachmentPt); |
321 | } | 439 | } |
322 | 440 | ||
323 | return objatt; | 441 | return objatt; |
@@ -330,31 +448,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
330 | /// Update the user inventory to the attachment of an item | 448 | /// Update the user inventory to the attachment of an item |
331 | /// </summary> | 449 | /// </summary> |
332 | /// <param name="att"></param> | 450 | /// <param name="att"></param> |
333 | /// <param name="remoteClient"></param> | 451 | /// <param name="sp"></param> |
334 | /// <param name="itemID"></param> | 452 | /// <param name="itemID"></param> |
335 | /// <param name="AttachmentPt"></param> | 453 | /// <param name="attachmentPoint"></param> |
336 | /// <returns></returns> | 454 | /// <returns></returns> |
337 | protected UUID ShowAttachInUserInventory( | 455 | private UUID ShowAttachInUserInventory( |
338 | SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | 456 | SceneObjectGroup att, IScenePresence sp, UUID itemID, uint attachmentPoint) |
339 | { | 457 | { |
340 | // m_log.DebugFormat( | 458 | // m_log.DebugFormat( |
341 | // "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} (item ID {2})", | 459 | // "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} {2} (item ID {3}) at {4}", |
342 | // remoteClient.Name, att.Name, itemID); | 460 | // sp.Name, att.Name, att.LocalId, itemID, AttachmentPt); |
343 | 461 | ||
344 | if (!att.IsDeleted) | 462 | if (!att.IsDeleted) |
345 | AttachmentPt = att.RootPart.AttachmentPoint; | 463 | attachmentPoint = att.AttachmentPoint; |
346 | 464 | ||
347 | ScenePresence presence; | 465 | ScenePresence presence; |
348 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 466 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) |
349 | { | 467 | { |
350 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 468 | InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); |
351 | if (m_scene.InventoryService != null) | 469 | if (m_scene.InventoryService != null) |
352 | item = m_scene.InventoryService.GetItem(item); | 470 | item = m_scene.InventoryService.GetItem(item); |
353 | 471 | ||
354 | bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); | 472 | bool changed = sp.Appearance.SetAttachment((int)attachmentPoint, itemID, item.AssetID); |
355 | if (changed && m_scene.AvatarFactory != null) | 473 | if (changed && m_scene.AvatarFactory != null) |
356 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); | 474 | m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); |
357 | } | ||
358 | 475 | ||
359 | return att.UUID; | 476 | return att.UUID; |
360 | } | 477 | } |
@@ -362,12 +479,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
362 | /// <summary> | 479 | /// <summary> |
363 | /// Update the user inventory to reflect an attachment | 480 | /// Update the user inventory to reflect an attachment |
364 | /// </summary> | 481 | /// </summary> |
365 | /// <param name="remoteClient"></param> | 482 | /// <param name="sp"></param> |
366 | /// <param name="AttachmentPt"></param> | 483 | /// <param name="AttachmentPt"></param> |
367 | /// <param name="itemID"></param> | 484 | /// <param name="itemID"></param> |
368 | /// <param name="att"></param> | 485 | /// <param name="att"></param> |
369 | protected void ShowAttachInUserInventory( | 486 | private void ShowAttachInUserInventory( |
370 | IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) | 487 | IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) |
371 | { | 488 | { |
372 | // m_log.DebugFormat( | 489 | // m_log.DebugFormat( |
373 | // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", | 490 | // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", |
@@ -390,23 +507,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
390 | m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment for a prim without the rootpart!"); | 507 | m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment for a prim without the rootpart!"); |
391 | return; | 508 | return; |
392 | } | 509 | } |
510 | InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); | ||
393 | 511 | ||
394 | ScenePresence presence; | 512 | |
395 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 513 | |
396 | { | 514 | |
397 | // XXYY!! | 515 | |
398 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 516 | |
399 | if (item == null) | 517 | item = m_scene.InventoryService.GetItem(item); |
400 | m_log.Error("[ATTACHMENT]: item == null"); | 518 | bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); |
401 | if (m_scene == null) | 519 | if (changed && m_scene.AvatarFactory != null) |
402 | m_log.Error("[ATTACHMENT]: m_scene == null"); | 520 | m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); |
403 | if (m_scene.InventoryService == null) | ||
404 | m_log.Error("[ATTACHMENT]: m_scene.InventoryService == null"); | ||
405 | item = m_scene.InventoryService.GetItem(item); | ||
406 | bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); | ||
407 | if (changed && m_scene.AvatarFactory != null) | ||
408 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); | ||
409 | } | ||
410 | } | 521 | } |
411 | 522 | ||
412 | public void DetachObject(uint objectLocalID, IClientAPI remoteClient) | 523 | public void DetachObject(uint objectLocalID, IClientAPI remoteClient) |
@@ -414,12 +525,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
414 | SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID); | 525 | SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID); |
415 | if (group != null) | 526 | if (group != null) |
416 | { | 527 | { |
417 | //group.DetachToGround(); | 528 | DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); |
418 | ShowDetachInUserInventory(group.GetFromItemID(), remoteClient); | ||
419 | } | 529 | } |
420 | } | 530 | } |
421 | 531 | ||
422 | public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient) | 532 | public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) |
423 | { | 533 | { |
424 | ScenePresence presence; | 534 | ScenePresence presence; |
425 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 535 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) |
@@ -430,34 +540,44 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
430 | bool changed = presence.Appearance.DetachAttachment(itemID); | 540 | bool changed = presence.Appearance.DetachAttachment(itemID); |
431 | if (changed && m_scene.AvatarFactory != null) | 541 | if (changed && m_scene.AvatarFactory != null) |
432 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); | 542 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); |
433 | } | ||
434 | 543 | ||
435 | DetachSingleAttachmentToInv(itemID, remoteClient); | 544 | DetachSingleAttachmentToInv(itemID, presence); |
545 | } | ||
436 | } | 546 | } |
437 | 547 | ||
438 | public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) | 548 | public void DetachSingleAttachmentToGround(uint soLocalId, IClientAPI remoteClient) |
439 | { | 549 | { |
440 | SceneObjectPart part = m_scene.GetSceneObjectPart(itemID); | 550 | // m_log.DebugFormat( |
441 | if (part == null || part.ParentGroup == null) | 551 | // "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}", |
552 | // remoteClient.Name, sceneObjectID); | ||
553 | |||
554 | SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId); | ||
555 | |||
556 | if (so == null) | ||
442 | return; | 557 | return; |
443 | 558 | ||
444 | if (part.ParentGroup.RootPart.AttachedAvatar != remoteClient.AgentId) | 559 | if (so.AttachedAvatar != remoteClient.AgentId) |
445 | return; | 560 | return; |
446 | 561 | ||
447 | UUID inventoryID = part.ParentGroup.GetFromItemID(); | 562 | UUID inventoryID = so.GetFromItemID(); |
563 | |||
564 | // m_log.DebugFormat( | ||
565 | // "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}", | ||
566 | // so.Name, so.LocalId, inventoryID); | ||
448 | 567 | ||
449 | ScenePresence presence; | 568 | ScenePresence presence; |
450 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 569 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) |
451 | { | 570 | { |
452 | if (!m_scene.Permissions.CanRezObject( | 571 | if (!m_scene.Permissions.CanRezObject( |
453 | part.ParentGroup.PrimCount, remoteClient.AgentId, presence.AbsolutePosition)) | 572 | so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition)) |
454 | return; | 573 | return; |
455 | 574 | ||
456 | bool changed = presence.Appearance.DetachAttachment(itemID); | 575 | bool changed = presence.Appearance.DetachAttachment(inventoryID); |
457 | if (changed && m_scene.AvatarFactory != null) | 576 | if (changed && m_scene.AvatarFactory != null) |
458 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); | 577 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); |
459 | 578 | ||
460 | part.ParentGroup.DetachToGround(); | 579 | presence.RemoveAttachment(so); |
580 | DetachSceneObjectToGround(so, presence); | ||
461 | 581 | ||
462 | List<UUID> uuids = new List<UUID>(); | 582 | List<UUID> uuids = new List<UUID>(); |
463 | uuids.Add(inventoryID); | 583 | uuids.Add(inventoryID); |
@@ -465,12 +585,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
465 | remoteClient.SendRemoveInventoryItem(inventoryID); | 585 | remoteClient.SendRemoveInventoryItem(inventoryID); |
466 | } | 586 | } |
467 | 587 | ||
468 | m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero); | 588 | m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero); |
589 | } | ||
590 | |||
591 | /// <summary> | ||
592 | /// Detach the given scene object to the ground. | ||
593 | /// </summary> | ||
594 | /// <remarks> | ||
595 | /// The caller has to take care of all the other work in updating avatar appearance, inventory, etc. | ||
596 | /// </remarks> | ||
597 | /// <param name="so">The scene object to detach.</param> | ||
598 | /// <param name="sp">The scene presence from which the scene object is being detached.</param> | ||
599 | private void DetachSceneObjectToGround(SceneObjectGroup so, ScenePresence sp) | ||
600 | { | ||
601 | SceneObjectPart rootPart = so.RootPart; | ||
602 | |||
603 | rootPart.FromItemID = UUID.Zero; | ||
604 | so.AbsolutePosition = sp.AbsolutePosition; | ||
605 | so.AttachedAvatar = UUID.Zero; | ||
606 | rootPart.SetParentLocalId(0); | ||
607 | so.ClearPartAttachmentData(); | ||
608 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim); | ||
609 | so.HasGroupChanged = true; | ||
610 | rootPart.Rezzed = DateTime.Now; | ||
611 | rootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
612 | so.AttachToBackup(); | ||
613 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
614 | rootPart.ScheduleFullUpdate(); | ||
615 | rootPart.ClearUndoState(); | ||
469 | } | 616 | } |
470 | 617 | ||
471 | // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. | 618 | // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. |
472 | // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? | 619 | // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? |
473 | protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) | 620 | private void DetachSingleAttachmentToInv(UUID itemID, IScenePresence sp) |
474 | { | 621 | { |
475 | if (itemID == UUID.Zero) // If this happened, someone made a mistake.... | 622 | if (itemID == UUID.Zero) // If this happened, someone made a mistake.... |
476 | return; | 623 | return; |
@@ -493,27 +640,55 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
493 | group.DetachToInventoryPrep(); | 640 | group.DetachToInventoryPrep(); |
494 | m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); | 641 | m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); |
495 | 642 | ||
496 | // If an item contains scripts, it's always changed. | 643 | // Prepare sog for storage |
497 | // This ensures script state is saved on detach | 644 | group.AttachedAvatar = UUID.Zero; |
498 | foreach (SceneObjectPart p in group.Parts) | 645 | |
499 | if (p.Inventory.ContainsScripts()) | 646 | group.ForEachPart( |
500 | group.HasGroupChanged = true; | 647 | delegate(SceneObjectPart part) |
648 | { | ||
649 | // If there are any scripts, | ||
650 | // then always trigger a new object and state persistence in UpdateKnownItem() | ||
651 | if (part.Inventory.ContainsScripts()) | ||
652 | group.HasGroupChanged = true; | ||
653 | } | ||
654 | ); | ||
501 | 655 | ||
502 | UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID); | 656 | group.RootPart.SetParentLocalId(0); |
657 | group.IsAttachment = false; | ||
658 | group.AbsolutePosition = group.RootPart.AttachedPos; | ||
659 | |||
660 | UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID); | ||
503 | m_scene.DeleteSceneObject(group, false); | 661 | m_scene.DeleteSceneObject(group, false); |
662 | |||
504 | return; | 663 | return; |
505 | } | 664 | } |
506 | } | 665 | } |
507 | } | 666 | } |
508 | } | 667 | } |
509 | 668 | ||
669 | public void UpdateAttachmentPosition(SceneObjectGroup sog, Vector3 pos) | ||
670 | { | ||
671 | // First we save the | ||
672 | // attachment point information, then we update the relative | ||
673 | // positioning. Then we have to mark the object as NOT an | ||
674 | // attachment. This is necessary in order to correctly save | ||
675 | // and retrieve GroupPosition information for the attachment. | ||
676 | // Finally, we restore the object's attachment status. | ||
677 | uint attachmentPoint = sog.AttachmentPoint; | ||
678 | sog.UpdateGroupPosition(pos); | ||
679 | sog.IsAttachment = false; | ||
680 | sog.AbsolutePosition = sog.RootPart.AttachedPos; | ||
681 | sog.AttachmentPoint = attachmentPoint; | ||
682 | sog.HasGroupChanged = true; | ||
683 | } | ||
684 | |||
510 | /// <summary> | 685 | /// <summary> |
511 | /// Update the attachment asset for the new sog details if they have changed. | 686 | /// Update the attachment asset for the new sog details if they have changed. |
512 | /// </summary> | 687 | /// </summary> |
513 | /// | 688 | /// <remarks> |
514 | /// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects, | 689 | /// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects, |
515 | /// these details are not stored on the region. | 690 | /// these details are not stored on the region. |
516 | /// | 691 | /// </remarks> |
517 | /// <param name="remoteClient"></param> | 692 | /// <param name="remoteClient"></param> |
518 | /// <param name="grp"></param> | 693 | /// <param name="grp"></param> |
519 | /// <param name="itemID"></param> | 694 | /// <param name="itemID"></param> |
@@ -524,15 +699,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
524 | { | 699 | { |
525 | if (!grp.HasGroupChanged) | 700 | if (!grp.HasGroupChanged) |
526 | { | 701 | { |
527 | m_log.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID); | 702 | m_log.DebugFormat( |
703 | "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", | ||
704 | grp.UUID, grp.AttachmentPoint); | ||
705 | |||
528 | return; | 706 | return; |
529 | } | 707 | } |
530 | 708 | ||
531 | m_log.DebugFormat( | 709 | m_log.DebugFormat( |
532 | "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", | 710 | "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", |
533 | grp.UUID, grp.GetAttachmentPoint()); | 711 | grp.UUID, grp.AttachmentPoint); |
534 | 712 | ||
535 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | 713 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); |
714 | |||
536 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 715 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); |
537 | item = m_scene.InventoryService.GetItem(item); | 716 | item = m_scene.InventoryService.GetItem(item); |
538 | 717 | ||
@@ -564,20 +743,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
564 | /// <summary> | 743 | /// <summary> |
565 | /// Attach this scene object to the given avatar. | 744 | /// Attach this scene object to the given avatar. |
566 | /// </summary> | 745 | /// </summary> |
567 | /// | 746 | /// <remarks> |
568 | /// This isn't publicly available since attachments should always perform the corresponding inventory | 747 | /// This isn't publicly available since attachments should always perform the corresponding inventory |
569 | /// operation (to show the attach in user inventory and update the asset with positional information). | 748 | /// operation (to show the attach in user inventory and update the asset with positional information). |
570 | /// | 749 | /// </remarks> |
571 | /// <param name="sp"></param> | 750 | /// <param name="sp"></param> |
572 | /// <param name="so"></param> | 751 | /// <param name="so"></param> |
573 | /// <param name="attachmentpoint"></param> | 752 | /// <param name="attachmentpoint"></param> |
574 | /// <param name="attachOffset"></param> | 753 | /// <param name="attachOffset"></param> |
575 | /// <param name="silent"></param> | 754 | /// <param name="silent"></param> |
576 | protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | 755 | private void AttachToAgent( |
756 | IScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | ||
577 | { | 757 | { |
578 | 758 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", | |
579 | m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name, | 759 | // so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); |
580 | attachmentpoint, attachOffset, so.RootPart.AttachedPos); | ||
581 | 760 | ||
582 | so.DetachFromBackup(); | 761 | so.DetachFromBackup(); |
583 | 762 | ||
@@ -585,12 +764,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
585 | m_scene.DeleteFromStorage(so.UUID); | 764 | m_scene.DeleteFromStorage(so.UUID); |
586 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | 765 | m_scene.EventManager.TriggerParcelPrimCountTainted(); |
587 | 766 | ||
588 | so.RootPart.AttachedAvatar = avatar.UUID; | 767 | so.AttachedAvatar = avatar.UUID; |
589 | |||
590 | //Anakin Lohner bug #3839 | ||
591 | SceneObjectPart[] parts = so.Parts; | ||
592 | for (int i = 0; i < parts.Length; i++) | ||
593 | parts[i].AttachedAvatar = avatar.UUID; | ||
594 | 768 | ||
595 | if (so.RootPart.PhysActor != null) | 769 | if (so.RootPart.PhysActor != null) |
596 | { | 770 | { |
@@ -600,10 +774,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
600 | 774 | ||
601 | so.AbsolutePosition = attachOffset; | 775 | so.AbsolutePosition = attachOffset; |
602 | so.RootPart.AttachedPos = attachOffset; | 776 | so.RootPart.AttachedPos = attachOffset; |
603 | so.RootPart.IsAttachment = true; | 777 | so.IsAttachment = true; |
604 | |||
605 | so.RootPart.SetParentLocalId(avatar.LocalId); | 778 | so.RootPart.SetParentLocalId(avatar.LocalId); |
606 | so.SetAttachmentPoint(Convert.ToByte(attachmentpoint)); | 779 | so.AttachmentPoint = attachmentpoint; |
607 | 780 | ||
608 | avatar.AddAttachment(so); | 781 | avatar.AddAttachment(so); |
609 | 782 | ||
@@ -617,5 +790,97 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
617 | // it get cleaned up | 790 | // it get cleaned up |
618 | so.RootPart.RemFlag(PrimFlags.TemporaryOnRez); | 791 | so.RootPart.RemFlag(PrimFlags.TemporaryOnRez); |
619 | } | 792 | } |
793 | |||
794 | /// <summary> | ||
795 | /// Add a scene object that was previously free in the scene as an attachment to an avatar. | ||
796 | /// </summary> | ||
797 | /// <param name="remoteClient"></param> | ||
798 | /// <param name="grp"></param> | ||
799 | /// <returns>The user inventory item created that holds the attachment.</returns> | ||
800 | private InventoryItemBase AddSceneObjectAsAttachment(IClientAPI remoteClient, SceneObjectGroup grp) | ||
801 | { | ||
802 | // m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); | ||
803 | |||
804 | Vector3 inventoryStoredPosition = new Vector3 | ||
805 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
806 | ? Constants.RegionSize - 6 | ||
807 | : grp.AbsolutePosition.X) | ||
808 | , | ||
809 | (grp.AbsolutePosition.Y > (int)Constants.RegionSize) | ||
810 | ? Constants.RegionSize - 6 | ||
811 | : grp.AbsolutePosition.Y, | ||
812 | grp.AbsolutePosition.Z); | ||
813 | |||
814 | Vector3 originalPosition = grp.AbsolutePosition; | ||
815 | |||
816 | grp.AbsolutePosition = inventoryStoredPosition; | ||
817 | |||
818 | // If we're being called from a script, then trying to serialize that same script's state will not complete | ||
819 | // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if | ||
820 | // the client/server crashes rather than logging out normally, the attachment's scripts will resume | ||
821 | // without state on relog. Arguably, this is what we want anyway. | ||
822 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); | ||
823 | |||
824 | grp.AbsolutePosition = originalPosition; | ||
825 | |||
826 | AssetBase asset = m_scene.CreateAsset( | ||
827 | grp.GetPartName(grp.LocalId), | ||
828 | grp.GetPartDescription(grp.LocalId), | ||
829 | (sbyte)AssetType.Object, | ||
830 | Utils.StringToBytes(sceneObjectXml), | ||
831 | remoteClient.AgentId); | ||
832 | |||
833 | m_scene.AssetService.Store(asset); | ||
834 | |||
835 | InventoryItemBase item = new InventoryItemBase(); | ||
836 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
837 | item.CreatorData = grp.RootPart.CreatorData; | ||
838 | item.Owner = remoteClient.AgentId; | ||
839 | item.ID = UUID.Random(); | ||
840 | item.AssetID = asset.FullID; | ||
841 | item.Description = asset.Description; | ||
842 | item.Name = asset.Name; | ||
843 | item.AssetType = asset.Type; | ||
844 | item.InvType = (int)InventoryType.Object; | ||
845 | |||
846 | InventoryFolderBase folder = m_scene.InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
847 | if (folder != null) | ||
848 | item.Folder = folder.ID; | ||
849 | else // oopsies | ||
850 | item.Folder = UUID.Zero; | ||
851 | |||
852 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && m_scene.Permissions.PropagatePermissions()) | ||
853 | { | ||
854 | item.BasePermissions = grp.RootPart.NextOwnerMask; | ||
855 | item.CurrentPermissions = grp.RootPart.NextOwnerMask; | ||
856 | item.NextPermissions = grp.RootPart.NextOwnerMask; | ||
857 | item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
858 | item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
859 | } | ||
860 | else | ||
861 | { | ||
862 | item.BasePermissions = grp.RootPart.BaseMask; | ||
863 | item.CurrentPermissions = grp.RootPart.OwnerMask; | ||
864 | item.NextPermissions = grp.RootPart.NextOwnerMask; | ||
865 | item.EveryOnePermissions = grp.RootPart.EveryoneMask; | ||
866 | item.GroupPermissions = grp.RootPart.GroupMask; | ||
867 | } | ||
868 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
869 | |||
870 | // sets itemID so client can show item as 'attached' in inventory | ||
871 | grp.SetFromItemID(item.ID); | ||
872 | |||
873 | if (m_scene.AddInventoryItem(item)) | ||
874 | { | ||
875 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
876 | } | ||
877 | else | ||
878 | { | ||
879 | if (m_dialogModule != null) | ||
880 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
881 | } | ||
882 | |||
883 | return item; | ||
884 | } | ||
620 | } | 885 | } |
621 | } | 886 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs new file mode 100644 index 0000000..363e258 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -0,0 +1,274 @@ | |||
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.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Threading; | ||
33 | using System.Timers; | ||
34 | using Timer=System.Timers.Timer; | ||
35 | using Nini.Config; | ||
36 | using NUnit.Framework; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Region.CoreModules.Avatar.Attachments; | ||
41 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | ||
42 | using OpenSim.Region.CoreModules.World.Serialiser; | ||
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
44 | using OpenSim.Region.Framework.Scenes; | ||
45 | using OpenSim.Region.Framework.Interfaces; | ||
46 | using OpenSim.Tests.Common; | ||
47 | using OpenSim.Tests.Common.Mock; | ||
48 | |||
49 | namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | ||
50 | { | ||
51 | /// <summary> | ||
52 | /// Attachment tests | ||
53 | /// </summary> | ||
54 | [TestFixture] | ||
55 | public class AttachmentsModuleTests | ||
56 | { | ||
57 | private Scene scene; | ||
58 | private AttachmentsModule m_attMod; | ||
59 | private ScenePresence m_presence; | ||
60 | |||
61 | [SetUp] | ||
62 | public void Init() | ||
63 | { | ||
64 | // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. | ||
65 | Util.FireAndForgetMethod = FireAndForgetMethod.None; | ||
66 | |||
67 | IConfigSource config = new IniConfigSource(); | ||
68 | config.AddConfig("Modules"); | ||
69 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
70 | |||
71 | scene = SceneHelpers.SetupScene(); | ||
72 | m_attMod = new AttachmentsModule(); | ||
73 | SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); | ||
74 | } | ||
75 | |||
76 | [TearDown] | ||
77 | public void TearDown() | ||
78 | { | ||
79 | // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple | ||
80 | // threads. Possibly, later tests should be rewritten not to worry about such things. | ||
81 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | ||
82 | } | ||
83 | |||
84 | /// <summary> | ||
85 | /// Add the standard presence for a test. | ||
86 | /// </summary> | ||
87 | private void AddPresence() | ||
88 | { | ||
89 | UUID userId = TestHelpers.ParseTail(0x1); | ||
90 | UserAccountHelpers.CreateUserWithInventory(scene, userId); | ||
91 | m_presence = SceneHelpers.AddScenePresence(scene, userId); | ||
92 | } | ||
93 | |||
94 | [Test] | ||
95 | public void TestAddAttachmentFromGround() | ||
96 | { | ||
97 | TestHelpers.InMethod(); | ||
98 | // log4net.Config.XmlConfigurator.Configure(); | ||
99 | |||
100 | AddPresence(); | ||
101 | string attName = "att"; | ||
102 | |||
103 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup; | ||
104 | |||
105 | m_attMod.AttachObject(m_presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false); | ||
106 | |||
107 | // Check status on scene presence | ||
108 | Assert.That(m_presence.HasAttachments(), Is.True); | ||
109 | List<SceneObjectGroup> attachments = m_presence.GetAttachments(); | ||
110 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
111 | SceneObjectGroup attSo = attachments[0]; | ||
112 | Assert.That(attSo.Name, Is.EqualTo(attName)); | ||
113 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); | ||
114 | Assert.That(attSo.IsAttachment); | ||
115 | Assert.That(attSo.UsesPhysics, Is.False); | ||
116 | Assert.That(attSo.IsTemporary, Is.False); | ||
117 | |||
118 | // Check item status | ||
119 | Assert.That(m_presence.Appearance.GetAttachpoint( | ||
120 | attSo.GetFromItemID()), Is.EqualTo((int)AttachmentPoint.Chest)); | ||
121 | } | ||
122 | |||
123 | [Test] | ||
124 | public void TestAddAttachmentFromInventory() | ||
125 | { | ||
126 | TestHelpers.InMethod(); | ||
127 | // log4net.Config.XmlConfigurator.Configure(); | ||
128 | |||
129 | AddPresence(); | ||
130 | |||
131 | UUID attItemId = TestHelpers.ParseTail(0x2); | ||
132 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
133 | string attName = "att"; | ||
134 | |||
135 | UserInventoryHelpers.CreateInventoryItem( | ||
136 | scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); | ||
137 | |||
138 | m_attMod.RezSingleAttachmentFromInventory( | ||
139 | m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); | ||
140 | |||
141 | // Check scene presence status | ||
142 | Assert.That(m_presence.HasAttachments(), Is.True); | ||
143 | List<SceneObjectGroup> attachments = m_presence.GetAttachments(); | ||
144 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
145 | SceneObjectGroup attSo = attachments[0]; | ||
146 | Assert.That(attSo.Name, Is.EqualTo(attName)); | ||
147 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); | ||
148 | Assert.That(attSo.IsAttachment); | ||
149 | Assert.That(attSo.UsesPhysics, Is.False); | ||
150 | Assert.That(attSo.IsTemporary, Is.False); | ||
151 | |||
152 | // Check appearance status | ||
153 | Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); | ||
154 | } | ||
155 | |||
156 | [Test] | ||
157 | public void TestDetachAttachmentToGround() | ||
158 | { | ||
159 | TestHelpers.InMethod(); | ||
160 | // log4net.Config.XmlConfigurator.Configure(); | ||
161 | |||
162 | AddPresence(); | ||
163 | |||
164 | UUID attItemId = TestHelpers.ParseTail(0x2); | ||
165 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
166 | string attName = "att"; | ||
167 | |||
168 | UserInventoryHelpers.CreateInventoryItem( | ||
169 | scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); | ||
170 | |||
171 | ISceneEntity so = m_attMod.RezSingleAttachmentFromInventory( | ||
172 | m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); | ||
173 | m_attMod.DetachSingleAttachmentToGround(so.LocalId, m_presence.ControllingClient); | ||
174 | |||
175 | // Check scene presence status | ||
176 | Assert.That(m_presence.HasAttachments(), Is.False); | ||
177 | List<SceneObjectGroup> attachments = m_presence.GetAttachments(); | ||
178 | Assert.That(attachments.Count, Is.EqualTo(0)); | ||
179 | |||
180 | // Check appearance status | ||
181 | Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(0)); | ||
182 | |||
183 | // Check item status | ||
184 | Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Null); | ||
185 | |||
186 | // Check object in scene | ||
187 | Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null); | ||
188 | } | ||
189 | |||
190 | [Test] | ||
191 | public void TestDetachAttachmentToInventory() | ||
192 | { | ||
193 | TestHelpers.InMethod(); | ||
194 | // log4net.Config.XmlConfigurator.Configure(); | ||
195 | |||
196 | AddPresence(); | ||
197 | |||
198 | UUID attItemId = TestHelpers.ParseTail(0x2); | ||
199 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
200 | string attName = "att"; | ||
201 | |||
202 | UserInventoryHelpers.CreateInventoryItem( | ||
203 | scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); | ||
204 | |||
205 | m_attMod.RezSingleAttachmentFromInventory( | ||
206 | m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); | ||
207 | m_attMod.DetachSingleAttachmentToInv(attItemId, m_presence.ControllingClient); | ||
208 | |||
209 | // Check status on scene presence | ||
210 | Assert.That(m_presence.HasAttachments(), Is.False); | ||
211 | List<SceneObjectGroup> attachments = m_presence.GetAttachments(); | ||
212 | Assert.That(attachments.Count, Is.EqualTo(0)); | ||
213 | |||
214 | // Check item status | ||
215 | Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0)); | ||
216 | } | ||
217 | |||
218 | [Test] | ||
219 | public void TestRezAttachmentsOnAvatarEntrance() | ||
220 | { | ||
221 | TestHelpers.InMethod(); | ||
222 | // log4net.Config.XmlConfigurator.Configure(); | ||
223 | |||
224 | UUID userId = TestHelpers.ParseTail(0x1); | ||
225 | UUID attItemId = TestHelpers.ParseTail(0x2); | ||
226 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
227 | string attName = "att"; | ||
228 | |||
229 | UserAccountHelpers.CreateUserWithInventory(scene, userId); | ||
230 | InventoryItemBase attItem | ||
231 | = UserInventoryHelpers.CreateInventoryItem( | ||
232 | scene, attName, attItemId, attAssetId, userId, InventoryType.Object); | ||
233 | |||
234 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); | ||
235 | acd.Appearance = new AvatarAppearance(); | ||
236 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); | ||
237 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); | ||
238 | |||
239 | Assert.That(presence.HasAttachments(), Is.True); | ||
240 | List<SceneObjectGroup> attachments = presence.GetAttachments(); | ||
241 | |||
242 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
243 | SceneObjectGroup attSo = attachments[0]; | ||
244 | Assert.That(attSo.Name, Is.EqualTo(attName)); | ||
245 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); | ||
246 | Assert.That(attSo.IsAttachment); | ||
247 | Assert.That(attSo.UsesPhysics, Is.False); | ||
248 | Assert.That(attSo.IsTemporary, Is.False); | ||
249 | } | ||
250 | |||
251 | // I'm commenting this test because scene setup NEEDS InventoryService to | ||
252 | // be non-null | ||
253 | //[Test] | ||
254 | // public void T032_CrossAttachments() | ||
255 | // { | ||
256 | // TestHelpers.InMethod(); | ||
257 | // | ||
258 | // ScenePresence presence = scene.GetScenePresence(agent1); | ||
259 | // ScenePresence presence2 = scene2.GetScenePresence(agent1); | ||
260 | // presence2.AddAttachment(sog1); | ||
261 | // presence2.AddAttachment(sog2); | ||
262 | // | ||
263 | // ISharedRegionModule serialiser = new SerialiserModule(); | ||
264 | // SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); | ||
265 | // SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); | ||
266 | // | ||
267 | // Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); | ||
268 | // | ||
269 | // //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | ||
270 | // Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | ||
271 | // Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | ||
272 | // } | ||
273 | } | ||
274 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index d02a305..b6a1564 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
104 | public void NewClient(IClientAPI client) | 104 | public void NewClient(IClientAPI client) |
105 | { | 105 | { |
106 | client.OnRequestWearables += SendWearables; | 106 | client.OnRequestWearables += SendWearables; |
107 | client.OnSetAppearance += SetAppearance; | 107 | client.OnSetAppearance += SetAppearanceFromClient; |
108 | client.OnAvatarNowWearing += AvatarIsWearing; | 108 | client.OnAvatarNowWearing += AvatarIsWearing; |
109 | } | 109 | } |
110 | 110 | ||
@@ -116,16 +116,20 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
116 | #endregion | 116 | #endregion |
117 | 117 | ||
118 | /// <summary> | 118 | /// <summary> |
119 | /// Check for the existence of the baked texture assets. Request a rebake | 119 | /// Check for the existence of the baked texture assets. |
120 | /// unless checkonly is true. | ||
121 | /// </summary> | 120 | /// </summary> |
122 | /// <param name="client"></param> | 121 | /// <param name="client"></param> |
123 | /// <param name="checkonly"></param> | ||
124 | public bool ValidateBakedTextureCache(IClientAPI client) | 122 | public bool ValidateBakedTextureCache(IClientAPI client) |
125 | { | 123 | { |
126 | return ValidateBakedTextureCache(client, true); | 124 | return ValidateBakedTextureCache(client, true); |
127 | } | 125 | } |
128 | 126 | ||
127 | /// <summary> | ||
128 | /// Check for the existence of the baked texture assets. Request a rebake | ||
129 | /// unless checkonly is true. | ||
130 | /// </summary> | ||
131 | /// <param name="client"></param> | ||
132 | /// <param name="checkonly"></param> | ||
129 | private bool ValidateBakedTextureCache(IClientAPI client, bool checkonly) | 133 | private bool ValidateBakedTextureCache(IClientAPI client, bool checkonly) |
130 | { | 134 | { |
131 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 135 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
@@ -147,6 +151,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
147 | if (face == null) | 151 | if (face == null) |
148 | continue; | 152 | continue; |
149 | 153 | ||
154 | // m_log.DebugFormat( | ||
155 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", | ||
156 | // face.TextureID, idx, client.Name, client.AgentId); | ||
157 | |||
150 | // if the texture is one of the "defaults" then skip it | 158 | // if the texture is one of the "defaults" then skip it |
151 | // this should probably be more intelligent (skirt texture doesnt matter | 159 | // this should probably be more intelligent (skirt texture doesnt matter |
152 | // if the avatar isnt wearing a skirt) but if any of the main baked | 160 | // if the avatar isnt wearing a skirt) but if any of the main baked |
@@ -156,13 +164,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
156 | 164 | ||
157 | defonly = false; // found a non-default texture reference | 165 | defonly = false; // found a non-default texture reference |
158 | 166 | ||
159 | if (! CheckBakedTextureAsset(client,face.TextureID,idx)) | 167 | if (!CheckBakedTextureAsset(client, face.TextureID, idx)) |
160 | { | 168 | { |
161 | // the asset didn't exist if we are only checking, then we found a bad | 169 | // the asset didn't exist if we are only checking, then we found a bad |
162 | // one and we're done otherwise, ask for a rebake | 170 | // one and we're done otherwise, ask for a rebake |
163 | if (checkonly) return false; | 171 | if (checkonly) |
172 | return false; | ||
164 | 173 | ||
165 | m_log.InfoFormat("[AVFACTORY]: missing baked texture {0}, requesting rebake", face.TextureID); | 174 | m_log.InfoFormat("[AVFACTORY]: missing baked texture {0}, requesting rebake", face.TextureID); |
175 | |||
166 | client.SendRebakeAvatarTextures(face.TextureID); | 176 | client.SendRebakeAvatarTextures(face.TextureID); |
167 | } | 177 | } |
168 | } | 178 | } |
@@ -174,16 +184,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
174 | } | 184 | } |
175 | 185 | ||
176 | /// <summary> | 186 | /// <summary> |
177 | /// Set appearance data (textureentry and slider settings) received from the client | 187 | /// Set appearance data (texture asset IDs and slider settings) received from the client |
178 | /// </summary> | 188 | /// </summary> |
189 | /// <param name="client"></param> | ||
179 | /// <param name="texture"></param> | 190 | /// <param name="texture"></param> |
180 | /// <param name="visualParam"></param> | 191 | /// <param name="visualParam"></param> |
181 | public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) | 192 | public void SetAppearanceFromClient(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) |
182 | { | 193 | { |
183 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 194 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
184 | if (sp == null) | 195 | if (sp == null) |
185 | { | 196 | { |
186 | m_log.WarnFormat("[AVFACTORY]: SetAppearance unable to find presence for {0}",client.AgentId); | 197 | m_log.WarnFormat("[AVFACTORY]: SetAppearance unable to find presence for {0}", client.AgentId); |
187 | return; | 198 | return; |
188 | } | 199 | } |
189 | 200 | ||
@@ -211,18 +222,18 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
211 | changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; | 222 | changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; |
212 | 223 | ||
213 | m_log.InfoFormat("[AVFACTORY]: received texture update for {0}", client.AgentId); | 224 | m_log.InfoFormat("[AVFACTORY]: received texture update for {0}", client.AgentId); |
214 | Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(client,false); }); | 225 | Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(client, false); }); |
215 | 226 | ||
216 | // This appears to be set only in the final stage of the appearance | 227 | // This appears to be set only in the final stage of the appearance |
217 | // update transaction. In theory, we should be able to do an immediate | 228 | // update transaction. In theory, we should be able to do an immediate |
218 | // appearance send and save here. | 229 | // appearance send and save here. |
219 | 230 | ||
220 | // save only if there were changes, send no matter what (doesn't hurt to send twice) | ||
221 | if (changed) | ||
222 | QueueAppearanceSave(client.AgentId); | ||
223 | QueueAppearanceSend(client.AgentId); | ||
224 | } | 231 | } |
232 | // save only if there were changes, send no matter what (doesn't hurt to send twice) | ||
233 | if (changed) | ||
234 | QueueAppearanceSave(client.AgentId); | ||
225 | 235 | ||
236 | QueueAppearanceSend(client.AgentId); | ||
226 | } | 237 | } |
227 | 238 | ||
228 | // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); | 239 | // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); |
@@ -246,6 +257,117 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
246 | return true; | 257 | return true; |
247 | } | 258 | } |
248 | 259 | ||
260 | public Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId) | ||
261 | { | ||
262 | ScenePresence sp = m_scene.GetScenePresence(agentId); | ||
263 | |||
264 | if (sp == null) | ||
265 | return new Dictionary<BakeType, Primitive.TextureEntryFace>(); | ||
266 | |||
267 | return GetBakedTextureFaces(sp); | ||
268 | } | ||
269 | |||
270 | private Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(ScenePresence sp) | ||
271 | { | ||
272 | if (sp.IsChildAgent) | ||
273 | return new Dictionary<BakeType, Primitive.TextureEntryFace>(); | ||
274 | |||
275 | Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures | ||
276 | = new Dictionary<BakeType, Primitive.TextureEntryFace>(); | ||
277 | |||
278 | AvatarAppearance appearance = sp.Appearance; | ||
279 | Primitive.TextureEntryFace[] faceTextures = appearance.Texture.FaceTextures; | ||
280 | |||
281 | foreach (int i in Enum.GetValues(typeof(BakeType))) | ||
282 | { | ||
283 | BakeType bakeType = (BakeType)i; | ||
284 | |||
285 | if (bakeType == BakeType.Unknown) | ||
286 | continue; | ||
287 | |||
288 | // m_log.DebugFormat( | ||
289 | // "[AVFACTORY]: NPC avatar {0} has texture id {1} : {2}", | ||
290 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); | ||
291 | |||
292 | int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); | ||
293 | bakedTextures[bakeType] = faceTextures[ftIndex]; | ||
294 | } | ||
295 | |||
296 | return bakedTextures; | ||
297 | } | ||
298 | |||
299 | public bool SaveBakedTextures(UUID agentId) | ||
300 | { | ||
301 | ScenePresence sp = m_scene.GetScenePresence(agentId); | ||
302 | |||
303 | if (sp == null) | ||
304 | return false; | ||
305 | |||
306 | m_log.DebugFormat( | ||
307 | "[AV FACTORY]: Permanently saving baked textures for {0} in {1}", | ||
308 | sp.Name, m_scene.RegionInfo.RegionName); | ||
309 | |||
310 | Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = GetBakedTextureFaces(sp); | ||
311 | |||
312 | if (bakedTextures.Count == 0) | ||
313 | return false; | ||
314 | |||
315 | foreach (BakeType bakeType in bakedTextures.Keys) | ||
316 | { | ||
317 | Primitive.TextureEntryFace bakedTextureFace = bakedTextures[bakeType]; | ||
318 | |||
319 | if (bakedTextureFace == null) | ||
320 | { | ||
321 | m_log.WarnFormat( | ||
322 | "[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently", | ||
323 | bakeType, sp.Name, m_scene.RegionInfo.RegionName); | ||
324 | |||
325 | continue; | ||
326 | } | ||
327 | |||
328 | AssetBase asset = m_scene.AssetService.Get(bakedTextureFace.TextureID.ToString()); | ||
329 | |||
330 | if (asset != null) | ||
331 | { | ||
332 | asset.Temporary = false; | ||
333 | asset.Local = false; | ||
334 | m_scene.AssetService.Store(asset); | ||
335 | } | ||
336 | else | ||
337 | { | ||
338 | m_log.WarnFormat( | ||
339 | "[AV FACTORY]: Baked texture id {0} not found for bake {1} for avatar {2} in {3} when trying to save permanently", | ||
340 | bakedTextureFace.TextureID, bakeType, sp.Name, m_scene.RegionInfo.RegionName); | ||
341 | } | ||
342 | } | ||
343 | |||
344 | // for (int i = 0; i < faceTextures.Length; i++) | ||
345 | // { | ||
346 | //// m_log.DebugFormat( | ||
347 | //// "[AVFACTORY]: NPC avatar {0} has texture id {1} : {2}", | ||
348 | //// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); | ||
349 | // | ||
350 | // if (faceTextures[i] == null) | ||
351 | // continue; | ||
352 | // | ||
353 | // AssetBase asset = m_scene.AssetService.Get(faceTextures[i].TextureID.ToString()); | ||
354 | // | ||
355 | // if (asset != null) | ||
356 | // { | ||
357 | // asset.Temporary = false; | ||
358 | // m_scene.AssetService.Store(asset); | ||
359 | // } | ||
360 | // else | ||
361 | // { | ||
362 | // m_log.WarnFormat( | ||
363 | // "[AV FACTORY]: Baked texture {0} for {1} in {2} not found when trying to save permanently", | ||
364 | // faceTextures[i].TextureID, sp.Name, m_scene.RegionInfo.RegionName); | ||
365 | // } | ||
366 | // } | ||
367 | |||
368 | return true; | ||
369 | } | ||
370 | |||
249 | #region UpdateAppearanceTimer | 371 | #region UpdateAppearanceTimer |
250 | 372 | ||
251 | /// <summary> | 373 | /// <summary> |
@@ -278,26 +400,13 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
278 | } | 400 | } |
279 | } | 401 | } |
280 | 402 | ||
281 | private void HandleAppearanceSend(UUID agentid) | 403 | private void SaveAppearance(UUID agentid) |
282 | { | 404 | { |
283 | ScenePresence sp = m_scene.GetScenePresence(agentid); | 405 | // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved |
284 | if (sp == null) | 406 | // in a culture where decimal points are commas and then reloaded in a culture which just treats them as |
285 | { | 407 | // number seperators. |
286 | m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); | 408 | Culture.SetCurrentCulture(); |
287 | return; | ||
288 | } | ||
289 | |||
290 | // m_log.WarnFormat("[AVFACTORY]: Handle appearance send for {0}", agentid); | ||
291 | 409 | ||
292 | // Send the appearance to everyone in the scene | ||
293 | sp.SendAppearanceToAllOtherAgents(); | ||
294 | |||
295 | // Send animations back to the avatar as well | ||
296 | sp.Animator.SendAnimPack(); | ||
297 | } | ||
298 | |||
299 | private void HandleAppearanceSave(UUID agentid) | ||
300 | { | ||
301 | ScenePresence sp = m_scene.GetScenePresence(agentid); | 410 | ScenePresence sp = m_scene.GetScenePresence(agentid); |
302 | if (sp == null) | 411 | if (sp == null) |
303 | { | 412 | { |
@@ -321,7 +430,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
321 | { | 430 | { |
322 | if (kvp.Value < now) | 431 | if (kvp.Value < now) |
323 | { | 432 | { |
324 | Util.FireAndForget(delegate(object o) { HandleAppearanceSend(kvp.Key); }); | 433 | Util.FireAndForget(delegate(object o) { SendAppearance(kvp.Key); }); |
325 | m_sendqueue.Remove(kvp.Key); | 434 | m_sendqueue.Remove(kvp.Key); |
326 | } | 435 | } |
327 | } | 436 | } |
@@ -334,7 +443,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
334 | { | 443 | { |
335 | if (kvp.Value < now) | 444 | if (kvp.Value < now) |
336 | { | 445 | { |
337 | Util.FireAndForget(delegate(object o) { HandleAppearanceSave(kvp.Key); }); | 446 | Util.FireAndForget(delegate(object o) { SaveAppearance(kvp.Key); }); |
338 | m_savequeue.Remove(kvp.Key); | 447 | m_savequeue.Remove(kvp.Key); |
339 | } | 448 | } |
340 | } | 449 | } |
@@ -380,11 +489,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
380 | // m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}", client.AgentId); | 489 | // m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}", client.AgentId); |
381 | 490 | ||
382 | // we need to clean out the existing textures | 491 | // we need to clean out the existing textures |
383 | sp.Appearance.ResetAppearance(); | 492 | sp.Appearance.ResetAppearance(); |
384 | 493 | ||
385 | // operate on a copy of the appearance so we don't have to lock anything | 494 | // operate on a copy of the appearance so we don't have to lock anything yet |
386 | AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false); | 495 | AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false); |
387 | 496 | ||
388 | foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) | 497 | foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) |
389 | { | 498 | { |
390 | if (wear.Type < AvatarWearable.MAX_WEARABLES) | 499 | if (wear.Type < AvatarWearable.MAX_WEARABLES) |
@@ -396,12 +505,37 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
396 | // This could take awhile since it needs to pull inventory | 505 | // This could take awhile since it needs to pull inventory |
397 | SetAppearanceAssets(sp.UUID, ref avatAppearance); | 506 | SetAppearanceAssets(sp.UUID, ref avatAppearance); |
398 | 507 | ||
399 | // could get fancier with the locks here, but in the spirit of "last write wins" | 508 | lock (m_setAppearanceLock) |
400 | // this should work correctly, also, we don't need to send the appearance here | 509 | { |
401 | // since the "iswearing" will trigger a new set of visual param and baked texture changes | 510 | // Update only those fields that we have changed. This is important because the viewer |
402 | // when those complete, the new appearance will be sent | 511 | // often sends AvatarIsWearing and SetAppearance packets at once, and AvatarIsWearing |
403 | sp.Appearance = avatAppearance; | 512 | // shouldn't overwrite the changes made in SetAppearance. |
404 | QueueAppearanceSave(client.AgentId); | 513 | sp.Appearance.Wearables = avatAppearance.Wearables; |
514 | sp.Appearance.Texture = avatAppearance.Texture; | ||
515 | |||
516 | // We don't need to send the appearance here since the "iswearing" will trigger a new set | ||
517 | // of visual param and baked texture changes. When those complete, the new appearance will be sent | ||
518 | |||
519 | QueueAppearanceSave(client.AgentId); | ||
520 | } | ||
521 | } | ||
522 | |||
523 | public bool SendAppearance(UUID agentId) | ||
524 | { | ||
525 | ScenePresence sp = m_scene.GetScenePresence(agentId); | ||
526 | if (sp == null) | ||
527 | { | ||
528 | m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); | ||
529 | return false; | ||
530 | } | ||
531 | |||
532 | // Send the appearance to everyone in the scene | ||
533 | sp.SendAppearanceToAllOtherAgents(); | ||
534 | |||
535 | // Send animations back to the avatar as well | ||
536 | sp.Animator.SendAnimPack(); | ||
537 | |||
538 | return true; | ||
405 | } | 539 | } |
406 | 540 | ||
407 | private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) | 541 | private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs new file mode 100644 index 0000000..7b2f14e --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs | |||
@@ -0,0 +1,120 @@ | |||
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.Collections.Generic; | ||
30 | using Nini.Config; | ||
31 | using NUnit.Framework; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.CoreModules.Asset; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Tests.Common; | ||
37 | using OpenSim.Tests.Common.Mock; | ||
38 | |||
39 | namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | ||
40 | { | ||
41 | [TestFixture] | ||
42 | public class AvatarFactoryModuleTests | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// Only partial right now since we don't yet test that it's ended up in the avatar appearance service. | ||
46 | /// </summary> | ||
47 | [Test] | ||
48 | public void TestSetAppearance() | ||
49 | { | ||
50 | TestHelpers.InMethod(); | ||
51 | // log4net.Config.XmlConfigurator.Configure(); | ||
52 | |||
53 | UUID userId = TestHelpers.ParseTail(0x1); | ||
54 | |||
55 | AvatarFactoryModule afm = new AvatarFactoryModule(); | ||
56 | TestScene scene = SceneHelpers.SetupScene(); | ||
57 | SceneHelpers.SetupSceneModules(scene, afm); | ||
58 | IClientAPI tc = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; | ||
59 | |||
60 | byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT]; | ||
61 | for (byte i = 0; i < visualParams.Length; i++) | ||
62 | visualParams[i] = i; | ||
63 | |||
64 | afm.SetAppearanceFromClient(tc, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams); | ||
65 | |||
66 | ScenePresence sp = scene.GetScenePresence(userId); | ||
67 | |||
68 | // TODO: Check baked texture | ||
69 | Assert.AreEqual(visualParams, sp.Appearance.VisualParams); | ||
70 | } | ||
71 | |||
72 | [Test] | ||
73 | public void TestSaveBakedTextures() | ||
74 | { | ||
75 | TestHelpers.InMethod(); | ||
76 | // log4net.Config.XmlConfigurator.Configure(); | ||
77 | |||
78 | UUID userId = TestHelpers.ParseTail(0x1); | ||
79 | UUID eyesTextureId = TestHelpers.ParseTail(0x2); | ||
80 | |||
81 | // We need an asset cache because otherwise the LocalAssetServiceConnector will short-circuit directly | ||
82 | // to the AssetService, which will then store temporary and local assets permanently | ||
83 | CoreAssetCache assetCache = new CoreAssetCache(); | ||
84 | |||
85 | AvatarFactoryModule afm = new AvatarFactoryModule(); | ||
86 | TestScene scene = SceneHelpers.SetupScene(assetCache); | ||
87 | SceneHelpers.SetupSceneModules(scene, afm); | ||
88 | IClientAPI tc = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; | ||
89 | |||
90 | // TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules | ||
91 | AssetBase uploadedAsset; | ||
92 | uploadedAsset = new AssetBase(eyesTextureId, "Baked Texture", (sbyte)AssetType.Texture, userId.ToString()); | ||
93 | uploadedAsset.Data = new byte[] { 2 }; | ||
94 | uploadedAsset.Temporary = true; | ||
95 | uploadedAsset.Local = true; // Local assets aren't persisted, non-local are | ||
96 | scene.AssetService.Store(uploadedAsset); | ||
97 | |||
98 | byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT]; | ||
99 | for (byte i = 0; i < visualParams.Length; i++) | ||
100 | visualParams[i] = i; | ||
101 | |||
102 | Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)); | ||
103 | uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes); | ||
104 | Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); | ||
105 | eyesFace.TextureID = eyesTextureId; | ||
106 | |||
107 | afm.SetAppearanceFromClient(tc, bakedTextureEntry, visualParams); | ||
108 | afm.SaveBakedTextures(userId); | ||
109 | // Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId); | ||
110 | |||
111 | // We should also inpsect the asset data store layer directly, but this is difficult to get at right now. | ||
112 | assetCache.Clear(); | ||
113 | |||
114 | AssetBase eyesBake = scene.AssetService.Get(eyesTextureId.ToString()); | ||
115 | Assert.That(eyesBake, Is.Not.Null); | ||
116 | Assert.That(eyesBake.Temporary, Is.False); | ||
117 | Assert.That(eyesBake.Local, Is.False); | ||
118 | } | ||
119 | } | ||
120 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 1a0b914..d9dcee7 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -172,11 +172,15 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
172 | private void RetrieveInstantMessages(IClientAPI client) | 172 | private void RetrieveInstantMessages(IClientAPI client) |
173 | { | 173 | { |
174 | if (m_RestURL == String.Empty) | 174 | if (m_RestURL == String.Empty) |
175 | { | ||
175 | return; | 176 | return; |
177 | } | ||
178 | else | ||
179 | { | ||
180 | m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); | ||
176 | 181 | ||
177 | m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId); | 182 | List<GridInstantMessage> msglist |
178 | 183 | = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>( | |
179 | List<GridInstantMessage> msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>( | ||
180 | "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); | 184 | "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); |
181 | 185 | ||
182 | if (msglist != null) | 186 | if (msglist != null) |
@@ -209,6 +213,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
209 | im.dialog != (byte)InstantMessageDialog.GroupInvitation && | 213 | im.dialog != (byte)InstantMessageDialog.GroupInvitation && |
210 | im.dialog != (byte)InstantMessageDialog.InventoryOffered) | 214 | im.dialog != (byte)InstantMessageDialog.InventoryOffered) |
211 | { | 215 | { |
216 | bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( | ||
217 | "POST", m_RestURL+"/SaveMessage/", im); | ||
212 | return; | 218 | return; |
213 | } | 219 | } |
214 | 220 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index aadeedb..19ef571 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs | |||
@@ -100,8 +100,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
100 | // log4net.Config.XmlConfigurator.Configure(); | 100 | // log4net.Config.XmlConfigurator.Configure(); |
101 | 101 | ||
102 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 102 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
103 | Scene scene = SceneSetupHelpers.SetupScene(); | 103 | Scene scene = SceneHelpers.SetupScene(); |
104 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | 104 | SceneHelpers.SetupSceneModules(scene, archiverModule); |
105 | 105 | ||
106 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); | 106 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); |
107 | 107 | ||
@@ -109,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
109 | 109 | ||
110 | // Create scene object asset | 110 | // Create scene object asset |
111 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | 111 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); |
112 | SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50); | 112 | SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50); |
113 | 113 | ||
114 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 114 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
115 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | 115 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
@@ -127,10 +127,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
127 | scene.AddInventoryItem(item1); | 127 | scene.AddInventoryItem(item1); |
128 | 128 | ||
129 | // Create coalesced objects asset | 129 | // Create coalesced objects asset |
130 | SceneObjectGroup cobj1 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120); | 130 | SceneObjectGroup cobj1 = SceneHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120); |
131 | cobj1.AbsolutePosition = new Vector3(15, 30, 45); | 131 | cobj1.AbsolutePosition = new Vector3(15, 30, 45); |
132 | 132 | ||
133 | SceneObjectGroup cobj2 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140); | 133 | SceneObjectGroup cobj2 = SceneHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140); |
134 | cobj2.AbsolutePosition = new Vector3(25, 50, 75); | 134 | cobj2.AbsolutePosition = new Vector3(25, 50, 75); |
135 | 135 | ||
136 | CoalescedSceneObjects coa = new CoalescedSceneObjects(m_uaLL1.PrincipalID, cobj1, cobj2); | 136 | CoalescedSceneObjects coa = new CoalescedSceneObjects(m_uaLL1.PrincipalID, cobj1, cobj2); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index ae3ab21..e409c8e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -61,14 +61,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
61 | SerialiserModule serialiserModule = new SerialiserModule(); | 61 | SerialiserModule serialiserModule = new SerialiserModule(); |
62 | m_archiverModule = new InventoryArchiverModule(); | 62 | m_archiverModule = new InventoryArchiverModule(); |
63 | 63 | ||
64 | m_scene = SceneSetupHelpers.SetupScene(); | 64 | m_scene = SceneHelpers.SetupScene(); |
65 | SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); | 65 | SceneHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); |
66 | } | 66 | } |
67 | 67 | ||
68 | [Test] | 68 | [Test] |
69 | public void TestLoadCoalesecedItem() | 69 | public void TestLoadCoalesecedItem() |
70 | { | 70 | { |
71 | TestHelper.InMethod(); | 71 | TestHelpers.InMethod(); |
72 | // log4net.Config.XmlConfigurator.Configure(); | 72 | // log4net.Config.XmlConfigurator.Configure(); |
73 | 73 | ||
74 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password"); | 74 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password"); |
@@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
104 | [Test] | 104 | [Test] |
105 | public void TestOrder() | 105 | public void TestOrder() |
106 | { | 106 | { |
107 | TestHelper.InMethod(); | 107 | TestHelpers.InMethod(); |
108 | // log4net.Config.XmlConfigurator.Configure(); | 108 | // log4net.Config.XmlConfigurator.Configure(); |
109 | 109 | ||
110 | MemoryStream archiveReadStream = new MemoryStream(m_iarStreamBytes); | 110 | MemoryStream archiveReadStream = new MemoryStream(m_iarStreamBytes); |
@@ -129,7 +129,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
129 | [Test] | 129 | [Test] |
130 | public void TestSaveItemToIar() | 130 | public void TestSaveItemToIar() |
131 | { | 131 | { |
132 | TestHelper.InMethod(); | 132 | TestHelpers.InMethod(); |
133 | // log4net.Config.XmlConfigurator.Configure(); | 133 | // log4net.Config.XmlConfigurator.Configure(); |
134 | 134 | ||
135 | // Create user | 135 | // Create user |
@@ -141,7 +141,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
141 | 141 | ||
142 | // Create asset | 142 | // Create asset |
143 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | 143 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); |
144 | SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50); | 144 | SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50); |
145 | 145 | ||
146 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 146 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
147 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | 147 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
@@ -224,7 +224,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
224 | [Test] | 224 | [Test] |
225 | public void TestSaveItemToIarNoAssets() | 225 | public void TestSaveItemToIarNoAssets() |
226 | { | 226 | { |
227 | TestHelper.InMethod(); | 227 | TestHelpers.InMethod(); |
228 | // log4net.Config.XmlConfigurator.Configure(); | 228 | // log4net.Config.XmlConfigurator.Configure(); |
229 | 229 | ||
230 | // Create user | 230 | // Create user |
@@ -236,7 +236,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
236 | 236 | ||
237 | // Create asset | 237 | // Create asset |
238 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | 238 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); |
239 | SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50); | 239 | SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50); |
240 | 240 | ||
241 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 241 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
242 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | 242 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
@@ -325,7 +325,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
325 | [Test] | 325 | [Test] |
326 | public void TestLoadIarCreatorAccountPresent() | 326 | public void TestLoadIarCreatorAccountPresent() |
327 | { | 327 | { |
328 | TestHelper.InMethod(); | 328 | TestHelpers.InMethod(); |
329 | // log4net.Config.XmlConfigurator.Configure(); | 329 | // log4net.Config.XmlConfigurator.Configure(); |
330 | 330 | ||
331 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood"); | 331 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood"); |
@@ -357,7 +357,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
357 | [Test] | 357 | [Test] |
358 | public void TestLoadIarV0_1SameNameCreator() | 358 | public void TestLoadIarV0_1SameNameCreator() |
359 | { | 359 | { |
360 | TestHelper.InMethod(); | 360 | TestHelpers.InMethod(); |
361 | // log4net.Config.XmlConfigurator.Configure(); | 361 | // log4net.Config.XmlConfigurator.Configure(); |
362 | 362 | ||
363 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood"); | 363 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood"); |
@@ -390,7 +390,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
390 | [Test] | 390 | [Test] |
391 | public void TestLoadIarV0_1AbsentCreator() | 391 | public void TestLoadIarV0_1AbsentCreator() |
392 | { | 392 | { |
393 | TestHelper.InMethod(); | 393 | TestHelpers.InMethod(); |
394 | // log4net.Config.XmlConfigurator.Configure(); | 394 | // log4net.Config.XmlConfigurator.Configure(); |
395 | 395 | ||
396 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "password"); | 396 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "password"); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs index 127d5f8..417c20c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs | |||
@@ -57,13 +57,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
57 | [Test] | 57 | [Test] |
58 | public void TestSavePathToIarV0_1() | 58 | public void TestSavePathToIarV0_1() |
59 | { | 59 | { |
60 | TestHelper.InMethod(); | 60 | TestHelpers.InMethod(); |
61 | // log4net.Config.XmlConfigurator.Configure(); | 61 | // log4net.Config.XmlConfigurator.Configure(); |
62 | 62 | ||
63 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 63 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
64 | 64 | ||
65 | Scene scene = SceneSetupHelpers.SetupScene(); | 65 | Scene scene = SceneHelpers.SetupScene(); |
66 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | 66 | SceneHelpers.SetupSceneModules(scene, archiverModule); |
67 | 67 | ||
68 | // Create user | 68 | // Create user |
69 | string userFirstName = "Jock"; | 69 | string userFirstName = "Jock"; |
@@ -172,16 +172,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
172 | [Test] | 172 | [Test] |
173 | public void TestLoadIarToInventoryPaths() | 173 | public void TestLoadIarToInventoryPaths() |
174 | { | 174 | { |
175 | TestHelper.InMethod(); | 175 | TestHelpers.InMethod(); |
176 | // log4net.Config.XmlConfigurator.Configure(); | 176 | // log4net.Config.XmlConfigurator.Configure(); |
177 | 177 | ||
178 | SerialiserModule serialiserModule = new SerialiserModule(); | 178 | SerialiserModule serialiserModule = new SerialiserModule(); |
179 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 179 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
180 | 180 | ||
181 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | 181 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene |
182 | Scene scene = SceneSetupHelpers.SetupScene(); | 182 | Scene scene = SceneHelpers.SetupScene(); |
183 | 183 | ||
184 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | 184 | SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); |
185 | 185 | ||
186 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "meowfood"); | 186 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "meowfood"); |
187 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); | 187 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); |
@@ -217,13 +217,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
217 | [Test] | 217 | [Test] |
218 | public void TestLoadIarPathStartsWithSlash() | 218 | public void TestLoadIarPathStartsWithSlash() |
219 | { | 219 | { |
220 | TestHelper.InMethod(); | 220 | TestHelpers.InMethod(); |
221 | // log4net.Config.XmlConfigurator.Configure(); | 221 | // log4net.Config.XmlConfigurator.Configure(); |
222 | 222 | ||
223 | SerialiserModule serialiserModule = new SerialiserModule(); | 223 | SerialiserModule serialiserModule = new SerialiserModule(); |
224 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 224 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
225 | Scene scene = SceneSetupHelpers.SetupScene(); | 225 | Scene scene = SceneHelpers.SetupScene(); |
226 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | 226 | SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); |
227 | 227 | ||
228 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "password"); | 228 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "password"); |
229 | archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream); | 229 | archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream); |
@@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
238 | [Test] | 238 | [Test] |
239 | public void TestLoadIarPathWithEscapedChars() | 239 | public void TestLoadIarPathWithEscapedChars() |
240 | { | 240 | { |
241 | TestHelper.InMethod(); | 241 | TestHelpers.InMethod(); |
242 | // log4net.Config.XmlConfigurator.Configure(); | 242 | // log4net.Config.XmlConfigurator.Configure(); |
243 | 243 | ||
244 | string itemName = "You & you are a mean/man/"; | 244 | string itemName = "You & you are a mean/man/"; |
@@ -247,8 +247,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
247 | 247 | ||
248 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 248 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
249 | 249 | ||
250 | Scene scene = SceneSetupHelpers.SetupScene(); | 250 | Scene scene = SceneHelpers.SetupScene(); |
251 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | 251 | SceneHelpers.SetupSceneModules(scene, archiverModule); |
252 | 252 | ||
253 | // Create user | 253 | // Create user |
254 | string userFirstName = "Jock"; | 254 | string userFirstName = "Jock"; |
@@ -323,10 +323,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
323 | [Test] | 323 | [Test] |
324 | public void TestNewIarPath() | 324 | public void TestNewIarPath() |
325 | { | 325 | { |
326 | TestHelper.InMethod(); | 326 | TestHelpers.InMethod(); |
327 | // log4net.Config.XmlConfigurator.Configure(); | 327 | // log4net.Config.XmlConfigurator.Configure(); |
328 | 328 | ||
329 | Scene scene = SceneSetupHelpers.SetupScene(); | 329 | Scene scene = SceneHelpers.SetupScene(); |
330 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); | 330 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); |
331 | 331 | ||
332 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); | 332 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); |
@@ -390,10 +390,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
390 | [Test] | 390 | [Test] |
391 | public void TestPartExistingIarPath() | 391 | public void TestPartExistingIarPath() |
392 | { | 392 | { |
393 | TestHelper.InMethod(); | 393 | TestHelpers.InMethod(); |
394 | //log4net.Config.XmlConfigurator.Configure(); | 394 | //log4net.Config.XmlConfigurator.Configure(); |
395 | 395 | ||
396 | Scene scene = SceneSetupHelpers.SetupScene(); | 396 | Scene scene = SceneHelpers.SetupScene(); |
397 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); | 397 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); |
398 | 398 | ||
399 | string folder1ExistingName = "a"; | 399 | string folder1ExistingName = "a"; |
@@ -441,10 +441,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
441 | [Test] | 441 | [Test] |
442 | public void TestMergeIarPath() | 442 | public void TestMergeIarPath() |
443 | { | 443 | { |
444 | TestHelper.InMethod(); | 444 | TestHelpers.InMethod(); |
445 | // log4net.Config.XmlConfigurator.Configure(); | 445 | // log4net.Config.XmlConfigurator.Configure(); |
446 | 446 | ||
447 | Scene scene = SceneSetupHelpers.SetupScene(); | 447 | Scene scene = SceneHelpers.SetupScene(); |
448 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); | 448 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); |
449 | 449 | ||
450 | string folder1ExistingName = "a"; | 450 | string folder1ExistingName = "a"; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 528bc8d..120fd43 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -208,9 +208,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
208 | Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length); | 208 | Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length); |
209 | 209 | ||
210 | if (user != null) | 210 | if (user != null) |
211 | { | ||
212 | user.ControllingClient.SendBulkUpdateInventory(folderCopy); | 211 | user.ControllingClient.SendBulkUpdateInventory(folderCopy); |
213 | } | ||
214 | 212 | ||
215 | // HACK!! | 213 | // HACK!! |
216 | im.imSessionID = folderID.Guid; | 214 | im.imSessionID = folderID.Guid; |
@@ -240,9 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
240 | Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16); | 238 | Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16); |
241 | 239 | ||
242 | if (user != null) | 240 | if (user != null) |
243 | { | ||
244 | user.ControllingClient.SendBulkUpdateInventory(itemCopy); | 241 | user.ControllingClient.SendBulkUpdateInventory(itemCopy); |
245 | } | ||
246 | 242 | ||
247 | // HACK!! | 243 | // HACK!! |
248 | im.imSessionID = itemID.Guid; | 244 | im.imSessionID = itemID.Guid; |
@@ -280,7 +276,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
280 | else | 276 | else |
281 | { | 277 | { |
282 | if (m_TransferModule != null) | 278 | if (m_TransferModule != null) |
283 | m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); | 279 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { |
280 | // Send BulkUpdateInventory | ||
281 | IInventoryService invService = scene.InventoryService; | ||
282 | UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip | ||
283 | |||
284 | InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); | ||
285 | folder = invService.GetFolder(folder); | ||
286 | |||
287 | ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); | ||
288 | |||
289 | // If the user has left the scene by the time the message comes back then we can't send | ||
290 | // them the update. | ||
291 | if (fromUser != null) | ||
292 | fromUser.ControllingClient.SendBulkUpdateInventory(folder); | ||
293 | }); | ||
284 | } | 294 | } |
285 | } | 295 | } |
286 | else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) | 296 | else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs index c82cfd2..d687e6a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs | |||
@@ -196,7 +196,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
196 | if (!(client.Scene is Scene)) | 196 | if (!(client.Scene is Scene)) |
197 | return; | 197 | return; |
198 | 198 | ||
199 | Scene scene = (Scene)(client.Scene); | 199 | // Scene scene = (Scene)(client.Scene); |
200 | 200 | ||
201 | GridInstantMessage im = null; | 201 | GridInstantMessage im = null; |
202 | if (m_PendingLures.TryGetValue(lureID, out im)) | 202 | if (m_PendingLures.TryGetValue(lureID, out im)) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs index 079e1b6..dee0ad4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs | |||
@@ -134,7 +134,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profile | |||
134 | if (!(s is Scene)) | 134 | if (!(s is Scene)) |
135 | return; | 135 | return; |
136 | 136 | ||
137 | Scene scene = (Scene)s; | 137 | // Scene scene = (Scene)s; |
138 | 138 | ||
139 | string profileUrl = String.Empty; | 139 | string profileUrl = String.Empty; |
140 | string aboutText = String.Empty; | 140 | string aboutText = String.Empty; |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 90f0ca2..faccab2 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -209,7 +209,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
209 | sp.TeleportFlags = (TeleportFlags)teleportFlags; | 209 | sp.TeleportFlags = (TeleportFlags)teleportFlags; |
210 | sp.Teleport(position); | 210 | sp.Teleport(position); |
211 | 211 | ||
212 | foreach (SceneObjectGroup grp in sp.Attachments) | 212 | foreach (SceneObjectGroup grp in sp.GetAttachments()) |
213 | sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT); | 213 | sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT); |
214 | } | 214 | } |
215 | else // Another region possibly in another simulator | 215 | else // Another region possibly in another simulator |
@@ -494,7 +494,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
494 | // Now let's make it officially a child agent | 494 | // Now let's make it officially a child agent |
495 | sp.MakeChildAgent(); | 495 | sp.MakeChildAgent(); |
496 | 496 | ||
497 | sp.Scene.CleanDroppedAttachments(); | 497 | // sp.Scene.CleanDroppedAttachments(); |
498 | 498 | ||
499 | // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone | 499 | // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone |
500 | 500 | ||
@@ -560,11 +560,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
560 | 560 | ||
561 | protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) | 561 | protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) |
562 | { | 562 | { |
563 | foreach (SceneObjectGroup sop in sp.Attachments) | 563 | sp.Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, true); |
564 | { | ||
565 | sop.Scene.DeleteSceneObject(sop, true); | ||
566 | } | ||
567 | sp.Attachments.Clear(); | ||
568 | } | 564 | } |
569 | 565 | ||
570 | protected void KillEntity(Scene scene, uint localID) | 566 | protected void KillEntity(Scene scene, uint localID) |
@@ -1088,10 +1084,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1088 | #endregion | 1084 | #endregion |
1089 | 1085 | ||
1090 | #region Enable Child Agent | 1086 | #region Enable Child Agent |
1087 | |||
1091 | /// <summary> | 1088 | /// <summary> |
1092 | /// This informs a single neighbouring region about agent "avatar". | 1089 | /// This informs a single neighbouring region about agent "avatar". |
1093 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | 1090 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. |
1094 | /// </summary> | 1091 | /// </summary> |
1092 | /// <param name="sp"></param> | ||
1093 | /// <param name="region"></param> | ||
1095 | public void EnableChildAgent(ScenePresence sp, GridRegion region) | 1094 | public void EnableChildAgent(ScenePresence sp, GridRegion region) |
1096 | { | 1095 | { |
1097 | m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName); | 1096 | m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName); |
@@ -1153,6 +1152,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1153 | /// This informs all neighbouring regions about agent "avatar". | 1152 | /// This informs all neighbouring regions about agent "avatar". |
1154 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | 1153 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. |
1155 | /// </summary> | 1154 | /// </summary> |
1155 | /// <param name="sp"></param> | ||
1156 | public void EnableChildAgents(ScenePresence sp) | 1156 | public void EnableChildAgents(ScenePresence sp) |
1157 | { | 1157 | { |
1158 | List<GridRegion> neighbours = new List<GridRegion>(); | 1158 | List<GridRegion> neighbours = new List<GridRegion>(); |
@@ -1340,7 +1340,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1340 | Utils.LongToUInts(reg.RegionHandle, out x, out y); | 1340 | Utils.LongToUInts(reg.RegionHandle, out x, out y); |
1341 | x = x / Constants.RegionSize; | 1341 | x = x / Constants.RegionSize; |
1342 | y = y / Constants.RegionSize; | 1342 | y = y / Constants.RegionSize; |
1343 | m_log.Debug("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")"); | 1343 | m_log.Debug("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint + ")"); |
1344 | 1344 | ||
1345 | string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath); | 1345 | string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath); |
1346 | 1346 | ||
@@ -1786,34 +1786,33 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1786 | 1786 | ||
1787 | protected bool CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent) | 1787 | protected bool CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent) |
1788 | { | 1788 | { |
1789 | List<SceneObjectGroup> m_attachments = sp.Attachments; | 1789 | List<SceneObjectGroup> m_attachments = sp.GetAttachments(); |
1790 | lock (m_attachments) | 1790 | |
1791 | // Validate | ||
1792 | foreach (SceneObjectGroup gobj in m_attachments) | ||
1791 | { | 1793 | { |
1792 | // Validate | 1794 | if (gobj == null || gobj.IsDeleted) |
1793 | foreach (SceneObjectGroup gobj in m_attachments) | 1795 | return false; |
1794 | { | 1796 | } |
1795 | if (gobj == null || gobj.IsDeleted) | ||
1796 | return false; | ||
1797 | } | ||
1798 | 1797 | ||
1799 | foreach (SceneObjectGroup gobj in m_attachments) | 1798 | foreach (SceneObjectGroup gobj in m_attachments) |
1799 | { | ||
1800 | // If the prim group is null then something must have happened to it! | ||
1801 | if (gobj != null) | ||
1800 | { | 1802 | { |
1801 | // If the prim group is null then something must have happened to it! | 1803 | // Set the parent localID to 0 so it transfers over properly. |
1802 | if (gobj != null && gobj.RootPart != null) | 1804 | gobj.RootPart.SetParentLocalId(0); |
1803 | { | 1805 | gobj.AbsolutePosition = gobj.RootPart.AttachedPos; |
1804 | // Set the parent localID to 0 so it transfers over properly. | 1806 | gobj.IsAttachment = false; |
1805 | gobj.RootPart.SetParentLocalId(0); | 1807 | //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); |
1806 | gobj.AbsolutePosition = gobj.RootPart.AttachedPos; | 1808 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); |
1807 | gobj.RootPart.IsAttachment = false; | 1809 | CrossPrimGroupIntoNewRegion(destination, gobj, silent); |
1808 | //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); | ||
1809 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); | ||
1810 | CrossPrimGroupIntoNewRegion(destination, gobj, silent); | ||
1811 | } | ||
1812 | } | 1810 | } |
1813 | m_attachments.Clear(); | ||
1814 | |||
1815 | return true; | ||
1816 | } | 1811 | } |
1812 | |||
1813 | sp.ClearAttachments(); | ||
1814 | |||
1815 | return true; | ||
1817 | } | 1816 | } |
1818 | 1817 | ||
1819 | #endregion | 1818 | #endregion |
@@ -1862,7 +1861,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1862 | int i = 0; | 1861 | int i = 0; |
1863 | if (sp.InTransitScriptStates.Count > 0) | 1862 | if (sp.InTransitScriptStates.Count > 0) |
1864 | { | 1863 | { |
1865 | sp.Attachments.ForEach(delegate(SceneObjectGroup sog) | 1864 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
1865 | |||
1866 | foreach (SceneObjectGroup sog in attachments) | ||
1866 | { | 1867 | { |
1867 | if (i < sp.InTransitScriptStates.Count) | 1868 | if (i < sp.InTransitScriptStates.Count) |
1868 | { | 1869 | { |
@@ -1871,8 +1872,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1871 | sog.ResumeScripts(); | 1872 | sog.ResumeScripts(); |
1872 | } | 1873 | } |
1873 | else | 1874 | else |
1874 | m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: InTransitScriptStates.Count={0} smaller than Attachments.Count={1}", sp.InTransitScriptStates.Count, sp.Attachments.Count); | 1875 | m_log.ErrorFormat( |
1875 | }); | 1876 | "[ENTITY TRANSFER MODULE]: InTransitScriptStates.Count={0} smaller than Attachments.Count={1}", |
1877 | sp.InTransitScriptStates.Count, attachments.Count); | ||
1878 | } | ||
1876 | 1879 | ||
1877 | sp.InTransitScriptStates.Clear(); | 1880 | sp.InTransitScriptStates.Clear(); |
1878 | } | 1881 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index a98ce85..654e202 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -325,7 +325,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | // This is pethod scoped and will be returned. It will be the | 328 | // This is method scoped and will be returned. It will be the |
329 | // last created asset id | 329 | // last created asset id |
330 | UUID assetID = UUID.Zero; | 330 | UUID assetID = UUID.Zero; |
331 | 331 | ||
@@ -354,9 +354,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
354 | CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); | 354 | CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); |
355 | Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); | 355 | Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); |
356 | 356 | ||
357 | Dictionary<UUID, string> xmlStrings = | ||
358 | new Dictionary<UUID, string>(); | ||
359 | |||
360 | foreach (SceneObjectGroup objectGroup in objlist) | 357 | foreach (SceneObjectGroup objectGroup in objlist) |
361 | { | 358 | { |
362 | Vector3 inventoryStoredPosition = new Vector3 | 359 | Vector3 inventoryStoredPosition = new Vector3 |
@@ -369,12 +366,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
369 | : objectGroup.AbsolutePosition.Y, | 366 | : objectGroup.AbsolutePosition.Y, |
370 | objectGroup.AbsolutePosition.Z); | 367 | objectGroup.AbsolutePosition.Z); |
371 | 368 | ||
372 | Vector3 originalPosition = objectGroup.AbsolutePosition; | 369 | originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; |
373 | |||
374 | // Restore attachment data after trip through the sim | ||
375 | if (objectGroup.RootPart.AttachPoint > 0) | ||
376 | inventoryStoredPosition = objectGroup.RootPart.AttachOffset; | ||
377 | objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint; | ||
378 | 370 | ||
379 | objectGroup.AbsolutePosition = inventoryStoredPosition; | 371 | objectGroup.AbsolutePosition = inventoryStoredPosition; |
380 | 372 | ||
@@ -388,60 +380,159 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
388 | (uint)PermissionMask.Modify); | 380 | (uint)PermissionMask.Modify); |
389 | objectGroup.RootPart.NextOwnerMask |= | 381 | objectGroup.RootPart.NextOwnerMask |= |
390 | (uint)PermissionMask.Move; | 382 | (uint)PermissionMask.Move; |
383 | |||
384 | coa.Add(objectGroup); | ||
385 | } | ||
391 | 386 | ||
392 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); | 387 | string itemXml; |
393 | 388 | ||
394 | objectGroup.AbsolutePosition = originalPosition; | 389 | if (objlist.Count > 1) |
390 | itemXml = CoalescedSceneObjectsSerializer.ToXml(coa); | ||
391 | else | ||
392 | itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0]); | ||
393 | |||
394 | // Restore the position of each group now that it has been stored to inventory. | ||
395 | foreach (SceneObjectGroup objectGroup in objlist) | ||
396 | objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; | ||
395 | 397 | ||
396 | xmlStrings[objectGroup.UUID] = sceneObjectXml; | 398 | InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID); |
399 | if (item == null) | ||
400 | return UUID.Zero; | ||
401 | |||
402 | // Can't know creator is the same, so null it in inventory | ||
403 | if (objlist.Count > 1) | ||
404 | { | ||
405 | item.CreatorId = UUID.Zero.ToString(); | ||
406 | item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; | ||
397 | } | 407 | } |
408 | else | ||
409 | { | ||
410 | item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); | ||
411 | item.SaleType = objlist[0].RootPart.ObjectSaleType; | ||
412 | item.SalePrice = objlist[0].RootPart.SalePrice; | ||
413 | } | ||
398 | 414 | ||
399 | string itemXml; | 415 | AssetBase asset = CreateAsset( |
416 | objlist[0].GetPartName(objlist[0].RootPart.LocalId), | ||
417 | objlist[0].GetPartDescription(objlist[0].RootPart.LocalId), | ||
418 | (sbyte)AssetType.Object, | ||
419 | Utils.StringToBytes(itemXml), | ||
420 | objlist[0].OwnerID.ToString()); | ||
421 | m_Scene.AssetService.Store(asset); | ||
422 | |||
423 | item.AssetID = asset.FullID; | ||
424 | assetID = asset.FullID; | ||
400 | 425 | ||
401 | if (objlist.Count > 1) | 426 | if (DeRezAction.SaveToExistingUserInventoryItem == action) |
402 | { | 427 | { |
403 | float minX, minY, minZ; | 428 | m_Scene.InventoryService.UpdateItem(item); |
404 | float maxX, maxY, maxZ; | 429 | } |
430 | else | ||
431 | { | ||
432 | AddPermissions(item, objlist[0], objlist, remoteClient); | ||
405 | 433 | ||
406 | Vector3[] offsets = Scene.GetCombinedBoundingBox(objlist, | 434 | item.CreationDate = Util.UnixTimeSinceEpoch(); |
407 | out minX, out maxX, out minY, out maxY, | 435 | item.Description = asset.Description; |
408 | out minZ, out maxZ); | 436 | item.Name = asset.Name; |
437 | item.AssetType = asset.Type; | ||
409 | 438 | ||
410 | // CreateWrapper | 439 | m_Scene.AddInventoryItem(item); |
411 | XmlDocument itemDoc = new XmlDocument(); | ||
412 | XmlElement root = itemDoc.CreateElement("", "CoalescedObject", ""); | ||
413 | itemDoc.AppendChild(root); | ||
414 | 440 | ||
415 | // Embed the offsets into the group XML | 441 | if (remoteClient != null && item.Owner == remoteClient.AgentId) |
416 | for ( int i = 0 ; i < objlist.Count ; i++ ) | ||
417 | { | 442 | { |
418 | XmlDocument doc = new XmlDocument(); | 443 | remoteClient.SendInventoryItemCreateUpdate(item, 0); |
419 | SceneObjectGroup g = objlist[i]; | 444 | } |
420 | doc.LoadXml(xmlStrings[g.UUID]); | 445 | else |
421 | XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup"); | 446 | { |
422 | e.SetAttribute("offsetx", offsets[i].X.ToString()); | 447 | ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner); |
423 | e.SetAttribute("offsety", offsets[i].Y.ToString()); | 448 | if (notifyUser != null) |
424 | e.SetAttribute("offsetz", offsets[i].Z.ToString()); | 449 | { |
425 | 450 | notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); | |
426 | XmlNode objectNode = itemDoc.ImportNode(e, true); | 451 | } |
427 | root.AppendChild(objectNode); | ||
428 | } | 452 | } |
453 | } | ||
454 | |||
455 | // This is a hook to do some per-asset post-processing for subclasses that need that | ||
456 | if (remoteClient != null) | ||
457 | ExportAsset(remoteClient.AgentId, assetID); | ||
458 | |||
459 | return assetID; | ||
460 | } | ||
429 | 461 | ||
430 | float sizeX = maxX - minX; | 462 | protected virtual void ExportAsset(UUID agentID, UUID assetID) |
431 | float sizeY = maxY - minY; | 463 | { |
432 | float sizeZ = maxZ - minZ; | 464 | // nothing to do here |
465 | } | ||
433 | 466 | ||
434 | root.SetAttribute("x", sizeX.ToString()); | 467 | /// <summary> |
435 | root.SetAttribute("y", sizeY.ToString()); | 468 | /// Add relevant permissions for an object to the item. |
436 | root.SetAttribute("z", sizeZ.ToString()); | 469 | /// </summary> |
470 | /// <param name="item"></param> | ||
471 | /// <param name="so"></param> | ||
472 | /// <param name="objsForEffectivePermissions"></param> | ||
473 | /// <param name="remoteClient"></param> | ||
474 | /// <returns></returns> | ||
475 | protected InventoryItemBase AddPermissions( | ||
476 | InventoryItemBase item, SceneObjectGroup so, List<SceneObjectGroup> objsForEffectivePermissions, | ||
477 | IClientAPI remoteClient) | ||
478 | { | ||
479 | uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; | ||
480 | foreach (SceneObjectGroup grp in objsForEffectivePermissions) | ||
481 | effectivePerms &= grp.GetEffectivePermissions(); | ||
482 | effectivePerms |= (uint)PermissionMask.Move; | ||
437 | 483 | ||
438 | itemXml = itemDoc.InnerXml; | 484 | if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) |
485 | { | ||
486 | uint perms = effectivePerms; | ||
487 | uint nextPerms = (perms & 7) << 13; | ||
488 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
489 | perms &= ~(uint)PermissionMask.Copy; | ||
490 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
491 | perms &= ~(uint)PermissionMask.Transfer; | ||
492 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
493 | perms &= ~(uint)PermissionMask.Modify; | ||
494 | |||
495 | item.BasePermissions = perms & so.RootPart.NextOwnerMask; | ||
496 | item.CurrentPermissions = item.BasePermissions; | ||
497 | item.NextPermissions = perms & so.RootPart.NextOwnerMask; | ||
498 | item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; | ||
499 | item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; | ||
500 | |||
501 | // Magic number badness. Maybe this deserves an enum. | ||
502 | // bit 4 (16) is the "Slam" bit, it means treat as passed | ||
503 | // and apply next owner perms on rez | ||
504 | item.CurrentPermissions |= 16; // Slam! | ||
439 | } | 505 | } |
440 | else | 506 | else |
441 | { | 507 | { |
442 | itemXml = xmlStrings[objlist[0].UUID]; | 508 | item.BasePermissions = effectivePerms; |
443 | } | 509 | item.CurrentPermissions = effectivePerms; |
510 | item.NextPermissions = so.RootPart.NextOwnerMask & effectivePerms; | ||
511 | item.EveryOnePermissions = so.RootPart.EveryoneMask & effectivePerms; | ||
512 | item.GroupPermissions = so.RootPart.GroupMask & effectivePerms; | ||
444 | 513 | ||
514 | item.CurrentPermissions &= | ||
515 | ((uint)PermissionMask.Copy | | ||
516 | (uint)PermissionMask.Transfer | | ||
517 | (uint)PermissionMask.Modify | | ||
518 | (uint)PermissionMask.Move | | ||
519 | 7); // Preserve folded permissions | ||
520 | } | ||
521 | |||
522 | return item; | ||
523 | } | ||
524 | |||
525 | /// <summary> | ||
526 | /// Create an item using details for the given scene object. | ||
527 | /// </summary> | ||
528 | /// <param name="action"></param> | ||
529 | /// <param name="remoteClient"></param> | ||
530 | /// <param name="so"></param> | ||
531 | /// <param name="folderID"></param> | ||
532 | /// <returns></returns> | ||
533 | protected InventoryItemBase CreateItemForObject( | ||
534 | DeRezAction action, IClientAPI remoteClient, SceneObjectGroup so, UUID folderID) | ||
535 | { | ||
445 | // Get the user info of the item destination | 536 | // Get the user info of the item destination |
446 | // | 537 | // |
447 | UUID userID = UUID.Zero; | 538 | UUID userID = UUID.Zero; |
@@ -453,7 +544,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
453 | // Saving changes requires a local user | 544 | // Saving changes requires a local user |
454 | // | 545 | // |
455 | if (remoteClient == null) | 546 | if (remoteClient == null) |
456 | return UUID.Zero; | 547 | return null; |
457 | 548 | ||
458 | userID = remoteClient.AgentId; | 549 | userID = remoteClient.AgentId; |
459 | } | 550 | } |
@@ -461,13 +552,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
461 | { | 552 | { |
462 | // All returns / deletes go to the object owner | 553 | // All returns / deletes go to the object owner |
463 | // | 554 | // |
464 | 555 | userID = so.RootPart.OwnerID; | |
465 | userID = objlist[0].RootPart.OwnerID; | ||
466 | } | 556 | } |
467 | 557 | ||
468 | if (userID == UUID.Zero) // Can't proceed | 558 | if (userID == UUID.Zero) // Can't proceed |
469 | { | 559 | { |
470 | return UUID.Zero; | 560 | return null; |
471 | } | 561 | } |
472 | 562 | ||
473 | // If we're returning someone's item, it goes back to the | 563 | // If we're returning someone's item, it goes back to the |
@@ -475,13 +565,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
475 | // Delete is treated like return in this case | 565 | // Delete is treated like return in this case |
476 | // Deleting your own items makes them go to trash | 566 | // Deleting your own items makes them go to trash |
477 | // | 567 | // |
478 | 568 | ||
479 | InventoryFolderBase folder = null; | 569 | InventoryFolderBase folder = null; |
480 | InventoryItemBase item = null; | 570 | InventoryItemBase item = null; |
481 | 571 | ||
482 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | 572 | if (DeRezAction.SaveToExistingUserInventoryItem == action) |
483 | { | 573 | { |
484 | item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID); | 574 | item = new InventoryItemBase(so.RootPart.FromUserInventoryItemID, userID); |
485 | item = m_Scene.InventoryService.GetItem(item); | 575 | item = m_Scene.InventoryService.GetItem(item); |
486 | 576 | ||
487 | //item = userInfo.RootFolder.FindItem( | 577 | //item = userInfo.RootFolder.FindItem( |
@@ -491,8 +581,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
491 | { | 581 | { |
492 | m_log.DebugFormat( | 582 | m_log.DebugFormat( |
493 | "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", | 583 | "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", |
494 | objlist[0].Name, objlist[0].UUID); | 584 | so.Name, so.UUID); |
495 | return UUID.Zero; | 585 | |
586 | return null; | ||
496 | } | 587 | } |
497 | } | 588 | } |
498 | else | 589 | else |
@@ -504,19 +595,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
504 | // Deleting someone else's item | 595 | // Deleting someone else's item |
505 | // | 596 | // |
506 | if (remoteClient == null || | 597 | if (remoteClient == null || |
507 | objlist[0].OwnerID != remoteClient.AgentId) | 598 | so.OwnerID != remoteClient.AgentId) |
508 | { | 599 | { |
509 | |||
510 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | 600 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); |
511 | } | 601 | } |
512 | else | 602 | else |
513 | { | 603 | { |
514 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | 604 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); |
515 | } | 605 | } |
516 | } | 606 | } |
517 | else if (action == DeRezAction.Return) | 607 | else if (action == DeRezAction.Return) |
518 | { | 608 | { |
519 | |||
520 | // Dump to lost + found unconditionally | 609 | // Dump to lost + found unconditionally |
521 | // | 610 | // |
522 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | 611 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); |
@@ -532,8 +621,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
532 | } | 621 | } |
533 | else | 622 | else |
534 | { | 623 | { |
535 | if (remoteClient == null || | 624 | if (remoteClient == null || so.OwnerID != remoteClient.AgentId) |
536 | objlist[0].OwnerID != remoteClient.AgentId) | ||
537 | { | 625 | { |
538 | // Taking copy of another person's item. Take to | 626 | // Taking copy of another person's item. Take to |
539 | // Objects folder. | 627 | // Objects folder. |
@@ -554,9 +642,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
554 | // | 642 | // |
555 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) | 643 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) |
556 | { | 644 | { |
557 | if (objlist[0].RootPart.FromFolderID != UUID.Zero && objlist[0].OwnerID == remoteClient.AgentId) | 645 | if (so.RootPart.FromFolderID != UUID.Zero) |
558 | { | 646 | { |
559 | InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID); | 647 | InventoryFolderBase f = new InventoryFolderBase(so.RootPart.FromFolderID, userID); |
560 | folder = m_Scene.InventoryService.GetFolder(f); | 648 | folder = m_Scene.InventoryService.GetFolder(f); |
561 | } | 649 | } |
562 | } | 650 | } |
@@ -567,380 +655,375 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
567 | 655 | ||
568 | if (folder == null) // Nowhere to put it | 656 | if (folder == null) // Nowhere to put it |
569 | { | 657 | { |
570 | return UUID.Zero; | 658 | return null; |
571 | } | 659 | } |
572 | } | 660 | } |
573 | 661 | ||
574 | item = new InventoryItemBase(); | 662 | item = new InventoryItemBase(); |
575 | // Can't know creator is the same, so null it in inventory | ||
576 | if (objlist.Count > 1) | ||
577 | { | ||
578 | item.CreatorId = UUID.Zero.ToString(); | ||
579 | item.CreatorData = String.Empty; | ||
580 | } | ||
581 | else | ||
582 | { | ||
583 | item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); | ||
584 | item.CreatorData = objlist[0].RootPart.CreatorData; | ||
585 | } | ||
586 | item.ID = UUID.Random(); | 663 | item.ID = UUID.Random(); |
587 | item.InvType = (int)InventoryType.Object; | 664 | item.InvType = (int)InventoryType.Object; |
588 | item.Folder = folder.ID; | 665 | item.Folder = folder.ID; |
589 | item.Owner = userID; | 666 | item.Owner = userID; |
590 | if (objlist.Count > 1) | 667 | } |
668 | |||
669 | return item; | ||
670 | } | ||
671 | |||
672 | public virtual SceneObjectGroup RezObject( | ||
673 | IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | ||
674 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
675 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
676 | { | ||
677 | // m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); | ||
678 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
679 | item = m_Scene.InventoryService.GetItem(item); | ||
680 | |||
681 | if (item == null) | ||
682 | { | ||
683 | |||
684 | return null; | ||
685 | } | ||
686 | |||
687 | |||
688 | |||
689 | |||
690 | |||
691 | |||
692 | |||
693 | item.Owner = remoteClient.AgentId; | ||
694 | |||
695 | return RezObject( | ||
696 | remoteClient, item, item.AssetID, | ||
697 | RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | ||
698 | RezSelected, RemoveItem, fromTaskID, attachment); | ||
699 | } | ||
700 | |||
701 | public virtual SceneObjectGroup RezObject( | ||
702 | IClientAPI remoteClient, InventoryItemBase item, UUID assetID, Vector3 RayEnd, Vector3 RayStart, | ||
703 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
704 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
705 | { | ||
706 | AssetBase rezAsset = m_Scene.AssetService.Get(assetID.ToString()); | ||
707 | |||
708 | if (rezAsset == null) | ||
709 | { | ||
710 | if (item != null) | ||
591 | { | 711 | { |
592 | item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; | 712 | m_log.WarnFormat( |
713 | "[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()", | ||
714 | assetID, item.Name, item.ID, remoteClient.Name); | ||
593 | } | 715 | } |
594 | else | 716 | else |
595 | { | 717 | { |
596 | item.SaleType = objlist[0].RootPart.ObjectSaleType; | 718 | m_log.WarnFormat( |
597 | item.SalePrice = objlist[0].RootPart.SalePrice; | 719 | "[InventoryAccessModule]: Could not find asset {0} for {1} in RezObject()", |
720 | assetID, remoteClient.Name); | ||
598 | } | 721 | } |
722 | |||
723 | return null; | ||
599 | } | 724 | } |
600 | 725 | ||
601 | AssetBase asset = CreateAsset( | 726 | SceneObjectGroup group = null; |
602 | objlist[0].GetPartName(objlist[0].RootPart.LocalId), | ||
603 | objlist[0].GetPartDescription(objlist[0].RootPart.LocalId), | ||
604 | (sbyte)AssetType.Object, | ||
605 | Utils.StringToBytes(itemXml), | ||
606 | objlist[0].OwnerID.ToString()); | ||
607 | m_Scene.AssetService.Store(asset); | ||
608 | assetID = asset.FullID; | ||
609 | 727 | ||
610 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | 728 | string xmlData = Utils.BytesToString(rezAsset.Data); |
729 | List<SceneObjectGroup> objlist = | ||
730 | new List<SceneObjectGroup>(); | ||
731 | List<Vector3> veclist = new List<Vector3>(); | ||
732 | byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); | ||
733 | Vector3 pos; | ||
734 | |||
735 | XmlDocument doc = new XmlDocument(); | ||
736 | doc.LoadXml(xmlData); | ||
737 | XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject"); | ||
738 | if (e == null || attachment) // Single | ||
611 | { | 739 | { |
612 | item.AssetID = asset.FullID; | 740 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
613 | m_Scene.InventoryService.UpdateItem(item); | 741 | |
742 | objlist.Add(g); | ||
743 | veclist.Add(new Vector3(0, 0, 0)); | ||
744 | |||
745 | float offsetHeight = 0; | ||
746 | pos = m_Scene.GetNewRezLocation( | ||
747 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | ||
748 | BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false); | ||
749 | pos.Z += offsetHeight; | ||
614 | } | 750 | } |
615 | else | 751 | else |
616 | { | 752 | { |
617 | item.AssetID = asset.FullID; | 753 | XmlElement coll = (XmlElement)e; |
754 | float bx = Convert.ToSingle(coll.GetAttribute("x")); | ||
755 | float by = Convert.ToSingle(coll.GetAttribute("y")); | ||
756 | float bz = Convert.ToSingle(coll.GetAttribute("z")); | ||
757 | Vector3 bbox = new Vector3(bx, by, bz); | ||
618 | 758 | ||
619 | uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; | 759 | pos = m_Scene.GetNewRezLocation(RayStart, RayEnd, |
620 | foreach (SceneObjectGroup grp in objlist) | 760 | RayTargetID, Quaternion.Identity, |
621 | effectivePerms &= grp.GetEffectivePermissions(); | 761 | BypassRayCast, bRayEndIsIntersection, true, |
622 | effectivePerms |= (uint)PermissionMask.Move; | 762 | bbox, false); |
623 | 763 | ||
624 | if (remoteClient != null && (remoteClient.AgentId != objlist[0].RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) | 764 | pos -= bbox / 2; |
625 | { | 765 | |
626 | uint perms = effectivePerms; | 766 | XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); |
627 | uint nextPerms = (perms & 7) << 13; | 767 | foreach (XmlNode n in groups) |
628 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
629 | perms &= ~(uint)PermissionMask.Copy; | ||
630 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
631 | perms &= ~(uint)PermissionMask.Transfer; | ||
632 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
633 | perms &= ~(uint)PermissionMask.Modify; | ||
634 | |||
635 | item.BasePermissions = perms & objlist[0].RootPart.NextOwnerMask; | ||
636 | item.CurrentPermissions = item.BasePermissions; | ||
637 | item.NextPermissions = perms & objlist[0].RootPart.NextOwnerMask; | ||
638 | item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & objlist[0].RootPart.NextOwnerMask; | ||
639 | item.GroupPermissions = objlist[0].RootPart.GroupMask & objlist[0].RootPart.NextOwnerMask; | ||
640 | |||
641 | item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; | ||
642 | } | ||
643 | else | ||
644 | { | 768 | { |
645 | item.BasePermissions = effectivePerms; | 769 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); |
646 | item.CurrentPermissions = effectivePerms; | 770 | |
647 | item.NextPermissions = objlist[0].RootPart.NextOwnerMask & effectivePerms; | 771 | objlist.Add(g); |
648 | item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & effectivePerms; | 772 | XmlElement el = (XmlElement)n; |
649 | item.GroupPermissions = objlist[0].RootPart.GroupMask & effectivePerms; | 773 | |
650 | 774 | string rawX = el.GetAttribute("offsetx"); | |
651 | item.CurrentPermissions &= | 775 | string rawY = el.GetAttribute("offsety"); |
652 | ((uint)PermissionMask.Copy | | 776 | string rawZ = el.GetAttribute("offsetz"); |
653 | (uint)PermissionMask.Transfer | | 777 | // |
654 | (uint)PermissionMask.Modify | | 778 | // m_log.DebugFormat( |
655 | (uint)PermissionMask.Move | | 779 | // "[INVENTORY ACCESS MODULE]: Converting coalesced object {0} offset <{1}, {2}, {3}>", |
656 | 7); // Preserve folded permissions | 780 | // g.Name, rawX, rawY, rawZ); |
781 | |||
782 | float x = Convert.ToSingle(rawX); | ||
783 | float y = Convert.ToSingle(rawY); | ||
784 | float z = Convert.ToSingle(rawZ); | ||
785 | veclist.Add(new Vector3(x, y, z)); | ||
657 | } | 786 | } |
787 | } | ||
658 | 788 | ||
659 | item.CreationDate = Util.UnixTimeSinceEpoch(); | 789 | if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, attachment)) |
660 | item.Description = asset.Description; | 790 | return null; |
661 | item.Name = asset.Name; | ||
662 | item.AssetType = asset.Type; | ||
663 | 791 | ||
664 | m_Scene.AddInventoryItem(item); | 792 | for (int i = 0; i < objlist.Count; i++) |
793 | { | ||
794 | group = objlist[i]; | ||
665 | 795 | ||
666 | if (remoteClient != null && item.Owner == remoteClient.AgentId) | 796 | // Vector3 storedPosition = group.AbsolutePosition; |
797 | if (group.UUID == UUID.Zero) | ||
667 | { | 798 | { |
668 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | 799 | m_log.Debug("[InventoryAccessModule]: Object has UUID.Zero! Position 3"); |
669 | } | 800 | } |
670 | else | 801 | |
802 | if (!attachment) | ||
671 | { | 803 | { |
672 | ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner); | 804 | // If it's rezzed in world, select it. Much easier to |
673 | if (notifyUser != null) | 805 | // find small items. |
806 | // | ||
807 | foreach (SceneObjectPart part in group.Parts) | ||
674 | { | 808 | { |
675 | notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); | 809 | part.CreateSelected = true; |
676 | } | 810 | } |
677 | } | 811 | } |
812 | |||
813 | group.ResetIDs(); | ||
814 | |||
815 | if (attachment) | ||
816 | { | ||
817 | group.RootPart.Flags |= PrimFlags.Phantom; | ||
818 | group.IsAttachment = true; | ||
819 | } | ||
820 | |||
821 | // If we're rezzing an attachment then don't ask | ||
822 | // AddNewSceneObject() to update the client since | ||
823 | // we'll be doing that later on. Scheduling more than | ||
824 | // one full update during the attachment | ||
825 | // process causes some clients to fail to display the | ||
826 | // attachment properly. | ||
827 | m_Scene.AddNewSceneObject(group, true, false); | ||
828 | |||
829 | // if attachment we set it's asset id so object updates | ||
830 | // can reflect that, if not, we set it's position in world. | ||
831 | if (!attachment) | ||
832 | { | ||
833 | group.ScheduleGroupForFullUpdate(); | ||
834 | |||
835 | group.AbsolutePosition = pos + veclist[i]; | ||
836 | } | ||
837 | |||
838 | SceneObjectPart rootPart = group.RootPart; | ||
839 | |||
840 | group.SetGroup(remoteClient.ActiveGroupId, remoteClient); | ||
841 | |||
842 | if (!attachment) | ||
843 | { | ||
844 | if (group.RootPart.Shape.PCode == (byte)PCode.Prim) | ||
845 | group.ClearPartAttachmentData(); | ||
846 | |||
847 | // Fire on_rez | ||
848 | group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); | ||
849 | rootPart.ParentGroup.ResumeScripts(); | ||
850 | |||
851 | rootPart.ScheduleFullUpdate(); | ||
852 | } | ||
853 | |||
854 | // m_log.DebugFormat( | ||
855 | // "[InventoryAccessModule]: Rezzed {0} {1} {2} for {3}", | ||
856 | // group.Name, group.LocalId, group.UUID, remoteClient.Name); | ||
678 | } | 857 | } |
679 | 858 | ||
680 | // This is a hook to do some per-asset post-processing for subclasses that need that | 859 | group.SetGroup(remoteClient.ActiveGroupId, remoteClient); |
681 | if (remoteClient != null) | 860 | // TODO: Remove the magic number badness |
682 | ExportAsset(remoteClient.AgentId, assetID); | 861 | if (item != null) |
683 | 862 | DoPostRezWhenFromItem(item, attachment); | |
684 | return assetID; | ||
685 | } | ||
686 | 863 | ||
687 | protected virtual void ExportAsset(UUID agentID, UUID assetID) | 864 | if ((rootPart.OwnerID != item.Owner) || |
688 | { | 865 | (item.CurrentPermissions & 16) != 0 || // Magic number |
689 | // nothing to do here | 866 | (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) |
867 | { | ||
868 | //Need to kill the for sale here | ||
869 | rootPart.ObjectSaleType = 0; | ||
870 | rootPart.SalePrice = 10; | ||
871 | |||
872 | return group; | ||
690 | } | 873 | } |
691 | 874 | ||
692 | /// <summary> | 875 | /// <summary> |
693 | /// Rez an object into the scene from the user's inventory | 876 | /// Do pre-rez processing when the object comes from an item. |
694 | /// </summary> | 877 | /// </summary> |
695 | /// FIXME: It would be really nice if inventory access modules didn't also actually do the work of rezzing | ||
696 | /// things to the scene. The caller should be doing that, I think. | ||
697 | /// <param name="remoteClient"></param> | 878 | /// <param name="remoteClient"></param> |
698 | /// <param name="itemID"></param> | 879 | /// <param name="item"></param> |
699 | /// <param name="RayEnd"></param> | 880 | /// <param name="objlist"></param> |
700 | /// <param name="RayStart"></param> | 881 | /// <param name="pos"></param> |
701 | /// <param name="RayTargetID"></param> | 882 | /// <param name="isAttachment"></param> |
702 | /// <param name="BypassRayCast"></param> | 883 | /// <returns>true if we can processed with rezzing, false if we need to abort</returns> |
703 | /// <param name="RayEndIsIntersection"></param> | 884 | private bool DoPreRezWhenFromItem( |
704 | /// <param name="RezSelected"></param> | 885 | IClientAPI remoteClient, InventoryItemBase item, List<SceneObjectGroup> objlist, Vector3 pos, bool isAttachment) |
705 | /// <param name="RemoveItem"></param> | ||
706 | /// <param name="fromTaskID"></param> | ||
707 | /// <param name="attachment"></param> | ||
708 | /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns> | ||
709 | public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | ||
710 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
711 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
712 | { | 886 | { |
713 | // Work out position details | 887 | UUID fromUserInventoryItemId = UUID.Zero; |
714 | byte bRayEndIsIntersection = (byte)0; | ||
715 | 888 | ||
716 | if (RayEndIsIntersection) | 889 | // If we have permission to copy then link the rezzed object back to the user inventory |
890 | // item that it came from. This allows us to enable 'save object to inventory' | ||
891 | if (!m_Scene.Permissions.BypassPermissions()) | ||
717 | { | 892 | { |
718 | bRayEndIsIntersection = (byte)1; | 893 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) |
894 | == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) | ||
895 | { | ||
896 | fromUserInventoryItemId = item.ID; | ||
897 | } | ||
719 | } | 898 | } |
720 | else | 899 | else |
721 | { | 900 | { |
722 | bRayEndIsIntersection = (byte)0; | 901 | if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) |
902 | { | ||
903 | // Brave new fullperm world | ||
904 | fromUserInventoryItemId = item.ID; | ||
905 | } | ||
723 | } | 906 | } |
724 | 907 | ||
725 | Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); | 908 | int primcount = 0; |
909 | foreach (SceneObjectGroup g in objlist) | ||
910 | primcount += g.PrimCount; | ||
726 | 911 | ||
912 | if (!m_Scene.Permissions.CanRezObject( | ||
913 | primcount, remoteClient.AgentId, pos) | ||
914 | && !isAttachment) | ||
915 | { | ||
916 | // The client operates in no fail mode. It will | ||
917 | // have already removed the item from the folder | ||
918 | // if it's no copy. | ||
919 | // Put it back if it's not an attachment | ||
920 | // | ||
921 | if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!isAttachment)) | ||
922 | remoteClient.SendBulkUpdateInventory(item); | ||
727 | 923 | ||
728 | Vector3 pos = m_Scene.GetNewRezLocation( | 924 | return false; |
729 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | 925 | } |
730 | BypassRayCast, bRayEndIsIntersection, true, scale, false); | ||
731 | |||
732 | // Rez object | ||
733 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
734 | item = m_Scene.InventoryService.GetItem(item); | ||
735 | 926 | ||
736 | if (item != null) | 927 | for (int i = 0; i < objlist.Count; i++) |
737 | { | 928 | { |
738 | if (item.ID == UUID.Zero) | 929 | SceneObjectGroup so = objlist[i]; |
930 | SceneObjectPart rootPart = so.RootPart; | ||
931 | |||
932 | // Since renaming the item in the inventory does not | ||
933 | // affect the name stored in the serialization, transfer | ||
934 | // the correct name from the inventory to the | ||
935 | // object itself before we rez. | ||
936 | // | ||
937 | // Only do these for the first object if we are rezzing a coalescence. | ||
938 | if (i == 0) | ||
739 | { | 939 | { |
740 | m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 1"); | 940 | rootPart.Name = item.Name; |
941 | rootPart.Description = item.Description; | ||
942 | rootPart.ObjectSaleType = item.SaleType; | ||
943 | rootPart.SalePrice = item.SalePrice; | ||
741 | } | 944 | } |
742 | item.Owner = remoteClient.AgentId; | ||
743 | |||
744 | AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); | ||
745 | |||
746 | SceneObjectGroup group = null; | ||
747 | 945 | ||
748 | if (rezAsset != null) | 946 | rootPart.FromFolderID = item.Folder; |
947 | |||
948 | if ((rootPart.OwnerID != item.Owner) || | ||
949 | (item.CurrentPermissions & 16) != 0) | ||
749 | { | 950 | { |
750 | UUID itemId = UUID.Zero; | 951 | //Need to kill the for sale here |
751 | 952 | rootPart.ObjectSaleType = 0; | |
752 | // If we have permission to copy then link the rezzed object back to the user inventory | 953 | rootPart.SalePrice = 10; |
753 | // item that it came from. This allows us to enable 'save object to inventory' | 954 | |
754 | if (!m_Scene.Permissions.BypassPermissions()) | 955 | if (m_Scene.Permissions.PropagatePermissions()) |
755 | { | ||
756 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) | ||
757 | { | ||
758 | itemId = item.ID; | ||
759 | } | ||
760 | } | ||
761 | else | ||
762 | { | 956 | { |
763 | if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) | 957 | foreach (SceneObjectPart part in so.Parts) |
764 | { | 958 | { |
765 | // Brave new fullperm world | 959 | if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) |
766 | itemId = item.ID; | 960 | { |
961 | part.EveryoneMask = item.EveryOnePermissions; | ||
962 | part.NextOwnerMask = item.NextPermissions; | ||
963 | } | ||
964 | part.GroupMask = 0; // DO NOT propagate here | ||
767 | } | 965 | } |
966 | |||
967 | so.ApplyNextOwnerPermissions(); | ||
768 | } | 968 | } |
969 | } | ||
970 | |||
971 | foreach (SceneObjectPart part in so.Parts) | ||
972 | { | ||
973 | part.FromUserInventoryItemID = fromUserInventoryItemId; | ||
769 | 974 | ||
770 | if (item.ID == UUID.Zero) | 975 | if ((part.OwnerID != item.Owner) || |
771 | { | 976 | (item.CurrentPermissions & 16) != 0) |
772 | m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 2"); | ||
773 | } | ||
774 | |||
775 | string xmlData = Utils.BytesToString(rezAsset.Data); | ||
776 | List<SceneObjectGroup> objlist = | ||
777 | new List<SceneObjectGroup>(); | ||
778 | List<Vector3> veclist = new List<Vector3>(); | ||
779 | |||
780 | XmlDocument doc = new XmlDocument(); | ||
781 | doc.LoadXml(xmlData); | ||
782 | XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject"); | ||
783 | if (e == null || attachment) // Single | ||
784 | { | 977 | { |
785 | SceneObjectGroup g = | 978 | part.LastOwnerID = part.OwnerID; |
786 | SceneObjectSerializer.FromOriginalXmlFormat( | 979 | part.OwnerID = item.Owner; |
787 | itemId, xmlData); | 980 | part.Inventory.ChangeInventoryOwner(item.Owner); |
788 | objlist.Add(g); | 981 | part.GroupMask = 0; // DO NOT propagate here |
789 | veclist.Add(new Vector3(0, 0, 0)); | ||
790 | |||
791 | float offsetHeight = 0; | ||
792 | pos = m_Scene.GetNewRezLocation( | ||
793 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | ||
794 | BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false); | ||
795 | pos.Z += offsetHeight; | ||
796 | } | 982 | } |
797 | else | 983 | part.EveryoneMask = item.EveryOnePermissions; |
798 | { | 984 | part.NextOwnerMask = item.NextPermissions; |
799 | XmlElement coll = (XmlElement)e; | 985 | } |
800 | float bx = Convert.ToSingle(coll.GetAttribute("x")); | 986 | |
801 | float by = Convert.ToSingle(coll.GetAttribute("y")); | 987 | rootPart.TrimPermissions(); |
802 | float bz = Convert.ToSingle(coll.GetAttribute("z")); | ||
803 | Vector3 bbox = new Vector3(bx, by, bz); | ||
804 | |||
805 | pos = m_Scene.GetNewRezLocation(RayStart, RayEnd, | ||
806 | RayTargetID, Quaternion.Identity, | ||
807 | BypassRayCast, bRayEndIsIntersection, true, | ||
808 | bbox, false); | ||
809 | |||
810 | pos -= bbox / 2; | ||
811 | 988 | ||
812 | XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); | 989 | if (isAttachment) |
813 | foreach (XmlNode n in groups) | 990 | so.SetFromItemID(item.ID); |
814 | { | 991 | } |
815 | SceneObjectGroup g = | ||
816 | SceneObjectSerializer.FromOriginalXmlFormat( | ||
817 | itemId, n.OuterXml); | ||
818 | objlist.Add(g); | ||
819 | XmlElement el = (XmlElement)n; | ||
820 | float x = Convert.ToSingle(el.GetAttribute("offsetx")); | ||
821 | float y = Convert.ToSingle(el.GetAttribute("offsety")); | ||
822 | float z = Convert.ToSingle(el.GetAttribute("offsetz")); | ||
823 | veclist.Add(new Vector3(x, y, z)); | ||
824 | } | ||
825 | } | ||
826 | 992 | ||
827 | int primcount = 0; | 993 | return true; |
828 | foreach (SceneObjectGroup g in objlist) | 994 | } |
829 | primcount += g.PrimCount; | ||
830 | 995 | ||
831 | if (!m_Scene.Permissions.CanRezObject( | 996 | /// <summary> |
832 | primcount, remoteClient.AgentId, pos) | 997 | /// Do post-rez processing when the object comes from an item. |
833 | && !attachment) | 998 | /// </summary> |
999 | /// <param name="item"></param> | ||
1000 | /// <param name="isAttachment"></param> | ||
1001 | private void DoPostRezWhenFromItem(InventoryItemBase item, bool isAttachment) | ||
1002 | { | ||
1003 | if (!m_Scene.Permissions.BypassPermissions()) | ||
1004 | { | ||
1005 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1006 | { | ||
1007 | // If this is done on attachments, no | ||
1008 | // copy ones will be lost, so avoid it | ||
1009 | // | ||
1010 | if (!isAttachment) | ||
834 | { | 1011 | { |
835 | // The client operates in no fail mode. It will | 1012 | List<UUID> uuids = new List<UUID>(); |
836 | // have already removed the item from the folder | 1013 | uuids.Add(item.ID); |
837 | // if it's no copy. | 1014 | m_Scene.InventoryService.DeleteItems(item.Owner, uuids); |
838 | // Put it back if it's not an attachment | ||
839 | // | ||
840 | if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) | ||
841 | remoteClient.SendBulkUpdateInventory(item); | ||
842 | return null; | ||
843 | } | 1015 | } |
844 | 1016 | } | |
845 | for (int i = 0 ; i < objlist.Count ; i++ ) | 1017 | } |
846 | { | 1018 | if ((rootPart.OwnerID != item.Owner) || |
847 | group = objlist[i]; | ||
848 | |||
849 | Vector3 storedPosition = group.AbsolutePosition; | ||
850 | if (group.UUID == UUID.Zero) | ||
851 | { | ||
852 | m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3"); | ||
853 | } | ||
854 | group.RootPart.FromFolderID = item.Folder; | ||
855 | |||
856 | // If it's rezzed in world, select it. Much easier to | ||
857 | // find small items. | ||
858 | // | ||
859 | if (!attachment) | ||
860 | { | ||
861 | group.RootPart.CreateSelected = true; | ||
862 | foreach (SceneObjectPart child in group.Parts) | ||
863 | child.CreateSelected = true; | ||
864 | } | ||
865 | |||
866 | group.ResetIDs(); | ||
867 | |||
868 | if (attachment) | ||
869 | { | ||
870 | group.RootPart.Flags |= PrimFlags.Phantom; | ||
871 | group.RootPart.IsAttachment = true; | ||
872 | |||
873 | // If we're rezzing an attachment then don't ask | ||
874 | // AddNewSceneObject() to update the client since | ||
875 | // we'll be doing that later on. Scheduling more | ||
876 | // than one full update during the attachment | ||
877 | // process causes some clients to fail to display | ||
878 | // the attachment properly. | ||
879 | // Also, don't persist attachments. | ||
880 | m_Scene.AddNewSceneObject(group, false, false); | ||
881 | } | ||
882 | else | ||
883 | { | ||
884 | m_Scene.AddNewSceneObject(group, true, false); | ||
885 | } | ||
886 | |||
887 | // if attachment we set it's asset id so object updates | ||
888 | // can reflect that, if not, we set it's position in world. | ||
889 | if (!attachment) | ||
890 | { | ||
891 | group.ScheduleGroupForFullUpdate(); | ||
892 | |||
893 | group.AbsolutePosition = pos + veclist[i]; | ||
894 | } | ||
895 | else | ||
896 | { | ||
897 | group.SetFromItemID(itemID); | ||
898 | } | ||
899 | |||
900 | SceneObjectPart rootPart = null; | ||
901 | |||
902 | try | ||
903 | { | ||
904 | rootPart = group.GetChildPart(group.UUID); | ||
905 | } | ||
906 | catch (NullReferenceException) | ||
907 | { | ||
908 | string isAttachment = ""; | ||
909 | |||
910 | if (attachment) | ||
911 | isAttachment = " Object was an attachment"; | ||
912 | |||
913 | m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); | ||
914 | } | ||
915 | |||
916 | // Since renaming the item in the inventory does not | ||
917 | // affect the name stored in the serialization, transfer | ||
918 | // the correct name from the inventory to the | ||
919 | // object itself before we rez. | ||
920 | // On coalesced objects, do the first one | ||
921 | if (((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) || i == 0) | ||
922 | { | ||
923 | rootPart.Name = item.Name; | ||
924 | rootPart.Description = item.Description; | ||
925 | } | ||
926 | if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0) | ||
927 | { | ||
928 | rootPart.ObjectSaleType = item.SaleType; | ||
929 | rootPart.SalePrice = item.SalePrice; | ||
930 | } | ||
931 | |||
932 | group.SetGroup(remoteClient.ActiveGroupId, remoteClient); | ||
933 | // TODO: Remove the magic number badness | ||
934 | |||
935 | if ((rootPart.OwnerID != item.Owner) || | ||
936 | (item.CurrentPermissions & 16) != 0 || // Magic number | 1019 | (item.CurrentPermissions & 16) != 0 || // Magic number |
937 | (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) | 1020 | (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) |
938 | { | 1021 | { |
939 | //Need to kill the for sale here | 1022 | //Need to kill the for sale here |
940 | rootPart.ObjectSaleType = 0; | 1023 | rootPart.ObjectSaleType = 0; |
941 | rootPart.SalePrice = 10; | 1024 | rootPart.SalePrice = 10; |
942 | 1025 | ||
943 | if (m_Scene.Permissions.PropagatePermissions()) | 1026 | if (m_Scene.Permissions.PropagatePermissions()) |
944 | { | 1027 | { |
945 | foreach (SceneObjectPart part in group.Parts) | 1028 | foreach (SceneObjectPart part in group.Parts) |
946 | { | 1029 | { |
@@ -965,58 +1048,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
965 | group.ApplyNextOwnerPermissions(); | 1048 | group.ApplyNextOwnerPermissions(); |
966 | } | 1049 | } |
967 | } | 1050 | } |
968 | 1051 | foreach (SceneObjectPart part in group.Parts) | |
969 | foreach (SceneObjectPart part in group.Parts) | 1052 | { |
970 | { | 1053 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) |
971 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | 1054 | part.EveryoneMask = item.EveryOnePermissions; |
972 | part.EveryoneMask = item.EveryOnePermissions; | 1055 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) |
973 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | 1056 | part.NextOwnerMask = item.NextPermissions; |
974 | part.NextOwnerMask = item.NextPermissions; | 1057 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) |
975 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) | 1058 | part.GroupMask = item.GroupPermissions; |
976 | part.GroupMask = item.GroupPermissions; | ||
977 | } | ||
978 | |||
979 | rootPart.TrimPermissions(); | ||
980 | |||
981 | if (!attachment) | ||
982 | { | ||
983 | if (group.RootPart.Shape.PCode == (byte)PCode.Prim) | ||
984 | { | ||
985 | // Save attachment data | ||
986 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
987 | group.RootPart.AttachOffset = storedPosition; | ||
988 | |||
989 | group.ClearPartAttachmentData(); | ||
990 | } | ||
991 | |||
992 | // Fire on_rez | ||
993 | group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); | ||
994 | rootPart.ParentGroup.ResumeScripts(); | ||
995 | |||
996 | rootPart.ScheduleFullUpdate(); | ||
997 | } | ||
998 | } | ||
999 | |||
1000 | if (!m_Scene.Permissions.BypassPermissions()) | ||
1001 | { | ||
1002 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1003 | { | ||
1004 | // If this is done on attachments, no | ||
1005 | // copy ones will be lost, so avoid it | ||
1006 | // | ||
1007 | if (!attachment) | ||
1008 | { | ||
1009 | List<UUID> uuids = new List<UUID>(); | ||
1010 | uuids.Add(item.ID); | ||
1011 | m_Scene.InventoryService.DeleteItems(item.Owner, uuids); | ||
1012 | } | ||
1013 | } | ||
1014 | } | ||
1015 | } | ||
1016 | return group; | ||
1017 | } | 1059 | } |
1018 | |||
1019 | return null; | ||
1020 | } | 1060 | } |
1021 | 1061 | ||
1022 | protected void AddUserData(SceneObjectGroup sog) | 1062 | protected void AddUserData(SceneObjectGroup sog) |
@@ -1033,11 +1073,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
1033 | public virtual bool CanGetAgentInventoryItem(IClientAPI remoteClient, UUID itemID, UUID requestID) | 1073 | public virtual bool CanGetAgentInventoryItem(IClientAPI remoteClient, UUID itemID, UUID requestID) |
1034 | { | 1074 | { |
1035 | InventoryItemBase assetRequestItem = GetItem(remoteClient.AgentId, itemID); | 1075 | InventoryItemBase assetRequestItem = GetItem(remoteClient.AgentId, itemID); |
1076 | |||
1036 | if (assetRequestItem == null) | 1077 | if (assetRequestItem == null) |
1037 | { | 1078 | { |
1038 | ILibraryService lib = m_Scene.RequestModuleInterface<ILibraryService>(); | 1079 | ILibraryService lib = m_Scene.RequestModuleInterface<ILibraryService>(); |
1080 | |||
1039 | if (lib != null) | 1081 | if (lib != null) |
1040 | assetRequestItem = lib.LibraryRootFolder.FindItem(itemID); | 1082 | assetRequestItem = lib.LibraryRootFolder.FindItem(itemID); |
1083 | |||
1041 | if (assetRequestItem == null) | 1084 | if (assetRequestItem == null) |
1042 | return false; | 1085 | return false; |
1043 | } | 1086 | } |
@@ -1068,6 +1111,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
1068 | m_log.WarnFormat( | 1111 | m_log.WarnFormat( |
1069 | "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}", | 1112 | "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}", |
1070 | Name, requestID, itemID, assetRequestItem.AssetID); | 1113 | Name, requestID, itemID, assetRequestItem.AssetID); |
1114 | |||
1071 | return false; | 1115 | return false; |
1072 | } | 1116 | } |
1073 | 1117 | ||
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs index 733ad25..e74310c 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs | |||
@@ -65,8 +65,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
65 | config.AddConfig("Modules"); | 65 | config.AddConfig("Modules"); |
66 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | 66 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); |
67 | 67 | ||
68 | m_scene = SceneSetupHelpers.SetupScene(); | 68 | m_scene = SceneHelpers.SetupScene(); |
69 | SceneSetupHelpers.SetupSceneModules(m_scene, config, m_iam); | 69 | SceneHelpers.SetupSceneModules(m_scene, config, m_iam); |
70 | 70 | ||
71 | // Create user | 71 | // Create user |
72 | string userFirstName = "Jock"; | 72 | string userFirstName = "Jock"; |
@@ -82,14 +82,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
82 | [Test] | 82 | [Test] |
83 | public void TestRezCoalescedObject() | 83 | public void TestRezCoalescedObject() |
84 | { | 84 | { |
85 | TestHelper.InMethod(); | 85 | TestHelpers.InMethod(); |
86 | // log4net.Config.XmlConfigurator.Configure(); | 86 | // log4net.Config.XmlConfigurator.Configure(); |
87 | 87 | ||
88 | // Create asset | 88 | // Create asset |
89 | SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20); | 89 | SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20); |
90 | object1.AbsolutePosition = new Vector3(15, 30, 45); | 90 | object1.AbsolutePosition = new Vector3(15, 30, 45); |
91 | 91 | ||
92 | SceneObjectGroup object2 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40); | 92 | SceneObjectGroup object2 = SceneHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40); |
93 | object2.AbsolutePosition = new Vector3(25, 50, 75); | 93 | object2.AbsolutePosition = new Vector3(25, 50, 75); |
94 | 94 | ||
95 | CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2); | 95 | CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2); |
@@ -138,11 +138,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
138 | [Test] | 138 | [Test] |
139 | public void TestRezObject() | 139 | public void TestRezObject() |
140 | { | 140 | { |
141 | TestHelper.InMethod(); | 141 | TestHelpers.InMethod(); |
142 | // log4net.Config.XmlConfigurator.Configure(); | 142 | // log4net.Config.XmlConfigurator.Configure(); |
143 | 143 | ||
144 | // Create asset | 144 | // Create asset |
145 | SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40); | 145 | SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40); |
146 | 146 | ||
147 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 147 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
148 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | 148 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index d570608..3155ce7 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | |||
@@ -185,6 +185,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
185 | archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName, false); | 185 | archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName, false); |
186 | archread.Execute(); | 186 | archread.Execute(); |
187 | } | 187 | } |
188 | |||
188 | foreach (InventoryNodeBase node in nodes) | 189 | foreach (InventoryNodeBase node in nodes) |
189 | FixPerms(node); | 190 | FixPerms(node); |
190 | } | 191 | } |
@@ -197,18 +198,19 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
197 | archread.Close(); | 198 | archread.Close(); |
198 | } | 199 | } |
199 | } | 200 | } |
200 | |||
201 | } | 201 | } |
202 | 202 | ||
203 | private void FixPerms(InventoryNodeBase node) | 203 | private void FixPerms(InventoryNodeBase node) |
204 | { | 204 | { |
205 | m_log.DebugFormat("[LIBRARY MODULE]: Fixing perms for {0} {1}", node.Name, node.ID); | ||
206 | |||
205 | if (node is InventoryItemBase) | 207 | if (node is InventoryItemBase) |
206 | { | 208 | { |
207 | InventoryItemBase item = (InventoryItemBase)node; | 209 | InventoryItemBase item = (InventoryItemBase)node; |
208 | item.BasePermissions = 0x7FFFFFFF; | 210 | item.BasePermissions = (uint)PermissionMask.All; |
209 | item.EveryOnePermissions = 0x7FFFFFFF; | 211 | item.EveryOnePermissions = (uint)PermissionMask.All - (uint)PermissionMask.Modify; |
210 | item.CurrentPermissions = 0x7FFFFFFF; | 212 | item.CurrentPermissions = (uint)PermissionMask.All; |
211 | item.NextPermissions = 0x7FFFFFFF; | 213 | item.NextPermissions = (uint)PermissionMask.All; |
212 | } | 214 | } |
213 | } | 215 | } |
214 | 216 | ||
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index f15f8f6..b5cbcbb 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs | |||
@@ -68,7 +68,6 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
68 | { | 68 | { |
69 | m_scene = scene; | 69 | m_scene = scene; |
70 | 70 | ||
71 | |||
72 | m_scene.AddCommand(this, "monitor report", | 71 | m_scene.AddCommand(this, "monitor report", |
73 | "monitor report", | 72 | "monitor report", |
74 | "Returns a variety of statistics about the current region and/or simulator", | 73 | "Returns a variety of statistics about the current region and/or simulator", |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 27eb178..b0b35e4 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -186,7 +186,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | |||
190 | private string[] GetUserNames(UUID uuid) | 189 | private string[] GetUserNames(UUID uuid) |
191 | { | 190 | { |
192 | string[] returnstring = new string[2]; | 191 | string[] returnstring = new string[2]; |
@@ -292,6 +291,25 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
292 | return userID.ToString(); | 291 | return userID.ToString(); |
293 | } | 292 | } |
294 | 293 | ||
294 | public void AddUser(UUID uuid, string first, string last) | ||
295 | { | ||
296 | if (m_UserCache.ContainsKey(uuid)) | ||
297 | return; | ||
298 | |||
299 | UserData user = new UserData(); | ||
300 | user.Id = uuid; | ||
301 | user.FirstName = first; | ||
302 | user.LastName = last; | ||
303 | // user.ProfileURL = we should initialize this to the default | ||
304 | |||
305 | AddUserInternal(user); | ||
306 | } | ||
307 | |||
308 | public void AddUser(UUID uuid, string first, string last, string profileURL) | ||
309 | { | ||
310 | AddUser(uuid, profileURL + ";" + first + " " + last); | ||
311 | } | ||
312 | |||
295 | public void AddUser(UUID id, string creatorData) | 313 | public void AddUser(UUID id, string creatorData) |
296 | { | 314 | { |
297 | if (m_UserCache.ContainsKey(id)) | 315 | if (m_UserCache.ContainsKey(id)) |
@@ -299,18 +317,17 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
299 | 317 | ||
300 | // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData); | 318 | // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData); |
301 | 319 | ||
302 | UserData user = new UserData(); | ||
303 | user.Id = id; | ||
304 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); | 320 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); |
305 | 321 | ||
306 | if (account != null) | 322 | if (account != null) |
307 | { | 323 | { |
308 | user.FirstName = account.FirstName; | 324 | AddUser(id, account.FirstName, account.LastName); |
309 | user.LastName = account.LastName; | ||
310 | // user.ProfileURL = we should initialize this to the default | ||
311 | } | 325 | } |
312 | else | 326 | else |
313 | { | 327 | { |
328 | UserData user = new UserData(); | ||
329 | user.Id = id; | ||
330 | |||
314 | if (creatorData != null && creatorData != string.Empty) | 331 | if (creatorData != null && creatorData != string.Empty) |
315 | { | 332 | { |
316 | //creatorData = <endpoint>;<name> | 333 | //creatorData = <endpoint>;<name> |
@@ -338,17 +355,19 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
338 | user.FirstName = "Unknown"; | 355 | user.FirstName = "Unknown"; |
339 | user.LastName = "User"; | 356 | user.LastName = "User"; |
340 | } | 357 | } |
341 | } | ||
342 | 358 | ||
343 | lock (m_UserCache) | 359 | AddUserInternal(user); |
344 | m_UserCache[id] = user; | 360 | } |
345 | |||
346 | //m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.HomeURL); | ||
347 | } | 361 | } |
348 | 362 | ||
349 | public void AddUser(UUID uuid, string first, string last, string profileURL) | 363 | void AddUserInternal(UserData user) |
350 | { | 364 | { |
351 | AddUser(uuid, profileURL + ";" + first + " " + last); | 365 | lock (m_UserCache) |
366 | m_UserCache[user.Id] = user; | ||
367 | |||
368 | m_log.DebugFormat( | ||
369 | "[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", | ||
370 | user.Id, user.FirstName, user.LastName, user.HomeURL); | ||
352 | } | 371 | } |
353 | 372 | ||
354 | //public void AddUser(UUID uuid, string userData) | 373 | //public void AddUser(UUID uuid, string userData) |
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index d647e71..b20a875 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | |||
@@ -282,6 +282,93 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | /// <summary> | ||
286 | /// Delivers the message to a scene entity. | ||
287 | /// </summary> | ||
288 | /// <param name='target'> | ||
289 | /// Target. | ||
290 | /// </param> | ||
291 | /// <param name='channel'> | ||
292 | /// Channel. | ||
293 | /// </param> | ||
294 | /// <param name='name'> | ||
295 | /// Name. | ||
296 | /// </param> | ||
297 | /// <param name='id'> | ||
298 | /// Identifier. | ||
299 | /// </param> | ||
300 | /// <param name='msg'> | ||
301 | /// Message. | ||
302 | /// </param> | ||
303 | public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) | ||
304 | { | ||
305 | error = null; | ||
306 | // Is id an avatar? | ||
307 | ScenePresence sp = m_scene.GetScenePresence(target); | ||
308 | |||
309 | if (sp != null) | ||
310 | { | ||
311 | // Send message to avatar | ||
312 | if (channel == 0) | ||
313 | { | ||
314 | m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Owner, 0, pos, name, id, false); | ||
315 | } | ||
316 | |||
317 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
318 | |||
319 | if (attachments.Count == 0) | ||
320 | return true; | ||
321 | |||
322 | // Get uuid of attachments | ||
323 | List<UUID> targets = new List<UUID>(); | ||
324 | foreach (SceneObjectGroup sog in attachments) | ||
325 | { | ||
326 | targets.Add(sog.UUID); | ||
327 | } | ||
328 | |||
329 | // Need to check each attachment | ||
330 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | ||
331 | { | ||
332 | if (li.GetHostID().Equals(id)) | ||
333 | continue; | ||
334 | |||
335 | if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) | ||
336 | continue; | ||
337 | |||
338 | if (targets.Contains(li.GetHostID())) | ||
339 | QueueMessage(new ListenerInfo(li, name, id, msg)); | ||
340 | } | ||
341 | |||
342 | return true; | ||
343 | } | ||
344 | |||
345 | // Need to toss an error here | ||
346 | if (channel == 0) | ||
347 | { | ||
348 | error = "Cannot use llRegionSayTo to message objects on channel 0"; | ||
349 | return false; | ||
350 | } | ||
351 | |||
352 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | ||
353 | { | ||
354 | // Dont process if this message is from yourself! | ||
355 | if (li.GetHostID().Equals(id)) | ||
356 | continue; | ||
357 | |||
358 | SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); | ||
359 | if (sPart == null) | ||
360 | continue; | ||
361 | |||
362 | if ( li.GetHostID().Equals(target)) | ||
363 | { | ||
364 | QueueMessage(new ListenerInfo(li, name, id, msg)); | ||
365 | break; | ||
366 | } | ||
367 | } | ||
368 | |||
369 | return true; | ||
370 | } | ||
371 | |||
285 | protected void QueueMessage(ListenerInfo li) | 372 | protected void QueueMessage(ListenerInfo li) |
286 | { | 373 | { |
287 | lock (m_pending.SyncRoot) | 374 | lock (m_pending.SyncRoot) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs index b570155..e5af1f4 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs | |||
@@ -48,7 +48,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage | |||
48 | private static bool m_Enabled = false; | 48 | private static bool m_Enabled = false; |
49 | 49 | ||
50 | private IConfigSource m_Config; | 50 | private IConfigSource m_Config; |
51 | bool m_Registered = false; | ||
52 | 51 | ||
53 | #region IRegionModule interface | 52 | #region IRegionModule interface |
54 | 53 | ||
@@ -64,9 +63,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage | |||
64 | m_log.Info("[MAP SERVICE IN CONNECTOR]: MapImage Service In Connector enabled"); | 63 | m_log.Info("[MAP SERVICE IN CONNECTOR]: MapImage Service In Connector enabled"); |
65 | new MapGetServiceConnector(m_Config, MainServer.Instance, "MapImageService"); | 64 | new MapGetServiceConnector(m_Config, MainServer.Instance, "MapImageService"); |
66 | } | 65 | } |
67 | |||
68 | } | 66 | } |
69 | |||
70 | } | 67 | } |
71 | 68 | ||
72 | public void PostInitialise() | 69 | public void PostInitialise() |
@@ -106,6 +103,5 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage | |||
106 | } | 103 | } |
107 | 104 | ||
108 | #endregion | 105 | #endregion |
109 | |||
110 | } | 106 | } |
111 | } | 107 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index 51d1d59..cc5d061 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs | |||
@@ -129,15 +129,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
129 | m_Cache = null; | 129 | m_Cache = null; |
130 | } | 130 | } |
131 | 131 | ||
132 | m_log.InfoFormat("[LOCAL ASSET SERVICES CONNECTOR]: Enabled local assets for region {0}", scene.RegionInfo.RegionName); | 132 | m_log.DebugFormat( |
133 | "[LOCAL ASSET SERVICES CONNECTOR]: Enabled connector for region {0}", scene.RegionInfo.RegionName); | ||
133 | 134 | ||
134 | if (m_Cache != null) | 135 | if (m_Cache != null) |
135 | { | 136 | { |
136 | m_log.InfoFormat("[LOCAL ASSET SERVICES CONNECTOR]: Enabled asset caching for region {0}", scene.RegionInfo.RegionName); | 137 | m_log.DebugFormat( |
138 | "[LOCAL ASSET SERVICES CONNECTOR]: Enabled asset caching for region {0}", | ||
139 | scene.RegionInfo.RegionName); | ||
137 | } | 140 | } |
138 | else | 141 | else |
139 | { | 142 | { |
140 | // Short-circuit directly to storage layer | 143 | // Short-circuit directly to storage layer. This ends up storing temporary and local assets. |
141 | // | 144 | // |
142 | scene.UnregisterModuleInterface<IAssetService>(this); | 145 | scene.UnregisterModuleInterface<IAssetService>(this); |
143 | scene.RegisterModuleInterface<IAssetService>(m_AssetService); | 146 | scene.RegisterModuleInterface<IAssetService>(m_AssetService); |
@@ -246,9 +249,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
246 | m_Cache.Cache(asset); | 249 | m_Cache.Cache(asset); |
247 | 250 | ||
248 | if (asset.Temporary || asset.Local) | 251 | if (asset.Temporary || asset.Local) |
252 | { | ||
253 | // m_log.DebugFormat( | ||
254 | // "[LOCAL ASSET SERVICE CONNECTOR]: Returning asset {0} {1} without querying database since status Temporary = {2}, Local = {3}", | ||
255 | // asset.Name, asset.ID, asset.Temporary, asset.Local); | ||
256 | |||
249 | return asset.ID; | 257 | return asset.ID; |
250 | 258 | } | |
251 | return m_AssetService.Store(asset); | 259 | else |
260 | { | ||
261 | // m_log.DebugFormat( | ||
262 | // "[LOCAL ASSET SERVICE CONNECTOR]: Passing {0} {1} on to asset service for storage, status Temporary = {2}, Local = {3}", | ||
263 | // asset.Name, asset.ID, asset.Temporary, asset.Local); | ||
264 | |||
265 | return m_AssetService.Store(asset); | ||
266 | } | ||
252 | } | 267 | } |
253 | 268 | ||
254 | public bool UpdateContent(string id, byte[] data) | 269 | public bool UpdateContent(string id, byte[] data) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs index 85a1ac3..18a7177 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs | |||
@@ -39,8 +39,7 @@ using OpenMetaverse; | |||
39 | 39 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | 40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization |
41 | { | 41 | { |
42 | public class LocalAuthorizationServicesConnector : | 42 | public class LocalAuthorizationServicesConnector : ISharedRegionModule, IAuthorizationService |
43 | ISharedRegionModule, IAuthorizationService | ||
44 | { | 43 | { |
45 | private static readonly ILog m_log = | 44 | private static readonly ILog m_log = |
46 | LogManager.GetLogger( | 45 | LogManager.GetLogger( |
@@ -127,15 +126,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | |||
127 | if (!m_Enabled) | 126 | if (!m_Enabled) |
128 | return; | 127 | return; |
129 | 128 | ||
130 | m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: Enabled local authorization for region {0}", scene.RegionInfo.RegionName); | 129 | m_log.InfoFormat( |
131 | 130 | "[AUTHORIZATION CONNECTOR]: Enabled local authorization for region {0}", | |
132 | 131 | scene.RegionInfo.RegionName); | |
133 | } | 132 | } |
134 | 133 | ||
135 | public bool IsAuthorizedForRegion(string userID, string regionID, out string message) | 134 | public bool IsAuthorizedForRegion( |
135 | string userID, string firstName, string lastName, string regionID, out string message) | ||
136 | { | 136 | { |
137 | return m_AuthorizationService.IsAuthorizedForRegion(userID, regionID, out message); | 137 | return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message); |
138 | } | 138 | } |
139 | |||
140 | } | 139 | } |
141 | } | 140 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs index 66994fa..003324f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs | |||
@@ -117,9 +117,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | |||
117 | 117 | ||
118 | } | 118 | } |
119 | 119 | ||
120 | public bool IsAuthorizedForRegion(string userID, string regionID, out string message) | 120 | public bool IsAuthorizedForRegion( |
121 | string userID, string firstName, string lastName, string regionID, out string message) | ||
121 | { | 122 | { |
122 | m_log.InfoFormat("[REMOTE AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} for region {1}", userID, regionID); | 123 | m_log.InfoFormat( |
124 | "[REMOTE AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} for region {1}", userID, regionID); | ||
123 | 125 | ||
124 | bool isAuthorized = true; | 126 | bool isAuthorized = true; |
125 | message = String.Empty; | 127 | message = String.Empty; |
@@ -140,17 +142,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | |||
140 | if (scene != null) | 142 | if (scene != null) |
141 | { | 143 | { |
142 | UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, new UUID(userID)); | 144 | UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, new UUID(userID)); |
143 | isAuthorized = IsAuthorizedForRegion(userID, account.FirstName, account.LastName, | 145 | |
144 | account.Email, scene.RegionInfo.RegionName, regionID, out message); | 146 | isAuthorized |
147 | = IsAuthorizedForRegion( | ||
148 | userID, firstName, lastName, account.Email, scene.RegionInfo.RegionName, regionID, out message); | ||
145 | } | 149 | } |
146 | else | 150 | else |
147 | { | 151 | { |
148 | m_log.ErrorFormat("[REMOTE AUTHORIZATION CONNECTOR] IsAuthorizedForRegion, can't find scene to match region id of {0} ",regionID); | 152 | m_log.ErrorFormat( |
153 | "[REMOTE AUTHORIZATION CONNECTOR] IsAuthorizedForRegion, can't find scene to match region id of {0}", | ||
154 | regionID); | ||
149 | } | 155 | } |
150 | 156 | ||
151 | |||
152 | return isAuthorized; | 157 | return isAuthorized; |
153 | |||
154 | } | 158 | } |
155 | } | 159 | } |
156 | } | 160 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index 150a4d5..cd7d6bc 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | |||
@@ -55,19 +55,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
55 | config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); | 55 | config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); |
56 | config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); | 56 | config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); |
57 | config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); | 57 | config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); |
58 | config.Configs["GridService"].Set("Region_Test_Region_1", "DefaultRegion"); | 58 | config.Configs["GridService"].Set("Region_Test_Region_1", "DefaultRegion"); |
59 | config.Configs["GridService"].Set("Region_Test_Region_2", "FallbackRegion"); | 59 | config.Configs["GridService"].Set("Region_Test_Region_2", "FallbackRegion"); |
60 | config.Configs["GridService"].Set("Region_Test_Region_3", "FallbackRegion"); | 60 | config.Configs["GridService"].Set("Region_Test_Region_3", "FallbackRegion"); |
61 | config.Configs["GridService"].Set("Region_Other_Region_4", "FallbackRegion"); | 61 | config.Configs["GridService"].Set("Region_Other_Region_4", "FallbackRegion"); |
62 | 62 | ||
63 | m_LocalConnector = new LocalGridServicesConnector(config); | 63 | m_LocalConnector = new LocalGridServicesConnector(config); |
64 | } | 64 | } |
65 | 65 | ||
66 | /// <summary> | 66 | /// <summary> |
67 | /// Test saving a V0.2 OpenSim Region Archive. | 67 | /// Test region registration. |
68 | /// </summary> | 68 | /// </summary> |
69 | [Test] | 69 | [Test] |
70 | public void TestRegisterRegionV0_2() | 70 | public void TestRegisterRegion() |
71 | { | 71 | { |
72 | SetUp(); | 72 | SetUp(); |
73 | 73 | ||
@@ -123,11 +123,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
123 | m_LocalConnector.RegisterRegion(UUID.Zero, r1); | 123 | m_LocalConnector.RegisterRegion(UUID.Zero, r1); |
124 | 124 | ||
125 | GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test"); | 125 | GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test"); |
126 | Assert.IsNull(result, "Retrieved GetRegionByName \"Test\" is not null"); | ||
127 | |||
128 | result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test Region 1"); | ||
126 | Assert.IsNotNull(result, "Retrieved GetRegionByName is null"); | 129 | Assert.IsNotNull(result, "Retrieved GetRegionByName is null"); |
127 | Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match"); | 130 | Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match"); |
128 | 131 | ||
129 | m_LocalConnector.RegisterRegion(UUID.Zero, r2); | 132 | m_LocalConnector.RegisterRegion(UUID.Zero, r2); |
130 | m_LocalConnector.RegisterRegion(UUID.Zero, r3); | 133 | m_LocalConnector.RegisterRegion(UUID.Zero, r3); |
131 | m_LocalConnector.RegisterRegion(UUID.Zero, r4); | 134 | m_LocalConnector.RegisterRegion(UUID.Zero, r4); |
132 | 135 | ||
133 | result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1)); | 136 | result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1)); |
@@ -152,38 +155,38 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
152 | Assert.IsNotNull(results, "Retrieved GetRegionRange collection is null"); | 155 | Assert.IsNotNull(results, "Retrieved GetRegionRange collection is null"); |
153 | Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected"); | 156 | Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected"); |
154 | 157 | ||
155 | results = m_LocalConnector.GetDefaultRegions(UUID.Zero); | 158 | results = m_LocalConnector.GetDefaultRegions(UUID.Zero); |
156 | Assert.IsNotNull(results, "Retrieved GetDefaultRegions collection is null"); | 159 | Assert.IsNotNull(results, "Retrieved GetDefaultRegions collection is null"); |
157 | Assert.That(results.Count, Is.EqualTo(1), "Retrieved default regions collection has not the expected size"); | 160 | Assert.That(results.Count, Is.EqualTo(1), "Retrieved default regions collection has not the expected size"); |
158 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(1)), "Retrieved default region's UUID does not match"); | 161 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(1)), "Retrieved default region's UUID does not match"); |
159 | 162 | ||
160 | results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r1.RegionLocX, r1.RegionLocY); | 163 | results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r1.RegionLocX, r1.RegionLocY); |
161 | Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 1 is null"); | 164 | Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 1 is null"); |
162 | Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 1 has not the expected size"); | 165 | Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 1 has not the expected size"); |
163 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions for default region are not in the expected order 2-4-3"); | 166 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions for default region are not in the expected order 2-4-3"); |
164 | Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions for default region are not in the expected order 2-4-3"); | 167 | Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions for default region are not in the expected order 2-4-3"); |
165 | Assert.That(results[2].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions for default region are not in the expected order 2-4-3"); | 168 | Assert.That(results[2].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions for default region are not in the expected order 2-4-3"); |
166 | 169 | ||
167 | results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r2.RegionLocX, r2.RegionLocY); | 170 | results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r2.RegionLocX, r2.RegionLocY); |
168 | Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 2 is null"); | 171 | Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 2 is null"); |
169 | Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 2 has not the expected size"); | 172 | Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 2 has not the expected size"); |
170 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 2-4-3"); | 173 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 2-4-3"); |
171 | Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 2-4-3"); | 174 | Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 2-4-3"); |
172 | Assert.That(results[2].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 2-4-3"); | 175 | Assert.That(results[2].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 2-4-3"); |
173 | 176 | ||
174 | results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r3.RegionLocX, r3.RegionLocY); | 177 | results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r3.RegionLocX, r3.RegionLocY); |
175 | Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 3 is null"); | 178 | Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 3 is null"); |
176 | Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 3 has not the expected size"); | 179 | Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 3 has not the expected size"); |
177 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 3-4-2"); | 180 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 3-4-2"); |
178 | Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 3-4-2"); | 181 | Assert.That(results[1].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 3-4-2"); |
179 | Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 3-4-2"); | 182 | Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 3-4-2"); |
180 | 183 | ||
181 | results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r4.RegionLocX, r4.RegionLocY); | 184 | results = m_LocalConnector.GetFallbackRegions(UUID.Zero, r4.RegionLocX, r4.RegionLocY); |
182 | Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 4 is null"); | 185 | Assert.IsNotNull(results, "Retrieved GetFallbackRegions collection for region 4 is null"); |
183 | Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 4 has not the expected size"); | 186 | Assert.That(results.Count, Is.EqualTo(3), "Retrieved fallback regions collection for region 4 has not the expected size"); |
184 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 4-3-2"); | 187 | Assert.That(results[0].RegionID, Is.EqualTo(new UUID(4)), "Retrieved fallback regions are not in the expected order 4-3-2"); |
185 | Assert.That(results[1].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 4-3-2"); | 188 | Assert.That(results[1].RegionID, Is.EqualTo(new UUID(3)), "Retrieved fallback regions are not in the expected order 4-3-2"); |
186 | Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 4-3-2"); | 189 | Assert.That(results[2].RegionID, Is.EqualTo(new UUID(2)), "Retrieved fallback regions are not in the expected order 4-3-2"); |
187 | 190 | ||
188 | results = m_LocalConnector.GetHyperlinks(UUID.Zero); | 191 | results = m_LocalConnector.GetHyperlinks(UUID.Zero); |
189 | Assert.IsNotNull(results, "Retrieved GetHyperlinks list is null"); | 192 | Assert.IsNotNull(results, "Retrieved GetHyperlinks list is null"); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs index 6543845..4cf62ec 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs | |||
@@ -66,7 +66,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser | |||
66 | public void OnMakeRootAgent(ScenePresence sp) | 66 | public void OnMakeRootAgent(ScenePresence sp) |
67 | { | 67 | { |
68 | // m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); | 68 | // m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); |
69 | m_GridUserService.SetLastPosition(sp.UUID.ToString(), UUID.Zero, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); | 69 | |
70 | if (sp.PresenceType != PresenceType.Npc) | ||
71 | m_GridUserService.SetLastPosition( | ||
72 | sp.UUID.ToString(), UUID.Zero, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); | ||
70 | } | 73 | } |
71 | 74 | ||
72 | public void OnNewClient(IClientAPI client) | 75 | public void OnNewClient(IClientAPI client) |
@@ -93,7 +96,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser | |||
93 | lookat = ((ScenePresence)sp).Lookat; | 96 | lookat = ((ScenePresence)sp).Lookat; |
94 | } | 97 | } |
95 | } | 98 | } |
96 | m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); | 99 | |
100 | // m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); | ||
97 | m_GridUserService.LoggedOut(client.AgentId.ToString(), client.SessionId, client.Scene.RegionInfo.RegionID, position, lookat); | 101 | m_GridUserService.LoggedOut(client.AgentId.ToString(), client.SessionId, client.Scene.RegionInfo.RegionID, position, lookat); |
98 | } | 102 | } |
99 | 103 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 698fd56..72ae3363 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs | |||
@@ -211,11 +211,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
211 | return; | 211 | return; |
212 | } | 212 | } |
213 | } | 213 | } |
214 | else | 214 | // else |
215 | { | 215 | // { |
216 | m_log.DebugFormat("[HG INVENTORY CONNECTOR]: User {0} does not have InventoryServerURI. OH NOES!", userID); | 216 | // m_log.DebugFormat("[HG INVENTORY CONNECTOR]: User {0} does not have InventoryServerURI. OH NOES!", userID); |
217 | return; | 217 | // return; |
218 | } | 218 | // } |
219 | } | 219 | } |
220 | } | 220 | } |
221 | if (sp == null) | 221 | if (sp == null) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 0c57618..65e39c0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | |||
@@ -280,7 +280,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
280 | { | 280 | { |
281 | // m_log.DebugFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Requesting inventory item {0}", item.ID); | 281 | // m_log.DebugFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Requesting inventory item {0}", item.ID); |
282 | 282 | ||
283 | UUID requestedItemId = item.ID; | 283 | // UUID requestedItemId = item.ID; |
284 | 284 | ||
285 | item = m_InventoryService.GetItem(item); | 285 | item = m_InventoryService.GetItem(item); |
286 | 286 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index e224670..6d3ace9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | |||
@@ -61,7 +61,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
61 | private bool m_enabled = false; | 61 | private bool m_enabled = false; |
62 | private IMapImageService m_MapService; | 62 | private IMapImageService m_MapService; |
63 | 63 | ||
64 | private string m_serverUrl = String.Empty; | ||
65 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); | 64 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); |
66 | 65 | ||
67 | private int m_refreshtime = 0; | 66 | private int m_refreshtime = 0; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index fa5b873..e2e383f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs | |||
@@ -39,7 +39,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | |||
39 | { | 39 | { |
40 | public class PresenceDetector | 40 | public class PresenceDetector |
41 | { | 41 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | private IPresenceService m_PresenceService; | 44 | private IPresenceService m_PresenceService; |
45 | private Scene m_aScene; | 45 | private Scene m_aScene; |
@@ -94,7 +94,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | |||
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); | 97 | // m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); |
98 | m_PresenceService.LogoutAgent(client.SessionId); | 98 | m_PresenceService.LogoutAgent(client.SessionId); |
99 | } | 99 | } |
100 | 100 | ||
diff --git a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs index c355b13..2399134 100644 --- a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs +++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs | |||
@@ -129,14 +129,12 @@ namespace OpenSim.Region.CoreModules.World | |||
129 | switch (cmd[1]) | 129 | switch (cmd[1]) |
130 | { | 130 | { |
131 | case "enable": | 131 | case "enable": |
132 | if (scene.LoginsDisabled) | ||
133 | MainConsole.Instance.Output(String.Format("Enabling logins for region {0}", scene.RegionInfo.RegionName)); | ||
134 | scene.LoginsDisabled = false; | 132 | scene.LoginsDisabled = false; |
133 | MainConsole.Instance.Output(String.Format("Logins are enabled for region {0}", scene.RegionInfo.RegionName)); | ||
135 | break; | 134 | break; |
136 | case "disable": | 135 | case "disable": |
137 | if (!scene.LoginsDisabled) | ||
138 | MainConsole.Instance.Output(String.Format("Disabling logins for region {0}", scene.RegionInfo.RegionName)); | ||
139 | scene.LoginsDisabled = true; | 136 | scene.LoginsDisabled = true; |
137 | MainConsole.Instance.Output(String.Format("Logins are disabled for region {0}", scene.RegionInfo.RegionName)); | ||
140 | break; | 138 | break; |
141 | case "status": | 139 | case "status": |
142 | if (scene.LoginsDisabled) | 140 | if (scene.LoginsDisabled) |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 6ba3459..b185d9b 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -68,8 +68,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
68 | SerialiserModule serialiserModule = new SerialiserModule(); | 68 | SerialiserModule serialiserModule = new SerialiserModule(); |
69 | TerrainModule terrainModule = new TerrainModule(); | 69 | TerrainModule terrainModule = new TerrainModule(); |
70 | 70 | ||
71 | m_scene = SceneSetupHelpers.SetupScene(); | 71 | m_scene = SceneHelpers.SetupScene(); |
72 | SceneSetupHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); | 72 | SceneHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); |
73 | } | 73 | } |
74 | 74 | ||
75 | private void LoadCompleted(Guid requestId, string errorMessage) | 75 | private void LoadCompleted(Guid requestId, string errorMessage) |
@@ -125,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
125 | [Test] | 125 | [Test] |
126 | public void TestSaveOar() | 126 | public void TestSaveOar() |
127 | { | 127 | { |
128 | TestHelper.InMethod(); | 128 | TestHelpers.InMethod(); |
129 | // log4net.Config.XmlConfigurator.Configure(); | 129 | // log4net.Config.XmlConfigurator.Configure(); |
130 | 130 | ||
131 | SceneObjectPart part1 = CreateSceneObjectPart1(); | 131 | SceneObjectPart part1 = CreateSceneObjectPart1(); |
@@ -217,7 +217,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
217 | [Test] | 217 | [Test] |
218 | public void TestSaveOarNoAssets() | 218 | public void TestSaveOarNoAssets() |
219 | { | 219 | { |
220 | TestHelper.InMethod(); | 220 | TestHelpers.InMethod(); |
221 | // log4net.Config.XmlConfigurator.Configure(); | 221 | // log4net.Config.XmlConfigurator.Configure(); |
222 | 222 | ||
223 | SceneObjectPart part1 = CreateSceneObjectPart1(); | 223 | SceneObjectPart part1 = CreateSceneObjectPart1(); |
@@ -300,7 +300,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
300 | [Test] | 300 | [Test] |
301 | public void TestLoadOar() | 301 | public void TestLoadOar() |
302 | { | 302 | { |
303 | TestHelper.InMethod(); | 303 | TestHelpers.InMethod(); |
304 | // log4net.Config.XmlConfigurator.Configure(); | 304 | // log4net.Config.XmlConfigurator.Configure(); |
305 | 305 | ||
306 | MemoryStream archiveWriteStream = new MemoryStream(); | 306 | MemoryStream archiveWriteStream = new MemoryStream(); |
@@ -409,7 +409,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
409 | [Test] | 409 | [Test] |
410 | public void TestLoadOarRegionSettings() | 410 | public void TestLoadOarRegionSettings() |
411 | { | 411 | { |
412 | TestHelper.InMethod(); | 412 | TestHelpers.InMethod(); |
413 | //log4net.Config.XmlConfigurator.Configure(); | 413 | //log4net.Config.XmlConfigurator.Configure(); |
414 | 414 | ||
415 | MemoryStream archiveWriteStream = new MemoryStream(); | 415 | MemoryStream archiveWriteStream = new MemoryStream(); |
@@ -505,7 +505,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
505 | //[Test] | 505 | //[Test] |
506 | public void TestMergeOar() | 506 | public void TestMergeOar() |
507 | { | 507 | { |
508 | TestHelper.InMethod(); | 508 | TestHelpers.InMethod(); |
509 | //XmlConfigurator.Configure(); | 509 | //XmlConfigurator.Configure(); |
510 | 510 | ||
511 | MemoryStream archiveWriteStream = new MemoryStream(); | 511 | MemoryStream archiveWriteStream = new MemoryStream(); |
@@ -524,8 +524,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
524 | SerialiserModule serialiserModule = new SerialiserModule(); | 524 | SerialiserModule serialiserModule = new SerialiserModule(); |
525 | TerrainModule terrainModule = new TerrainModule(); | 525 | TerrainModule terrainModule = new TerrainModule(); |
526 | 526 | ||
527 | Scene scene = SceneSetupHelpers.SetupScene(); | 527 | Scene scene = SceneHelpers.SetupScene(); |
528 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); | 528 | SceneHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); |
529 | 529 | ||
530 | m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); | 530 | m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); |
531 | 531 | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index b96f300..fb32288 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -875,41 +875,35 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
875 | SceneObjectPart prt = Scene.GetSceneObjectPart(obj); | 875 | SceneObjectPart prt = Scene.GetSceneObjectPart(obj); |
876 | if (prt != null) | 876 | if (prt != null) |
877 | { | 877 | { |
878 | if (prt.ParentGroup != null) | 878 | SceneObjectGroup sog = prt.ParentGroup; |
879 | LandStatReportItem lsri = new LandStatReportItem(); | ||
880 | lsri.LocationX = sog.AbsolutePosition.X; | ||
881 | lsri.LocationY = sog.AbsolutePosition.Y; | ||
882 | lsri.LocationZ = sog.AbsolutePosition.Z; | ||
883 | lsri.Score = SceneData[obj]; | ||
884 | lsri.TaskID = sog.UUID; | ||
885 | lsri.TaskLocalID = sog.LocalId; | ||
886 | lsri.TaskName = sog.GetPartName(obj); | ||
887 | lsri.OwnerName = "waiting"; | ||
888 | lock (uuidNameLookupList) | ||
889 | uuidNameLookupList.Add(sog.OwnerID); | ||
890 | |||
891 | if (filter.Length != 0) | ||
879 | { | 892 | { |
880 | SceneObjectGroup sog = prt.ParentGroup; | 893 | if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter))) |
881 | if (sog != null) | ||
882 | { | 894 | { |
883 | LandStatReportItem lsri = new LandStatReportItem(); | 895 | } |
884 | lsri.LocationX = sog.AbsolutePosition.X; | 896 | else |
885 | lsri.LocationY = sog.AbsolutePosition.Y; | 897 | { |
886 | lsri.LocationZ = sog.AbsolutePosition.Z; | 898 | continue; |
887 | lsri.Score = SceneData[obj]; | ||
888 | lsri.TaskID = sog.UUID; | ||
889 | lsri.TaskLocalID = sog.LocalId; | ||
890 | lsri.TaskName = sog.GetPartName(obj); | ||
891 | lsri.OwnerName = "waiting"; | ||
892 | lock (uuidNameLookupList) | ||
893 | uuidNameLookupList.Add(sog.OwnerID); | ||
894 | |||
895 | if (filter.Length != 0) | ||
896 | { | ||
897 | if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter))) | ||
898 | { | ||
899 | } | ||
900 | else | ||
901 | { | ||
902 | continue; | ||
903 | } | ||
904 | } | ||
905 | |||
906 | SceneReport.Add(lsri); | ||
907 | } | 899 | } |
908 | } | 900 | } |
909 | } | ||
910 | 901 | ||
902 | SceneReport.Add(lsri); | ||
903 | } | ||
911 | } | 904 | } |
912 | } | 905 | } |
906 | |||
913 | remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray()); | 907 | remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray()); |
914 | 908 | ||
915 | if (uuidNameLookupList.Count > 0) | 909 | if (uuidNameLookupList.Count > 0) |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 4e7c76f..a3066e7 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -423,17 +423,49 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
423 | SendLandUpdate(avatar, false); | 423 | SendLandUpdate(avatar, false); |
424 | } | 424 | } |
425 | 425 | ||
426 | public void EventManagerOnSignificantClientMovement(IClientAPI remote_client) | 426 | public void EventManagerOnSignificantClientMovement(ScenePresence clientAvatar) |
427 | { | 427 | { |
428 | ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId); | 428 | SendLandUpdate(clientAvatar); |
429 | 429 | SendOutNearestBanLine(clientAvatar.ControllingClient); | |
430 | if (clientAvatar != null) | 430 | ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); |
431 | if (parcel != null) | ||
431 | { | 432 | { |
432 | SendLandUpdate(clientAvatar); | 433 | if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT && |
433 | SendOutNearestBanLine(remote_client); | 434 | clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) |
434 | ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); | 435 | { |
435 | if (parcel != null) | 436 | EventManagerOnAvatarEnteringNewParcel(clientAvatar, parcel.LandData.LocalID, |
436 | EnforceBans(parcel, clientAvatar); | 437 | m_scene.RegionInfo.RegionID); |
438 | //They are going under the safety line! | ||
439 | if (!parcel.IsBannedFromLand(clientAvatar.UUID)) | ||
440 | { | ||
441 | clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; | ||
442 | } | ||
443 | } | ||
444 | else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT && | ||
445 | parcel.IsBannedFromLand(clientAvatar.UUID)) | ||
446 | { | ||
447 | //once we've sent the message once, keep going toward the target until we are done | ||
448 | if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId)) | ||
449 | { | ||
450 | SendYouAreBannedNotice(clientAvatar); | ||
451 | ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar)); | ||
452 | } | ||
453 | } | ||
454 | else if (parcel.IsRestrictedFromLand(clientAvatar.UUID)) | ||
455 | { | ||
456 | //once we've sent the message once, keep going toward the target until we are done | ||
457 | if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId)) | ||
458 | { | ||
459 | SendYouAreRestrictedNotice(clientAvatar); | ||
460 | ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar)); | ||
461 | } | ||
462 | } | ||
463 | else | ||
464 | { | ||
465 | //when we are finally in a safe place, lets release the forced position lock | ||
466 | forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); | ||
467 | } | ||
468 | EnforceBans(parcel, clientAvatar); | ||
437 | } | 469 | } |
438 | } | 470 | } |
439 | 471 | ||
@@ -665,7 +697,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
665 | // Corner case. If an autoreturn happens during sim startup | 697 | // Corner case. If an autoreturn happens during sim startup |
666 | // we will come here with the list uninitialized | 698 | // we will come here with the list uninitialized |
667 | // | 699 | // |
668 | int landId = m_landIDList[x, y]; | 700 | // int landId = m_landIDList[x, y]; |
669 | 701 | ||
670 | // if (landId == 0) | 702 | // if (landId == 0) |
671 | // m_log.DebugFormat( | 703 | // m_log.DebugFormat( |
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index f466194..5122734 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
51 | 51 | ||
52 | public class PrimCountModule : IPrimCountModule, INonSharedRegionModule | 52 | public class PrimCountModule : IPrimCountModule, INonSharedRegionModule |
53 | { | 53 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 55 | ||
56 | private Scene m_Scene; | 56 | private Scene m_Scene; |
57 | private Dictionary<UUID, PrimCounts> m_PrimCounts = | 57 | private Dictionary<UUID, PrimCounts> m_PrimCounts = |
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index a3aa38d..e553ffa 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs | |||
@@ -64,8 +64,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
64 | { | 64 | { |
65 | m_pcm = new PrimCountModule(); | 65 | m_pcm = new PrimCountModule(); |
66 | LandManagementModule lmm = new LandManagementModule(); | 66 | LandManagementModule lmm = new LandManagementModule(); |
67 | m_scene = SceneSetupHelpers.SetupScene(); | 67 | m_scene = SceneHelpers.SetupScene(); |
68 | SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm); | 68 | SceneHelpers.SetupSceneModules(m_scene, lmm, m_pcm); |
69 | 69 | ||
70 | int xParcelDivider = (int)Constants.RegionSize - 1; | 70 | int xParcelDivider = (int)Constants.RegionSize - 1; |
71 | 71 | ||
@@ -106,12 +106,12 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
106 | [Test] | 106 | [Test] |
107 | public void TestAddOwnerObject() | 107 | public void TestAddOwnerObject() |
108 | { | 108 | { |
109 | TestHelper.InMethod(); | 109 | TestHelpers.InMethod(); |
110 | // log4net.Config.XmlConfigurator.Configure(); | 110 | // log4net.Config.XmlConfigurator.Configure(); |
111 | 111 | ||
112 | IPrimCounts pc = m_lo.PrimCounts; | 112 | IPrimCounts pc = m_lo.PrimCounts; |
113 | 113 | ||
114 | SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); | 114 | SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); |
115 | m_scene.AddNewSceneObject(sog, false); | 115 | m_scene.AddNewSceneObject(sog, false); |
116 | 116 | ||
117 | Assert.That(pc.Owner, Is.EqualTo(3)); | 117 | Assert.That(pc.Owner, Is.EqualTo(3)); |
@@ -124,7 +124,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
124 | Assert.That(pc.Simulator, Is.EqualTo(3)); | 124 | Assert.That(pc.Simulator, Is.EqualTo(3)); |
125 | 125 | ||
126 | // Add a second object and retest | 126 | // Add a second object and retest |
127 | SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10); | 127 | SceneObjectGroup sog2 = SceneHelpers.CreateSceneObject(2, m_userId, "b", 0x10); |
128 | m_scene.AddNewSceneObject(sog2, false); | 128 | m_scene.AddNewSceneObject(sog2, false); |
129 | 129 | ||
130 | Assert.That(pc.Owner, Is.EqualTo(5)); | 130 | Assert.That(pc.Owner, Is.EqualTo(5)); |
@@ -143,12 +143,12 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
143 | [Test] | 143 | [Test] |
144 | public void TestCopyOwnerObject() | 144 | public void TestCopyOwnerObject() |
145 | { | 145 | { |
146 | TestHelper.InMethod(); | 146 | TestHelpers.InMethod(); |
147 | // log4net.Config.XmlConfigurator.Configure(); | 147 | // log4net.Config.XmlConfigurator.Configure(); |
148 | 148 | ||
149 | IPrimCounts pc = m_lo.PrimCounts; | 149 | IPrimCounts pc = m_lo.PrimCounts; |
150 | 150 | ||
151 | SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); | 151 | SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); |
152 | m_scene.AddNewSceneObject(sog, false); | 152 | m_scene.AddNewSceneObject(sog, false); |
153 | m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity); | 153 | m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity); |
154 | 154 | ||
@@ -169,12 +169,12 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
169 | [Test] | 169 | [Test] |
170 | public void TestMoveOwnerObject() | 170 | public void TestMoveOwnerObject() |
171 | { | 171 | { |
172 | TestHelper.InMethod(); | 172 | TestHelpers.InMethod(); |
173 | // log4net.Config.XmlConfigurator.Configure(); | 173 | // log4net.Config.XmlConfigurator.Configure(); |
174 | 174 | ||
175 | SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); | 175 | SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); |
176 | m_scene.AddNewSceneObject(sog, false); | 176 | m_scene.AddNewSceneObject(sog, false); |
177 | SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10); | 177 | SceneObjectGroup sog2 = SceneHelpers.CreateSceneObject(2, m_userId, "b", 0x10); |
178 | m_scene.AddNewSceneObject(sog2, false); | 178 | m_scene.AddNewSceneObject(sog2, false); |
179 | 179 | ||
180 | // Move the first scene object to the eastern strip parcel | 180 | // Move the first scene object to the eastern strip parcel |
@@ -230,13 +230,13 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
230 | [Test] | 230 | [Test] |
231 | public void TestRemoveOwnerObject() | 231 | public void TestRemoveOwnerObject() |
232 | { | 232 | { |
233 | TestHelper.InMethod(); | 233 | TestHelpers.InMethod(); |
234 | // log4net.Config.XmlConfigurator.Configure(); | 234 | // log4net.Config.XmlConfigurator.Configure(); |
235 | 235 | ||
236 | IPrimCounts pc = m_lo.PrimCounts; | 236 | IPrimCounts pc = m_lo.PrimCounts; |
237 | 237 | ||
238 | m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1), false); | 238 | m_scene.AddNewSceneObject(SceneHelpers.CreateSceneObject(1, m_userId, "a", 0x1), false); |
239 | SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10); | 239 | SceneObjectGroup sogToDelete = SceneHelpers.CreateSceneObject(3, m_userId, "b", 0x10); |
240 | m_scene.AddNewSceneObject(sogToDelete, false); | 240 | m_scene.AddNewSceneObject(sogToDelete, false); |
241 | m_scene.DeleteSceneObject(sogToDelete, false); | 241 | m_scene.DeleteSceneObject(sogToDelete, false); |
242 | 242 | ||
@@ -253,14 +253,14 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
253 | [Test] | 253 | [Test] |
254 | public void TestAddGroupObject() | 254 | public void TestAddGroupObject() |
255 | { | 255 | { |
256 | TestHelper.InMethod(); | 256 | TestHelpers.InMethod(); |
257 | // log4net.Config.XmlConfigurator.Configure(); | 257 | // log4net.Config.XmlConfigurator.Configure(); |
258 | 258 | ||
259 | m_lo.DeedToGroup(m_groupId); | 259 | m_lo.DeedToGroup(m_groupId); |
260 | 260 | ||
261 | IPrimCounts pc = m_lo.PrimCounts; | 261 | IPrimCounts pc = m_lo.PrimCounts; |
262 | 262 | ||
263 | SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01); | 263 | SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01); |
264 | sog.GroupID = m_groupId; | 264 | sog.GroupID = m_groupId; |
265 | m_scene.AddNewSceneObject(sog, false); | 265 | m_scene.AddNewSceneObject(sog, false); |
266 | 266 | ||
@@ -284,18 +284,18 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
284 | [Test] | 284 | [Test] |
285 | public void TestRemoveGroupObject() | 285 | public void TestRemoveGroupObject() |
286 | { | 286 | { |
287 | TestHelper.InMethod(); | 287 | TestHelpers.InMethod(); |
288 | // log4net.Config.XmlConfigurator.Configure(); | 288 | // log4net.Config.XmlConfigurator.Configure(); |
289 | 289 | ||
290 | m_lo.DeedToGroup(m_groupId); | 290 | m_lo.DeedToGroup(m_groupId); |
291 | 291 | ||
292 | IPrimCounts pc = m_lo.PrimCounts; | 292 | IPrimCounts pc = m_lo.PrimCounts; |
293 | 293 | ||
294 | SceneObjectGroup sogToKeep = SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1); | 294 | SceneObjectGroup sogToKeep = SceneHelpers.CreateSceneObject(1, m_userId, "a", 0x1); |
295 | sogToKeep.GroupID = m_groupId; | 295 | sogToKeep.GroupID = m_groupId; |
296 | m_scene.AddNewSceneObject(sogToKeep, false); | 296 | m_scene.AddNewSceneObject(sogToKeep, false); |
297 | 297 | ||
298 | SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10); | 298 | SceneObjectGroup sogToDelete = SceneHelpers.CreateSceneObject(3, m_userId, "b", 0x10); |
299 | m_scene.AddNewSceneObject(sogToDelete, false); | 299 | m_scene.AddNewSceneObject(sogToDelete, false); |
300 | m_scene.DeleteSceneObject(sogToDelete, false); | 300 | m_scene.DeleteSceneObject(sogToDelete, false); |
301 | 301 | ||
@@ -313,12 +313,12 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
313 | [Test] | 313 | [Test] |
314 | public void TestAddOthersObject() | 314 | public void TestAddOthersObject() |
315 | { | 315 | { |
316 | TestHelper.InMethod(); | 316 | TestHelpers.InMethod(); |
317 | // log4net.Config.XmlConfigurator.Configure(); | 317 | // log4net.Config.XmlConfigurator.Configure(); |
318 | 318 | ||
319 | IPrimCounts pc = m_lo.PrimCounts; | 319 | IPrimCounts pc = m_lo.PrimCounts; |
320 | 320 | ||
321 | SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01); | 321 | SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01); |
322 | m_scene.AddNewSceneObject(sog, false); | 322 | m_scene.AddNewSceneObject(sog, false); |
323 | 323 | ||
324 | Assert.That(pc.Owner, Is.EqualTo(0)); | 324 | Assert.That(pc.Owner, Is.EqualTo(0)); |
@@ -334,13 +334,13 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
334 | [Test] | 334 | [Test] |
335 | public void TestRemoveOthersObject() | 335 | public void TestRemoveOthersObject() |
336 | { | 336 | { |
337 | TestHelper.InMethod(); | 337 | TestHelpers.InMethod(); |
338 | // log4net.Config.XmlConfigurator.Configure(); | 338 | // log4net.Config.XmlConfigurator.Configure(); |
339 | 339 | ||
340 | IPrimCounts pc = m_lo.PrimCounts; | 340 | IPrimCounts pc = m_lo.PrimCounts; |
341 | 341 | ||
342 | m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_otherUserId, "a", 0x1), false); | 342 | m_scene.AddNewSceneObject(SceneHelpers.CreateSceneObject(1, m_otherUserId, "a", 0x1), false); |
343 | SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "b", 0x10); | 343 | SceneObjectGroup sogToDelete = SceneHelpers.CreateSceneObject(3, m_otherUserId, "b", 0x10); |
344 | m_scene.AddNewSceneObject(sogToDelete, false); | 344 | m_scene.AddNewSceneObject(sogToDelete, false); |
345 | m_scene.DeleteSceneObject(sogToDelete, false); | 345 | m_scene.DeleteSceneObject(sogToDelete, false); |
346 | 346 | ||
@@ -360,10 +360,10 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
360 | [Test] | 360 | [Test] |
361 | public void TestTaint() | 361 | public void TestTaint() |
362 | { | 362 | { |
363 | TestHelper.InMethod(); | 363 | TestHelpers.InMethod(); |
364 | IPrimCounts pc = m_lo.PrimCounts; | 364 | IPrimCounts pc = m_lo.PrimCounts; |
365 | 365 | ||
366 | SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); | 366 | SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); |
367 | m_scene.AddNewSceneObject(sog, false); | 367 | m_scene.AddNewSceneObject(sog, false); |
368 | 368 | ||
369 | m_pcm.TaintPrimCount(); | 369 | m_pcm.TaintPrimCount(); |
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs index aa14054..1d2141e 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs | |||
@@ -173,7 +173,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
173 | private Bitmap fetchTexture(UUID id) | 173 | private Bitmap fetchTexture(UUID id) |
174 | { | 174 | { |
175 | AssetBase asset = m_scene.AssetService.Get(id.ToString()); | 175 | AssetBase asset = m_scene.AssetService.Get(id.ToString()); |
176 | m_log.DebugFormat("Fetched texture {0}, found: {1}", id, asset != null); | 176 | m_log.DebugFormat("[TexturedMapTileRenderer]: Fetched texture {0}, found: {1}", id, asset != null); |
177 | if (asset == null) return null; | 177 | if (asset == null) return null; |
178 | 178 | ||
179 | ManagedImage managedImage; | 179 | ManagedImage managedImage; |
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs index d5b7082..4326606 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs | |||
@@ -53,17 +53,17 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests | |||
53 | public void SetUp() | 53 | public void SetUp() |
54 | { | 54 | { |
55 | m_module = new MoapModule(); | 55 | m_module = new MoapModule(); |
56 | m_scene = SceneSetupHelpers.SetupScene(); | 56 | m_scene = SceneHelpers.SetupScene(); |
57 | SceneSetupHelpers.SetupSceneModules(m_scene, m_module); | 57 | SceneHelpers.SetupSceneModules(m_scene, m_module); |
58 | } | 58 | } |
59 | 59 | ||
60 | [Test] | 60 | [Test] |
61 | public void TestClearMediaUrl() | 61 | public void TestClearMediaUrl() |
62 | { | 62 | { |
63 | TestHelper.InMethod(); | 63 | TestHelpers.InMethod(); |
64 | // log4net.Config.XmlConfigurator.Configure(); | 64 | // log4net.Config.XmlConfigurator.Configure(); |
65 | 65 | ||
66 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene); | 66 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); |
67 | MediaEntry me = new MediaEntry(); | 67 | MediaEntry me = new MediaEntry(); |
68 | 68 | ||
69 | m_module.SetMediaEntry(part, 1, me); | 69 | m_module.SetMediaEntry(part, 1, me); |
@@ -84,11 +84,11 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests | |||
84 | [Test] | 84 | [Test] |
85 | public void TestSetMediaUrl() | 85 | public void TestSetMediaUrl() |
86 | { | 86 | { |
87 | TestHelper.InMethod(); | 87 | TestHelpers.InMethod(); |
88 | 88 | ||
89 | string homeUrl = "opensimulator.org"; | 89 | string homeUrl = "opensimulator.org"; |
90 | 90 | ||
91 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene); | 91 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); |
92 | MediaEntry me = new MediaEntry() { HomeURL = homeUrl }; | 92 | MediaEntry me = new MediaEntry() { HomeURL = homeUrl }; |
93 | 93 | ||
94 | m_module.SetMediaEntry(part, 1, me); | 94 | m_module.SetMediaEntry(part, 1, me); |
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs index 516189f..49e3236 100644 --- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs | |||
@@ -85,7 +85,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell | |||
85 | IClientAPI client, UUID agentID, UUID sessionID, uint localID, byte saleType, int salePrice) | 85 | IClientAPI client, UUID agentID, UUID sessionID, uint localID, byte saleType, int salePrice) |
86 | { | 86 | { |
87 | SceneObjectPart part = m_scene.GetSceneObjectPart(localID); | 87 | SceneObjectPart part = m_scene.GetSceneObjectPart(localID); |
88 | if (part == null || part.ParentGroup == null) | 88 | if (part == null) |
89 | return; | 89 | return; |
90 | 90 | ||
91 | if (part.ParentGroup.IsDeleted) | 91 | if (part.ParentGroup.IsDeleted) |
@@ -111,9 +111,6 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell | |||
111 | if (part == null) | 111 | if (part == null) |
112 | return false; | 112 | return false; |
113 | 113 | ||
114 | if (part.ParentGroup == null) | ||
115 | return false; | ||
116 | |||
117 | SceneObjectGroup group = part.ParentGroup; | 114 | SceneObjectGroup group = part.ParentGroup; |
118 | 115 | ||
119 | switch (saleType) | 116 | switch (saleType) |
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 2c7843f..afb641f 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -146,7 +146,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
146 | = ParseUserSetConfigSetting(myConfig, "allowed_script_editors", m_allowedScriptEditors); | 146 | = ParseUserSetConfigSetting(myConfig, "allowed_script_editors", m_allowedScriptEditors); |
147 | 147 | ||
148 | if (m_bypassPermissions) | 148 | if (m_bypassPermissions) |
149 | m_log.Info("[PERMISSIONS]: serviceside_object_permissions = false in ini file so disabling all region service permission checks"); | 149 | m_log.Info("[PERMISSIONS]: serverside_object_permissions = false in ini file so disabling all region service permission checks"); |
150 | else | 150 | else |
151 | m_log.Debug("[PERMISSIONS]: Enabling all region service permission checks"); | 151 | m_log.Debug("[PERMISSIONS]: Enabling all region service permission checks"); |
152 | 152 | ||
@@ -1131,7 +1131,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1131 | SceneObjectPart part = scene.GetSceneObjectPart(objectID); | 1131 | SceneObjectPart part = scene.GetSceneObjectPart(objectID); |
1132 | if (part.OwnerID != moverID) | 1132 | if (part.OwnerID != moverID) |
1133 | { | 1133 | { |
1134 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) | 1134 | if (!part.ParentGroup.IsDeleted) |
1135 | { | 1135 | { |
1136 | if (part.ParentGroup.IsAttachment) | 1136 | if (part.ParentGroup.IsAttachment) |
1137 | return false; | 1137 | return false; |
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index 4f752ab..d5b585a 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | |||
@@ -236,14 +236,14 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
236 | public void Init() | 236 | public void Init() |
237 | { | 237 | { |
238 | m_serialiserModule = new SerialiserModule(); | 238 | m_serialiserModule = new SerialiserModule(); |
239 | m_scene = SceneSetupHelpers.SetupScene(); | 239 | m_scene = SceneHelpers.SetupScene(); |
240 | SceneSetupHelpers.SetupSceneModules(m_scene, m_serialiserModule); | 240 | SceneHelpers.SetupSceneModules(m_scene, m_serialiserModule); |
241 | } | 241 | } |
242 | 242 | ||
243 | [Test] | 243 | [Test] |
244 | public void TestDeserializeXml() | 244 | public void TestDeserializeXml() |
245 | { | 245 | { |
246 | TestHelper.InMethod(); | 246 | TestHelpers.InMethod(); |
247 | //log4net.Config.XmlConfigurator.Configure(); | 247 | //log4net.Config.XmlConfigurator.Configure(); |
248 | 248 | ||
249 | SceneObjectGroup so = SceneObjectSerializer.FromOriginalXmlFormat(xml); | 249 | SceneObjectGroup so = SceneObjectSerializer.FromOriginalXmlFormat(xml); |
@@ -259,7 +259,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
259 | [Test] | 259 | [Test] |
260 | public void TestSerializeXml() | 260 | public void TestSerializeXml() |
261 | { | 261 | { |
262 | TestHelper.InMethod(); | 262 | TestHelpers.InMethod(); |
263 | //log4net.Config.XmlConfigurator.Configure(); | 263 | //log4net.Config.XmlConfigurator.Configure(); |
264 | 264 | ||
265 | string rpName = "My Little Donkey"; | 265 | string rpName = "My Little Donkey"; |
@@ -334,7 +334,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
334 | [Test] | 334 | [Test] |
335 | public void TestDeserializeXml2() | 335 | public void TestDeserializeXml2() |
336 | { | 336 | { |
337 | TestHelper.InMethod(); | 337 | TestHelpers.InMethod(); |
338 | //log4net.Config.XmlConfigurator.Configure(); | 338 | //log4net.Config.XmlConfigurator.Configure(); |
339 | 339 | ||
340 | SceneObjectGroup so = m_serialiserModule.DeserializeGroupFromXml2(xml2); | 340 | SceneObjectGroup so = m_serialiserModule.DeserializeGroupFromXml2(xml2); |
@@ -350,7 +350,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
350 | [Test] | 350 | [Test] |
351 | public void TestSerializeXml2() | 351 | public void TestSerializeXml2() |
352 | { | 352 | { |
353 | TestHelper.InMethod(); | 353 | TestHelpers.InMethod(); |
354 | //log4net.Config.XmlConfigurator.Configure(); | 354 | //log4net.Config.XmlConfigurator.Configure(); |
355 | 355 | ||
356 | string rpName = "My Little Pony"; | 356 | string rpName = "My Little Pony"; |
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index 09c0ebb..22ffcd6 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | |||
@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
81 | 81 | ||
82 | if (grp.IsAttachment) | 82 | if (grp.IsAttachment) |
83 | { | 83 | { |
84 | if (grp.GetAttachmentPoint() > 30) // HUD | 84 | if (grp.AttachmentPoint > 30) // HUD |
85 | { | 85 | { |
86 | if (sp.ControllingClient.AgentId != grp.OwnerID) | 86 | if (sp.ControllingClient.AgentId != grp.OwnerID) |
87 | return; | 87 | return; |
@@ -115,7 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
115 | { | 115 | { |
116 | SceneObjectGroup grp = part.ParentGroup; | 116 | SceneObjectGroup grp = part.ParentGroup; |
117 | 117 | ||
118 | if (grp.IsAttachment && grp.GetAttachmentPoint() > 30) | 118 | if (grp.IsAttachment && grp.AttachmentPoint > 30) |
119 | { | 119 | { |
120 | objectID = ownerID; | 120 | objectID = ownerID; |
121 | parentID = ownerID; | 121 | parentID = ownerID; |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 2da6458..a93ffaa 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -84,7 +84,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
84 | private ITerrainChannel m_revert; | 84 | private ITerrainChannel m_revert; |
85 | private Scene m_scene; | 85 | private Scene m_scene; |
86 | private volatile bool m_tainted; | 86 | private volatile bool m_tainted; |
87 | private readonly UndoStack<LandUndoState> m_undo = new UndoStack<LandUndoState>(5); | 87 | private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5); |
88 | 88 | ||
89 | #region ICommandableModule Members | 89 | #region ICommandableModule Members |
90 | 90 | ||
diff --git a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs index c2ad7b8..ab8e1bf 100644 --- a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs +++ b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs | |||
@@ -100,15 +100,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Vegetation | |||
100 | { | 100 | { |
101 | case Tree.Cypress1: | 101 | case Tree.Cypress1: |
102 | case Tree.Cypress2: | 102 | case Tree.Cypress2: |
103 | tree.Scale = new Vector3(4, 4, 10); | 103 | tree.Scale *= new Vector3(8, 8, 20); |
104 | break; | 104 | break; |
105 | 105 | ||
106 | // case... other tree types | 106 | // case... other tree types |
107 | // tree.Scale = new Vector3(?, ?, ?); | 107 | // tree.Scale *= new Vector3(?, ?, ?); |
108 | // break; | 108 | // break; |
109 | 109 | ||
110 | default: | 110 | default: |
111 | tree.Scale = new Vector3(4, 4, 4); | 111 | tree.Scale *= new Vector3(8, 8, 8); |
112 | break; | 112 | break; |
113 | } | 113 | } |
114 | } | 114 | } |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index ced2773..c13e9c6 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | |||
@@ -96,16 +96,7 @@ m_log.DebugFormat("MAP NAME=({0})", mapName); | |||
96 | 96 | ||
97 | // try to fetch from GridServer | 97 | // try to fetch from GridServer |
98 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); | 98 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); |
99 | if (regionInfos == null) | 99 | if (regionInfos.Count == 0) |
100 | { | ||
101 | m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?"); | ||
102 | // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region | ||
103 | regionInfos = new List<GridRegion>(); | ||
104 | GridRegion info = m_scene.GridService.GetRegionByName(m_scene.RegionInfo.ScopeID, mapName); | ||
105 | if (info != null) | ||
106 | regionInfos.Add(info); | ||
107 | } | ||
108 | else if (regionInfos.Count == 0) | ||
109 | remoteClient.SendAlertMessage("Hyperlink could not be established."); | 100 | remoteClient.SendAlertMessage("Hyperlink could not be established."); |
110 | 101 | ||
111 | //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); | 102 | //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index ca5529d9..21e3ecb 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -46,6 +46,7 @@ using OpenSim.Framework.Servers; | |||
46 | using OpenSim.Framework.Servers.HttpServer; | 46 | using OpenSim.Framework.Servers.HttpServer; |
47 | using OpenSim.Region.Framework.Interfaces; | 47 | using OpenSim.Region.Framework.Interfaces; |
48 | using OpenSim.Region.Framework.Scenes; | 48 | using OpenSim.Region.Framework.Scenes; |
49 | using OpenSim.Region.CoreModules.World.Land; | ||
49 | using Caps=OpenSim.Framework.Capabilities.Caps; | 50 | using Caps=OpenSim.Framework.Capabilities.Caps; |
50 | using OSDArray=OpenMetaverse.StructuredData.OSDArray; | 51 | using OSDArray=OpenMetaverse.StructuredData.OSDArray; |
51 | using OSDMap=OpenMetaverse.StructuredData.OSDMap; | 52 | using OSDMap=OpenMetaverse.StructuredData.OSDMap; |
@@ -68,6 +69,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
68 | protected Scene m_scene; | 69 | protected Scene m_scene; |
69 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); | 70 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); |
70 | private int cachedTime = 0; | 71 | private int cachedTime = 0; |
72 | private int blacklistTimeout = 10*60*1000; // 10 minutes | ||
71 | private byte[] myMapImageJPEG; | 73 | private byte[] myMapImageJPEG; |
72 | protected volatile bool m_Enabled = false; | 74 | protected volatile bool m_Enabled = false; |
73 | private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>(); | 75 | private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>(); |
@@ -85,6 +87,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
85 | IConfig startupConfig = config.Configs["Startup"]; | 87 | IConfig startupConfig = config.Configs["Startup"]; |
86 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == "WorldMap") | 88 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == "WorldMap") |
87 | m_Enabled = true; | 89 | m_Enabled = true; |
90 | |||
91 | blacklistTimeout = startupConfig.GetInt("BlacklistTimeout", 10*60) * 1000; | ||
88 | } | 92 | } |
89 | 93 | ||
90 | public virtual void AddRegion (Scene scene) | 94 | public virtual void AddRegion (Scene scene) |
@@ -159,11 +163,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
159 | m_scene.EventManager.OnClientClosed += ClientLoggedOut; | 163 | m_scene.EventManager.OnClientClosed += ClientLoggedOut; |
160 | m_scene.EventManager.OnMakeChildAgent += MakeChildAgent; | 164 | m_scene.EventManager.OnMakeChildAgent += MakeChildAgent; |
161 | m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; | 165 | m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; |
166 | m_scene.EventManager.OnRegionUp += OnRegionUp; | ||
167 | |||
168 | StartThread(new object()); | ||
162 | } | 169 | } |
163 | 170 | ||
164 | // this has to be called with a lock on m_scene | 171 | // this has to be called with a lock on m_scene |
165 | protected virtual void RemoveHandlers() | 172 | protected virtual void RemoveHandlers() |
166 | { | 173 | { |
174 | StopThread(); | ||
175 | |||
176 | m_scene.EventManager.OnRegionUp -= OnRegionUp; | ||
167 | m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent; | 177 | m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent; |
168 | m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent; | 178 | m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent; |
169 | m_scene.EventManager.OnClientClosed -= ClientLoggedOut; | 179 | m_scene.EventManager.OnClientClosed -= ClientLoggedOut; |
@@ -279,7 +289,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
279 | /// <returns></returns> | 289 | /// <returns></returns> |
280 | public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) | 290 | public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) |
281 | { | 291 | { |
282 | m_log.Debug("[WORLD MAP]: MapLayer Request in region: " + m_scene.RegionInfo.RegionName); | 292 | m_log.DebugFormat("[WORLD MAP]: MapLayer Request in region: {0}", m_scene.RegionInfo.RegionName); |
283 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); | 293 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); |
284 | mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); | 294 | mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); |
285 | return mapResponse; | 295 | return mapResponse; |
@@ -321,8 +331,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
321 | lock (m_rootAgents) | 331 | lock (m_rootAgents) |
322 | { | 332 | { |
323 | m_rootAgents.Remove(AgentId); | 333 | m_rootAgents.Remove(AgentId); |
324 | if (m_rootAgents.Count == 0) | ||
325 | StopThread(); | ||
326 | } | 334 | } |
327 | } | 335 | } |
328 | #endregion | 336 | #endregion |
@@ -362,6 +370,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
362 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, | 370 | public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, |
363 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) | 371 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) |
364 | { | 372 | { |
373 | // m_log.DebugFormat("[WORLD MAP]: Handle MapItem request {0} {1}", regionhandle, itemtype); | ||
374 | |||
365 | lock (m_rootAgents) | 375 | lock (m_rootAgents) |
366 | { | 376 | { |
367 | if (!m_rootAgents.Contains(remoteClient.AgentId)) | 377 | if (!m_rootAgents.Contains(remoteClient.AgentId)) |
@@ -370,7 +380,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
370 | uint xstart = 0; | 380 | uint xstart = 0; |
371 | uint ystart = 0; | 381 | uint ystart = 0; |
372 | Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out xstart, out ystart); | 382 | Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out xstart, out ystart); |
373 | if (itemtype == 6) // we only sevice 6 right now (avatar green dots) | 383 | if (itemtype == 6) // Service 6 right now (MAP_ITEM_AGENTS_LOCATION; green dots) |
374 | { | 384 | { |
375 | if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) | 385 | if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) |
376 | { | 386 | { |
@@ -414,14 +424,57 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
414 | // Remote Map Item Request | 424 | // Remote Map Item Request |
415 | 425 | ||
416 | // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. | 426 | // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. |
417 | // Note that we only start up a remote mapItem Request thread if there's users who could | 427 | RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); |
418 | // be making requests | 428 | } |
419 | if (!threadrunning) | 429 | } else if (itemtype == 7) // Service 7 (MAP_ITEM_LAND_FOR_SALE) |
430 | { | ||
431 | if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) | ||
432 | { | ||
433 | // Parcels | ||
434 | ILandChannel landChannel = m_scene.LandChannel; | ||
435 | List<ILandObject> parcels = landChannel.AllParcels(); | ||
436 | |||
437 | // Local Map Item Request | ||
438 | List<mapItemReply> mapitems = new List<mapItemReply>(); | ||
439 | mapItemReply mapitem = new mapItemReply(); | ||
440 | if ((parcels != null) && (parcels.Count >= 1)) | ||
420 | { | 441 | { |
421 | m_log.Warn("[WORLD MAP]: Starting new remote request thread manually. This means that AvatarEnteringParcel never fired! This needs to be fixed! Don't Mantis this, as the developers can see it in this message"); | 442 | foreach (ILandObject parcel_interface in parcels) |
422 | StartThread(new object()); | 443 | { |
444 | // Play it safe | ||
445 | if (!(parcel_interface is LandObject)) | ||
446 | continue; | ||
447 | |||
448 | LandObject land = (LandObject)parcel_interface; | ||
449 | LandData parcel = land.LandData; | ||
450 | |||
451 | // Show land for sale | ||
452 | if ((parcel.Flags & (uint)ParcelFlags.ForSale) == (uint)ParcelFlags.ForSale) | ||
453 | { | ||
454 | Vector3 min = parcel.AABBMin; | ||
455 | Vector3 max = parcel.AABBMax; | ||
456 | float x = (min.X+max.X)/2; | ||
457 | float y = (min.Y+max.Y)/2; | ||
458 | |||
459 | mapitem = new mapItemReply(); | ||
460 | mapitem.x = (uint)(xstart + x); | ||
461 | mapitem.y = (uint)(ystart + y); | ||
462 | // mapitem.z = (uint)m_scene.GetGroundHeight(x,y); | ||
463 | mapitem.id = UUID.Zero; | ||
464 | mapitem.name = parcel.Name; | ||
465 | mapitem.Extra = parcel.Area; | ||
466 | mapitem.Extra2 = parcel.SalePrice; | ||
467 | mapitems.Add(mapitem); | ||
468 | } | ||
469 | } | ||
423 | } | 470 | } |
471 | remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); | ||
472 | } | ||
473 | else | ||
474 | { | ||
475 | // Remote Map Item Request | ||
424 | 476 | ||
477 | // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes. | ||
425 | RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); | 478 | RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); |
426 | } | 479 | } |
427 | } | 480 | } |
@@ -542,6 +595,28 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
542 | } | 595 | } |
543 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags); | 596 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags); |
544 | } | 597 | } |
598 | |||
599 | // Service 7 (MAP_ITEM_LAND_FOR_SALE) | ||
600 | uint itemtype = 7; | ||
601 | |||
602 | if (response.ContainsKey(itemtype.ToString())) | ||
603 | { | ||
604 | List<mapItemReply> returnitems = new List<mapItemReply>(); | ||
605 | OSDArray itemarray = (OSDArray)response[itemtype.ToString()]; | ||
606 | for (int i = 0; i < itemarray.Count; i++) | ||
607 | { | ||
608 | OSDMap mapitem = (OSDMap)itemarray[i]; | ||
609 | mapItemReply mi = new mapItemReply(); | ||
610 | mi.x = (uint)mapitem["X"].AsInteger(); | ||
611 | mi.y = (uint)mapitem["Y"].AsInteger(); | ||
612 | mi.id = mapitem["ID"].AsUUID(); | ||
613 | mi.Extra = mapitem["Extra"].AsInteger(); | ||
614 | mi.Extra2 = mapitem["Extra2"].AsInteger(); | ||
615 | mi.name = mapitem["Name"].AsString(); | ||
616 | returnitems.Add(mi); | ||
617 | } | ||
618 | av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags); | ||
619 | } | ||
545 | } | 620 | } |
546 | } | 621 | } |
547 | } | 622 | } |
@@ -589,12 +664,23 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
589 | private OSDMap RequestMapItemsAsync(UUID id, uint flags, | 664 | private OSDMap RequestMapItemsAsync(UUID id, uint flags, |
590 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) | 665 | uint EstateID, bool godlike, uint itemtype, ulong regionhandle) |
591 | { | 666 | { |
667 | // m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); | ||
668 | |||
592 | string httpserver = ""; | 669 | string httpserver = ""; |
593 | bool blacklisted = false; | 670 | bool blacklisted = false; |
594 | lock (m_blacklistedregions) | 671 | lock (m_blacklistedregions) |
595 | { | 672 | { |
596 | if (m_blacklistedregions.ContainsKey(regionhandle)) | 673 | if (m_blacklistedregions.ContainsKey(regionhandle)) |
597 | blacklisted = true; | 674 | { |
675 | if (Environment.TickCount > (m_blacklistedregions[regionhandle] + blacklistTimeout)) | ||
676 | { | ||
677 | m_log.DebugFormat("[WORLDMAP]: Unblock blacklisted region {0}", regionhandle); | ||
678 | |||
679 | m_blacklistedregions.Remove(regionhandle); | ||
680 | } | ||
681 | else | ||
682 | blacklisted = true; | ||
683 | } | ||
598 | } | 684 | } |
599 | 685 | ||
600 | if (blacklisted) | 686 | if (blacklisted) |
@@ -636,7 +722,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
636 | lock (m_blacklistedurls) | 722 | lock (m_blacklistedurls) |
637 | { | 723 | { |
638 | if (m_blacklistedurls.ContainsKey(httpserver)) | 724 | if (m_blacklistedurls.ContainsKey(httpserver)) |
639 | blacklisted = true; | 725 | { |
726 | if (Environment.TickCount > (m_blacklistedurls[httpserver] + blacklistTimeout)) | ||
727 | { | ||
728 | m_log.DebugFormat("[WORLDMAP]: Unblock blacklisted URL {0}", httpserver); | ||
729 | |||
730 | m_blacklistedurls.Remove(httpserver); | ||
731 | } | ||
732 | else | ||
733 | blacklisted = true; | ||
734 | } | ||
640 | } | 735 | } |
641 | 736 | ||
642 | // Can't find the http server | 737 | // Can't find the http server |
@@ -682,7 +777,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
682 | mapitemsrequest.ContentLength = buffer.Length; //Count bytes to send | 777 | mapitemsrequest.ContentLength = buffer.Length; //Count bytes to send |
683 | os = mapitemsrequest.GetRequestStream(); | 778 | os = mapitemsrequest.GetRequestStream(); |
684 | os.Write(buffer, 0, buffer.Length); //Send it | 779 | os.Write(buffer, 0, buffer.Length); //Send it |
685 | os.Close(); | ||
686 | //m_log.DebugFormat("[WORLD MAP]: Getting MapItems from {0}", httpserver); | 780 | //m_log.DebugFormat("[WORLD MAP]: Getting MapItems from {0}", httpserver); |
687 | } | 781 | } |
688 | catch (WebException ex) | 782 | catch (WebException ex) |
@@ -705,6 +799,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
705 | responseMap["connect"] = OSD.FromBoolean(false); | 799 | responseMap["connect"] = OSD.FromBoolean(false); |
706 | return responseMap; | 800 | return responseMap; |
707 | } | 801 | } |
802 | finally | ||
803 | { | ||
804 | if (os != null) | ||
805 | os.Close(); | ||
806 | } | ||
708 | 807 | ||
709 | string response_mapItems_reply = null; | 808 | string response_mapItems_reply = null; |
710 | { // get the response | 809 | { // get the response |
@@ -1060,6 +1159,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1060 | 1159 | ||
1061 | Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart); | 1160 | Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart); |
1062 | 1161 | ||
1162 | // Service 6 (MAP_ITEM_AGENTS_LOCATION; green dots) | ||
1163 | |||
1063 | OSDMap responsemap = new OSDMap(); | 1164 | OSDMap responsemap = new OSDMap(); |
1064 | int tc = Environment.TickCount; | 1165 | int tc = Environment.TickCount; |
1065 | if (m_scene.GetRootAgentCount() == 0) | 1166 | if (m_scene.GetRootAgentCount() == 0) |
@@ -1092,6 +1193,60 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1092 | }); | 1193 | }); |
1093 | responsemap["6"] = responsearr; | 1194 | responsemap["6"] = responsearr; |
1094 | } | 1195 | } |
1196 | |||
1197 | // Service 7 (MAP_ITEM_LAND_FOR_SALE) | ||
1198 | |||
1199 | ILandChannel landChannel = m_scene.LandChannel; | ||
1200 | List<ILandObject> parcels = landChannel.AllParcels(); | ||
1201 | |||
1202 | if ((parcels == null) || (parcels.Count == 0)) | ||
1203 | { | ||
1204 | OSDMap responsemapdata = new OSDMap(); | ||
1205 | responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1)); | ||
1206 | responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1)); | ||
1207 | responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); | ||
1208 | responsemapdata["Name"] = OSD.FromString(""); | ||
1209 | responsemapdata["Extra"] = OSD.FromInteger(0); | ||
1210 | responsemapdata["Extra2"] = OSD.FromInteger(0); | ||
1211 | OSDArray responsearr = new OSDArray(); | ||
1212 | responsearr.Add(responsemapdata); | ||
1213 | |||
1214 | responsemap["7"] = responsearr; | ||
1215 | } | ||
1216 | else | ||
1217 | { | ||
1218 | OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); | ||
1219 | foreach (ILandObject parcel_interface in parcels) | ||
1220 | { | ||
1221 | // Play it safe | ||
1222 | if (!(parcel_interface is LandObject)) | ||
1223 | continue; | ||
1224 | |||
1225 | LandObject land = (LandObject)parcel_interface; | ||
1226 | LandData parcel = land.LandData; | ||
1227 | |||
1228 | // Show land for sale | ||
1229 | if ((parcel.Flags & (uint)ParcelFlags.ForSale) == (uint)ParcelFlags.ForSale) | ||
1230 | { | ||
1231 | Vector3 min = parcel.AABBMin; | ||
1232 | Vector3 max = parcel.AABBMax; | ||
1233 | float x = (min.X+max.X)/2; | ||
1234 | float y = (min.Y+max.Y)/2; | ||
1235 | |||
1236 | OSDMap responsemapdata = new OSDMap(); | ||
1237 | responsemapdata["X"] = OSD.FromInteger((int)(xstart + x)); | ||
1238 | responsemapdata["Y"] = OSD.FromInteger((int)(ystart + y)); | ||
1239 | // responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y)); | ||
1240 | responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); | ||
1241 | responsemapdata["Name"] = OSD.FromString(parcel.Name); | ||
1242 | responsemapdata["Extra"] = OSD.FromInteger(parcel.Area); | ||
1243 | responsemapdata["Extra2"] = OSD.FromInteger(parcel.SalePrice); | ||
1244 | responsearr.Add(responsemapdata); | ||
1245 | } | ||
1246 | } | ||
1247 | responsemap["7"] = responsearr; | ||
1248 | } | ||
1249 | |||
1095 | return responsemap; | 1250 | return responsemap; |
1096 | } | 1251 | } |
1097 | 1252 | ||
@@ -1110,14 +1265,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1110 | if (data == null) | 1265 | if (data == null) |
1111 | return; | 1266 | return; |
1112 | 1267 | ||
1113 | UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID; | ||
1114 | |||
1115 | m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE"); | 1268 | m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE"); |
1116 | 1269 | ||
1117 | m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Random(); | 1270 | UUID terrainImageID = UUID.Random(); |
1118 | 1271 | ||
1119 | AssetBase asset = new AssetBase( | 1272 | AssetBase asset = new AssetBase( |
1120 | m_scene.RegionInfo.RegionSettings.TerrainImageID, | 1273 | terrainImageID, |
1121 | "terrainImage_" + m_scene.RegionInfo.RegionID.ToString(), | 1274 | "terrainImage_" + m_scene.RegionInfo.RegionID.ToString(), |
1122 | (sbyte)AssetType.Texture, | 1275 | (sbyte)AssetType.Texture, |
1123 | m_scene.RegionInfo.RegionID.ToString()); | 1276 | m_scene.RegionInfo.RegionID.ToString()); |
@@ -1129,6 +1282,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1129 | // Store the new one | 1282 | // Store the new one |
1130 | m_log.DebugFormat("[WORLDMAP]: Storing map tile {0}", asset.ID); | 1283 | m_log.DebugFormat("[WORLDMAP]: Storing map tile {0}", asset.ID); |
1131 | m_scene.AssetService.Store(asset); | 1284 | m_scene.AssetService.Store(asset); |
1285 | |||
1286 | // Switch to the new one | ||
1287 | UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID; | ||
1288 | m_scene.RegionInfo.RegionSettings.TerrainImageID = terrainImageID; | ||
1132 | m_scene.RegionInfo.RegionSettings.Save(); | 1289 | m_scene.RegionInfo.RegionSettings.Save(); |
1133 | 1290 | ||
1134 | // Delete the old one | 1291 | // Delete the old one |
@@ -1138,12 +1295,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1138 | 1295 | ||
1139 | private void MakeRootAgent(ScenePresence avatar) | 1296 | private void MakeRootAgent(ScenePresence avatar) |
1140 | { | 1297 | { |
1141 | // You may ask, why this is in a threadpool to start with.. | ||
1142 | // The reason is so we don't cause the thread to freeze waiting | ||
1143 | // for the 1 second it costs to start a thread manually. | ||
1144 | if (!threadrunning) | ||
1145 | Util.FireAndForget(this.StartThread); | ||
1146 | |||
1147 | lock (m_rootAgents) | 1298 | lock (m_rootAgents) |
1148 | { | 1299 | { |
1149 | if (!m_rootAgents.Contains(avatar.UUID)) | 1300 | if (!m_rootAgents.Contains(avatar.UUID)) |
@@ -1158,8 +1309,30 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1158 | lock (m_rootAgents) | 1309 | lock (m_rootAgents) |
1159 | { | 1310 | { |
1160 | m_rootAgents.Remove(avatar.UUID); | 1311 | m_rootAgents.Remove(avatar.UUID); |
1161 | if (m_rootAgents.Count == 0) | 1312 | } |
1162 | StopThread(); | 1313 | } |
1314 | |||
1315 | public void OnRegionUp(GridRegion otherRegion) | ||
1316 | { | ||
1317 | ulong regionhandle = otherRegion.RegionHandle; | ||
1318 | string httpserver = otherRegion.ServerURI + "MAP/MapItems/" + regionhandle.ToString(); | ||
1319 | |||
1320 | lock (m_blacklistedregions) | ||
1321 | { | ||
1322 | if (!m_blacklistedregions.ContainsKey(regionhandle)) | ||
1323 | m_blacklistedregions.Remove(regionhandle); | ||
1324 | } | ||
1325 | |||
1326 | lock (m_blacklistedurls) | ||
1327 | { | ||
1328 | if (m_blacklistedurls.ContainsKey(httpserver)) | ||
1329 | m_blacklistedurls.Remove(httpserver); | ||
1330 | } | ||
1331 | |||
1332 | lock (m_cachedRegionMapItemsAddress) | ||
1333 | { | ||
1334 | if (!m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) | ||
1335 | m_cachedRegionMapItemsAddress.Remove(regionhandle); | ||
1163 | } | 1336 | } |
1164 | } | 1337 | } |
1165 | 1338 | ||