diff options
Diffstat (limited to 'OpenSim/Region/CoreModules')
60 files changed, 2761 insertions, 1305 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 127ca1d..7054825 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -83,7 +83,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
83 | private Dictionary<string, ManualResetEvent> m_CurrentlyWriting = new Dictionary<string, ManualResetEvent>(); | 83 | private Dictionary<string, ManualResetEvent> m_CurrentlyWriting = new Dictionary<string, ManualResetEvent>(); |
84 | private int m_WaitOnInprogressTimeout = 3000; | 84 | private int m_WaitOnInprogressTimeout = 3000; |
85 | #else | 85 | #else |
86 | private List<string> m_CurrentlyWriting = new List<string>(); | 86 | private HashSet<string> m_CurrentlyWriting = new HashSet<string>(); |
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | private bool m_FileCacheEnabled = true; | 89 | private bool m_FileCacheEnabled = true; |
@@ -272,7 +272,11 @@ namespace Flotsam.RegionModules.AssetCache | |||
272 | // the other thread has updated the time for us. | 272 | // the other thread has updated the time for us. |
273 | try | 273 | try |
274 | { | 274 | { |
275 | File.SetLastAccessTime(filename, DateTime.Now); | 275 | lock (m_CurrentlyWriting) |
276 | { | ||
277 | if (!m_CurrentlyWriting.Contains(filename)) | ||
278 | File.SetLastAccessTime(filename, DateTime.Now); | ||
279 | } | ||
276 | } | 280 | } |
277 | catch | 281 | catch |
278 | { | 282 | { |
diff --git a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs index 5adb845..c91b25f 100644 --- a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs +++ b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs | |||
@@ -65,7 +65,7 @@ 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 = SceneHelpers.SetupScene(); | 68 | m_scene = new SceneHelpers().SetupScene(); |
69 | SceneHelpers.SetupSceneModules(m_scene, config, m_cache); | 69 | SceneHelpers.SetupSceneModules(m_scene, config, m_cache); |
70 | } | 70 | } |
71 | 71 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index d7c7283..de40e59 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 51 | ||
52 | private Scene m_scene; | 52 | private Scene m_scene; |
53 | private IDialogModule m_dialogModule; | 53 | private IInventoryAccessModule m_invAccessModule; |
54 | 54 | ||
55 | /// <summary> | 55 | /// <summary> |
56 | /// Are attachments enabled? | 56 | /// Are attachments enabled? |
@@ -72,7 +72,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
72 | public void AddRegion(Scene scene) | 72 | public void AddRegion(Scene scene) |
73 | { | 73 | { |
74 | m_scene = scene; | 74 | m_scene = scene; |
75 | m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>(); | ||
76 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); | 75 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); |
77 | 76 | ||
78 | if (Enabled) | 77 | if (Enabled) |
@@ -89,7 +88,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
89 | m_scene.EventManager.OnNewClient -= SubscribeToClientEvents; | 88 | m_scene.EventManager.OnNewClient -= SubscribeToClientEvents; |
90 | } | 89 | } |
91 | 90 | ||
92 | public void RegionLoaded(Scene scene) {} | 91 | public void RegionLoaded(Scene scene) |
92 | { | ||
93 | m_invAccessModule = m_scene.RequestModuleInterface<IInventoryAccessModule>(); | ||
94 | } | ||
93 | 95 | ||
94 | public void Close() | 96 | public void Close() |
95 | { | 97 | { |
@@ -189,7 +191,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
189 | } | 191 | } |
190 | catch (Exception e) | 192 | catch (Exception e) |
191 | { | 193 | { |
192 | m_log.ErrorFormat("[ATTACHMENTS MODULE]: Unable to rez attachment: {0}{1}", e.Message, e.StackTrace); | 194 | UUID agentId = (sp.ControllingClient == null) ? (UUID)null : sp.ControllingClient.AgentId; |
195 | m_log.ErrorFormat("[ATTACHMENTS MODULE]: Unable to rez attachment with itemID {0}, assetID {1}, point {2} for {3}: {4}\n{5}", | ||
196 | attach.ItemID, attach.AssetID, p, agentId, e.Message, e.StackTrace); | ||
193 | } | 197 | } |
194 | } | 198 | } |
195 | } | 199 | } |
@@ -440,7 +444,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
440 | lock (sp.AttachmentsSyncLock) | 444 | lock (sp.AttachmentsSyncLock) |
441 | { | 445 | { |
442 | // Save avatar attachment information | 446 | // Save avatar attachment information |
443 | m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID); | 447 | // m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID); |
444 | 448 | ||
445 | bool changed = sp.Appearance.DetachAttachment(itemID); | 449 | bool changed = sp.Appearance.DetachAttachment(itemID); |
446 | if (changed && m_scene.AvatarFactory != null) | 450 | if (changed && m_scene.AvatarFactory != null) |
@@ -520,9 +524,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
520 | 524 | ||
521 | if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts())) | 525 | if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts())) |
522 | { | 526 | { |
523 | m_log.DebugFormat( | 527 | // m_log.DebugFormat( |
524 | "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", | 528 | // "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", |
525 | grp.UUID, grp.AttachmentPoint); | 529 | // grp.UUID, grp.AttachmentPoint); |
526 | 530 | ||
527 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | 531 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); |
528 | 532 | ||
@@ -553,12 +557,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
553 | } | 557 | } |
554 | grp.HasGroupChanged = false; // Prevent it being saved over and over | 558 | grp.HasGroupChanged = false; // Prevent it being saved over and over |
555 | } | 559 | } |
556 | else | 560 | // else |
557 | { | 561 | // { |
558 | m_log.DebugFormat( | 562 | // m_log.DebugFormat( |
559 | "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", | 563 | // "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", |
560 | grp.UUID, grp.AttachmentPoint); | 564 | // grp.UUID, grp.AttachmentPoint); |
561 | } | 565 | // } |
562 | } | 566 | } |
563 | 567 | ||
564 | /// <summary> | 568 | /// <summary> |
@@ -576,9 +580,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
576 | private void AttachToAgent( | 580 | private void AttachToAgent( |
577 | IScenePresence sp, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | 581 | IScenePresence sp, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) |
578 | { | 582 | { |
579 | // m_log.DebugFormat( | 583 | // m_log.DebugFormat( |
580 | // "[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", | 584 | // "[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", |
581 | // so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); | 585 | // so.Name, sp.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); |
582 | 586 | ||
583 | so.DetachFromBackup(); | 587 | so.DetachFromBackup(); |
584 | 588 | ||
@@ -627,6 +631,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
627 | /// <returns>The user inventory item created that holds the attachment.</returns> | 631 | /// <returns>The user inventory item created that holds the attachment.</returns> |
628 | private InventoryItemBase AddSceneObjectAsNewAttachmentInInv(IScenePresence sp, SceneObjectGroup grp) | 632 | private InventoryItemBase AddSceneObjectAsNewAttachmentInInv(IScenePresence sp, SceneObjectGroup grp) |
629 | { | 633 | { |
634 | if (m_invAccessModule == null) | ||
635 | return null; | ||
636 | |||
630 | // m_log.DebugFormat( | 637 | // m_log.DebugFormat( |
631 | // "[ATTACHMENTS MODULE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2}", | 638 | // "[ATTACHMENTS MODULE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2}", |
632 | // grp.Name, grp.LocalId, remoteClient.Name); | 639 | // grp.Name, grp.LocalId, remoteClient.Name); |
@@ -703,16 +710,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
703 | // sets itemID so client can show item as 'attached' in inventory | 710 | // sets itemID so client can show item as 'attached' in inventory |
704 | grp.FromItemID = item.ID; | 711 | grp.FromItemID = item.ID; |
705 | 712 | ||
706 | if (m_scene.AddInventoryItem(item)) | ||
707 | { | ||
708 | sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0); | ||
709 | } | ||
710 | else | ||
711 | { | ||
712 | if (m_dialogModule != null) | ||
713 | m_dialogModule.SendAlertToUser(sp.ControllingClient, "Operation failed"); | ||
714 | } | ||
715 | |||
716 | return item; | 713 | return item; |
717 | } | 714 | } |
718 | 715 | ||
@@ -761,76 +758,75 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
761 | protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( | 758 | protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( |
762 | IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc) | 759 | IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc) |
763 | { | 760 | { |
764 | IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); | 761 | if (m_invAccessModule == null) |
765 | if (invAccess != null) | 762 | return null; |
763 | |||
764 | lock (sp.AttachmentsSyncLock) | ||
766 | { | 765 | { |
767 | lock (sp.AttachmentsSyncLock) | 766 | SceneObjectGroup objatt; |
767 | |||
768 | if (itemID != UUID.Zero) | ||
769 | objatt = m_invAccessModule.RezObject(sp.ControllingClient, | ||
770 | itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, | ||
771 | false, false, sp.UUID, true); | ||
772 | else | ||
773 | objatt = m_invAccessModule.RezObject(sp.ControllingClient, | ||
774 | null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, | ||
775 | false, false, sp.UUID, true); | ||
776 | |||
777 | // m_log.DebugFormat( | ||
778 | // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", | ||
779 | // objatt.Name, remoteClient.Name, AttachmentPt); | ||
780 | |||
781 | if (objatt != null) | ||
768 | { | 782 | { |
769 | SceneObjectGroup objatt; | 783 | // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. |
770 | 784 | objatt.HasGroupChanged = false; | |
771 | if (itemID != UUID.Zero) | 785 | bool tainted = false; |
772 | objatt = invAccess.RezObject(sp.ControllingClient, | 786 | if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) |
773 | itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, | 787 | tainted = true; |
774 | false, false, sp.UUID, true); | ||
775 | else | ||
776 | objatt = invAccess.RezObject(sp.ControllingClient, | ||
777 | null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, | ||
778 | false, false, sp.UUID, true); | ||
779 | |||
780 | // m_log.DebugFormat( | ||
781 | // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", | ||
782 | // objatt.Name, remoteClient.Name, AttachmentPt); | ||
783 | |||
784 | if (objatt != null) | ||
785 | { | ||
786 | // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. | ||
787 | objatt.HasGroupChanged = false; | ||
788 | bool tainted = false; | ||
789 | if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) | ||
790 | tainted = true; | ||
791 | |||
792 | // This will throw if the attachment fails | ||
793 | try | ||
794 | { | ||
795 | AttachObject(sp, objatt, attachmentPt, false); | ||
796 | } | ||
797 | catch (Exception e) | ||
798 | { | ||
799 | m_log.ErrorFormat( | ||
800 | "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", | ||
801 | objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); | ||
802 | |||
803 | // Make sure the object doesn't stick around and bail | ||
804 | sp.RemoveAttachment(objatt); | ||
805 | m_scene.DeleteSceneObject(objatt, false); | ||
806 | return null; | ||
807 | } | ||
808 | |||
809 | if (tainted) | ||
810 | objatt.HasGroupChanged = true; | ||
811 | |||
812 | if (doc != null) | ||
813 | { | ||
814 | objatt.LoadScriptState(doc); | ||
815 | objatt.ResetOwnerChangeFlag(); | ||
816 | } | ||
817 | |||
818 | // Fire after attach, so we don't get messy perms dialogs | ||
819 | // 4 == AttachedRez | ||
820 | objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); | ||
821 | objatt.ResumeScripts(); | ||
822 | |||
823 | // Do this last so that event listeners have access to all the effects of the attachment | ||
824 | m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID); | ||
825 | 788 | ||
826 | return objatt; | 789 | // This will throw if the attachment fails |
790 | try | ||
791 | { | ||
792 | AttachObject(sp, objatt, attachmentPt, false); | ||
827 | } | 793 | } |
828 | else | 794 | catch (Exception e) |
795 | { | ||
796 | m_log.ErrorFormat( | ||
797 | "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", | ||
798 | objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); | ||
799 | |||
800 | // Make sure the object doesn't stick around and bail | ||
801 | sp.RemoveAttachment(objatt); | ||
802 | m_scene.DeleteSceneObject(objatt, false); | ||
803 | return null; | ||
804 | } | ||
805 | |||
806 | if (doc != null) | ||
829 | { | 807 | { |
830 | m_log.WarnFormat( | 808 | objatt.LoadScriptState(doc); |
831 | "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", | 809 | objatt.ResetOwnerChangeFlag(); |
832 | itemID, sp.Name, attachmentPt); | ||
833 | } | 810 | } |
811 | |||
812 | if (tainted) | ||
813 | objatt.HasGroupChanged = true; | ||
814 | |||
815 | // Fire after attach, so we don't get messy perms dialogs | ||
816 | // 4 == AttachedRez | ||
817 | objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); | ||
818 | objatt.ResumeScripts(); | ||
819 | |||
820 | // Do this last so that event listeners have access to all the effects of the attachment | ||
821 | m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID); | ||
822 | |||
823 | return objatt; | ||
824 | } | ||
825 | else | ||
826 | { | ||
827 | m_log.WarnFormat( | ||
828 | "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", | ||
829 | itemID, sp.Name, attachmentPt); | ||
834 | } | 830 | } |
835 | } | 831 | } |
836 | 832 | ||
@@ -846,9 +842,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
846 | /// <param name="att"></param> | 842 | /// <param name="att"></param> |
847 | private void ShowAttachInUserInventory(IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) | 843 | private void ShowAttachInUserInventory(IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) |
848 | { | 844 | { |
849 | // m_log.DebugFormat( | 845 | // m_log.DebugFormat( |
850 | // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", | 846 | // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", |
851 | // att.Name, sp.Name, AttachmentPt, itemID); | 847 | // att.Name, sp.Name, AttachmentPt, itemID); |
852 | 848 | ||
853 | if (UUID.Zero == itemID) | 849 | if (UUID.Zero == itemID) |
854 | { | 850 | { |
@@ -911,9 +907,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
911 | 907 | ||
912 | private void Client_OnObjectAttach(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) | 908 | private void Client_OnObjectAttach(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) |
913 | { | 909 | { |
914 | // m_log.DebugFormat( | 910 | // m_log.DebugFormat( |
915 | // "[ATTACHMENTS MODULE]: Attaching object local id {0} to {1} point {2} from ground (silent = {3})", | 911 | // "[ATTACHMENTS MODULE]: Attaching object local id {0} to {1} point {2} from ground (silent = {3})", |
916 | // objectLocalID, remoteClient.Name, AttachmentPt, silent); | 912 | // objectLocalID, remoteClient.Name, AttachmentPt, silent); |
917 | 913 | ||
918 | if (!Enabled) | 914 | if (!Enabled) |
919 | return; | 915 | return; |
@@ -949,13 +945,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
949 | // Calls attach with a Zero position | 945 | // Calls attach with a Zero position |
950 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) | 946 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) |
951 | { | 947 | { |
952 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); | 948 | // m_log.Debug( |
949 | // "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | ||
950 | // + ", AttachmentPoint: " + AttachmentPt); | ||
953 | 951 | ||
954 | // Save avatar attachment information | 952 | // Save avatar attachment information |
955 | m_log.Debug( | 953 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); |
956 | "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | ||
957 | + ", AttachmentPoint: " + AttachmentPt); | ||
958 | |||
959 | } | 954 | } |
960 | } | 955 | } |
961 | catch (Exception e) | 956 | catch (Exception e) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index bfe5e4a..5e89eec 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
72 | config.AddConfig("Modules"); | 72 | config.AddConfig("Modules"); |
73 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | 73 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); |
74 | 74 | ||
75 | scene = SceneHelpers.SetupScene(); | 75 | scene = new SceneHelpers().SetupScene(); |
76 | m_attMod = new AttachmentsModule(); | 76 | m_attMod = new AttachmentsModule(); |
77 | SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); | 77 | SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); |
78 | } | 78 | } |
@@ -99,12 +99,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
99 | public void TestAddAttachmentFromGround() | 99 | public void TestAddAttachmentFromGround() |
100 | { | 100 | { |
101 | TestHelpers.InMethod(); | 101 | TestHelpers.InMethod(); |
102 | // log4net.Config.XmlConfigurator.Configure(); | 102 | // TestHelpers.EnableLogging(); |
103 | 103 | ||
104 | AddPresence(); | 104 | AddPresence(); |
105 | string attName = "att"; | 105 | string attName = "att"; |
106 | 106 | ||
107 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup; | 107 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, m_presence.UUID).ParentGroup; |
108 | 108 | ||
109 | m_attMod.AttachObject(m_presence, so, (uint)AttachmentPoint.Chest, false); | 109 | m_attMod.AttachObject(m_presence, so, (uint)AttachmentPoint.Chest, false); |
110 | 110 | ||
@@ -123,6 +123,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
123 | Assert.That( | 123 | Assert.That( |
124 | m_presence.Appearance.GetAttachpoint(attSo.FromItemID), | 124 | m_presence.Appearance.GetAttachpoint(attSo.FromItemID), |
125 | Is.EqualTo((int)AttachmentPoint.Chest)); | 125 | Is.EqualTo((int)AttachmentPoint.Chest)); |
126 | |||
127 | InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID)); | ||
128 | Assert.That(attachmentItem, Is.Not.Null); | ||
129 | Assert.That(attachmentItem.Name, Is.EqualTo(attName)); | ||
130 | |||
131 | InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(m_presence.UUID, AssetType.Object); | ||
132 | Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID)); | ||
133 | |||
134 | // TestHelpers.DisableLogging(); | ||
126 | } | 135 | } |
127 | 136 | ||
128 | [Test] | 137 | [Test] |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 2bebd30..875c073 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -158,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
158 | // Process the baked texture array | 158 | // Process the baked texture array |
159 | if (textureEntry != null) | 159 | if (textureEntry != null) |
160 | { | 160 | { |
161 | m_log.InfoFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); | 161 | // m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); |
162 | 162 | ||
163 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); | 163 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); |
164 | 164 | ||
@@ -208,7 +208,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
208 | ScenePresence sp = m_scene.GetScenePresence(agentId); | 208 | ScenePresence sp = m_scene.GetScenePresence(agentId); |
209 | if (sp == null) | 209 | if (sp == null) |
210 | { | 210 | { |
211 | m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); | 211 | // This is expected if the user has gone away. |
212 | // m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); | ||
212 | return false; | 213 | return false; |
213 | } | 214 | } |
214 | 215 | ||
@@ -248,10 +249,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
248 | 249 | ||
249 | if (bakedTextureFace == null) | 250 | if (bakedTextureFace == null) |
250 | { | 251 | { |
251 | m_log.WarnFormat( | 252 | // This can happen legitimately, since some baked textures might not exist |
252 | "[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently", | 253 | //m_log.WarnFormat( |
253 | bakeType, sp.Name, m_scene.RegionInfo.RegionName); | 254 | // "[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently", |
254 | 255 | // bakeType, sp.Name, m_scene.RegionInfo.RegionName); | |
255 | continue; | 256 | continue; |
256 | } | 257 | } |
257 | 258 | ||
@@ -337,7 +338,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
337 | return false; | 338 | return false; |
338 | } | 339 | } |
339 | 340 | ||
340 | m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); | 341 | // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); |
341 | 342 | ||
342 | // If we only found default textures, then the appearance is not cached | 343 | // If we only found default textures, then the appearance is not cached |
343 | return (defonly ? false : true); | 344 | return (defonly ? false : true); |
@@ -370,11 +371,21 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
370 | if (missingTexturesOnly) | 371 | if (missingTexturesOnly) |
371 | { | 372 | { |
372 | if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) | 373 | if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) |
374 | { | ||
373 | continue; | 375 | continue; |
376 | } | ||
374 | else | 377 | else |
378 | { | ||
379 | // On inter-simulator teleports, this occurs if baked textures are not being stored by the | ||
380 | // grid asset service (which means that they are not available to the new region and so have | ||
381 | // to be re-requested from the client). | ||
382 | // | ||
383 | // The only available core OpenSimulator behaviour right now | ||
384 | // is not to store these textures, temporarily or otherwise. | ||
375 | m_log.DebugFormat( | 385 | m_log.DebugFormat( |
376 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | 386 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", |
377 | face.TextureID, idx, sp.Name); | 387 | face.TextureID, idx, sp.Name); |
388 | } | ||
378 | } | 389 | } |
379 | else | 390 | else |
380 | { | 391 | { |
@@ -417,7 +428,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
417 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); | 428 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); |
418 | 429 | ||
419 | int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); | 430 | int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); |
420 | bakedTextures[bakeType] = faceTextures[ftIndex]; | 431 | Primitive.TextureEntryFace texture = faceTextures[ftIndex]; // this will be null if there's no such baked texture |
432 | bakedTextures[bakeType] = texture; | ||
421 | } | 433 | } |
422 | 434 | ||
423 | return bakedTextures; | 435 | return bakedTextures; |
@@ -482,7 +494,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
482 | ScenePresence sp = m_scene.GetScenePresence(agentid); | 494 | ScenePresence sp = m_scene.GetScenePresence(agentid); |
483 | if (sp == null) | 495 | if (sp == null) |
484 | { | 496 | { |
485 | m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); | 497 | // This is expected if the user has gone away. |
498 | // m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); | ||
486 | return; | 499 | return; |
487 | } | 500 | } |
488 | 501 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index 11a0a86..848b3bf 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs | |||
@@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
53 | UUID userId = TestHelpers.ParseTail(0x1); | 53 | UUID userId = TestHelpers.ParseTail(0x1); |
54 | 54 | ||
55 | AvatarFactoryModule afm = new AvatarFactoryModule(); | 55 | AvatarFactoryModule afm = new AvatarFactoryModule(); |
56 | TestScene scene = SceneHelpers.SetupScene(); | 56 | TestScene scene = new SceneHelpers().SetupScene(); |
57 | SceneHelpers.SetupSceneModules(scene, afm); | 57 | SceneHelpers.SetupSceneModules(scene, afm); |
58 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); | 58 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); |
59 | 59 | ||
@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
81 | CoreAssetCache assetCache = new CoreAssetCache(); | 81 | CoreAssetCache assetCache = new CoreAssetCache(); |
82 | 82 | ||
83 | AvatarFactoryModule afm = new AvatarFactoryModule(); | 83 | AvatarFactoryModule afm = new AvatarFactoryModule(); |
84 | TestScene scene = SceneHelpers.SetupScene(assetCache); | 84 | TestScene scene = new SceneHelpers(assetCache).SetupScene(); |
85 | SceneHelpers.SetupSceneModules(scene, afm); | 85 | SceneHelpers.SetupSceneModules(scene, afm); |
86 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); | 86 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); |
87 | 87 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 4d8fb90..6ffc7e6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -197,6 +197,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
197 | string fromName = c.From; | 197 | string fromName = c.From; |
198 | string fromNamePrefix = ""; | 198 | string fromNamePrefix = ""; |
199 | UUID fromID = UUID.Zero; | 199 | UUID fromID = UUID.Zero; |
200 | UUID targetID = c.TargetUUID; | ||
200 | string message = c.Message; | 201 | string message = c.Message; |
201 | IScene scene = c.Scene; | 202 | IScene scene = c.Scene; |
202 | Vector3 fromPos = c.Position; | 203 | Vector3 fromPos = c.Position; |
@@ -235,17 +236,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
235 | message = message.Substring(0, 1000); | 236 | message = message.Substring(0, 1000); |
236 | 237 | ||
237 | // m_log.DebugFormat( | 238 | // m_log.DebugFormat( |
238 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", | 239 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", |
239 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); | 240 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); |
240 | 241 | ||
241 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 242 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
242 | 243 | ||
243 | foreach (Scene s in m_scenes) | 244 | foreach (Scene s in m_scenes) |
244 | { | 245 | { |
245 | // This should use ForEachClient, but clients don't have a position. | 246 | if (targetID == UUID.Zero) |
246 | // If camera is moved into client, then camera position can be used | 247 | { |
247 | s.ForEachRootScenePresence( | 248 | // This should use ForEachClient, but clients don't have a position. |
248 | delegate(ScenePresence presence) | 249 | // If camera is moved into client, then camera position can be used |
250 | s.ForEachRootScenePresence( | ||
251 | delegate(ScenePresence presence) | ||
252 | { | ||
253 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, false)) | ||
254 | receiverIDs.Add(presence.UUID); | ||
255 | } | ||
256 | ); | ||
257 | } | ||
258 | else | ||
259 | { | ||
260 | // This is a send to a specific client eg from llRegionSayTo | ||
261 | // no need to check distance etc, jand send is as say | ||
262 | ScenePresence presence = s.GetScenePresence(targetID); | ||
263 | if (presence != null && !presence.IsChildAgent) | ||
249 | { | 264 | { |
250 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); | 265 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); |
251 | if (Presencecheck != null) | 266 | if (Presencecheck != null) |
@@ -256,15 +271,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
256 | // objects on a parcel with access restrictions | 271 | // objects on a parcel with access restrictions |
257 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) | 272 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) |
258 | { | 273 | { |
259 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType)) | 274 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType, false)) |
260 | receiverIDs.Add(presence.UUID); | 275 | receiverIDs.Add(presence.UUID); |
261 | } | 276 | } |
262 | } | 277 | } |
263 | |||
264 | } | 278 | } |
265 | ); | 279 | } |
266 | } | 280 | } |
267 | 281 | ||
268 | (scene as Scene).EventManager.TriggerOnChatToClients( | 282 | (scene as Scene).EventManager.TriggerOnChatToClients( |
269 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); | 283 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); |
270 | } | 284 | } |
@@ -344,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
344 | /// precondition</returns> | 358 | /// precondition</returns> |
345 | protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, | 359 | protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, |
346 | UUID fromAgentID, string fromName, ChatTypeEnum type, | 360 | UUID fromAgentID, string fromName, ChatTypeEnum type, |
347 | string message, ChatSourceType src) | 361 | string message, ChatSourceType src, bool ignoreDistance) |
348 | { | 362 | { |
349 | // don't send stuff to child agents | 363 | // don't send stuff to child agents |
350 | if (presence.IsChildAgent) return false; | 364 | if (presence.IsChildAgent) return false; |
@@ -355,12 +369,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
355 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | 369 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
356 | 370 | ||
357 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); | 371 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); |
358 | 372 | ||
359 | if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || | 373 | if (!ignoreDistance) |
360 | type == ChatTypeEnum.Say && dis > m_saydistance || | ||
361 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | ||
362 | { | 374 | { |
363 | return false; | 375 | if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || |
376 | type == ChatTypeEnum.Say && dis > m_saydistance || | ||
377 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | ||
378 | { | ||
379 | return false; | ||
380 | } | ||
364 | } | 381 | } |
365 | 382 | ||
366 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView | 383 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView |
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 0babeb5..3a91465 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs | |||
@@ -96,6 +96,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule | |||
96 | ScenePresence killingAvatar = null; | 96 | ScenePresence killingAvatar = null; |
97 | // string killingAvatarMessage; | 97 | // string killingAvatarMessage; |
98 | 98 | ||
99 | // check to see if it is an NPC and just remove it | ||
100 | INPCModule NPCmodule = deadAvatar.Scene.RequestModuleInterface<INPCModule>(); | ||
101 | if (NPCmodule != null && NPCmodule.DeleteNPC(deadAvatar.UUID, deadAvatar.Scene)) | ||
102 | { | ||
103 | return; | ||
104 | } | ||
105 | |||
99 | if (killerObjectLocalID == 0) | 106 | if (killerObjectLocalID == 0) |
100 | deadAvatarMessage = "You committed suicide!"; | 107 | deadAvatarMessage = "You committed suicide!"; |
101 | else | 108 | else |
@@ -145,7 +152,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule | |||
145 | catch (InvalidOperationException) | 152 | catch (InvalidOperationException) |
146 | { } | 153 | { } |
147 | 154 | ||
148 | deadAvatar.Health = 100; | 155 | deadAvatar.setHealthWithUpdate(100.0f); |
149 | deadAvatar.Scene.TeleportClientHome(deadAvatar.UUID, deadAvatar.ControllingClient); | 156 | deadAvatar.Scene.TeleportClientHome(deadAvatar.UUID, deadAvatar.ControllingClient); |
150 | } | 157 | } |
151 | 158 | ||
@@ -154,14 +161,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule | |||
154 | try | 161 | try |
155 | { | 162 | { |
156 | ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 163 | ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); |
157 | 164 | if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0 | |
158 | if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) | 165 | || avatar.Scene.RegionInfo.RegionSettings.AllowDamage) |
159 | { | 166 | { |
160 | avatar.Invulnerable = false; | 167 | avatar.Invulnerable = false; |
161 | } | 168 | } |
162 | else | 169 | else |
163 | { | 170 | { |
164 | avatar.Invulnerable = true; | 171 | avatar.Invulnerable = true; |
172 | if (avatar.Health < 100.0f) | ||
173 | { | ||
174 | avatar.setHealthWithUpdate(100.0f); | ||
175 | } | ||
165 | } | 176 | } |
166 | } | 177 | } |
167 | catch (Exception) | 178 | catch (Exception) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Commands/UserCommandsModule.cs b/OpenSim/Region/CoreModules/Avatar/Commands/UserCommandsModule.cs new file mode 100644 index 0000000..4bcd2ac --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Commands/UserCommandsModule.cs | |||
@@ -0,0 +1,189 @@ | |||
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.Text.RegularExpressions; | ||
33 | using log4net; | ||
34 | using Mono.Addins; | ||
35 | using NDesk.Options; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Console; | ||
40 | using OpenSim.Framework.Statistics; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | |||
44 | namespace OpenSim.Region.CoreModules.Avatars.Commands | ||
45 | { | ||
46 | /// <summary> | ||
47 | /// A module that holds commands for manipulating objects in the scene. | ||
48 | /// </summary> | ||
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UserCommandsModule")] | ||
50 | public class UserCommandsModule : ISharedRegionModule | ||
51 | { | ||
52 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
53 | |||
54 | public const string TeleportUserCommandSyntax = "teleport user <first-name> <last-name> <destination>"; | ||
55 | |||
56 | public static Regex InterRegionDestinationRegex | ||
57 | = new Regex(@"^(?<regionName>.+)/(?<x>\d+)/(?<y>\d+)/(?<z>\d+)$", RegexOptions.Compiled); | ||
58 | |||
59 | public static Regex WithinRegionDestinationRegex | ||
60 | = new Regex(@"^(?<x>\d+)/(?<y>\d+)/(?<z>\d+)$", RegexOptions.Compiled); | ||
61 | |||
62 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); | ||
63 | |||
64 | public string Name { get { return "User Commands Module"; } } | ||
65 | |||
66 | public Type ReplaceableInterface { get { return null; } } | ||
67 | |||
68 | public void Initialise(IConfigSource source) | ||
69 | { | ||
70 | // m_log.DebugFormat("[USER COMMANDS MODULE]: INITIALIZED MODULE"); | ||
71 | } | ||
72 | |||
73 | public void PostInitialise() | ||
74 | { | ||
75 | // m_log.DebugFormat("[USER COMMANDS MODULE]: POST INITIALIZED MODULE"); | ||
76 | } | ||
77 | |||
78 | public void Close() | ||
79 | { | ||
80 | // m_log.DebugFormat("[USER COMMANDS MODULE]: CLOSED MODULE"); | ||
81 | } | ||
82 | |||
83 | public void AddRegion(Scene scene) | ||
84 | { | ||
85 | // m_log.DebugFormat("[USER COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); | ||
86 | |||
87 | lock (m_scenes) | ||
88 | m_scenes[scene.RegionInfo.RegionID] = scene; | ||
89 | |||
90 | scene.AddCommand( | ||
91 | "Users", | ||
92 | this, | ||
93 | "teleport user", | ||
94 | TeleportUserCommandSyntax, | ||
95 | "Teleport a user in this simulator to the given destination", | ||
96 | "<destination> is in format [<region-name>]/<x>/<y>/<z>, e.g. regionone/20/30/40 or just 20/30/40 to teleport within same region." | ||
97 | + "\nIf the region contains a space then the whole destination must be in quotes, e.g. \"region one/20/30/40\"", | ||
98 | HandleTeleportUser); | ||
99 | } | ||
100 | |||
101 | public void RemoveRegion(Scene scene) | ||
102 | { | ||
103 | // m_log.DebugFormat("[USER COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | ||
104 | |||
105 | lock (m_scenes) | ||
106 | m_scenes.Remove(scene.RegionInfo.RegionID); | ||
107 | } | ||
108 | |||
109 | public void RegionLoaded(Scene scene) | ||
110 | { | ||
111 | // m_log.DebugFormat("[USER COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); | ||
112 | } | ||
113 | |||
114 | private ScenePresence GetUser(string firstName, string lastName) | ||
115 | { | ||
116 | ScenePresence userFound = null; | ||
117 | |||
118 | lock (m_scenes) | ||
119 | { | ||
120 | foreach (Scene scene in m_scenes.Values) | ||
121 | { | ||
122 | ScenePresence user = scene.GetScenePresence(firstName, lastName); | ||
123 | if (user != null && !user.IsChildAgent) | ||
124 | { | ||
125 | userFound = user; | ||
126 | break; | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | |||
131 | return userFound; | ||
132 | } | ||
133 | |||
134 | private void HandleTeleportUser(string module, string[] cmd) | ||
135 | { | ||
136 | if (cmd.Length < 5) | ||
137 | { | ||
138 | MainConsole.Instance.OutputFormat("Usage: " + TeleportUserCommandSyntax); | ||
139 | return; | ||
140 | } | ||
141 | |||
142 | string firstName = cmd[2]; | ||
143 | string lastName = cmd[3]; | ||
144 | string rawDestination = cmd[4]; | ||
145 | |||
146 | ScenePresence user = GetUser(firstName, lastName); | ||
147 | |||
148 | if (user == null) | ||
149 | { | ||
150 | MainConsole.Instance.OutputFormat("No user found with name {0} {1}", firstName, lastName); | ||
151 | return; | ||
152 | } | ||
153 | |||
154 | // MainConsole.Instance.OutputFormat("rawDestination [{0}]", rawDestination); | ||
155 | |||
156 | Match m = WithinRegionDestinationRegex.Match(rawDestination); | ||
157 | |||
158 | if (!m.Success) | ||
159 | { | ||
160 | m = InterRegionDestinationRegex.Match(rawDestination); | ||
161 | |||
162 | if (!m.Success) | ||
163 | { | ||
164 | MainConsole.Instance.OutputFormat("Invalid destination {0}", rawDestination); | ||
165 | return; | ||
166 | } | ||
167 | } | ||
168 | |||
169 | string regionName | ||
170 | = m.Groups["regionName"].Success ? m.Groups["regionName"].Value : user.Scene.RegionInfo.RegionName; | ||
171 | |||
172 | MainConsole.Instance.OutputFormat( | ||
173 | "Teleporting {0} to {1},{2},{3} in {4}", | ||
174 | user.Name, | ||
175 | m.Groups["x"], m.Groups["y"], m.Groups["z"], | ||
176 | regionName); | ||
177 | |||
178 | user.Scene.RequestTeleportLocation( | ||
179 | user.ControllingClient, | ||
180 | regionName, | ||
181 | new Vector3( | ||
182 | float.Parse(m.Groups["x"].Value), | ||
183 | float.Parse(m.Groups["y"].Value), | ||
184 | float.Parse(m.Groups["z"].Value)), | ||
185 | user.Lookat, | ||
186 | (uint)TeleportFlags.ViaLocation); | ||
187 | } | ||
188 | } | ||
189 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index f64c161..24ec435 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -162,7 +162,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | protected void InitModule(IConfigSource config) | 165 | protected virtual void InitModule(IConfigSource config) |
166 | { | 166 | { |
167 | IConfig friendsConfig = config.Configs["Friends"]; | 167 | IConfig friendsConfig = config.Configs["Friends"]; |
168 | if (friendsConfig != null) | 168 | if (friendsConfig != null) |
@@ -449,29 +449,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
449 | /// </summary> | 449 | /// </summary> |
450 | public IClientAPI LocateClientObject(UUID agentID) | 450 | public IClientAPI LocateClientObject(UUID agentID) |
451 | { | 451 | { |
452 | Scene scene = GetClientScene(agentID); | ||
453 | if (scene != null) | ||
454 | { | ||
455 | ScenePresence presence = scene.GetScenePresence(agentID); | ||
456 | if (presence != null) | ||
457 | return presence.ControllingClient; | ||
458 | } | ||
459 | |||
460 | return null; | ||
461 | } | ||
462 | |||
463 | /// <summary> | ||
464 | /// Find the scene for an agent | ||
465 | /// </summary> | ||
466 | private Scene GetClientScene(UUID agentId) | ||
467 | { | ||
468 | lock (m_Scenes) | 452 | lock (m_Scenes) |
469 | { | 453 | { |
470 | foreach (Scene scene in m_Scenes) | 454 | foreach (Scene scene in m_Scenes) |
471 | { | 455 | { |
472 | ScenePresence presence = scene.GetScenePresence(agentId); | 456 | ScenePresence presence = scene.GetScenePresence(agentID); |
473 | if (presence != null && !presence.IsChildAgent) | 457 | if (presence != null && !presence.IsChildAgent) |
474 | return scene; | 458 | return presence.ControllingClient; |
475 | } | 459 | } |
476 | } | 460 | } |
477 | 461 | ||
@@ -498,7 +482,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
498 | Util.FireAndForget( | 482 | Util.FireAndForget( |
499 | delegate | 483 | delegate |
500 | { | 484 | { |
501 | m_log.DebugFormat("[FRIENDS MODULE]: Notifying {0} friends", friendList.Count); | 485 | m_log.DebugFormat( |
486 | "[FRIENDS MODULE]: Notifying {0} friends of {1} of online status {2}", | ||
487 | friendList.Count, agentID, online); | ||
488 | |||
502 | // Notify about this user status | 489 | // Notify about this user status |
503 | StatusNotify(friendList, agentID, online); | 490 | StatusNotify(friendList, agentID, online); |
504 | } | 491 | } |
@@ -515,7 +502,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
515 | { | 502 | { |
516 | // Try local | 503 | // Try local |
517 | if (LocalStatusNotification(userID, friendID, online)) | 504 | if (LocalStatusNotification(userID, friendID, online)) |
518 | return; | 505 | continue; |
519 | 506 | ||
520 | // The friend is not here [as root]. Let's forward. | 507 | // The friend is not here [as root]. Let's forward. |
521 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); | 508 | PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); |
@@ -523,11 +510,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
523 | { | 510 | { |
524 | PresenceInfo friendSession = null; | 511 | PresenceInfo friendSession = null; |
525 | foreach (PresenceInfo pinfo in friendSessions) | 512 | foreach (PresenceInfo pinfo in friendSessions) |
513 | { | ||
526 | if (pinfo.RegionID != UUID.Zero) // let's guard against sessions-gone-bad | 514 | if (pinfo.RegionID != UUID.Zero) // let's guard against sessions-gone-bad |
527 | { | 515 | { |
528 | friendSession = pinfo; | 516 | friendSession = pinfo; |
529 | break; | 517 | break; |
530 | } | 518 | } |
519 | } | ||
531 | 520 | ||
532 | if (friendSession != null) | 521 | if (friendSession != null) |
533 | { | 522 | { |
@@ -546,7 +535,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
546 | } | 535 | } |
547 | } | 536 | } |
548 | 537 | ||
549 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) | 538 | protected virtual void OnInstantMessage(IClientAPI client, GridInstantMessage im) |
550 | { | 539 | { |
551 | if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) | 540 | if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) |
552 | { | 541 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 9a6d277..06f27e2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs | |||
@@ -50,6 +50,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
50 | { | 50 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
53 | private int m_levelHGFriends = 0; | ||
54 | |||
53 | IUserManagement m_uMan; | 55 | IUserManagement m_uMan; |
54 | public IUserManagement UserManagementModule | 56 | public IUserManagement UserManagementModule |
55 | { | 57 | { |
@@ -87,6 +89,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
87 | m_StatusNotifier = new HGStatusNotifier(this); | 89 | m_StatusNotifier = new HGStatusNotifier(this); |
88 | } | 90 | } |
89 | 91 | ||
92 | protected override void InitModule(IConfigSource config) | ||
93 | { | ||
94 | base.InitModule(config); | ||
95 | |||
96 | // Additionally to the base method | ||
97 | IConfig friendsConfig = config.Configs["HGFriendsModule"]; | ||
98 | if (friendsConfig != null) | ||
99 | { | ||
100 | m_levelHGFriends = friendsConfig.GetInt("LevelHGFriends", 0); | ||
101 | |||
102 | // TODO: read in all config variables pertaining to | ||
103 | // HG friendship permissions | ||
104 | } | ||
105 | } | ||
106 | |||
90 | #endregion | 107 | #endregion |
91 | 108 | ||
92 | #region IFriendsSimConnector | 109 | #region IFriendsSimConnector |
@@ -105,6 +122,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
105 | 122 | ||
106 | #endregion | 123 | #endregion |
107 | 124 | ||
125 | protected override void OnInstantMessage(IClientAPI client, GridInstantMessage im) | ||
126 | { | ||
127 | if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) | ||
128 | { | ||
129 | // we got a friendship offer | ||
130 | UUID principalID = new UUID(im.fromAgentID); | ||
131 | UUID friendID = new UUID(im.toAgentID); | ||
132 | |||
133 | // Check if friendID is foreigner and if principalID has the permission | ||
134 | // to request friendships with foreigners. If not, return immediately. | ||
135 | if (!UserManagementModule.IsLocalGridUser(friendID)) | ||
136 | { | ||
137 | ScenePresence avatar = null; | ||
138 | ((Scene)client.Scene).TryGetScenePresence(principalID, out avatar); | ||
139 | |||
140 | if (avatar == null) | ||
141 | return; | ||
142 | |||
143 | if (avatar.UserLevel < m_levelHGFriends) | ||
144 | { | ||
145 | client.SendAgentAlertMessage("Unable to send friendship invitation to foreigner. Insufficient permissions.", false); | ||
146 | return; | ||
147 | } | ||
148 | } | ||
149 | } | ||
150 | |||
151 | base.OnInstantMessage(client, im); | ||
152 | } | ||
153 | |||
108 | protected override void OnApproveFriendRequest(IClientAPI client, UUID friendID, List<UUID> callingCardFolders) | 154 | protected override void OnApproveFriendRequest(IClientAPI client, UUID friendID, List<UUID> callingCardFolders) |
109 | { | 155 | { |
110 | // Update the local cache. Yes, we need to do it right here | 156 | // Update the local cache. Yes, we need to do it right here |
@@ -369,12 +415,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
369 | 415 | ||
370 | protected override void StoreBackwards(UUID friendID, UUID agentID) | 416 | protected override void StoreBackwards(UUID friendID, UUID agentID) |
371 | { | 417 | { |
372 | Boolean agentIsLocal = true; | 418 | bool agentIsLocal = true; |
373 | Boolean friendIsLocal = true; | 419 | // bool friendIsLocal = true; |
420 | |||
374 | if (UserManagementModule != null) | 421 | if (UserManagementModule != null) |
375 | { | 422 | { |
376 | agentIsLocal = UserManagementModule.IsLocalGridUser(agentID); | 423 | agentIsLocal = UserManagementModule.IsLocalGridUser(agentID); |
377 | friendIsLocal = UserManagementModule.IsLocalGridUser(friendID); | 424 | // friendIsLocal = UserManagementModule.IsLocalGridUser(friendID); |
378 | } | 425 | } |
379 | 426 | ||
380 | // Is the requester a local user? | 427 | // Is the requester a local user? |
@@ -461,7 +508,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
461 | { | 508 | { |
462 | friendUUI = finfo.Friend; | 509 | friendUUI = finfo.Friend; |
463 | theFriendUUID = friendUUI; | 510 | theFriendUUID = friendUUI; |
464 | UUID utmp = UUID.Zero; String url = String.Empty; String first = String.Empty, last = String.Empty, tmp = String.Empty; | 511 | UUID utmp = UUID.Zero; |
512 | string url = String.Empty; | ||
513 | string first = String.Empty; | ||
514 | string last = String.Empty; | ||
515 | |||
465 | // If it's confirming the friendship, we already have the full UUI with the secret | 516 | // If it's confirming the friendship, we already have the full UUI with the secret |
466 | if (Util.ParseUniversalUserIdentifier(theFriendUUID, out utmp, out url, out first, out last, out secret)) | 517 | if (Util.ParseUniversalUserIdentifier(theFriendUUID, out utmp, out url, out first, out last, out secret)) |
467 | { | 518 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs index 45b4264..7a197f7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs | |||
@@ -78,7 +78,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests | |||
78 | config.AddConfig("FriendsService"); | 78 | config.AddConfig("FriendsService"); |
79 | config.Configs["FriendsService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); | 79 | config.Configs["FriendsService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); |
80 | 80 | ||
81 | m_scene = SceneHelpers.SetupScene(); | 81 | m_scene = new SceneHelpers().SetupScene(); |
82 | m_fm = new FriendsModule(); | 82 | m_fm = new FriendsModule(); |
83 | SceneHelpers.SetupSceneModules(m_scene, config, m_fm); | 83 | SceneHelpers.SetupSceneModules(m_scene, config, m_fm); |
84 | } | 84 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 8560c73..6587ead 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -39,6 +39,9 @@ using OpenSim.Framework.Serialization.External; | |||
39 | using OpenSim.Region.CoreModules.World.Archiver; | 39 | using OpenSim.Region.CoreModules.World.Archiver; |
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | using OpenSim.Services.Interfaces; | 41 | using OpenSim.Services.Interfaces; |
42 | using Ionic.Zlib; | ||
43 | using GZipStream = Ionic.Zlib.GZipStream; | ||
44 | using CompressionMode = Ionic.Zlib.CompressionMode; | ||
42 | 45 | ||
43 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | 46 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver |
44 | { | 47 | { |
@@ -91,7 +94,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
91 | /// Constructor | 94 | /// Constructor |
92 | /// </summary> | 95 | /// </summary> |
93 | public InventoryArchiveWriteRequest( | 96 | public InventoryArchiveWriteRequest( |
94 | Guid id, InventoryArchiverModule module, Scene scene, | 97 | Guid id, InventoryArchiverModule module, Scene scene, |
95 | UserAccount userInfo, string invPath, string savePath) | 98 | UserAccount userInfo, string invPath, string savePath) |
96 | : this( | 99 | : this( |
97 | id, | 100 | id, |
@@ -99,7 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
99 | scene, | 102 | scene, |
100 | userInfo, | 103 | userInfo, |
101 | invPath, | 104 | invPath, |
102 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)) | 105 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress, CompressionLevel.BestCompression)) |
103 | { | 106 | { |
104 | } | 107 | } |
105 | 108 | ||
@@ -107,7 +110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
107 | /// Constructor | 110 | /// Constructor |
108 | /// </summary> | 111 | /// </summary> |
109 | public InventoryArchiveWriteRequest( | 112 | public InventoryArchiveWriteRequest( |
110 | Guid id, InventoryArchiverModule module, Scene scene, | 113 | Guid id, InventoryArchiverModule module, Scene scene, |
111 | UserAccount userInfo, string invPath, Stream saveStream) | 114 | UserAccount userInfo, string invPath, Stream saveStream) |
112 | { | 115 | { |
113 | m_id = id; | 116 | m_id = id; |
@@ -125,7 +128,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
125 | { | 128 | { |
126 | Exception reportedException = null; | 129 | Exception reportedException = null; |
127 | bool succeeded = true; | 130 | bool succeeded = true; |
128 | 131 | ||
129 | try | 132 | try |
130 | { | 133 | { |
131 | m_archiveWriter.Close(); | 134 | m_archiveWriter.Close(); |
@@ -146,6 +149,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
146 | 149 | ||
147 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService) | 150 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService) |
148 | { | 151 | { |
152 | if (options.ContainsKey("exclude")) | ||
153 | { | ||
154 | if (((List<String>)options["exclude"]).Contains(inventoryItem.Name) || | ||
155 | ((List<String>)options["exclude"]).Contains(inventoryItem.ID.ToString())) | ||
156 | { | ||
157 | if (options.ContainsKey("verbose")) | ||
158 | { | ||
159 | m_log.InfoFormat( | ||
160 | "[INVENTORY ARCHIVER]: Skipping inventory item {0} {1} at {2}", | ||
161 | inventoryItem.Name, inventoryItem.ID, path); | ||
162 | } | ||
163 | return; | ||
164 | } | ||
165 | } | ||
166 | |||
149 | if (options.ContainsKey("verbose")) | 167 | if (options.ContainsKey("verbose")) |
150 | m_log.InfoFormat( | 168 | m_log.InfoFormat( |
151 | "[INVENTORY ARCHIVER]: Saving item {0} {1} with asset {2}", | 169 | "[INVENTORY ARCHIVER]: Saving item {0} {1} with asset {2}", |
@@ -175,9 +193,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
175 | /// <param name="options"></param> | 193 | /// <param name="options"></param> |
176 | /// <param name="userAccountService"></param> | 194 | /// <param name="userAccountService"></param> |
177 | protected void SaveInvFolder( | 195 | protected void SaveInvFolder( |
178 | InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, | 196 | InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, |
179 | Dictionary<string, object> options, IUserAccountService userAccountService) | 197 | Dictionary<string, object> options, IUserAccountService userAccountService) |
180 | { | 198 | { |
199 | if (options.ContainsKey("excludefolders")) | ||
200 | { | ||
201 | if (((List<String>)options["excludefolders"]).Contains(inventoryFolder.Name) || | ||
202 | ((List<String>)options["excludefolders"]).Contains(inventoryFolder.ID.ToString())) | ||
203 | { | ||
204 | if (options.ContainsKey("verbose")) | ||
205 | { | ||
206 | m_log.InfoFormat( | ||
207 | "[INVENTORY ARCHIVER]: Skipping folder {0} at {1}", | ||
208 | inventoryFolder.Name, path); | ||
209 | } | ||
210 | return; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | if (options.ContainsKey("verbose")) | ||
215 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Saving folder {0}", inventoryFolder.Name); | ||
216 | |||
181 | if (saveThisFolderItself) | 217 | if (saveThisFolderItself) |
182 | { | 218 | { |
183 | path += CreateArchiveFolderName(inventoryFolder); | 219 | path += CreateArchiveFolderName(inventoryFolder); |
@@ -186,7 +222,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
186 | m_archiveWriter.WriteDir(path); | 222 | m_archiveWriter.WriteDir(path); |
187 | } | 223 | } |
188 | 224 | ||
189 | InventoryCollection contents | 225 | InventoryCollection contents |
190 | = m_scene.InventoryService.GetFolderContent(inventoryFolder.Owner, inventoryFolder.ID); | 226 | = m_scene.InventoryService.GetFolderContent(inventoryFolder.Owner, inventoryFolder.ID); |
191 | 227 | ||
192 | foreach (InventoryFolderBase childFolder in contents.Folders) | 228 | foreach (InventoryFolderBase childFolder in contents.Folders) |
@@ -213,16 +249,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
213 | InventoryFolderBase inventoryFolder = null; | 249 | InventoryFolderBase inventoryFolder = null; |
214 | InventoryItemBase inventoryItem = null; | 250 | InventoryItemBase inventoryItem = null; |
215 | InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID); | 251 | InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID); |
216 | 252 | ||
217 | bool saveFolderContentsOnly = false; | 253 | bool saveFolderContentsOnly = false; |
218 | 254 | ||
219 | // Eliminate double slashes and any leading / on the path. | 255 | // Eliminate double slashes and any leading / on the path. |
220 | string[] components | 256 | string[] components |
221 | = m_invPath.Split( | 257 | = m_invPath.Split( |
222 | new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); | 258 | new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); |
223 | 259 | ||
224 | int maxComponentIndex = components.Length - 1; | 260 | int maxComponentIndex = components.Length - 1; |
225 | 261 | ||
226 | // If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the | 262 | // If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the |
227 | // folder itself. This may get more sophisicated later on | 263 | // folder itself. This may get more sophisicated later on |
228 | if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD) | 264 | if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD) |
@@ -230,13 +266,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
230 | saveFolderContentsOnly = true; | 266 | saveFolderContentsOnly = true; |
231 | maxComponentIndex--; | 267 | maxComponentIndex--; |
232 | } | 268 | } |
233 | 269 | ||
234 | m_invPath = String.Empty; | 270 | m_invPath = String.Empty; |
235 | for (int i = 0; i <= maxComponentIndex; i++) | 271 | for (int i = 0; i <= maxComponentIndex; i++) |
236 | { | 272 | { |
237 | m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER; | 273 | m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER; |
238 | } | 274 | } |
239 | 275 | ||
240 | // Annoyingly Split actually returns the original string if the input string consists only of delimiters | 276 | // Annoyingly Split actually returns the original string if the input string consists only of delimiters |
241 | // Therefore if we still start with a / after the split, then we need the root folder | 277 | // Therefore if we still start with a / after the split, then we need the root folder |
242 | if (m_invPath.Length == 0) | 278 | if (m_invPath.Length == 0) |
@@ -246,25 +282,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
246 | else | 282 | else |
247 | { | 283 | { |
248 | m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); | 284 | m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); |
249 | List<InventoryFolderBase> candidateFolders | 285 | List<InventoryFolderBase> candidateFolders |
250 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath); | 286 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath); |
251 | if (candidateFolders.Count > 0) | 287 | if (candidateFolders.Count > 0) |
252 | inventoryFolder = candidateFolders[0]; | 288 | inventoryFolder = candidateFolders[0]; |
253 | } | 289 | } |
254 | 290 | ||
255 | // The path may point to an item instead | 291 | // The path may point to an item instead |
256 | if (inventoryFolder == null) | 292 | if (inventoryFolder == null) |
257 | inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath); | 293 | inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath); |
258 | 294 | ||
259 | if (null == inventoryFolder && null == inventoryItem) | 295 | if (null == inventoryFolder && null == inventoryItem) |
260 | { | 296 | { |
261 | // We couldn't find the path indicated | 297 | // We couldn't find the path indicated |
262 | string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); | 298 | string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); |
263 | Exception e = new InventoryArchiverException(errorMessage); | 299 | Exception e = new InventoryArchiverException(errorMessage); |
264 | m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e); | 300 | m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e); |
265 | throw e; | 301 | throw e; |
266 | } | 302 | } |
267 | 303 | ||
268 | m_archiveWriter = new TarArchiveWriter(m_saveStream); | 304 | m_archiveWriter = new TarArchiveWriter(m_saveStream); |
269 | 305 | ||
270 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Adding control file to archive."); | 306 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Adding control file to archive."); |
@@ -278,10 +314,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
278 | { | 314 | { |
279 | m_log.DebugFormat( | 315 | m_log.DebugFormat( |
280 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", | 316 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", |
281 | inventoryFolder.Name, | 317 | inventoryFolder.Name, |
282 | inventoryFolder.ID, | 318 | inventoryFolder.ID, |
283 | m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath); | 319 | m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath); |
284 | 320 | ||
285 | //recurse through all dirs getting dirs and files | 321 | //recurse through all dirs getting dirs and files |
286 | SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService); | 322 | SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService); |
287 | } | 323 | } |
@@ -290,10 +326,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
290 | m_log.DebugFormat( | 326 | m_log.DebugFormat( |
291 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", | 327 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", |
292 | inventoryItem.Name, inventoryItem.ID, m_invPath); | 328 | inventoryItem.Name, inventoryItem.ID, m_invPath); |
293 | 329 | ||
294 | SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService); | 330 | SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService); |
295 | } | 331 | } |
296 | 332 | ||
297 | // Don't put all this profile information into the archive right now. | 333 | // Don't put all this profile information into the archive right now. |
298 | //SaveUsers(); | 334 | //SaveUsers(); |
299 | 335 | ||
@@ -352,7 +388,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
352 | /// | 388 | /// |
353 | /// These names are prepended with an inventory folder's UUID so that more than one folder can have the | 389 | /// These names are prepended with an inventory folder's UUID so that more than one folder can have the |
354 | /// same name | 390 | /// same name |
355 | /// | 391 | /// |
356 | /// <param name="folder"></param> | 392 | /// <param name="folder"></param> |
357 | /// <returns></returns> | 393 | /// <returns></returns> |
358 | public static string CreateArchiveFolderName(InventoryFolderBase folder) | 394 | public static string CreateArchiveFolderName(InventoryFolderBase folder) |
@@ -366,7 +402,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
366 | /// | 402 | /// |
367 | /// These names are prepended with an inventory item's UUID so that more than one item can have the | 403 | /// These names are prepended with an inventory item's UUID so that more than one item can have the |
368 | /// same name | 404 | /// same name |
369 | /// | 405 | /// |
370 | /// <param name="item"></param> | 406 | /// <param name="item"></param> |
371 | /// <returns></returns> | 407 | /// <returns></returns> |
372 | public static string CreateArchiveItemName(InventoryItemBase item) | 408 | public static string CreateArchiveItemName(InventoryItemBase item) |
@@ -412,7 +448,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
412 | public string CreateControlFile(Dictionary<string, object> options) | 448 | public string CreateControlFile(Dictionary<string, object> options) |
413 | { | 449 | { |
414 | int majorVersion, minorVersion; | 450 | int majorVersion, minorVersion; |
415 | 451 | ||
416 | if (options.ContainsKey("home")) | 452 | if (options.ContainsKey("home")) |
417 | { | 453 | { |
418 | majorVersion = 1; | 454 | majorVersion = 1; |
@@ -422,10 +458,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
422 | { | 458 | { |
423 | majorVersion = 0; | 459 | majorVersion = 0; |
424 | minorVersion = 3; | 460 | minorVersion = 3; |
425 | } | 461 | } |
426 | 462 | ||
427 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); | 463 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); |
428 | 464 | ||
429 | StringWriter sw = new StringWriter(); | 465 | StringWriter sw = new StringWriter(); |
430 | XmlTextWriter xtw = new XmlTextWriter(sw); | 466 | XmlTextWriter xtw = new XmlTextWriter(sw); |
431 | xtw.Formatting = Formatting.Indented; | 467 | xtw.Formatting = Formatting.Indented; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index ac22c3f..cf87010 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -47,18 +47,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
47 | public class InventoryArchiverModule : IRegionModule, IInventoryArchiverModule | 47 | public class InventoryArchiverModule : IRegionModule, IInventoryArchiverModule |
48 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | public string Name { get { return "Inventory Archiver Module"; } } | 51 | public string Name { get { return "Inventory Archiver Module"; } } |
52 | 52 | ||
53 | public bool IsSharedModule { get { return true; } } | 53 | public bool IsSharedModule { get { return true; } } |
54 | 54 | ||
55 | /// <value> | 55 | /// <value> |
56 | /// Enable or disable checking whether the iar user is actually logged in | 56 | /// Enable or disable checking whether the iar user is actually logged in |
57 | /// </value> | 57 | /// </value> |
58 | // public bool DisablePresenceChecks { get; set; } | 58 | // public bool DisablePresenceChecks { get; set; } |
59 | 59 | ||
60 | public event InventoryArchiveSaved OnInventoryArchiveSaved; | 60 | public event InventoryArchiveSaved OnInventoryArchiveSaved; |
61 | 61 | ||
62 | /// <summary> | 62 | /// <summary> |
63 | /// The file to load and save inventory if no filename has been specified | 63 | /// The file to load and save inventory if no filename has been specified |
64 | /// </summary> | 64 | /// </summary> |
@@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
68 | /// Pending save completions initiated from the console | 68 | /// Pending save completions initiated from the console |
69 | /// </value> | 69 | /// </value> |
70 | protected List<Guid> m_pendingConsoleSaves = new List<Guid>(); | 70 | protected List<Guid> m_pendingConsoleSaves = new List<Guid>(); |
71 | 71 | ||
72 | /// <value> | 72 | /// <value> |
73 | /// All scenes that this module knows about | 73 | /// All scenes that this module knows about |
74 | /// </value> | 74 | /// </value> |
@@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
106 | { | 106 | { |
107 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); | 107 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); |
108 | OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; | 108 | OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; |
109 | 109 | ||
110 | scene.AddCommand( | 110 | scene.AddCommand( |
111 | "Archiving", this, "load iar", | 111 | "Archiving", this, "load iar", |
112 | "load iar [-m|--merge] <first> <last> <inventory path> <password> [<IAR path>]", | 112 | "load iar [-m|--merge] <first> <last> <inventory path> <password> [<IAR path>]", |
@@ -119,11 +119,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
119 | + "<IAR path> is the filesystem path or URI from which to load the IAR." | 119 | + "<IAR path> is the filesystem path or URI from which to load the IAR." |
120 | + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), | 120 | + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), |
121 | HandleLoadInvConsoleCommand); | 121 | HandleLoadInvConsoleCommand); |
122 | 122 | ||
123 | scene.AddCommand( | 123 | scene.AddCommand( |
124 | "Archiving", this, "save iar", | 124 | "Archiving", this, "save iar", |
125 | "save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-v|--verbose]", | 125 | "save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-e|--exclude=<name/uuid>] [-f|--excludefolder=<foldername/uuid>] [-v|--verbose]", |
126 | "Save user inventory archive (IAR).", | 126 | "Save user inventory archive (IAR).", |
127 | "<first> is the user's first name.\n" | 127 | "<first> is the user's first name.\n" |
128 | + "<last> is the user's last name.\n" | 128 | + "<last> is the user's last name.\n" |
129 | + "<inventory path> is the path inside the user's inventory for the folder/item to be saved.\n" | 129 | + "<inventory path> is the path inside the user's inventory for the folder/item to be saved.\n" |
@@ -131,32 +131,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
131 | + string.Format(" If this is not given then the filename {0} in the current directory is used.\n", DEFAULT_INV_BACKUP_FILENAME) | 131 | + string.Format(" If this is not given then the filename {0} in the current directory is used.\n", DEFAULT_INV_BACKUP_FILENAME) |
132 | + "-h|--home=<url> adds the url of the profile service to the saved user information.\n" | 132 | + "-h|--home=<url> adds the url of the profile service to the saved user information.\n" |
133 | + "-c|--creators preserves information about foreign creators.\n" | 133 | + "-c|--creators preserves information about foreign creators.\n" |
134 | + "-e|--exclude=<name/uuid> don't save the inventory item in archive" + Environment.NewLine | ||
135 | + "-f|--excludefolder=<folder/uuid> don't save contents of the folder in archive" + Environment.NewLine | ||
134 | + "-v|--verbose extra debug messages.\n" | 136 | + "-v|--verbose extra debug messages.\n" |
135 | + "--noassets stops assets being saved to the IAR.", | 137 | + "--noassets stops assets being saved to the IAR.", |
136 | HandleSaveInvConsoleCommand); | 138 | HandleSaveInvConsoleCommand); |
137 | 139 | ||
138 | m_aScene = scene; | 140 | m_aScene = scene; |
139 | } | 141 | } |
140 | 142 | ||
141 | m_scenes[scene.RegionInfo.RegionID] = scene; | 143 | m_scenes[scene.RegionInfo.RegionID] = scene; |
142 | } | 144 | } |
143 | 145 | ||
144 | public void PostInitialise() {} | 146 | public void PostInitialise() {} |
145 | 147 | ||
146 | public void Close() {} | 148 | public void Close() {} |
147 | 149 | ||
148 | /// <summary> | 150 | /// <summary> |
149 | /// Trigger the inventory archive saved event. | 151 | /// Trigger the inventory archive saved event. |
150 | /// </summary> | 152 | /// </summary> |
151 | protected internal void TriggerInventoryArchiveSaved( | 153 | protected internal void TriggerInventoryArchiveSaved( |
152 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, | 154 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, |
153 | Exception reportedException) | 155 | Exception reportedException) |
154 | { | 156 | { |
155 | InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; | 157 | InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; |
156 | if (handlerInventoryArchiveSaved != null) | 158 | if (handlerInventoryArchiveSaved != null) |
157 | handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); | 159 | handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); |
158 | } | 160 | } |
159 | 161 | ||
160 | public bool ArchiveInventory( | 162 | public bool ArchiveInventory( |
161 | Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) | 163 | Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) |
162 | { | 164 | { |
@@ -164,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
164 | } | 166 | } |
165 | 167 | ||
166 | public bool ArchiveInventory( | 168 | public bool ArchiveInventory( |
167 | Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream, | 169 | Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream, |
168 | Dictionary<string, object> options) | 170 | Dictionary<string, object> options) |
169 | { | 171 | { |
170 | if (m_scenes.Count > 0) | 172 | if (m_scenes.Count > 0) |
@@ -188,7 +190,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
188 | 190 | ||
189 | return false; | 191 | return false; |
190 | } | 192 | } |
191 | 193 | ||
192 | return true; | 194 | return true; |
193 | // } | 195 | // } |
194 | // else | 196 | // else |
@@ -202,15 +204,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
202 | 204 | ||
203 | return false; | 205 | return false; |
204 | } | 206 | } |
205 | 207 | ||
206 | public bool ArchiveInventory( | 208 | public bool ArchiveInventory( |
207 | Guid id, string firstName, string lastName, string invPath, string pass, string savePath, | 209 | Guid id, string firstName, string lastName, string invPath, string pass, string savePath, |
208 | Dictionary<string, object> options) | 210 | Dictionary<string, object> options) |
209 | { | 211 | { |
210 | if (m_scenes.Count > 0) | 212 | if (m_scenes.Count > 0) |
211 | { | 213 | { |
212 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); | 214 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); |
213 | 215 | ||
214 | if (userInfo != null) | 216 | if (userInfo != null) |
215 | { | 217 | { |
216 | // if (CheckPresence(userInfo.PrincipalID)) | 218 | // if (CheckPresence(userInfo.PrincipalID)) |
@@ -228,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
228 | 230 | ||
229 | return false; | 231 | return false; |
230 | } | 232 | } |
231 | 233 | ||
232 | return true; | 234 | return true; |
233 | // } | 235 | // } |
234 | // else | 236 | // else |
@@ -239,7 +241,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
239 | // } | 241 | // } |
240 | } | 242 | } |
241 | } | 243 | } |
242 | 244 | ||
243 | return false; | 245 | return false; |
244 | } | 246 | } |
245 | 247 | ||
@@ -247,9 +249,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
247 | { | 249 | { |
248 | return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>()); | 250 | return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>()); |
249 | } | 251 | } |
250 | 252 | ||
251 | public bool DearchiveInventory( | 253 | public bool DearchiveInventory( |
252 | string firstName, string lastName, string invPath, string pass, Stream loadStream, | 254 | string firstName, string lastName, string invPath, string pass, Stream loadStream, |
253 | Dictionary<string, object> options) | 255 | Dictionary<string, object> options) |
254 | { | 256 | { |
255 | if (m_scenes.Count > 0) | 257 | if (m_scenes.Count > 0) |
@@ -295,22 +297,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
295 | 297 | ||
296 | return false; | 298 | return false; |
297 | } | 299 | } |
298 | 300 | ||
299 | public bool DearchiveInventory( | 301 | public bool DearchiveInventory( |
300 | string firstName, string lastName, string invPath, string pass, string loadPath, | 302 | string firstName, string lastName, string invPath, string pass, string loadPath, |
301 | Dictionary<string, object> options) | 303 | Dictionary<string, object> options) |
302 | { | 304 | { |
303 | if (m_scenes.Count > 0) | 305 | if (m_scenes.Count > 0) |
304 | { | 306 | { |
305 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); | 307 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); |
306 | 308 | ||
307 | if (userInfo != null) | 309 | if (userInfo != null) |
308 | { | 310 | { |
309 | // if (CheckPresence(userInfo.PrincipalID)) | 311 | // if (CheckPresence(userInfo.PrincipalID)) |
310 | // { | 312 | // { |
311 | InventoryArchiveReadRequest request; | 313 | InventoryArchiveReadRequest request; |
312 | bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false); | 314 | bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false); |
313 | 315 | ||
314 | try | 316 | try |
315 | { | 317 | { |
316 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath, merge); | 318 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath, merge); |
@@ -324,7 +326,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
324 | 326 | ||
325 | return false; | 327 | return false; |
326 | } | 328 | } |
327 | 329 | ||
328 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 330 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); |
329 | 331 | ||
330 | return true; | 332 | return true; |
@@ -340,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
340 | 342 | ||
341 | return false; | 343 | return false; |
342 | } | 344 | } |
343 | 345 | ||
344 | /// <summary> | 346 | /// <summary> |
345 | /// Load inventory from an inventory file archive | 347 | /// Load inventory from an inventory file archive |
346 | /// </summary> | 348 | /// </summary> |
@@ -351,26 +353,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
351 | { | 353 | { |
352 | Dictionary<string, object> options = new Dictionary<string, object>(); | 354 | Dictionary<string, object> options = new Dictionary<string, object>(); |
353 | OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; }); | 355 | OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; }); |
354 | 356 | ||
355 | List<string> mainParams = optionSet.Parse(cmdparams); | 357 | List<string> mainParams = optionSet.Parse(cmdparams); |
356 | 358 | ||
357 | if (mainParams.Count < 6) | 359 | if (mainParams.Count < 6) |
358 | { | 360 | { |
359 | m_log.Error( | 361 | m_log.Error( |
360 | "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] <first name> <last name> <inventory path> <user password> [<load file path>]"); | 362 | "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] <first name> <last name> <inventory path> <user password> [<load file path>]"); |
361 | return; | 363 | return; |
362 | } | 364 | } |
363 | 365 | ||
364 | string firstName = mainParams[2]; | 366 | string firstName = mainParams[2]; |
365 | string lastName = mainParams[3]; | 367 | string lastName = mainParams[3]; |
366 | string invPath = mainParams[4]; | 368 | string invPath = mainParams[4]; |
367 | string pass = mainParams[5]; | 369 | string pass = mainParams[5]; |
368 | string loadPath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); | 370 | string loadPath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); |
369 | 371 | ||
370 | m_log.InfoFormat( | 372 | m_log.InfoFormat( |
371 | "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", | 373 | "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", |
372 | loadPath, invPath, firstName, lastName); | 374 | loadPath, invPath, firstName, lastName); |
373 | 375 | ||
374 | if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options)) | 376 | if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options)) |
375 | m_log.InfoFormat( | 377 | m_log.InfoFormat( |
376 | "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", | 378 | "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", |
@@ -381,7 +383,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
381 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message); | 383 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message); |
382 | } | 384 | } |
383 | } | 385 | } |
384 | 386 | ||
385 | /// <summary> | 387 | /// <summary> |
386 | /// Save inventory to a file archive | 388 | /// Save inventory to a file archive |
387 | /// </summary> | 389 | /// </summary> |
@@ -398,6 +400,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
398 | ops.Add("v|verbose", delegate(string v) { options["verbose"] = v; }); | 400 | ops.Add("v|verbose", delegate(string v) { options["verbose"] = v; }); |
399 | ops.Add("c|creators", delegate(string v) { options["creators"] = v; }); | 401 | ops.Add("c|creators", delegate(string v) { options["creators"] = v; }); |
400 | ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; }); | 402 | ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; }); |
403 | ops.Add("e|exclude=", delegate(string v) | ||
404 | { | ||
405 | if (!options.ContainsKey("exclude")) | ||
406 | options["exclude"] = new List<String>(); | ||
407 | ((List<String>)options["exclude"]).Add(v); | ||
408 | }); | ||
409 | ops.Add("f|excludefolder=", delegate(string v) | ||
410 | { | ||
411 | if (!options.ContainsKey("excludefolders")) | ||
412 | options["excludefolders"] = new List<String>(); | ||
413 | ((List<String>)options["excludefolders"]).Add(v); | ||
414 | }); | ||
401 | 415 | ||
402 | List<string> mainParams = ops.Parse(cmdparams); | 416 | List<string> mainParams = ops.Parse(cmdparams); |
403 | 417 | ||
@@ -406,10 +420,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
406 | if (mainParams.Count < 6) | 420 | if (mainParams.Count < 6) |
407 | { | 421 | { |
408 | m_log.Error( | 422 | m_log.Error( |
409 | "[INVENTORY ARCHIVER]: usage is save iar [-h|--home=<url>] [--noassets] <first name> <last name> <inventory path> <user password> [<save file path>] [-c|--creators] [-v|--verbose]"); | 423 | "[INVENTORY ARCHIVER]: save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-e|--exclude=<name/uuid>] [-f|--excludefolder=<foldername/uuid>] [-v|--verbose]"); |
410 | return; | 424 | return; |
411 | } | 425 | } |
412 | 426 | ||
413 | if (options.ContainsKey("home")) | 427 | if (options.ContainsKey("home")) |
414 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Please be aware that inventory archives with creator information are not compatible with OpenSim 0.7.0.2 and earlier. Do not use the -home option if you want to produce a compatible IAR"); | 428 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Please be aware that inventory archives with creator information are not compatible with OpenSim 0.7.0.2 and earlier. Do not use the -home option if you want to produce a compatible IAR"); |
415 | 429 | ||
@@ -418,7 +432,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
418 | string invPath = mainParams[4]; | 432 | string invPath = mainParams[4]; |
419 | string pass = mainParams[5]; | 433 | string pass = mainParams[5]; |
420 | string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); | 434 | string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); |
421 | 435 | ||
422 | m_log.InfoFormat( | 436 | m_log.InfoFormat( |
423 | "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", | 437 | "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", |
424 | savePath, invPath, firstName, lastName); | 438 | savePath, invPath, firstName, lastName); |
@@ -433,9 +447,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
433 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message); | 447 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message); |
434 | } | 448 | } |
435 | } | 449 | } |
436 | 450 | ||
437 | private void SaveInvConsoleCommandCompleted( | 451 | private void SaveInvConsoleCommandCompleted( |
438 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, | 452 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, |
439 | Exception reportedException) | 453 | Exception reportedException) |
440 | { | 454 | { |
441 | lock (m_pendingConsoleSaves) | 455 | lock (m_pendingConsoleSaves) |
@@ -445,7 +459,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
445 | else | 459 | else |
446 | return; | 460 | return; |
447 | } | 461 | } |
448 | 462 | ||
449 | if (succeeded) | 463 | if (succeeded) |
450 | { | 464 | { |
451 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0} {1}", userInfo.FirstName, userInfo.LastName); | 465 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0} {1}", userInfo.FirstName, userInfo.LastName); |
@@ -453,11 +467,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
453 | else | 467 | else |
454 | { | 468 | { |
455 | m_log.ErrorFormat( | 469 | m_log.ErrorFormat( |
456 | "[INVENTORY ARCHIVER]: Archive save for {0} {1} failed - {2}", | 470 | "[INVENTORY ARCHIVER]: Archive save for {0} {1} failed - {2}", |
457 | userInfo.FirstName, userInfo.LastName, reportedException.Message); | 471 | userInfo.FirstName, userInfo.LastName, reportedException.Message); |
458 | } | 472 | } |
459 | } | 473 | } |
460 | 474 | ||
461 | /// <summary> | 475 | /// <summary> |
462 | /// Get user information for the given name. | 476 | /// Get user information for the given name. |
463 | /// </summary> | 477 | /// </summary> |
@@ -467,13 +481,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
467 | /// <returns></returns> | 481 | /// <returns></returns> |
468 | protected UserAccount GetUserInfo(string firstName, string lastName, string pass) | 482 | protected UserAccount GetUserInfo(string firstName, string lastName, string pass) |
469 | { | 483 | { |
470 | UserAccount account | 484 | UserAccount account |
471 | = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, firstName, lastName); | 485 | = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, firstName, lastName); |
472 | 486 | ||
473 | if (null == account) | 487 | if (null == account) |
474 | { | 488 | { |
475 | m_log.ErrorFormat( | 489 | m_log.ErrorFormat( |
476 | "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1}", | 490 | "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1}", |
477 | firstName, lastName); | 491 | firstName, lastName); |
478 | return null; | 492 | return null; |
479 | } | 493 | } |
@@ -488,7 +502,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
488 | else | 502 | else |
489 | { | 503 | { |
490 | m_log.ErrorFormat( | 504 | m_log.ErrorFormat( |
491 | "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.", | 505 | "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.", |
492 | firstName, lastName); | 506 | firstName, lastName); |
493 | return null; | 507 | return null; |
494 | } | 508 | } |
@@ -499,7 +513,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
499 | return null; | 513 | return null; |
500 | } | 514 | } |
501 | } | 515 | } |
502 | 516 | ||
503 | /// <summary> | 517 | /// <summary> |
504 | /// Notify the client of loaded nodes if they are logged in | 518 | /// Notify the client of loaded nodes if they are logged in |
505 | /// </summary> | 519 | /// </summary> |
@@ -508,22 +522,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
508 | { | 522 | { |
509 | if (loadedNodes.Count == 0) | 523 | if (loadedNodes.Count == 0) |
510 | return; | 524 | return; |
511 | 525 | ||
512 | foreach (Scene scene in m_scenes.Values) | 526 | foreach (Scene scene in m_scenes.Values) |
513 | { | 527 | { |
514 | ScenePresence user = scene.GetScenePresence(userInfo.PrincipalID); | 528 | ScenePresence user = scene.GetScenePresence(userInfo.PrincipalID); |
515 | 529 | ||
516 | if (user != null && !user.IsChildAgent) | 530 | if (user != null && !user.IsChildAgent) |
517 | { | 531 | { |
518 | foreach (InventoryNodeBase node in loadedNodes) | 532 | foreach (InventoryNodeBase node in loadedNodes) |
519 | { | 533 | { |
520 | // m_log.DebugFormat( | 534 | // m_log.DebugFormat( |
521 | // "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}", | 535 | // "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}", |
522 | // user.Name, node.Name); | 536 | // user.Name, node.Name); |
523 | 537 | ||
524 | user.ControllingClient.SendBulkUpdateInventory(node); | 538 | user.ControllingClient.SendBulkUpdateInventory(node); |
525 | } | 539 | } |
526 | 540 | ||
527 | break; | 541 | break; |
528 | } | 542 | } |
529 | } | 543 | } |
@@ -538,7 +552,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
538 | // { | 552 | // { |
539 | // if (DisablePresenceChecks) | 553 | // if (DisablePresenceChecks) |
540 | // return true; | 554 | // return true; |
541 | // | 555 | // |
542 | // foreach (Scene scene in m_scenes.Values) | 556 | // foreach (Scene scene in m_scenes.Values) |
543 | // { | 557 | // { |
544 | // ScenePresence p; | 558 | // ScenePresence p; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index 19ef571..90ae69d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs | |||
@@ -100,7 +100,7 @@ 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 = SceneHelpers.SetupScene(); | 103 | Scene scene = new SceneHelpers().SetupScene(); |
104 | SceneHelpers.SetupSceneModules(scene, archiverModule); | 104 | SceneHelpers.SetupSceneModules(scene, archiverModule); |
105 | 105 | ||
106 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); | 106 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index e409c8e..b112b6d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -61,7 +61,7 @@ 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 = SceneHelpers.SetupScene(); | 64 | m_scene = new SceneHelpers().SetupScene(); |
65 | SceneHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); | 65 | SceneHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); |
66 | } | 66 | } |
67 | 67 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs index 417c20c..6eb3605 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs | |||
@@ -62,7 +62,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
62 | 62 | ||
63 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 63 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
64 | 64 | ||
65 | Scene scene = SceneHelpers.SetupScene(); | 65 | Scene scene = new SceneHelpers().SetupScene(); |
66 | SceneHelpers.SetupSceneModules(scene, archiverModule); | 66 | SceneHelpers.SetupSceneModules(scene, archiverModule); |
67 | 67 | ||
68 | // Create user | 68 | // Create user |
@@ -179,7 +179,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
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 = SceneHelpers.SetupScene(); | 182 | Scene scene = new SceneHelpers().SetupScene(); |
183 | 183 | ||
184 | SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | 184 | SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); |
185 | 185 | ||
@@ -222,7 +222,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
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 = SceneHelpers.SetupScene(); | 225 | Scene scene = new SceneHelpers().SetupScene(); |
226 | SceneHelpers.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"); |
@@ -247,7 +247,7 @@ 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 = SceneHelpers.SetupScene(); | 250 | Scene scene = new SceneHelpers().SetupScene(); |
251 | SceneHelpers.SetupSceneModules(scene, archiverModule); | 251 | SceneHelpers.SetupSceneModules(scene, archiverModule); |
252 | 252 | ||
253 | // Create user | 253 | // Create user |
@@ -326,7 +326,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
326 | TestHelpers.InMethod(); | 326 | TestHelpers.InMethod(); |
327 | // log4net.Config.XmlConfigurator.Configure(); | 327 | // log4net.Config.XmlConfigurator.Configure(); |
328 | 328 | ||
329 | Scene scene = SceneHelpers.SetupScene(); | 329 | Scene scene = new 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>(); |
@@ -393,7 +393,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
393 | TestHelpers.InMethod(); | 393 | TestHelpers.InMethod(); |
394 | //log4net.Config.XmlConfigurator.Configure(); | 394 | //log4net.Config.XmlConfigurator.Configure(); |
395 | 395 | ||
396 | Scene scene = SceneHelpers.SetupScene(); | 396 | Scene scene = new SceneHelpers().SetupScene(); |
397 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); | 397 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); |
398 | 398 | ||
399 | string folder1ExistingName = "a"; | 399 | string folder1ExistingName = "a"; |
@@ -444,7 +444,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
444 | TestHelpers.InMethod(); | 444 | TestHelpers.InMethod(); |
445 | // log4net.Config.XmlConfigurator.Configure(); | 445 | // log4net.Config.XmlConfigurator.Configure(); |
446 | 446 | ||
447 | Scene scene = SceneHelpers.SetupScene(); | 447 | Scene scene = new 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/Lure/HGLureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs index bc5c1ff..92cf9d1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs | |||
@@ -240,13 +240,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
240 | { | 240 | { |
241 | ScenePresence sp = scene.GetScenePresence(client.AgentId); | 241 | ScenePresence sp = scene.GetScenePresence(client.AgentId); |
242 | IEntityTransferModule transferMod = scene.RequestModuleInterface<IEntityTransferModule>(); | 242 | IEntityTransferModule transferMod = scene.RequestModuleInterface<IEntityTransferModule>(); |
243 | IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>(); | 243 | |
244 | if (transferMod != null && sp != null && eq != null) | 244 | if (transferMod != null && sp != null) |
245 | transferMod.DoTeleport(sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 0f), Vector3.UnitX, teleportflags, eq); | 245 | transferMod.DoTeleport( |
246 | sp, gatekeeper, finalDestination, im.Position + new Vector3(0.5f, 0.5f, 0f), | ||
247 | Vector3.UnitX, teleportflags); | ||
246 | } | 248 | } |
247 | } | 249 | } |
248 | } | 250 | } |
249 | } | 251 | } |
250 | } | 252 | } |
251 | } | 253 | } |
252 | } | 254 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index dcfdf8f..a889984 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs | |||
@@ -151,6 +151,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
151 | Scene scene = (Scene)(client.Scene); | 151 | Scene scene = (Scene)(client.Scene); |
152 | ScenePresence presence = scene.GetScenePresence(client.AgentId); | 152 | ScenePresence presence = scene.GetScenePresence(client.AgentId); |
153 | 153 | ||
154 | // Round up Z co-ordinate rather than round-down by casting. This stops tall avatars from being given | ||
155 | // a teleport Z co-ordinate by short avatars that drops them through or embeds them in thin floors on | ||
156 | // arrival. | ||
157 | // | ||
158 | // Ideally we would give the exact float position adjusting for the relative height of the two avatars | ||
159 | // but it looks like a float component isn't possible with a parcel ID. | ||
154 | UUID dest = Util.BuildFakeParcelID( | 160 | UUID dest = Util.BuildFakeParcelID( |
155 | scene.RegionInfo.RegionHandle, | 161 | scene.RegionInfo.RegionHandle, |
156 | (uint)presence.AbsolutePosition.X, | 162 | (uint)presence.AbsolutePosition.X, |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 2b790f4..7db2491 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -30,7 +30,6 @@ using System.Collections.Generic; | |||
30 | using System.Net; | 30 | using System.Net; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | |||
34 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Capabilities; | 34 | using OpenSim.Framework.Capabilities; |
36 | using OpenSim.Framework.Client; | 35 | using OpenSim.Framework.Client; |
@@ -47,29 +46,39 @@ using Nini.Config; | |||
47 | 46 | ||
48 | namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | 47 | namespace OpenSim.Region.CoreModules.Framework.EntityTransfer |
49 | { | 48 | { |
50 | public class EntityTransferModule : ISharedRegionModule, IEntityTransferModule | 49 | public class EntityTransferModule : INonSharedRegionModule, IEntityTransferModule |
51 | { | 50 | { |
52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
53 | 52 | ||
53 | public const int DefaultMaxTransferDistance = 4095; | ||
54 | public const bool WaitForAgentArrivedAtDestinationDefault = true; | ||
55 | |||
54 | /// <summary> | 56 | /// <summary> |
55 | /// The maximum distance, in standard region units (256m) that an agent is allowed to transfer. | 57 | /// The maximum distance, in standard region units (256m) that an agent is allowed to transfer. |
56 | /// </summary> | 58 | /// </summary> |
57 | private int m_MaxTransferDistance = 4095; | 59 | public int MaxTransferDistance { get; set; } |
58 | public int MaxTransferDistance | ||
59 | { | ||
60 | get { return m_MaxTransferDistance; } | ||
61 | set { m_MaxTransferDistance = value; } | ||
62 | } | ||
63 | 60 | ||
64 | private int m_levelHGTeleport = 0; | 61 | /// <summary> |
62 | /// If true then on a teleport, the source region waits for a callback from the destination region. If | ||
63 | /// a callback fails to arrive within a set time then the user is pulled back into the source region. | ||
64 | /// </summary> | ||
65 | public bool WaitForAgentArrivedAtDestination { get; set; } | ||
65 | 66 | ||
66 | protected bool m_Enabled = false; | 67 | protected bool m_Enabled = false; |
67 | protected Scene m_aScene; | 68 | |
68 | protected List<Scene> m_Scenes = new List<Scene>(); | 69 | public Scene Scene { get; private set; } |
69 | protected List<UUID> m_agentsInTransit; | 70 | |
71 | /// <summary> | ||
72 | /// Handles recording and manipulation of state for entities that are in transfer within or between regions | ||
73 | /// (cross or teleport). | ||
74 | /// </summary> | ||
75 | private EntityTransferStateMachine m_entityTransferStateMachine; | ||
76 | |||
70 | private ExpiringCache<UUID, ExpiringCache<ulong, DateTime>> m_bannedRegions = | 77 | private ExpiringCache<UUID, ExpiringCache<ulong, DateTime>> m_bannedRegions = |
71 | new ExpiringCache<UUID, ExpiringCache<ulong, DateTime>>(); | 78 | new ExpiringCache<UUID, ExpiringCache<ulong, DateTime>>(); |
72 | 79 | ||
80 | private IEventQueue m_eqModule; | ||
81 | |||
73 | #region ISharedRegionModule | 82 | #region ISharedRegionModule |
74 | 83 | ||
75 | public Type ReplaceableInterface | 84 | public Type ReplaceableInterface |
@@ -105,11 +114,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
105 | IConfig transferConfig = source.Configs["EntityTransfer"]; | 114 | IConfig transferConfig = source.Configs["EntityTransfer"]; |
106 | if (transferConfig != null) | 115 | if (transferConfig != null) |
107 | { | 116 | { |
108 | MaxTransferDistance = transferConfig.GetInt("max_distance", 4095); | 117 | WaitForAgentArrivedAtDestination |
109 | m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); | 118 | = transferConfig.GetBoolean("wait_for_callback", WaitForAgentArrivedAtDestinationDefault); |
119 | |||
120 | MaxTransferDistance = transferConfig.GetInt("max_distance", DefaultMaxTransferDistance); | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | MaxTransferDistance = DefaultMaxTransferDistance; | ||
110 | } | 125 | } |
111 | 126 | ||
112 | m_agentsInTransit = new List<UUID>(); | 127 | m_entityTransferStateMachine = new EntityTransferStateMachine(this); |
128 | |||
113 | m_Enabled = true; | 129 | m_Enabled = true; |
114 | } | 130 | } |
115 | 131 | ||
@@ -122,10 +138,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
122 | if (!m_Enabled) | 138 | if (!m_Enabled) |
123 | return; | 139 | return; |
124 | 140 | ||
125 | if (m_aScene == null) | 141 | Scene = scene; |
126 | m_aScene = scene; | ||
127 | 142 | ||
128 | m_Scenes.Add(scene); | ||
129 | scene.RegisterModuleInterface<IEntityTransferModule>(this); | 143 | scene.RegisterModuleInterface<IEntityTransferModule>(this); |
130 | scene.EventManager.OnNewClient += OnNewClient; | 144 | scene.EventManager.OnNewClient += OnNewClient; |
131 | } | 145 | } |
@@ -136,26 +150,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
136 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; | 150 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; |
137 | } | 151 | } |
138 | 152 | ||
139 | public virtual void Close() | 153 | public virtual void Close() {} |
140 | { | ||
141 | if (!m_Enabled) | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | public virtual void RemoveRegion(Scene scene) | ||
146 | { | ||
147 | if (!m_Enabled) | ||
148 | return; | ||
149 | if (scene == m_aScene) | ||
150 | m_aScene = null; | ||
151 | 154 | ||
152 | m_Scenes.Remove(scene); | 155 | public virtual void RemoveRegion(Scene scene) {} |
153 | } | ||
154 | 156 | ||
155 | public virtual void RegionLoaded(Scene scene) | 157 | public virtual void RegionLoaded(Scene scene) |
156 | { | 158 | { |
157 | if (!m_Enabled) | 159 | if (!m_Enabled) |
158 | return; | 160 | return; |
161 | |||
162 | m_eqModule = Scene.RequestModuleInterface<IEventQueue>(); | ||
159 | } | 163 | } |
160 | 164 | ||
161 | #endregion | 165 | #endregion |
@@ -164,170 +168,257 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
164 | 168 | ||
165 | public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) | 169 | public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) |
166 | { | 170 | { |
171 | if (sp.Scene.Permissions.IsGridGod(sp.UUID)) | ||
172 | { | ||
173 | // This user will be a God in the destination scene, too | ||
174 | teleportFlags |= (uint)TeleportFlags.Godlike; | ||
175 | } | ||
176 | |||
167 | if (!sp.Scene.Permissions.CanTeleport(sp.UUID)) | 177 | if (!sp.Scene.Permissions.CanTeleport(sp.UUID)) |
168 | return; | 178 | return; |
169 | 179 | ||
170 | IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>(); | ||
171 | |||
172 | // Reset animations; the viewer does that in teleports. | 180 | // Reset animations; the viewer does that in teleports. |
173 | sp.Animator.ResetAnimations(); | 181 | sp.Animator.ResetAnimations(); |
174 | 182 | ||
183 | string destinationRegionName = "(not found)"; | ||
184 | |||
175 | try | 185 | try |
176 | { | 186 | { |
177 | if (regionHandle == sp.Scene.RegionInfo.RegionHandle) | 187 | if (regionHandle == sp.Scene.RegionInfo.RegionHandle) |
178 | { | 188 | { |
179 | m_log.DebugFormat( | 189 | destinationRegionName = sp.Scene.RegionInfo.RegionName; |
180 | "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}", | ||
181 | position, sp.Scene.RegionInfo.RegionName); | ||
182 | 190 | ||
183 | // Teleport within the same region | 191 | TeleportAgentWithinRegion(sp, position, lookAt, teleportFlags); |
184 | if (IsOutsideRegion(sp.Scene, position) || position.Z < 0) | 192 | } |
185 | { | 193 | else // Another region possibly in another simulator |
186 | Vector3 emergencyPos = new Vector3(128, 128, 128); | 194 | { |
195 | GridRegion finalDestination; | ||
196 | TeleportAgentToDifferentRegion( | ||
197 | sp, regionHandle, position, lookAt, teleportFlags, out finalDestination); | ||
187 | 198 | ||
188 | m_log.WarnFormat( | 199 | if (finalDestination != null) |
189 | "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", | 200 | destinationRegionName = finalDestination.RegionName; |
190 | position, sp.Name, sp.UUID, emergencyPos); | 201 | } |
191 | position = emergencyPos; | 202 | } |
192 | } | 203 | catch (Exception e) |
204 | { | ||
205 | m_log.ErrorFormat( | ||
206 | "[ENTITY TRANSFER MODULE]: Exception on teleport of {0} from {1}@{2} to {3}@{4}: {5}{6}", | ||
207 | sp.Name, sp.AbsolutePosition, sp.Scene.RegionInfo.RegionName, position, destinationRegionName, | ||
208 | e.Message, e.StackTrace); | ||
193 | 209 | ||
194 | // TODO: Get proper AVG Height | 210 | // Make sure that we clear the in-transit flag so that future teleport attempts don't always fail. |
195 | float localAVHeight = 1.56f; | 211 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); |
196 | float posZLimit = 22; | ||
197 | 212 | ||
198 | // TODO: Check other Scene HeightField | 213 | sp.ControllingClient.SendTeleportFailed("Internal error"); |
199 | if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize) | 214 | } |
200 | { | 215 | } |
201 | posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y]; | ||
202 | } | ||
203 | 216 | ||
204 | float newPosZ = posZLimit + localAVHeight; | 217 | /// <summary> |
205 | if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 218 | /// Teleports the agent within its current region. |
206 | { | 219 | /// </summary> |
207 | position.Z = newPosZ; | 220 | /// <param name="sp"></param> |
208 | } | 221 | /// <param name="position"></param> |
222 | /// <param name="lookAt"></param> | ||
223 | /// <param name="teleportFlags"></param | ||
224 | private void TeleportAgentWithinRegion(ScenePresence sp, Vector3 position, Vector3 lookAt, uint teleportFlags) | ||
225 | { | ||
226 | m_log.DebugFormat( | ||
227 | "[ENTITY TRANSFER MODULE]: Teleport for {0} to {1} within {2}", | ||
228 | sp.Name, position, sp.Scene.RegionInfo.RegionName); | ||
209 | 229 | ||
210 | sp.ControllingClient.SendTeleportStart(teleportFlags); | 230 | if (!m_entityTransferStateMachine.SetInTransit(sp.UUID)) |
231 | { | ||
232 | m_log.DebugFormat( | ||
233 | "[ENTITY TRANSFER MODULE]: Ignoring within region teleport request of {0} {1} to {2} - agent is already in transit.", | ||
234 | sp.Name, sp.UUID, position); | ||
211 | 235 | ||
212 | sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); | 236 | return; |
213 | sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags; | 237 | } |
214 | sp.Teleport(position); | ||
215 | 238 | ||
216 | foreach (SceneObjectGroup grp in sp.GetAttachments()) | 239 | // Teleport within the same region |
217 | { | 240 | if (IsOutsideRegion(sp.Scene, position) || position.Z < 0) |
218 | sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT); | 241 | { |
219 | } | 242 | Vector3 emergencyPos = new Vector3(128, 128, 128); |
243 | |||
244 | m_log.WarnFormat( | ||
245 | "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", | ||
246 | position, sp.Name, sp.UUID, emergencyPos); | ||
247 | |||
248 | position = emergencyPos; | ||
249 | } | ||
250 | |||
251 | // TODO: Get proper AVG Height | ||
252 | float localAVHeight = 1.56f; | ||
253 | float posZLimit = 22; | ||
254 | |||
255 | // TODO: Check other Scene HeightField | ||
256 | if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize) | ||
257 | { | ||
258 | posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y]; | ||
259 | } | ||
260 | |||
261 | float newPosZ = posZLimit + localAVHeight; | ||
262 | if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | ||
263 | { | ||
264 | position.Z = newPosZ; | ||
265 | } | ||
266 | |||
267 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); | ||
268 | |||
269 | sp.ControllingClient.SendTeleportStart(teleportFlags); | ||
270 | |||
271 | sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); | ||
272 | sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags; | ||
273 | sp.Velocity = Vector3.Zero; | ||
274 | sp.Teleport(position); | ||
275 | |||
276 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.ReceivedAtDestination); | ||
277 | |||
278 | foreach (SceneObjectGroup grp in sp.GetAttachments()) | ||
279 | { | ||
280 | sp.Scene.EventManager.TriggerOnScriptChangedEvent(grp.LocalId, (uint)Changed.TELEPORT); | ||
281 | } | ||
282 | |||
283 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); | ||
284 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); | ||
285 | } | ||
286 | |||
287 | /// <summary> | ||
288 | /// Teleports the agent to a different region. | ||
289 | /// </summary> | ||
290 | /// <param name='sp'></param> | ||
291 | /// <param name='regionHandle'>/param> | ||
292 | /// <param name='position'></param> | ||
293 | /// <param name='lookAt'></param> | ||
294 | /// <param name='teleportFlags'></param> | ||
295 | /// <param name='finalDestination'></param> | ||
296 | private void TeleportAgentToDifferentRegion( | ||
297 | ScenePresence sp, ulong regionHandle, Vector3 position, | ||
298 | Vector3 lookAt, uint teleportFlags, out GridRegion finalDestination) | ||
299 | { | ||
300 | uint x = 0, y = 0; | ||
301 | Utils.LongToUInts(regionHandle, out x, out y); | ||
302 | GridRegion reg = Scene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y); | ||
303 | |||
304 | if (reg != null) | ||
305 | { | ||
306 | finalDestination = GetFinalDestination(reg); | ||
307 | |||
308 | if (finalDestination == null) | ||
309 | { | ||
310 | m_log.WarnFormat( | ||
311 | "[ENTITY TRANSFER MODULE]: Final destination is having problems. Unable to teleport {0} {1}", | ||
312 | sp.Name, sp.UUID); | ||
313 | |||
314 | sp.ControllingClient.SendTeleportFailed("Problem at destination"); | ||
315 | return; | ||
220 | } | 316 | } |
221 | else // Another region possibly in another simulator | 317 | |
318 | // Check that these are not the same coordinates | ||
319 | if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX && | ||
320 | finalDestination.RegionLocY == sp.Scene.RegionInfo.RegionLocY) | ||
222 | { | 321 | { |
223 | uint x = 0, y = 0; | 322 | // Can't do. Viewer crashes |
224 | Utils.LongToUInts(regionHandle, out x, out y); | 323 | sp.ControllingClient.SendTeleportFailed("Space warp! You would crash. Move to a different region and try again."); |
225 | GridRegion reg = m_aScene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y); | 324 | return; |
325 | } | ||
226 | 326 | ||
227 | if (reg != null) | 327 | // |
228 | { | 328 | // This is it |
229 | GridRegion finalDestination = GetFinalDestination(reg); | 329 | // |
230 | if (finalDestination == null) | 330 | DoTeleport(sp, reg, finalDestination, position, lookAt, teleportFlags); |
231 | { | 331 | // |
232 | m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination is having problems. Unable to teleport agent."); | 332 | // |
233 | sp.ControllingClient.SendTeleportFailed("Problem at destination"); | 333 | // |
234 | return; | 334 | } |
235 | } | 335 | else |
336 | { | ||
337 | finalDestination = null; | ||
236 | 338 | ||
237 | // check if HyperGrid teleport is allowed, based on user level | 339 | // TP to a place that doesn't exist (anymore) |
238 | int flags = m_aScene.GridService.GetRegionFlags(sp.Scene.RegionInfo.ScopeID, reg.RegionID); | 340 | // Inform the viewer about that |
341 | sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore"); | ||
239 | 342 | ||
240 | if (((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) && (sp.UserLevel < m_levelHGTeleport)) | 343 | // and set the map-tile to '(Offline)' |
241 | { | 344 | uint regX, regY; |
242 | m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination link is non permitted hypergrid region. Unable to teleport agent."); | 345 | Utils.LongToUInts(regionHandle, out regX, out regY); |
243 | sp.ControllingClient.SendTeleportFailed("HyperGrid teleport not permitted"); | 346 | |
244 | return; | 347 | MapBlockData block = new MapBlockData(); |
245 | } | 348 | block.X = (ushort)(regX / Constants.RegionSize); |
349 | block.Y = (ushort)(regY / Constants.RegionSize); | ||
350 | block.Access = 254; // == not there | ||
246 | 351 | ||
247 | uint curX = 0, curY = 0; | 352 | List<MapBlockData> blocks = new List<MapBlockData>(); |
248 | Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY); | 353 | blocks.Add(block); |
249 | int curCellX = (int)(curX / Constants.RegionSize); | 354 | sp.ControllingClient.SendMapBlock(blocks, 0); |
250 | int curCellY = (int)(curY / Constants.RegionSize); | 355 | } |
251 | int destCellX = (int)(finalDestination.RegionLocX / Constants.RegionSize); | 356 | } |
252 | int destCellY = (int)(finalDestination.RegionLocY / Constants.RegionSize); | ||
253 | 357 | ||
358 | /// <summary> | ||
359 | /// Determines whether this instance is within the max transfer distance. | ||
360 | /// </summary> | ||
361 | /// <param name="sourceRegion"></param> | ||
362 | /// <param name="destRegion"></param> | ||
363 | /// <returns> | ||
364 | /// <c>true</c> if this instance is within max transfer distance; otherwise, <c>false</c>. | ||
365 | /// </returns> | ||
366 | private bool IsWithinMaxTeleportDistance(RegionInfo sourceRegion, GridRegion destRegion) | ||
367 | { | ||
254 | // m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Source co-ords are x={0} y={1}", curRegionX, curRegionY); | 368 | // m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Source co-ords are x={0} y={1}", curRegionX, curRegionY); |
255 | // | 369 | // |
256 | // m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final dest is x={0} y={1} {2}@{3}", | 370 | // m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final dest is x={0} y={1} {2}@{3}", |
257 | // destRegionX, destRegionY, finalDestination.RegionID, finalDestination.ServerURI); | 371 | // destRegionX, destRegionY, finalDestination.RegionID, finalDestination.ServerURI); |
258 | 372 | ||
259 | // Check that these are not the same coordinates | 373 | // Insanely, RegionLoc on RegionInfo is the 256m map co-ord whilst GridRegion.RegionLoc is the raw meters position. |
260 | if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX && | 374 | return Math.Abs(sourceRegion.RegionLocX - destRegion.RegionCoordX) <= MaxTransferDistance |
261 | finalDestination.RegionLocY == sp.Scene.RegionInfo.RegionLocY) | 375 | && Math.Abs(sourceRegion.RegionLocY - destRegion.RegionCoordY) <= MaxTransferDistance; |
262 | { | 376 | } |
263 | // Can't do. Viewer crashes | ||
264 | sp.ControllingClient.SendTeleportFailed("Space warp! You would crash. Move to a different region and try again."); | ||
265 | return; | ||
266 | } | ||
267 | |||
268 | if (Math.Abs(curCellX - destCellX) > MaxTransferDistance || Math.Abs(curCellY - destCellY) > MaxTransferDistance) | ||
269 | { | ||
270 | sp.ControllingClient.SendTeleportFailed( | ||
271 | string.Format( | ||
272 | "Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way", | ||
273 | finalDestination.RegionName, destCellX, destCellY, | ||
274 | sp.Scene.RegionInfo.RegionName, curCellX, curCellY, | ||
275 | MaxTransferDistance)); | ||
276 | |||
277 | return; | ||
278 | } | ||
279 | 377 | ||
280 | // | 378 | public void DoTeleport( |
281 | // This is it | 379 | ScenePresence sp, GridRegion reg, GridRegion finalDestination, |
282 | // | 380 | Vector3 position, Vector3 lookAt, uint teleportFlags) |
283 | DoTeleport(sp, reg, finalDestination, position, lookAt, teleportFlags, eq); | 381 | { |
284 | // | 382 | // Record that this agent is in transit so that we can prevent simultaneous requests and do later detection |
285 | // | 383 | // of whether the destination region completes the teleport. |
286 | // | 384 | if (!m_entityTransferStateMachine.SetInTransit(sp.UUID)) |
287 | } | ||
288 | else | ||
289 | { | ||
290 | // TP to a place that doesn't exist (anymore) | ||
291 | // Inform the viewer about that | ||
292 | sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore"); | ||
293 | |||
294 | // and set the map-tile to '(Offline)' | ||
295 | uint regX, regY; | ||
296 | Utils.LongToUInts(regionHandle, out regX, out regY); | ||
297 | |||
298 | MapBlockData block = new MapBlockData(); | ||
299 | block.X = (ushort)(regX / Constants.RegionSize); | ||
300 | block.Y = (ushort)(regY / Constants.RegionSize); | ||
301 | block.Access = 254; // == not there | ||
302 | |||
303 | List<MapBlockData> blocks = new List<MapBlockData>(); | ||
304 | blocks.Add(block); | ||
305 | sp.ControllingClient.SendMapBlock(blocks, 0); | ||
306 | } | ||
307 | } | ||
308 | } | ||
309 | catch (Exception e) | ||
310 | { | 385 | { |
311 | m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0} {1}", e.Message, e.StackTrace); | 386 | m_log.DebugFormat( |
312 | sp.ControllingClient.SendTeleportFailed("Internal error"); | 387 | "[ENTITY TRANSFER MODULE]: Ignoring teleport request of {0} {1} to {2} ({3}) {4}/{5} - agent is already in transit.", |
388 | sp.Name, sp.UUID, reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position); | ||
389 | |||
390 | return; | ||
313 | } | 391 | } |
314 | } | ||
315 | 392 | ||
316 | public void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq) | ||
317 | { | ||
318 | if (reg == null || finalDestination == null) | 393 | if (reg == null || finalDestination == null) |
319 | { | 394 | { |
320 | sp.ControllingClient.SendTeleportFailed("Unable to locate destination"); | 395 | sp.ControllingClient.SendTeleportFailed("Unable to locate destination"); |
321 | return; | 396 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); |
322 | } | ||
323 | 397 | ||
324 | if (IsInTransit(sp.UUID)) // Avie is already on the way. Caller shouldn't do this. | ||
325 | return; | 398 | return; |
399 | } | ||
326 | 400 | ||
327 | m_log.DebugFormat( | 401 | m_log.DebugFormat( |
328 | "[ENTITY TRANSFER MODULE]: Request Teleport to {0} ({1}) {2}/{3}", | 402 | "[ENTITY TRANSFER MODULE]: Teleporting {0} {1} from {2} to {3} ({4}) {5}/{6}", |
403 | sp.Name, sp.UUID, sp.Scene.RegionInfo.RegionName, | ||
329 | reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position); | 404 | reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position); |
330 | 405 | ||
406 | RegionInfo sourceRegion = sp.Scene.RegionInfo; | ||
407 | |||
408 | if (!IsWithinMaxTeleportDistance(sourceRegion, finalDestination)) | ||
409 | { | ||
410 | sp.ControllingClient.SendTeleportFailed( | ||
411 | string.Format( | ||
412 | "Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way", | ||
413 | finalDestination.RegionName, finalDestination.RegionCoordX, finalDestination.RegionCoordY, | ||
414 | sourceRegion.RegionName, sourceRegion.RegionLocX, sourceRegion.RegionLocY, | ||
415 | MaxTransferDistance)); | ||
416 | |||
417 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); | ||
418 | |||
419 | return; | ||
420 | } | ||
421 | |||
331 | uint newRegionX = (uint)(reg.RegionHandle >> 40); | 422 | uint newRegionX = (uint)(reg.RegionHandle >> 40); |
332 | uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); | 423 | uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); |
333 | uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); | 424 | uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); |
@@ -341,15 +432,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
341 | IPEndPoint endPoint = finalDestination.ExternalEndPoint; | 432 | IPEndPoint endPoint = finalDestination.ExternalEndPoint; |
342 | if (endPoint != null && endPoint.Address != null) | 433 | if (endPoint != null && endPoint.Address != null) |
343 | { | 434 | { |
344 | // Fixing a bug where teleporting while sitting results in the avatar ending up removed from | 435 | sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); |
345 | // both regions | 436 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); |
346 | if (sp.ParentID != (uint)0) | ||
347 | sp.StandUp(); | ||
348 | 437 | ||
349 | if (!sp.ValidateAttachments()) | 438 | return; |
350 | m_log.DebugFormat( | 439 | } |
351 | "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for teleport of {0} from {1} to {2}. Continuing.", | 440 | |
352 | sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName); | 441 | if (!sp.ValidateAttachments()) |
442 | m_log.DebugFormat( | ||
443 | "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for teleport of {0} from {1} to {2}. Continuing.", | ||
444 | sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName); | ||
353 | 445 | ||
354 | // if (!sp.ValidateAttachments()) | 446 | // if (!sp.ValidateAttachments()) |
355 | // { | 447 | // { |
@@ -357,218 +449,246 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
357 | // return; | 449 | // return; |
358 | // } | 450 | // } |
359 | 451 | ||
360 | string reason; | 452 | string reason; |
361 | string version; | 453 | string version; |
362 | if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out version, out reason)) | 454 | if (!Scene.SimulationService.QueryAccess( |
363 | { | 455 | finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out version, out reason)) |
364 | sp.ControllingClient.SendTeleportFailed("Teleport failed: " + reason); | 456 | { |
365 | return; | 457 | sp.ControllingClient.SendTeleportFailed(reason); |
366 | } | 458 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); |
367 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Destination is running version {0}", version); | ||
368 | |||
369 | sp.ControllingClient.SendTeleportStart(teleportFlags); | ||
370 | |||
371 | // the avatar.Close below will clear the child region list. We need this below for (possibly) | ||
372 | // closing the child agents, so save it here (we need a copy as it is Clear()-ed). | ||
373 | //List<ulong> childRegions = avatar.KnownRegionHandles; | ||
374 | // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport | ||
375 | // failure at this point (unlike a border crossing failure). So perhaps this can never fail | ||
376 | // once we reach here... | ||
377 | //avatar.Scene.RemoveCapsHandler(avatar.UUID); | ||
378 | |||
379 | string capsPath = String.Empty; | ||
380 | |||
381 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | ||
382 | AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); | ||
383 | agentCircuit.startpos = position; | ||
384 | agentCircuit.child = true; | ||
385 | agentCircuit.Appearance = sp.Appearance; | ||
386 | if (currentAgentCircuit != null) | ||
387 | { | ||
388 | agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs; | ||
389 | agentCircuit.IPAddress = currentAgentCircuit.IPAddress; | ||
390 | agentCircuit.Viewer = currentAgentCircuit.Viewer; | ||
391 | agentCircuit.Channel = currentAgentCircuit.Channel; | ||
392 | agentCircuit.Mac = currentAgentCircuit.Mac; | ||
393 | agentCircuit.Id0 = currentAgentCircuit.Id0; | ||
394 | } | ||
395 | 459 | ||
396 | if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) | 460 | m_log.DebugFormat( |
397 | { | 461 | "[ENTITY TRANSFER MODULE]: {0} was stopped from teleporting from {1} to {2} because {3}", |
398 | // brand new agent, let's create a new caps seed | 462 | sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName, reason); |
399 | agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
400 | } | ||
401 | 463 | ||
402 | // Let's create an agent there if one doesn't exist yet. | 464 | return; |
403 | bool logout = false; | 465 | } |
404 | if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) | ||
405 | { | ||
406 | sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", | ||
407 | reason)); | ||
408 | return; | ||
409 | } | ||
410 | 466 | ||
411 | // OK, it got this agent. Let's close some child agents | 467 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Destination is running version {0}", version); |
412 | sp.CloseChildAgents(newRegionX, newRegionY); | ||
413 | IClientIPEndpoint ipepClient; | ||
414 | if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) | ||
415 | { | ||
416 | //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); | ||
417 | #region IP Translation for NAT | ||
418 | // Uses ipepClient above | ||
419 | if (sp.ClientView.TryGet(out ipepClient)) | ||
420 | { | ||
421 | endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); | ||
422 | } | ||
423 | #endregion | ||
424 | capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | ||
425 | 468 | ||
426 | if (eq != null) | 469 | // Fixing a bug where teleporting while sitting results in the avatar ending up removed from |
427 | { | 470 | // both regions |
428 | eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); | 471 | if (sp.ParentID != (uint)0) |
472 | sp.StandUp(); | ||
429 | 473 | ||
430 | // ES makes the client send a UseCircuitCode message to the destination, | 474 | sp.ControllingClient.SendTeleportStart(teleportFlags); |
431 | // which triggers a bunch of things there. | ||
432 | // So let's wait | ||
433 | Thread.Sleep(200); | ||
434 | 475 | ||
435 | eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); | 476 | // the avatar.Close below will clear the child region list. We need this below for (possibly) |
477 | // closing the child agents, so save it here (we need a copy as it is Clear()-ed). | ||
478 | //List<ulong> childRegions = avatar.KnownRegionHandles; | ||
479 | // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport | ||
480 | // failure at this point (unlike a border crossing failure). So perhaps this can never fail | ||
481 | // once we reach here... | ||
482 | //avatar.Scene.RemoveCapsHandler(avatar.UUID); | ||
436 | 483 | ||
437 | } | 484 | string capsPath = String.Empty; |
438 | else | 485 | |
439 | { | 486 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); |
440 | sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); | 487 | AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); |
441 | } | 488 | agentCircuit.startpos = position; |
442 | } | 489 | agentCircuit.child = true; |
443 | else | 490 | agentCircuit.Appearance = sp.Appearance; |
444 | { | 491 | if (currentAgentCircuit != null) |
445 | agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); | 492 | { |
446 | capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | 493 | agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs; |
447 | } | 494 | agentCircuit.IPAddress = currentAgentCircuit.IPAddress; |
495 | agentCircuit.Viewer = currentAgentCircuit.Viewer; | ||
496 | agentCircuit.Channel = currentAgentCircuit.Channel; | ||
497 | agentCircuit.Mac = currentAgentCircuit.Mac; | ||
498 | agentCircuit.Id0 = currentAgentCircuit.Id0; | ||
499 | } | ||
448 | 500 | ||
501 | if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) | ||
502 | { | ||
503 | // brand new agent, let's create a new caps seed | ||
504 | agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
505 | } | ||
449 | 506 | ||
450 | SetInTransit(sp.UUID); | 507 | // Let's create an agent there if one doesn't exist yet. |
508 | bool logout = false; | ||
509 | if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) | ||
510 | { | ||
511 | sp.ControllingClient.SendTeleportFailed(String.Format("Teleport refused: {0}", reason)); | ||
512 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); | ||
513 | |||
514 | m_log.DebugFormat( | ||
515 | "[ENTITY TRANSFER MODULE]: Teleport of {0} from {1} to {2} was refused because {3}", | ||
516 | sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName, reason); | ||
517 | |||
518 | return; | ||
519 | } | ||
451 | 520 | ||
452 | // Let's send a full update of the agent. This is a synchronous call. | 521 | // Past this point we have to attempt clean up if the teleport fails, so update transfer state. |
453 | AgentData agent = new AgentData(); | 522 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); |
454 | sp.CopyTo(agent); | ||
455 | agent.Position = position; | ||
456 | SetCallbackURL(agent, sp.Scene.RegionInfo); | ||
457 | 523 | ||
458 | //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Updating agent..."); | 524 | // OK, it got this agent. Let's close some child agents |
525 | sp.CloseChildAgents(newRegionX, newRegionY); | ||
459 | 526 | ||
460 | if (!UpdateAgent(reg, finalDestination, agent)) | 527 | IClientIPEndpoint ipepClient; |
528 | if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) | ||
529 | { | ||
530 | //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); | ||
531 | #region IP Translation for NAT | ||
532 | // Uses ipepClient above | ||
533 | if (sp.ClientView.TryGet(out ipepClient)) | ||
461 | { | 534 | { |
462 | // Region doesn't take it | 535 | endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); |
463 | m_log.WarnFormat( | ||
464 | "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Returning avatar to source region.", | ||
465 | sp.Name, finalDestination.RegionName); | ||
466 | |||
467 | Fail(sp, finalDestination, logout); | ||
468 | return; | ||
469 | } | 536 | } |
537 | #endregion | ||
538 | capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | ||
470 | 539 | ||
471 | sp.ControllingClient.SendTeleportProgress(teleportFlags | (uint)TeleportFlags.DisableCancel, "sending_dest"); | 540 | if (m_eqModule != null) |
541 | { | ||
542 | m_eqModule.EnableSimulator(destinationHandle, endPoint, sp.UUID); | ||
472 | 543 | ||
473 | m_log.DebugFormat( | 544 | // ES makes the client send a UseCircuitCode message to the destination, |
474 | "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); | 545 | // which triggers a bunch of things there. |
546 | // So let's wait | ||
547 | Thread.Sleep(200); | ||
548 | |||
549 | m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); | ||
475 | 550 | ||
476 | if (eq != null) | ||
477 | { | ||
478 | eq.TeleportFinishEvent(destinationHandle, 13, endPoint, | ||
479 | 0, teleportFlags, capsPath, sp.UUID); | ||
480 | } | 551 | } |
481 | else | 552 | else |
482 | { | 553 | { |
483 | sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, | 554 | sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); |
484 | teleportFlags, capsPath); | ||
485 | } | 555 | } |
556 | } | ||
557 | else | ||
558 | { | ||
559 | agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); | ||
560 | capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | ||
561 | } | ||
486 | 562 | ||
487 | // Let's set this to true tentatively. This does not trigger OnChildAgent | 563 | // Let's send a full update of the agent. This is a synchronous call. |
488 | sp.IsChildAgent = true; | 564 | AgentData agent = new AgentData(); |
565 | sp.CopyTo(agent); | ||
566 | agent.Position = position; | ||
567 | SetCallbackURL(agent, sp.Scene.RegionInfo); | ||
489 | 568 | ||
490 | // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which | 569 | //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Updating agent..."); |
491 | // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation | ||
492 | // that the client contacted the destination before we close things here. | ||
493 | if (!WaitForCallback(sp.UUID)) | ||
494 | { | ||
495 | m_log.WarnFormat( | ||
496 | "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} failed due to no callback from destination region. Returning avatar to source region.", | ||
497 | sp.Name, finalDestination.RegionName); | ||
498 | |||
499 | Fail(sp, finalDestination, logout); | ||
500 | return; | ||
501 | } | ||
502 | 570 | ||
503 | // For backwards compatibility | 571 | if (!UpdateAgent(reg, finalDestination, agent)) |
504 | if (version == "Unknown" || version == string.Empty) | 572 | { |
505 | { | 573 | // Region doesn't take it |
506 | // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it | 574 | m_log.WarnFormat( |
507 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Old simulator, sending attachments one by one..."); | 575 | "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Returning avatar to source region.", |
508 | CrossAttachmentsIntoNewRegion(finalDestination, sp, true); | 576 | sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); |
509 | } | 577 | |
578 | Fail(sp, finalDestination, logout); | ||
579 | return; | ||
580 | } | ||
510 | 581 | ||
511 | // May need to logout or other cleanup | 582 | sp.ControllingClient.SendTeleportProgress(teleportFlags | (uint)TeleportFlags.DisableCancel, "sending_dest"); |
512 | AgentHasMovedAway(sp, logout); | ||
513 | 583 | ||
514 | // Well, this is it. The agent is over there. | 584 | m_log.DebugFormat( |
515 | KillEntity(sp.Scene, sp.LocalId); | 585 | "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} from {1} to {2}", |
586 | capsPath, sp.Scene.RegionInfo.RegionName, sp.Name); | ||
516 | 587 | ||
517 | // Now let's make it officially a child agent | 588 | if (m_eqModule != null) |
518 | sp.MakeChildAgent(); | 589 | { |
590 | m_eqModule.TeleportFinishEvent(destinationHandle, 13, endPoint, 0, teleportFlags, capsPath, sp.UUID); | ||
591 | } | ||
592 | else | ||
593 | { | ||
594 | sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, | ||
595 | teleportFlags, capsPath); | ||
596 | } | ||
519 | 597 | ||
520 | // sp.Scene.CleanDroppedAttachments(); | 598 | // Let's set this to true tentatively. This does not trigger OnChildAgent |
599 | sp.IsChildAgent = true; | ||
521 | 600 | ||
522 | // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone | 601 | // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which |
602 | // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation | ||
603 | // that the client contacted the destination before we close things here. | ||
604 | if (!m_entityTransferStateMachine.WaitForAgentArrivedAtDestination(sp.UUID)) | ||
605 | { | ||
606 | m_log.WarnFormat( | ||
607 | "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} from {2} failed due to no callback from destination region. Returning avatar to source region.", | ||
608 | sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); | ||
609 | |||
610 | Fail(sp, finalDestination, logout); | ||
611 | return; | ||
612 | } | ||
523 | 613 | ||
524 | if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) | 614 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); |
525 | { | ||
526 | Thread.Sleep(5000); | ||
527 | sp.Close(); | ||
528 | sp.Scene.IncomingCloseAgent(sp.UUID); | ||
529 | } | ||
530 | else | ||
531 | { | ||
532 | // now we have a child agent in this region. | ||
533 | sp.Reset(); | ||
534 | } | ||
535 | 615 | ||
536 | // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! | 616 | // For backwards compatibility |
537 | if (sp.Scene.NeedSceneCacheClear(sp.UUID)) | 617 | if (version == "Unknown" || version == string.Empty) |
538 | { | 618 | { |
539 | m_log.DebugFormat( | 619 | // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it |
540 | "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", | 620 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Old simulator, sending attachments one by one..."); |
541 | sp.UUID); | 621 | CrossAttachmentsIntoNewRegion(finalDestination, sp, true); |
542 | } | 622 | } |
623 | |||
624 | // May need to logout or other cleanup | ||
625 | AgentHasMovedAway(sp, logout); | ||
626 | |||
627 | // Well, this is it. The agent is over there. | ||
628 | KillEntity(sp.Scene, sp.LocalId); | ||
629 | |||
630 | // Now let's make it officially a child agent | ||
631 | sp.MakeChildAgent(); | ||
632 | |||
633 | // sp.Scene.CleanDroppedAttachments(); | ||
634 | |||
635 | // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone | ||
636 | |||
637 | if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) | ||
638 | { | ||
639 | // We need to delay here because Imprudence viewers, unlike v1 or v3, have a short (<200ms, <500ms) delay before | ||
640 | // they regard the new region as the current region after receiving the AgentMovementComplete | ||
641 | // response. If close is sent before then, it will cause the viewer to quit instead. | ||
642 | // | ||
643 | // This sleep can be increased if necessary. However, whilst it's active, | ||
644 | // an agent cannot teleport back to this region if it has teleported away. | ||
645 | Thread.Sleep(2000); | ||
646 | |||
647 | sp.Close(); | ||
648 | sp.Scene.IncomingCloseAgent(sp.UUID); | ||
543 | } | 649 | } |
544 | else | 650 | else |
545 | { | 651 | { |
546 | sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); | 652 | // now we have a child agent in this region. |
653 | sp.Reset(); | ||
547 | } | 654 | } |
655 | |||
656 | // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! | ||
657 | if (sp.Scene.NeedSceneCacheClear(sp.UUID)) | ||
658 | { | ||
659 | m_log.DebugFormat( | ||
660 | "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", | ||
661 | sp.UUID); | ||
662 | } | ||
663 | |||
664 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); | ||
548 | } | 665 | } |
549 | 666 | ||
550 | protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout) | 667 | protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout) |
551 | { | 668 | { |
669 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); | ||
670 | |||
552 | // Client never contacted destination. Let's restore everything back | 671 | // Client never contacted destination. Let's restore everything back |
553 | sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); | 672 | sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); |
554 | 673 | ||
555 | // Fail. Reset it back | 674 | // Fail. Reset it back |
556 | sp.IsChildAgent = false; | 675 | sp.IsChildAgent = false; |
557 | ReInstantiateScripts(sp); | 676 | ReInstantiateScripts(sp); |
558 | ResetFromTransit(sp.UUID); | ||
559 | 677 | ||
560 | EnableChildAgents(sp); | 678 | EnableChildAgents(sp); |
561 | 679 | ||
562 | // Finally, kill the agent we just created at the destination. | 680 | // Finally, kill the agent we just created at the destination. |
563 | m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID); | 681 | Scene.SimulationService.CloseAgent(finalDestination, sp.UUID); |
564 | 682 | ||
565 | sp.Scene.EventManager.TriggerTeleportFail(sp.ControllingClient, logout); | 683 | sp.Scene.EventManager.TriggerTeleportFail(sp.ControllingClient, logout); |
684 | |||
685 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); | ||
566 | } | 686 | } |
567 | 687 | ||
568 | protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout) | 688 | protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout) |
569 | { | 689 | { |
570 | logout = false; | 690 | logout = false; |
571 | bool success = m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); | 691 | bool success = Scene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); |
572 | 692 | ||
573 | if (success) | 693 | if (success) |
574 | sp.Scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout); | 694 | sp.Scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout); |
@@ -578,19 +698,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
578 | 698 | ||
579 | protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent) | 699 | protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent) |
580 | { | 700 | { |
581 | return m_aScene.SimulationService.UpdateAgent(finalDestination, agent); | 701 | return Scene.SimulationService.UpdateAgent(finalDestination, agent); |
582 | } | 702 | } |
583 | 703 | ||
584 | protected virtual void SetCallbackURL(AgentData agent, RegionInfo region) | 704 | protected virtual void SetCallbackURL(AgentData agent, RegionInfo region) |
585 | { | 705 | { |
586 | agent.CallbackURI = region.ServerURI + "agent/" + agent.AgentID.ToString() + "/" + region.RegionID.ToString() + "/release/"; | 706 | agent.CallbackURI = region.ServerURI + "agent/" + agent.AgentID.ToString() + "/" + region.RegionID.ToString() + "/release/"; |
587 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Set callback URL to {0}", agent.CallbackURI); | ||
588 | 707 | ||
708 | m_log.DebugFormat( | ||
709 | "[ENTITY TRANSFER MODULE]: Set release callback URL to {0} in {1}", | ||
710 | agent.CallbackURI, region.RegionName); | ||
589 | } | 711 | } |
590 | 712 | ||
591 | protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) | 713 | protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) |
592 | { | 714 | { |
593 | sp.Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, true); | 715 | if (sp.Scene.AttachmentsModule != null) |
716 | sp.Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, true); | ||
594 | } | 717 | } |
595 | 718 | ||
596 | protected void KillEntity(Scene scene, uint localID) | 719 | protected void KillEntity(Scene scene, uint localID) |
@@ -615,7 +738,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
615 | 738 | ||
616 | protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) | 739 | protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) |
617 | { | 740 | { |
618 | |||
619 | if (s.TestBorderCross(pos, Cardinals.N)) | 741 | if (s.TestBorderCross(pos, Cardinals.N)) |
620 | return true; | 742 | return true; |
621 | if (s.TestBorderCross(pos, Cardinals.S)) | 743 | if (s.TestBorderCross(pos, Cardinals.S)) |
@@ -628,7 +750,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
628 | return false; | 750 | return false; |
629 | } | 751 | } |
630 | 752 | ||
631 | |||
632 | #endregion | 753 | #endregion |
633 | 754 | ||
634 | #region Landmark Teleport | 755 | #region Landmark Teleport |
@@ -640,7 +761,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
640 | /// <param name="position"></param> | 761 | /// <param name="position"></param> |
641 | public virtual void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm) | 762 | public virtual void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm) |
642 | { | 763 | { |
643 | GridRegion info = m_aScene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); | 764 | GridRegion info = Scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); |
644 | 765 | ||
645 | if (info == null) | 766 | if (info == null) |
646 | { | 767 | { |
@@ -663,10 +784,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
663 | 784 | ||
664 | public virtual bool TeleportHome(UUID id, IClientAPI client) | 785 | public virtual bool TeleportHome(UUID id, IClientAPI client) |
665 | { | 786 | { |
666 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); | 787 | m_log.DebugFormat( |
788 | "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); | ||
667 | 789 | ||
668 | //OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId); | 790 | //OpenSim.Services.Interfaces.PresenceInfo pinfo = Scene.PresenceService.GetAgent(client.SessionId); |
669 | GridUserInfo uinfo = m_aScene.GridUserService.GetGridUserInfo(client.AgentId.ToString()); | 791 | GridUserInfo uinfo = Scene.GridUserService.GetGridUserInfo(client.AgentId.ToString()); |
670 | 792 | ||
671 | if (uinfo != null) | 793 | if (uinfo != null) |
672 | { | 794 | { |
@@ -676,7 +798,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
676 | client.SendTeleportFailed("You don't have a home position set."); | 798 | client.SendTeleportFailed("You don't have a home position set."); |
677 | return false; | 799 | return false; |
678 | } | 800 | } |
679 | GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); | 801 | GridRegion regionInfo = Scene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); |
680 | if (regionInfo == null) | 802 | if (regionInfo == null) |
681 | { | 803 | { |
682 | // can't find the Home region: Tell viewer and abort | 804 | // can't find the Home region: Tell viewer and abort |
@@ -684,8 +806,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
684 | return false; | 806 | return false; |
685 | } | 807 | } |
686 | 808 | ||
687 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: User's home region is {0} {1} ({2}-{3})", | 809 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Home region of {0} is {1} ({2}-{3})", |
688 | regionInfo.RegionName, regionInfo.RegionID, regionInfo.RegionLocX / Constants.RegionSize, regionInfo.RegionLocY / Constants.RegionSize); | 810 | client.Name, regionInfo.RegionName, regionInfo.RegionCoordX, regionInfo.RegionCoordY); |
689 | 811 | ||
690 | // a little eekie that this goes back to Scene and with a forced cast, will fix that at some point... | 812 | // a little eekie that this goes back to Scene and with a forced cast, will fix that at some point... |
691 | ((Scene)(client.Scene)).RequestTeleportLocation( | 813 | ((Scene)(client.Scene)).RequestTeleportLocation( |
@@ -736,7 +858,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
736 | 858 | ||
737 | neighbourx--; | 859 | neighbourx--; |
738 | newpos.X = Constants.RegionSize - enterDistance; | 860 | newpos.X = Constants.RegionSize - enterDistance; |
739 | |||
740 | } | 861 | } |
741 | else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) | 862 | else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) |
742 | { | 863 | { |
@@ -922,107 +1043,123 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
922 | ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, | 1043 | ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, |
923 | bool isFlying, string version) | 1044 | bool isFlying, string version) |
924 | { | 1045 | { |
1046 | if (neighbourRegion == null) | ||
1047 | return agent; | ||
1048 | |||
925 | try | 1049 | try |
926 | { | 1050 | { |
1051 | m_entityTransferStateMachine.SetInTransit(agent.UUID); | ||
1052 | |||
927 | ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | 1053 | ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); |
928 | 1054 | ||
929 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3} running version {4}", agent.Firstname, agent.Lastname, neighbourx, neighboury, version); | 1055 | m_log.DebugFormat( |
1056 | "[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3} running version {4}", | ||
1057 | agent.Firstname, agent.Lastname, neighbourx, neighboury, version); | ||
930 | 1058 | ||
931 | Scene m_scene = agent.Scene; | 1059 | Scene m_scene = agent.Scene; |
932 | 1060 | ||
933 | if (neighbourRegion != null) | 1061 | if (!agent.ValidateAttachments()) |
1062 | m_log.DebugFormat( | ||
1063 | "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for region crossing of {0} from {1} to {2}. Continuing.", | ||
1064 | agent.Name, agent.Scene.RegionInfo.RegionName, neighbourRegion.RegionName); | ||
1065 | |||
1066 | pos = pos + agent.Velocity; | ||
1067 | Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0); | ||
1068 | |||
1069 | agent.RemoveFromPhysicalScene(); | ||
1070 | |||
1071 | AgentData cAgent = new AgentData(); | ||
1072 | agent.CopyTo(cAgent); | ||
1073 | cAgent.Position = pos; | ||
1074 | if (isFlying) | ||
1075 | cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
1076 | |||
1077 | // We don't need the callback anymnore | ||
1078 | cAgent.CallbackURI = String.Empty; | ||
1079 | |||
1080 | // Beyond this point, extra cleanup is needed beyond removing transit state | ||
1081 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.Transferring); | ||
1082 | |||
1083 | if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) | ||
934 | { | 1084 | { |
935 | if (!agent.ValidateAttachments()) | 1085 | // region doesn't take it |
936 | m_log.DebugFormat( | 1086 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); |
937 | "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for region crossing of {0} from {1} to {2}. Continuing.", | ||
938 | agent.Name, agent.Scene.RegionInfo.RegionName, neighbourRegion.RegionName); | ||
939 | 1087 | ||
940 | pos = pos + agent.Velocity; | 1088 | ReInstantiateScripts(agent); |
941 | Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0); | 1089 | agent.AddToPhysicalScene(isFlying); |
1090 | m_entityTransferStateMachine.ResetFromTransit(agent.UUID); | ||
942 | 1091 | ||
943 | agent.RemoveFromPhysicalScene(); | 1092 | return agent; |
944 | SetInTransit(agent.UUID); | 1093 | } |
945 | 1094 | ||
946 | AgentData cAgent = new AgentData(); | 1095 | //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); |
947 | agent.CopyTo(cAgent); | 1096 | agent.ControllingClient.RequestClientInfo(); |
948 | cAgent.Position = pos; | ||
949 | if (isFlying) | ||
950 | cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
951 | 1097 | ||
952 | // We don't need the callback anymnore | 1098 | //m_log.Debug("BEFORE CROSS"); |
953 | cAgent.CallbackURI = String.Empty; | 1099 | //Scene.DumpChildrenSeeds(UUID); |
1100 | //DumpKnownRegions(); | ||
1101 | string agentcaps; | ||
1102 | if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) | ||
1103 | { | ||
1104 | m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", | ||
1105 | neighbourRegion.RegionHandle); | ||
1106 | return agent; | ||
1107 | } | ||
1108 | // No turning back | ||
1109 | agent.IsChildAgent = true; | ||
954 | 1110 | ||
955 | if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) | 1111 | string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps); |
956 | { | ||
957 | // region doesn't take it | ||
958 | ReInstantiateScripts(agent); | ||
959 | agent.AddToPhysicalScene(isFlying); | ||
960 | ResetFromTransit(agent.UUID); | ||
961 | return agent; | ||
962 | } | ||
963 | |||
964 | //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); | ||
965 | agent.ControllingClient.RequestClientInfo(); | ||
966 | |||
967 | //m_log.Debug("BEFORE CROSS"); | ||
968 | //Scene.DumpChildrenSeeds(UUID); | ||
969 | //DumpKnownRegions(); | ||
970 | string agentcaps; | ||
971 | if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) | ||
972 | { | ||
973 | m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", | ||
974 | neighbourRegion.RegionHandle); | ||
975 | return agent; | ||
976 | } | ||
977 | // No turning back | ||
978 | agent.IsChildAgent = true; | ||
979 | 1112 | ||
980 | string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps); | 1113 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); |
981 | |||
982 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); | ||
983 | 1114 | ||
984 | IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>(); | 1115 | if (m_eqModule != null) |
985 | if (eq != null) | 1116 | { |
986 | { | 1117 | m_eqModule.CrossRegion( |
987 | eq.CrossRegion(neighbourHandle, pos, vel2 /* agent.Velocity */, neighbourRegion.ExternalEndPoint, | 1118 | neighbourHandle, pos, vel2 /* agent.Velocity */, neighbourRegion.ExternalEndPoint, |
988 | capsPath, agent.UUID, agent.ControllingClient.SessionId); | 1119 | capsPath, agent.UUID, agent.ControllingClient.SessionId); |
989 | } | 1120 | } |
990 | else | 1121 | else |
991 | { | 1122 | { |
992 | agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, | 1123 | agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, |
993 | capsPath); | 1124 | capsPath); |
994 | } | 1125 | } |
995 | 1126 | ||
996 | // SUCCESS! | 1127 | // SUCCESS! |
997 | agent.MakeChildAgent(); | 1128 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination); |
998 | ResetFromTransit(agent.UUID); | ||
999 | 1129 | ||
1000 | // now we have a child agent in this region. Request all interesting data about other (root) agents | 1130 | // Unlike a teleport, here we do not wait for the destination region to confirm the receipt. |
1001 | agent.SendOtherAgentsAvatarDataToMe(); | 1131 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); |
1002 | agent.SendOtherAgentsAppearanceToMe(); | ||
1003 | 1132 | ||
1004 | // Backwards compatibility. Best effort | 1133 | agent.MakeChildAgent(); |
1005 | if (version == "Unknown" || version == string.Empty) | ||
1006 | { | ||
1007 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one..."); | ||
1008 | Thread.Sleep(3000); // wait a little now that we're not waiting for the callback | ||
1009 | CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); | ||
1010 | } | ||
1011 | 1134 | ||
1135 | // FIXME: Possibly this should occur lower down after other commands to close other agents, | ||
1136 | // but not sure yet what the side effects would be. | ||
1137 | m_entityTransferStateMachine.ResetFromTransit(agent.UUID); | ||
1012 | 1138 | ||
1013 | // Next, let's close the child agent connections that are too far away. | 1139 | // now we have a child agent in this region. Request all interesting data about other (root) agents |
1014 | agent.CloseChildAgents(neighbourx, neighboury); | 1140 | agent.SendOtherAgentsAvatarDataToMe(); |
1015 | 1141 | agent.SendOtherAgentsAppearanceToMe(); | |
1016 | AgentHasMovedAway(agent, false); | 1142 | |
1017 | 1143 | // Backwards compatibility. Best effort | |
1018 | // the user may change their profile information in other region, | 1144 | if (version == "Unknown" || version == string.Empty) |
1019 | // so the userinfo in UserProfileCache is not reliable any more, delete it | 1145 | { |
1020 | // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! | 1146 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one..."); |
1021 | if (agent.Scene.NeedSceneCacheClear(agent.UUID)) | 1147 | Thread.Sleep(3000); // wait a little now that we're not waiting for the callback |
1022 | { | 1148 | CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); |
1023 | m_log.DebugFormat( | 1149 | } |
1024 | "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID); | 1150 | |
1025 | } | 1151 | // Next, let's close the child agent connections that are too far away. |
1152 | agent.CloseChildAgents(neighbourx, neighboury); | ||
1153 | |||
1154 | AgentHasMovedAway(agent, false); | ||
1155 | |||
1156 | // the user may change their profile information in other region, | ||
1157 | // so the userinfo in UserProfileCache is not reliable any more, delete it | ||
1158 | // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! | ||
1159 | if (agent.Scene.NeedSceneCacheClear(agent.UUID)) | ||
1160 | { | ||
1161 | m_log.DebugFormat( | ||
1162 | "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID); | ||
1026 | } | 1163 | } |
1027 | 1164 | ||
1028 | //m_log.Debug("AFTER CROSS"); | 1165 | //m_log.Debug("AFTER CROSS"); |
@@ -1034,11 +1171,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1034 | m_log.ErrorFormat( | 1171 | m_log.ErrorFormat( |
1035 | "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2}. Exception {3}{4}", | 1172 | "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2}. Exception {3}{4}", |
1036 | agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName, e.Message, e.StackTrace); | 1173 | agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName, e.Message, e.StackTrace); |
1174 | |||
1175 | // TODO: Might be worth attempting other restoration here such as reinstantiation of scripts, etc. | ||
1037 | } | 1176 | } |
1038 | 1177 | ||
1039 | return agent; | 1178 | return agent; |
1040 | } | 1179 | } |
1041 | 1180 | ||
1042 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) | 1181 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) |
1043 | { | 1182 | { |
1044 | CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; | 1183 | CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; |
@@ -1186,7 +1325,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1186 | { | 1325 | { |
1187 | if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) | 1326 | if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) |
1188 | { | 1327 | { |
1189 | |||
1190 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | 1328 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); |
1191 | AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); | 1329 | AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); |
1192 | agent.BaseFolder = UUID.Zero; | 1330 | agent.BaseFolder = UUID.Zero; |
@@ -1211,7 +1349,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1211 | seeds.Add(neighbour.RegionHandle, agent.CapsPath); | 1349 | seeds.Add(neighbour.RegionHandle, agent.CapsPath); |
1212 | } | 1350 | } |
1213 | else | 1351 | else |
1352 | { | ||
1214 | agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, neighbour.RegionHandle); | 1353 | agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, neighbour.RegionHandle); |
1354 | } | ||
1215 | 1355 | ||
1216 | cagents.Add(agent); | 1356 | cagents.Add(agent); |
1217 | } | 1357 | } |
@@ -1322,24 +1462,21 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1322 | // after a cross here | 1462 | // after a cross here |
1323 | Thread.Sleep(500); | 1463 | Thread.Sleep(500); |
1324 | 1464 | ||
1325 | Scene m_scene = sp.Scene; | 1465 | Scene scene = sp.Scene; |
1326 | 1466 | ||
1327 | uint x, y; | 1467 | m_log.DebugFormat( |
1328 | Utils.LongToUInts(reg.RegionHandle, out x, out y); | 1468 | "[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})", |
1329 | x = x / Constants.RegionSize; | 1469 | sp.Name, sp.UUID, reg.RegionName, endPoint, reg.RegionCoordX, reg.RegionCoordY); |
1330 | y = y / Constants.RegionSize; | ||
1331 | m_log.Debug("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint + ")"); | ||
1332 | 1470 | ||
1333 | string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath); | 1471 | string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath); |
1334 | 1472 | ||
1335 | string reason = String.Empty; | 1473 | string reason = String.Empty; |
1336 | 1474 | ||
1337 | bool regionAccepted = m_scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason); | 1475 | bool regionAccepted = scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason); |
1338 | 1476 | ||
1339 | if (regionAccepted && newAgent) | 1477 | if (regionAccepted && newAgent) |
1340 | { | 1478 | { |
1341 | IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>(); | 1479 | if (m_eqModule != null) |
1342 | if (eq != null) | ||
1343 | { | 1480 | { |
1344 | #region IP Translation for NAT | 1481 | #region IP Translation for NAT |
1345 | IClientIPEndpoint ipepClient; | 1482 | IClientIPEndpoint ipepClient; |
@@ -1351,10 +1488,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1351 | 1488 | ||
1352 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbour region {2} @ {3} " + | 1489 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbour region {2} @ {3} " + |
1353 | "and EstablishAgentCommunication with seed cap {4}", | 1490 | "and EstablishAgentCommunication with seed cap {4}", |
1354 | m_scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath); | 1491 | scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath); |
1355 | 1492 | ||
1356 | eq.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID); | 1493 | m_eqModule.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID); |
1357 | eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); | 1494 | m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); |
1358 | } | 1495 | } |
1359 | else | 1496 | else |
1360 | { | 1497 | { |
@@ -1362,8 +1499,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1362 | // TODO: make Event Queue disablable! | 1499 | // TODO: make Event Queue disablable! |
1363 | } | 1500 | } |
1364 | 1501 | ||
1365 | m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); | 1502 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Completed inform {0} {1} about neighbour {2}", sp.Name, sp.UUID, endPoint); |
1366 | } | 1503 | } |
1504 | |||
1505 | if (!regionAccepted) | ||
1506 | m_log.WarnFormat( | ||
1507 | "[ENTITY TRANSFER MODULE]: Region {0} did not accept {1} {2}: {3}", | ||
1508 | reg.RegionName, sp.Name, sp.UUID, reason); | ||
1367 | } | 1509 | } |
1368 | 1510 | ||
1369 | /// <summary> | 1511 | /// <summary> |
@@ -1471,12 +1613,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1471 | 1613 | ||
1472 | #endregion | 1614 | #endregion |
1473 | 1615 | ||
1474 | |||
1475 | #region Agent Arrived | 1616 | #region Agent Arrived |
1617 | |||
1476 | public void AgentArrivedAtDestination(UUID id) | 1618 | public void AgentArrivedAtDestination(UUID id) |
1477 | { | 1619 | { |
1478 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Agent {0} released", id); | 1620 | m_entityTransferStateMachine.SetAgentArrivedAtDestination(id); |
1479 | ResetFromTransit(id); | ||
1480 | } | 1621 | } |
1481 | 1622 | ||
1482 | #endregion | 1623 | #endregion |
@@ -1747,8 +1888,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1747 | //// And the new channel... | 1888 | //// And the new channel... |
1748 | //if (m_interregionCommsOut != null) | 1889 | //if (m_interregionCommsOut != null) |
1749 | // successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true); | 1890 | // successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true); |
1750 | if (m_aScene.SimulationService != null) | 1891 | if (Scene.SimulationService != null) |
1751 | successYN = m_aScene.SimulationService.CreateObject(destination, newPosition, grp, true); | 1892 | successYN = Scene.SimulationService.CreateObject(destination, newPosition, grp, true); |
1752 | 1893 | ||
1753 | if (successYN) | 1894 | if (successYN) |
1754 | { | 1895 | { |
@@ -1827,51 +1968,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1827 | 1968 | ||
1828 | #region Misc | 1969 | #region Misc |
1829 | 1970 | ||
1830 | protected bool WaitForCallback(UUID id) | 1971 | public bool IsInTransit(UUID id) |
1831 | { | 1972 | { |
1832 | int count = 200; | 1973 | return m_entityTransferStateMachine.IsInTransit(id); |
1833 | while (m_agentsInTransit.Contains(id) && count-- > 0) | ||
1834 | { | ||
1835 | //m_log.Debug(" >>> Waiting... " + count); | ||
1836 | Thread.Sleep(100); | ||
1837 | } | ||
1838 | |||
1839 | if (count > 0) | ||
1840 | return true; | ||
1841 | else | ||
1842 | return false; | ||
1843 | } | ||
1844 | |||
1845 | protected void SetInTransit(UUID id) | ||
1846 | { | ||
1847 | lock (m_agentsInTransit) | ||
1848 | { | ||
1849 | if (!m_agentsInTransit.Contains(id)) | ||
1850 | m_agentsInTransit.Add(id); | ||
1851 | } | ||
1852 | } | ||
1853 | |||
1854 | protected bool IsInTransit(UUID id) | ||
1855 | { | ||
1856 | lock (m_agentsInTransit) | ||
1857 | { | ||
1858 | if (m_agentsInTransit.Contains(id)) | ||
1859 | return true; | ||
1860 | } | ||
1861 | return false; | ||
1862 | } | ||
1863 | |||
1864 | protected bool ResetFromTransit(UUID id) | ||
1865 | { | ||
1866 | lock (m_agentsInTransit) | ||
1867 | { | ||
1868 | if (m_agentsInTransit.Contains(id)) | ||
1869 | { | ||
1870 | m_agentsInTransit.Remove(id); | ||
1871 | return true; | ||
1872 | } | ||
1873 | } | ||
1874 | return false; | ||
1875 | } | 1974 | } |
1876 | 1975 | ||
1877 | protected void ReInstantiateScripts(ScenePresence sp) | 1976 | protected void ReInstantiateScripts(ScenePresence sp) |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs new file mode 100644 index 0000000..d0cab49 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs | |||
@@ -0,0 +1,269 @@ | |||
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.Net; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using OpenMetaverse; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Capabilities; | ||
38 | using OpenSim.Framework.Client; | ||
39 | using OpenSim.Region.Framework.Interfaces; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | using OpenSim.Region.Physics.Manager; | ||
42 | using OpenSim.Services.Interfaces; | ||
43 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
44 | |||
45 | namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// The possible states that an agent can be in when its being transferred between regions. | ||
49 | /// </summary> | ||
50 | /// <remarks> | ||
51 | /// This is a state machine. | ||
52 | /// | ||
53 | /// [Entry] => Preparing | ||
54 | /// Preparing => { Transferring || CleaningUp || [Exit] } | ||
55 | /// Transferring => { ReceivedAtDestination || CleaningUp } | ||
56 | /// ReceivedAtDestination => CleaningUp | ||
57 | /// CleaningUp => [Exit] | ||
58 | /// | ||
59 | /// In other words, agents normally travel throwing Preparing => Transferring => ReceivedAtDestination => CleaningUp | ||
60 | /// However, any state can transition to CleaningUp if the teleport has failed. | ||
61 | /// </remarks> | ||
62 | enum AgentTransferState | ||
63 | { | ||
64 | Preparing, // The agent is being prepared for transfer | ||
65 | Transferring, // The agent is in the process of being transferred to a destination | ||
66 | ReceivedAtDestination, // The destination has notified us that the agent has been successfully received | ||
67 | CleaningUp // The agent is being changed to child/removed after a transfer | ||
68 | } | ||
69 | |||
70 | /// <summary> | ||
71 | /// Records the state of entities when they are in transfer within or between regions (cross or teleport). | ||
72 | /// </summary> | ||
73 | public class EntityTransferStateMachine | ||
74 | { | ||
75 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
76 | |||
77 | /// <summary> | ||
78 | /// If true then on a teleport, the source region waits for a callback from the destination region. If | ||
79 | /// a callback fails to arrive within a set time then the user is pulled back into the source region. | ||
80 | /// </summary> | ||
81 | public bool EnableWaitForAgentArrivedAtDestination { get; set; } | ||
82 | |||
83 | private EntityTransferModule m_mod; | ||
84 | |||
85 | private Dictionary<UUID, AgentTransferState> m_agentsInTransit = new Dictionary<UUID, AgentTransferState>(); | ||
86 | |||
87 | public EntityTransferStateMachine(EntityTransferModule module) | ||
88 | { | ||
89 | m_mod = module; | ||
90 | } | ||
91 | |||
92 | /// <summary> | ||
93 | /// Set that an agent is in transit. | ||
94 | /// </summary> | ||
95 | /// <param name='id'>The ID of the agent being teleported</param> | ||
96 | /// <returns>true if the agent was not already in transit, false if it was</returns> | ||
97 | internal bool SetInTransit(UUID id) | ||
98 | { | ||
99 | lock (m_agentsInTransit) | ||
100 | { | ||
101 | if (!m_agentsInTransit.ContainsKey(id)) | ||
102 | { | ||
103 | m_agentsInTransit[id] = AgentTransferState.Preparing; | ||
104 | return true; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | return false; | ||
109 | } | ||
110 | |||
111 | /// <summary> | ||
112 | /// Updates the state of an agent that is already in transit. | ||
113 | /// </summary> | ||
114 | /// <param name='id'></param> | ||
115 | /// <param name='newState'></param> | ||
116 | /// <returns></returns> | ||
117 | /// <exception cref='Exception'>Illegal transitions will throw an Exception</exception> | ||
118 | internal void UpdateInTransit(UUID id, AgentTransferState newState) | ||
119 | { | ||
120 | lock (m_agentsInTransit) | ||
121 | { | ||
122 | // Illegal to try and update an agent that's not actually in transit. | ||
123 | if (!m_agentsInTransit.ContainsKey(id)) | ||
124 | throw new Exception( | ||
125 | string.Format( | ||
126 | "Agent with ID {0} is not registered as in transit in {1}", | ||
127 | id, m_mod.Scene.RegionInfo.RegionName)); | ||
128 | |||
129 | AgentTransferState oldState = m_agentsInTransit[id]; | ||
130 | |||
131 | bool transitionOkay = false; | ||
132 | |||
133 | if (newState == AgentTransferState.CleaningUp && oldState != AgentTransferState.CleaningUp) | ||
134 | transitionOkay = true; | ||
135 | else if (newState == AgentTransferState.Transferring && oldState == AgentTransferState.Preparing) | ||
136 | transitionOkay = true; | ||
137 | else if (newState == AgentTransferState.ReceivedAtDestination && oldState == AgentTransferState.Transferring) | ||
138 | transitionOkay = true; | ||
139 | |||
140 | if (transitionOkay) | ||
141 | m_agentsInTransit[id] = newState; | ||
142 | else | ||
143 | throw new Exception( | ||
144 | string.Format( | ||
145 | "Agent with ID {0} is not allowed to move from old transit state {1} to new state {2} in {3}", | ||
146 | id, oldState, newState, m_mod.Scene.RegionInfo.RegionName)); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | internal bool IsInTransit(UUID id) | ||
151 | { | ||
152 | lock (m_agentsInTransit) | ||
153 | return m_agentsInTransit.ContainsKey(id); | ||
154 | } | ||
155 | |||
156 | /// <summary> | ||
157 | /// Removes an agent from the transit state machine. | ||
158 | /// </summary> | ||
159 | /// <param name='id'></param> | ||
160 | /// <returns>true if the agent was flagged as being teleported when this method was called, false otherwise</returns> | ||
161 | internal bool ResetFromTransit(UUID id) | ||
162 | { | ||
163 | lock (m_agentsInTransit) | ||
164 | { | ||
165 | if (m_agentsInTransit.ContainsKey(id)) | ||
166 | { | ||
167 | AgentTransferState state = m_agentsInTransit[id]; | ||
168 | |||
169 | if (state == AgentTransferState.Transferring || state == AgentTransferState.ReceivedAtDestination) | ||
170 | { | ||
171 | // FIXME: For now, we allow exit from any state since a thrown exception in teleport is now guranteed | ||
172 | // to be handled properly - ResetFromTransit() could be invoked at any step along the process | ||
173 | m_log.WarnFormat( | ||
174 | "[ENTITY TRANSFER STATE MACHINE]: Agent with ID {0} should not exit directly from state {1}, should go to {2} state first in {3}", | ||
175 | id, state, AgentTransferState.CleaningUp, m_mod.Scene.RegionInfo.RegionName); | ||
176 | |||
177 | // throw new Exception( | ||
178 | // "Agent with ID {0} cannot exit directly from state {1}, it must go to {2} state first", | ||
179 | // state, AgentTransferState.CleaningUp); | ||
180 | } | ||
181 | |||
182 | m_agentsInTransit.Remove(id); | ||
183 | |||
184 | m_log.DebugFormat( | ||
185 | "[ENTITY TRANSFER STATE MACHINE]: Agent {0} cleared from transit in {1}", | ||
186 | id, m_mod.Scene.RegionInfo.RegionName); | ||
187 | |||
188 | return true; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | m_log.WarnFormat( | ||
193 | "[ENTITY TRANSFER STATE MACHINE]: Agent {0} requested to clear from transit in {1} but was already cleared", | ||
194 | id, m_mod.Scene.RegionInfo.RegionName); | ||
195 | |||
196 | return false; | ||
197 | } | ||
198 | |||
199 | internal bool WaitForAgentArrivedAtDestination(UUID id) | ||
200 | { | ||
201 | if (!m_mod.WaitForAgentArrivedAtDestination) | ||
202 | return true; | ||
203 | |||
204 | lock (m_agentsInTransit) | ||
205 | { | ||
206 | if (!IsInTransit(id)) | ||
207 | throw new Exception( | ||
208 | string.Format( | ||
209 | "Asked to wait for destination callback for agent with ID {0} in {1} but agent is not in transit", | ||
210 | id, m_mod.Scene.RegionInfo.RegionName)); | ||
211 | |||
212 | AgentTransferState currentState = m_agentsInTransit[id]; | ||
213 | |||
214 | if (currentState != AgentTransferState.Transferring && currentState != AgentTransferState.ReceivedAtDestination) | ||
215 | throw new Exception( | ||
216 | string.Format( | ||
217 | "Asked to wait for destination callback for agent with ID {0} in {1} but agent is in state {2}", | ||
218 | id, m_mod.Scene.RegionInfo.RegionName, currentState)); | ||
219 | } | ||
220 | |||
221 | int count = 200; | ||
222 | |||
223 | // There should be no race condition here since no other code should be removing the agent transfer or | ||
224 | // changing the state to another other than Transferring => ReceivedAtDestination. | ||
225 | while (m_agentsInTransit[id] != AgentTransferState.ReceivedAtDestination && count-- > 0) | ||
226 | { | ||
227 | // m_log.Debug(" >>> Waiting... " + count); | ||
228 | Thread.Sleep(100); | ||
229 | } | ||
230 | |||
231 | return count > 0; | ||
232 | } | ||
233 | |||
234 | internal void SetAgentArrivedAtDestination(UUID id) | ||
235 | { | ||
236 | lock (m_agentsInTransit) | ||
237 | { | ||
238 | if (!m_agentsInTransit.ContainsKey(id)) | ||
239 | { | ||
240 | m_log.WarnFormat( | ||
241 | "[ENTITY TRANSFER STATE MACHINE]: Region {0} received notification of arrival in destination of agent {1} but no teleport request is active", | ||
242 | m_mod.Scene.RegionInfo.RegionName, id); | ||
243 | |||
244 | return; | ||
245 | } | ||
246 | |||
247 | AgentTransferState currentState = m_agentsInTransit[id]; | ||
248 | |||
249 | if (currentState == AgentTransferState.ReceivedAtDestination) | ||
250 | { | ||
251 | // An anomoly but don't make this an outright failure - destination region could be overzealous in sending notification. | ||
252 | m_log.WarnFormat( | ||
253 | "[ENTITY TRANSFER STATE MACHINE]: Region {0} received notification of arrival in destination of agent {1} but notification has already previously been received", | ||
254 | m_mod.Scene.RegionInfo.RegionName, id); | ||
255 | } | ||
256 | else if (currentState != AgentTransferState.Transferring) | ||
257 | { | ||
258 | m_log.ErrorFormat( | ||
259 | "[ENTITY TRANSFER STATE MACHINE]: Region {0} received notification of arrival in destination of agent {1} but agent is in state {2}", | ||
260 | m_mod.Scene.RegionInfo.RegionName, id, currentState); | ||
261 | |||
262 | return; | ||
263 | } | ||
264 | |||
265 | m_agentsInTransit[id] = AgentTransferState.ReceivedAtDestination; | ||
266 | } | ||
267 | } | ||
268 | } | ||
269 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 8b5ad23..7e71fd1 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -45,11 +45,12 @@ using Nini.Config; | |||
45 | 45 | ||
46 | namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | 46 | namespace OpenSim.Region.CoreModules.Framework.EntityTransfer |
47 | { | 47 | { |
48 | public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule | 48 | public class HGEntityTransferModule |
49 | : EntityTransferModule, INonSharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule | ||
49 | { | 50 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 52 | ||
52 | private bool m_Initialized = false; | 53 | private int m_levelHGTeleport = 0; |
53 | 54 | ||
54 | private GatekeeperServiceConnector m_GatekeeperConnector; | 55 | private GatekeeperServiceConnector m_GatekeeperConnector; |
55 | 56 | ||
@@ -63,11 +64,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
63 | public override void Initialise(IConfigSource source) | 64 | public override void Initialise(IConfigSource source) |
64 | { | 65 | { |
65 | IConfig moduleConfig = source.Configs["Modules"]; | 66 | IConfig moduleConfig = source.Configs["Modules"]; |
67 | |||
66 | if (moduleConfig != null) | 68 | if (moduleConfig != null) |
67 | { | 69 | { |
68 | string name = moduleConfig.GetString("EntityTransferModule", ""); | 70 | string name = moduleConfig.GetString("EntityTransferModule", ""); |
69 | if (name == Name) | 71 | if (name == Name) |
70 | { | 72 | { |
73 | IConfig transferConfig = source.Configs["EntityTransfer"]; | ||
74 | if (transferConfig != null) | ||
75 | m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); | ||
76 | |||
71 | InitialiseCommon(source); | 77 | InitialiseCommon(source); |
72 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); | 78 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); |
73 | } | 79 | } |
@@ -77,10 +83,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
77 | public override void AddRegion(Scene scene) | 83 | public override void AddRegion(Scene scene) |
78 | { | 84 | { |
79 | base.AddRegion(scene); | 85 | base.AddRegion(scene); |
86 | |||
80 | if (m_Enabled) | 87 | if (m_Enabled) |
81 | { | ||
82 | scene.RegisterModuleInterface<IUserAgentVerificationModule>(this); | 88 | scene.RegisterModuleInterface<IUserAgentVerificationModule>(this); |
83 | } | ||
84 | } | 89 | } |
85 | 90 | ||
86 | protected override void OnNewClient(IClientAPI client) | 91 | protected override void OnNewClient(IClientAPI client) |
@@ -93,33 +98,28 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
93 | public override void RegionLoaded(Scene scene) | 98 | public override void RegionLoaded(Scene scene) |
94 | { | 99 | { |
95 | base.RegionLoaded(scene); | 100 | base.RegionLoaded(scene); |
96 | if (m_Enabled) | ||
97 | if (!m_Initialized) | ||
98 | { | ||
99 | m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService); | ||
100 | m_Initialized = true; | ||
101 | |||
102 | } | ||
103 | 101 | ||
102 | if (m_Enabled) | ||
103 | m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService); | ||
104 | } | 104 | } |
105 | |||
105 | public override void RemoveRegion(Scene scene) | 106 | public override void RemoveRegion(Scene scene) |
106 | { | 107 | { |
107 | base.AddRegion(scene); | 108 | base.AddRegion(scene); |
109 | |||
108 | if (m_Enabled) | 110 | if (m_Enabled) |
109 | { | ||
110 | scene.UnregisterModuleInterface<IUserAgentVerificationModule>(this); | 111 | scene.UnregisterModuleInterface<IUserAgentVerificationModule>(this); |
111 | } | ||
112 | } | 112 | } |
113 | 113 | ||
114 | |||
115 | #endregion | 114 | #endregion |
116 | 115 | ||
117 | #region HG overrides of IEntiryTransferModule | 116 | #region HG overrides of IEntiryTransferModule |
118 | 117 | ||
119 | protected override GridRegion GetFinalDestination(GridRegion region) | 118 | protected override GridRegion GetFinalDestination(GridRegion region) |
120 | { | 119 | { |
121 | int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, region.RegionID); | 120 | int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, region.RegionID); |
122 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags); | 121 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags); |
122 | |||
123 | if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) | 123 | if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) |
124 | { | 124 | { |
125 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID); | 125 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID); |
@@ -130,6 +130,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
130 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: GetHyperlinkRegion to Gatekeeper {0} failed", region.ServerURI); | 130 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: GetHyperlinkRegion to Gatekeeper {0} failed", region.ServerURI); |
131 | return real_destination; | 131 | return real_destination; |
132 | } | 132 | } |
133 | |||
133 | return region; | 134 | return region; |
134 | } | 135 | } |
135 | 136 | ||
@@ -138,7 +139,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
138 | if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) | 139 | if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) |
139 | return true; | 140 | return true; |
140 | 141 | ||
141 | int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); | 142 | int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); |
142 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) | 143 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) |
143 | return true; | 144 | return true; |
144 | 145 | ||
@@ -151,7 +152,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
151 | if (logout) | 152 | if (logout) |
152 | { | 153 | { |
153 | // Log them out of this grid | 154 | // Log them out of this grid |
154 | m_aScene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 155 | Scene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
155 | } | 156 | } |
156 | } | 157 | } |
157 | 158 | ||
@@ -160,10 +161,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
160 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: CreateAgent {0} {1}", reg.ServerURI, finalDestination.ServerURI); | 161 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: CreateAgent {0} {1}", reg.ServerURI, finalDestination.ServerURI); |
161 | reason = string.Empty; | 162 | reason = string.Empty; |
162 | logout = false; | 163 | logout = false; |
163 | int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); | 164 | int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); |
164 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) | 165 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) |
165 | { | 166 | { |
166 | // this user is going to another grid | 167 | // this user is going to another grid |
168 | // check if HyperGrid teleport is allowed, based on user level | ||
169 | if (sp.UserLevel < m_levelHGTeleport) | ||
170 | { | ||
171 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel."); | ||
172 | reason = "Hypergrid teleport not allowed"; | ||
173 | return false; | ||
174 | } | ||
175 | |||
167 | if (agentCircuit.ServiceURLs.ContainsKey("HomeURI")) | 176 | if (agentCircuit.ServiceURLs.ContainsKey("HomeURI")) |
168 | { | 177 | { |
169 | string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); | 178 | string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); |
@@ -193,10 +202,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
193 | 202 | ||
194 | public override bool TeleportHome(UUID id, IClientAPI client) | 203 | public override bool TeleportHome(UUID id, IClientAPI client) |
195 | { | 204 | { |
196 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); | 205 | m_log.DebugFormat( |
206 | "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); | ||
197 | 207 | ||
198 | // Let's find out if this is a foreign user or a local user | 208 | // Let's find out if this is a foreign user or a local user |
199 | IUserManagement uMan = m_aScene.RequestModuleInterface<IUserManagement>(); | 209 | IUserManagement uMan = Scene.RequestModuleInterface<IUserManagement>(); |
200 | if (uMan != null && uMan.IsLocalGridUser(id)) | 210 | if (uMan != null && uMan.IsLocalGridUser(id)) |
201 | { | 211 | { |
202 | // local grid user | 212 | // local grid user |
@@ -232,13 +242,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
232 | return false; | 242 | return false; |
233 | } | 243 | } |
234 | 244 | ||
235 | IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>(); | ||
236 | GridRegion homeGatekeeper = MakeRegion(aCircuit); | 245 | GridRegion homeGatekeeper = MakeRegion(aCircuit); |
237 | 246 | ||
238 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}", | 247 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}", |
239 | aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName); | 248 | aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName); |
240 | 249 | ||
241 | DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq); | 250 | DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); |
242 | return true; | 251 | return true; |
243 | } | 252 | } |
244 | 253 | ||
@@ -252,19 +261,21 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
252 | { | 261 | { |
253 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}", | 262 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}", |
254 | (lm.Gatekeeper == string.Empty) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position); | 263 | (lm.Gatekeeper == string.Empty) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position); |
264 | |||
255 | if (lm.Gatekeeper == string.Empty) | 265 | if (lm.Gatekeeper == string.Empty) |
256 | { | 266 | { |
257 | base.RequestTeleportLandmark(remoteClient, lm); | 267 | base.RequestTeleportLandmark(remoteClient, lm); |
258 | return; | 268 | return; |
259 | } | 269 | } |
260 | 270 | ||
261 | GridRegion info = m_aScene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); | 271 | GridRegion info = Scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); |
262 | 272 | ||
263 | // Local region? | 273 | // Local region? |
264 | if (info != null) | 274 | if (info != null) |
265 | { | 275 | { |
266 | ((Scene)(remoteClient.Scene)).RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position, | 276 | ((Scene)(remoteClient.Scene)).RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position, |
267 | Vector3.Zero, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); | 277 | Vector3.Zero, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); |
278 | |||
268 | return; | 279 | return; |
269 | } | 280 | } |
270 | else | 281 | else |
@@ -275,21 +286,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
275 | GridRegion gatekeeper = new GridRegion(); | 286 | GridRegion gatekeeper = new GridRegion(); |
276 | gatekeeper.ServerURI = lm.Gatekeeper; | 287 | gatekeeper.ServerURI = lm.Gatekeeper; |
277 | GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID)); | 288 | GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID)); |
289 | |||
278 | if (finalDestination != null) | 290 | if (finalDestination != null) |
279 | { | 291 | { |
280 | ScenePresence sp = scene.GetScenePresence(remoteClient.AgentId); | 292 | ScenePresence sp = scene.GetScenePresence(remoteClient.AgentId); |
281 | IEntityTransferModule transferMod = scene.RequestModuleInterface<IEntityTransferModule>(); | 293 | IEntityTransferModule transferMod = scene.RequestModuleInterface<IEntityTransferModule>(); |
282 | IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>(); | 294 | |
283 | if (transferMod != null && sp != null && eq != null) | 295 | if (transferMod != null && sp != null) |
284 | transferMod.DoTeleport(sp, gatekeeper, finalDestination, lm.Position, | 296 | transferMod.DoTeleport( |
285 | Vector3.UnitX, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark), eq); | 297 | sp, gatekeeper, finalDestination, lm.Position, Vector3.UnitX, |
298 | (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); | ||
286 | } | 299 | } |
287 | 300 | ||
288 | } | 301 | } |
289 | 302 | ||
290 | // can't find the region: Tell viewer and abort | 303 | // can't find the region: Tell viewer and abort |
291 | remoteClient.SendTeleportFailed("The teleport destination could not be found."); | 304 | remoteClient.SendTeleportFailed("The teleport destination could not be found."); |
292 | |||
293 | } | 305 | } |
294 | 306 | ||
295 | #endregion | 307 | #endregion |
@@ -304,8 +316,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
304 | IUserAgentService security = new UserAgentServiceConnector(url); | 316 | IUserAgentService security = new UserAgentServiceConnector(url); |
305 | return security.VerifyClient(aCircuit.SessionID, token); | 317 | return security.VerifyClient(aCircuit.SessionID, token); |
306 | } | 318 | } |
307 | else | 319 | else |
308 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent {0} {1} does not have a HomeURI OH NO!", aCircuit.firstname, aCircuit.lastname); | 320 | { |
321 | m_log.DebugFormat( | ||
322 | "[HG ENTITY TRANSFER MODULE]: Agent {0} {1} does not have a HomeURI OH NO!", | ||
323 | aCircuit.firstname, aCircuit.lastname); | ||
324 | } | ||
309 | 325 | ||
310 | return false; | 326 | return false; |
311 | } | 327 | } |
@@ -322,8 +338,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
322 | } | 338 | } |
323 | 339 | ||
324 | // Let's find out if this is a foreign user or a local user | 340 | // Let's find out if this is a foreign user or a local user |
325 | IUserManagement uMan = m_aScene.RequestModuleInterface<IUserManagement>(); | 341 | IUserManagement uMan = Scene.RequestModuleInterface<IUserManagement>(); |
326 | UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, obj.AgentId); | 342 | // UserAccount account = Scene.UserAccountService.GetUserAccount(Scene.RegionInfo.ScopeID, obj.AgentId); |
327 | if (uMan != null && uMan.IsLocalGridUser(obj.AgentId)) | 343 | if (uMan != null && uMan.IsLocalGridUser(obj.AgentId)) |
328 | { | 344 | { |
329 | // local grid user | 345 | // local grid user |
@@ -346,7 +362,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
346 | 362 | ||
347 | #endregion | 363 | #endregion |
348 | 364 | ||
349 | |||
350 | private GridRegion MakeRegion(AgentCircuitData aCircuit) | 365 | private GridRegion MakeRegion(AgentCircuitData aCircuit) |
351 | { | 366 | { |
352 | GridRegion region = new GridRegion(); | 367 | GridRegion region = new GridRegion(); |
@@ -363,6 +378,5 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
363 | region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); | 378 | region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); |
364 | return region; | 379 | return region; |
365 | } | 380 | } |
366 | |||
367 | } | 381 | } |
368 | } | 382 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index a71584a..cf72b58 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |||
@@ -364,8 +364,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
364 | { | 364 | { |
365 | m_log.DebugFormat("[HG INVENTORY ACCESS MODULE]: Changing root inventory for user {0}", client.Name); | 365 | m_log.DebugFormat("[HG INVENTORY ACCESS MODULE]: Changing root inventory for user {0}", client.Name); |
366 | InventoryCollection content = m_Scene.InventoryService.GetFolderContent(client.AgentId, root.ID); | 366 | InventoryCollection content = m_Scene.InventoryService.GetFolderContent(client.AgentId, root.ID); |
367 | List<UUID> fids = new List<UUID>(); | 367 | |
368 | List<UUID> iids = new List<UUID>(); | ||
369 | List<InventoryFolderBase> keep = new List<InventoryFolderBase>(); | 368 | List<InventoryFolderBase> keep = new List<InventoryFolderBase>(); |
370 | 369 | ||
371 | foreach (InventoryFolderBase f in content.Folders) | 370 | foreach (InventoryFolderBase f in content.Folders) |
@@ -395,4 +394,4 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
395 | 394 | ||
396 | #endregion | 395 | #endregion |
397 | } | 396 | } |
398 | } | 397 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index ee9961f..31820e0 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -175,7 +175,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
175 | sbyte assetType, | 175 | sbyte assetType, |
176 | byte wearableType, uint nextOwnerMask, int creationDate) | 176 | byte wearableType, uint nextOwnerMask, int creationDate) |
177 | { | 177 | { |
178 | m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item {0} in folder {1}", name, folderID); | 178 | m_log.DebugFormat("[INVENTORY ACCESS MODULE]: Received request to create inventory item {0} in folder {1}", name, folderID); |
179 | 179 | ||
180 | if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) | 180 | if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) |
181 | return; | 181 | return; |
@@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
210 | else | 210 | else |
211 | { | 211 | { |
212 | m_log.ErrorFormat( | 212 | m_log.ErrorFormat( |
213 | "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", | 213 | "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", |
214 | remoteClient.AgentId); | 214 | remoteClient.AgentId); |
215 | } | 215 | } |
216 | } | 216 | } |
@@ -288,16 +288,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
288 | else | 288 | else |
289 | { | 289 | { |
290 | m_log.ErrorFormat( | 290 | m_log.ErrorFormat( |
291 | "[AGENT INVENTORY]: Could not find item {0} for caps inventory update", | 291 | "[INVENTORY ACCESS MODULE]: Could not find item {0} for caps inventory update", |
292 | itemID); | 292 | itemID); |
293 | } | 293 | } |
294 | 294 | ||
295 | return UUID.Zero; | 295 | return UUID.Zero; |
296 | } | 296 | } |
297 | 297 | ||
298 | public virtual UUID CopyToInventory(DeRezAction action, UUID folderID, | 298 | public virtual List<InventoryItemBase> CopyToInventory( |
299 | List<SceneObjectGroup> objectGroups, IClientAPI remoteClient) | 299 | DeRezAction action, UUID folderID, |
300 | List<SceneObjectGroup> objectGroups, IClientAPI remoteClient, bool asAttachment) | ||
300 | { | 301 | { |
302 | List<InventoryItemBase> copiedItems = new List<InventoryItemBase>(); | ||
303 | |||
301 | Dictionary<UUID, List<SceneObjectGroup>> bundlesToCopy = new Dictionary<UUID, List<SceneObjectGroup>>(); | 304 | Dictionary<UUID, List<SceneObjectGroup>> bundlesToCopy = new Dictionary<UUID, List<SceneObjectGroup>>(); |
302 | 305 | ||
303 | if (CoalesceMultipleObjectsToInventory) | 306 | if (CoalesceMultipleObjectsToInventory) |
@@ -324,16 +327,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
324 | } | 327 | } |
325 | } | 328 | } |
326 | 329 | ||
327 | // This is method scoped and will be returned. It will be the | 330 | // m_log.DebugFormat( |
328 | // last created asset id | 331 | // "[INVENTORY ACCESS MODULE]: Copying {0} object bundles to folder {1} action {2} for {3}", |
329 | UUID assetID = UUID.Zero; | 332 | // bundlesToCopy.Count, folderID, action, remoteClient.Name); |
330 | 333 | ||
331 | // Each iteration is really a separate asset being created, | 334 | // Each iteration is really a separate asset being created, |
332 | // with distinct destinations as well. | 335 | // with distinct destinations as well. |
333 | foreach (List<SceneObjectGroup> bundle in bundlesToCopy.Values) | 336 | foreach (List<SceneObjectGroup> bundle in bundlesToCopy.Values) |
334 | assetID = CopyBundleToInventory(action, folderID, bundle, remoteClient); | 337 | copiedItems.Add(CopyBundleToInventory(action, folderID, bundle, remoteClient, asAttachment)); |
335 | 338 | ||
336 | return assetID; | 339 | return copiedItems; |
337 | } | 340 | } |
338 | 341 | ||
339 | /// <summary> | 342 | /// <summary> |
@@ -344,12 +347,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
344 | /// <param name="folderID"></param> | 347 | /// <param name="folderID"></param> |
345 | /// <param name="objlist"></param> | 348 | /// <param name="objlist"></param> |
346 | /// <param name="remoteClient"></param> | 349 | /// <param name="remoteClient"></param> |
347 | /// <returns></returns> | 350 | /// <param name="asAttachment">Should be true if the bundle is being copied as an attachment. This prevents |
348 | protected UUID CopyBundleToInventory( | 351 | /// attempted serialization of any script state which would abort any operating scripts.</param> |
349 | DeRezAction action, UUID folderID, List<SceneObjectGroup> objlist, IClientAPI remoteClient) | 352 | /// <returns>The inventory item created by the copy</returns> |
353 | protected InventoryItemBase CopyBundleToInventory( | ||
354 | DeRezAction action, UUID folderID, List<SceneObjectGroup> objlist, IClientAPI remoteClient, | ||
355 | bool asAttachment) | ||
350 | { | 356 | { |
351 | UUID assetID = UUID.Zero; | ||
352 | |||
353 | CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); | 357 | CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); |
354 | Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); | 358 | Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); |
355 | 359 | ||
@@ -401,18 +405,27 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
401 | 405 | ||
402 | string itemXml; | 406 | string itemXml; |
403 | 407 | ||
408 | // If we're being called from a script, then trying to serialize that same script's state will not complete | ||
409 | // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if | ||
410 | // the client/server crashes rather than logging out normally, the attachment's scripts will resume | ||
411 | // without state on relog. Arguably, this is what we want anyway. | ||
404 | if (objlist.Count > 1) | 412 | if (objlist.Count > 1) |
405 | itemXml = CoalescedSceneObjectsSerializer.ToXml(coa); | 413 | itemXml = CoalescedSceneObjectsSerializer.ToXml(coa, !asAttachment); |
406 | else | 414 | else |
407 | itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0]); | 415 | itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0], !asAttachment); |
408 | 416 | ||
409 | // Restore the position of each group now that it has been stored to inventory. | 417 | // Restore the position of each group now that it has been stored to inventory. |
410 | foreach (SceneObjectGroup objectGroup in objlist) | 418 | foreach (SceneObjectGroup objectGroup in objlist) |
411 | objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; | 419 | objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; |
412 | 420 | ||
413 | InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID); | 421 | InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID); |
422 | |||
423 | // m_log.DebugFormat( | ||
424 | // "[INVENTORY ACCESS MODULE]: Created item is {0}", | ||
425 | // item != null ? item.ID.ToString() : "NULL"); | ||
426 | |||
414 | if (item == null) | 427 | if (item == null) |
415 | return UUID.Zero; | 428 | return null; |
416 | 429 | ||
417 | // Can't know creator is the same, so null it in inventory | 430 | // Can't know creator is the same, so null it in inventory |
418 | if (objlist.Count > 1) | 431 | if (objlist.Count > 1) |
@@ -422,7 +435,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
422 | } | 435 | } |
423 | else | 436 | else |
424 | { | 437 | { |
425 | item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); | 438 | item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); |
439 | item.CreatorData = objlist[0].RootPart.CreatorData; | ||
426 | item.SaleType = objlist[0].RootPart.ObjectSaleType; | 440 | item.SaleType = objlist[0].RootPart.ObjectSaleType; |
427 | item.SalePrice = objlist[0].RootPart.SalePrice; | 441 | item.SalePrice = objlist[0].RootPart.SalePrice; |
428 | } | 442 | } |
@@ -435,8 +449,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
435 | objlist[0].OwnerID.ToString()); | 449 | objlist[0].OwnerID.ToString()); |
436 | m_Scene.AssetService.Store(asset); | 450 | m_Scene.AssetService.Store(asset); |
437 | 451 | ||
438 | item.AssetID = asset.FullID; | 452 | item.AssetID = asset.FullID; |
439 | assetID = asset.FullID; | ||
440 | 453 | ||
441 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | 454 | if (DeRezAction.SaveToExistingUserInventoryItem == action) |
442 | { | 455 | { |
@@ -469,9 +482,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
469 | 482 | ||
470 | // This is a hook to do some per-asset post-processing for subclasses that need that | 483 | // This is a hook to do some per-asset post-processing for subclasses that need that |
471 | if (remoteClient != null) | 484 | if (remoteClient != null) |
472 | ExportAsset(remoteClient.AgentId, assetID); | 485 | ExportAsset(remoteClient.AgentId, asset.FullID); |
473 | 486 | ||
474 | return assetID; | 487 | return item; |
475 | } | 488 | } |
476 | 489 | ||
477 | protected virtual void ExportAsset(UUID agentID, UUID assetID) | 490 | protected virtual void ExportAsset(UUID agentID, UUID assetID) |
@@ -617,7 +630,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
617 | if (null == item) | 630 | if (null == item) |
618 | { | 631 | { |
619 | m_log.DebugFormat( | 632 | m_log.DebugFormat( |
620 | "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", | 633 | "[INVENTORY ACCESS MODULE]: Object {0} {1} scheduled for save to inventory has already been deleted.", |
621 | so.Name, so.UUID); | 634 | so.Name, so.UUID); |
622 | 635 | ||
623 | return null; | 636 | return null; |
@@ -668,7 +681,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
668 | { | 681 | { |
669 | // Catch all. Use lost & found | 682 | // Catch all. Use lost & found |
670 | // | 683 | // |
671 | |||
672 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | 684 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); |
673 | } | 685 | } |
674 | } | 686 | } |
@@ -718,7 +730,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
718 | 730 | ||
719 | if (item == null) | 731 | if (item == null) |
720 | { | 732 | { |
721 | |||
722 | return null; | 733 | return null; |
723 | } | 734 | } |
724 | 735 | ||
@@ -748,7 +759,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
748 | else | 759 | else |
749 | { | 760 | { |
750 | m_log.WarnFormat( | 761 | m_log.WarnFormat( |
751 | "[InventoryAccessModule]: Could not find asset {0} for {1} in RezObject()", | 762 | "[INVENTORY ACCESS MODULE]: Could not find asset {0} for {1} in RezObject()", |
752 | assetID, remoteClient.Name); | 763 | assetID, remoteClient.Name); |
753 | } | 764 | } |
754 | 765 | ||
@@ -859,7 +870,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
859 | SceneObjectPart rootPart = group.RootPart; | 870 | SceneObjectPart rootPart = group.RootPart; |
860 | 871 | ||
861 | // m_log.DebugFormat( | 872 | // m_log.DebugFormat( |
862 | // "[InventoryAccessModule]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", | 873 | // "[INVENTORY ACCESS MODULE]: Preparing to rez {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", |
863 | // group.Name, group.LocalId, group.UUID, | 874 | // group.Name, group.LocalId, group.UUID, |
864 | // group.RootPart.OwnerMask, group.RootPart.NextOwnerMask, group.RootPart.GroupMask, group.RootPart.EveryoneMask, | 875 | // group.RootPart.OwnerMask, group.RootPart.NextOwnerMask, group.RootPart.GroupMask, group.RootPart.EveryoneMask, |
865 | // remoteClient.Name); | 876 | // remoteClient.Name); |
@@ -867,7 +878,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
867 | // Vector3 storedPosition = group.AbsolutePosition; | 878 | // Vector3 storedPosition = group.AbsolutePosition; |
868 | if (group.UUID == UUID.Zero) | 879 | if (group.UUID == UUID.Zero) |
869 | { | 880 | { |
870 | m_log.Debug("[InventoryAccessModule]: Object has UUID.Zero! Position 3"); | 881 | m_log.Debug("[INVENTORY ACCESS MODULE]: Object has UUID.Zero! Position 3"); |
871 | } | 882 | } |
872 | 883 | ||
873 | foreach (SceneObjectPart part in group.Parts) | 884 | foreach (SceneObjectPart part in group.Parts) |
@@ -928,7 +939,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
928 | } | 939 | } |
929 | 940 | ||
930 | // m_log.DebugFormat( | 941 | // m_log.DebugFormat( |
931 | // "[InventoryAccessModule]: Rezzed {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", | 942 | // "[INVENTORY ACCESS MODULE]: Rezzed {0} {1} {2} ownermask={3:X} nextownermask={4:X} groupmask={5:X} everyonemask={6:X} for {7}", |
932 | // group.Name, group.LocalId, group.UUID, | 943 | // group.Name, group.LocalId, group.UUID, |
933 | // group.RootPart.OwnerMask, group.RootPart.NextOwnerMask, group.RootPart.GroupMask, group.RootPart.EveryoneMask, | 944 | // group.RootPart.OwnerMask, group.RootPart.NextOwnerMask, group.RootPart.GroupMask, group.RootPart.EveryoneMask, |
934 | // remoteClient.Name); | 945 | // remoteClient.Name); |
@@ -1023,8 +1034,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
1023 | 1034 | ||
1024 | so.FromFolderID = item.Folder; | 1035 | so.FromFolderID = item.Folder; |
1025 | 1036 | ||
1026 | // Console.WriteLine("rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}", | 1037 | // m_log.DebugFormat( |
1027 | // rootPart.OwnerID, item.Owner, item.CurrentPermissions); | 1038 | // "[INVENTORY ACCESS MODULE]: rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}", |
1039 | // rootPart.OwnerID, item.Owner, item.CurrentPermissions); | ||
1028 | 1040 | ||
1029 | if ((rootPart.OwnerID != item.Owner) || | 1041 | if ((rootPart.OwnerID != item.Owner) || |
1030 | (item.CurrentPermissions & 16) != 0 || | 1042 | (item.CurrentPermissions & 16) != 0 || |
@@ -1160,7 +1172,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
1160 | if (assetRequestItem.AssetID != requestID) | 1172 | if (assetRequestItem.AssetID != requestID) |
1161 | { | 1173 | { |
1162 | m_log.WarnFormat( | 1174 | m_log.WarnFormat( |
1163 | "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}", | 1175 | "[INVENTORY ACCESS MODULE]: {0} requested asset {1} from item {2} but this does not match item's asset {3}", |
1164 | Name, requestID, itemID, assetRequestItem.AssetID); | 1176 | Name, requestID, itemID, assetRequestItem.AssetID); |
1165 | 1177 | ||
1166 | return false; | 1178 | return false; |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs index e74310c..21d8bd7 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs | |||
@@ -64,8 +64,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
64 | IConfigSource config = new IniConfigSource(); | 64 | IConfigSource config = new IniConfigSource(); |
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 = SceneHelpers.SetupScene(); | 68 | SceneHelpers sceneHelpers = new SceneHelpers(); |
69 | m_scene = sceneHelpers.SetupScene(); | ||
69 | SceneHelpers.SetupSceneModules(m_scene, config, m_iam); | 70 | SceneHelpers.SetupSceneModules(m_scene, config, m_iam); |
70 | 71 | ||
71 | // Create user | 72 | // Create user |
@@ -76,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
76 | 77 | ||
77 | AgentCircuitData acd = new AgentCircuitData(); | 78 | AgentCircuitData acd = new AgentCircuitData(); |
78 | acd.AgentID = m_userId; | 79 | acd.AgentID = m_userId; |
79 | m_tc = new TestClient(acd, m_scene); | 80 | m_tc = new TestClient(acd, m_scene); |
80 | } | 81 | } |
81 | 82 | ||
82 | [Test] | 83 | [Test] |
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index 7f8271d..4a8c369 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs | |||
@@ -49,7 +49,16 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
49 | public bool Enabled { get; private set; } | 49 | public bool Enabled { get; private set; } |
50 | 50 | ||
51 | private Scene m_scene; | 51 | private Scene m_scene; |
52 | private readonly List<IMonitor> m_monitors = new List<IMonitor>(); | 52 | |
53 | /// <summary> | ||
54 | /// These are monitors where we know the static details in advance. | ||
55 | /// </summary> | ||
56 | /// <remarks> | ||
57 | /// Dynamic monitors also exist (we don't know any of the details of what stats we get back here) | ||
58 | /// but these are currently hardcoded. | ||
59 | /// </remarks> | ||
60 | private readonly List<IMonitor> m_staticMonitors = new List<IMonitor>(); | ||
61 | |||
53 | private readonly List<IAlert> m_alerts = new List<IAlert>(); | 62 | private readonly List<IAlert> m_alerts = new List<IAlert>(); |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 63 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 64 | ||
@@ -84,9 +93,18 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
84 | 93 | ||
85 | public void DebugMonitors(string module, string[] args) | 94 | public void DebugMonitors(string module, string[] args) |
86 | { | 95 | { |
87 | foreach (IMonitor monitor in m_monitors) | 96 | foreach (IMonitor monitor in m_staticMonitors) |
88 | { | 97 | { |
89 | m_log.Info("[MonitorModule]: " + m_scene.RegionInfo.RegionName + " reports " + monitor.GetFriendlyName() + " = " + monitor.GetFriendlyValue()); | 98 | m_log.InfoFormat( |
99 | "[MONITOR MODULE]: {0} reports {1} = {2}", | ||
100 | m_scene.RegionInfo.RegionName, monitor.GetFriendlyName(), monitor.GetFriendlyValue()); | ||
101 | } | ||
102 | |||
103 | foreach (KeyValuePair<string, float> tuple in m_scene.StatsReporter.GetExtraSimStats()) | ||
104 | { | ||
105 | m_log.InfoFormat( | ||
106 | "[MONITOR MODULE]: {0} reports {1} = {2}", | ||
107 | m_scene.RegionInfo.RegionName, tuple.Key, tuple.Value); | ||
90 | } | 108 | } |
91 | } | 109 | } |
92 | 110 | ||
@@ -106,11 +124,12 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
106 | { | 124 | { |
107 | string monID = (string) request["monitor"]; | 125 | string monID = (string) request["monitor"]; |
108 | 126 | ||
109 | foreach (IMonitor monitor in m_monitors) | 127 | foreach (IMonitor monitor in m_staticMonitors) |
110 | { | 128 | { |
111 | string elemName = monitor.ToString(); | 129 | string elemName = monitor.ToString(); |
112 | if (elemName.StartsWith(monitor.GetType().Namespace)) | 130 | if (elemName.StartsWith(monitor.GetType().Namespace)) |
113 | elemName = elemName.Substring(monitor.GetType().Namespace.Length + 1); | 131 | elemName = elemName.Substring(monitor.GetType().Namespace.Length + 1); |
132 | |||
114 | if (elemName == monID || monitor.ToString() == monID) | 133 | if (elemName == monID || monitor.ToString() == monID) |
115 | { | 134 | { |
116 | Hashtable ereply3 = new Hashtable(); | 135 | Hashtable ereply3 = new Hashtable(); |
@@ -123,6 +142,9 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
123 | } | 142 | } |
124 | } | 143 | } |
125 | 144 | ||
145 | // FIXME: Arguably this should also be done with dynamic monitors but I'm not sure what the above code | ||
146 | // is even doing. Why are we inspecting the type of the monitor??? | ||
147 | |||
126 | // No monitor with that name | 148 | // No monitor with that name |
127 | Hashtable ereply2 = new Hashtable(); | 149 | Hashtable ereply2 = new Hashtable(); |
128 | 150 | ||
@@ -134,12 +156,18 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
134 | } | 156 | } |
135 | 157 | ||
136 | string xml = "<data>"; | 158 | string xml = "<data>"; |
137 | foreach (IMonitor monitor in m_monitors) | 159 | foreach (IMonitor monitor in m_staticMonitors) |
138 | { | 160 | { |
139 | string elemName = monitor.GetName(); | 161 | string elemName = monitor.GetName(); |
140 | xml += "<" + elemName + ">" + monitor.GetValue().ToString() + "</" + elemName + ">"; | 162 | xml += "<" + elemName + ">" + monitor.GetValue().ToString() + "</" + elemName + ">"; |
141 | // m_log.DebugFormat("[MONITOR MODULE]: {0} = {1}", elemName, monitor.GetValue()); | 163 | // m_log.DebugFormat("[MONITOR MODULE]: {0} = {1}", elemName, monitor.GetValue()); |
142 | } | 164 | } |
165 | |||
166 | foreach (KeyValuePair<string, float> tuple in m_scene.StatsReporter.GetExtraSimStats()) | ||
167 | { | ||
168 | xml += "<" + tuple.Key + ">" + tuple.Value + "</" + tuple.Key + ">"; | ||
169 | } | ||
170 | |||
143 | xml += "</data>"; | 171 | xml += "</data>"; |
144 | 172 | ||
145 | Hashtable ereply = new Hashtable(); | 173 | Hashtable ereply = new Hashtable(); |
@@ -156,20 +184,20 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
156 | if (!Enabled) | 184 | if (!Enabled) |
157 | return; | 185 | return; |
158 | 186 | ||
159 | m_monitors.Add(new AgentCountMonitor(m_scene)); | 187 | m_staticMonitors.Add(new AgentCountMonitor(m_scene)); |
160 | m_monitors.Add(new ChildAgentCountMonitor(m_scene)); | 188 | m_staticMonitors.Add(new ChildAgentCountMonitor(m_scene)); |
161 | m_monitors.Add(new GCMemoryMonitor()); | 189 | m_staticMonitors.Add(new GCMemoryMonitor()); |
162 | m_monitors.Add(new ObjectCountMonitor(m_scene)); | 190 | m_staticMonitors.Add(new ObjectCountMonitor(m_scene)); |
163 | m_monitors.Add(new PhysicsFrameMonitor(m_scene)); | 191 | m_staticMonitors.Add(new PhysicsFrameMonitor(m_scene)); |
164 | m_monitors.Add(new PhysicsUpdateFrameMonitor(m_scene)); | 192 | m_staticMonitors.Add(new PhysicsUpdateFrameMonitor(m_scene)); |
165 | m_monitors.Add(new PWSMemoryMonitor()); | 193 | m_staticMonitors.Add(new PWSMemoryMonitor()); |
166 | m_monitors.Add(new ThreadCountMonitor()); | 194 | m_staticMonitors.Add(new ThreadCountMonitor()); |
167 | m_monitors.Add(new TotalFrameMonitor(m_scene)); | 195 | m_staticMonitors.Add(new TotalFrameMonitor(m_scene)); |
168 | m_monitors.Add(new EventFrameMonitor(m_scene)); | 196 | m_staticMonitors.Add(new EventFrameMonitor(m_scene)); |
169 | m_monitors.Add(new LandFrameMonitor(m_scene)); | 197 | m_staticMonitors.Add(new LandFrameMonitor(m_scene)); |
170 | m_monitors.Add(new LastFrameTimeMonitor(m_scene)); | 198 | m_staticMonitors.Add(new LastFrameTimeMonitor(m_scene)); |
171 | 199 | ||
172 | m_monitors.Add( | 200 | m_staticMonitors.Add( |
173 | new GenericMonitor( | 201 | new GenericMonitor( |
174 | m_scene, | 202 | m_scene, |
175 | "TimeDilationMonitor", | 203 | "TimeDilationMonitor", |
@@ -177,7 +205,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
177 | m => m.Scene.StatsReporter.LastReportedSimStats[0], | 205 | m => m.Scene.StatsReporter.LastReportedSimStats[0], |
178 | m => m.GetValue().ToString())); | 206 | m => m.GetValue().ToString())); |
179 | 207 | ||
180 | m_monitors.Add( | 208 | m_staticMonitors.Add( |
181 | new GenericMonitor( | 209 | new GenericMonitor( |
182 | m_scene, | 210 | m_scene, |
183 | "SimFPSMonitor", | 211 | "SimFPSMonitor", |
@@ -185,7 +213,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
185 | m => m.Scene.StatsReporter.LastReportedSimStats[1], | 213 | m => m.Scene.StatsReporter.LastReportedSimStats[1], |
186 | m => string.Format("{0}", m.GetValue()))); | 214 | m => string.Format("{0}", m.GetValue()))); |
187 | 215 | ||
188 | m_monitors.Add( | 216 | m_staticMonitors.Add( |
189 | new GenericMonitor( | 217 | new GenericMonitor( |
190 | m_scene, | 218 | m_scene, |
191 | "PhysicsFPSMonitor", | 219 | "PhysicsFPSMonitor", |
@@ -193,7 +221,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
193 | m => m.Scene.StatsReporter.LastReportedSimStats[2], | 221 | m => m.Scene.StatsReporter.LastReportedSimStats[2], |
194 | m => string.Format("{0}", m.GetValue()))); | 222 | m => string.Format("{0}", m.GetValue()))); |
195 | 223 | ||
196 | m_monitors.Add( | 224 | m_staticMonitors.Add( |
197 | new GenericMonitor( | 225 | new GenericMonitor( |
198 | m_scene, | 226 | m_scene, |
199 | "AgentUpdatesPerSecondMonitor", | 227 | "AgentUpdatesPerSecondMonitor", |
@@ -201,15 +229,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
201 | m => m.Scene.StatsReporter.LastReportedSimStats[3], | 229 | m => m.Scene.StatsReporter.LastReportedSimStats[3], |
202 | m => string.Format("{0} per second", m.GetValue()))); | 230 | m => string.Format("{0} per second", m.GetValue()))); |
203 | 231 | ||
204 | m_monitors.Add( | 232 | m_staticMonitors.Add( |
205 | new GenericMonitor( | ||
206 | m_scene, | ||
207 | "ObjectUpdatesPerSecondMonitor", | ||
208 | "Object Updates", | ||
209 | m => m.Scene.StatsReporter.LastReportedObjectUpdates, | ||
210 | m => string.Format("{0} per second", m.GetValue()))); | ||
211 | |||
212 | m_monitors.Add( | ||
213 | new GenericMonitor( | 233 | new GenericMonitor( |
214 | m_scene, | 234 | m_scene, |
215 | "ActiveObjectCountMonitor", | 235 | "ActiveObjectCountMonitor", |
@@ -217,7 +237,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
217 | m => m.Scene.StatsReporter.LastReportedSimStats[7], | 237 | m => m.Scene.StatsReporter.LastReportedSimStats[7], |
218 | m => string.Format("{0}", m.GetValue()))); | 238 | m => string.Format("{0}", m.GetValue()))); |
219 | 239 | ||
220 | m_monitors.Add( | 240 | m_staticMonitors.Add( |
221 | new GenericMonitor( | 241 | new GenericMonitor( |
222 | m_scene, | 242 | m_scene, |
223 | "ActiveScriptsMonitor", | 243 | "ActiveScriptsMonitor", |
@@ -225,7 +245,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
225 | m => m.Scene.StatsReporter.LastReportedSimStats[19], | 245 | m => m.Scene.StatsReporter.LastReportedSimStats[19], |
226 | m => string.Format("{0}", m.GetValue()))); | 246 | m => string.Format("{0}", m.GetValue()))); |
227 | 247 | ||
228 | m_monitors.Add( | 248 | m_staticMonitors.Add( |
229 | new GenericMonitor( | 249 | new GenericMonitor( |
230 | m_scene, | 250 | m_scene, |
231 | "ScriptEventsPerSecondMonitor", | 251 | "ScriptEventsPerSecondMonitor", |
@@ -233,7 +253,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
233 | m => m.Scene.StatsReporter.LastReportedSimStats[20], | 253 | m => m.Scene.StatsReporter.LastReportedSimStats[20], |
234 | m => string.Format("{0} per second", m.GetValue()))); | 254 | m => string.Format("{0} per second", m.GetValue()))); |
235 | 255 | ||
236 | m_monitors.Add( | 256 | m_staticMonitors.Add( |
237 | new GenericMonitor( | 257 | new GenericMonitor( |
238 | m_scene, | 258 | m_scene, |
239 | "InPacketsPerSecondMonitor", | 259 | "InPacketsPerSecondMonitor", |
@@ -241,7 +261,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
241 | m => m.Scene.StatsReporter.LastReportedSimStats[13], | 261 | m => m.Scene.StatsReporter.LastReportedSimStats[13], |
242 | m => string.Format("{0} per second", m.GetValue()))); | 262 | m => string.Format("{0} per second", m.GetValue()))); |
243 | 263 | ||
244 | m_monitors.Add( | 264 | m_staticMonitors.Add( |
245 | new GenericMonitor( | 265 | new GenericMonitor( |
246 | m_scene, | 266 | m_scene, |
247 | "OutPacketsPerSecondMonitor", | 267 | "OutPacketsPerSecondMonitor", |
@@ -249,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
249 | m => m.Scene.StatsReporter.LastReportedSimStats[14], | 269 | m => m.Scene.StatsReporter.LastReportedSimStats[14], |
250 | m => string.Format("{0} per second", m.GetValue()))); | 270 | m => string.Format("{0} per second", m.GetValue()))); |
251 | 271 | ||
252 | m_monitors.Add( | 272 | m_staticMonitors.Add( |
253 | new GenericMonitor( | 273 | new GenericMonitor( |
254 | m_scene, | 274 | m_scene, |
255 | "UnackedBytesMonitor", | 275 | "UnackedBytesMonitor", |
@@ -257,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
257 | m => m.Scene.StatsReporter.LastReportedSimStats[15], | 277 | m => m.Scene.StatsReporter.LastReportedSimStats[15], |
258 | m => string.Format("{0}", m.GetValue()))); | 278 | m => string.Format("{0}", m.GetValue()))); |
259 | 279 | ||
260 | m_monitors.Add( | 280 | m_staticMonitors.Add( |
261 | new GenericMonitor( | 281 | new GenericMonitor( |
262 | m_scene, | 282 | m_scene, |
263 | "PendingDownloadsMonitor", | 283 | "PendingDownloadsMonitor", |
@@ -265,7 +285,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
265 | m => m.Scene.StatsReporter.LastReportedSimStats[17], | 285 | m => m.Scene.StatsReporter.LastReportedSimStats[17], |
266 | m => string.Format("{0}", m.GetValue()))); | 286 | m => string.Format("{0}", m.GetValue()))); |
267 | 287 | ||
268 | m_monitors.Add( | 288 | m_staticMonitors.Add( |
269 | new GenericMonitor( | 289 | new GenericMonitor( |
270 | m_scene, | 290 | m_scene, |
271 | "PendingUploadsMonitor", | 291 | "PendingUploadsMonitor", |
@@ -273,7 +293,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
273 | m => m.Scene.StatsReporter.LastReportedSimStats[18], | 293 | m => m.Scene.StatsReporter.LastReportedSimStats[18], |
274 | m => string.Format("{0}", m.GetValue()))); | 294 | m => string.Format("{0}", m.GetValue()))); |
275 | 295 | ||
276 | m_monitors.Add( | 296 | m_staticMonitors.Add( |
277 | new GenericMonitor( | 297 | new GenericMonitor( |
278 | m_scene, | 298 | m_scene, |
279 | "TotalFrameTimeMonitor", | 299 | "TotalFrameTimeMonitor", |
@@ -281,7 +301,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
281 | m => m.Scene.StatsReporter.LastReportedSimStats[8], | 301 | m => m.Scene.StatsReporter.LastReportedSimStats[8], |
282 | m => string.Format("{0} ms", m.GetValue()))); | 302 | m => string.Format("{0} ms", m.GetValue()))); |
283 | 303 | ||
284 | m_monitors.Add( | 304 | m_staticMonitors.Add( |
285 | new GenericMonitor( | 305 | new GenericMonitor( |
286 | m_scene, | 306 | m_scene, |
287 | "NetFrameTimeMonitor", | 307 | "NetFrameTimeMonitor", |
@@ -289,7 +309,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
289 | m => m.Scene.StatsReporter.LastReportedSimStats[9], | 309 | m => m.Scene.StatsReporter.LastReportedSimStats[9], |
290 | m => string.Format("{0} ms", m.GetValue()))); | 310 | m => string.Format("{0} ms", m.GetValue()))); |
291 | 311 | ||
292 | m_monitors.Add( | 312 | m_staticMonitors.Add( |
293 | new GenericMonitor( | 313 | new GenericMonitor( |
294 | m_scene, | 314 | m_scene, |
295 | "PhysicsFrameTimeMonitor", | 315 | "PhysicsFrameTimeMonitor", |
@@ -297,7 +317,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
297 | m => m.Scene.StatsReporter.LastReportedSimStats[10], | 317 | m => m.Scene.StatsReporter.LastReportedSimStats[10], |
298 | m => string.Format("{0} ms", m.GetValue()))); | 318 | m => string.Format("{0} ms", m.GetValue()))); |
299 | 319 | ||
300 | m_monitors.Add( | 320 | m_staticMonitors.Add( |
301 | new GenericMonitor( | 321 | new GenericMonitor( |
302 | m_scene, | 322 | m_scene, |
303 | "SimulationFrameTimeMonitor", | 323 | "SimulationFrameTimeMonitor", |
@@ -305,7 +325,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
305 | m => m.Scene.StatsReporter.LastReportedSimStats[12], | 325 | m => m.Scene.StatsReporter.LastReportedSimStats[12], |
306 | m => string.Format("{0} ms", m.GetValue()))); | 326 | m => string.Format("{0} ms", m.GetValue()))); |
307 | 327 | ||
308 | m_monitors.Add( | 328 | m_staticMonitors.Add( |
309 | new GenericMonitor( | 329 | new GenericMonitor( |
310 | m_scene, | 330 | m_scene, |
311 | "AgentFrameTimeMonitor", | 331 | "AgentFrameTimeMonitor", |
@@ -313,7 +333,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
313 | m => m.Scene.StatsReporter.LastReportedSimStats[16], | 333 | m => m.Scene.StatsReporter.LastReportedSimStats[16], |
314 | m => string.Format("{0} ms", m.GetValue()))); | 334 | m => string.Format("{0} ms", m.GetValue()))); |
315 | 335 | ||
316 | m_monitors.Add( | 336 | m_staticMonitors.Add( |
317 | new GenericMonitor( | 337 | new GenericMonitor( |
318 | m_scene, | 338 | m_scene, |
319 | "ImagesFrameTimeMonitor", | 339 | "ImagesFrameTimeMonitor", |
@@ -321,7 +341,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
321 | m => m.Scene.StatsReporter.LastReportedSimStats[11], | 341 | m => m.Scene.StatsReporter.LastReportedSimStats[11], |
322 | m => string.Format("{0} ms", m.GetValue()))); | 342 | m => string.Format("{0} ms", m.GetValue()))); |
323 | 343 | ||
324 | m_alerts.Add(new DeadlockAlert(m_monitors.Find(x => x is LastFrameTimeMonitor) as LastFrameTimeMonitor)); | 344 | m_alerts.Add(new DeadlockAlert(m_staticMonitors.Find(x => x is LastFrameTimeMonitor) as LastFrameTimeMonitor)); |
325 | 345 | ||
326 | foreach (IAlert alert in m_alerts) | 346 | foreach (IAlert alert in m_alerts) |
327 | { | 347 | { |
diff --git a/OpenSim/Region/CoreModules/LightShare/EnvironmentModule.cs b/OpenSim/Region/CoreModules/LightShare/EnvironmentModule.cs new file mode 100644 index 0000000..1526886 --- /dev/null +++ b/OpenSim/Region/CoreModules/LightShare/EnvironmentModule.cs | |||
@@ -0,0 +1,224 @@ | |||
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.Reflection; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Framework.Capabilities; | ||
33 | using OpenSim.Framework.Servers.HttpServer; | ||
34 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using log4net; | ||
37 | using Nini.Config; | ||
38 | using Mono.Addins; | ||
39 | |||
40 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
41 | |||
42 | |||
43 | namespace OpenSim.Region.CoreModules.World.LightShare | ||
44 | { | ||
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EnvironmentModule")] | ||
46 | |||
47 | public class EnvironmentModule : INonSharedRegionModule, IEnvironmentModule | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private Scene m_scene = null; | ||
52 | private UUID regionID = UUID.Zero; | ||
53 | private static bool Enabled = false; | ||
54 | |||
55 | private static readonly string capsName = "EnvironmentSettings"; | ||
56 | private static readonly string capsBase = "/CAPS/0020/"; | ||
57 | |||
58 | private LLSDEnvironmentSetResponse setResponse = null; | ||
59 | |||
60 | #region INonSharedRegionModule | ||
61 | public void Initialise(IConfigSource source) | ||
62 | { | ||
63 | IConfig config = source.Configs["ClientStack.LindenCaps"]; | ||
64 | |||
65 | if (null == config) | ||
66 | return; | ||
67 | |||
68 | if (config.GetString("Cap_EnvironmentSettings", String.Empty) != "localhost") | ||
69 | { | ||
70 | m_log.InfoFormat("[{0}]: Module is disabled.", Name); | ||
71 | return; | ||
72 | } | ||
73 | |||
74 | Enabled = true; | ||
75 | |||
76 | m_log.InfoFormat("[{0}]: Module is enabled.", Name); | ||
77 | } | ||
78 | |||
79 | public void Close() | ||
80 | { | ||
81 | } | ||
82 | |||
83 | public string Name | ||
84 | { | ||
85 | get { return "EnvironmentModule"; } | ||
86 | } | ||
87 | |||
88 | public Type ReplaceableInterface | ||
89 | { | ||
90 | get { return null; } | ||
91 | } | ||
92 | |||
93 | public void AddRegion(Scene scene) | ||
94 | { | ||
95 | if (!Enabled) | ||
96 | return; | ||
97 | |||
98 | scene.RegisterModuleInterface<IEnvironmentModule>(this); | ||
99 | m_scene = scene; | ||
100 | regionID = scene.RegionInfo.RegionID; | ||
101 | } | ||
102 | |||
103 | public void RegionLoaded(Scene scene) | ||
104 | { | ||
105 | if (!Enabled) | ||
106 | return; | ||
107 | |||
108 | setResponse = new LLSDEnvironmentSetResponse(); | ||
109 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
110 | } | ||
111 | |||
112 | public void RemoveRegion(Scene scene) | ||
113 | { | ||
114 | if (Enabled) | ||
115 | return; | ||
116 | |||
117 | scene.EventManager.OnRegisterCaps -= OnRegisterCaps; | ||
118 | m_scene = null; | ||
119 | } | ||
120 | #endregion | ||
121 | |||
122 | #region IEnvironmentModule | ||
123 | public void ResetEnvironmentSettings(UUID regionUUID) | ||
124 | { | ||
125 | if (!Enabled) | ||
126 | return; | ||
127 | |||
128 | m_scene.SimulationDataService.RemoveRegionEnvironmentSettings(regionUUID); | ||
129 | } | ||
130 | #endregion | ||
131 | |||
132 | #region Events | ||
133 | private void OnRegisterCaps(UUID agentID, Caps caps) | ||
134 | { | ||
135 | // m_log.DebugFormat("[{0}]: Register capability for agentID {1} in region {2}", | ||
136 | // Name, agentID, caps.RegionName); | ||
137 | |||
138 | string capsPath = capsBase + UUID.Random(); | ||
139 | |||
140 | // Get handler | ||
141 | caps.RegisterHandler( | ||
142 | capsName, | ||
143 | new RestStreamHandler( | ||
144 | "GET", | ||
145 | capsPath, | ||
146 | (request, path, param, httpRequest, httpResponse) | ||
147 | => GetEnvironmentSettings(request, path, param, agentID, caps), | ||
148 | capsName, | ||
149 | agentID.ToString())); | ||
150 | |||
151 | // Set handler | ||
152 | caps.HttpListener.AddStreamHandler( | ||
153 | new RestStreamHandler( | ||
154 | "POST", | ||
155 | capsPath, | ||
156 | (request, path, param, httpRequest, httpResponse) | ||
157 | => SetEnvironmentSettings(request, path, param, agentID, caps), | ||
158 | capsName, | ||
159 | agentID.ToString())); | ||
160 | } | ||
161 | #endregion | ||
162 | |||
163 | private string GetEnvironmentSettings(string request, string path, string param, | ||
164 | UUID agentID, Caps caps) | ||
165 | { | ||
166 | // m_log.DebugFormat("[{0}]: Environment GET handle for agentID {1} in region {2}", | ||
167 | // Name, agentID, caps.RegionName); | ||
168 | |||
169 | string env = String.Empty; | ||
170 | |||
171 | try | ||
172 | { | ||
173 | env = m_scene.SimulationDataService.LoadRegionEnvironmentSettings(regionID); | ||
174 | } | ||
175 | catch (Exception e) | ||
176 | { | ||
177 | m_log.ErrorFormat("[{0}]: Unable to load environment settings for region {1}, Exception: {2} - {3}", | ||
178 | Name, caps.RegionName, e.Message, e.StackTrace); | ||
179 | } | ||
180 | |||
181 | if (String.IsNullOrEmpty(env)) | ||
182 | env = EnvironmentSettings.EmptySettings(UUID.Zero, regionID); | ||
183 | |||
184 | return env; | ||
185 | } | ||
186 | |||
187 | private string SetEnvironmentSettings(string request, string path, string param, | ||
188 | UUID agentID, Caps caps) | ||
189 | { | ||
190 | |||
191 | // m_log.DebugFormat("[{0}]: Environment SET handle from agentID {1} in region {2}", | ||
192 | // Name, agentID, caps.RegionName); | ||
193 | |||
194 | setResponse.regionID = regionID; | ||
195 | setResponse.success = false; | ||
196 | |||
197 | if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false)) | ||
198 | { | ||
199 | setResponse.fail_reason = "Insufficient estate permissions, settings has not been saved."; | ||
200 | return LLSDHelpers.SerialiseLLSDReply(setResponse); | ||
201 | } | ||
202 | |||
203 | try | ||
204 | { | ||
205 | m_scene.SimulationDataService.StoreRegionEnvironmentSettings(regionID, request); | ||
206 | setResponse.success = true; | ||
207 | |||
208 | m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}", | ||
209 | Name, agentID, caps.RegionName); | ||
210 | } | ||
211 | catch (Exception e) | ||
212 | { | ||
213 | m_log.ErrorFormat("[{0}]: Environment settings has not been saved for region {1}, Exception: {2} - {3}", | ||
214 | Name, caps.RegionName, e.Message, e.StackTrace); | ||
215 | |||
216 | setResponse.success = false; | ||
217 | setResponse.fail_reason = String.Format("Environment Set for region {0} has failed, settings has not been saved.", caps.RegionName); | ||
218 | } | ||
219 | |||
220 | return LLSDHelpers.SerialiseLLSDReply(setResponse); | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | |||
diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index 9255791..e91e8b9 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs | |||
@@ -64,6 +64,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
64 | private TimeSpan m_QueueTimeout = new TimeSpan(2, 0, 0); // 2 hours without llGetNextEmail drops the queue | 64 | private TimeSpan m_QueueTimeout = new TimeSpan(2, 0, 0); // 2 hours without llGetNextEmail drops the queue |
65 | private string m_InterObjectHostname = "lsl.opensim.local"; | 65 | private string m_InterObjectHostname = "lsl.opensim.local"; |
66 | 66 | ||
67 | private int m_MaxEmailSize = 4096; // largest email allowed by default, as per lsl docs. | ||
68 | |||
67 | // Scenes by Region Handle | 69 | // Scenes by Region Handle |
68 | private Dictionary<ulong, Scene> m_Scenes = | 70 | private Dictionary<ulong, Scene> m_Scenes = |
69 | new Dictionary<ulong, Scene>(); | 71 | new Dictionary<ulong, Scene>(); |
@@ -127,6 +129,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
127 | SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); | 129 | SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); |
128 | SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); | 130 | SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); |
129 | SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); | 131 | SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); |
132 | m_MaxEmailSize = SMTPConfig.GetInt("email_max_size", m_MaxEmailSize); | ||
130 | } | 133 | } |
131 | catch (Exception e) | 134 | catch (Exception e) |
132 | { | 135 | { |
@@ -176,18 +179,6 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
176 | get { return true; } | 179 | get { return true; } |
177 | } | 180 | } |
178 | 181 | ||
179 | /// <summary> | ||
180 | /// Delay function using thread in seconds | ||
181 | /// </summary> | ||
182 | /// <param name="seconds"></param> | ||
183 | private void DelayInSeconds(int delay) | ||
184 | { | ||
185 | delay = (int)((float)delay * 1000); | ||
186 | if (delay == 0) | ||
187 | return; | ||
188 | System.Threading.Thread.Sleep(delay); | ||
189 | } | ||
190 | |||
191 | private bool IsLocal(UUID objectID) | 182 | private bool IsLocal(UUID objectID) |
192 | { | 183 | { |
193 | string unused; | 184 | string unused; |
@@ -267,10 +258,9 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
267 | m_log.Error("[EMAIL] REGEX Problem in EMail Address: "+address); | 258 | m_log.Error("[EMAIL] REGEX Problem in EMail Address: "+address); |
268 | return; | 259 | return; |
269 | } | 260 | } |
270 | //FIXME:Check if subject + body = 4096 Byte | 261 | if ((subject.Length + body.Length) > m_MaxEmailSize) |
271 | if ((subject.Length + body.Length) > 1024) | ||
272 | { | 262 | { |
273 | m_log.Error("[EMAIL] subject + body > 1024 Byte"); | 263 | m_log.Error("[EMAIL] subject + body larger than limit of " + m_MaxEmailSize + " bytes"); |
274 | return; | 264 | return; |
275 | } | 265 | } |
276 | 266 | ||
@@ -345,10 +335,6 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
345 | // TODO FIX | 335 | // TODO FIX |
346 | } | 336 | } |
347 | } | 337 | } |
348 | |||
349 | //DONE: Message as Second Life style | ||
350 | //20 second delay - AntiSpam System - for now only 10 seconds | ||
351 | DelayInSeconds(10); | ||
352 | } | 338 | } |
353 | 339 | ||
354 | /// <summary> | 340 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index f4cf6b4..1865ab8 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | |||
@@ -85,6 +85,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
85 | private IHttpServer m_HttpsServer = null; | 85 | private IHttpServer m_HttpsServer = null; |
86 | 86 | ||
87 | private string m_ExternalHostNameForLSL = ""; | 87 | private string m_ExternalHostNameForLSL = ""; |
88 | public string ExternalHostNameForLSL | ||
89 | { | ||
90 | get { return m_ExternalHostNameForLSL; } | ||
91 | } | ||
88 | 92 | ||
89 | public Type ReplaceableInterface | 93 | public Type ReplaceableInterface |
90 | { | 94 | { |
@@ -147,6 +151,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
147 | public void Close() | 151 | public void Close() |
148 | { | 152 | { |
149 | } | 153 | } |
154 | |||
150 | public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID) | 155 | public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID) |
151 | { | 156 | { |
152 | UUID urlcode = UUID.Random(); | 157 | UUID urlcode = UUID.Random(); |
@@ -176,6 +181,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
176 | uri, | 181 | uri, |
177 | new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); | 182 | new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); |
178 | 183 | ||
184 | m_log.DebugFormat( | ||
185 | "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}", | ||
186 | uri, itemID, host.Name, host.LocalId); | ||
187 | |||
179 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); | 188 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); |
180 | } | 189 | } |
181 | 190 | ||
@@ -218,6 +227,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
218 | uri, | 227 | uri, |
219 | new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); | 228 | new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); |
220 | 229 | ||
230 | m_log.DebugFormat( | ||
231 | "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", | ||
232 | uri, itemID, host.Name, host.LocalId); | ||
233 | |||
221 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); | 234 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); |
222 | } | 235 | } |
223 | 236 | ||
@@ -241,6 +254,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
241 | m_RequestMap.Remove(req); | 254 | m_RequestMap.Remove(req); |
242 | } | 255 | } |
243 | 256 | ||
257 | // m_log.DebugFormat( | ||
258 | // "[URL MODULE]: Releasing url {0} for {1} in {2}", | ||
259 | // url, data.itemID, data.hostID); | ||
260 | |||
244 | RemoveUrl(data); | 261 | RemoveUrl(data); |
245 | m_UrlMap.Remove(url); | 262 | m_UrlMap.Remove(url); |
246 | } | 263 | } |
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 176c86d..8358bc0 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | |||
@@ -308,56 +308,56 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
308 | /// <param name='msg'> | 308 | /// <param name='msg'> |
309 | /// Message. | 309 | /// Message. |
310 | /// </param> | 310 | /// </param> |
311 | public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) | 311 | public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) |
312 | { | 312 | { |
313 | error = null; | ||
314 | // Is id an avatar? | 313 | // Is id an avatar? |
315 | ScenePresence sp = m_scene.GetScenePresence(target); | 314 | ScenePresence sp = m_scene.GetScenePresence(target); |
316 | 315 | ||
317 | if (sp != null) | 316 | if (sp != null) |
318 | { | 317 | { |
319 | // Send message to avatar | 318 | // ignore if a child agent this is restricted to inside one region |
319 | if (sp.IsChildAgent) | ||
320 | return; | ||
321 | |||
322 | // Send message to the avatar. | ||
323 | // Channel zero only goes to the avatar | ||
324 | // non zero channel messages only go to the attachments | ||
320 | if (channel == 0) | 325 | if (channel == 0) |
321 | { | 326 | { |
322 | m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false); | 327 | m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false); |
323 | } | 328 | } |
324 | 329 | else | |
325 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
326 | |||
327 | if (attachments.Count == 0) | ||
328 | return true; | ||
329 | |||
330 | // Get uuid of attachments | ||
331 | List<UUID> targets = new List<UUID>(); | ||
332 | foreach (SceneObjectGroup sog in attachments) | ||
333 | { | 330 | { |
334 | if (!sog.IsDeleted) | 331 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
335 | targets.Add(sog.UUID); | 332 | if (attachments.Count == 0) |
336 | } | 333 | return; |
337 | 334 | ||
338 | // Need to check each attachment | 335 | // Get uuid of attachments |
339 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | 336 | List<UUID> targets = new List<UUID>(); |
340 | { | 337 | foreach (SceneObjectGroup sog in attachments) |
341 | if (li.GetHostID().Equals(id)) | 338 | { |
342 | continue; | 339 | if (!sog.IsDeleted) |
340 | targets.Add(sog.UUID); | ||
341 | } | ||
343 | 342 | ||
344 | if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) | 343 | // Need to check each attachment |
345 | continue; | 344 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) |
345 | { | ||
346 | if (li.GetHostID().Equals(id)) | ||
347 | continue; | ||
346 | 348 | ||
347 | if (targets.Contains(li.GetHostID())) | 349 | if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) |
348 | QueueMessage(new ListenerInfo(li, name, id, msg)); | 350 | continue; |
349 | } | ||
350 | 351 | ||
351 | return true; | 352 | if (targets.Contains(li.GetHostID())) |
352 | } | 353 | QueueMessage(new ListenerInfo(li, name, id, msg)); |
354 | } | ||
355 | } | ||
353 | 356 | ||
354 | // Need to toss an error here | 357 | return; |
355 | if (channel == 0) | ||
356 | { | ||
357 | error = "Cannot use llRegionSayTo to message objects on channel 0"; | ||
358 | return false; | ||
359 | } | 358 | } |
360 | 359 | ||
360 | // No avatar found so look for an object | ||
361 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | 361 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) |
362 | { | 362 | { |
363 | // Dont process if this message is from yourself! | 363 | // Dont process if this message is from yourself! |
@@ -375,7 +375,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
375 | } | 375 | } |
376 | } | 376 | } |
377 | 377 | ||
378 | return true; | 378 | return; |
379 | } | 379 | } |
380 | 380 | ||
381 | protected void QueueMessage(ListenerInfo li) | 381 | protected void QueueMessage(ListenerInfo li) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs index 8df1c7b..a7dd0dd 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs | |||
@@ -122,7 +122,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid | |||
122 | ISimulationService simService = scene.RequestModuleInterface<ISimulationService>(); | 122 | ISimulationService simService = scene.RequestModuleInterface<ISimulationService>(); |
123 | IFriendsSimConnector friendsConn = scene.RequestModuleInterface<IFriendsSimConnector>(); | 123 | IFriendsSimConnector friendsConn = scene.RequestModuleInterface<IFriendsSimConnector>(); |
124 | Object[] args = new Object[] { m_Config }; | 124 | Object[] args = new Object[] { m_Config }; |
125 | IFriendsService friendsService = ServerUtils.LoadPlugin<IFriendsService>(m_LocalServiceDll, args); | 125 | // IFriendsService friendsService = ServerUtils.LoadPlugin<IFriendsService>(m_LocalServiceDll, args) |
126 | ServerUtils.LoadPlugin<IFriendsService>(m_LocalServiceDll, args); | ||
126 | 127 | ||
127 | m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService); | 128 | m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService); |
128 | 129 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs index 8395f83..008465f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs | |||
@@ -149,7 +149,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
149 | 149 | ||
150 | m_aScene = scene; | 150 | m_aScene = scene; |
151 | 151 | ||
152 | scene.RegisterModuleInterface<IAssetService>(this); | 152 | m_aScene.RegisterModuleInterface<IAssetService>(this); |
153 | } | 153 | } |
154 | 154 | ||
155 | public void RemoveRegion(Scene scene) | 155 | public void RemoveRegion(Scene scene) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs index f0d21e6..4470799 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs | |||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | |||
55 | MethodBase.GetCurrentMethod().DeclaringType); | 55 | MethodBase.GetCurrentMethod().DeclaringType); |
56 | 56 | ||
57 | private IUserManagement m_UserManagement; | 57 | private IUserManagement m_UserManagement; |
58 | private IGridService m_GridService; | 58 | // private IGridService m_GridService; |
59 | 59 | ||
60 | private Scene m_Scene; | 60 | private Scene m_Scene; |
61 | AccessFlags m_accessValue = AccessFlags.None; | 61 | AccessFlags m_accessValue = AccessFlags.None; |
@@ -65,7 +65,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | |||
65 | { | 65 | { |
66 | m_Scene = scene; | 66 | m_Scene = scene; |
67 | m_UserManagement = scene.RequestModuleInterface<IUserManagement>(); | 67 | m_UserManagement = scene.RequestModuleInterface<IUserManagement>(); |
68 | m_GridService = scene.GridService; | 68 | // m_GridService = scene.GridService; |
69 | 69 | ||
70 | if (config != null) | 70 | if (config != null) |
71 | { | 71 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 3b862da..6cd077a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | |||
@@ -149,9 +149,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
149 | lock (m_scenes) | 149 | lock (m_scenes) |
150 | m_scenes[scene.RegionInfo.RegionID] = scene; | 150 | m_scenes[scene.RegionInfo.RegionID] = scene; |
151 | 151 | ||
152 | scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); | 152 | scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; |
153 | } | 153 | } |
154 | 154 | ||
155 | |||
155 | ///<summary> | 156 | ///<summary> |
156 | /// | 157 | /// |
157 | ///</summary> | 158 | ///</summary> |
@@ -166,9 +167,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
166 | 167 | ||
167 | #endregion ISharedRegionModule | 168 | #endregion ISharedRegionModule |
168 | 169 | ||
169 | void EventManager_OnPrimsLoaded(Scene s) | 170 | void OnLoginsEnabled(string regionName) |
170 | { | 171 | { |
171 | UploadMapTile(s); | 172 | Scene scene = null; |
173 | foreach (Scene s in m_scenes.Values) | ||
174 | if (s.RegionInfo.RegionName == regionName) | ||
175 | { | ||
176 | scene = s; | ||
177 | break; | ||
178 | } | ||
179 | if (scene != null) | ||
180 | UploadMapTile(scene); | ||
172 | } | 181 | } |
173 | 182 | ||
174 | 183 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 6e75692..008992e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Linq; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using log4net; | 31 | using log4net; |
31 | using Nini.Config; | 32 | using Nini.Config; |
@@ -41,22 +42,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
41 | public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService | 42 | public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService |
42 | { | 43 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | // Version of this service | ||
45 | private const string m_Version = "SIMULATION/0.1"; | ||
46 | 45 | ||
47 | private List<Scene> m_sceneList = new List<Scene>(); | 46 | /// <summary> |
47 | /// Version of this service | ||
48 | /// </summary> | ||
49 | private const string m_Version = "SIMULATION/0.1"; | ||
48 | 50 | ||
49 | private IEntityTransferModule m_AgentTransferModule; | 51 | /// <summary> |
50 | protected IEntityTransferModule AgentTransferModule | 52 | /// Map region ID to scene. |
51 | { | 53 | /// </summary> |
52 | get | 54 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); |
53 | { | ||
54 | if (m_AgentTransferModule == null) | ||
55 | m_AgentTransferModule = m_sceneList[0].RequestModuleInterface<IEntityTransferModule>(); | ||
56 | return m_AgentTransferModule; | ||
57 | } | ||
58 | } | ||
59 | 55 | ||
56 | /// <summary> | ||
57 | /// Is this module enabled? | ||
58 | /// </summary> | ||
60 | private bool m_ModuleEnabled = false; | 59 | private bool m_ModuleEnabled = false; |
61 | 60 | ||
62 | #region IRegionModule | 61 | #region IRegionModule |
@@ -129,12 +128,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
129 | /// <param name="scene"></param> | 128 | /// <param name="scene"></param> |
130 | public void RemoveScene(Scene scene) | 129 | public void RemoveScene(Scene scene) |
131 | { | 130 | { |
132 | lock (m_sceneList) | 131 | lock (m_scenes) |
133 | { | 132 | { |
134 | if (m_sceneList.Contains(scene)) | 133 | if (m_scenes.ContainsKey(scene.RegionInfo.RegionID)) |
135 | { | 134 | m_scenes.Remove(scene.RegionInfo.RegionID); |
136 | m_sceneList.Remove(scene); | 135 | else |
137 | } | 136 | m_log.WarnFormat( |
137 | "[LOCAL SIMULATION CONNECTOR]: Tried to remove region {0} but it was not present", | ||
138 | scene.RegionInfo.RegionName); | ||
138 | } | 139 | } |
139 | } | 140 | } |
140 | 141 | ||
@@ -144,13 +145,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
144 | /// <param name="scene"></param> | 145 | /// <param name="scene"></param> |
145 | public void Init(Scene scene) | 146 | public void Init(Scene scene) |
146 | { | 147 | { |
147 | if (!m_sceneList.Contains(scene)) | 148 | lock (m_scenes) |
148 | { | 149 | { |
149 | lock (m_sceneList) | 150 | if (!m_scenes.ContainsKey(scene.RegionInfo.RegionID)) |
150 | { | 151 | m_scenes[scene.RegionInfo.RegionID] = scene; |
151 | m_sceneList.Add(scene); | 152 | else |
152 | } | 153 | m_log.WarnFormat( |
153 | 154 | "[LOCAL SIMULATION CONNECTOR]: Tried to add region {0} but it is already present", | |
155 | scene.RegionInfo.RegionName); | ||
154 | } | 156 | } |
155 | } | 157 | } |
156 | 158 | ||
@@ -158,15 +160,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
158 | 160 | ||
159 | #region ISimulation | 161 | #region ISimulation |
160 | 162 | ||
161 | public IScene GetScene(ulong regionhandle) | 163 | public IScene GetScene(UUID regionId) |
162 | { | 164 | { |
163 | foreach (Scene s in m_sceneList) | 165 | if (m_scenes.ContainsKey(regionId)) |
164 | { | 166 | { |
165 | if (s.RegionInfo.RegionHandle == regionhandle) | 167 | return m_scenes[regionId]; |
166 | return s; | 168 | } |
169 | else | ||
170 | { | ||
171 | // FIXME: This was pre-existing behaviour but possibly not a good idea, since it hides an error rather | ||
172 | // than making it obvious and fixable. Need to see if the error message comes up in practice. | ||
173 | Scene s = m_scenes.Values.ToArray()[0]; | ||
174 | |||
175 | m_log.ErrorFormat( | ||
176 | "[LOCAL SIMULATION CONNECTOR]: Region with id {0} not found. Returning {1} {2} instead", | ||
177 | regionId, s.RegionInfo.RegionName, s.RegionInfo.RegionID); | ||
178 | |||
179 | return s; | ||
167 | } | 180 | } |
168 | // ? weird. should not happen | ||
169 | return m_sceneList[0]; | ||
170 | } | 181 | } |
171 | 182 | ||
172 | public ISimulationService GetInnerService() | 183 | public ISimulationService GetInnerService() |
@@ -187,13 +198,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
187 | return false; | 198 | return false; |
188 | } | 199 | } |
189 | 200 | ||
190 | foreach (Scene s in m_sceneList) | 201 | if (m_scenes.ContainsKey(destination.RegionID)) |
191 | { | 202 | { |
192 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | 203 | // m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName); |
193 | { | 204 | return m_scenes[destination.RegionID].NewUserConnection(aCircuit, teleportFlags, out reason); |
194 | m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName); | ||
195 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); | ||
196 | } | ||
197 | } | 205 | } |
198 | 206 | ||
199 | reason = "Did not find region " + destination.RegionName; | 207 | reason = "Did not find region " + destination.RegionName; |
@@ -205,17 +213,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
205 | if (destination == null) | 213 | if (destination == null) |
206 | return false; | 214 | return false; |
207 | 215 | ||
208 | foreach (Scene s in m_sceneList) | 216 | if (m_scenes.ContainsKey(destination.RegionID)) |
209 | { | 217 | { |
210 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | 218 | // m_log.DebugFormat( |
211 | { | 219 | // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", |
212 | m_log.DebugFormat( | 220 | // s.RegionInfo.RegionName, destination.RegionHandle); |
213 | "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", | ||
214 | s.RegionInfo.RegionName, destination.RegionHandle); | ||
215 | 221 | ||
216 | s.IncomingChildAgentDataUpdate(cAgentData); | 222 | return m_scenes[destination.RegionID].IncomingChildAgentDataUpdate(cAgentData); |
217 | return true; | ||
218 | } | ||
219 | } | 223 | } |
220 | 224 | ||
221 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); | 225 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); |
@@ -231,11 +235,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
231 | // simulator so when we receive the update we need to hand it to each of the | 235 | // simulator so when we receive the update we need to hand it to each of the |
232 | // scenes; scenes each check to see if the is a scene presence for the avatar | 236 | // scenes; scenes each check to see if the is a scene presence for the avatar |
233 | // note that we really don't need the GridRegion for this call | 237 | // note that we really don't need the GridRegion for this call |
234 | foreach (Scene s in m_sceneList) | 238 | foreach (Scene s in m_scenes.Values) |
235 | { | 239 | { |
236 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | 240 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); |
237 | s.IncomingChildAgentDataUpdate(cAgentData); | 241 | s.IncomingChildAgentDataUpdate(cAgentData); |
238 | } | 242 | } |
243 | |||
239 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | 244 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); |
240 | return true; | 245 | return true; |
241 | } | 246 | } |
@@ -247,14 +252,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
247 | if (destination == null) | 252 | if (destination == null) |
248 | return false; | 253 | return false; |
249 | 254 | ||
250 | foreach (Scene s in m_sceneList) | 255 | if (m_scenes.ContainsKey(destination.RegionID)) |
251 | { | 256 | { |
252 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | 257 | // m_log.DebugFormat( |
253 | { | 258 | // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", |
254 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | 259 | // s.RegionInfo.RegionName, destination.RegionHandle); |
255 | return s.IncomingRetrieveRootAgent(id, out agent); | 260 | |
256 | } | 261 | return m_scenes[destination.RegionID].IncomingRetrieveRootAgent(id, out agent); |
257 | } | 262 | } |
263 | |||
258 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | 264 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); |
259 | return false; | 265 | return false; |
260 | } | 266 | } |
@@ -266,59 +272,49 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
266 | if (destination == null) | 272 | if (destination == null) |
267 | return false; | 273 | return false; |
268 | 274 | ||
269 | foreach (Scene s in m_sceneList) | 275 | if (m_scenes.ContainsKey(destination.RegionID)) |
270 | { | 276 | { |
271 | if (s.RegionInfo.RegionID == destination.RegionID) | 277 | // m_log.DebugFormat( |
272 | return s.QueryAccess(id, position, out reason); | 278 | // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", |
279 | // s.RegionInfo.RegionName, destination.RegionHandle); | ||
280 | |||
281 | return m_scenes[destination.RegionID].QueryAccess(id, position, out reason); | ||
273 | } | 282 | } |
283 | |||
284 | //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess"); | ||
274 | return false; | 285 | return false; |
275 | } | 286 | } |
276 | 287 | ||
277 | public bool ReleaseAgent(UUID origin, UUID id, string uri) | 288 | public bool ReleaseAgent(UUID originId, UUID agentId, string uri) |
278 | { | 289 | { |
279 | foreach (Scene s in m_sceneList) | 290 | if (m_scenes.ContainsKey(originId)) |
280 | { | 291 | { |
281 | if (s.RegionInfo.RegionID == origin) | 292 | // m_log.DebugFormat( |
282 | { | 293 | // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", |
283 | m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); | 294 | // s.RegionInfo.RegionName, destination.RegionHandle); |
284 | AgentTransferModule.AgentArrivedAtDestination(id); | 295 | |
285 | return true; | 296 | m_scenes[originId].EntityTransferModule.AgentArrivedAtDestination(agentId); |
286 | // return s.IncomingReleaseAgent(id); | 297 | return true; |
287 | } | ||
288 | } | 298 | } |
299 | |||
289 | //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent " + origin); | 300 | //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent " + origin); |
290 | return false; | 301 | return false; |
291 | } | 302 | } |
292 | 303 | ||
293 | public bool CloseAgent(GridRegion destination, UUID id) | 304 | public bool CloseChildAgent(GridRegion destination, UUID id) |
294 | { | 305 | { |
295 | if (destination == null) | 306 | return CloseAgent(destination, id); |
296 | return false; | ||
297 | |||
298 | foreach (Scene s in m_sceneList) | ||
299 | { | ||
300 | if (s.RegionInfo.RegionID == destination.RegionID) | ||
301 | { | ||
302 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); | ||
303 | return s.IncomingCloseAgent(id); | ||
304 | } | ||
305 | } | ||
306 | //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); | ||
307 | return false; | ||
308 | } | 307 | } |
309 | 308 | ||
310 | public bool CloseChildAgent(GridRegion destination, UUID id) | 309 | public bool CloseAgent(GridRegion destination, UUID id) |
311 | { | 310 | { |
312 | if (destination == null) | 311 | if (destination == null) |
313 | return false; | 312 | return false; |
314 | 313 | ||
315 | foreach (Scene s in m_sceneList) | 314 | if (m_scenes.ContainsKey(destination.RegionID)) |
316 | { | 315 | { |
317 | if (s.RegionInfo.RegionID == destination.RegionID) | 316 | Util.FireAndForget(delegate { m_scenes[destination.RegionID].IncomingCloseAgent(id); }); |
318 | { | 317 | return true; |
319 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); | ||
320 | return s.IncomingCloseChildAgent(id); | ||
321 | } | ||
322 | } | 318 | } |
323 | //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); | 319 | //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); |
324 | return false; | 320 | return false; |
@@ -333,25 +329,28 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
333 | if (destination == null) | 329 | if (destination == null) |
334 | return false; | 330 | return false; |
335 | 331 | ||
336 | foreach (Scene s in m_sceneList) | 332 | if (m_scenes.ContainsKey(destination.RegionID)) |
337 | { | 333 | { |
338 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | 334 | // m_log.DebugFormat( |
335 | // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", | ||
336 | // s.RegionInfo.RegionName, destination.RegionHandle); | ||
337 | |||
338 | Scene s = m_scenes[destination.RegionID]; | ||
339 | |||
340 | if (isLocalCall) | ||
341 | { | ||
342 | // We need to make a local copy of the object | ||
343 | ISceneObject sogClone = sog.CloneForNewScene(); | ||
344 | sogClone.SetState(sog.GetStateSnapshot(), s); | ||
345 | return s.IncomingCreateObject(newPosition, sogClone); | ||
346 | } | ||
347 | else | ||
339 | { | 348 | { |
340 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); | 349 | // Use the object as it came through the wire |
341 | if (isLocalCall) | 350 | return s.IncomingCreateObject(newPosition, sog); |
342 | { | ||
343 | // We need to make a local copy of the object | ||
344 | ISceneObject sogClone = sog.CloneForNewScene(); | ||
345 | sogClone.SetState(sog.GetStateSnapshot(), s); | ||
346 | return s.IncomingCreateObject(newPosition, sogClone); | ||
347 | } | ||
348 | else | ||
349 | { | ||
350 | // Use the object as it came through the wire | ||
351 | return s.IncomingCreateObject(newPosition, sog); | ||
352 | } | ||
353 | } | 351 | } |
354 | } | 352 | } |
353 | |||
355 | return false; | 354 | return false; |
356 | } | 355 | } |
357 | 356 | ||
@@ -360,13 +359,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
360 | if (destination == null) | 359 | if (destination == null) |
361 | return false; | 360 | return false; |
362 | 361 | ||
363 | foreach (Scene s in m_sceneList) | 362 | if (m_scenes.ContainsKey(destination.RegionID)) |
364 | { | 363 | { |
365 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | 364 | // m_log.DebugFormat( |
366 | { | 365 | // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", |
367 | return s.IncomingCreateObject(userID, itemID); | 366 | // s.RegionInfo.RegionName, destination.RegionHandle); |
368 | } | 367 | |
368 | return m_scenes[destination.RegionID].IncomingCreateObject(userID, itemID); | ||
369 | } | 369 | } |
370 | |||
370 | return false; | 371 | return false; |
371 | } | 372 | } |
372 | 373 | ||
@@ -377,18 +378,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
377 | 378 | ||
378 | public bool IsLocalRegion(ulong regionhandle) | 379 | public bool IsLocalRegion(ulong regionhandle) |
379 | { | 380 | { |
380 | foreach (Scene s in m_sceneList) | 381 | foreach (Scene s in m_scenes.Values) |
381 | if (s.RegionInfo.RegionHandle == regionhandle) | 382 | if (s.RegionInfo.RegionHandle == regionhandle) |
382 | return true; | 383 | return true; |
384 | |||
383 | return false; | 385 | return false; |
384 | } | 386 | } |
385 | 387 | ||
386 | public bool IsLocalRegion(UUID id) | 388 | public bool IsLocalRegion(UUID id) |
387 | { | 389 | { |
388 | foreach (Scene s in m_sceneList) | 390 | return m_scenes.ContainsKey(id); |
389 | if (s.RegionInfo.RegionID == id) | ||
390 | return true; | ||
391 | return false; | ||
392 | } | 391 | } |
393 | 392 | ||
394 | #endregion | 393 | #endregion |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 4b70692..d395413 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | |||
@@ -151,9 +151,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
151 | 151 | ||
152 | #region IInterregionComms | 152 | #region IInterregionComms |
153 | 153 | ||
154 | public IScene GetScene(ulong handle) | 154 | public IScene GetScene(UUID regionId) |
155 | { | 155 | { |
156 | return m_localBackend.GetScene(handle); | 156 | return m_localBackend.GetScene(regionId); |
157 | } | 157 | } |
158 | 158 | ||
159 | public ISimulationService GetInnerService() | 159 | public ISimulationService GetInnerService() |
@@ -226,13 +226,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
226 | return m_remoteConnector.RetrieveAgent(destination, id, out agent); | 226 | return m_remoteConnector.RetrieveAgent(destination, id, out agent); |
227 | 227 | ||
228 | return false; | 228 | return false; |
229 | |||
230 | } | 229 | } |
231 | 230 | ||
232 | public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason) | 231 | public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason) |
233 | { | 232 | { |
234 | reason = "Communications failure"; | 233 | reason = "Communications failure"; |
235 | version = "Unknown"; | 234 | version = "Unknown"; |
235 | |||
236 | if (destination == null) | 236 | if (destination == null) |
237 | return false; | 237 | return false; |
238 | 238 | ||
@@ -245,7 +245,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
245 | return m_remoteConnector.QueryAccess(destination, id, position, out version, out reason); | 245 | return m_remoteConnector.QueryAccess(destination, id, position, out version, out reason); |
246 | 246 | ||
247 | return false; | 247 | return false; |
248 | |||
249 | } | 248 | } |
250 | 249 | ||
251 | public bool ReleaseAgent(UUID origin, UUID id, string uri) | 250 | public bool ReleaseAgent(UUID origin, UUID id, string uri) |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 38db239..619550c 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -41,6 +41,7 @@ using OpenSim.Framework.Serialization.External; | |||
41 | using OpenSim.Region.CoreModules.World.Terrain; | 41 | using OpenSim.Region.CoreModules.World.Terrain; |
42 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
44 | using OpenSim.Services.Interfaces; | 45 | using OpenSim.Services.Interfaces; |
45 | 46 | ||
46 | namespace OpenSim.Region.CoreModules.World.Archiver | 47 | namespace OpenSim.Region.CoreModules.World.Archiver |
@@ -245,6 +246,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
245 | // Reload serialized prims | 246 | // Reload serialized prims |
246 | m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); | 247 | m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); |
247 | 248 | ||
249 | UUID oldTelehubUUID = m_scene.RegionInfo.RegionSettings.TelehubObject; | ||
250 | |||
248 | IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface<IRegionSerialiserModule>(); | 251 | IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface<IRegionSerialiserModule>(); |
249 | int sceneObjectsLoadedCount = 0; | 252 | int sceneObjectsLoadedCount = 0; |
250 | 253 | ||
@@ -266,11 +269,21 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
266 | 269 | ||
267 | SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject); | 270 | SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject); |
268 | 271 | ||
272 | bool isTelehub = (sceneObject.UUID == oldTelehubUUID); | ||
273 | |||
269 | // For now, give all incoming scene objects new uuids. This will allow scenes to be cloned | 274 | // For now, give all incoming scene objects new uuids. This will allow scenes to be cloned |
270 | // on the same region server and multiple examples a single object archive to be imported | 275 | // on the same region server and multiple examples a single object archive to be imported |
271 | // to the same scene (when this is possible). | 276 | // to the same scene (when this is possible). |
272 | sceneObject.ResetIDs(); | 277 | sceneObject.ResetIDs(); |
273 | 278 | ||
279 | if (isTelehub) | ||
280 | { | ||
281 | // Change the Telehub Object to the new UUID | ||
282 | m_scene.RegionInfo.RegionSettings.TelehubObject = sceneObject.UUID; | ||
283 | m_scene.RegionInfo.RegionSettings.Save(); | ||
284 | oldTelehubUUID = UUID.Zero; | ||
285 | } | ||
286 | |||
274 | // Try to retain the original creator/owner/lastowner if their uuid is present on this grid | 287 | // Try to retain the original creator/owner/lastowner if their uuid is present on this grid |
275 | // or creator data is present. Otherwise, use the estate owner instead. | 288 | // or creator data is present. Otherwise, use the estate owner instead. |
276 | foreach (SceneObjectPart part in sceneObject.Parts) | 289 | foreach (SceneObjectPart part in sceneObject.Parts) |
@@ -347,7 +360,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
347 | int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount; | 360 | int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount; |
348 | 361 | ||
349 | if (ignoredObjects > 0) | 362 | if (ignoredObjects > 0) |
350 | m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects); | 363 | m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects); |
364 | |||
365 | if (oldTelehubUUID != UUID.Zero) | ||
366 | { | ||
367 | m_log.WarnFormat("Telehub object not found: {0}", oldTelehubUUID); | ||
368 | m_scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; | ||
369 | m_scene.RegionInfo.RegionSettings.ClearSpawnPoints(); | ||
370 | } | ||
351 | } | 371 | } |
352 | 372 | ||
353 | /// <summary> | 373 | /// <summary> |
@@ -523,6 +543,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
523 | currentRegionSettings.TerrainTexture4 = loadedRegionSettings.TerrainTexture4; | 543 | currentRegionSettings.TerrainTexture4 = loadedRegionSettings.TerrainTexture4; |
524 | currentRegionSettings.UseEstateSun = loadedRegionSettings.UseEstateSun; | 544 | currentRegionSettings.UseEstateSun = loadedRegionSettings.UseEstateSun; |
525 | currentRegionSettings.WaterHeight = loadedRegionSettings.WaterHeight; | 545 | currentRegionSettings.WaterHeight = loadedRegionSettings.WaterHeight; |
546 | currentRegionSettings.TelehubObject = loadedRegionSettings.TelehubObject; | ||
547 | currentRegionSettings.ClearSpawnPoints(); | ||
548 | foreach (SpawnPoint sp in loadedRegionSettings.SpawnPoints()) | ||
549 | currentRegionSettings.AddSpawnPoint(sp); | ||
526 | 550 | ||
527 | currentRegionSettings.Save(); | 551 | currentRegionSettings.Save(); |
528 | 552 | ||
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 4d459bf..4edaaca 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs | |||
@@ -40,6 +40,9 @@ using OpenSim.Framework.Serialization; | |||
40 | using OpenSim.Region.CoreModules.World.Terrain; | 40 | using OpenSim.Region.CoreModules.World.Terrain; |
41 | using OpenSim.Region.Framework.Interfaces; | 41 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
43 | using Ionic.Zlib; | ||
44 | using GZipStream = Ionic.Zlib.GZipStream; | ||
45 | using CompressionMode = Ionic.Zlib.CompressionMode; | ||
43 | 46 | ||
44 | namespace OpenSim.Region.CoreModules.World.Archiver | 47 | namespace OpenSim.Region.CoreModules.World.Archiver |
45 | { | 48 | { |
@@ -64,7 +67,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
64 | /// Determine whether this archive will save assets. Default is true. | 67 | /// Determine whether this archive will save assets. Default is true. |
65 | /// </summary> | 68 | /// </summary> |
66 | public bool SaveAssets { get; set; } | 69 | public bool SaveAssets { get; set; } |
67 | 70 | ||
71 | protected ArchiverModule m_module; | ||
68 | protected Scene m_scene; | 72 | protected Scene m_scene; |
69 | protected Stream m_saveStream; | 73 | protected Stream m_saveStream; |
70 | protected Guid m_requestId; | 74 | protected Guid m_requestId; |
@@ -72,17 +76,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
72 | /// <summary> | 76 | /// <summary> |
73 | /// Constructor | 77 | /// Constructor |
74 | /// </summary> | 78 | /// </summary> |
75 | /// <param name="scene"></param> | 79 | /// <param name="module">Calling module</param> |
76 | /// <param name="savePath">The path to which to save data.</param> | 80 | /// <param name="savePath">The path to which to save data.</param> |
77 | /// <param name="requestId">The id associated with this request</param> | 81 | /// <param name="requestId">The id associated with this request</param> |
78 | /// <exception cref="System.IO.IOException"> | 82 | /// <exception cref="System.IO.IOException"> |
79 | /// If there was a problem opening a stream for the file specified by the savePath | 83 | /// If there was a problem opening a stream for the file specified by the savePath |
80 | /// </exception> | 84 | /// </exception> |
81 | public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId) : this(scene, requestId) | 85 | public ArchiveWriteRequestPreparation(ArchiverModule module, string savePath, Guid requestId) : this(module, requestId) |
82 | { | 86 | { |
83 | try | 87 | try |
84 | { | 88 | { |
85 | m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress); | 89 | m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress, CompressionLevel.BestCompression); |
86 | } | 90 | } |
87 | catch (EntryPointNotFoundException e) | 91 | catch (EntryPointNotFoundException e) |
88 | { | 92 | { |
@@ -96,17 +100,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
96 | /// <summary> | 100 | /// <summary> |
97 | /// Constructor. | 101 | /// Constructor. |
98 | /// </summary> | 102 | /// </summary> |
99 | /// <param name="scene"></param> | 103 | /// <param name="module">Calling module</param> |
100 | /// <param name="saveStream">The stream to which to save data.</param> | 104 | /// <param name="saveStream">The stream to which to save data.</param> |
101 | /// <param name="requestId">The id associated with this request</param> | 105 | /// <param name="requestId">The id associated with this request</param> |
102 | public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream, Guid requestId) : this(scene, requestId) | 106 | public ArchiveWriteRequestPreparation(ArchiverModule module, Stream saveStream, Guid requestId) : this(module, requestId) |
103 | { | 107 | { |
104 | m_saveStream = saveStream; | 108 | m_saveStream = saveStream; |
105 | } | 109 | } |
106 | 110 | ||
107 | protected ArchiveWriteRequestPreparation(Scene scene, Guid requestId) | 111 | protected ArchiveWriteRequestPreparation(ArchiverModule module, Guid requestId) |
108 | { | 112 | { |
109 | m_scene = scene; | 113 | m_module = module; |
114 | |||
115 | // FIXME: This is only here for regression test purposes since they do not supply a module. Need to fix | ||
116 | // this. | ||
117 | if (m_module != null) | ||
118 | m_scene = m_module.Scene; | ||
119 | |||
110 | m_requestId = requestId; | 120 | m_requestId = requestId; |
111 | 121 | ||
112 | SaveAssets = true; | 122 | SaveAssets = true; |
@@ -297,10 +307,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
297 | if (checkPermissions.Contains("T") && !canTransfer) | 307 | if (checkPermissions.Contains("T") && !canTransfer) |
298 | partPermitted = false; | 308 | partPermitted = false; |
299 | 309 | ||
310 | // If the user is the Creator of the object then it can always be included in the OAR | ||
311 | bool creator = (obj.CreatorID.Guid == user.Guid); | ||
312 | if (creator) | ||
313 | partPermitted = true; | ||
314 | |||
300 | //string name = (objGroup.PrimCount == 1) ? objGroup.Name : string.Format("{0} ({1}/{2})", obj.Name, primNumber, objGroup.PrimCount); | 315 | //string name = (objGroup.PrimCount == 1) ? objGroup.Name : string.Format("{0} ({1}/{2})", obj.Name, primNumber, objGroup.PrimCount); |
301 | //m_log.DebugFormat("[ARCHIVER]: Object permissions: {0}: Base={1:X4}, Owner={2:X4}, Everyone={3:X4}, permissionClass={4}, checkPermissions={5}, canCopy={6}, canTransfer={7}, permitted={8}", | 316 | //m_log.DebugFormat("[ARCHIVER]: Object permissions: {0}: Base={1:X4}, Owner={2:X4}, Everyone={3:X4}, permissionClass={4}, checkPermissions={5}, canCopy={6}, canTransfer={7}, creator={8}, permitted={9}", |
302 | // name, obj.BaseMask, obj.OwnerMask, obj.EveryoneMask, | 317 | // name, obj.BaseMask, obj.OwnerMask, obj.EveryoneMask, |
303 | // permissionClass, checkPermissions, canCopy, canTransfer, permitted); | 318 | // permissionClass, checkPermissions, canCopy, canTransfer, creator, partPermitted); |
304 | 319 | ||
305 | if (!partPermitted) | 320 | if (!partPermitted) |
306 | { | 321 | { |
@@ -320,7 +335,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
320 | /// <returns></returns> | 335 | /// <returns></returns> |
321 | public string CreateControlFile(Dictionary<string, object> options) | 336 | public string CreateControlFile(Dictionary<string, object> options) |
322 | { | 337 | { |
323 | int majorVersion = MAX_MAJOR_VERSION, minorVersion = 7; | 338 | int majorVersion = MAX_MAJOR_VERSION, minorVersion = 8; |
324 | // | 339 | // |
325 | // if (options.ContainsKey("version")) | 340 | // if (options.ContainsKey("version")) |
326 | // { | 341 | // { |
@@ -356,32 +371,66 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
356 | //if (majorVersion == 1) | 371 | //if (majorVersion == 1) |
357 | //{ | 372 | //{ |
358 | // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); | 373 | // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); |
359 | //} | 374 | //} |
375 | |||
376 | String s; | ||
360 | 377 | ||
361 | StringWriter sw = new StringWriter(); | 378 | using (StringWriter sw = new StringWriter()) |
362 | XmlTextWriter xtw = new XmlTextWriter(sw); | 379 | { |
363 | xtw.Formatting = Formatting.Indented; | 380 | using (XmlTextWriter xtw = new XmlTextWriter(sw)) |
364 | xtw.WriteStartDocument(); | 381 | { |
365 | xtw.WriteStartElement("archive"); | 382 | xtw.Formatting = Formatting.Indented; |
366 | xtw.WriteAttributeString("major_version", majorVersion.ToString()); | 383 | xtw.WriteStartDocument(); |
367 | xtw.WriteAttributeString("minor_version", minorVersion.ToString()); | 384 | xtw.WriteStartElement("archive"); |
368 | 385 | xtw.WriteAttributeString("major_version", majorVersion.ToString()); | |
369 | xtw.WriteStartElement("creation_info"); | 386 | xtw.WriteAttributeString("minor_version", minorVersion.ToString()); |
370 | DateTime now = DateTime.UtcNow; | 387 | |
371 | TimeSpan t = now - new DateTime(1970, 1, 1); | 388 | xtw.WriteStartElement("creation_info"); |
372 | xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); | 389 | DateTime now = DateTime.UtcNow; |
373 | xtw.WriteElementString("id", UUID.Random().ToString()); | 390 | TimeSpan t = now - new DateTime(1970, 1, 1); |
374 | xtw.WriteEndElement(); | 391 | xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); |
375 | 392 | xtw.WriteElementString("id", UUID.Random().ToString()); | |
376 | xtw.WriteElementString("assets_included", SaveAssets.ToString()); | 393 | xtw.WriteEndElement(); |
377 | 394 | ||
378 | xtw.WriteEndElement(); | 395 | xtw.WriteStartElement("region_info"); |
379 | 396 | ||
380 | xtw.Flush(); | 397 | bool isMegaregion; |
381 | xtw.Close(); | 398 | Vector2 size; |
382 | 399 | IRegionCombinerModule rcMod = null; | |
383 | String s = sw.ToString(); | 400 | |
384 | sw.Close(); | 401 | // FIXME: This is only here for regression test purposes since they do not supply a module. Need to fix |
402 | // this, possibly by doing control file creation somewhere else. | ||
403 | if (m_module != null) | ||
404 | rcMod = m_module.RegionCombinerModule; | ||
405 | |||
406 | if (rcMod != null) | ||
407 | isMegaregion = rcMod.IsRootForMegaregion(m_scene.RegionInfo.RegionID); | ||
408 | else | ||
409 | isMegaregion = false; | ||
410 | |||
411 | if (isMegaregion) | ||
412 | size = rcMod.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); | ||
413 | else | ||
414 | size = new Vector2((float)Constants.RegionSize, (float)Constants.RegionSize); | ||
415 | |||
416 | xtw.WriteElementString("is_megaregion", isMegaregion.ToString()); | ||
417 | xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y)); | ||
418 | |||
419 | xtw.WriteEndElement(); | ||
420 | |||
421 | xtw.WriteElementString("assets_included", SaveAssets.ToString()); | ||
422 | |||
423 | xtw.WriteEndElement(); | ||
424 | |||
425 | xtw.Flush(); | ||
426 | } | ||
427 | |||
428 | s = sw.ToString(); | ||
429 | } | ||
430 | |||
431 | // if (m_scene != null) | ||
432 | // Console.WriteLine( | ||
433 | // "[ARCHIVE WRITE REQUEST PREPARATION]: Control file for {0} is: {1}", m_scene.RegionInfo.RegionName, s); | ||
385 | 434 | ||
386 | return s; | 435 | return s; |
387 | } | 436 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index f5a5a8d..bf3b124 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs | |||
@@ -45,7 +45,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
45 | private static readonly ILog m_log = | 45 | private static readonly ILog m_log = |
46 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | private Scene m_scene; | 48 | public Scene Scene { get; private set; } |
49 | public IRegionCombinerModule RegionCombinerModule { get; private set; } | ||
49 | 50 | ||
50 | /// <value> | 51 | /// <value> |
51 | /// The file used to load and save an opensimulator archive if no filename has been specified | 52 | /// The file used to load and save an opensimulator archive if no filename has been specified |
@@ -70,13 +71,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
70 | 71 | ||
71 | public void AddRegion(Scene scene) | 72 | public void AddRegion(Scene scene) |
72 | { | 73 | { |
73 | m_scene = scene; | 74 | Scene = scene; |
74 | m_scene.RegisterModuleInterface<IRegionArchiverModule>(this); | 75 | Scene.RegisterModuleInterface<IRegionArchiverModule>(this); |
75 | //m_log.DebugFormat("[ARCHIVER]: Enabled for region {0}", scene.RegionInfo.RegionName); | 76 | //m_log.DebugFormat("[ARCHIVER]: Enabled for region {0}", scene.RegionInfo.RegionName); |
76 | } | 77 | } |
77 | 78 | ||
78 | public void RegionLoaded(Scene scene) | 79 | public void RegionLoaded(Scene scene) |
79 | { | 80 | { |
81 | RegionCombinerModule = scene.RequestModuleInterface<IRegionCombinerModule>(); | ||
80 | } | 82 | } |
81 | 83 | ||
82 | public void RemoveRegion(Scene scene) | 84 | public void RemoveRegion(Scene scene) |
@@ -165,9 +167,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
165 | public void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options) | 167 | public void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options) |
166 | { | 168 | { |
167 | m_log.InfoFormat( | 169 | m_log.InfoFormat( |
168 | "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath); | 170 | "[ARCHIVER]: Writing archive for region {0} to {1}", Scene.RegionInfo.RegionName, savePath); |
169 | 171 | ||
170 | new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(options); | 172 | new ArchiveWriteRequestPreparation(this, savePath, requestId).ArchiveRegion(options); |
171 | } | 173 | } |
172 | 174 | ||
173 | public void ArchiveRegion(Stream saveStream) | 175 | public void ArchiveRegion(Stream saveStream) |
@@ -182,7 +184,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
182 | 184 | ||
183 | public void ArchiveRegion(Stream saveStream, Guid requestId, Dictionary<string, object> options) | 185 | public void ArchiveRegion(Stream saveStream, Guid requestId, Dictionary<string, object> options) |
184 | { | 186 | { |
185 | new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(options); | 187 | new ArchiveWriteRequestPreparation(this, saveStream, requestId).ArchiveRegion(options); |
186 | } | 188 | } |
187 | 189 | ||
188 | public void DearchiveRegion(string loadPath) | 190 | public void DearchiveRegion(string loadPath) |
@@ -193,9 +195,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
193 | public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId) | 195 | public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId) |
194 | { | 196 | { |
195 | m_log.InfoFormat( | 197 | m_log.InfoFormat( |
196 | "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath); | 198 | "[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath); |
197 | 199 | ||
198 | new ArchiveReadRequest(m_scene, loadPath, merge, skipAssets, requestId).DearchiveRegion(); | 200 | new ArchiveReadRequest(Scene, loadPath, merge, skipAssets, requestId).DearchiveRegion(); |
199 | } | 201 | } |
200 | 202 | ||
201 | public void DearchiveRegion(Stream loadStream) | 203 | public void DearchiveRegion(Stream loadStream) |
@@ -205,7 +207,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
205 | 207 | ||
206 | public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId) | 208 | public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId) |
207 | { | 209 | { |
208 | new ArchiveReadRequest(m_scene, loadStream, merge, skipAssets, requestId).DearchiveRegion(); | 210 | new ArchiveReadRequest(Scene, loadStream, merge, skipAssets, requestId).DearchiveRegion(); |
209 | } | 211 | } |
210 | } | 212 | } |
211 | } | 213 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 63f1363..5deaf52 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -68,7 +68,7 @@ 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 = SceneHelpers.SetupScene(); | 71 | m_scene = new SceneHelpers().SetupScene(); |
72 | SceneHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); | 72 | SceneHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); |
73 | } | 73 | } |
74 | 74 | ||
@@ -102,9 +102,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
102 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | 102 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); |
103 | Vector3 groupPosition = new Vector3(10, 20, 30); | 103 | Vector3 groupPosition = new Vector3(10, 20, 30); |
104 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | 104 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); |
105 | Vector3 offsetPosition = new Vector3(5, 10, 15); | 105 | // Vector3 offsetPosition = new Vector3(5, 10, 15); |
106 | 106 | ||
107 | return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; | 107 | return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, Vector3.Zero) { Name = partName }; |
108 | } | 108 | } |
109 | 109 | ||
110 | protected SceneObjectPart CreateSceneObjectPart2() | 110 | protected SceneObjectPart CreateSceneObjectPart2() |
@@ -292,6 +292,59 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
292 | } | 292 | } |
293 | 293 | ||
294 | /// <summary> | 294 | /// <summary> |
295 | /// Test loading an OpenSim Region Archive where the scene object parts are not ordered by link number (e.g. | ||
296 | /// 2 can come after 3). | ||
297 | /// </summary> | ||
298 | [Test] | ||
299 | public void TestLoadOarUnorderedParts() | ||
300 | { | ||
301 | TestHelpers.InMethod(); | ||
302 | |||
303 | UUID ownerId = TestHelpers.ParseTail(0xaaaa); | ||
304 | |||
305 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
306 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | ||
307 | |||
308 | tar.WriteFile( | ||
309 | ArchiveConstants.CONTROL_FILE_PATH, | ||
310 | new ArchiveWriteRequestPreparation(null, (Stream)null, Guid.Empty).CreateControlFile(new Dictionary<string, Object>())); | ||
311 | |||
312 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ownerId, "obj1-", 0x11); | ||
313 | SceneObjectPart sop2 | ||
314 | = SceneHelpers.CreateSceneObjectPart("obj1-Part2", TestHelpers.ParseTail(0x12), ownerId); | ||
315 | SceneObjectPart sop3 | ||
316 | = SceneHelpers.CreateSceneObjectPart("obj1-Part3", TestHelpers.ParseTail(0x13), ownerId); | ||
317 | |||
318 | // Add the parts so they will be written out in reverse order to the oar | ||
319 | sog1.AddPart(sop3); | ||
320 | sop3.LinkNum = 3; | ||
321 | sog1.AddPart(sop2); | ||
322 | sop2.LinkNum = 2; | ||
323 | |||
324 | tar.WriteFile( | ||
325 | ArchiveConstants.CreateOarObjectPath(sog1.Name, sog1.UUID, sog1.AbsolutePosition), | ||
326 | SceneObjectSerializer.ToXml2Format(sog1)); | ||
327 | |||
328 | tar.Close(); | ||
329 | |||
330 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
331 | |||
332 | lock (this) | ||
333 | { | ||
334 | m_scene.EventManager.OnOarFileLoaded += LoadCompleted; | ||
335 | m_archiverModule.DearchiveRegion(archiveReadStream); | ||
336 | } | ||
337 | |||
338 | Assert.That(m_lastErrorMessage, Is.Null); | ||
339 | |||
340 | SceneObjectPart part2 = m_scene.GetSceneObjectPart("obj1-Part2"); | ||
341 | Assert.That(part2.LinkNum, Is.EqualTo(2)); | ||
342 | |||
343 | SceneObjectPart part3 = m_scene.GetSceneObjectPart("obj1-Part3"); | ||
344 | Assert.That(part3.LinkNum, Is.EqualTo(3)); | ||
345 | } | ||
346 | |||
347 | /// <summary> | ||
295 | /// Test loading an OpenSim Region Archive. | 348 | /// Test loading an OpenSim Region Archive. |
296 | /// </summary> | 349 | /// </summary> |
297 | [Test] | 350 | [Test] |
@@ -463,7 +516,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
463 | SerialiserModule serialiserModule = new SerialiserModule(); | 516 | SerialiserModule serialiserModule = new SerialiserModule(); |
464 | TerrainModule terrainModule = new TerrainModule(); | 517 | TerrainModule terrainModule = new TerrainModule(); |
465 | 518 | ||
466 | TestScene scene2 = SceneHelpers.SetupScene(); | 519 | TestScene scene2 = new SceneHelpers().SetupScene(); |
467 | SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule); | 520 | SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule); |
468 | 521 | ||
469 | // Make sure there's a valid owner for the owner we saved (this should have been wiped if the code is | 522 | // Make sure there's a valid owner for the owner we saved (this should have been wiped if the code is |
@@ -534,6 +587,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
534 | rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080"); | 587 | rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080"); |
535 | rs.UseEstateSun = true; | 588 | rs.UseEstateSun = true; |
536 | rs.WaterHeight = 23; | 589 | rs.WaterHeight = 23; |
590 | rs.TelehubObject = UUID.Parse("00000000-0000-0000-0000-111111111111"); | ||
591 | rs.AddSpawnPoint(SpawnPoint.Parse("1,-2,0.33")); | ||
537 | 592 | ||
538 | tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs)); | 593 | tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs)); |
539 | 594 | ||
@@ -580,6 +635,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
580 | Assert.That(loadedRs.TerrainTexture4, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000080"))); | 635 | Assert.That(loadedRs.TerrainTexture4, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000080"))); |
581 | Assert.That(loadedRs.UseEstateSun, Is.True); | 636 | Assert.That(loadedRs.UseEstateSun, Is.True); |
582 | Assert.That(loadedRs.WaterHeight, Is.EqualTo(23)); | 637 | Assert.That(loadedRs.WaterHeight, Is.EqualTo(23)); |
638 | Assert.AreEqual(UUID.Zero, loadedRs.TelehubObject); // because no object was found with the original UUID | ||
639 | Assert.AreEqual(0, loadedRs.SpawnPoints().Count); | ||
583 | } | 640 | } |
584 | 641 | ||
585 | /// <summary> | 642 | /// <summary> |
@@ -607,7 +664,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
607 | SerialiserModule serialiserModule = new SerialiserModule(); | 664 | SerialiserModule serialiserModule = new SerialiserModule(); |
608 | TerrainModule terrainModule = new TerrainModule(); | 665 | TerrainModule terrainModule = new TerrainModule(); |
609 | 666 | ||
610 | Scene scene = SceneHelpers.SetupScene(); | 667 | Scene scene = new SceneHelpers().SetupScene(); |
611 | SceneHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); | 668 | SceneHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); |
612 | 669 | ||
613 | m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); | 670 | m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 1e743c3..ddc2a07 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -168,12 +168,18 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
168 | sendRegionInfoPacketToAll(); | 168 | sendRegionInfoPacketToAll(); |
169 | } | 169 | } |
170 | 170 | ||
171 | public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int corner, UUID texture) | 171 | public void setEstateTerrainBaseTexture(int level, UUID texture) |
172 | { | ||
173 | setEstateTerrainBaseTexture(null, level, texture); | ||
174 | sendRegionHandshakeToAll(); | ||
175 | } | ||
176 | |||
177 | public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int level, UUID texture) | ||
172 | { | 178 | { |
173 | if (texture == UUID.Zero) | 179 | if (texture == UUID.Zero) |
174 | return; | 180 | return; |
175 | 181 | ||
176 | switch (corner) | 182 | switch (level) |
177 | { | 183 | { |
178 | case 0: | 184 | case 0: |
179 | Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture; | 185 | Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture; |
@@ -193,6 +199,11 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
193 | sendRegionInfoPacketToAll(); | 199 | sendRegionInfoPacketToAll(); |
194 | } | 200 | } |
195 | 201 | ||
202 | public void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue) | ||
203 | { | ||
204 | setEstateTerrainTextureHeights(null, corner, lowValue, highValue); | ||
205 | } | ||
206 | |||
196 | public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue) | 207 | public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue) |
197 | { | 208 | { |
198 | switch (corner) | 209 | switch (corner) |
@@ -987,7 +998,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
987 | { | 998 | { |
988 | RegionHandshakeArgs args = new RegionHandshakeArgs(); | 999 | RegionHandshakeArgs args = new RegionHandshakeArgs(); |
989 | 1000 | ||
990 | args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManager(remoteClient.AgentId); | 1001 | args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(remoteClient.AgentId); |
991 | if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId) | 1002 | if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId) |
992 | args.isEstateManager = true; | 1003 | args.isEstateManager = true; |
993 | 1004 | ||
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 02ac091..2fa0b3f 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -1392,21 +1392,26 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1392 | private void EventManagerOnRegisterCaps(UUID agentID, Caps caps) | 1392 | private void EventManagerOnRegisterCaps(UUID agentID, Caps caps) |
1393 | { | 1393 | { |
1394 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | 1394 | string capsBase = "/CAPS/" + caps.CapsObjectPath; |
1395 | caps.RegisterHandler("RemoteParcelRequest", | 1395 | caps.RegisterHandler( |
1396 | new RestStreamHandler("POST", capsBase + remoteParcelRequestPath, | 1396 | "RemoteParcelRequest", |
1397 | delegate(string request, string path, string param, | 1397 | new RestStreamHandler( |
1398 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 1398 | "POST", |
1399 | { | 1399 | capsBase + remoteParcelRequestPath, |
1400 | return RemoteParcelRequest(request, path, param, agentID, caps); | 1400 | (request, path, param, httpRequest, httpResponse) |
1401 | })); | 1401 | => RemoteParcelRequest(request, path, param, agentID, caps), |
1402 | "RemoteParcelRequest", | ||
1403 | agentID.ToString())); | ||
1404 | |||
1402 | UUID parcelCapID = UUID.Random(); | 1405 | UUID parcelCapID = UUID.Random(); |
1403 | caps.RegisterHandler("ParcelPropertiesUpdate", | 1406 | caps.RegisterHandler( |
1404 | new RestStreamHandler("POST", "/CAPS/" + parcelCapID, | 1407 | "ParcelPropertiesUpdate", |
1405 | delegate(string request, string path, string param, | 1408 | new RestStreamHandler( |
1406 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 1409 | "POST", |
1407 | { | 1410 | "/CAPS/" + parcelCapID, |
1408 | return ProcessPropertiesUpdate(request, path, param, agentID, caps); | 1411 | (request, path, param, httpRequest, httpResponse) |
1409 | })); | 1412 | => ProcessPropertiesUpdate(request, path, param, agentID, caps), |
1413 | "ParcelPropertiesUpdate", | ||
1414 | agentID.ToString())); | ||
1410 | } | 1415 | } |
1411 | private string ProcessPropertiesUpdate(string request, string path, string param, UUID agentID, Caps caps) | 1416 | private string ProcessPropertiesUpdate(string request, string path, string param, UUID agentID, Caps caps) |
1412 | { | 1417 | { |
@@ -1771,7 +1776,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1771 | 1776 | ||
1772 | Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); | 1777 | Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); |
1773 | 1778 | ||
1774 | targetAvatar.TeleportWithMomentum(pos); | 1779 | targetAvatar.TeleportWithMomentum(pos, null); |
1775 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); | 1780 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); |
1776 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); | 1781 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); |
1777 | 1782 | ||
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 509c4d7..16792b3 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -447,7 +447,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
447 | { | 447 | { |
448 | bool isMember; | 448 | bool isMember; |
449 | if (m_groupMemberCache.TryGetValue(avatar, out isMember)) | 449 | if (m_groupMemberCache.TryGetValue(avatar, out isMember)) |
450 | { | ||
451 | m_groupMemberCache.Update(avatar, isMember, m_groupMemberCacheTimeout); | ||
450 | return isMember; | 452 | return isMember; |
453 | } | ||
451 | 454 | ||
452 | IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); | 455 | IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); |
453 | if (groupsModule == null) | 456 | if (groupsModule == null) |
@@ -484,7 +487,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
484 | if (m_scene.Permissions.IsAdministrator(avatar)) | 487 | if (m_scene.Permissions.IsAdministrator(avatar)) |
485 | return false; | 488 | return false; |
486 | 489 | ||
487 | if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar)) | 490 | if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar)) |
488 | return false; | 491 | return false; |
489 | 492 | ||
490 | if (avatar == LandData.OwnerID) | 493 | if (avatar == LandData.OwnerID) |
@@ -514,7 +517,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
514 | if (m_scene.Permissions.IsAdministrator(avatar)) | 517 | if (m_scene.Permissions.IsAdministrator(avatar)) |
515 | return false; | 518 | return false; |
516 | 519 | ||
517 | if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar)) | 520 | if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar)) |
518 | return false; | 521 | return false; |
519 | 522 | ||
520 | if (avatar == LandData.OwnerID) | 523 | if (avatar == LandData.OwnerID) |
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 5122734..102b4d7 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | |||
@@ -126,7 +126,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
126 | // m_log.DebugFormat( | 126 | // m_log.DebugFormat( |
127 | // "[PRIM COUNT MODULE]: Ignoring OnParcelPrimCountAdd() for {0} on {1} since count is tainted", | 127 | // "[PRIM COUNT MODULE]: Ignoring OnParcelPrimCountAdd() for {0} on {1} since count is tainted", |
128 | // obj.Name, m_Scene.RegionInfo.RegionName); | 128 | // obj.Name, m_Scene.RegionInfo.RegionName); |
129 | |||
130 | } | 129 | } |
131 | } | 130 | } |
132 | 131 | ||
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index e553ffa..b5ee4d2 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs | |||
@@ -64,7 +64,7 @@ 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 = SceneHelpers.SetupScene(); | 67 | m_scene = new SceneHelpers().SetupScene(); |
68 | SceneHelpers.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; |
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index f86c790..aa306c7 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | |||
@@ -225,7 +225,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
225 | int tc = 0; | 225 | int tc = 0; |
226 | double[,] hm = whichScene.Heightmap.GetDoubles(); | 226 | double[,] hm = whichScene.Heightmap.GetDoubles(); |
227 | tc = Environment.TickCount; | 227 | tc = Environment.TickCount; |
228 | m_log.Info("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); | 228 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); |
229 | EntityBase[] objs = whichScene.GetEntities(); | 229 | EntityBase[] objs = whichScene.GetEntities(); |
230 | Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>(); | 230 | Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>(); |
231 | //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>(); | 231 | //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>(); |
@@ -541,7 +541,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
541 | g.Dispose(); | 541 | g.Dispose(); |
542 | } // lock entities objs | 542 | } // lock entities objs |
543 | 543 | ||
544 | m_log.Info("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); | 544 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); |
545 | return mapbmp; | 545 | return mapbmp; |
546 | } | 546 | } |
547 | 547 | ||
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs index eb1a27f..992bff3 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs | |||
@@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
54 | public void TerrainToBitmap(Bitmap mapbmp) | 54 | public void TerrainToBitmap(Bitmap mapbmp) |
55 | { | 55 | { |
56 | int tc = Environment.TickCount; | 56 | int tc = Environment.TickCount; |
57 | m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain"); | 57 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); |
58 | 58 | ||
59 | double[,] hm = m_scene.Heightmap.GetDoubles(); | 59 | double[,] hm = m_scene.Heightmap.GetDoubles(); |
60 | bool ShadowDebugContinue = true; | 60 | bool ShadowDebugContinue = true; |
@@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
238 | } | 238 | } |
239 | } | 239 | } |
240 | } | 240 | } |
241 | m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | 241 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | } | 244 | } |
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs index 1d2141e..d13c2ef 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs | |||
@@ -278,7 +278,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
278 | public void TerrainToBitmap(Bitmap mapbmp) | 278 | public void TerrainToBitmap(Bitmap mapbmp) |
279 | { | 279 | { |
280 | int tc = Environment.TickCount; | 280 | int tc = Environment.TickCount; |
281 | m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain"); | 281 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); |
282 | 282 | ||
283 | // These textures should be in the AssetCache anyway, as every client conneting to this | 283 | // These textures should be in the AssetCache anyway, as every client conneting to this |
284 | // region needs them. Except on start, when the map is recreated (before anyone connected), | 284 | // region needs them. Except on start, when the map is recreated (before anyone connected), |
@@ -412,7 +412,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
412 | } | 412 | } |
413 | } | 413 | } |
414 | } | 414 | } |
415 | m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | 415 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); |
416 | } | 416 | } |
417 | } | 417 | } |
418 | } | 418 | } |
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index 5239f50..601e81e 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs | |||
@@ -145,7 +145,9 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap | |||
145 | 145 | ||
146 | // Even though we're registering for POST we're going to get GETS and UPDATES too | 146 | // Even though we're registering for POST we're going to get GETS and UPDATES too |
147 | caps.RegisterHandler( | 147 | caps.RegisterHandler( |
148 | "ObjectMedia", new RestStreamHandler("POST", omCapUrl, HandleObjectMediaMessage)); | 148 | "ObjectMedia", |
149 | new RestStreamHandler( | ||
150 | "POST", omCapUrl, HandleObjectMediaMessage, "ObjectMedia", agentID.ToString())); | ||
149 | } | 151 | } |
150 | 152 | ||
151 | string omuCapUrl = "/CAPS/" + UUID.Random(); | 153 | string omuCapUrl = "/CAPS/" + UUID.Random(); |
@@ -157,7 +159,9 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap | |||
157 | 159 | ||
158 | // Even though we're registering for POST we're going to get GETS and UPDATES too | 160 | // Even though we're registering for POST we're going to get GETS and UPDATES too |
159 | caps.RegisterHandler( | 161 | caps.RegisterHandler( |
160 | "ObjectMediaNavigate", new RestStreamHandler("POST", omuCapUrl, HandleObjectMediaNavigateMessage)); | 162 | "ObjectMediaNavigate", |
163 | new RestStreamHandler( | ||
164 | "POST", omuCapUrl, HandleObjectMediaNavigateMessage, "ObjectMediaNavigate", agentID.ToString())); | ||
161 | } | 165 | } |
162 | } | 166 | } |
163 | 167 | ||
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs index 4326606..0545250 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs | |||
@@ -53,7 +53,7 @@ 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 = SceneHelpers.SetupScene(); | 56 | m_scene = new SceneHelpers().SetupScene(); |
57 | SceneHelpers.SetupSceneModules(m_scene, m_module); | 57 | SceneHelpers.SetupSceneModules(m_scene, m_module); |
58 | } | 58 | } |
59 | 59 | ||
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index f5a5c92..830d9cb 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | |||
@@ -29,8 +29,10 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Text.RegularExpressions; | ||
32 | using log4net; | 33 | using log4net; |
33 | using Mono.Addins; | 34 | using Mono.Addins; |
35 | using NDesk.Options; | ||
34 | using Nini.Config; | 36 | using Nini.Config; |
35 | using OpenMetaverse; | 37 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
@@ -78,49 +80,61 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
78 | m_scene = scene; | 80 | m_scene = scene; |
79 | m_console = MainConsole.Instance; | 81 | m_console = MainConsole.Instance; |
80 | 82 | ||
81 | m_console.Commands.AddCommand("Regions", false, "delete object owner", | 83 | m_console.Commands.AddCommand( |
82 | "delete object owner <UUID>", | 84 | "Objects", false, "delete object owner", |
83 | "Delete a scene object by owner", HandleDeleteObject); | 85 | "delete object owner <UUID>", |
84 | m_console.Commands.AddCommand("Regions", false, "delete object creator", | 86 | "Delete a scene object by owner", HandleDeleteObject); |
85 | "delete object creator <UUID>", | 87 | |
86 | "Delete a scene object by creator", HandleDeleteObject); | 88 | m_console.Commands.AddCommand( |
87 | m_console.Commands.AddCommand("Regions", false, "delete object uuid", | 89 | "Objects", false, "delete object creator", |
88 | "delete object uuid <UUID>", | 90 | "delete object creator <UUID>", |
89 | "Delete a scene object by uuid", HandleDeleteObject); | 91 | "Delete a scene object by creator", HandleDeleteObject); |
90 | m_console.Commands.AddCommand("Regions", false, "delete object name", | 92 | |
91 | "delete object name <name>", | 93 | m_console.Commands.AddCommand( |
92 | "Delete a scene object by name", HandleDeleteObject); | 94 | "Objects", false, "delete object uuid", |
93 | m_console.Commands.AddCommand("Regions", false, "delete object outside", | 95 | "delete object uuid <UUID>", |
94 | "delete object outside", | 96 | "Delete a scene object by uuid", HandleDeleteObject); |
95 | "Delete all scene objects outside region boundaries", HandleDeleteObject); | 97 | |
98 | m_console.Commands.AddCommand( | ||
99 | "Objects", false, "delete object name", | ||
100 | "delete object name [--regex] <name>", | ||
101 | "Delete a scene object by name.\nIf --regex is specified then the name is treatead as a regular expression", | ||
102 | HandleDeleteObject); | ||
103 | |||
104 | m_console.Commands.AddCommand( | ||
105 | "Objects", false, "delete object outside", | ||
106 | "delete object outside", | ||
107 | "Delete all scene objects outside region boundaries", HandleDeleteObject); | ||
96 | 108 | ||
97 | m_console.Commands.AddCommand( | 109 | m_console.Commands.AddCommand( |
98 | "Regions", | 110 | "Objects", |
99 | false, | 111 | false, |
100 | "show object uuid", | 112 | "show object uuid", |
101 | "show object uuid <UUID>", | 113 | "show object uuid <UUID>", |
102 | "Show details of a scene object with the given UUID", HandleShowObjectByUuid); | 114 | "Show details of a scene object with the given UUID", HandleShowObjectByUuid); |
103 | 115 | ||
104 | m_console.Commands.AddCommand( | 116 | m_console.Commands.AddCommand( |
105 | "Regions", | 117 | "Objects", |
106 | false, | 118 | false, |
107 | "show object name", | 119 | "show object name", |
108 | "show object name <name>", | 120 | "show object name [--regex] <name>", |
109 | "Show details of scene objects with the given name", HandleShowObjectByName); | 121 | "Show details of scene objects with the given name.\nIf --regex is specified then the name is treatead as a regular expression", |
122 | HandleShowObjectByName); | ||
110 | 123 | ||
111 | m_console.Commands.AddCommand( | 124 | m_console.Commands.AddCommand( |
112 | "Regions", | 125 | "Objects", |
113 | false, | 126 | false, |
114 | "show part uuid", | 127 | "show part uuid", |
115 | "show part uuid <UUID>", | 128 | "show part uuid <UUID>", |
116 | "Show details of a scene object parts with the given UUID", HandleShowPartByUuid); | 129 | "Show details of a scene object parts with the given UUID", HandleShowPartByUuid); |
117 | 130 | ||
118 | m_console.Commands.AddCommand( | 131 | m_console.Commands.AddCommand( |
119 | "Regions", | 132 | "Objects", |
120 | false, | 133 | false, |
121 | "show part name", | 134 | "show part name", |
122 | "show part name <name>", | 135 | "show part name [--regex] <name>", |
123 | "Show details of scene object parts with the given name", HandleShowPartByName); | 136 | "Show details of scene object parts with the given name.\nIf --regex is specified then the name is treatead as a regular expression", |
137 | HandleShowPartByName); | ||
124 | } | 138 | } |
125 | 139 | ||
126 | public void RemoveRegion(Scene scene) | 140 | public void RemoveRegion(Scene scene) |
@@ -165,22 +179,38 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
165 | m_console.OutputFormat(sb.ToString()); | 179 | m_console.OutputFormat(sb.ToString()); |
166 | } | 180 | } |
167 | 181 | ||
168 | private void HandleShowObjectByName(string module, string[] cmd) | 182 | private void HandleShowObjectByName(string module, string[] cmdparams) |
169 | { | 183 | { |
170 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) | 184 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) |
171 | return; | 185 | return; |
172 | 186 | ||
173 | if (cmd.Length < 4) | 187 | bool useRegex = false; |
188 | OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null ); | ||
189 | |||
190 | List<string> mainParams = options.Parse(cmdparams); | ||
191 | |||
192 | if (mainParams.Count < 4) | ||
174 | { | 193 | { |
175 | m_console.OutputFormat("Usage: show object name <name>"); | 194 | m_console.OutputFormat("Usage: show object name [--regex] <name>"); |
176 | return; | 195 | return; |
177 | } | 196 | } |
178 | 197 | ||
179 | string name = cmd[3]; | 198 | string name = mainParams[3]; |
180 | 199 | ||
181 | List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); | 200 | List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); |
201 | Action<SceneObjectGroup> searchAction; | ||
182 | 202 | ||
183 | m_scene.ForEachSOG(so => { if (so.Name == name) { sceneObjects.Add(so); }}); | 203 | if (useRegex) |
204 | { | ||
205 | Regex nameRegex = new Regex(name); | ||
206 | searchAction = so => { if (nameRegex.IsMatch(so.Name)) { sceneObjects.Add(so); }}; | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | searchAction = so => { if (so.Name == name) { sceneObjects.Add(so); }}; | ||
211 | } | ||
212 | |||
213 | m_scene.ForEachSOG(searchAction); | ||
184 | 214 | ||
185 | if (sceneObjects.Count == 0) | 215 | if (sceneObjects.Count == 0) |
186 | { | 216 | { |
@@ -231,22 +261,39 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
231 | m_console.OutputFormat(sb.ToString()); | 261 | m_console.OutputFormat(sb.ToString()); |
232 | } | 262 | } |
233 | 263 | ||
234 | private void HandleShowPartByName(string module, string[] cmd) | 264 | private void HandleShowPartByName(string module, string[] cmdparams) |
235 | { | 265 | { |
236 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) | 266 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) |
237 | return; | 267 | return; |
238 | 268 | ||
239 | if (cmd.Length < 4) | 269 | bool useRegex = false; |
270 | OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null ); | ||
271 | |||
272 | List<string> mainParams = options.Parse(cmdparams); | ||
273 | |||
274 | if (mainParams.Count < 4) | ||
240 | { | 275 | { |
241 | m_console.OutputFormat("Usage: show part name <name>"); | 276 | m_console.OutputFormat("Usage: show part name [--regex] <name>"); |
242 | return; | 277 | return; |
243 | } | 278 | } |
244 | 279 | ||
245 | string name = cmd[3]; | 280 | string name = mainParams[3]; |
246 | 281 | ||
247 | List<SceneObjectPart> parts = new List<SceneObjectPart>(); | 282 | List<SceneObjectPart> parts = new List<SceneObjectPart>(); |
248 | 283 | ||
249 | m_scene.ForEachSOG(so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } })); | 284 | Action<SceneObjectGroup> searchAction; |
285 | |||
286 | if (useRegex) | ||
287 | { | ||
288 | Regex nameRegex = new Regex(name); | ||
289 | searchAction = so => so.ForEachPart(sop => { if (nameRegex.IsMatch(sop.Name)) { parts.Add(sop); } }); | ||
290 | } | ||
291 | else | ||
292 | { | ||
293 | searchAction = so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } }); | ||
294 | } | ||
295 | |||
296 | m_scene.ForEachSOG(searchAction); | ||
250 | 297 | ||
251 | if (parts.Count == 0) | 298 | if (parts.Count == 0) |
252 | { | 299 | { |
@@ -271,6 +318,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
271 | sb.AppendFormat("Description: {0}\n", so.Description); | 318 | sb.AppendFormat("Description: {0}\n", so.Description); |
272 | sb.AppendFormat("Location: {0} @ {1}\n", so.AbsolutePosition, so.Scene.RegionInfo.RegionName); | 319 | sb.AppendFormat("Location: {0} @ {1}\n", so.AbsolutePosition, so.Scene.RegionInfo.RegionName); |
273 | sb.AppendFormat("Parts: {0}\n", so.PrimCount); | 320 | sb.AppendFormat("Parts: {0}\n", so.PrimCount); |
321 | sb.AppendFormat("Flags: {0}\n", so.RootPart.Flags); | ||
274 | 322 | ||
275 | return sb; | 323 | return sb; |
276 | } | 324 | } |
@@ -282,7 +330,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
282 | sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); | 330 | sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); |
283 | sb.AppendFormat("Parent: {0}", | 331 | sb.AppendFormat("Parent: {0}", |
284 | sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); | 332 | sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); |
285 | sb.AppendFormat("Parts: {0}\n", !sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());; | 333 | sb.AppendFormat("Link number: {0}\n", sop.LinkNum); |
334 | sb.AppendFormat("Flags: {0}\n", sop.Flags); | ||
286 | 335 | ||
287 | return sb; | 336 | return sb; |
288 | } | 337 | } |
@@ -306,105 +355,169 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
306 | o = cmd[3]; | 355 | o = cmd[3]; |
307 | } | 356 | } |
308 | 357 | ||
309 | List<SceneObjectGroup> deletes = new List<SceneObjectGroup>(); | 358 | List<SceneObjectGroup> deletes = null; |
310 | |||
311 | UUID match; | 359 | UUID match; |
360 | bool requireConfirmation = true; | ||
312 | 361 | ||
313 | switch (mode) | 362 | switch (mode) |
314 | { | 363 | { |
315 | case "owner": | 364 | case "owner": |
316 | if (!UUID.TryParse(o, out match)) | 365 | if (!UUID.TryParse(o, out match)) |
317 | return; | 366 | return; |
318 | 367 | ||
319 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | 368 | deletes = new List<SceneObjectGroup>(); |
320 | { | ||
321 | if (g.OwnerID == match && !g.IsAttachment) | ||
322 | deletes.Add(g); | ||
323 | }); | ||
324 | 369 | ||
325 | // if (deletes.Count == 0) | 370 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) |
326 | // m_console.OutputFormat("No objects were found with owner {0}", match); | 371 | { |
327 | 372 | if (g.OwnerID == match && !g.IsAttachment) | |
328 | break; | 373 | deletes.Add(g); |
374 | }); | ||
375 | |||
376 | // if (deletes.Count == 0) | ||
377 | // m_console.OutputFormat("No objects were found with owner {0}", match); | ||
378 | |||
379 | break; | ||
380 | |||
381 | case "creator": | ||
382 | if (!UUID.TryParse(o, out match)) | ||
383 | return; | ||
329 | 384 | ||
330 | case "creator": | 385 | deletes = new List<SceneObjectGroup>(); |
331 | if (!UUID.TryParse(o, out match)) | ||
332 | return; | ||
333 | 386 | ||
334 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | 387 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) |
335 | { | 388 | { |
336 | if (g.RootPart.CreatorID == match && !g.IsAttachment) | 389 | if (g.RootPart.CreatorID == match && !g.IsAttachment) |
337 | deletes.Add(g); | 390 | deletes.Add(g); |
338 | }); | 391 | }); |
392 | |||
393 | // if (deletes.Count == 0) | ||
394 | // m_console.OutputFormat("No objects were found with creator {0}", match); | ||
395 | |||
396 | break; | ||
397 | |||
398 | case "uuid": | ||
399 | if (!UUID.TryParse(o, out match)) | ||
400 | return; | ||
339 | 401 | ||
340 | // if (deletes.Count == 0) | 402 | requireConfirmation = false; |
341 | // m_console.OutputFormat("No objects were found with creator {0}", match); | 403 | deletes = new List<SceneObjectGroup>(); |
404 | |||
405 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | ||
406 | { | ||
407 | if (g.UUID == match && !g.IsAttachment) | ||
408 | deletes.Add(g); | ||
409 | }); | ||
410 | |||
411 | // if (deletes.Count == 0) | ||
412 | // m_console.OutputFormat("No objects were found with uuid {0}", match); | ||
413 | |||
414 | break; | ||
415 | |||
416 | case "name": | ||
417 | deletes = GetDeleteCandidatesByName(module, cmd); | ||
418 | break; | ||
419 | |||
420 | case "outside": | ||
421 | deletes = new List<SceneObjectGroup>(); | ||
342 | 422 | ||
343 | break; | 423 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) |
424 | { | ||
425 | SceneObjectPart rootPart = g.RootPart; | ||
426 | bool delete = false; | ||
427 | |||
428 | if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0) | ||
429 | { | ||
430 | delete = true; | ||
431 | } | ||
432 | else | ||
433 | { | ||
434 | ILandObject parcel | ||
435 | = m_scene.LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y); | ||
436 | |||
437 | if (parcel == null || parcel.LandData.Name == "NO LAND") | ||
438 | delete = true; | ||
439 | } | ||
440 | |||
441 | if (delete && !g.IsAttachment && !deletes.Contains(g)) | ||
442 | deletes.Add(g); | ||
443 | }); | ||
444 | |||
445 | if (deletes.Count == 0) | ||
446 | m_console.OutputFormat("No objects were found outside region bounds"); | ||
447 | |||
448 | break; | ||
344 | 449 | ||
345 | case "uuid": | 450 | default: |
346 | if (!UUID.TryParse(o, out match)) | 451 | m_console.OutputFormat("Unrecognized mode {0}", mode); |
347 | return; | 452 | return; |
453 | } | ||
348 | 454 | ||
349 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | 455 | if (deletes == null || deletes.Count <= 0) |
350 | { | 456 | return; |
351 | if (g.UUID == match && !g.IsAttachment) | ||
352 | deletes.Add(g); | ||
353 | }); | ||
354 | |||
355 | // if (deletes.Count == 0) | ||
356 | // m_console.OutputFormat("No objects were found with uuid {0}", match); | ||
357 | |||
358 | break; | ||
359 | 457 | ||
360 | case "name": | 458 | if (requireConfirmation) |
361 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | 459 | { |
460 | string response = MainConsole.Instance.CmdPrompt( | ||
461 | string.Format( | ||
462 | "Are you sure that you want to delete {0} objects from {1}", | ||
463 | deletes.Count, m_scene.RegionInfo.RegionName), | ||
464 | "n"); | ||
465 | |||
466 | if (response.ToLower() != "y") | ||
362 | { | 467 | { |
363 | if (g.RootPart.Name == o && !g.IsAttachment) | 468 | MainConsole.Instance.OutputFormat( |
364 | deletes.Add(g); | 469 | "Aborting delete of {0} objects from {1}", deletes.Count, m_scene.RegionInfo.RegionName); |
365 | }); | ||
366 | 470 | ||
367 | // if (deletes.Count == 0) | 471 | return; |
368 | // m_console.OutputFormat("No objects were found with name {0}", o); | 472 | } |
369 | 473 | } | |
370 | break; | ||
371 | 474 | ||
372 | case "outside": | 475 | m_console.OutputFormat("Deleting {0} objects in {1}", deletes.Count, m_scene.RegionInfo.RegionName); |
373 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | ||
374 | { | ||
375 | SceneObjectPart rootPart = g.RootPart; | ||
376 | bool delete = false; | ||
377 | 476 | ||
378 | if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0) | 477 | foreach (SceneObjectGroup g in deletes) |
379 | { | 478 | { |
380 | delete = true; | 479 | m_console.OutputFormat("Deleting object {0} {1}", g.UUID, g.Name); |
381 | } | 480 | m_scene.DeleteSceneObject(g, false); |
382 | else | 481 | } |
383 | { | 482 | } |
384 | ILandObject parcel | ||
385 | = m_scene.LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y); | ||
386 | 483 | ||
387 | if (parcel == null || parcel.LandData.Name == "NO LAND") | 484 | private List<SceneObjectGroup> GetDeleteCandidatesByName(string module, string[] cmdparams) |
388 | delete = true; | 485 | { |
389 | } | 486 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) |
487 | return null; | ||
390 | 488 | ||
391 | if (delete && !g.IsAttachment && !deletes.Contains(g)) | 489 | bool useRegex = false; |
392 | deletes.Add(g); | 490 | OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null ); |
393 | }); | ||
394 | 491 | ||
395 | // if (deletes.Count == 0) | 492 | List<string> mainParams = options.Parse(cmdparams); |
396 | // m_console.OutputFormat("No objects were found outside region bounds"); | ||
397 | 493 | ||
398 | break; | 494 | if (mainParams.Count < 4) |
495 | { | ||
496 | m_console.OutputFormat("Usage: delete object name [--regex] <name>"); | ||
497 | return null; | ||
399 | } | 498 | } |
400 | 499 | ||
401 | m_console.OutputFormat("Deleting {0} objects in {1}", deletes.Count, m_scene.RegionInfo.RegionName); | 500 | string name = mainParams[3]; |
402 | 501 | ||
403 | foreach (SceneObjectGroup g in deletes) | 502 | List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); |
503 | Action<SceneObjectGroup> searchAction; | ||
504 | |||
505 | if (useRegex) | ||
404 | { | 506 | { |
405 | m_console.OutputFormat("Deleting object {0} {1}", g.UUID, g.Name); | 507 | Regex nameRegex = new Regex(name); |
406 | m_scene.DeleteSceneObject(g, false); | 508 | searchAction = so => { if (nameRegex.IsMatch(so.Name)) { sceneObjects.Add(so); }}; |
509 | } | ||
510 | else | ||
511 | { | ||
512 | searchAction = so => { if (so.Name == name) { sceneObjects.Add(so); }}; | ||
407 | } | 513 | } |
514 | |||
515 | m_scene.ForEachSOG(searchAction); | ||
516 | |||
517 | if (sceneObjects.Count == 0) | ||
518 | m_console.OutputFormat("No objects with name {0} found in {1}", name, m_scene.RegionInfo.RegionName); | ||
519 | |||
520 | return sceneObjects; | ||
408 | } | 521 | } |
409 | } | 522 | } |
410 | } \ No newline at end of file | 523 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 82ccaf8..8c97f58 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -166,6 +166,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
166 | m_scene.Permissions.OnDeedParcel += CanDeedParcel; | 166 | m_scene.Permissions.OnDeedParcel += CanDeedParcel; |
167 | m_scene.Permissions.OnDeedObject += CanDeedObject; | 167 | m_scene.Permissions.OnDeedObject += CanDeedObject; |
168 | m_scene.Permissions.OnIsGod += IsGod; | 168 | m_scene.Permissions.OnIsGod += IsGod; |
169 | m_scene.Permissions.OnIsGridGod += IsGridGod; | ||
169 | m_scene.Permissions.OnIsAdministrator += IsAdministrator; | 170 | m_scene.Permissions.OnIsAdministrator += IsAdministrator; |
170 | m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; | 171 | m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; |
171 | m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED | 172 | m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED |
@@ -449,39 +450,49 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
449 | } | 450 | } |
450 | 451 | ||
451 | /// <summary> | 452 | /// <summary> |
452 | /// Is the given user an administrator (in other words, a god)? | 453 | /// Is the user regarded as an administrator? |
453 | /// </summary> | 454 | /// </summary> |
454 | /// <param name="user"></param> | 455 | /// <param name="user"></param> |
455 | /// <returns></returns> | 456 | /// <returns></returns> |
456 | protected bool IsAdministrator(UUID user) | 457 | protected bool IsAdministrator(UUID user) |
457 | { | 458 | { |
458 | if (user == UUID.Zero) return false; | 459 | if (user == UUID.Zero) |
459 | 460 | return false; | |
460 | if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) | 461 | |
461 | { | 462 | if (m_scene.RegionInfo.EstateSettings.EstateOwner == user && m_RegionOwnerIsGod) |
462 | if (m_scene.RegionInfo.EstateSettings.EstateOwner == user && m_RegionOwnerIsGod) | 463 | return true; |
463 | return true; | ||
464 | } | ||
465 | 464 | ||
466 | if (IsEstateManager(user) && m_RegionManagerIsGod) | 465 | if (IsEstateManager(user) && m_RegionManagerIsGod) |
467 | return true; | 466 | return true; |
468 | 467 | ||
468 | if (IsGridGod(user, null)) | ||
469 | return true; | ||
470 | |||
471 | return false; | ||
472 | } | ||
473 | |||
474 | /// <summary> | ||
475 | /// Is the given user a God throughout the grid (not just in the current scene)? | ||
476 | /// </summary> | ||
477 | /// <param name="user">The user</param> | ||
478 | /// <param name="scene">Unused, can be null</param> | ||
479 | /// <returns></returns> | ||
480 | protected bool IsGridGod(UUID user, Scene scene) | ||
481 | { | ||
482 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | ||
483 | if (m_bypassPermissions) return m_bypassPermissionsValue; | ||
484 | |||
485 | if (user == UUID.Zero) return false; | ||
486 | |||
469 | if (m_allowGridGods) | 487 | if (m_allowGridGods) |
470 | { | 488 | { |
471 | ScenePresence sp = m_scene.GetScenePresence(user); | 489 | ScenePresence sp = m_scene.GetScenePresence(user); |
472 | if (sp != null) | 490 | if (sp != null) |
473 | { | 491 | return (sp.UserLevel >= 200); |
474 | if (sp.UserLevel >= 200) | ||
475 | return true; | ||
476 | return false; | ||
477 | } | ||
478 | 492 | ||
479 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, user); | 493 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, user); |
480 | if (account != null) | 494 | if (account != null) |
481 | { | 495 | return (account.UserLevel >= 200); |
482 | if (account.UserLevel >= 200) | ||
483 | return true; | ||
484 | } | ||
485 | } | 496 | } |
486 | 497 | ||
487 | return false; | 498 | return false; |
@@ -503,7 +514,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
503 | { | 514 | { |
504 | if (user == UUID.Zero) return false; | 515 | if (user == UUID.Zero) return false; |
505 | 516 | ||
506 | return m_scene.RegionInfo.EstateSettings.IsEstateManager(user); | 517 | return m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(user); |
507 | } | 518 | } |
508 | 519 | ||
509 | #endregion | 520 | #endregion |
diff --git a/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs b/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs new file mode 100644 index 0000000..2838e0c --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs | |||
@@ -0,0 +1,155 @@ | |||
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.Text.RegularExpressions; | ||
33 | using log4net; | ||
34 | using Mono.Addins; | ||
35 | using NDesk.Options; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Console; | ||
40 | using OpenSim.Framework.Statistics; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | |||
44 | namespace OpenSim.Region.CoreModules.World.Objects.Commands | ||
45 | { | ||
46 | /// <summary> | ||
47 | /// A module that holds commands for manipulating objects in the scene. | ||
48 | /// </summary> | ||
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionCommandsModule")] | ||
50 | public class RegionCommandsModule : INonSharedRegionModule | ||
51 | { | ||
52 | private Scene m_scene; | ||
53 | private ICommandConsole m_console; | ||
54 | |||
55 | public string Name { get { return "Region Commands Module"; } } | ||
56 | |||
57 | public Type ReplaceableInterface { get { return null; } } | ||
58 | |||
59 | public void Initialise(IConfigSource source) | ||
60 | { | ||
61 | // m_log.DebugFormat("[REGION COMMANDS MODULE]: INITIALIZED MODULE"); | ||
62 | } | ||
63 | |||
64 | public void PostInitialise() | ||
65 | { | ||
66 | // m_log.DebugFormat("[REGION COMMANDS MODULE]: POST INITIALIZED MODULE"); | ||
67 | } | ||
68 | |||
69 | public void Close() | ||
70 | { | ||
71 | // m_log.DebugFormat("[REGION COMMANDS MODULE]: CLOSED MODULE"); | ||
72 | } | ||
73 | |||
74 | public void AddRegion(Scene scene) | ||
75 | { | ||
76 | // m_log.DebugFormat("[REGION COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); | ||
77 | |||
78 | m_scene = scene; | ||
79 | m_console = MainConsole.Instance; | ||
80 | |||
81 | m_console.Commands.AddCommand( | ||
82 | "Regions", false, "show scene", | ||
83 | "show scene", | ||
84 | "Show live scene information for the currently selected region.", HandleShowScene); | ||
85 | } | ||
86 | |||
87 | public void RemoveRegion(Scene scene) | ||
88 | { | ||
89 | // m_log.DebugFormat("[REGION COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | ||
90 | } | ||
91 | |||
92 | public void RegionLoaded(Scene scene) | ||
93 | { | ||
94 | // m_log.DebugFormat("[REGION COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); | ||
95 | } | ||
96 | |||
97 | private void HandleShowScene(string module, string[] cmd) | ||
98 | { | ||
99 | if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene)) | ||
100 | return; | ||
101 | |||
102 | SimStatsReporter r = m_scene.StatsReporter; | ||
103 | float[] stats = r.LastReportedSimStats; | ||
104 | |||
105 | float timeDilation = stats[0]; | ||
106 | float simFps = stats[1]; | ||
107 | float physicsFps = stats[2]; | ||
108 | float agentUpdates = stats[3]; | ||
109 | float rootAgents = stats[4]; | ||
110 | float childAgents = stats[5]; | ||
111 | float totalPrims = stats[6]; | ||
112 | float activePrims = stats[7]; | ||
113 | float totalFrameTime = stats[8]; | ||
114 | // float netFrameTime = stats.StatsBlock[9].StatValue; // Ignored - not used by OpenSimulator | ||
115 | float physicsFrameTime = stats[10]; | ||
116 | float otherFrameTime = stats[11]; | ||
117 | // float imageFrameTime = stats.StatsBlock[12].StatValue; // Ignored | ||
118 | float inPacketsPerSecond = stats[13]; | ||
119 | float outPacketsPerSecond = stats[14]; | ||
120 | float unackedBytes = stats[15]; | ||
121 | // float agentFrameTime = stats.StatsBlock[16].StatValue; // Not really used | ||
122 | float pendingDownloads = stats[17]; | ||
123 | float pendingUploads = stats[18]; | ||
124 | float activeScripts = stats[19]; | ||
125 | float scriptLinesPerSecond = stats[20]; | ||
126 | |||
127 | StringBuilder sb = new StringBuilder(); | ||
128 | sb.AppendFormat("Scene statistics for {0}\n", m_scene.RegionInfo.RegionName); | ||
129 | |||
130 | ConsoleDisplayList dispList = new ConsoleDisplayList(); | ||
131 | dispList.AddRow("Time Dilation", timeDilation); | ||
132 | dispList.AddRow("Sim FPS", simFps); | ||
133 | dispList.AddRow("Physics FPS", physicsFps); | ||
134 | dispList.AddRow("Avatars", rootAgents); | ||
135 | dispList.AddRow("Child agents", childAgents); | ||
136 | dispList.AddRow("Total prims", totalPrims); | ||
137 | dispList.AddRow("Scripts", activeScripts); | ||
138 | dispList.AddRow("Script lines processed per second", scriptLinesPerSecond); | ||
139 | dispList.AddRow("Physics enabled prims", activePrims); | ||
140 | dispList.AddRow("Total frame time", totalFrameTime); | ||
141 | dispList.AddRow("Physics frame time", physicsFrameTime); | ||
142 | dispList.AddRow("Other frame time", otherFrameTime); | ||
143 | dispList.AddRow("Agent Updates per second", agentUpdates); | ||
144 | dispList.AddRow("Packets processed from clients per second", inPacketsPerSecond); | ||
145 | dispList.AddRow("Packets sent to clients per second", outPacketsPerSecond); | ||
146 | dispList.AddRow("Bytes unacknowledged by clients", unackedBytes); | ||
147 | dispList.AddRow("Pending asset downloads to clients", pendingDownloads); | ||
148 | dispList.AddRow("Pending asset uploads from clients", pendingUploads); | ||
149 | |||
150 | dispList.AddToStringBuilder(sb); | ||
151 | |||
152 | MainConsole.Instance.Output(sb.ToString()); | ||
153 | } | ||
154 | } | ||
155 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index d1d2020..7825e3e 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | |||
@@ -343,7 +343,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
343 | public void Init() | 343 | public void Init() |
344 | { | 344 | { |
345 | m_serialiserModule = new SerialiserModule(); | 345 | m_serialiserModule = new SerialiserModule(); |
346 | m_scene = SceneHelpers.SetupScene(); | 346 | m_scene = new SceneHelpers().SetupScene(); |
347 | SceneHelpers.SetupSceneModules(m_scene, m_serialiserModule); | 347 | SceneHelpers.SetupSceneModules(m_scene, m_serialiserModule); |
348 | } | 348 | } |
349 | 349 | ||
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index da81dc1..d78ade5 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | |||
@@ -59,28 +59,32 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
59 | /// <returns>A terrain channel generated from the image.</returns> | 59 | /// <returns>A terrain channel generated from the image.</returns> |
60 | public virtual ITerrainChannel LoadFile(string filename) | 60 | public virtual ITerrainChannel LoadFile(string filename) |
61 | { | 61 | { |
62 | return LoadBitmap(new Bitmap(filename)); | 62 | using (Bitmap b = new Bitmap(filename)) |
63 | return LoadBitmap(b); | ||
63 | } | 64 | } |
64 | 65 | ||
65 | public virtual ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int w, int h) | 66 | public virtual ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int w, int h) |
66 | { | 67 | { |
67 | Bitmap bitmap = new Bitmap(filename); | 68 | using (Bitmap bitmap = new Bitmap(filename)) |
68 | ITerrainChannel retval = new TerrainChannel(true); | ||
69 | |||
70 | for (int x = 0; x < retval.Width; x++) | ||
71 | { | 69 | { |
72 | for (int y = 0; y < retval.Height; y++) | 70 | ITerrainChannel retval = new TerrainChannel(true); |
71 | |||
72 | for (int x = 0; x < retval.Width; x++) | ||
73 | { | 73 | { |
74 | retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128; | 74 | for (int y = 0; y < retval.Height; y++) |
75 | { | ||
76 | retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128; | ||
77 | } | ||
75 | } | 78 | } |
76 | } | ||
77 | 79 | ||
78 | return retval; | 80 | return retval; |
81 | } | ||
79 | } | 82 | } |
80 | 83 | ||
81 | public virtual ITerrainChannel LoadStream(Stream stream) | 84 | public virtual ITerrainChannel LoadStream(Stream stream) |
82 | { | 85 | { |
83 | return LoadBitmap(new Bitmap(stream)); | 86 | using (Bitmap b = new Bitmap(stream)) |
87 | return LoadBitmap(b); | ||
84 | } | 88 | } |
85 | 89 | ||
86 | protected virtual ITerrainChannel LoadBitmap(Bitmap bitmap) | 90 | protected virtual ITerrainChannel LoadBitmap(Bitmap bitmap) |
@@ -134,35 +138,53 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
134 | // "Saving the image to the same file it was constructed from is not allowed and throws an exception." | 138 | // "Saving the image to the same file it was constructed from is not allowed and throws an exception." |
135 | string tempName = Path.GetTempFileName(); | 139 | string tempName = Path.GetTempFileName(); |
136 | 140 | ||
137 | Bitmap entireBitmap = null; | 141 | Bitmap existingBitmap = null; |
138 | Bitmap thisBitmap = null; | 142 | Bitmap thisBitmap = null; |
139 | if (File.Exists(filename)) | 143 | Bitmap newBitmap = null; |
144 | |||
145 | try | ||
140 | { | 146 | { |
141 | File.Copy(filename, tempName, true); | 147 | if (File.Exists(filename)) |
142 | entireBitmap = new Bitmap(tempName); | 148 | { |
143 | if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY) | 149 | File.Copy(filename, tempName, true); |
150 | existingBitmap = new Bitmap(tempName); | ||
151 | if (existingBitmap.Width != fileWidth * regionSizeX || existingBitmap.Height != fileHeight * regionSizeY) | ||
152 | { | ||
153 | // old file, let's overwrite it | ||
154 | newBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | newBitmap = existingBitmap; | ||
159 | } | ||
160 | } | ||
161 | else | ||
144 | { | 162 | { |
145 | // old file, let's overwrite it | 163 | newBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); |
146 | entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); | ||
147 | } | 164 | } |
165 | |||
166 | thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); | ||
167 | // Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); | ||
168 | for (int x = 0; x < regionSizeX; x++) | ||
169 | for (int y = 0; y < regionSizeY; y++) | ||
170 | newBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); | ||
171 | |||
172 | Save(newBitmap, filename); | ||
148 | } | 173 | } |
149 | else | 174 | finally |
150 | { | 175 | { |
151 | entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); | 176 | if (existingBitmap != null) |
152 | } | 177 | existingBitmap.Dispose(); |
153 | 178 | ||
154 | thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); | 179 | if (thisBitmap != null) |
155 | // Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); | 180 | thisBitmap.Dispose(); |
156 | for (int x = 0; x < regionSizeX; x++) | ||
157 | for (int y = 0; y < regionSizeY; y++) | ||
158 | entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); | ||
159 | 181 | ||
160 | Save(entireBitmap, filename); | 182 | if (newBitmap != null) |
161 | thisBitmap.Dispose(); | 183 | newBitmap.Dispose(); |
162 | entireBitmap.Dispose(); | ||
163 | 184 | ||
164 | if (File.Exists(tempName)) | 185 | if (File.Exists(tempName)) |
165 | File.Delete(tempName); | 186 | File.Delete(tempName); |
187 | } | ||
166 | } | 188 | } |
167 | 189 | ||
168 | protected virtual void Save(Bitmap bmp, string filename) | 190 | protected virtual void Save(Bitmap bmp, string filename) |
@@ -226,16 +248,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
226 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> | 248 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> |
227 | protected static Bitmap CreateBitmapFromMap(ITerrainChannel map) | 249 | protected static Bitmap CreateBitmapFromMap(ITerrainChannel map) |
228 | { | 250 | { |
229 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 251 | int pallete; |
230 | 252 | Bitmap bmp; | |
231 | int pallete = gradientmapLd.Height; | 253 | Color[] colours; |
232 | 254 | ||
233 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 255 | using (Bitmap gradientmapLd = new Bitmap("defaultstripe.png")) |
234 | Color[] colours = new Color[pallete]; | ||
235 | |||
236 | for (int i = 0; i < pallete; i++) | ||
237 | { | 256 | { |
238 | colours[i] = gradientmapLd.GetPixel(0, i); | 257 | pallete = gradientmapLd.Height; |
258 | |||
259 | bmp = new Bitmap(map.Width, map.Height); | ||
260 | colours = new Color[pallete]; | ||
261 | |||
262 | for (int i = 0; i < pallete; i++) | ||
263 | { | ||
264 | colours[i] = gradientmapLd.GetPixel(0, i); | ||
265 | } | ||
239 | } | 266 | } |
240 | 267 | ||
241 | for (int y = 0; y < map.Height; y++) | 268 | for (int y = 0; y < map.Height; y++) |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs index 699d67a..9cc767a 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs | |||
@@ -99,16 +99,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
99 | 99 | ||
100 | private static Bitmap CreateBitmapFromMap(ITerrainChannel map) | 100 | private static Bitmap CreateBitmapFromMap(ITerrainChannel map) |
101 | { | 101 | { |
102 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 102 | int pallete; |
103 | Bitmap bmp; | ||
104 | Color[] colours; | ||
103 | 105 | ||
104 | int pallete = gradientmapLd.Height; | 106 | using (Bitmap gradientmapLd = new Bitmap("defaultstripe.png")) |
105 | |||
106 | Bitmap bmp = new Bitmap(map.Width, map.Height); | ||
107 | Color[] colours = new Color[pallete]; | ||
108 | |||
109 | for (int i = 0; i < pallete; i++) | ||
110 | { | 107 | { |
111 | colours[i] = gradientmapLd.GetPixel(0, i); | 108 | pallete = gradientmapLd.Height; |
109 | |||
110 | bmp = new Bitmap(map.Width, map.Height); | ||
111 | colours = new Color[pallete]; | ||
112 | |||
113 | for (int i = 0; i < pallete; i++) | ||
114 | { | ||
115 | colours[i] = gradientmapLd.GetPixel(0, i); | ||
116 | } | ||
112 | } | 117 | } |
113 | 118 | ||
114 | for (int y = 0; y < map.Height; y++) | 119 | for (int y = 0; y < map.Height; y++) |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs index 5d2f893..b416b82 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
59 | } | 59 | } |
60 | 60 | ||
61 | //Returns true if this extension is supported for terrain save-tile | 61 | //Returns true if this extension is supported for terrain save-tile |
62 | public bool SupportsTileSave() | 62 | public override bool SupportsTileSave() |
63 | { | 63 | { |
64 | return false; | 64 | return false; |
65 | } | 65 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs index 1ebf916..71c71e6 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
65 | bool eof = false; | 65 | bool eof = false; |
66 | 66 | ||
67 | int fileXPoints = 0; | 67 | int fileXPoints = 0; |
68 | int fileYPoints = 0; | 68 | // int fileYPoints = 0; |
69 | 69 | ||
70 | // Terragen file | 70 | // Terragen file |
71 | while (eof == false) | 71 | while (eof == false) |
@@ -75,7 +75,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
75 | { | 75 | { |
76 | case "SIZE": | 76 | case "SIZE": |
77 | fileXPoints = bs.ReadInt16() + 1; | 77 | fileXPoints = bs.ReadInt16() + 1; |
78 | fileYPoints = fileXPoints; | 78 | // fileYPoints = fileXPoints; |
79 | bs.ReadInt16(); | 79 | bs.ReadInt16(); |
80 | break; | 80 | break; |
81 | case "XPTS": | 81 | case "XPTS": |
@@ -83,7 +83,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
83 | bs.ReadInt16(); | 83 | bs.ReadInt16(); |
84 | break; | 84 | break; |
85 | case "YPTS": | 85 | case "YPTS": |
86 | fileYPoints = bs.ReadInt16(); | 86 | // fileYPoints = bs.ReadInt16(); |
87 | bs.ReadInt16(); | ||
87 | bs.ReadInt16(); | 88 | bs.ReadInt16(); |
88 | break; | 89 | break; |
89 | case "ALTW": | 90 | case "ALTW": |
@@ -164,10 +165,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
164 | bool eof = false; | 165 | bool eof = false; |
165 | if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") | 166 | if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") |
166 | { | 167 | { |
167 | 168 | // int fileWidth = w; | |
168 | int fileWidth = w; | 169 | // int fileHeight = h; |
169 | int fileHeight = h; | ||
170 | |||
171 | 170 | ||
172 | // Terragen file | 171 | // Terragen file |
173 | while (eof == false) | 172 | while (eof == false) |
@@ -176,17 +175,22 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
176 | switch (tmp) | 175 | switch (tmp) |
177 | { | 176 | { |
178 | case "SIZE": | 177 | case "SIZE": |
179 | int sztmp = bs.ReadInt16() + 1; | 178 | // int sztmp = bs.ReadInt16() + 1; |
180 | fileWidth = sztmp; | 179 | // fileWidth = sztmp; |
181 | fileHeight = sztmp; | 180 | // fileHeight = sztmp; |
181 | bs.ReadInt16(); | ||
182 | bs.ReadInt16(); | ||
183 | bs.ReadInt16(); | ||
182 | bs.ReadInt16(); | 184 | bs.ReadInt16(); |
183 | break; | 185 | break; |
184 | case "XPTS": | 186 | case "XPTS": |
185 | fileWidth = bs.ReadInt16(); | 187 | // fileWidth = bs.ReadInt16(); |
188 | bs.ReadInt16(); | ||
186 | bs.ReadInt16(); | 189 | bs.ReadInt16(); |
187 | break; | 190 | break; |
188 | case "YPTS": | 191 | case "YPTS": |
189 | fileHeight = bs.ReadInt16(); | 192 | // fileHeight = bs.ReadInt16(); |
193 | bs.ReadInt16(); | ||
190 | bs.ReadInt16(); | 194 | bs.ReadInt16(); |
191 | break; | 195 | break; |
192 | case "ALTW": | 196 | case "ALTW": |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index e2bd769..5b03ac7 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -724,6 +724,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
724 | } | 724 | } |
725 | if (shouldTaint) | 725 | if (shouldTaint) |
726 | { | 726 | { |
727 | m_scene.EventManager.TriggerTerrainTainted(); | ||
727 | m_tainted = true; | 728 | m_tainted = true; |
728 | } | 729 | } |
729 | } | 730 | } |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 899e5ea..be6b240 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -190,14 +190,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
190 | { | 190 | { |
191 | //m_log.DebugFormat("[WORLD MAP]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | 191 | //m_log.DebugFormat("[WORLD MAP]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); |
192 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | 192 | string capsBase = "/CAPS/" + caps.CapsObjectPath; |
193 | caps.RegisterHandler("MapLayer", | 193 | caps.RegisterHandler( |
194 | new RestStreamHandler("POST", capsBase + m_mapLayerPath, | 194 | "MapLayer", |
195 | delegate(string request, string path, string param, | 195 | new RestStreamHandler( |
196 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 196 | "POST", |
197 | { | 197 | capsBase + m_mapLayerPath, |
198 | return MapLayerRequest(request, path, param, | 198 | (request, path, param, httpRequest, httpResponse) |
199 | agentID, caps); | 199 | => MapLayerRequest(request, path, param, agentID, caps), |
200 | })); | 200 | "MapLayer", |
201 | agentID.ToString())); | ||
201 | } | 202 | } |
202 | 203 | ||
203 | /// <summary> | 204 | /// <summary> |