diff options
author | Justin Clark-Casey (justincc) | 2012-07-05 00:05:06 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-07-05 00:05:06 +0100 |
commit | 951b45b80fd504b4874b9ec3e0fbff49a25cb46f (patch) | |
tree | 29b59d97d8b8ce8ee00227c41227d824d6694efa /OpenSim | |
parent | Use GetInventoryItem() in llRezAtRoot rather than iterating through a cloned ... (diff) | |
download | opensim-SC_OLD-951b45b80fd504b4874b9ec3e0fbff49a25cb46f.zip opensim-SC_OLD-951b45b80fd504b4874b9ec3e0fbff49a25cb46f.tar.gz opensim-SC_OLD-951b45b80fd504b4874b9ec3e0fbff49a25cb46f.tar.bz2 opensim-SC_OLD-951b45b80fd504b4874b9ec3e0fbff49a25cb46f.tar.xz |
Add OSSL function osForceAttachToAvatarFromInventory()
This works like osForceAttachToAvatar() but allows an object to be directly specified from the script object's inventory rather than forcing it to be rezzed in the scene first.
Still only attaches objects to the owner of the script.
This allows one to bypass the complicated co-ordination of first rezzing objects in the scene before attaching them.
Threat level high.
Diffstat (limited to 'OpenSim')
17 files changed, 340 insertions, 51 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index b0c087f..7856953 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -122,7 +122,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
122 | 122 | ||
123 | string attName = "att"; | 123 | string attName = "att"; |
124 | 124 | ||
125 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID).ParentGroup; | 125 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); |
126 | 126 | ||
127 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false); | 127 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false); |
128 | 128 | ||
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs index 0545250..396095a 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs | |||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests | |||
63 | TestHelpers.InMethod(); | 63 | TestHelpers.InMethod(); |
64 | // log4net.Config.XmlConfigurator.Configure(); | 64 | // log4net.Config.XmlConfigurator.Configure(); |
65 | 65 | ||
66 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); | 66 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
67 | MediaEntry me = new MediaEntry(); | 67 | MediaEntry me = new MediaEntry(); |
68 | 68 | ||
69 | m_module.SetMediaEntry(part, 1, me); | 69 | m_module.SetMediaEntry(part, 1, me); |
@@ -88,7 +88,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests | |||
88 | 88 | ||
89 | string homeUrl = "opensimulator.org"; | 89 | string homeUrl = "opensimulator.org"; |
90 | 90 | ||
91 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); | 91 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
92 | MediaEntry me = new MediaEntry() { HomeURL = homeUrl }; | 92 | MediaEntry me = new MediaEntry() { HomeURL = homeUrl }; |
93 | 93 | ||
94 | m_module.SetMediaEntry(part, 1, me); | 94 | m_module.SetMediaEntry(part, 1, me); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 81add43..3398a53 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs | |||
@@ -186,15 +186,15 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
186 | TestHelpers.InMethod(); | 186 | TestHelpers.InMethod(); |
187 | 187 | ||
188 | TestScene scene = new SceneHelpers().SetupScene(); | 188 | TestScene scene = new SceneHelpers().SetupScene(); |
189 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); | 189 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene); |
190 | 190 | ||
191 | Assert.That(part.ParentGroup.IsDeleted, Is.False); | 191 | Assert.That(so.IsDeleted, Is.False); |
192 | 192 | ||
193 | scene.DeleteSceneObject(part.ParentGroup, false); | 193 | scene.DeleteSceneObject(so, false); |
194 | 194 | ||
195 | Assert.That(part.ParentGroup.IsDeleted, Is.True); | 195 | Assert.That(so.IsDeleted, Is.True); |
196 | 196 | ||
197 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | 197 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); |
198 | Assert.That(retrievedPart, Is.Null); | 198 | Assert.That(retrievedPart, Is.Null); |
199 | } | 199 | } |
200 | 200 | ||
@@ -215,22 +215,22 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
215 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | 215 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; |
216 | sogd.Enabled = false; | 216 | sogd.Enabled = false; |
217 | 217 | ||
218 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); | 218 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene); |
219 | 219 | ||
220 | IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; | 220 | IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; |
221 | scene.DeRezObjects(client, new System.Collections.Generic.List<uint>() { part.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero); | 221 | scene.DeRezObjects(client, new System.Collections.Generic.List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero); |
222 | 222 | ||
223 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | 223 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); |
224 | 224 | ||
225 | Assert.That(retrievedPart, Is.Not.Null); | 225 | Assert.That(retrievedPart, Is.Not.Null); |
226 | 226 | ||
227 | Assert.That(part.ParentGroup.IsDeleted, Is.False); | 227 | Assert.That(so.IsDeleted, Is.False); |
228 | 228 | ||
229 | sogd.InventoryDeQueueAndDelete(); | 229 | sogd.InventoryDeQueueAndDelete(); |
230 | 230 | ||
231 | Assert.That(part.ParentGroup.IsDeleted, Is.True); | 231 | Assert.That(so.IsDeleted, Is.True); |
232 | 232 | ||
233 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); | 233 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); |
234 | Assert.That(retrievedPart2, Is.Null); | 234 | Assert.That(retrievedPart2, Is.Null); |
235 | } | 235 | } |
236 | 236 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs index 1add3dd..0e525c9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs | |||
@@ -72,10 +72,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
72 | bool debugtest = false; | 72 | bool debugtest = false; |
73 | 73 | ||
74 | Scene scene = new SceneHelpers().SetupScene(); | 74 | Scene scene = new SceneHelpers().SetupScene(); |
75 | SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); | 75 | SceneObjectGroup grp1 = SceneHelpers.AddSceneObject(scene); |
76 | SceneObjectGroup grp1 = part1.ParentGroup; | 76 | SceneObjectPart part1 = grp1.RootPart; |
77 | SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); | 77 | SceneObjectGroup grp2 = SceneHelpers.AddSceneObject(scene); |
78 | SceneObjectGroup grp2 = part2.ParentGroup; | 78 | SceneObjectPart part2 = grp2.RootPart; |
79 | 79 | ||
80 | grp1.AbsolutePosition = new Vector3(10, 10, 10); | 80 | grp1.AbsolutePosition = new Vector3(10, 10, 10); |
81 | grp2.AbsolutePosition = Vector3.Zero; | 81 | grp2.AbsolutePosition = Vector3.Zero; |
@@ -154,14 +154,14 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
154 | bool debugtest = false; | 154 | bool debugtest = false; |
155 | 155 | ||
156 | Scene scene = new SceneHelpers().SetupScene(); | 156 | Scene scene = new SceneHelpers().SetupScene(); |
157 | SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); | 157 | SceneObjectGroup grp1 = SceneHelpers.AddSceneObject(scene); |
158 | SceneObjectGroup grp1 = part1.ParentGroup; | 158 | SceneObjectPart part1 = grp1.RootPart; |
159 | SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); | 159 | SceneObjectGroup grp2 = SceneHelpers.AddSceneObject(scene); |
160 | SceneObjectGroup grp2 = part2.ParentGroup; | 160 | SceneObjectPart part2 = grp2.RootPart; |
161 | SceneObjectPart part3 = SceneHelpers.AddSceneObject(scene); | 161 | SceneObjectGroup grp3 = SceneHelpers.AddSceneObject(scene); |
162 | SceneObjectGroup grp3 = part3.ParentGroup; | 162 | SceneObjectPart part3 = grp3.RootPart; |
163 | SceneObjectPart part4 = SceneHelpers.AddSceneObject(scene); | 163 | SceneObjectGroup grp4 = SceneHelpers.AddSceneObject(scene); |
164 | SceneObjectGroup grp4 = part4.ParentGroup; | 164 | SceneObjectPart part4 = grp4.RootPart; |
165 | 165 | ||
166 | grp1.AbsolutePosition = new Vector3(10, 10, 10); | 166 | grp1.AbsolutePosition = new Vector3(10, 10, 10); |
167 | grp2.AbsolutePosition = Vector3.Zero; | 167 | grp2.AbsolutePosition = Vector3.Zero; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs index 0a94c19..e931859 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs | |||
@@ -53,7 +53,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
53 | // log4net.Config.XmlConfigurator.Configure(); | 53 | // log4net.Config.XmlConfigurator.Configure(); |
54 | 54 | ||
55 | Scene scene = new SceneHelpers().SetupScene(); | 55 | Scene scene = new SceneHelpers().SetupScene(); |
56 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene).ParentGroup; | 56 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); |
57 | 57 | ||
58 | g1.GroupResize(new Vector3(2, 3, 4)); | 58 | g1.GroupResize(new Vector3(2, 3, 4)); |
59 | 59 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs index 313e350..ed39be1 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs | |||
@@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
64 | Vector3 startPos = new Vector3(10.1f, 0, 0); | 64 | Vector3 startPos = new Vector3(10.1f, 0, 0); |
65 | m_sp.AbsolutePosition = startPos; | 65 | m_sp.AbsolutePosition = startPos; |
66 | 66 | ||
67 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); | 67 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
68 | 68 | ||
69 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); | 69 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); |
70 | 70 | ||
@@ -82,7 +82,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
82 | Vector3 startPos = new Vector3(9.9f, 0, 0); | 82 | Vector3 startPos = new Vector3(9.9f, 0, 0); |
83 | m_sp.AbsolutePosition = startPos; | 83 | m_sp.AbsolutePosition = startPos; |
84 | 84 | ||
85 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); | 85 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
86 | 86 | ||
87 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); | 87 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); |
88 | 88 | ||
@@ -100,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
100 | Vector3 startPos = new Vector3(1, 1, 1); | 100 | Vector3 startPos = new Vector3(1, 1, 1); |
101 | m_sp.AbsolutePosition = startPos; | 101 | m_sp.AbsolutePosition = startPos; |
102 | 102 | ||
103 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); | 103 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
104 | 104 | ||
105 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); | 105 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); |
106 | 106 | ||
@@ -133,7 +133,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
133 | Vector3 startPos = new Vector3(128, 128, 30); | 133 | Vector3 startPos = new Vector3(128, 128, 30); |
134 | m_sp.AbsolutePosition = startPos; | 134 | m_sp.AbsolutePosition = startPos; |
135 | 135 | ||
136 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); | 136 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
137 | part.SitTargetPosition = new Vector3(0, 0, 1); | 137 | part.SitTargetPosition = new Vector3(0, 0, 1); |
138 | 138 | ||
139 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); | 139 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index d15141b..a51e4e3 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | |||
@@ -128,7 +128,9 @@ namespace OpenSim.Region.Framework.Tests | |||
128 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | 128 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
129 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); | 129 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
130 | SceneObjectPart sop1 = sog1.RootPart; | 130 | SceneObjectPart sop1 = sog1.RootPart; |
131 | TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1); | 131 | TaskInventoryItem sopItem1 |
132 | = TaskInventoryHelpers.AddNotecard( | ||
133 | scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); | ||
132 | 134 | ||
133 | InventoryFolderBase folder | 135 | InventoryFolderBase folder |
134 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; | 136 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; |
@@ -156,8 +158,11 @@ namespace OpenSim.Region.Framework.Tests | |||
156 | Scene scene = new SceneHelpers().SetupScene(); | 158 | Scene scene = new SceneHelpers().SetupScene(); |
157 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | 159 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
158 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); | 160 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
161 | |||
159 | SceneObjectPart sop1 = sog1.RootPart; | 162 | SceneObjectPart sop1 = sog1.RootPart; |
160 | TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1); | 163 | TaskInventoryItem sopItem1 |
164 | = TaskInventoryHelpers.AddNotecard( | ||
165 | scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); | ||
161 | 166 | ||
162 | // Perform test | 167 | // Perform test |
163 | scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); | 168 | scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 65dad2d..9179966 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -301,7 +301,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
301 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); | 301 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); |
302 | 302 | ||
303 | ScenePresence npc = m_scene.GetScenePresence(npcId); | 303 | ScenePresence npc = m_scene.GetScenePresence(npcId); |
304 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); | 304 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
305 | 305 | ||
306 | part.SitTargetPosition = new Vector3(0, 0, 1); | 306 | part.SitTargetPosition = new Vector3(0, 0, 1); |
307 | m_npcMod.Sit(npc.UUID, part.UUID, m_scene); | 307 | m_npcMod.Sit(npc.UUID, part.UUID, m_scene); |
@@ -333,7 +333,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
333 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); | 333 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); |
334 | 334 | ||
335 | ScenePresence npc = m_scene.GetScenePresence(npcId); | 335 | ScenePresence npc = m_scene.GetScenePresence(npcId); |
336 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); | 336 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
337 | 337 | ||
338 | m_npcMod.Sit(npc.UUID, part.UUID, m_scene); | 338 | m_npcMod.Sit(npc.UUID, part.UUID, m_scene); |
339 | 339 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7fa25f5..fa9364d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -126,7 +126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
126 | [Serializable] | 126 | [Serializable] |
127 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi | 127 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi |
128 | { | 128 | { |
129 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 129 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
130 | 130 | ||
131 | public const string GridInfoServiceConfigSectionName = "GridInfoService"; | 131 | public const string GridInfoServiceConfigSectionName = "GridInfoService"; |
132 | 132 | ||
@@ -3151,6 +3151,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3151 | ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); | 3151 | ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); |
3152 | } | 3152 | } |
3153 | 3153 | ||
3154 | public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint) | ||
3155 | { | ||
3156 | CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory"); | ||
3157 | |||
3158 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | ||
3159 | |||
3160 | if (attachmentsModule == null) | ||
3161 | return; | ||
3162 | |||
3163 | m_host.AddScriptLPS(1); | ||
3164 | |||
3165 | InitLSL(); | ||
3166 | |||
3167 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); | ||
3168 | |||
3169 | if (item == null) | ||
3170 | { | ||
3171 | ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Could not find object '{0}'", itemName)); | ||
3172 | throw new Exception(String.Format("The inventory item '{0}' could not be found", itemName)); | ||
3173 | } | ||
3174 | |||
3175 | if (item.InvType != (int)InventoryType.Object) | ||
3176 | { | ||
3177 | // FIXME: Temporary null check for regression tests since they dont' have the infrastructure to set | ||
3178 | // up the api reference. | ||
3179 | if (m_LSL_Api != null) | ||
3180 | ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName)); | ||
3181 | |||
3182 | throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName)); | ||
3183 | |||
3184 | return; | ||
3185 | } | ||
3186 | |||
3187 | ScenePresence sp = World.GetScenePresence(m_host.OwnerID); | ||
3188 | |||
3189 | if (sp == null) | ||
3190 | return; | ||
3191 | |||
3192 | InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID); | ||
3193 | |||
3194 | if (newItem == null) | ||
3195 | { | ||
3196 | m_log.ErrorFormat( | ||
3197 | "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}", | ||
3198 | itemName, m_host.Name, attachmentPoint, World.Name); | ||
3199 | |||
3200 | return; | ||
3201 | } | ||
3202 | |||
3203 | attachmentsModule.RezSingleAttachmentFromInventory(sp, newItem.ID, (uint)attachmentPoint); | ||
3204 | } | ||
3205 | |||
3154 | public void osForceDetachFromAvatar() | 3206 | public void osForceDetachFromAvatar() |
3155 | { | 3207 | { |
3156 | CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); | 3208 | CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index e92518d..a8335aa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -107,6 +107,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
107 | void osForceAttachToAvatar(int attachment); | 107 | void osForceAttachToAvatar(int attachment); |
108 | 108 | ||
109 | /// <summary> | 109 | /// <summary> |
110 | /// Attach the inventory item in the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH | ||
111 | /// </summary> | ||
112 | /// <param name='itemName'>Tha name of the item. If this is not found then a warning is said to the owner</param> | ||
113 | /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param> | ||
114 | void osForceAttachToAvatarFromInventory(string itemName, int attachment); | ||
115 | |||
116 | /// <summary> | ||
110 | /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH | 117 | /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH |
111 | /// </summary> | 118 | /// </summary> |
112 | /// <remarks>Nothing happens if the object is not attached.</remarks> | 119 | /// <remarks>Nothing happens if the object is not attached.</remarks> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index d230662..500ed96 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -296,6 +296,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
296 | m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint); | 296 | m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint); |
297 | } | 297 | } |
298 | 298 | ||
299 | public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint) | ||
300 | { | ||
301 | m_OSSL_Functions.osForceAttachToAvatarFromInventory(itemName, attachmentPoint); | ||
302 | } | ||
303 | |||
299 | public void osForceDetachFromAvatar() | 304 | public void osForceDetachFromAvatar() |
300 | { | 305 | { |
301 | m_OSSL_Functions.osForceDetachFromAvatar(); | 306 | m_OSSL_Functions.osForceDetachFromAvatar(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs index bc3b790..2565ae7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs | |||
@@ -89,7 +89,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
89 | 89 | ||
90 | // FIXME: This should really be a script item (with accompanying script) | 90 | // FIXME: This should really be a script item (with accompanying script) |
91 | TaskInventoryItem grp1Item | 91 | TaskInventoryItem grp1Item |
92 | = TaskInventoryHelpers.AddNotecard(m_scene, grp1.RootPart); | 92 | = TaskInventoryHelpers.AddNotecard( |
93 | m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); | ||
93 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 94 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
94 | 95 | ||
95 | SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); | 96 | SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); |
@@ -122,7 +123,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
122 | 123 | ||
123 | // FIXME: This should really be a script item (with accompanying script) | 124 | // FIXME: This should really be a script item (with accompanying script) |
124 | TaskInventoryItem grp1Item | 125 | TaskInventoryItem grp1Item |
125 | = TaskInventoryHelpers.AddNotecard(m_scene, grp1.RootPart); | 126 | = TaskInventoryHelpers.AddNotecard( |
127 | m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); | ||
128 | |||
126 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 129 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
127 | 130 | ||
128 | LSL_Api apiGrp1 = new LSL_Api(); | 131 | LSL_Api apiGrp1 = new LSL_Api(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index f96a156..c41d1e7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
59 | config.Set("Enabled", "true"); | 59 | config.Set("Enabled", "true"); |
60 | 60 | ||
61 | Scene scene = new SceneHelpers().SetupScene(); | 61 | Scene scene = new SceneHelpers().SetupScene(); |
62 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); | 62 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene).RootPart; |
63 | 63 | ||
64 | XEngine.XEngine engine = new XEngine.XEngine(); | 64 | XEngine.XEngine engine = new XEngine.XEngine(); |
65 | engine.Initialise(initConfigSource); | 65 | engine.Initialise(initConfigSource); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs new file mode 100644 index 0000000..537b8aa --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs | |||
@@ -0,0 +1,178 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.Assets; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.CoreModules.Avatar.Attachments; | ||
40 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using OpenSim.Region.ScriptEngine.Shared; | ||
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
44 | using OpenSim.Services.Interfaces; | ||
45 | using OpenSim.Tests.Common; | ||
46 | using OpenSim.Tests.Common.Mock; | ||
47 | |||
48 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | ||
49 | { | ||
50 | /// <summary> | ||
51 | /// Tests for OSSL attachment functions | ||
52 | /// </summary> | ||
53 | /// <remarks> | ||
54 | /// TODO: Add tests for all functions | ||
55 | /// </remarks> | ||
56 | [TestFixture] | ||
57 | public class OSSL_ApiAttachmentTests : OpenSimTestCase | ||
58 | { | ||
59 | protected Scene m_scene; | ||
60 | protected XEngine.XEngine m_engine; | ||
61 | |||
62 | [SetUp] | ||
63 | public override void SetUp() | ||
64 | { | ||
65 | base.SetUp(); | ||
66 | |||
67 | IConfigSource initConfigSource = new IniConfigSource(); | ||
68 | |||
69 | IConfig xengineConfig = initConfigSource.AddConfig("XEngine"); | ||
70 | xengineConfig.Set("Enabled", "true"); | ||
71 | xengineConfig.Set("AllowOSFunctions", "true"); | ||
72 | xengineConfig.Set("OSFunctionThreatLevel", "Severe"); | ||
73 | |||
74 | IConfig modulesConfig = initConfigSource.AddConfig("Modules"); | ||
75 | modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
76 | |||
77 | m_scene = new SceneHelpers().SetupScene(); | ||
78 | SceneHelpers.SetupSceneModules( | ||
79 | m_scene, initConfigSource, new AttachmentsModule(), new BasicInventoryAccessModule()); | ||
80 | |||
81 | m_engine = new XEngine.XEngine(); | ||
82 | m_engine.Initialise(initConfigSource); | ||
83 | m_engine.AddRegion(m_scene); | ||
84 | } | ||
85 | |||
86 | [Test] | ||
87 | public void TestOsForceAttachToAvatarFromInventory() | ||
88 | { | ||
89 | TestHelpers.InMethod(); | ||
90 | // TestHelpers.EnableLogging(); | ||
91 | |||
92 | string taskInvObjItemName = "sphere"; | ||
93 | UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); | ||
94 | AttachmentPoint attachPoint = AttachmentPoint.Chin; | ||
95 | |||
96 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1); | ||
97 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID); | ||
98 | SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); | ||
99 | TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); | ||
100 | |||
101 | new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); | ||
102 | OSSL_Api osslApi = new OSSL_Api(); | ||
103 | osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); | ||
104 | |||
105 | // SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ua1.PrincipalID); | ||
106 | |||
107 | // Create an object embedded inside the first | ||
108 | TaskInventoryHelpers.AddSceneObject(m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); | ||
109 | |||
110 | osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint); | ||
111 | |||
112 | // Check scene presence status | ||
113 | Assert.That(sp.HasAttachments(), Is.True); | ||
114 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
115 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
116 | SceneObjectGroup attSo = attachments[0]; | ||
117 | Assert.That(attSo.Name, Is.EqualTo(taskInvObjItemName)); | ||
118 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((uint)attachPoint)); | ||
119 | Assert.That(attSo.IsAttachment); | ||
120 | Assert.That(attSo.UsesPhysics, Is.False); | ||
121 | Assert.That(attSo.IsTemporary, Is.False); | ||
122 | |||
123 | // Check appearance status | ||
124 | List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments(); | ||
125 | Assert.That(attachmentsInAppearance.Count, Is.EqualTo(1)); | ||
126 | Assert.That(sp.Appearance.GetAttachpoint(attachmentsInAppearance[0].ItemID), Is.EqualTo((uint)attachPoint)); | ||
127 | } | ||
128 | |||
129 | /// <summary> | ||
130 | /// Make sure we can't force attach anything other than objects. | ||
131 | /// </summary> | ||
132 | [Test] | ||
133 | public void TestOsForceAttachToAvatarFromInventoryNotObject() | ||
134 | { | ||
135 | TestHelpers.InMethod(); | ||
136 | // TestHelpers.EnableLogging(); | ||
137 | |||
138 | string taskInvObjItemName = "sphere"; | ||
139 | UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); | ||
140 | AttachmentPoint attachPoint = AttachmentPoint.Chin; | ||
141 | |||
142 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1); | ||
143 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID); | ||
144 | SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); | ||
145 | TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); | ||
146 | |||
147 | new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); | ||
148 | OSSL_Api osslApi = new OSSL_Api(); | ||
149 | osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); | ||
150 | |||
151 | // Create an object embedded inside the first | ||
152 | TaskInventoryHelpers.AddNotecard( | ||
153 | m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900)); | ||
154 | |||
155 | bool exceptionCaught = false; | ||
156 | |||
157 | try | ||
158 | { | ||
159 | osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint); | ||
160 | } | ||
161 | catch (Exception e) | ||
162 | { | ||
163 | exceptionCaught = true; | ||
164 | } | ||
165 | |||
166 | Assert.That(exceptionCaught, Is.True); | ||
167 | |||
168 | // Check scene presence status | ||
169 | Assert.That(sp.HasAttachments(), Is.False); | ||
170 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
171 | Assert.That(attachments.Count, Is.EqualTo(0)); | ||
172 | |||
173 | // Check appearance status | ||
174 | List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments(); | ||
175 | Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0)); | ||
176 | } | ||
177 | } | ||
178 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs index 0ccd889..813e53b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | |||
@@ -52,14 +52,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
52 | /// Tests for OSSL NPC API | 52 | /// Tests for OSSL NPC API |
53 | /// </summary> | 53 | /// </summary> |
54 | [TestFixture] | 54 | [TestFixture] |
55 | public class OSSL_NpcApiAppearanceTest | 55 | public class OSSL_NpcApiAppearanceTest : OpenSimTestCase |
56 | { | 56 | { |
57 | protected Scene m_scene; | 57 | protected Scene m_scene; |
58 | protected XEngine.XEngine m_engine; | 58 | protected XEngine.XEngine m_engine; |
59 | 59 | ||
60 | [SetUp] | 60 | [SetUp] |
61 | public void SetUp() | 61 | public override void SetUp() |
62 | { | 62 | { |
63 | base.SetUp(); | ||
64 | |||
63 | IConfigSource initConfigSource = new IniConfigSource(); | 65 | IConfigSource initConfigSource = new IniConfigSource(); |
64 | IConfig config = initConfigSource.AddConfig("XEngine"); | 66 | IConfig config = initConfigSource.AddConfig("XEngine"); |
65 | config.Set("Enabled", "true"); | 67 | config.Set("Enabled", "true"); |
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 239afc0..3a2e420 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs | |||
@@ -564,7 +564,7 @@ namespace OpenSim.Tests.Common | |||
564 | /// </summary> | 564 | /// </summary> |
565 | /// <param name="scene"></param> | 565 | /// <param name="scene"></param> |
566 | /// <returns></returns> | 566 | /// <returns></returns> |
567 | public static SceneObjectPart AddSceneObject(Scene scene) | 567 | public static SceneObjectGroup AddSceneObject(Scene scene) |
568 | { | 568 | { |
569 | return AddSceneObject(scene, "Test Object", UUID.Zero); | 569 | return AddSceneObject(scene, "Test Object", UUID.Zero); |
570 | } | 570 | } |
@@ -576,16 +576,16 @@ namespace OpenSim.Tests.Common | |||
576 | /// <param name="name"></param> | 576 | /// <param name="name"></param> |
577 | /// <param name="ownerId"></param> | 577 | /// <param name="ownerId"></param> |
578 | /// <returns></returns> | 578 | /// <returns></returns> |
579 | public static SceneObjectPart AddSceneObject(Scene scene, string name, UUID ownerId) | 579 | public static SceneObjectGroup AddSceneObject(Scene scene, string name, UUID ownerId) |
580 | { | 580 | { |
581 | SceneObjectPart part = CreateSceneObjectPart(name, UUID.Random(), ownerId); | 581 | SceneObjectGroup so = new SceneObjectGroup(CreateSceneObjectPart(name, UUID.Random(), ownerId)); |
582 | 582 | ||
583 | //part.UpdatePrimFlags(false, false, true); | 583 | //part.UpdatePrimFlags(false, false, true); |
584 | //part.ObjectFlags |= (uint)PrimFlags.Phantom; | 584 | //part.ObjectFlags |= (uint)PrimFlags.Phantom; |
585 | 585 | ||
586 | scene.AddNewSceneObject(new SceneObjectGroup(part), false); | 586 | scene.AddNewSceneObject(so, false); |
587 | 587 | ||
588 | return part; | 588 | return so; |
589 | } | 589 | } |
590 | 590 | ||
591 | /// <summary> | 591 | /// <summary> |
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs index 7058d1e..9607f1f 100644 --- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs | |||
@@ -45,20 +45,23 @@ namespace OpenSim.Tests.Common | |||
45 | /// </summary> | 45 | /// </summary> |
46 | /// <param name="scene"></param> | 46 | /// <param name="scene"></param> |
47 | /// <param name="part"></param> | 47 | /// <param name="part"></param> |
48 | /// <param name="itemName"></param> | ||
49 | /// <param name="itemID"></param> | ||
50 | /// <param name="assetID"></param> | ||
48 | /// <returns>The item that was added</returns> | 51 | /// <returns>The item that was added</returns> |
49 | public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part) | 52 | public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part, string itemName, UUID itemID, UUID assetID) |
50 | { | 53 | { |
51 | AssetNotecard nc = new AssetNotecard(); | 54 | AssetNotecard nc = new AssetNotecard(); |
52 | nc.BodyText = "Hello World!"; | 55 | nc.BodyText = "Hello World!"; |
53 | nc.Encode(); | 56 | nc.Encode(); |
54 | UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); | 57 | |
55 | UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); | ||
56 | AssetBase ncAsset | 58 | AssetBase ncAsset |
57 | = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); | 59 | = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero); |
58 | scene.AssetService.Store(ncAsset); | 60 | scene.AssetService.Store(ncAsset); |
61 | |||
59 | TaskInventoryItem ncItem | 62 | TaskInventoryItem ncItem |
60 | = new TaskInventoryItem | 63 | = new TaskInventoryItem |
61 | { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid, | 64 | { Name = itemName, AssetID = assetID, ItemID = itemID, |
62 | Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; | 65 | Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; |
63 | part.Inventory.AddInventoryItem(ncItem, true); | 66 | part.Inventory.AddInventoryItem(ncItem, true); |
64 | 67 | ||
@@ -66,8 +69,42 @@ namespace OpenSim.Tests.Common | |||
66 | } | 69 | } |
67 | 70 | ||
68 | /// <summary> | 71 | /// <summary> |
72 | /// Add a blank script to the given part. | ||
73 | /// </summary> | ||
74 | /// <remarks> | ||
75 | /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these | ||
76 | /// functions more than once in a test. | ||
77 | /// </remarks> | ||
78 | /// <param name="scene"></param> | ||
79 | /// <param name="part"></param> | ||
80 | /// <returns>The item that was added</returns> | ||
81 | public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part) | ||
82 | { | ||
83 | AssetScriptText ast = new AssetScriptText(); | ||
84 | ast.Encode(); | ||
85 | |||
86 | UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000"); | ||
87 | UUID itemUuid = new UUID("00000000-0000-0000-1100-000000000000"); | ||
88 | AssetBase asset | ||
89 | = AssetHelpers.CreateAsset(assetUuid, AssetType.LSLText, ast.AssetData, UUID.Zero); | ||
90 | scene.AssetService.Store(asset); | ||
91 | TaskInventoryItem item | ||
92 | = new TaskInventoryItem | ||
93 | { Name = "scriptItem", AssetID = assetUuid, ItemID = itemUuid, | ||
94 | Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; | ||
95 | part.Inventory.AddInventoryItem(item, true); | ||
96 | |||
97 | return item; | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
69 | /// Add a scene object item to the given part. | 101 | /// Add a scene object item to the given part. |
70 | /// </summary> | 102 | /// </summary> |
103 | /// <remarks> | ||
104 | /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these | ||
105 | /// functions more than once in a test. | ||
106 | /// </remarks> | ||
107 | /// | ||
71 | /// <param name="scene"></param> | 108 | /// <param name="scene"></param> |
72 | /// <param name="sop"></param> | 109 | /// <param name="sop"></param> |
73 | /// <param name="itemName"></param> | 110 | /// <param name="itemName"></param> |