aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-09-08 20:51:52 +0100
committerJustin Clark-Casey (justincc)2011-09-08 20:51:52 +0100
commitbd5d2cb043892399baff85667ee1e6ec6f3b3d2e (patch)
tree60d7ab71edceede360a78f2bd32d386067a780e6 /OpenSim
parentIncrease information in logging for UserAgentServiceConnector. (diff)
downloadopensim-SC_OLD-bd5d2cb043892399baff85667ee1e6ec6f3b3d2e.zip
opensim-SC_OLD-bd5d2cb043892399baff85667ee1e6ec6f3b3d2e.tar.gz
opensim-SC_OLD-bd5d2cb043892399baff85667ee1e6ec6f3b3d2e.tar.bz2
opensim-SC_OLD-bd5d2cb043892399baff85667ee1e6ec6f3b3d2e.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs19
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs77
-rw-r--r--OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs3
3 files changed, 90 insertions, 9 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 4e8466d..03238d9 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -724,8 +724,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
724 SceneObjectGroup group = null; 724 SceneObjectGroup group = null;
725 725
726 string xmlData = Utils.BytesToString(rezAsset.Data); 726 string xmlData = Utils.BytesToString(rezAsset.Data);
727 List<SceneObjectGroup> objlist = 727 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>();
728 new List<SceneObjectGroup>();
729 List<Vector3> veclist = new List<Vector3>(); 728 List<Vector3> veclist = new List<Vector3>();
730 byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); 729 byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0);
731 Vector3 pos; 730 Vector3 pos;
@@ -797,6 +796,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
797 m_log.Debug("[InventoryAccessModule]: Object has UUID.Zero! Position 3"); 796 m_log.Debug("[InventoryAccessModule]: Object has UUID.Zero! Position 3");
798 } 797 }
799 798
799 foreach (SceneObjectPart part in group.Parts)
800 {
801 // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset.
802 part.LastOwnerID = part.OwnerID;
803 part.OwnerID = remoteClient.AgentId;
804 }
805
800 if (!attachment) 806 if (!attachment)
801 { 807 {
802 // If it's rezzed in world, select it. Much easier to 808 // If it's rezzed in world, select it. Much easier to
@@ -833,13 +839,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
833 group.AbsolutePosition = pos + veclist[i]; 839 group.AbsolutePosition = pos + veclist[i];
834 } 840 }
835 841
836 SceneObjectPart rootPart = group.RootPart;
837
838 group.SetGroup(remoteClient.ActiveGroupId, remoteClient); 842 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
839 843
840 if (!attachment) 844 if (!attachment)
841 { 845 {
842 if (group.RootPart.Shape.PCode == (byte)PCode.Prim) 846 SceneObjectPart rootPart = group.RootPart;
847
848 if (rootPart.Shape.PCode == (byte)PCode.Prim)
843 group.ClearPartAttachmentData(); 849 group.ClearPartAttachmentData();
844 850
845 // Fire on_rez 851 // Fire on_rez
@@ -963,11 +969,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
963 if ((part.OwnerID != item.Owner) || 969 if ((part.OwnerID != item.Owner) ||
964 (item.CurrentPermissions & 16) != 0) 970 (item.CurrentPermissions & 16) != 0)
965 { 971 {
966 part.LastOwnerID = part.OwnerID;
967 part.OwnerID = item.Owner;
968 part.Inventory.ChangeInventoryOwner(item.Owner); 972 part.Inventory.ChangeInventoryOwner(item.Owner);
969 part.GroupMask = 0; // DO NOT propagate here 973 part.GroupMask = 0; // DO NOT propagate here
970 } 974 }
975
971 part.EveryoneMask = item.EveryOnePermissions; 976 part.EveryoneMask = item.EveryOnePermissions;
972 part.NextOwnerMask = item.NextPermissions; 977 part.NextOwnerMask = item.NextPermissions;
973 } 978 }
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index 78296a4..3bd43b4 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
30using log4net; 31using log4net;
31using Nini.Config; 32using Nini.Config;
@@ -33,7 +34,9 @@ using NUnit.Framework;
33using OpenMetaverse; 34using OpenMetaverse;
34using OpenSim.Framework; 35using OpenSim.Framework;
35using OpenSim.Framework.Communications; 36using OpenSim.Framework.Communications;
37using OpenSim.Region.CoreModules.Avatar.Attachments;
36using OpenSim.Region.CoreModules.Avatar.AvatarFactory; 38using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
39using OpenSim.Region.CoreModules.Framework.InventoryAccess;
37using OpenSim.Region.CoreModules.Framework.UserManagement; 40using OpenSim.Region.CoreModules.Framework.UserManagement;
38using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; 41using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
39using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
@@ -47,6 +50,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
47 [TestFixture] 50 [TestFixture]
48 public class NPCModuleTests 51 public class NPCModuleTests
49 { 52 {
53 [SetUp]
54 public void Init()
55 {
56 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
57 Util.FireAndForgetMethod = FireAndForgetMethod.None;
58 }
59
50 [Test] 60 [Test]
51 public void TestCreate() 61 public void TestCreate()
52 { 62 {
@@ -88,6 +98,73 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
88 } 98 }
89 99
90 [Test] 100 [Test]
101 public void TestAttachments()
102 {
103 TestHelpers.InMethod();
104// log4net.Config.XmlConfigurator.Configure();
105
106 IConfigSource config = new IniConfigSource();
107 config.AddConfig("NPC");
108 config.Configs["NPC"].Set("Enabled", "true");
109 config.AddConfig("Modules");
110 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
111
112 AvatarFactoryModule afm = new AvatarFactoryModule();
113 UserManagementModule umm = new UserManagementModule();
114 AttachmentsModule am = new AttachmentsModule();
115
116 TestScene scene = SceneHelpers.SetupScene();
117 SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule());
118
119 UUID userId = TestHelpers.ParseTail(0x1);
120 UserAccountHelpers.CreateUserWithInventory(scene, userId);
121 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
122// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
123
124 // 8 is the index of the first baked texture in AvatarAppearance
125// UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
126// Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
127// Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
128// originalTef.TextureID = originalFace8TextureId;
129
130 // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
131 // ScenePresence.SendInitialData() to reset our entire appearance.
132// scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId));
133//
134// afm.SetAppearanceFromClient(sp.ControllingClient, originalTe, null);
135
136 UUID attItemId = TestHelpers.ParseTail(0x2);
137 UUID attAssetId = TestHelpers.ParseTail(0x3);
138 string attName = "att";
139
140 UserInventoryHelpers.CreateInventoryItem(
141 scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);
142
143 am.RezSingleAttachmentFromInventory(
144 sp.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
145
146 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
147 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance);
148
149 ScenePresence npc = scene.GetScenePresence(npcId);
150
151 // Check scene presence status
152 Assert.That(npc.HasAttachments(), Is.True);
153 List<SceneObjectGroup> attachments = npc.GetAttachments();
154 Assert.That(attachments.Count, Is.EqualTo(1));
155 SceneObjectGroup attSo = attachments[0];
156
157 // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
158 // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
159// Assert.That(attSo.Name, Is.EqualTo(attName));
160 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
161 Assert.That(attSo.IsAttachment);
162 Assert.That(attSo.UsesPhysics, Is.False);
163 Assert.That(attSo.IsTemporary, Is.False);
164 Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID));
165 }
166
167 [Test]
91 public void TestMove() 168 public void TestMove()
92 { 169 {
93 TestHelpers.InMethod(); 170 TestHelpers.InMethod();
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
index 4e60ca9..ceb7905 100644
--- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
@@ -88,8 +88,7 @@ namespace OpenSim.Tests.Common
88 if (type == InventoryType.Notecard) 88 if (type == InventoryType.Notecard)
89 asset = AssetHelpers.CreateAsset(scene, userId); 89 asset = AssetHelpers.CreateAsset(scene, userId);
90 else if (type == InventoryType.Object) 90 else if (type == InventoryType.Object)
91 asset 91 asset = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId));
92 = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId));
93 else 92 else
94 throw new Exception(string.Format("Inventory type {0} not supported", type)); 93 throw new Exception(string.Format("Inventory type {0} not supported", type));
95 94