aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorMelanie2010-03-06 12:37:24 +0000
committerMelanie2010-03-06 12:37:24 +0000
commit8180c72cbc9cafff247d614ac14db29499fc32a9 (patch)
treefd92204394e657b805e094a237ffecaf50066df6 /OpenSim/Region/Framework
parentMerge branch 'master' into careminster-presence-refactor (diff)
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC-8180c72cbc9cafff247d614ac14db29499fc32a9.zip
opensim-SC-8180c72cbc9cafff247d614ac14db29499fc32a9.tar.gz
opensim-SC-8180c72cbc9cafff247d614ac14db29499fc32a9.tar.bz2
opensim-SC-8180c72cbc9cafff247d614ac14db29499fc32a9.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs72
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs30
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs109
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs31
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs133
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs8
8 files changed, 119 insertions, 270 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
new file mode 100644
index 0000000..367ff3d
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -0,0 +1,72 @@
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 OpenSim 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 OpenMetaverse;
30using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes;
32
33namespace OpenSim.Region.Framework.Interfaces
34{
35 public interface IAttachmentsModule
36 {
37 /// <summary>
38 /// Attach an object to an avatar.
39 /// </summary>
40 /// <param name="controllingClient"></param>
41 /// <param name="localID"></param>
42 /// <param name="attachPoint"></param>
43 /// <param name="rot"></param>
44 /// <param name="pos"></param>
45 /// <param name="silent"></param>
46 /// <returns>true if the object was successfully attached, false otherwise</returns>
47 bool AttachObject(
48 IClientAPI controllingClient, uint localID, uint attachPoint, Quaternion rot, Vector3 pos, bool silent);
49
50 /// <summary>
51 /// Update the user inventory to the attachment of an item
52 /// </summary>
53 /// <param name="att"></param>
54 /// <param name="remoteClient"></param>
55 /// <param name="itemID"></param>
56 /// <param name="AttachmentPt"></param>
57 /// <returns></returns>
58 UUID SetAttachmentInventoryStatus(
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);
71 }
72} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 3cce53d..1650946 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -110,21 +110,24 @@ namespace OpenSim.Region.Framework.Scenes
110 public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; 110 public event OnSetRootAgentSceneDelegate OnSetRootAgentScene;
111 111
112 /// <summary> 112 /// <summary>
113 /// Called when an object is touched/grabbed. 113 /// Fired when an object is touched/grabbed.
114 /// </summary> 114 /// </summary>
115 /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of 115 /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of
116 /// the root part. 116 /// the root part.
117 public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
118 public event ObjectGrabDelegate OnObjectGrab; 117 public event ObjectGrabDelegate OnObjectGrab;
118 public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
119 119
120 public event ObjectGrabDelegate OnObjectGrabbing; 120 public event ObjectGrabDelegate OnObjectGrabbing;
121 public event ObjectDeGrabDelegate OnObjectDeGrab; 121 public event ObjectDeGrabDelegate OnObjectDeGrab;
122 public event ScriptResetDelegate OnScriptReset; 122 public event ScriptResetDelegate OnScriptReset;
123 123
124 public event OnPermissionErrorDelegate OnPermissionError; 124 public event OnPermissionErrorDelegate OnPermissionError;
125 125
126 public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); 126 /// <summary>
127 /// Fired when a new script is created.
128 /// </summary>
127 public event NewRezScript OnRezScript; 129 public event NewRezScript OnRezScript;
130 public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource);
128 131
129 public delegate void RemoveScript(uint localID, UUID itemID); 132 public delegate void RemoveScript(uint localID, UUID itemID);
130 public event RemoveScript OnRemoveScript; 133 public event RemoveScript OnRemoveScript;
@@ -166,38 +169,35 @@ namespace OpenSim.Region.Framework.Scenes
166 169
167 public delegate void ClientClosed(UUID clientID, Scene scene); 170 public delegate void ClientClosed(UUID clientID, Scene scene);
168 171
169 public event ClientClosed OnClientClosed; 172 public event ClientClosed OnClientClosed;
170
171 public delegate void ScriptChangedEvent(uint localID, uint change);
172 173
174 /// <summary>
175 /// This is fired when a scene object property that a script might be interested in (such as color, scale or
176 /// inventory) changes. Only enough information is sent for the LSL changed event
177 /// (see http://lslwiki.net/lslwiki/wakka.php?wakka=changed)
178 /// </summary>
173 public event ScriptChangedEvent OnScriptChangedEvent; 179 public event ScriptChangedEvent OnScriptChangedEvent;
180 public delegate void ScriptChangedEvent(uint localID, uint change);
174 181
175 public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed); 182 public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed);
176
177 public event ScriptControlEvent OnScriptControlEvent; 183 public event ScriptControlEvent OnScriptControlEvent;
178 184
179 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); 185 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos);
180
181 public event ScriptAtTargetEvent OnScriptAtTargetEvent; 186 public event ScriptAtTargetEvent OnScriptAtTargetEvent;
182 187
183 public delegate void ScriptNotAtTargetEvent(uint localID); 188 public delegate void ScriptNotAtTargetEvent(uint localID);
184
185 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; 189 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent;
186 190
187 public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot); 191 public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot);
188
189 public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent; 192 public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent;
190 193
191 public delegate void ScriptNotAtRotTargetEvent(uint localID); 194 public delegate void ScriptNotAtRotTargetEvent(uint localID);
192
193 public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent; 195 public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent;
194 196
195 public delegate void ScriptColliding(uint localID, ColliderArgs colliders); 197 public delegate void ScriptColliding(uint localID, ColliderArgs colliders);
196
197 public event ScriptColliding OnScriptColliderStart; 198 public event ScriptColliding OnScriptColliderStart;
198 public event ScriptColliding OnScriptColliding; 199 public event ScriptColliding OnScriptColliding;
199 public event ScriptColliding OnScriptCollidingEnd; 200 public event ScriptColliding OnScriptCollidingEnd;
200
201 public event ScriptColliding OnScriptLandColliderStart; 201 public event ScriptColliding OnScriptLandColliderStart;
202 public event ScriptColliding OnScriptLandColliding; 202 public event ScriptColliding OnScriptLandColliding;
203 public event ScriptColliding OnScriptLandColliderEnd; 203 public event ScriptColliding OnScriptLandColliderEnd;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 9cbaffc..eb51019 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1862,39 +1862,11 @@ namespace OpenSim.Region.Framework.Scenes
1862 1862
1863 if (att == null) 1863 if (att == null)
1864 { 1864 {
1865 DetachSingleAttachmentToInv(itemID, remoteClient); 1865 AttachmentsModule.ShowDetachInUserInventory(itemID, remoteClient);
1866 return UUID.Zero; 1866 return UUID.Zero;
1867 } 1867 }
1868 1868
1869 return RezSingleAttachment(att, remoteClient, itemID, AttachmentPt); 1869 return AttachmentsModule.SetAttachmentInventoryStatus(att, remoteClient, itemID, AttachmentPt);
1870 }
1871
1872 /// <summary>
1873 /// Update the user inventory to reflect an attachment
1874 /// </summary>
1875 /// <param name="att"></param>
1876 /// <param name="remoteClient"></param>
1877 /// <param name="itemID"></param>
1878 /// <param name="AttachmentPt"></param>
1879 /// <returns></returns>
1880 public UUID RezSingleAttachment(SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
1881 {
1882 m_log.DebugFormat(
1883 "[USER INVENTORY]: Updating inventory of {0} to show attachment of {1} (item ID {2})",
1884 remoteClient.Name, att.Name, itemID);
1885
1886 if (!att.IsDeleted)
1887 AttachmentPt = att.RootPart.AttachmentPoint;
1888
1889 ScenePresence presence;
1890 if (TryGetAvatar(remoteClient.AgentId, out presence))
1891 {
1892 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
1893 item = InventoryService.GetItem(item);
1894
1895 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
1896 }
1897 return att.UUID;
1898 } 1870 }
1899 1871
1900 public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, 1872 public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
@@ -1906,65 +1878,6 @@ namespace OpenSim.Region.Framework.Scenes
1906 } 1878 }
1907 } 1879 }
1908 1880
1909 /// <summary>
1910 /// Attach an object.
1911 /// </summary>
1912 /// <param name="controllingClient"></param>
1913 /// <param name="localID"></param>
1914 /// <param name="attachPoint"></param>
1915 /// <param name="rot"></param>
1916 /// <param name="pos"></param>
1917 /// <param name="silent"></param>
1918 /// <returns>true if the object was successfully attached, false otherwise</returns>
1919 public bool AttachObject(IClientAPI controllingClient, uint localID, uint attachPoint, Quaternion rot, Vector3 pos, bool silent)
1920 {
1921 return m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent);
1922 }
1923
1924 /// <summary>
1925 /// This registers the item as attached in a user's inventory
1926 /// </summary>
1927 /// <param name="remoteClient"></param>
1928 /// <param name="AttachmentPt"></param>
1929 /// <param name="itemID"></param>
1930 /// <param name="att"></param>
1931 public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att)
1932 {
1933// m_log.DebugFormat(
1934// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
1935// att.Name, remoteClient.Name, AttachmentPt, itemID);
1936
1937 if (UUID.Zero == itemID)
1938 {
1939 m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID.");
1940 return;
1941 }
1942
1943 if (0 == AttachmentPt)
1944 {
1945 m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error attachment point.");
1946 return;
1947 }
1948
1949 if (null == att.RootPart)
1950 {
1951 m_log.Error("[SCENE INVENTORY]: Unable to save attachment for a prim without the rootpart!");
1952 return;
1953 }
1954
1955 ScenePresence presence;
1956 if (TryGetAvatar(remoteClient.AgentId, out presence))
1957 {
1958 // XXYY!!
1959 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
1960 item = InventoryService.GetItem(item);
1961 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
1962
1963 if (m_AvatarFactory != null)
1964 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
1965 }
1966 }
1967
1968 public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) 1881 public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient)
1969 { 1882 {
1970 SceneObjectPart part = GetSceneObjectPart(itemID); 1883 SceneObjectPart part = GetSceneObjectPart(itemID);
@@ -1995,24 +1908,6 @@ namespace OpenSim.Region.Framework.Scenes
1995 SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); 1908 SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero);
1996 } 1909 }
1997 1910
1998 public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
1999 {
2000 ScenePresence presence;
2001 if (TryGetAvatar(remoteClient.AgentId, out presence))
2002 {
2003 presence.Appearance.DetachAttachment(itemID);
2004
2005 // Save avatar attachment information
2006 if (m_AvatarFactory != null)
2007 {
2008 m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID);
2009 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
2010 }
2011 }
2012
2013 m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient);
2014 }
2015
2016 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 1911 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
2017 { 1912 {
2018 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); 1913 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index a84f966..388bc99 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -307,6 +307,7 @@ namespace OpenSim.Region.Framework.Scenes
307 307
308 protected IXMLRPC m_xmlrpcModule; 308 protected IXMLRPC m_xmlrpcModule;
309 protected IWorldComm m_worldCommModule; 309 protected IWorldComm m_worldCommModule;
310 public IAttachmentsModule AttachmentsModule { get; set; }
310 protected IAvatarFactory m_AvatarFactory; 311 protected IAvatarFactory m_AvatarFactory;
311 public IAvatarFactory AvatarFactory 312 public IAvatarFactory AvatarFactory
312 { 313 {
@@ -1146,10 +1147,7 @@ namespace OpenSim.Region.Framework.Scenes
1146 1147
1147 public int GetInaccurateNeighborCount() 1148 public int GetInaccurateNeighborCount()
1148 { 1149 {
1149 lock (m_neighbours) 1150 return m_neighbours.Count;
1150 {
1151 return m_neighbours.Count;
1152 }
1153 } 1151 }
1154 1152
1155 // This is the method that shuts down the scene. 1153 // This is the method that shuts down the scene.
@@ -1229,6 +1227,7 @@ namespace OpenSim.Region.Framework.Scenes
1229 m_worldCommModule = RequestModuleInterface<IWorldComm>(); 1227 m_worldCommModule = RequestModuleInterface<IWorldComm>();
1230 XferManager = RequestModuleInterface<IXfer>(); 1228 XferManager = RequestModuleInterface<IXfer>();
1231 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); 1229 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>();
1230 AttachmentsModule = RequestModuleInterface<IAttachmentsModule>();
1232 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1231 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1233 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1232 m_dialogModule = RequestModuleInterface<IDialogModule>();
1234 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1233 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
@@ -2432,9 +2431,11 @@ namespace OpenSim.Region.Framework.Scenes
2432 //grp.SetFromAssetID(grp.RootPart.LastOwnerID); 2431 //grp.SetFromAssetID(grp.RootPart.LastOwnerID);
2433 m_log.DebugFormat( 2432 m_log.DebugFormat(
2434 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2433 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2434
2435 if (AttachmentsModule != null)
2436 AttachmentsModule.AttachObject(
2437 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false);
2435 2438
2436 AttachObject(
2437 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false);
2438 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2439 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2439 grp.SendGroupFullUpdate(); 2440 grp.SendGroupFullUpdate();
2440 } 2441 }
@@ -2669,10 +2670,12 @@ namespace OpenSim.Region.Framework.Scenes
2669 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) 2670 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client)
2670 { 2671 {
2671 client.OnRezSingleAttachmentFromInv += RezSingleAttachment; 2672 client.OnRezSingleAttachmentFromInv += RezSingleAttachment;
2672 client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments; 2673 client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments;
2673 client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv;
2674 client.OnObjectAttach += m_sceneGraph.AttachObject; 2674 client.OnObjectAttach += m_sceneGraph.AttachObject;
2675 client.OnObjectDetach += m_sceneGraph.DetachObject; 2675 client.OnObjectDetach += m_sceneGraph.DetachObject;
2676
2677 if (AttachmentsModule != null)
2678 client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory;
2676 } 2679 }
2677 2680
2678 public virtual void SubscribeToClientTeleportEvents(IClientAPI client) 2681 public virtual void SubscribeToClientTeleportEvents(IClientAPI client)
@@ -2719,8 +2722,7 @@ namespace OpenSim.Region.Framework.Scenes
2719 } 2722 }
2720 2723
2721 protected virtual void UnsubscribeToClientEvents(IClientAPI client) 2724 protected virtual void UnsubscribeToClientEvents(IClientAPI client)
2722 { 2725 {
2723
2724 } 2726 }
2725 2727
2726 /// <summary> 2728 /// <summary>
@@ -2742,7 +2744,6 @@ namespace OpenSim.Region.Framework.Scenes
2742 2744
2743 UnSubscribeToClientNetworkEvents(client); 2745 UnSubscribeToClientNetworkEvents(client);
2744 2746
2745
2746 // EventManager.TriggerOnNewClient(client); 2747 // EventManager.TriggerOnNewClient(client);
2747 } 2748 }
2748 2749
@@ -2822,12 +2823,14 @@ namespace OpenSim.Region.Framework.Scenes
2822 } 2823 }
2823 2824
2824 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) 2825 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client)
2825 { 2826 {
2826 client.OnRezSingleAttachmentFromInv -= RezSingleAttachment;
2827 client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments; 2827 client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments;
2828 client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; 2828 client.OnRezSingleAttachmentFromInv -= RezSingleAttachment;
2829 client.OnObjectAttach -= m_sceneGraph.AttachObject; 2829 client.OnObjectAttach -= m_sceneGraph.AttachObject;
2830 client.OnObjectDetach -= m_sceneGraph.DetachObject; 2830 client.OnObjectDetach -= m_sceneGraph.DetachObject;
2831
2832 if (AttachmentsModule != null)
2833 client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory;
2831 } 2834 }
2832 2835
2833 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) 2836 public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client)
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index cac768e..4e41b07 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -476,7 +476,7 @@ namespace OpenSim.Region.Framework.Scenes
476 if (group != null) 476 if (group != null)
477 { 477 {
478 //group.DetachToGround(); 478 //group.DetachToGround();
479 m_parentScene.DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); 479 m_parentScene.AttachmentsModule.ShowDetachInUserInventory(group.GetFromItemID(), remoteClient);
480 } 480 }
481 } 481 }
482 482
@@ -528,7 +528,7 @@ namespace OpenSim.Region.Framework.Scenes
528 return; 528 return;
529 529
530 // Calls attach with a Zero position 530 // Calls attach with a Zero position
531 if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false)) 531 if (m_parentScene.AttachmentsModule.AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false))
532 { 532 {
533 m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); 533 m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId);
534 534
@@ -571,8 +571,10 @@ namespace OpenSim.Region.Framework.Scenes
571 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) 571 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
572 tainted = true; 572 tainted = true;
573 573
574 AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false); 574 m_parentScene.AttachmentsModule.AttachObject(
575 remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
575 //objatt.ScheduleGroupForFullUpdate(); 576 //objatt.ScheduleGroupForFullUpdate();
577
576 if (tainted) 578 if (tainted)
577 objatt.HasGroupChanged = true; 579 objatt.HasGroupChanged = true;
578 580
@@ -596,131 +598,6 @@ namespace OpenSim.Region.Framework.Scenes
596 return null; 598 return null;
597 } 599 }
598 600
599 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
600 // To LocalId or UUID, *THAT* is the question. How now Brown UUID??
601 public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
602 {
603 if (itemID == UUID.Zero) // If this happened, someone made a mistake....
604 return;
605
606 // We can NOT use the dictionries here, as we are looking
607 // for an entity by the fromAssetID, which is NOT the prim UUID
608 //
609 List<EntityBase> detachEntities = GetEntities();
610 SceneObjectGroup group;
611
612 foreach (EntityBase entity in detachEntities)
613 {
614 if (entity is SceneObjectGroup)
615 {
616 group = (SceneObjectGroup)entity;
617 if (group.GetFromItemID() == itemID)
618 {
619 m_parentScene.SendAttachEvent(group.LocalId, itemID, UUID.Zero);
620 bool hasScripts = false;
621 foreach (SceneObjectPart part in group.Children.Values)
622 {
623 if (part.Inventory.ContainsScripts())
624 {
625 hasScripts = true;
626 break;
627 }
628 }
629
630 if (hasScripts) // Allow the object to execute the attach(NULL_KEY) event
631 System.Threading.Thread.Sleep(100);
632 group.DetachToInventoryPrep();
633 m_log.Debug("[DETACH]: Saving attachpoint: " +
634 ((uint)group.GetAttachmentPoint()).ToString());
635 m_parentScene.UpdateKnownItem(remoteClient, group,
636 group.GetFromItemID(), group.OwnerID);
637 m_parentScene.DeleteSceneObject(group, false);
638 return;
639 }
640 }
641 }
642 }
643
644 /// <summary>
645 /// Attach a scene object to an avatar.
646 /// </summary>
647 /// <param name="remoteClient"></param>
648 /// <param name="objectLocalID"></param>
649 /// <param name="AttachmentPt"></param>
650 /// <param name="rot"></param>
651 /// <param name="attachPos"></param>
652 /// <param name="silent"></param>
653 /// <returns>true if the attachment was successful, false otherwise</returns>
654 protected internal bool AttachObject(
655 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent)
656 {
657 SceneObjectGroup group = GetGroupByPrim(objectLocalID);
658 if (group != null)
659 {
660 if (m_parentScene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
661 {
662 // If the attachment point isn't the same as the one previously used
663 // set it's offset position = 0 so that it appears on the attachment point
664 // and not in a weird location somewhere unknown.
665 if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint())
666 {
667 attachPos = Vector3.Zero;
668 }
669
670 // AttachmentPt 0 means the client chose to 'wear' the attachment.
671 if (AttachmentPt == 0)
672 {
673 // Check object for stored attachment point
674 AttachmentPt = (uint)group.GetAttachmentPoint();
675 }
676
677 // if we still didn't find a suitable attachment point.......
678 if (AttachmentPt == 0)
679 {
680 // Stick it on left hand with Zero Offset from the attachment point.
681 AttachmentPt = (uint)AttachmentPoint.LeftHand;
682 attachPos = Vector3.Zero;
683 }
684
685 group.SetAttachmentPoint((byte)AttachmentPt);
686 group.AbsolutePosition = attachPos;
687
688 // Saves and gets itemID
689 UUID itemId;
690
691 if (group.GetFromItemID() == UUID.Zero)
692 {
693 m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId);
694 }
695 else
696 {
697 itemId = group.GetFromItemID();
698 }
699
700 m_parentScene.AttachObject(remoteClient, AttachmentPt, itemId, group);
701
702 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent);
703 // In case it is later dropped again, don't let
704 // it get cleaned up
705 //
706 group.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
707 group.HasGroupChanged = false;
708 }
709 else
710 {
711 remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false);
712 return false;
713 }
714 }
715 else
716 {
717 m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID);
718 return false;
719 }
720
721 return true;
722 }
723
724 protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) 601 protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance)
725 { 602 {
726 ScenePresence newAvatar = null; 603 ScenePresence newAvatar = null;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index badf782..e0d0fe1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4732,5 +4732,10 @@ namespace OpenSim.Region.Framework.Scenes
4732 m_log.Error("[Physics] " + ex); 4732 m_log.Error("[Physics] " + ex);
4733 } 4733 }
4734 } 4734 }
4735
4736 public Color4 GetTextColor()
4737 {
4738 return new Color4((byte)Color.R, (byte)Color.G, (byte)Color.B, (byte)(0xFF - Color.A));
4739 }
4735 } 4740 }
4736} 4741}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 013285f..836622d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -641,7 +641,6 @@ namespace OpenSim.Region.Framework.Scenes
641 m_items[item.ItemID] = item; 641 m_items[item.ItemID] = item;
642 m_inventorySerial++; 642 m_inventorySerial++;
643 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 643 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
644
645 HasInventoryChanged = true; 644 HasInventoryChanged = true;
646 m_part.ParentGroup.HasGroupChanged = true; 645 m_part.ParentGroup.HasGroupChanged = true;
647 m_items.LockItemsForWrite(false); 646 m_items.LockItemsForWrite(false);
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 9dbe332..93e66e0 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2872,6 +2872,9 @@ namespace OpenSim.Region.Framework.Scenes
2872 if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || 2872 if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance ||
2873 Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) 2873 Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance)
2874 { 2874 {
2875 m_lastChildAgentUpdatePosition = AbsolutePosition;
2876 m_lastChildAgentUpdateCamPosition = CameraPosition;
2877
2875 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); 2878 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
2876 cadu.ActiveGroupID = UUID.Zero.Guid; 2879 cadu.ActiveGroupID = UUID.Zero.Guid;
2877 cadu.AgentID = UUID.Guid; 2880 cadu.AgentID = UUID.Guid;
@@ -2880,8 +2883,6 @@ namespace OpenSim.Region.Framework.Scenes
2880 Vector3 tempCameraCenter = m_CameraCenter; 2883 Vector3 tempCameraCenter = m_CameraCenter;
2881 cadu.cameraPosition = tempCameraCenter; 2884 cadu.cameraPosition = tempCameraCenter;
2882 cadu.drawdistance = m_DrawDistance; 2885 cadu.drawdistance = m_DrawDistance;
2883 if (m_scene.Permissions.IsGod(new UUID(cadu.AgentID)))
2884 cadu.godlevel = m_godlevel;
2885 cadu.GroupAccess = 0; 2886 cadu.GroupAccess = 0;
2886 cadu.Position = AbsolutePosition; 2887 cadu.Position = AbsolutePosition;
2887 cadu.regionHandle = m_rootRegionHandle; 2888 cadu.regionHandle = m_rootRegionHandle;
@@ -2904,9 +2905,6 @@ namespace OpenSim.Region.Framework.Scenes
2904 agentpos.CopyFrom(cadu); 2905 agentpos.CopyFrom(cadu);
2905 2906
2906 m_scene.SendOutChildAgentUpdates(agentpos, this); 2907 m_scene.SendOutChildAgentUpdates(agentpos, this);
2907
2908 m_lastChildAgentUpdatePosition = AbsolutePosition;
2909 m_lastChildAgentUpdateCamPosition = CameraPosition;
2910 } 2908 }
2911 } 2909 }
2912 2910