aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs71
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs20
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs18
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs35
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs5
6 files changed, 82 insertions, 78 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 530a21c..d458364 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic;
28using System.Reflection; 29using System.Reflection;
29using log4net; 30using log4net;
30using Nini.Config; 31using Nini.Config;
@@ -131,26 +132,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
131 } 132 }
132 else 133 else
133 { 134 {
134 m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID); 135 m_log.DebugFormat("[ATTACHMENTS MODULE]: AttachObject found no such scene object {0}", objectLocalID);
135 return false; 136 return false;
136 } 137 }
137 138
138 return true; 139 return true;
139 } 140 }
140 141
141 /// <summary>
142 /// Update the user inventory to reflect an attachment
143 /// </summary>
144 /// <param name="att"></param>
145 /// <param name="remoteClient"></param>
146 /// <param name="itemID"></param>
147 /// <param name="AttachmentPt"></param>
148 /// <returns></returns>
149 public UUID SetAttachmentInventoryStatus( 142 public UUID SetAttachmentInventoryStatus(
150 SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt) 143 SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
151 { 144 {
152 m_log.DebugFormat( 145 m_log.DebugFormat(
153 "[USER INVENTORY]: Updating inventory of {0} to show attachment of {1} (item ID {2})", 146 "[ATTACHMENTS MODULEY]: Updating inventory of {0} to show attachment of {1} (item ID {2})",
154 remoteClient.Name, att.Name, itemID); 147 remoteClient.Name, att.Name, itemID);
155 148
156 if (!att.IsDeleted) 149 if (!att.IsDeleted)
@@ -184,19 +177,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
184 177
185 if (UUID.Zero == itemID) 178 if (UUID.Zero == itemID)
186 { 179 {
187 m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID."); 180 m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment. Error inventory item ID.");
188 return; 181 return;
189 } 182 }
190 183
191 if (0 == AttachmentPt) 184 if (0 == AttachmentPt)
192 { 185 {
193 m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error attachment point."); 186 m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment. Error attachment point.");
194 return; 187 return;
195 } 188 }
196 189
197 if (null == att.RootPart) 190 if (null == att.RootPart)
198 { 191 {
199 m_log.Error("[SCENE INVENTORY]: Unable to save attachment for a prim without the rootpart!"); 192 m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment for a prim without the rootpart!");
200 return; 193 return;
201 } 194 }
202 195
@@ -212,5 +205,53 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
212 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 205 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
213 } 206 }
214 } 207 }
208
209 public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient)
210 {
211 ScenePresence presence;
212 if (m_scene.TryGetAvatar(remoteClient.AgentId, out presence))
213 {
214 presence.Appearance.DetachAttachment(itemID);
215
216 // Save avatar attachment information
217 if (m_scene.AvatarFactory != null)
218 {
219 m_log.Debug("[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID);
220 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
221 }
222 }
223
224 DetachSingleAttachmentToInv(itemID, remoteClient);
225 }
226
227 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
228 // To LocalId or UUID, *THAT* is the question. How now Brown UUID??
229 protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
230 {
231 if (itemID == UUID.Zero) // If this happened, someone made a mistake....
232 return;
233
234 // We can NOT use the dictionries here, as we are looking
235 // for an entity by the fromAssetID, which is NOT the prim UUID
236 List<EntityBase> detachEntities = m_scene.GetEntities();
237 SceneObjectGroup group;
238
239 foreach (EntityBase entity in detachEntities)
240 {
241 if (entity is SceneObjectGroup)
242 {
243 group = (SceneObjectGroup)entity;
244 if (group.GetFromItemID() == itemID)
245 {
246 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
247 group.DetachToInventoryPrep();
248 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
249 m_scene.UpdateKnownItem(remoteClient, group,group.GetFromItemID(), group.OwnerID);
250 m_scene.DeleteSceneObject(group, false);
251 return;
252 }
253 }
254 }
255 }
215 } 256 }
216} \ No newline at end of file 257} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 5e5df4b..367ff3d 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -57,5 +57,16 @@ namespace OpenSim.Region.Framework.Interfaces
57 /// <returns></returns> 57 /// <returns></returns>
58 UUID SetAttachmentInventoryStatus( 58 UUID SetAttachmentInventoryStatus(
59 SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt); 59 SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
60
61 /// <summary>
62 /// Update the user inventory to show a detach.
63 /// </summary>
64 /// <param name="itemID">
65 /// A <see cref="UUID"/>
66 /// </param>
67 /// <param name="remoteClient">
68 /// A <see cref="IClientAPI"/>
69 /// </param>
70 void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient);
60 } 71 }
61} \ No newline at end of file 72} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index bd3b433..dad0efd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1858,7 +1858,7 @@ namespace OpenSim.Region.Framework.Scenes
1858 1858
1859 if (att == null) 1859 if (att == null)
1860 { 1860 {
1861 DetachSingleAttachmentToInv(itemID, remoteClient); 1861 AttachmentsModule.ShowDetachInUserInventory(itemID, remoteClient);
1862 return UUID.Zero; 1862 return UUID.Zero;
1863 } 1863 }
1864 1864
@@ -1904,24 +1904,6 @@ namespace OpenSim.Region.Framework.Scenes
1904 SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); 1904 SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero);
1905 } 1905 }
1906 1906
1907 public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
1908 {
1909 ScenePresence presence;
1910 if (TryGetAvatar(remoteClient.AgentId, out presence))
1911 {
1912 presence.Appearance.DetachAttachment(itemID);
1913
1914 // Save avatar attachment information
1915 if (m_AvatarFactory != null)
1916 {
1917 m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID);
1918 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
1919 }
1920 }
1921
1922 m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient);
1923 }
1924
1925 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 1907 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
1926 { 1908 {
1927 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); 1909 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c83132f..7c0375e 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2646,10 +2646,12 @@ namespace OpenSim.Region.Framework.Scenes
2646 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) 2646 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client)
2647 { 2647 {
2648 client.OnRezSingleAttachmentFromInv += RezSingleAttachment; 2648 client.OnRezSingleAttachmentFromInv += RezSingleAttachment;
2649 client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments; 2649 client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments;
2650 client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv;
2651 client.OnObjectAttach += m_sceneGraph.AttachObject; 2650 client.OnObjectAttach += m_sceneGraph.AttachObject;
2652 client.OnObjectDetach += m_sceneGraph.DetachObject; 2651 client.OnObjectDetach += m_sceneGraph.DetachObject;
2652
2653 if (AttachmentsModule != null)
2654 client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory;
2653 } 2655 }
2654 2656
2655 public virtual void SubscribeToClientTeleportEvents(IClientAPI client) 2657 public virtual void SubscribeToClientTeleportEvents(IClientAPI client)
@@ -2696,8 +2698,7 @@ namespace OpenSim.Region.Framework.Scenes
2696 } 2698 }
2697 2699
2698 protected virtual void UnsubscribeToClientEvents(IClientAPI client) 2700 protected virtual void UnsubscribeToClientEvents(IClientAPI client)
2699 { 2701 {
2700
2701 } 2702 }
2702 2703
2703 /// <summary> 2704 /// <summary>
@@ -2719,7 +2720,6 @@ namespace OpenSim.Region.Framework.Scenes
2719 2720
2720 UnSubscribeToClientNetworkEvents(client); 2721 UnSubscribeToClientNetworkEvents(client);
2721 2722
2722
2723 // EventManager.TriggerOnNewClient(client); 2723 // EventManager.TriggerOnNewClient(client);
2724 } 2724 }
2725 2725
@@ -2799,12 +2799,14 @@ namespace OpenSim.Region.Framework.Scenes
2799 } 2799 }
2800 2800
2801 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) 2801 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client)
2802 { 2802 {
2803 client.OnRezSingleAttachmentFromInv -= RezSingleAttachment;
2804 client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments; 2803 client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments;
2805 client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; 2804 client.OnRezSingleAttachmentFromInv -= RezSingleAttachment;
2806 client.OnObjectAttach -= m_sceneGraph.AttachObject; 2805 client.OnObjectAttach -= m_sceneGraph.AttachObject;
2807 client.OnObjectDetach -= m_sceneGraph.DetachObject; 2806 client.OnObjectDetach -= m_sceneGraph.DetachObject;
2807
2808 if (AttachmentsModule != null)
2809 client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory;
2808 } 2810 }
2809 2811
2810 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) 2812 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client)
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 48744d7..380722d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -452,7 +452,7 @@ namespace OpenSim.Region.Framework.Scenes
452 if (group != null) 452 if (group != null)
453 { 453 {
454 //group.DetachToGround(); 454 //group.DetachToGround();
455 m_parentScene.DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); 455 m_parentScene.AttachmentsModule.ShowDetachInUserInventory(group.GetFromItemID(), remoteClient);
456 } 456 }
457 } 457 }
458 458
@@ -574,39 +574,6 @@ namespace OpenSim.Region.Framework.Scenes
574 return null; 574 return null;
575 } 575 }
576 576
577 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
578 // To LocalId or UUID, *THAT* is the question. How now Brown UUID??
579 public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
580 {
581 if (itemID == UUID.Zero) // If this happened, someone made a mistake....
582 return;
583
584 // We can NOT use the dictionries here, as we are looking
585 // for an entity by the fromAssetID, which is NOT the prim UUID
586 //
587 List<EntityBase> detachEntities = GetEntities();
588 SceneObjectGroup group;
589
590 foreach (EntityBase entity in detachEntities)
591 {
592 if (entity is SceneObjectGroup)
593 {
594 group = (SceneObjectGroup)entity;
595 if (group.GetFromItemID() == itemID)
596 {
597 m_parentScene.SendAttachEvent(group.LocalId, itemID, UUID.Zero);
598 group.DetachToInventoryPrep();
599 m_log.Debug("[DETACH]: Saving attachpoint: " +
600 ((uint)group.GetAttachmentPoint()).ToString());
601 m_parentScene.UpdateKnownItem(remoteClient, group,
602 group.GetFromItemID(), group.OwnerID);
603 m_parentScene.DeleteSceneObject(group, false);
604 return;
605 }
606 }
607 }
608 }
609
610 protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) 577 protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance)
611 { 578 {
612 ScenePresence newAvatar = null; 579 ScenePresence newAvatar = null;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0eee147..8217248 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2931,8 +2931,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2931 2931
2932 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 2932 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
2933 2933
2934 m_ScriptEngine.World.DetachSingleAttachmentToInv(itemID, 2934 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
2935 presence.ControllingClient); 2935 if (attachmentsModule != null)
2936 attachmentsModule.ShowDetachInUserInventory(itemID, presence.ControllingClient);
2936 } 2937 }
2937 } 2938 }
2938 2939