Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
avinationmerge
Melanie 2012-06-28 03:21:08 +01:00
commit 41a1903c60
17 changed files with 505 additions and 238 deletions

View File

@ -79,6 +79,16 @@ namespace OpenSim.Framework.Console
return sb.ToString();
}
public void AddColumn(string name, int width)
{
Columns.Add(new ConsoleDisplayTableColumn(name, width));
}
public void AddRow(params string[] cells)
{
Rows.Add(new ConsoleDisplayTableRow(cells));
}
public void AddToStringBuilder(StringBuilder sb)
{
string formatString = GetFormatString();
@ -135,5 +145,10 @@ namespace OpenSim.Framework.Console
{
Cells = cells;
}
public ConsoleDisplayTableRow(params string[] cells) : this()
{
Cells = new List<string>(cells);
}
}
}

View File

@ -409,10 +409,6 @@ namespace OpenSim
m_console.Commands.AddCommand("General", false, "modules unload",
"modules unload <name>",
"Unload a module", HandleModules);
m_console.Commands.AddCommand("Objects", false, "kill uuid",
"kill uuid <UUID>",
"Kill an object by UUID", KillUUID);
}
public override void ShutdownSpecific()
@ -1309,58 +1305,6 @@ namespace OpenSim
return result;
}
/// <summary>
/// Kill an object given its UUID.
/// </summary>
/// <param name="cmdparams"></param>
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 <UUID>");
}
}
#endregion
}
}

View File

@ -102,6 +102,56 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
#region IAttachmentsModule
public void CopyAttachments(IScenePresence sp, AgentData ad)
{
lock (sp.AttachmentsSyncLock)
{
// Attachment objects
List<SceneObjectGroup> attachments = sp.GetAttachments();
if (attachments.Count > 0)
{
ad.AttachmentObjects = new List<ISceneObject>();
ad.AttachmentObjectStates = new List<string>();
// IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
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);
}
}
}
/// <summary>
/// RezAttachments. This should only be called upon login on the first region.
/// Attachment rezzings on crossings and TPs are done in a different way.

View File

@ -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
/// </summary>
[TestFixture]
public class AttachmentsModuleTests
public class AttachmentsModuleTests : OpenSimTestCase
{
private Scene scene;
private AttachmentsModule m_attMod;
private ScenePresence m_presence;
/// <summary>
/// Standard user ID
/// </summary>
private UUID m_userId = TestHelpers.ParseTail(0x1);
// /// <summary>
// /// Standard attachment item ID
// /// </summary>
// private UUID m_attItemId = TestHelpers.ParseTail(0x10);
//
// /// <summary>
// /// Standard attachment asset ID
// /// </summary>
// 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;
}
/// <summary>
/// Creates an attachment item in the given user's inventory. Does not attach.
/// </summary>
@ -109,11 +93,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
/// <returns>
/// The attachment item.
/// </returns>
/// <param name='scene'></param>
/// <param name='userId'></param>
/// <param name='attName'></param>
/// <param name='rawItemId'></param>
/// <param name='rawAssetId'></param>
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, false);
scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false);
// Check status on scene presence
Assert.That(m_presence.HasAttachments(), Is.True);
List<SceneObjectGroup> attachments = m_presence.GetAttachments();
Assert.That(sp.HasAttachments(), Is.True);
List<SceneObjectGroup> 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<SceneObjectGroup> attachments = m_presence.GetAttachments();
Assert.That(sp.HasAttachments(), Is.True);
List<SceneObjectGroup> 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<SceneObjectGroup> attachments = m_presence.GetAttachments();
Assert.That(sp.HasAttachments(), Is.False);
List<SceneObjectGroup> 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<SceneObjectGroup> attachments = m_presence.GetAttachments();
Assert.That(sp.HasAttachments(), Is.False);
List<SceneObjectGroup> 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));
}
/// <summary>
@ -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<AvatarAttachment> 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<SceneObjectGroup> 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<AvatarAttachment> 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<SceneObjectGroup> 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]

View File

@ -128,7 +128,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
/// <param name="visualParam"></param>
public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams)
{
// m_log.InfoFormat("[AVFACTORY]: start SetAppearance for {0}", client.AgentId);
// m_log.DebugFormat(
// "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}",
// sp.Name, textureEntry, visualParams);
// TODO: This is probably not necessary any longer, just assume the
// textureEntry set implies that the appearance transaction is complete

View File

@ -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);
}

View File

@ -709,6 +709,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
agent.CallbackURI, region.RegionName);
}
/// <summary>
/// Clean up operations once an agent has moved away through cross or teleport.
/// </summary>
/// <param name='sp'></param>
/// <param name='logout'></param>
protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout)
{
if (sp.Scene.AttachmentsModule != null)
@ -1622,6 +1627,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
#endregion
#region Object Transfers
/// <summary>
/// Move the given scene object into a new region depending on which region its absolute position has moved
/// into.
@ -1932,35 +1938,43 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return successYN;
}
protected bool CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent)
/// <summary>
/// Cross the attachments for an avatar into the destination region.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
/// <param name='destination'></param>
/// <param name='sp'></param>
/// <param name='silent'></param>
protected void CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent)
{
List<SceneObjectGroup> m_attachments = sp.GetAttachments();
List<SceneObjectGroup> 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

View File

@ -98,7 +98,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
m_console.Commands.AddCommand(
"Objects", false, "delete object name",
"delete object name [--regex] <name>",
"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] <name>",
"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] <name>",
"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);
}

View File

@ -36,6 +36,20 @@ namespace OpenSim.Region.Framework.Interfaces
{
public interface IAttachmentsModule
{
/// <summary>
/// Copy attachment data from a ScenePresence into the AgentData structure for transmission to another simulator
/// </summary>
/// <param name='sp'></param>
/// <param name='ad'></param>
void CopyAttachments(IScenePresence sp, AgentData ad);
/// <summary>
/// Copy attachment data from an AgentData structure into a ScenePresence.
/// </summary>
/// <param name='ad'></param>
/// <param name='sp'></param>
void CopyAttachments(AgentData ad, IScenePresence sp);
/// <summary>
/// RezAttachments. This should only be called upon login on the first region.
/// Attachment rezzings on crossings and TPs are done in a different way.

View File

@ -40,6 +40,12 @@ namespace OpenSim.Region.Framework.Interfaces
/// </remarks>
public interface IScenePresence : ISceneAgent
{
/// <summary>
/// Copy of the script states while the agent is in transit. This state may
/// need to be placed back in case of transfer fail.
/// </summary>
List<string> InTransitScriptStates { get; }
/// <summary>
/// The AttachmentsModule synchronizes on this to avoid race conditions between commands to add and remove attachments.
/// </summary>

View File

@ -3279,31 +3279,8 @@ namespace OpenSim.Region.Framework.Scenes
catch { }
cAgent.DefaultAnim = Animator.Animations.DefaultAnimation;
// Attachment objects
List<SceneObjectGroup> attachments = GetAttachments();
if (attachments.Count > 0)
{
cAgent.AttachmentObjects = new List<ISceneObject>();
cAgent.AttachmentObjectStates = new List<string>();
// IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
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)
@ -3378,18 +3355,8 @@ namespace OpenSim.Region.Framework.Scenes
if (cAgent.DefaultAnim != null)
Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero);
if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0)
{
m_attachments = new List<SceneObjectGroup>();
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)

View File

@ -165,11 +165,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_LSL_Functions.llBreakLink(linknum);
}
public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
{
return m_LSL_Functions.llCastRay(start, end, options);
}
public LSL_Integer llCeil(double f)
{
return m_LSL_Functions.llCeil(f);
@ -971,6 +966,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);

View File

@ -835,35 +835,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine
int colon = firstline.IndexOf(':');
if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1)
{
string engineName = firstline.Substring(2, colon-2);
string engineName = firstline.Substring(2, colon - 2);
if (names.Contains(engineName))
{
engine = engineName;
script = "//" + script.Substring(script.IndexOf(':')+1);
script = "//" + script.Substring(colon + 1);
}
else
{
if (engine == ScriptEngineName)
{
SceneObjectPart part =
m_Scene.GetSceneObjectPart(
localID);
TaskInventoryItem item =
part.Inventory.GetInventoryItem(itemID);
// If we are falling back on XEngine as the default engine, then only complain to the user
// if a script language has been explicitly set and it's one that we recognize. If it's
// explicitly not allowed or the script is not in LSL then the user will be informed by a later compiler message.
//
// This avoids the overwhelming number of false positives where we're in this code because
// there's a colon in a comment in the first line of a script for entirely
// unrelated reasons (e.g. vim settings).
//
// TODO: A better fix would be to deprecate simple : detection and look for some less likely
// string to begin the comment (like #! in unix shell scripts).
bool scriptExplicitlyInXEngineLanguage = false;
string restOfScript = script.Substring(colon + 1);
ScenePresence presence =
m_Scene.GetScenePresence(
item.OwnerID);
// FIXME: These are hardcoded because they are currently hardcoded in Compiler.cs
if (restOfScript.StartsWith("c#")
|| restOfScript.StartsWith("vb")
|| restOfScript.StartsWith("lsl")
|| restOfScript.StartsWith("js")
|| restOfScript.StartsWith("yp"))
scriptExplicitlyInXEngineLanguage = true;
if (presence != null)
if (scriptExplicitlyInXEngineLanguage)
{
presence.ControllingClient.SendAgentAlertMessage(
"Selected engine unavailable. "+
"Running script on "+
ScriptEngineName,
false);
SceneObjectPart part =
m_Scene.GetSceneObjectPart(
localID);
TaskInventoryItem item =
part.Inventory.GetInventoryItem(itemID);
ScenePresence presence =
m_Scene.GetScenePresence(
item.OwnerID);
if (presence != null)
{
presence.ControllingClient.SendAgentAlertMessage(
"Selected engine unavailable. "+
"Running script on "+
ScriptEngineName,
false);
}
}
}
}

View File

@ -85,19 +85,38 @@ namespace OpenSim.Services.GridService
if (MainConsole.Instance != null)
{
MainConsole.Instance.Commands.AddCommand("Regions", true,
"deregister region",
"deregister region <Region UUID>",
"deregister region id",
"deregister region id <Region UUID>",
"Deregister a region manually.",
String.Empty,
HandleDeregisterRegion);
// A messy way of stopping this command being added if we are in standalone (since the simulator
// has an identically named command
//
// XXX: We're relying on the OpenSimulator version being registered first, which is not well defined.
if (MainConsole.Instance.Commands.Resolve(new string[] { "show", "regions" }).Length == 0)
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show regions",
"show regions",
"Show details on all regions",
String.Empty,
HandleShowRegions);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show region",
"show region <Region name>",
"show region name",
"show region name <Region name>",
"Show details on a region",
String.Empty,
HandleShowRegion);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show region at",
"show region at <x-coord> <y-coord>",
"Show details on a region at the given co-ordinate.",
"For example, show region at 1000 1000",
HandleShowRegionAt);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"set region flags",
"set region flags <Region name> <flags>",
@ -504,13 +523,13 @@ namespace OpenSim.Services.GridService
private void HandleDeregisterRegion(string module, string[] cmd)
{
if (cmd.Length != 3)
if (cmd.Length != 4)
{
MainConsole.Instance.Output("Syntax: degregister region <Region UUID>");
MainConsole.Instance.Output("Syntax: degregister region id <Region UUID>");
return;
}
string rawRegionUuid = cmd[2];
string rawRegionUuid = cmd[3];
UUID regionUuid;
if (!UUID.TryParse(rawRegionUuid, out regionUuid))
@ -540,36 +559,113 @@ namespace OpenSim.Services.GridService
return;
}
private void HandleShowRegions(string module, string[] cmd)
{
if (cmd.Length != 2)
{
MainConsole.Instance.Output("Syntax: show regions");
return;
}
List<RegionData> regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero);
OutputRegionsToConsoleSummary(regions);
}
private void HandleShowRegion(string module, string[] cmd)
{
if (cmd.Length != 3)
if (cmd.Length != 4)
{
MainConsole.Instance.Output("Syntax: show region <region name>");
MainConsole.Instance.Output("Syntax: show region name <region name>");
return;
}
List<RegionData> regions = m_Database.Get(cmd[2], UUID.Zero);
string regionName = cmd[3];
List<RegionData> regions = m_Database.Get(regionName, UUID.Zero);
if (regions == null || regions.Count < 1)
{
MainConsole.Instance.Output("Region not found");
MainConsole.Instance.Output("No region with name {0} found", regionName);
return;
}
OutputRegionsToConsole(regions);
}
private void HandleShowRegionAt(string module, string[] cmd)
{
if (cmd.Length != 5)
{
MainConsole.Instance.Output("Syntax: show region at <x-coord> <y-coord>");
return;
}
int x, y;
if (!int.TryParse(cmd[3], out x))
{
MainConsole.Instance.Output("x-coord must be an integer");
return;
}
if (!int.TryParse(cmd[4], out y))
{
MainConsole.Instance.Output("y-coord must be an integer");
return;
}
RegionData region = m_Database.Get(x * (int)Constants.RegionSize, y * (int)Constants.RegionSize, UUID.Zero);
if (region == null)
{
MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y);
return;
}
OutputRegionToConsole(region);
}
private void OutputRegionToConsole(RegionData r)
{
OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]);
ConsoleDisplayList dispList = new ConsoleDisplayList();
dispList.AddRow("Region Name", r.RegionName);
dispList.AddRow("Region ID", r.RegionID);
dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY));
dispList.AddRow("URI", r.Data["serverURI"]);
dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
dispList.AddRow("Flags", flags);
MainConsole.Instance.Output(dispList.ToString());
}
private void OutputRegionsToConsole(List<RegionData> regions)
{
foreach (RegionData r in regions)
OutputRegionToConsole(r);
}
private void OutputRegionsToConsoleSummary(List<RegionData> regions)
{
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"]);
ConsoleDisplayList dispList = new ConsoleDisplayList();
dispList.AddRow("Region Name", r.RegionName);
dispList.AddRow("Region ID", r.RegionID);
dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY));
dispList.AddRow("URI", r.Data["serverURI"]);
dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
dispList.AddRow("Flags", flags);
MainConsole.Instance.Output(dispList.ToString());
dispTable.AddRow(
r.RegionName,
r.RegionID.ToString(),
string.Format("{0},{1}", r.coordX, r.coordY),
r.Data["owner_uuid"].ToString(),
flags.ToString());
}
return;
MainConsole.Instance.Output(dispTable.ToString());
}
private int ParseFlags(int prev, string flags)

View File

@ -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)
{

View File

@ -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();
}
}
}

View File

@ -58,7 +58,7 @@ namespace OpenSim.Tests.Common
</root>
</log4net>"));
private static Stream DisableLoggingConfigStream
private static MemoryStream DisableLoggingConfigStream
= new MemoryStream(
Encoding.UTF8.GetBytes(
// "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/><appender-ref ref=\"A1\"/></root></log4net></configuration>"));
@ -109,6 +109,7 @@ namespace OpenSim.Tests.Common
public static void DisableLogging()
{
log4net.Config.XmlConfigurator.Configure(DisableLoggingConfigStream);
DisableLoggingConfigStream.Position = 0;
}
/// <summary>