aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs49
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs126
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs2
6 files changed, 166 insertions, 19 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index b588704..88ca9db 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -284,7 +284,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
284 sp.ClearAttachments(); 284 sp.ClearAttachments();
285 } 285 }
286 286
287 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData) 287 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp)
288 { 288 {
289 lock (sp.AttachmentsSyncLock) 289 lock (sp.AttachmentsSyncLock)
290 { 290 {
@@ -361,7 +361,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
361 group.AbsolutePosition = attachPos; 361 group.AbsolutePosition = attachPos;
362 362
363 if (sp.PresenceType != PresenceType.Npc) 363 if (sp.PresenceType != PresenceType.Npc)
364 UpdateUserInventoryWithAttachment(sp, group, attachmentPt); 364 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp);
365 365
366 AttachToAgent(sp, group, attachmentPt, attachPos, silent); 366 AttachToAgent(sp, group, attachmentPt, attachPos, silent);
367 } 367 }
@@ -369,7 +369,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
369 return true; 369 return true;
370 } 370 }
371 371
372 private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt) 372 private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp)
373 { 373 {
374 // Remove any previous attachments 374 // Remove any previous attachments
375 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); 375 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
@@ -379,18 +379,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
379 { 379 {
380 if (attachments[0].FromItemID != UUID.Zero) 380 if (attachments[0].FromItemID != UUID.Zero)
381 DetachSingleAttachmentToInvInternal(sp, attachments[0]); 381 DetachSingleAttachmentToInvInternal(sp, attachments[0]);
382 else 382 // Error logging commented because UUID.Zero now means temp attachment
383 m_log.WarnFormat( 383// else
384 "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!", 384// m_log.WarnFormat(
385 attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name); 385// "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
386// attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
386 } 387 }
387 388
388 // Add the new attachment to inventory if we don't already have it. 389 // Add the new attachment to inventory if we don't already have it.
389 UUID newAttachmentItemID = group.FromItemID; 390 if (!temp)
390 if (newAttachmentItemID == UUID.Zero) 391 {
391 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID; 392 UUID newAttachmentItemID = group.FromItemID;
393 if (newAttachmentItemID == UUID.Zero)
394 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
392 395
393 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group); 396 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group);
397 }
394 } 398 }
395 399
396 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) 400 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
@@ -474,6 +478,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
474 478
475 UUID inventoryID = so.FromItemID; 479 UUID inventoryID = so.FromItemID;
476 480
481 // As per Linden spec, drop is disabled for temp attachs
482 if (inventoryID == UUID.Zero)
483 return;
484
477// m_log.DebugFormat( 485// m_log.DebugFormat(
478// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}", 486// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}",
479// so.Name, so.LocalId, inventoryID); 487// so.Name, so.LocalId, inventoryID);
@@ -484,7 +492,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
484 so.PrimCount, sp.UUID, sp.AbsolutePosition)) 492 so.PrimCount, sp.UUID, sp.AbsolutePosition))
485 return; 493 return;
486 494
487 bool changed = sp.Appearance.DetachAttachment(inventoryID); 495 bool changed = false;
496 if (inventoryID != UUID.Zero)
497 changed = sp.Appearance.DetachAttachment(inventoryID);
488 if (changed && m_scene.AvatarFactory != null) 498 if (changed && m_scene.AvatarFactory != null)
489 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); 499 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
490 500
@@ -516,6 +526,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
516 526
517 public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so) 527 public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so)
518 { 528 {
529 // As per Linden spec, detach (take) is disabled for temp attachs
530 if (so.FromItemID == UUID.Zero)
531 return;
532
519 lock (sp.AttachmentsSyncLock) 533 lock (sp.AttachmentsSyncLock)
520 { 534 {
521 // Save avatar attachment information 535 // Save avatar attachment information
@@ -589,6 +603,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
589 /// <param name="saveAllScripted"></param> 603 /// <param name="saveAllScripted"></param>
590 private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, string scriptedState) 604 private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, string scriptedState)
591 { 605 {
606 if (grp.FromItemID == UUID.Zero)
607 {
608 // We can't save temp attachments
609 grp.HasGroupChanged = false;
610 return;
611 }
612
592 // Saving attachments for NPCs messes them up for the real owner! 613 // Saving attachments for NPCs messes them up for the real owner!
593 INPCModule module = m_scene.RequestModuleInterface<INPCModule>(); 614 INPCModule module = m_scene.RequestModuleInterface<INPCModule>();
594 if (module != null) 615 if (module != null)
@@ -845,7 +866,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
845 // This will throw if the attachment fails 866 // This will throw if the attachment fails
846 try 867 try
847 { 868 {
848 AttachObject(sp, objatt, attachmentPt, false, false); 869 AttachObject(sp, objatt, attachmentPt, false, false, false);
849 } 870 }
850 catch (Exception e) 871 catch (Exception e)
851 { 872 {
@@ -1005,7 +1026,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1005 AttachmentPt &= 0x7f; 1026 AttachmentPt &= 0x7f;
1006 1027
1007 // Calls attach with a Zero position 1028 // Calls attach with a Zero position
1008 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true)) 1029 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, false))
1009 { 1030 {
1010// m_log.Debug( 1031// m_log.Debug(
1011// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId 1032// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 273e290..d9a619d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -189,7 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
189 189
190 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); 190 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
191 191
192 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); 192 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false);
193 193
194 // Check status on scene presence 194 // Check status on scene presence
195 Assert.That(sp.HasAttachments(), Is.True); 195 Assert.That(sp.HasAttachments(), Is.True);
@@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
243 sp2.AbsolutePosition = new Vector3(0, 0, 0); 243 sp2.AbsolutePosition = new Vector3(0, 0, 0);
244 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); 244 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);
245 245
246 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); 246 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false);
247 247
248 Assert.That(sp.HasAttachments(), Is.False); 248 Assert.That(sp.HasAttachments(), Is.False);
249 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); 249 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 11a13e1..90a13a7 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Region.Framework.Interfaces
84 /// <param name="AttachmentPt"></param> 84 /// <param name="AttachmentPt"></param>
85 /// <param name="silent"></param> 85 /// <param name="silent"></param>
86 /// <returns>true if the object was successfully attached, false otherwise</returns> 86 /// <returns>true if the object was successfully attached, false otherwise</returns>
87 bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool useAttachmentInfo); 87 bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool useAttachmentInfo, bool temp);
88 88
89 /// <summary> 89 /// <summary>
90 /// Rez an attachment from user inventory and change inventory status to match. 90 /// Rez an attachment from user inventory and change inventory status to match.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index a8594e4..a29b4fd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2755,7 +2755,7 @@ namespace OpenSim.Region.Framework.Scenes
2755 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2755 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2756 2756
2757 if (AttachmentsModule != null) 2757 if (AttachmentsModule != null)
2758 AttachmentsModule.AttachObject(sp, grp, 0, false, false); 2758 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false);
2759 } 2759 }
2760 else 2760 else
2761 { 2761 {
diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
new file mode 100644
index 0000000..b166588
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
@@ -0,0 +1,126 @@
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
28using System;
29using System.Collections.Generic;
30using System.Linq;
31using System.Reflection;
32using System.Text;
33using log4net;
34using Mono.Addins;
35using Nini.Config;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Console;
39using OpenSim.Framework.Monitoring;
40using OpenSim.Region.ClientStack.LindenUDP;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43
44namespace OpenSim.Region.OptionalModules.Avatar.Attachments
45{
46 /// <summary>
47 /// A module that just holds commands for inspecting avatar appearance.
48 /// </summary>
49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "TempAttachmentsModule")]
50 public class TempAttachmentsModule : INonSharedRegionModule
51 {
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53
54 private Scene m_scene;
55
56 public void Initialise(IConfigSource configSource)
57 {
58 }
59
60 public void AddRegion(Scene scene)
61 {
62 m_scene = scene;
63
64 IScriptModuleComms comms = scene.RequestModuleInterface<IScriptModuleComms>();
65 if (comms != null)
66 {
67 comms.RegisterScriptInvocation( this, "llAttachToAvatarTemp");
68 m_log.DebugFormat("[TEMP ATTACHS]: Registered script functions");
69 }
70 else
71 {
72 m_log.ErrorFormat("[TEMP ATTACHS]: Failed to register script functions");
73 }
74 }
75
76 public void RemoveRegion(Scene scene)
77 {
78 }
79
80 public void RegionLoaded(Scene scene)
81 {
82 }
83
84 public void Close()
85 {
86 }
87
88 public Type ReplaceableInterface
89 {
90 get { return null; }
91 }
92
93 public string Name
94 {
95 get { return "TempAttachmentsModule"; }
96 }
97
98 private void llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint)
99 {
100 SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host);
101
102 if (hostPart == null)
103 return;
104
105 if (hostPart.ParentGroup.IsAttachment)
106 return;
107
108 IAttachmentsModule attachmentsModule = m_scene.RequestModuleInterface<IAttachmentsModule>();
109 if (attachmentsModule == null)
110 return;
111
112 TaskInventoryItem item = hostPart.Inventory.GetInventoryItem(script);
113 if (item == null)
114 return;
115
116 if ((item.PermsMask & 32) == 0) // PERMISSION_ATTACH
117 return;
118
119 ScenePresence target;
120 if (!m_scene.TryGetScenePresence(item.PermsGranter, out target))
121 return;
122
123 attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, true, true);
124 }
125 }
126}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 8cbebbb..54cb214 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3346,7 +3346,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3346 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 3346 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3347 3347
3348 if (attachmentsModule != null) 3348 if (attachmentsModule != null)
3349 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, true); 3349 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, true, false);
3350 else 3350 else
3351 return false; 3351 return false;
3352 } 3352 }