aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorMic Bowman2011-08-26 15:23:46 -0700
committerMic Bowman2011-08-26 15:23:46 -0700
commit23f10f1d22d5ecf542119e39503230994c521bf0 (patch)
tree2498e8cccf2ed398052dfa53e9a1faf6e998d039 /OpenSim/Region/Framework
parentMerge branch 'master' into bulletsim (diff)
parentrefactor: simplify SOP.AttachedAvatar into SOG.AttachedAvatar (diff)
downloadopensim-SC_OLD-23f10f1d22d5ecf542119e39503230994c521bf0.zip
opensim-SC_OLD-23f10f1d22d5ecf542119e39503230994c521bf0.tar.gz
opensim-SC_OLD-23f10f1d22d5ecf542119e39503230994c521bf0.tar.bz2
opensim-SC_OLD-23f10f1d22d5ecf542119e39503230994c521bf0.tar.xz
Merge branch 'master' into bulletsim
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs34
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs43
-rw-r--r--OpenSim/Region/Framework/Interfaces/IWorldComm.cs20
-rw-r--r--OpenSim/Region/Framework/Scenes/EntityBase.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/Prioritizer.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs80
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs158
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs20
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs31
10 files changed, 180 insertions, 225 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 4cb3df2..86f5a0f 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -47,13 +47,11 @@ namespace OpenSim.Region.Framework.Interfaces
47 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent); 47 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent);
48 48
49 /// <summary> 49 /// <summary>
50 /// Attach an object to an avatar. 50 /// Attach an object to an avatar
51 /// </summary> 51 /// </summary>
52 /// <param name="controllingClient"></param> 52 /// <param name="remoteClient"></param>
53 /// <param name="localID"></param> 53 /// <param name="grp"></param>
54 /// <param name="attachPoint"></param> 54 /// <param name="AttachmentPt"></param>
55 /// <param name="rot"></param>
56 /// <param name="attachPos"></param>
57 /// <param name="silent"></param> 55 /// <param name="silent"></param>
58 /// <returns>true if the object was successfully attached, false otherwise</returns> 56 /// <returns>true if the object was successfully attached, false otherwise</returns>
59 bool AttachObject( 57 bool AttachObject(
@@ -107,16 +105,16 @@ namespace OpenSim.Region.Framework.Interfaces
107 /// <summary> 105 /// <summary>
108 /// Detach the given item to the ground. 106 /// Detach the given item to the ground.
109 /// </summary> 107 /// </summary>
110 /// <param name="itemID"></param> 108 /// <param name="sceneObjectID"></param>
111 /// <param name="remoteClient"></param> 109 /// <param name="remoteClient"></param>
112 void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient); 110 void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient);
113 111
114 /// <summary> 112 /// <summary>
115 /// Update the user inventory to show a detach. 113 /// Detach the given item so that it remains in the user's inventory.
116 /// </summary> 114 /// </summary>
117 /// <param name="itemID">/param> 115 /// <param name="itemID">/param>
118 /// <param name="remoteClient"></param> 116 /// <param name="remoteClient"></param>
119 void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient); 117 void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient);
120 118
121 /// <summary> 119 /// <summary>
122 /// Update the position of an attachment. 120 /// Update the position of an attachment.
@@ -128,18 +126,10 @@ namespace OpenSim.Region.Framework.Interfaces
128 /// <summary> 126 /// <summary>
129 /// Update the user inventory with a changed attachment 127 /// Update the user inventory with a changed attachment
130 /// </summary> 128 /// </summary>
131 /// <param name="remoteClient"> 129 /// <param name="remoteClient"></param>
132 /// A <see cref="IClientAPI"/> 130 /// <param name="grp"></param>
133 /// </param> 131 /// <param name="itemID"></param>
134 /// <param name="grp"> 132 /// <param name="agentID"></param>
135 /// A <see cref="SceneObjectGroup"/>
136 /// </param>
137 /// <param name="itemID">
138 /// A <see cref="UUID"/>
139 /// </param>
140 /// <param name="agentID">
141 /// A <see cref="UUID"/>
142 /// </param>
143 void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID); 133 void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID);
144 } 134 }
145} 135}
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs b/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs
new file mode 100644
index 0000000..8cef14e
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs
@@ -0,0 +1,43 @@
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 OpenMetaverse.StructuredData;
30
31namespace OpenSim.Region.Framework.Interfaces
32{
33 /// <summary>
34 /// Add remove or retrieve Simulator Features that will be given to a viewer via the SimulatorFeatures capability.
35 /// </summary>
36 public interface ISimulatorFeaturesModule
37 {
38 void AddFeature(string name, OSD value);
39 bool RemoveFeature(string name);
40 bool TryGetFeature(string name, out OSD value);
41 OSDMap GetFeatures();
42 }
43} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
index 8da99a0..dafbf30 100644
--- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
@@ -81,6 +81,26 @@ namespace OpenSim.Region.Framework.Interfaces
81 void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg); 81 void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg);
82 82
83 /// <summary> 83 /// <summary>
84 /// Delivers the message to a specified object in the region.
85 /// </summary>
86 /// <param name='target'>
87 /// Target.
88 /// </param>
89 /// <param name='channel'>
90 /// Channel.
91 /// </param>
92 /// <param name='name'>
93 /// Name.
94 /// </param>
95 /// <param name='id'>
96 /// Identifier.
97 /// </param>
98 /// <param name='msg'>
99 /// Message.
100 /// </param>
101 bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error);
102
103 /// <summary>
84 /// Are there any listen events ready to be dispatched? 104 /// Are there any listen events ready to be dispatched?
85 /// </summary> 105 /// </summary>
86 /// <returns>boolean indication</returns> 106 /// <returns>boolean indication</returns>
diff --git a/OpenSim/Region/Framework/Scenes/EntityBase.cs b/OpenSim/Region/Framework/Scenes/EntityBase.cs
index 6fd38e5..213431a 100644
--- a/OpenSim/Region/Framework/Scenes/EntityBase.cs
+++ b/OpenSim/Region/Framework/Scenes/EntityBase.cs
@@ -66,12 +66,7 @@ namespace OpenSim.Region.Framework.Scenes
66 /// <summary> 66 /// <summary>
67 /// Signals whether this entity was in a scene but has since been removed from it. 67 /// Signals whether this entity was in a scene but has since been removed from it.
68 /// </summary> 68 /// </summary>
69 public bool IsDeleted 69 public bool IsDeleted { get; protected internal set; }
70 {
71 get { return m_isDeleted; }
72 set { m_isDeleted = value; }
73 }
74 protected bool m_isDeleted;
75 70
76 protected Vector3 m_pos; 71 protected Vector3 m_pos;
77 72
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs
index 4595a29..2a76755 100644
--- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs
+++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs
@@ -116,14 +116,13 @@ namespace OpenSim.Region.Framework.Scenes
116 return priority; 116 return priority;
117 } 117 }
118 118
119
120 private uint GetPriorityByTime(IClientAPI client, ISceneEntity entity) 119 private uint GetPriorityByTime(IClientAPI client, ISceneEntity entity)
121 { 120 {
122 // And anything attached to this avatar gets top priority as well 121 // And anything attached to this avatar gets top priority as well
123 if (entity is SceneObjectPart) 122 if (entity is SceneObjectPart)
124 { 123 {
125 SceneObjectPart sop = (SceneObjectPart)entity; 124 SceneObjectPart sop = (SceneObjectPart)entity;
126 if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar) 125 if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar)
127 return 1; 126 return 1;
128 } 127 }
129 128
@@ -136,7 +135,7 @@ namespace OpenSim.Region.Framework.Scenes
136 if (entity is SceneObjectPart) 135 if (entity is SceneObjectPart)
137 { 136 {
138 SceneObjectPart sop = (SceneObjectPart)entity; 137 SceneObjectPart sop = (SceneObjectPart)entity;
139 if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar) 138 if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar)
140 return 1; 139 return 1;
141 } 140 }
142 141
@@ -149,7 +148,7 @@ namespace OpenSim.Region.Framework.Scenes
149 if (entity is SceneObjectPart) 148 if (entity is SceneObjectPart)
150 { 149 {
151 SceneObjectPart sop = (SceneObjectPart)entity; 150 SceneObjectPart sop = (SceneObjectPart)entity;
152 if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar) 151 if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar)
153 return 1; 152 return 1;
154 } 153 }
155 154
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index afc1a4f..9358e7b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1871,86 +1871,6 @@ namespace OpenSim.Region.Framework.Scenes
1871 } 1871 }
1872 } 1872 }
1873 1873
1874 public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
1875 {
1876 itemID = UUID.Zero;
1877 if (grp != null)
1878 {
1879 Vector3 inventoryStoredPosition = new Vector3
1880 (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
1881 ? 250
1882 : grp.AbsolutePosition.X)
1883 ,
1884 (grp.AbsolutePosition.X > (int)Constants.RegionSize)
1885 ? 250
1886 : grp.AbsolutePosition.X,
1887 grp.AbsolutePosition.Z);
1888
1889 Vector3 originalPosition = grp.AbsolutePosition;
1890
1891 grp.AbsolutePosition = inventoryStoredPosition;
1892
1893 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
1894
1895 grp.AbsolutePosition = originalPosition;
1896
1897 AssetBase asset = CreateAsset(
1898 grp.GetPartName(grp.LocalId),
1899 grp.GetPartDescription(grp.LocalId),
1900 (sbyte)AssetType.Object,
1901 Utils.StringToBytes(sceneObjectXml),
1902 remoteClient.AgentId);
1903 AssetService.Store(asset);
1904
1905 InventoryItemBase item = new InventoryItemBase();
1906 item.CreatorId = grp.RootPart.CreatorID.ToString();
1907 item.CreatorData = grp.RootPart.CreatorData;
1908 item.Owner = remoteClient.AgentId;
1909 item.ID = UUID.Random();
1910 item.AssetID = asset.FullID;
1911 item.Description = asset.Description;
1912 item.Name = asset.Name;
1913 item.AssetType = asset.Type;
1914 item.InvType = (int)InventoryType.Object;
1915
1916 InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
1917 if (folder != null)
1918 item.Folder = folder.ID;
1919 else // oopsies
1920 item.Folder = UUID.Zero;
1921
1922 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
1923 {
1924 item.BasePermissions = grp.RootPart.NextOwnerMask;
1925 item.CurrentPermissions = grp.RootPart.NextOwnerMask;
1926 item.NextPermissions = grp.RootPart.NextOwnerMask;
1927 item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
1928 item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
1929 }
1930 else
1931 {
1932 item.BasePermissions = grp.RootPart.BaseMask;
1933 item.CurrentPermissions = grp.RootPart.OwnerMask;
1934 item.NextPermissions = grp.RootPart.NextOwnerMask;
1935 item.EveryOnePermissions = grp.RootPart.EveryoneMask;
1936 item.GroupPermissions = grp.RootPart.GroupMask;
1937 }
1938 item.CreationDate = Util.UnixTimeSinceEpoch();
1939
1940 // sets itemID so client can show item as 'attached' in inventory
1941 grp.SetFromItemID(item.ID);
1942
1943 if (AddInventoryItem(item))
1944 remoteClient.SendInventoryItemCreateUpdate(item, 0);
1945 else
1946 m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
1947
1948 itemID = item.ID;
1949 return item.AssetID;
1950 }
1951 return UUID.Zero;
1952 }
1953
1954 /// <summary> 1874 /// <summary>
1955 /// Event Handler Rez an object into a scene 1875 /// Event Handler Rez an object into a scene
1956 /// Calls the non-void event handler 1876 /// Calls the non-void event handler
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index fe96152..fada688 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -147,15 +147,16 @@ namespace OpenSim.Region.Framework.Scenes
147 return false; 147 return false;
148 } 148 }
149 149
150 /// <value> 150 /// <summary>
151 /// Is this scene object acting as an attachment? 151 /// Is this scene object acting as an attachment?
152 /// 152 /// </summary>
153 /// <remarks>
153 /// We return false if the group has already been deleted. 154 /// We return false if the group has already been deleted.
154 /// 155 ///
155 /// TODO: At the moment set must be done on the part itself. There may be a case for doing it here since I 156 /// TODO: At the moment set must be done on the part itself. There may be a case for doing it here since I
156 /// presume either all or no parts in a linkset can be part of an attachment (in which 157 /// presume either all or no parts in a linkset can be part of an attachment (in which
157 /// case the value would get proprogated down into all the descendent parts). 158 /// case the value would get proprogated down into all the descendent parts).
158 /// </value> 159 /// </remarks>
159 public bool IsAttachment 160 public bool IsAttachment
160 { 161 {
161 get 162 get
@@ -167,6 +168,52 @@ namespace OpenSim.Region.Framework.Scenes
167 } 168 }
168 } 169 }
169 170
171 /// <summary>
172 /// The avatar to which this scene object is attached.
173 /// </summary>
174 /// <remarks>
175 /// If we're not attached to an avatar then this is UUID.Zero
176 /// </remarks>
177 public UUID AttachedAvatar { get; set; }
178
179 /// <summary>
180 /// Is this scene object phantom?
181 /// </summary>
182 /// <remarks>
183 /// Updating must currently take place through UpdatePrimFlags()
184 /// </remarks>
185 public bool IsPhantom
186 {
187 get { return (RootPart.Flags & PrimFlags.Phantom) != 0; }
188 }
189
190 /// <summary>
191 /// Does this scene object use physics?
192 /// </summary>
193 /// <remarks>
194 /// Updating must currently take place through UpdatePrimFlags()
195 /// </remarks>
196 public bool UsesPhysics
197 {
198 get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; }
199 }
200
201 /// <summary>
202 /// Is this scene object temporary?
203 /// </summary>
204 /// <remarks>
205 /// Updating must currently take place through UpdatePrimFlags()
206 /// </remarks>
207 public bool IsTemporary
208 {
209 get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; }
210 }
211
212 public bool IsVolumeDetect
213 {
214 get { return RootPart.VolumeDetectActive; }
215 }
216
170 public float scriptScore; 217 public float scriptScore;
171 218
172 private Vector3 lastPhysGroupPos; 219 private Vector3 lastPhysGroupPos;
@@ -940,68 +987,16 @@ namespace OpenSim.Region.Framework.Scenes
940 return m_rootPart.Shape.State; 987 return m_rootPart.Shape.State;
941 } 988 }
942 989
943 public void ClearPartAttachmentData() 990 public void SetAttachmentPoint(byte point)
944 {
945 SetAttachmentPoint((Byte)0);
946 }
947
948 public void DetachToGround()
949 { 991 {
950 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar);
951 if (avatar == null)
952 return;
953
954 avatar.RemoveAttachment(this);
955
956 Vector3 detachedpos = new Vector3(127f,127f,127f);
957 if (avatar == null)
958 return;
959
960 detachedpos = avatar.AbsolutePosition;
961 RootPart.FromItemID = UUID.Zero;
962
963 AbsolutePosition = detachedpos;
964 m_rootPart.AttachedAvatar = UUID.Zero;
965
966 SceneObjectPart[] parts = m_parts.GetArray(); 992 SceneObjectPart[] parts = m_parts.GetArray();
967 for (int i = 0; i < parts.Length; i++) 993 for (int i = 0; i < parts.Length; i++)
968 parts[i].AttachedAvatar = UUID.Zero; 994 parts[i].SetAttachmentPoint(point);
969
970 m_rootPart.SetParentLocalId(0);
971 SetAttachmentPoint((byte)0);
972 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim);
973 HasGroupChanged = true;
974 RootPart.Rezzed = DateTime.Now;
975 RootPart.RemFlag(PrimFlags.TemporaryOnRez);
976 AttachToBackup();
977 m_scene.EventManager.TriggerParcelPrimCountTainted();
978 m_rootPart.ScheduleFullUpdate();
979 m_rootPart.ClearUndoState();
980 } 995 }
981 996
982 public void DetachToInventoryPrep() 997 public void ClearPartAttachmentData()
983 { 998 {
984 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); 999 SetAttachmentPoint((Byte)0);
985 //Vector3 detachedpos = new Vector3(127f, 127f, 127f);
986 if (avatar != null)
987 {
988 //detachedpos = avatar.AbsolutePosition;
989 avatar.RemoveAttachment(this);
990 }
991
992 m_rootPart.AttachedAvatar = UUID.Zero;
993
994 SceneObjectPart[] parts = m_parts.GetArray();
995 for (int i = 0; i < parts.Length; i++)
996 parts[i].AttachedAvatar = UUID.Zero;
997
998 m_rootPart.SetParentLocalId(0);
999 //m_rootPart.SetAttachmentPoint((byte)0);
1000 m_rootPart.IsAttachment = false;
1001 AbsolutePosition = m_rootPart.AttachedPos;
1002 //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
1003 //AttachToBackup();
1004 //m_rootPart.ScheduleFullUpdate();
1005 } 1000 }
1006 1001
1007 /// <summary> 1002 /// <summary>
@@ -1510,36 +1505,24 @@ namespace OpenSim.Region.Framework.Scenes
1510 SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); 1505 SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed));
1511 } 1506 }
1512 1507
1513 public void ScriptSetPhysicsStatus(bool UsePhysics) 1508 public void ScriptSetPhysicsStatus(bool usePhysics)
1514 { 1509 {
1515 bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); 1510 UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
1516 bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
1517 bool IsVolumeDetect = RootPart.VolumeDetectActive;
1518 UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
1519 } 1511 }
1520 1512
1521 public void ScriptSetTemporaryStatus(bool TemporaryStatus) 1513 public void ScriptSetTemporaryStatus(bool makeTemporary)
1522 { 1514 {
1523 bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); 1515 UpdatePrimFlags(RootPart.LocalId, UsesPhysics, makeTemporary, IsPhantom, IsVolumeDetect);
1524 bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
1525 bool IsVolumeDetect = RootPart.VolumeDetectActive;
1526 UpdatePrimFlags(RootPart.LocalId, UsePhysics, TemporaryStatus, IsPhantom, IsVolumeDetect);
1527 } 1516 }
1528 1517
1529 public void ScriptSetPhantomStatus(bool PhantomStatus) 1518 public void ScriptSetPhantomStatus(bool makePhantom)
1530 { 1519 {
1531 bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); 1520 UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, makePhantom, IsVolumeDetect);
1532 bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
1533 bool IsVolumeDetect = RootPart.VolumeDetectActive;
1534 UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, PhantomStatus, IsVolumeDetect);
1535 } 1521 }
1536 1522
1537 public void ScriptSetVolumeDetect(bool VDStatus) 1523 public void ScriptSetVolumeDetect(bool makeVolumeDetect)
1538 { 1524 {
1539 bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); 1525 UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, IsPhantom, makeVolumeDetect);
1540 bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
1541 bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
1542 UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, VDStatus);
1543 1526
1544 /* 1527 /*
1545 ScriptSetPhantomStatus(false); // What ever it was before, now it's not phantom anymore 1528 ScriptSetPhantomStatus(false); // What ever it was before, now it's not phantom anymore
@@ -1565,7 +1548,7 @@ namespace OpenSim.Region.Framework.Scenes
1565 { 1548 {
1566 if (IsAttachment) 1549 if (IsAttachment)
1567 { 1550 {
1568 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); 1551 ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
1569 if (avatar != null) 1552 if (avatar != null)
1570 { 1553 {
1571 avatar.PushForce(impulse); 1554 avatar.PushForce(impulse);
@@ -1647,7 +1630,7 @@ namespace OpenSim.Region.Framework.Scenes
1647 { 1630 {
1648 if (IsAttachment) 1631 if (IsAttachment)
1649 { 1632 {
1650 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); 1633 ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
1651 if (avatar != null) 1634 if (avatar != null)
1652 { 1635 {
1653 avatar.MoveToTarget(target, false); 1636 avatar.MoveToTarget(target, false);
@@ -1806,7 +1789,7 @@ namespace OpenSim.Region.Framework.Scenes
1806 // an object has been deleted from a scene before update was processed. 1789 // an object has been deleted from a scene before update was processed.
1807 // A more fundamental overhaul of the update mechanism is required to eliminate all 1790 // A more fundamental overhaul of the update mechanism is required to eliminate all
1808 // the race conditions. 1791 // the race conditions.
1809 if (m_isDeleted) 1792 if (IsDeleted)
1810 return; 1793 return;
1811 1794
1812 // Even temporary objects take part in physics (e.g. temp-on-rez bullets) 1795 // Even temporary objects take part in physics (e.g. temp-on-rez bullets)
@@ -2116,7 +2099,7 @@ namespace OpenSim.Region.Framework.Scenes
2116 } 2099 }
2117 2100
2118 m_scene.UnlinkSceneObject(objectGroup, true); 2101 m_scene.UnlinkSceneObject(objectGroup, true);
2119 objectGroup.m_isDeleted = true; 2102 objectGroup.IsDeleted = true;
2120 2103
2121 objectGroup.m_parts.Clear(); 2104 objectGroup.m_parts.Clear();
2122 2105
@@ -3347,19 +3330,12 @@ namespace OpenSim.Region.Framework.Scenes
3347 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); 3330 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition);
3348 } 3331 }
3349 3332
3350 public void SetAttachmentPoint(byte point)
3351 {
3352 SceneObjectPart[] parts = m_parts.GetArray();
3353 for (int i = 0; i < parts.Length; i++)
3354 parts[i].SetAttachmentPoint(point);
3355 }
3356
3357 #region ISceneObject 3333 #region ISceneObject
3358 3334
3359 public virtual ISceneObject CloneForNewScene() 3335 public virtual ISceneObject CloneForNewScene()
3360 { 3336 {
3361 SceneObjectGroup sog = Copy(false); 3337 SceneObjectGroup sog = Copy(false);
3362 sog.m_isDeleted = false; 3338 sog.IsDeleted = false;
3363 return sog; 3339 return sog;
3364 } 3340 }
3365 3341
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index a0e87d0..e510611 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -221,9 +221,6 @@ namespace OpenSim.Region.Framework.Scenes
221 public scriptEvents AggregateScriptEvents; 221 public scriptEvents AggregateScriptEvents;
222 222
223 223
224 public UUID AttachedAvatar;
225
226
227 public Vector3 AttachedPos; 224 public Vector3 AttachedPos;
228 225
229 226
@@ -728,7 +725,7 @@ namespace OpenSim.Region.Framework.Scenes
728 725
729 if (IsAttachment) 726 if (IsAttachment)
730 { 727 {
731 ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); 728 ScenePresence sp = m_parentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar);
732 if (sp != null) 729 if (sp != null)
733 return sp.AbsolutePosition; 730 return sp.AbsolutePosition;
734 } 731 }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 719f2da..fc89473 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3509,12 +3509,7 @@ namespace OpenSim.Region.Framework.Scenes
3509 public void RemoveAttachment(SceneObjectGroup gobj) 3509 public void RemoveAttachment(SceneObjectGroup gobj)
3510 { 3510 {
3511 lock (m_attachments) 3511 lock (m_attachments)
3512 { 3512 m_attachments.Remove(gobj);
3513 if (m_attachments.Contains(gobj))
3514 {
3515 m_attachments.Remove(gobj);
3516 }
3517 }
3518 } 3513 }
3519 3514
3520 public bool ValidateAttachments() 3515 public bool ValidateAttachments()
@@ -3525,12 +3520,22 @@ namespace OpenSim.Region.Framework.Scenes
3525 foreach (SceneObjectGroup gobj in m_attachments) 3520 foreach (SceneObjectGroup gobj in m_attachments)
3526 { 3521 {
3527 if (gobj == null) 3522 if (gobj == null)
3523 {
3524 m_log.WarnFormat(
3525 "[SCENE PRESENCE]: Failed to validate an attachment for {0} since it was null", Name);
3528 return false; 3526 return false;
3527 }
3529 3528
3530 if (gobj.IsDeleted) 3529 if (gobj.IsDeleted)
3530 {
3531 m_log.WarnFormat(
3532 "[SCENE PRESENCE]: Failed to validate attachment {0} {1} for {2} since it had been deleted",
3533 gobj.Name, gobj.UUID, Name);
3531 return false; 3534 return false;
3535 }
3532 } 3536 }
3533 } 3537 }
3538
3534 return true; 3539 return true;
3535 } 3540 }
3536 3541
@@ -3804,9 +3809,6 @@ namespace OpenSim.Region.Framework.Scenes
3804 List<AvatarAttachment> attachments = m_appearance.GetAttachments(); 3809 List<AvatarAttachment> attachments = m_appearance.GetAttachments();
3805 foreach (AvatarAttachment attach in attachments) 3810 foreach (AvatarAttachment attach in attachments)
3806 { 3811 {
3807 if (m_isDeleted)
3808 return;
3809
3810 int p = attach.AttachPoint; 3812 int p = attach.AttachPoint;
3811 UUID itemID = attach.ItemID; 3813 UUID itemID = attach.ItemID;
3812 3814
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 8fb9fad..a60ee9b 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -127,26 +127,36 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
127 /// <returns></returns> 127 /// <returns></returns>
128 public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject) 128 public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject)
129 { 129 {
130 return ToOriginalXmlFormat(sceneObject, true);
131 }
132
133 /// <summary>
134 /// Serialize a scene object to the original xml format
135 /// </summary>
136 /// <param name="sceneObject"></param>
137 /// <param name="doScriptStates">Control whether script states are also serialized.</para>
138 /// <returns></returns>
139 public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject, bool doScriptStates)
140 {
130 using (StringWriter sw = new StringWriter()) 141 using (StringWriter sw = new StringWriter())
131 { 142 {
132 using (XmlTextWriter writer = new XmlTextWriter(sw)) 143 using (XmlTextWriter writer = new XmlTextWriter(sw))
133 { 144 {
134 ToOriginalXmlFormat(sceneObject, writer); 145 ToOriginalXmlFormat(sceneObject, writer, doScriptStates);
135 } 146 }
136 147
137 return sw.ToString(); 148 return sw.ToString();
138 } 149 }
139 } 150 }
140
141 151
142 /// <summary> 152 /// <summary>
143 /// Serialize a scene object to the original xml format 153 /// Serialize a scene object to the original xml format
144 /// </summary> 154 /// </summary>
145 /// <param name="sceneObject"></param> 155 /// <param name="sceneObject"></param>
146 /// <returns></returns> 156 /// <returns></returns>
147 public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer) 157 public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer, bool doScriptStates)
148 { 158 {
149 ToOriginalXmlFormat(sceneObject, writer, false); 159 ToOriginalXmlFormat(sceneObject, writer, doScriptStates, false);
150 } 160 }
151 161
152 /// <summary> 162 /// <summary>
@@ -156,10 +166,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
156 /// <param name="writer"></param> 166 /// <param name="writer"></param>
157 /// <param name="noRootElement">If false, don't write the enclosing SceneObjectGroup element</param> 167 /// <param name="noRootElement">If false, don't write the enclosing SceneObjectGroup element</param>
158 /// <returns></returns> 168 /// <returns></returns>
159 public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer, bool noRootElement) 169 public static void ToOriginalXmlFormat(
170 SceneObjectGroup sceneObject, XmlTextWriter writer, bool doScriptStates, bool noRootElement)
160 { 171 {
161 //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name); 172// m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", sceneObject.Name);
162 //int time = System.Environment.TickCount; 173// int time = System.Environment.TickCount;
163 174
164 if (!noRootElement) 175 if (!noRootElement)
165 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); 176 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
@@ -182,12 +193,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
182 } 193 }
183 194
184 writer.WriteEndElement(); // OtherParts 195 writer.WriteEndElement(); // OtherParts
185 sceneObject.SaveScriptedState(writer); 196
197 if (doScriptStates)
198 sceneObject.SaveScriptedState(writer);
186 199
187 if (!noRootElement) 200 if (!noRootElement)
188 writer.WriteEndElement(); // SceneObjectGroup 201 writer.WriteEndElement(); // SceneObjectGroup
189 202
190 //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); 203// m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", sceneObject.Name, System.Environment.TickCount - time);
191 } 204 }
192 205
193 protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer) 206 protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer)