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 } } 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/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 8f4a807182..65722fe379 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -38,11 +38,14 @@ 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; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; +using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; @@ -52,27 +55,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests /// Attachment tests /// [TestFixture] - public class AttachmentsModuleTests + public class AttachmentsModuleTests : OpenSimTestCase { - private Scene scene; - private AttachmentsModule m_attMod; - private ScenePresence m_presence; - - /// - /// 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() { @@ -80,18 +64,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 +72,18 @@ 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(); + SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule()); + + return scene; + } + /// /// Creates an attachment item in the given user's inventory. Does not attach. /// @@ -109,11 +93,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,18 +116,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // TestHelpers.EnableLogging(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - m_presence = SceneHelpers.AddScenePresence(scene, m_userId); + Scene scene = CreateDefaultTestScene(); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); 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); + scene.AttachmentsModule.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)); @@ -152,14 +139,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(); @@ -171,17 +158,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - m_presence = SceneHelpers.AddScenePresence(scene, m_userId); + Scene scene = CreateDefaultTestScene(); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); - InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); - m_attMod.RezSingleAttachmentFromInventory( - m_presence, attItem.ID, (uint)AttachmentPoint.Chest); + scene.AttachmentsModule.RezSingleAttachmentFromInventory( + 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)); @@ -191,8 +179,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] @@ -201,23 +189,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - m_presence = SceneHelpers.AddScenePresence(scene, m_userId); + Scene scene = CreateDefaultTestScene(); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); - InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); ISceneEntity so - = m_attMod.RezSingleAttachmentFromInventory( - m_presence, attItem.ID, (uint)AttachmentPoint.Chest); - m_attMod.DetachSingleAttachmentToGround(m_presence, so.LocalId); + = scene.AttachmentsModule.RezSingleAttachmentFromInventory( + sp, attItem.ID, (uint)AttachmentPoint.Chest); + scene.AttachmentsModule.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); @@ -232,22 +221,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - m_presence = SceneHelpers.AddScenePresence(scene, m_userId); + Scene scene = CreateDefaultTestScene(); + UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); - InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); + InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); - m_attMod.RezSingleAttachmentFromInventory( - m_presence, attItem.ID, (uint)AttachmentPoint.Chest); - m_attMod.DetachSingleAttachmentToInv(m_presence, attItem.ID); + scene.AttachmentsModule.RezSingleAttachmentFromInventory( + sp, attItem.ID, (uint)AttachmentPoint.Chest); + scene.AttachmentsModule.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)); } /// @@ -259,10 +249,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); + Scene scene = CreateDefaultTestScene(); + 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); @@ -281,10 +272,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); + Scene scene = CreateDefaultTestScene(); + 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); @@ -314,10 +306,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests { TestHelpers.InMethod(); - UserAccountHelpers.CreateUserWithInventory(scene, m_userId); - InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); + Scene scene = CreateDefaultTestScene(); + 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); @@ -332,6 +325,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); + + 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); + + 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()); + + 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, ua1.PrincipalID, "att", 0x10, 0x20); + + sceneA.AttachmentsModule.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(ua1.PrincipalID); + + // 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(ua1.PrincipalID); + + // 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)); + } + // I'm commenting this test because scene setup NEEDS InventoryService to // be non-null //[Test] diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index 90ae69d6ff..1056865590 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); @@ -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); } diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 7d82060835..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) @@ -1666,6 +1671,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 +1973,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 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); } 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) diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 842a6979a9..aab403a203 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); @@ -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()); 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) { 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; } ///