Use scene presence agent id for rezzed object ownership rather than item owner.
These should be identical. However, the item isn't available when rezzing npc attachments.remove-scene-viewer
parent
3e7960d161
commit
bd5d2cb043
|
@ -724,8 +724,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
SceneObjectGroup group = null;
|
SceneObjectGroup group = null;
|
||||||
|
|
||||||
string xmlData = Utils.BytesToString(rezAsset.Data);
|
string xmlData = Utils.BytesToString(rezAsset.Data);
|
||||||
List<SceneObjectGroup> objlist =
|
List<SceneObjectGroup> objlist = new List<SceneObjectGroup>();
|
||||||
new List<SceneObjectGroup>();
|
|
||||||
List<Vector3> veclist = new List<Vector3>();
|
List<Vector3> veclist = new List<Vector3>();
|
||||||
byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0);
|
byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0);
|
||||||
Vector3 pos;
|
Vector3 pos;
|
||||||
|
@ -797,6 +796,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
m_log.Debug("[InventoryAccessModule]: Object has UUID.Zero! Position 3");
|
m_log.Debug("[InventoryAccessModule]: Object has UUID.Zero! Position 3");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (SceneObjectPart part in group.Parts)
|
||||||
|
{
|
||||||
|
// Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset.
|
||||||
|
part.LastOwnerID = part.OwnerID;
|
||||||
|
part.OwnerID = remoteClient.AgentId;
|
||||||
|
}
|
||||||
|
|
||||||
if (!attachment)
|
if (!attachment)
|
||||||
{
|
{
|
||||||
// If it's rezzed in world, select it. Much easier to
|
// If it's rezzed in world, select it. Much easier to
|
||||||
|
@ -833,13 +839,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
group.AbsolutePosition = pos + veclist[i];
|
group.AbsolutePosition = pos + veclist[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneObjectPart rootPart = group.RootPart;
|
|
||||||
|
|
||||||
group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
|
group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
|
||||||
|
|
||||||
if (!attachment)
|
if (!attachment)
|
||||||
{
|
{
|
||||||
if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
|
SceneObjectPart rootPart = group.RootPart;
|
||||||
|
|
||||||
|
if (rootPart.Shape.PCode == (byte)PCode.Prim)
|
||||||
group.ClearPartAttachmentData();
|
group.ClearPartAttachmentData();
|
||||||
|
|
||||||
// Fire on_rez
|
// Fire on_rez
|
||||||
|
@ -963,11 +969,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
if ((part.OwnerID != item.Owner) ||
|
if ((part.OwnerID != item.Owner) ||
|
||||||
(item.CurrentPermissions & 16) != 0)
|
(item.CurrentPermissions & 16) != 0)
|
||||||
{
|
{
|
||||||
part.LastOwnerID = part.OwnerID;
|
|
||||||
part.OwnerID = item.Owner;
|
|
||||||
part.Inventory.ChangeInventoryOwner(item.Owner);
|
part.Inventory.ChangeInventoryOwner(item.Owner);
|
||||||
part.GroupMask = 0; // DO NOT propagate here
|
part.GroupMask = 0; // DO NOT propagate here
|
||||||
}
|
}
|
||||||
|
|
||||||
part.EveryoneMask = item.EveryOnePermissions;
|
part.EveryoneMask = item.EveryOnePermissions;
|
||||||
part.NextOwnerMask = item.NextPermissions;
|
part.NextOwnerMask = item.NextPermissions;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
|
@ -33,7 +34,9 @@ using NUnit.Framework;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications;
|
using OpenSim.Framework.Communications;
|
||||||
|
using OpenSim.Region.CoreModules.Avatar.Attachments;
|
||||||
using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
|
using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
|
||||||
|
using OpenSim.Region.CoreModules.Framework.InventoryAccess;
|
||||||
using OpenSim.Region.CoreModules.Framework.UserManagement;
|
using OpenSim.Region.CoreModules.Framework.UserManagement;
|
||||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
@ -47,6 +50,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class NPCModuleTests
|
public class NPCModuleTests
|
||||||
{
|
{
|
||||||
|
[SetUp]
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
// Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
|
||||||
|
Util.FireAndForgetMethod = FireAndForgetMethod.None;
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestCreate()
|
public void TestCreate()
|
||||||
{
|
{
|
||||||
|
@ -87,6 +97,73 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
|
||||||
Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
|
Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAttachments()
|
||||||
|
{
|
||||||
|
TestHelpers.InMethod();
|
||||||
|
// log4net.Config.XmlConfigurator.Configure();
|
||||||
|
|
||||||
|
IConfigSource config = new IniConfigSource();
|
||||||
|
config.AddConfig("NPC");
|
||||||
|
config.Configs["NPC"].Set("Enabled", "true");
|
||||||
|
config.AddConfig("Modules");
|
||||||
|
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
|
||||||
|
|
||||||
|
AvatarFactoryModule afm = new AvatarFactoryModule();
|
||||||
|
UserManagementModule umm = new UserManagementModule();
|
||||||
|
AttachmentsModule am = new AttachmentsModule();
|
||||||
|
|
||||||
|
TestScene scene = SceneHelpers.SetupScene();
|
||||||
|
SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule());
|
||||||
|
|
||||||
|
UUID userId = TestHelpers.ParseTail(0x1);
|
||||||
|
UserAccountHelpers.CreateUserWithInventory(scene, userId);
|
||||||
|
ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
|
||||||
|
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
|
||||||
|
|
||||||
|
// 8 is the index of the first baked texture in AvatarAppearance
|
||||||
|
// UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
|
||||||
|
// Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
|
||||||
|
// Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
|
||||||
|
// originalTef.TextureID = originalFace8TextureId;
|
||||||
|
|
||||||
|
// We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
|
||||||
|
// ScenePresence.SendInitialData() to reset our entire appearance.
|
||||||
|
// scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId));
|
||||||
|
//
|
||||||
|
// afm.SetAppearanceFromClient(sp.ControllingClient, originalTe, null);
|
||||||
|
|
||||||
|
UUID attItemId = TestHelpers.ParseTail(0x2);
|
||||||
|
UUID attAssetId = TestHelpers.ParseTail(0x3);
|
||||||
|
string attName = "att";
|
||||||
|
|
||||||
|
UserInventoryHelpers.CreateInventoryItem(
|
||||||
|
scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);
|
||||||
|
|
||||||
|
am.RezSingleAttachmentFromInventory(
|
||||||
|
sp.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
|
||||||
|
|
||||||
|
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
|
||||||
|
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance);
|
||||||
|
|
||||||
|
ScenePresence npc = scene.GetScenePresence(npcId);
|
||||||
|
|
||||||
|
// Check scene presence status
|
||||||
|
Assert.That(npc.HasAttachments(), Is.True);
|
||||||
|
List<SceneObjectGroup> attachments = npc.GetAttachments();
|
||||||
|
Assert.That(attachments.Count, Is.EqualTo(1));
|
||||||
|
SceneObjectGroup attSo = attachments[0];
|
||||||
|
|
||||||
|
// Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
|
||||||
|
// name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
|
||||||
|
// Assert.That(attSo.Name, Is.EqualTo(attName));
|
||||||
|
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
|
||||||
|
Assert.That(attSo.IsAttachment);
|
||||||
|
Assert.That(attSo.UsesPhysics, Is.False);
|
||||||
|
Assert.That(attSo.IsTemporary, Is.False);
|
||||||
|
Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestMove()
|
public void TestMove()
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,8 +88,7 @@ namespace OpenSim.Tests.Common
|
||||||
if (type == InventoryType.Notecard)
|
if (type == InventoryType.Notecard)
|
||||||
asset = AssetHelpers.CreateAsset(scene, userId);
|
asset = AssetHelpers.CreateAsset(scene, userId);
|
||||||
else if (type == InventoryType.Object)
|
else if (type == InventoryType.Object)
|
||||||
asset
|
asset = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId));
|
||||||
= AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId));
|
|
||||||
else
|
else
|
||||||
throw new Exception(string.Format("Inventory type {0} not supported", type));
|
throw new Exception(string.Format("Inventory type {0} not supported", type));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue