From 988112d4460adb2c6621027145f4fe60b079c7e5 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 26 Jun 2012 15:14:25 -0400 Subject: [PATCH 01/13] Add stub for llCastRay --- OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 06f5617fac..a0b3bc8d4c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -954,6 +954,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llRequestDisplayName(id); } + public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) + { + return m_LSL_Functions.llCastRay(start, end, options); + } + public void llLinkParticleSystem(int linknum, LSL_List rules) { m_LSL_Functions.llLinkParticleSystem(linknum, rules); From 4b6c3fd4bb8e4c989a7f0b4c0687379ea4bc63c1 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 26 Jun 2012 21:06:47 +0100 Subject: [PATCH 02/13] If crossing attachments into another region pre-fatpack, clone objects before changing properties to avoid hud display race condition with update threads. This matches behaviour in fatpack crossing, where attachments are cloned before their properties are changed. This only applies to crossings to simulators running code released before April 2011. --- .../EntityTransfer/EntityTransferModule.cs | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 7d82060835..f5ebe970c2 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1666,6 +1666,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #endregion #region Object Transfers + /// /// Move the given scene object into a new region depending on which region its absolute position has moved /// into. @@ -1967,35 +1968,43 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return successYN; } - protected bool CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent) + /// + /// Cross the attachments for an avatar into the destination region. + /// + /// + /// This is only invoked for simulators released prior to April 2011. Versions of OpenSimulator since then + /// transfer attachments in one go as part of the ChildAgentDataUpdate data passed in the update agent call. + /// + /// + /// + /// + protected void CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent) { - List m_attachments = sp.GetAttachments(); + List attachments = sp.GetAttachments(); - // Validate -// foreach (SceneObjectGroup gobj in m_attachments) -// { -// if (gobj == null || gobj.IsDeleted) -// return false; -// } +// m_log.DebugFormat( +// "[ENTITY TRANSFER MODULE]: Crossing {0} attachments into {1} for {2}", +// m_attachments.Count, destination.RegionName, sp.Name); - foreach (SceneObjectGroup gobj in m_attachments) + foreach (SceneObjectGroup gobj in attachments) { // If the prim group is null then something must have happened to it! if (gobj != null && !gobj.IsDeleted) { - // Set the parent localID to 0 so it transfers over properly. - gobj.RootPart.SetParentLocalId(0); - gobj.AbsolutePosition = gobj.RootPart.AttachedPos; - gobj.IsAttachment = false; + SceneObjectGroup clone = (SceneObjectGroup)gobj.CloneForNewScene(); + clone.RootPart.GroupPosition = gobj.RootPart.AttachedPos; + clone.IsAttachment = false; + //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); - m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); - CrossPrimGroupIntoNewRegion(destination, Vector3.Zero, gobj, silent); + m_log.DebugFormat( + "[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", + clone.UUID, destination.RegionName); + + CrossPrimGroupIntoNewRegion(destination, Vector3.Zero, clone, silent); } } sp.ClearAttachments(); - - return true; } #endregion From 32a4ce94f0b896eff0ca5b91b30714e776132acf Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 26 Jun 2012 22:16:44 +0100 Subject: [PATCH 03/13] Add regression test to check that attachments in source region are deleting when an agent teleports to a neighbouring region --- .../Tests/AttachmentsModuleTests.cs | 137 +++++++++++++++--- .../EntityTransfer/EntityTransferModule.cs | 5 + 2 files changed, 122 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 8f4a807182..695994fe68 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -38,6 +38,8 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.CoreModules.Avatar.Attachments; +using OpenSim.Region.CoreModules.Framework; +using OpenSim.Region.CoreModules.Framework.EntityTransfer; using OpenSim.Region.CoreModules.Framework.InventoryAccess; using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; @@ -54,7 +56,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests [TestFixture] public class AttachmentsModuleTests { - private Scene scene; private AttachmentsModule m_attMod; private ScenePresence m_presence; @@ -80,18 +81,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Util.FireAndForgetMethod = FireAndForgetMethod.None; } - [SetUp] - public void Init() - { - IConfigSource config = new IniConfigSource(); - config.AddConfig("Modules"); - config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); - - scene = new SceneHelpers().SetupScene(); - m_attMod = new AttachmentsModule(); - SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); - } - [TestFixtureTearDown] public void TearDown() { @@ -100,6 +89,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; } + private Scene CreateDefaultTestScene() + { + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); + + Scene scene = new SceneHelpers().SetupScene(); + m_attMod = new AttachmentsModule(); + SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); + + return scene; + } + /// /// Creates an attachment item in the given user's inventory. Does not attach. /// @@ -109,11 +111,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests /// /// The attachment item. /// + /// /// /// /// /// - private InventoryItemBase CreateAttachmentItem(UUID userId, string attName, int rawItemId, int rawAssetId) + private InventoryItemBase CreateAttachmentItem( + Scene scene, UUID userId, string attName, int rawItemId, int rawAssetId) { return UserInventoryHelpers.CreateInventoryItem( scene, @@ -130,6 +134,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); + Scene scene = CreateDefaultTestScene(); UserAccountHelpers.CreateUserWithInventory(scene, m_userId); m_presence = SceneHelpers.AddScenePresence(scene, m_userId); @@ -171,10 +176,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); + Scene scene = CreateDefaultTestScene(); UserAccountHelpers.CreateUserWithInventory(scene, m_userId); m_presence = SceneHelpers.AddScenePresence(scene, m_userId); - InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); m_attMod.RezSingleAttachmentFromInventory( m_presence, attItem.ID, (uint)AttachmentPoint.Chest); @@ -201,10 +207,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); + Scene scene = CreateDefaultTestScene(); UserAccountHelpers.CreateUserWithInventory(scene, m_userId); m_presence = SceneHelpers.AddScenePresence(scene, m_userId); - InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); ISceneEntity so = m_attMod.RezSingleAttachmentFromInventory( @@ -232,10 +239,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); + Scene scene = CreateDefaultTestScene(); UserAccountHelpers.CreateUserWithInventory(scene, m_userId); m_presence = SceneHelpers.AddScenePresence(scene, m_userId); - InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); m_attMod.RezSingleAttachmentFromInventory( m_presence, attItem.ID, (uint)AttachmentPoint.Chest); @@ -259,8 +267,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); + Scene scene = CreateDefaultTestScene(); UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); acd.Appearance = new AvatarAppearance(); @@ -281,8 +290,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); + Scene scene = CreateDefaultTestScene(); UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); acd.Appearance = new AvatarAppearance(); @@ -314,8 +324,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests { TestHelpers.InMethod(); + Scene scene = CreateDefaultTestScene(); UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); acd.Appearance = new AvatarAppearance(); @@ -332,6 +343,92 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition)); } + [Test] + public void TestSameSimulatorNeighbouringRegionsTeleport() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + AttachmentsModule attModA = new AttachmentsModule(); + AttachmentsModule attModB = new AttachmentsModule(); + EntityTransferModule etmA = new EntityTransferModule(); + EntityTransferModule etmB = new EntityTransferModule(); + LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); + + IConfigSource config = new IniConfigSource(); + IConfig modulesConfig = config.AddConfig("Modules"); + modulesConfig.Set("EntityTransferModule", etmA.Name); + modulesConfig.Set("SimulationServices", lscm.Name); + IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); + + // In order to run a single threaded regression test we do not want the entity transfer module waiting + // for a callback from the destination scene before removing its avatar data. + entityTransferConfig.Set("wait_for_callback", false); + + SceneHelpers sh = new SceneHelpers(); + TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); + TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); + + SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); + SceneHelpers.SetupSceneModules( + sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule()); + SceneHelpers.SetupSceneModules( + sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule()); + + UserAccountHelpers.CreateUserWithInventory(sceneA, m_userId); + ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, m_userId, sh.SceneManager); + beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32); + + InventoryItemBase attItem = CreateAttachmentItem(sceneA, m_userId, "att", 0x10, 0x20); + + m_attMod.RezSingleAttachmentFromInventory( + beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest); + + Vector3 teleportPosition = new Vector3(10, 11, 12); + Vector3 teleportLookAt = new Vector3(20, 21, 22); + + sceneA.RequestTeleportLocation( + beforeTeleportSp.ControllingClient, + sceneB.RegionInfo.RegionHandle, + teleportPosition, + teleportLookAt, + (uint)TeleportFlags.ViaLocation); + + ((TestClient)beforeTeleportSp.ControllingClient).CompleteTeleportClientSide(); + + // Check attachments have made it into sceneB + ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(m_userId); + + // This is appearance data, as opposed to actually rezzed attachments + List sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments(); + Assert.That(sceneBAttachments.Count, Is.EqualTo(1)); + Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest)); + Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID)); + Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID)); + Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); + + // This is the actual attachment + List actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments(); + Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1)); + SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0]; + Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name)); + Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest)); + + // Check attachments have been removed from sceneA + ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(m_userId); + + // Since this is appearance data, it is still present on the child avatar! + List sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments(); + Assert.That(sceneAAttachments.Count, Is.EqualTo(1)); + Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); + + // This is the actual attachment, which should no longer exist + List actualSceneAAttachments = afterTeleportSceneASp.GetAttachments(); + Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0)); + +// TestHelpers.DisableLogging(); + } + // I'm commenting this test because scene setup NEEDS InventoryService to // be non-null //[Test] diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index f5ebe970c2..46738f687d 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -709,6 +709,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agent.CallbackURI, region.RegionName); } + /// + /// Clean up operations once an agent has moved away through cross or teleport. + /// + /// + /// protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) { if (sp.Scene.AttachmentsModule != null) From 4329cc7b8a698acc6154f3e195c6261c61014916 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 26 Jun 2012 22:21:54 +0100 Subject: [PATCH 04/13] refactor: make m_presence a local variable in all AttachmentsModuleTests since it doesn't need to be global and some tests set up more than one sp --- .../Tests/AttachmentsModuleTests.cs | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 695994fe68..4c750bc6e6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -57,7 +57,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests public class AttachmentsModuleTests { private AttachmentsModule m_attMod; - private ScenePresence m_presence; /// /// Standard user ID @@ -136,17 +135,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Scene scene = CreateDefaultTestScene(); UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - m_presence = SceneHelpers.AddScenePresence(scene, m_userId); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, m_userId); string attName = "att"; - SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, m_presence.UUID).ParentGroup; + SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID).ParentGroup; - m_attMod.AttachObject(m_presence, so, (uint)AttachmentPoint.Chest, false); + m_attMod.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false); // Check status on scene presence - Assert.That(m_presence.HasAttachments(), Is.True); - List attachments = m_presence.GetAttachments(); + Assert.That(sp.HasAttachments(), Is.True); + List attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); @@ -157,14 +156,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // Check item status Assert.That( - m_presence.Appearance.GetAttachpoint(attSo.FromItemID), + sp.Appearance.GetAttachpoint(attSo.FromItemID), Is.EqualTo((int)AttachmentPoint.Chest)); InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID)); Assert.That(attachmentItem, Is.Not.Null); Assert.That(attachmentItem.Name, Is.EqualTo(attName)); - InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(m_presence.UUID, AssetType.Object); + InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object); Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID)); // TestHelpers.DisableLogging(); @@ -178,16 +177,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Scene scene = CreateDefaultTestScene(); UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - m_presence = SceneHelpers.AddScenePresence(scene, m_userId); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, m_userId); InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); m_attMod.RezSingleAttachmentFromInventory( - m_presence, attItem.ID, (uint)AttachmentPoint.Chest); + sp, attItem.ID, (uint)AttachmentPoint.Chest); // Check scene presence status - Assert.That(m_presence.HasAttachments(), Is.True); - List attachments = m_presence.GetAttachments(); + Assert.That(sp.HasAttachments(), Is.True); + List attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attItem.Name)); @@ -197,8 +196,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.IsTemporary, Is.False); // Check appearance status - Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(1)); - Assert.That(m_presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); + Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); + Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); } [Test] @@ -209,22 +208,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Scene scene = CreateDefaultTestScene(); UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - m_presence = SceneHelpers.AddScenePresence(scene, m_userId); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, m_userId); InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); ISceneEntity so = m_attMod.RezSingleAttachmentFromInventory( - m_presence, attItem.ID, (uint)AttachmentPoint.Chest); - m_attMod.DetachSingleAttachmentToGround(m_presence, so.LocalId); + sp, attItem.ID, (uint)AttachmentPoint.Chest); + m_attMod.DetachSingleAttachmentToGround(sp, so.LocalId); // Check scene presence status - Assert.That(m_presence.HasAttachments(), Is.False); - List attachments = m_presence.GetAttachments(); + Assert.That(sp.HasAttachments(), Is.False); + List attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(0)); // Check appearance status - Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(0)); + Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(0)); // Check item status Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItem.ID)), Is.Null); @@ -241,21 +240,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Scene scene = CreateDefaultTestScene(); UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - m_presence = SceneHelpers.AddScenePresence(scene, m_userId); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, m_userId); InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); m_attMod.RezSingleAttachmentFromInventory( - m_presence, attItem.ID, (uint)AttachmentPoint.Chest); - m_attMod.DetachSingleAttachmentToInv(m_presence, attItem.ID); + sp, attItem.ID, (uint)AttachmentPoint.Chest); + m_attMod.DetachSingleAttachmentToInv(sp, attItem.ID); // Check status on scene presence - Assert.That(m_presence.HasAttachments(), Is.False); - List attachments = m_presence.GetAttachments(); + Assert.That(sp.HasAttachments(), Is.False); + List attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(0)); // Check item status - Assert.That(m_presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0)); + Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0)); } /// From 2b82c421adf23cc47e1dc4f6da941b7cd2a407b6 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 26 Jun 2012 22:31:25 +0100 Subject: [PATCH 05/13] refactor: Use local attachment module variables instead of global m_attMod. This also avoids confusion between tests where one sets up m_attMod and another accidentally uses it after failing to set one up itself. --- .../Tests/AttachmentsModuleTests.cs | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 4c750bc6e6..d233faf149 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -56,8 +56,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests [TestFixture] public class AttachmentsModuleTests { - private AttachmentsModule m_attMod; - /// /// Standard user ID /// @@ -95,8 +93,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); Scene scene = new SceneHelpers().SetupScene(); - m_attMod = new AttachmentsModule(); - SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); + SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule()); return scene; } @@ -141,7 +138,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID).ParentGroup; - m_attMod.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false); + scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false); // Check status on scene presence Assert.That(sp.HasAttachments(), Is.True); @@ -181,7 +178,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); - m_attMod.RezSingleAttachmentFromInventory( + scene.AttachmentsModule.RezSingleAttachmentFromInventory( sp, attItem.ID, (uint)AttachmentPoint.Chest); // Check scene presence status @@ -213,9 +210,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); ISceneEntity so - = m_attMod.RezSingleAttachmentFromInventory( + = scene.AttachmentsModule.RezSingleAttachmentFromInventory( sp, attItem.ID, (uint)AttachmentPoint.Chest); - m_attMod.DetachSingleAttachmentToGround(sp, so.LocalId); + scene.AttachmentsModule.DetachSingleAttachmentToGround(sp, so.LocalId); // Check scene presence status Assert.That(sp.HasAttachments(), Is.False); @@ -244,9 +241,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); - m_attMod.RezSingleAttachmentFromInventory( + scene.AttachmentsModule.RezSingleAttachmentFromInventory( sp, attItem.ID, (uint)AttachmentPoint.Chest); - m_attMod.DetachSingleAttachmentToInv(sp, attItem.ID); + scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, attItem.ID); // Check status on scene presence Assert.That(sp.HasAttachments(), Is.False); @@ -364,6 +361,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // for a callback from the destination scene before removing its avatar data. entityTransferConfig.Set("wait_for_callback", false); + modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule"); + SceneHelpers sh = new SceneHelpers(); TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); @@ -380,7 +379,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests InventoryItemBase attItem = CreateAttachmentItem(sceneA, m_userId, "att", 0x10, 0x20); - m_attMod.RezSingleAttachmentFromInventory( + sceneA.AttachmentsModule.RezSingleAttachmentFromInventory( beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest); Vector3 teleportPosition = new Vector3(10, 11, 12); From 99954c14980817adae427ab8ac4cdf07cbad0d7d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 26 Jun 2012 22:53:08 +0100 Subject: [PATCH 06/13] refactor: Remove unnecessary AttachmentModuleTests.m_userId in favour of local variables --- .../Tests/AttachmentsModuleTests.cs | 66 ++++++++----------- .../Common/Helpers/UserAccountHelpers.cs | 5 ++ 2 files changed, 31 insertions(+), 40 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index d233faf149..ddfc6cb004 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -45,6 +45,7 @@ using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; +using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; @@ -56,21 +57,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests [TestFixture] public class AttachmentsModuleTests { - /// - /// Standard user ID - /// - private UUID m_userId = TestHelpers.ParseTail(0x1); - -// /// -// /// Standard attachment item ID -// /// -// private UUID m_attItemId = TestHelpers.ParseTail(0x10); -// -// /// -// /// Standard attachment asset ID -// /// -// private UUID m_attAssetId = TestHelpers.ParseTail(0x11); - [TestFixtureSetUp] public void FixtureInit() { @@ -131,8 +117,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // TestHelpers.EnableLogging(); Scene scene = CreateDefaultTestScene(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - ScenePresence sp = SceneHelpers.AddScenePresence(scene, m_userId); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); string attName = "att"; @@ -173,10 +159,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = CreateDefaultTestScene(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - ScenePresence sp = SceneHelpers.AddScenePresence(scene, m_userId); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); - InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); scene.AttachmentsModule.RezSingleAttachmentFromInventory( sp, attItem.ID, (uint)AttachmentPoint.Chest); @@ -204,10 +190,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = CreateDefaultTestScene(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - ScenePresence sp = SceneHelpers.AddScenePresence(scene, m_userId); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); - InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); ISceneEntity so = scene.AttachmentsModule.RezSingleAttachmentFromInventory( @@ -236,10 +222,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = CreateDefaultTestScene(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - ScenePresence sp = SceneHelpers.AddScenePresence(scene, m_userId); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); - InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); scene.AttachmentsModule.RezSingleAttachmentFromInventory( sp, attItem.ID, (uint)AttachmentPoint.Chest); @@ -264,10 +250,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = CreateDefaultTestScene(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); + InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); - AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); + AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); acd.Appearance = new AvatarAppearance(); acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); @@ -287,10 +273,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // log4net.Config.XmlConfigurator.Configure(); Scene scene = CreateDefaultTestScene(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); + InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); - AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); + AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); acd.Appearance = new AvatarAppearance(); acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); @@ -321,10 +307,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); Scene scene = CreateDefaultTestScene(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); + InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); - AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); + AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); acd.Appearance = new AvatarAppearance(); acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); ScenePresence sp = SceneHelpers.AddScenePresence(scene, acd); @@ -373,11 +359,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests SceneHelpers.SetupSceneModules( sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule()); - UserAccountHelpers.CreateUserWithInventory(sceneA, m_userId); - ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, m_userId, sh.SceneManager); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1); + ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, ua1.PrincipalID, sh.SceneManager); beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32); - InventoryItemBase attItem = CreateAttachmentItem(sceneA, m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20); sceneA.AttachmentsModule.RezSingleAttachmentFromInventory( beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest); @@ -395,7 +381,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests ((TestClient)beforeTeleportSp.ControllingClient).CompleteTeleportClientSide(); // Check attachments have made it into sceneB - ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(m_userId); + ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID); // This is appearance data, as opposed to actually rezzed attachments List sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments(); @@ -413,7 +399,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest)); // Check attachments have been removed from sceneA - ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(m_userId); + ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID); // Since this is appearance data, it is still present on the child avatar! List sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments(); diff --git a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs index b73df2ca4c..3d3e65c58c 100644 --- a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs @@ -126,6 +126,11 @@ namespace OpenSim.Tests.Common return CreateUserWithInventory(scene, "Bill", "Bailey", userId, "troll"); } + public static UserAccount CreateUserWithInventory(Scene scene, int userId) + { + return CreateUserWithInventory(scene, "Bill", "Bailey", TestHelpers.ParseTail(userId), "troll"); + } + public static UserAccount CreateUserWithInventory( Scene scene, string firstName, string lastName, UUID userId, string pw) { From 25245179868990b07d4431e2dc2e800a4de372e5 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 26 Jun 2012 22:54:41 +0100 Subject: [PATCH 07/13] minor: correct GridService "show regions" cibsike cinnabd usage statement --- OpenSim/Services/GridService/GridService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 842a6979a9..36cd573c6b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -98,7 +98,7 @@ namespace OpenSim.Services.GridService if (MainConsole.Instance.Commands.Resolve(new string[] { "show", "regions" }).Length == 0) MainConsole.Instance.Commands.AddCommand("Regions", true, "show regions", - "show all regions", + "show regions", "Show details on all regions", String.Empty, HandleShowRegions); From 97437feb06060fa58f8209e32c362bfe91c279f5 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 26 Jun 2012 23:05:10 +0100 Subject: [PATCH 08/13] Show region positions in "show regions" robust console command --- OpenSim/Services/GridService/GridService.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 36cd573c6b..aab403a203 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -650,13 +650,19 @@ namespace OpenSim.Services.GridService ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); dispTable.AddColumn("Name", 16); dispTable.AddColumn("ID", 36); + dispTable.AddColumn("Position", 11); dispTable.AddColumn("Owner ID", 36); dispTable.AddColumn("Flags", 60); foreach (RegionData r in regions) { OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); - dispTable.AddRow(r.RegionName, r.RegionID.ToString(), r.Data["owner_uuid"].ToString(), flags.ToString()); + dispTable.AddRow( + r.RegionName, + r.RegionID.ToString(), + string.Format("{0},{1}", r.coordX, r.coordY), + r.Data["owner_uuid"].ToString(), + flags.ToString()); } MainConsole.Instance.Output(dispTable.ToString()); From 0b298777907d29027336813d84e589f0cb78419b Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 26 Jun 2012 23:15:15 +0100 Subject: [PATCH 09/13] Fix output for help on some object region console commands --- .../World/Objects/Commands/ObjectCommandsModule.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 830d9cbc1b..e5cd3e2133 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -98,7 +98,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands m_console.Commands.AddCommand( "Objects", false, "delete object name", "delete object name [--regex] ", - "Delete a scene object by name.\nIf --regex is specified then the name is treatead as a regular expression", + "Delete a scene object by name.", + "If --regex is specified then the name is treatead as a regular expression", HandleDeleteObject); m_console.Commands.AddCommand( @@ -118,7 +119,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands false, "show object name", "show object name [--regex] ", - "Show details of scene objects with the given name.\nIf --regex is specified then the name is treatead as a regular expression", + "Show details of scene objects with the given name.", + "If --regex is specified then the name is treatead as a regular expression", HandleShowObjectByName); m_console.Commands.AddCommand( @@ -133,7 +135,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands false, "show part name", "show part name [--regex] ", - "Show details of scene object parts with the given name.\nIf --regex is specified then the name is treatead as a regular expression", + "Show details of scene object parts with the given name.", + "If --regex is specified then the name is treatead as a regular expression", HandleShowPartByName); } From 87ca820f9bc19fc1f8c7b88a87bdef59e0a5bd0b Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 26 Jun 2012 23:28:48 +0100 Subject: [PATCH 10/13] Replace "kill uuid" console command with the more consistent "delete object uuid", which was present in the last opensim release. --- OpenSim/Region/Application/OpenSim.cs | 56 --------------------------- 1 file changed, 56 deletions(-) diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 04ff4e62e6..56ad5c9e47 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -409,10 +409,6 @@ namespace OpenSim m_console.Commands.AddCommand("General", false, "modules unload", "modules unload ", "Unload a module", HandleModules); - - m_console.Commands.AddCommand("Objects", false, "kill uuid", - "kill uuid ", - "Kill an object by UUID", KillUUID); } public override void ShutdownSpecific() @@ -1309,58 +1305,6 @@ namespace OpenSim return result; } - /// - /// Kill an object given its UUID. - /// - /// - protected void KillUUID(string module, string[] cmdparams) - { - if (cmdparams.Length > 2) - { - UUID id = UUID.Zero; - SceneObjectGroup grp = null; - Scene sc = null; - - if (!UUID.TryParse(cmdparams[2], out id)) - { - MainConsole.Instance.Output("[KillUUID]: Error bad UUID format!"); - return; - } - - m_sceneManager.ForEachScene( - delegate(Scene scene) - { - SceneObjectPart part = scene.GetSceneObjectPart(id); - if (part == null) - return; - - grp = part.ParentGroup; - sc = scene; - }); - - if (grp == null) - { - MainConsole.Instance.Output(String.Format("[KillUUID]: Given UUID {0} not found!", id)); - } - else - { - MainConsole.Instance.Output(String.Format("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName)); - try - { - sc.DeleteSceneObject(grp, false); - } - catch (Exception e) - { - m_log.ErrorFormat("[KillUUID]: Error while removing objects from scene: " + e); - } - } - } - else - { - MainConsole.Instance.Output("[KillUUID]: Usage: kill uuid "); - } - } - #endregion } } From 5bec5bcf714a94129070cf1b6219984496cbd6c2 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 27 Jun 2012 00:00:49 +0100 Subject: [PATCH 11/13] Automatically disable log4net before each regression test so that logging is confined to a single test if it's turned on. This involves making test classes inherit from a common OpenSimTestCase. This will be applied to more classes as required. --- .../Tests/AttachmentsModuleTests.cs | 4 +- .../Tests/InventoryArchiveTestCase.cs | 2 +- OpenSim/Tests/Common/OpenSimTestCase.cs | 46 +++++++++++++++++++ OpenSim/Tests/Common/TestHelpers.cs | 3 +- 4 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 OpenSim/Tests/Common/OpenSimTestCase.cs diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index ddfc6cb004..65722fe379 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests /// Attachment tests /// [TestFixture] - public class AttachmentsModuleTests + public class AttachmentsModuleTests : OpenSimTestCase { [TestFixtureSetUp] public void FixtureInit() @@ -409,8 +409,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // This is the actual attachment, which should no longer exist List actualSceneAAttachments = afterTeleportSceneASp.GetAttachments(); Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0)); - -// TestHelpers.DisableLogging(); } // I'm commenting this test because scene setup NEEDS InventoryService to diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index 90ae69d6ff..f9d4b785d6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs @@ -48,7 +48,7 @@ using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests { [TestFixture] - public class InventoryArchiveTestCase + public class InventoryArchiveTestCase : OpenSimTestCase { protected ManualResetEvent mre = new ManualResetEvent(false); diff --git a/OpenSim/Tests/Common/OpenSimTestCase.cs b/OpenSim/Tests/Common/OpenSimTestCase.cs new file mode 100644 index 0000000000..8c40923017 --- /dev/null +++ b/OpenSim/Tests/Common/OpenSimTestCase.cs @@ -0,0 +1,46 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using NUnit.Framework; + +namespace OpenSim.Tests.Common +{ + [TestFixture] + public class OpenSimTestCase + { + [SetUp] + public virtual void SetUp() + { +// TestHelpers.InMethod(); + // Disable logging for each test so that one where logging is enabled doesn't cause all subsequent tests + // to have logging on if it failed with an exception. + TestHelpers.DisableLogging(); + } + } +} + diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs index d38d692ed6..30121fef6a 100644 --- a/OpenSim/Tests/Common/TestHelpers.cs +++ b/OpenSim/Tests/Common/TestHelpers.cs @@ -58,7 +58,7 @@ namespace OpenSim.Tests.Common ")); - private static Stream DisableLoggingConfigStream + private static MemoryStream DisableLoggingConfigStream = new MemoryStream( Encoding.UTF8.GetBytes( // "")); @@ -109,6 +109,7 @@ namespace OpenSim.Tests.Common public static void DisableLogging() { log4net.Config.XmlConfigurator.Configure(DisableLoggingConfigStream); + DisableLoggingConfigStream.Position = 0; } /// From d0432133172f4147f7401f214c703611978423cd Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 27 Jun 2012 00:41:46 +0100 Subject: [PATCH 12/13] refactor: Move ScenePresence <-> AgentData attachments copying code into AttachmentsModule. --- .../Avatar/Attachments/AttachmentsModule.cs | 50 +++++++++++++++++++ .../Interfaces/IAttachmentsModule.cs | 14 ++++++ .../Framework/Interfaces/IScenePresence.cs | 6 +++ .../Region/Framework/Scenes/ScenePresence.cs | 41 ++------------- 4 files changed, 74 insertions(+), 37 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2b0e4ab5b3..4a7fbcee96 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -100,6 +100,56 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments #region IAttachmentsModule + public void CopyAttachments(IScenePresence sp, AgentData ad) + { + lock (sp.AttachmentsSyncLock) + { + // Attachment objects + List attachments = sp.GetAttachments(); + if (attachments.Count > 0) + { + ad.AttachmentObjects = new List(); + ad.AttachmentObjectStates = new List(); + // IScriptModule se = m_scene.RequestModuleInterface(); + sp.InTransitScriptStates.Clear(); + + foreach (SceneObjectGroup sog in attachments) + { + // We need to make a copy and pass that copy + // because of transfers withn the same sim + ISceneObject clone = sog.CloneForNewScene(); + // Attachment module assumes that GroupPosition holds the offsets...! + ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; + ((SceneObjectGroup)clone).IsAttachment = false; + ad.AttachmentObjects.Add(clone); + string state = sog.GetStateSnapshot(); + ad.AttachmentObjectStates.Add(state); + sp.InTransitScriptStates.Add(state); + // Let's remove the scripts of the original object here + sog.RemoveScriptInstances(true); + } + } + } + } + + public void CopyAttachments(AgentData ad, IScenePresence sp) + { + if (ad.AttachmentObjects != null && ad.AttachmentObjects.Count > 0) + { + lock (sp.AttachmentsSyncLock) + sp.ClearAttachments(); + + int i = 0; + foreach (ISceneObject so in ad.AttachmentObjects) + { + ((SceneObjectGroup)so).LocalId = 0; + ((SceneObjectGroup)so).RootPart.ClearUpdateSchedule(); + so.SetState(ad.AttachmentObjectStates[i++], m_scene); + m_scene.IncomingCreateObject(Vector3.Zero, so); + } + } + } + /// /// RezAttachments. This should only be called upon login on the first region. /// Attachment rezzings on crossings and TPs are done in a different way. diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index fde5de1561..375d3345a2 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -35,6 +35,20 @@ namespace OpenSim.Region.Framework.Interfaces { public interface IAttachmentsModule { + /// + /// Copy attachment data from a ScenePresence into the AgentData structure for transmission to another simulator + /// + /// + /// + void CopyAttachments(IScenePresence sp, AgentData ad); + + /// + /// Copy attachment data from an AgentData structure into a ScenePresence. + /// + /// + /// + void CopyAttachments(AgentData ad, IScenePresence sp); + /// /// RezAttachments. This should only be called upon login on the first region. /// Attachment rezzings on crossings and TPs are done in a different way. diff --git a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs index 5e43843faf..19a8236427 100644 --- a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs +++ b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs @@ -40,6 +40,12 @@ namespace OpenSim.Region.Framework.Interfaces /// public interface IScenePresence : ISceneAgent { + /// + /// Copy of the script states while the agent is in transit. This state may + /// need to be placed back in case of transfer fail. + /// + List InTransitScriptStates { get; } + /// /// The AttachmentsModule synchronizes on this to avoid race conditions between commands to add and remove attachments. /// diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 909c7c86d7..c7a670f2c2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3084,31 +3084,8 @@ namespace OpenSim.Region.Framework.Scenes } catch { } - // Attachment objects - List attachments = GetAttachments(); - if (attachments.Count > 0) - { - cAgent.AttachmentObjects = new List(); - cAgent.AttachmentObjectStates = new List(); -// IScriptModule se = m_scene.RequestModuleInterface(); - InTransitScriptStates.Clear(); - - foreach (SceneObjectGroup sog in attachments) - { - // We need to make a copy and pass that copy - // because of transfers withn the same sim - ISceneObject clone = sog.CloneForNewScene(); - // Attachment module assumes that GroupPosition holds the offsets...! - ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; - ((SceneObjectGroup)clone).IsAttachment = false; - cAgent.AttachmentObjects.Add(clone); - string state = sog.GetStateSnapshot(); - cAgent.AttachmentObjectStates.Add(state); - InTransitScriptStates.Add(state); - // Let's remove the scripts of the original object here - sog.RemoveScriptInstances(true); - } - } + if (Scene.AttachmentsModule != null) + Scene.AttachmentsModule.CopyAttachments(this, cAgent); } private void CopyFrom(AgentData cAgent) @@ -3178,18 +3155,8 @@ namespace OpenSim.Region.Framework.Scenes if (cAgent.Anims != null) Animator.Animations.FromArray(cAgent.Anims); - if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0) - { - m_attachments = new List(); - int i = 0; - foreach (ISceneObject so in cAgent.AttachmentObjects) - { - ((SceneObjectGroup)so).LocalId = 0; - ((SceneObjectGroup)so).RootPart.ClearUpdateSchedule(); - so.SetState(cAgent.AttachmentObjectStates[i++], m_scene); - m_scene.IncomingCreateObject(Vector3.Zero, so); - } - } + if (Scene.AttachmentsModule != null) + Scene.AttachmentsModule.CopyAttachments(cAgent, this); } public bool CopyAgent(out IAgentData agent) From bb48060b447a1b9c85f8652cd4bd177558d3bb0d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 27 Jun 2012 00:50:36 +0100 Subject: [PATCH 13/13] Fix issue in InventoryArchiveTestCase where it didn't call down to OpenSimTestCase.SetUp() --- .../Inventory/Archiver/Tests/InventoryArchiveTestCase.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index f9d4b785d6..1056865590 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs @@ -84,8 +84,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests protected string m_coaItemName = "Coalesced Item"; [SetUp] - public virtual void SetUp() + public override void SetUp() { + base.SetUp(); m_iarStream = new MemoryStream(m_iarStreamBytes); }