diff options
4 files changed, 96 insertions, 5 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 61394af..e90f577 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -3190,13 +3190,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3190 | { | 3190 | { |
3191 | CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory"); | 3191 | CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory"); |
3192 | 3192 | ||
3193 | m_host.AddScriptLPS(1); | ||
3194 | |||
3195 | ForceAttachToAvatarFromInventory(m_host.OwnerID, itemName, attachmentPoint); | ||
3196 | } | ||
3197 | |||
3198 | public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint) | ||
3199 | { | ||
3200 | CheckThreatLevel(ThreatLevel.Severe, "osForceAttachToOtherAvatarFromInventory"); | ||
3201 | |||
3202 | m_host.AddScriptLPS(1); | ||
3203 | |||
3204 | UUID avatarId; | ||
3205 | |||
3206 | if (!UUID.TryParse(rawAvatarId, out avatarId)) | ||
3207 | return; | ||
3208 | |||
3209 | ForceAttachToAvatarFromInventory(avatarId, itemName, attachmentPoint); | ||
3210 | } | ||
3211 | |||
3212 | public void ForceAttachToAvatarFromInventory(UUID avatarId, string itemName, int attachmentPoint) | ||
3213 | { | ||
3193 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3214 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3194 | 3215 | ||
3195 | if (attachmentsModule == null) | 3216 | if (attachmentsModule == null) |
3196 | return; | 3217 | return; |
3197 | 3218 | ||
3198 | m_host.AddScriptLPS(1); | ||
3199 | |||
3200 | InitLSL(); | 3219 | InitLSL(); |
3201 | 3220 | ||
3202 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); | 3221 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); |
@@ -3219,7 +3238,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3219 | return; | 3238 | return; |
3220 | } | 3239 | } |
3221 | 3240 | ||
3222 | ScenePresence sp = World.GetScenePresence(m_host.OwnerID); | 3241 | ScenePresence sp = World.GetScenePresence(avatarId); |
3223 | 3242 | ||
3224 | if (sp == null) | 3243 | if (sp == null) |
3225 | return; | 3244 | return; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index d38709e..b5416c8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -101,19 +101,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
101 | // Attachment commands | 101 | // Attachment commands |
102 | 102 | ||
103 | /// <summary> | 103 | /// <summary> |
104 | /// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH | 104 | /// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH |
105 | /// </summary> | 105 | /// </summary> |
106 | /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param> | 106 | /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param> |
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 | 110 | /// Attach an inventory item in the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH |
111 | /// </summary> | 111 | /// </summary> |
112 | /// <remarks> | ||
113 | /// Nothing happens if the owner is not in the region. | ||
114 | /// </remarks> | ||
112 | /// <param name='itemName'>Tha name of the item. If this is not found then a warning is said to the owner</param> | 115 | /// <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> | 116 | /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param> |
114 | void osForceAttachToAvatarFromInventory(string itemName, int attachment); | 117 | void osForceAttachToAvatarFromInventory(string itemName, int attachment); |
115 | 118 | ||
116 | /// <summary> | 119 | /// <summary> |
120 | /// Attach an inventory item in the object containing this script to any avatar in the region without asking for PERMISSION_ATTACH | ||
121 | /// </summary> | ||
122 | /// <remarks> | ||
123 | /// Nothing happens if the avatar is not in the region. | ||
124 | /// </remarks> | ||
125 | /// <param name='rawAvatarId'>The UUID of the avatar to which to attach. Nothing happens if this is not a UUID</para> | ||
126 | /// <param name='itemName'>The name of the item. If this is not found then a warning is said to the owner</param> | ||
127 | /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param> | ||
128 | void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint); | ||
129 | |||
130 | /// <summary> | ||
117 | /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH | 131 | /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH |
118 | /// </summary> | 132 | /// </summary> |
119 | /// <remarks>Nothing happens if the object is not attached.</remarks> | 133 | /// <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 692bb0a..b40bdf0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -301,6 +301,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
301 | m_OSSL_Functions.osForceAttachToAvatarFromInventory(itemName, attachmentPoint); | 301 | m_OSSL_Functions.osForceAttachToAvatarFromInventory(itemName, attachmentPoint); |
302 | } | 302 | } |
303 | 303 | ||
304 | public void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint) | ||
305 | { | ||
306 | m_OSSL_Functions.osForceAttachToOtherAvatarFromInventory(rawAvatarId, itemName, attachmentPoint); | ||
307 | } | ||
308 | |||
304 | public void osForceDetachFromAvatar() | 309 | public void osForceDetachFromAvatar() |
305 | { | 310 | { |
306 | m_OSSL_Functions.osForceDetachFromAvatar(); | 311 | m_OSSL_Functions.osForceDetachFromAvatar(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs index 78db2c6..f5aa518 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs | |||
@@ -174,5 +174,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
174 | List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments(); | 174 | List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments(); |
175 | Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0)); | 175 | Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0)); |
176 | } | 176 | } |
177 | |||
178 | [Test] | ||
179 | public void TestOsForceAttachToOtherAvatarFromInventory() | ||
180 | { | ||
181 | TestHelpers.InMethod(); | ||
182 | TestHelpers.EnableLogging(); | ||
183 | |||
184 | string taskInvObjItemName = "sphere"; | ||
185 | UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); | ||
186 | AttachmentPoint attachPoint = AttachmentPoint.Chin; | ||
187 | |||
188 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, "user", "one", 0x1, "pass"); | ||
189 | UserAccount ua2 = UserAccountHelpers.CreateUserWithInventory(m_scene, "user", "two", 0x2, "pass"); | ||
190 | |||
191 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1); | ||
192 | SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); | ||
193 | TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); | ||
194 | |||
195 | new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); | ||
196 | OSSL_Api osslApi = new OSSL_Api(); | ||
197 | osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); | ||
198 | |||
199 | // Create an object embedded inside the first | ||
200 | TaskInventoryHelpers.AddSceneObject(m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); | ||
201 | |||
202 | ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, ua2); | ||
203 | |||
204 | osslApi.osForceAttachToOtherAvatarFromInventory(sp2.UUID.ToString(), taskInvObjItemName, (int)attachPoint); | ||
205 | |||
206 | // Check scene presence status | ||
207 | Assert.That(sp.HasAttachments(), Is.False); | ||
208 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
209 | Assert.That(attachments.Count, Is.EqualTo(0)); | ||
210 | |||
211 | Assert.That(sp2.HasAttachments(), Is.True); | ||
212 | List<SceneObjectGroup> attachments2 = sp2.GetAttachments(); | ||
213 | Assert.That(attachments2.Count, Is.EqualTo(1)); | ||
214 | SceneObjectGroup attSo = attachments2[0]; | ||
215 | Assert.That(attSo.Name, Is.EqualTo(taskInvObjItemName)); | ||
216 | Assert.That(attSo.OwnerID, Is.EqualTo(ua2.PrincipalID)); | ||
217 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((uint)attachPoint)); | ||
218 | Assert.That(attSo.IsAttachment); | ||
219 | Assert.That(attSo.UsesPhysics, Is.False); | ||
220 | Assert.That(attSo.IsTemporary, Is.False); | ||
221 | |||
222 | // Check appearance status | ||
223 | List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments(); | ||
224 | Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0)); | ||
225 | |||
226 | List<AvatarAttachment> attachmentsInAppearance2 = sp2.Appearance.GetAttachments(); | ||
227 | Assert.That(attachmentsInAppearance2.Count, Is.EqualTo(1)); | ||
228 | Assert.That(sp2.Appearance.GetAttachpoint(attachmentsInAppearance2[0].ItemID), Is.EqualTo((uint)attachPoint)); | ||
229 | } | ||
177 | } | 230 | } |
178 | } \ No newline at end of file | 231 | } \ No newline at end of file |