aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorMelanie2010-11-16 20:44:39 +0100
committerMelanie2010-11-16 20:44:39 +0100
commit4f15b8d4e6be1e1fe88ad32aa43595861d1005ad (patch)
tree5c6dd29543347ea43c2a46658a451b355fdbf528 /OpenSim/Region/Framework
parentCan't detach an object from within the script thread because it will throw. (diff)
downloadopensim-SC_OLD-4f15b8d4e6be1e1fe88ad32aa43595861d1005ad.zip
opensim-SC_OLD-4f15b8d4e6be1e1fe88ad32aa43595861d1005ad.tar.gz
opensim-SC_OLD-4f15b8d4e6be1e1fe88ad32aa43595861d1005ad.tar.bz2
opensim-SC_OLD-4f15b8d4e6be1e1fe88ad32aa43595861d1005ad.tar.xz
Change the way attachments are persisted. Editing a worn attachment will now
save properly, as will the results of a resizer script working. Attachment positions are no longer saved on each move, but instead are saved once on logout. Attachment script states are saved as part of the attachment now when detaching.
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs19
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs37
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs18
8 files changed, 72 insertions, 32 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 1d9aeb9..788f42b 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -127,13 +127,20 @@ namespace OpenSim.Region.Framework.Interfaces
127 void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient); 127 void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient);
128 128
129 /// <summary> 129 /// <summary>
130 /// Update the position of an attachment 130 /// Update the user inventory with a changed attachment
131 /// </summary> 131 /// </summary>
132 /// <param name="client"></param> 132 /// <param name="remoteClient">
133 /// <param name="sog"></param> 133 /// A <see cref="IClientAPI"/>
134 /// <param name="pos"></param> 134 /// </param>
135 void UpdateAttachmentPosition(IClientAPI client, SceneObjectGroup sog, Vector3 pos); 135 /// <param name="grp">
136 136 /// A <see cref="SceneObjectGroup"/>
137 /// </param>
138 /// <param name="itemID">
139 /// A <see cref="UUID"/>
140 /// </param>
141 /// <param name="agentID">
142 /// A <see cref="UUID"/>
143 /// </param>
137 void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID); 144 void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID);
138 } 145 }
139} 146}
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 59ce090..ed40da9 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -185,6 +185,7 @@ namespace OpenSim.Region.Framework.Interfaces
185 /// <returns>false if the item did not exist, true if the update occurred successfully</returns> 185 /// <returns>false if the item did not exist, true if the update occurred successfully</returns>
186 bool UpdateInventoryItem(TaskInventoryItem item); 186 bool UpdateInventoryItem(TaskInventoryItem item);
187 bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents); 187 bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents);
188 bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged);
188 189
189 /// <summary> 190 /// <summary>
190 /// Remove an item from this entity's inventory 191 /// Remove an item from this entity's inventory
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index dd06be2..c4639c3 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3255,7 +3255,6 @@ namespace OpenSim.Region.Framework.Scenes
3255 List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles); 3255 List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles);
3256 regions.Remove(RegionInfo.RegionHandle); 3256 regions.Remove(RegionInfo.RegionHandle);
3257 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3257 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3258
3259 } 3258 }
3260 m_log.Debug("[Scene] Beginning ClientClosed"); 3259 m_log.Debug("[Scene] Beginning ClientClosed");
3261 m_eventManager.TriggerClientClosed(agentID, this); 3260 m_eventManager.TriggerClientClosed(agentID, this);
@@ -3271,6 +3270,9 @@ namespace OpenSim.Region.Framework.Scenes
3271 m_eventManager.TriggerOnRemovePresence(agentID); 3270 m_eventManager.TriggerOnRemovePresence(agentID);
3272 m_log.Debug("[Scene] Finished OnRemovePresence"); 3271 m_log.Debug("[Scene] Finished OnRemovePresence");
3273 3272
3273 if (avatar != null && (!avatar.IsChildAgent))
3274 avatar.SaveChangedAttachments();
3275
3274 ForEachClient( 3276 ForEachClient(
3275 delegate(IClientAPI client) 3277 delegate(IClientAPI client)
3276 { 3278 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index a462133..b2d9358 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -281,7 +281,7 @@ namespace OpenSim.Region.Framework.Scenes
281 } 281 }
282 } 282 }
283 283
284 if (!alreadyPersisted) 284 if (attachToBackup && (!alreadyPersisted))
285 { 285 {
286 sceneObject.ForceInventoryPersistence(); 286 sceneObject.ForceInventoryPersistence();
287 sceneObject.HasGroupChanged = true; 287 sceneObject.HasGroupChanged = true;
@@ -304,8 +304,10 @@ namespace OpenSim.Region.Framework.Scenes
304 /// </returns> 304 /// </returns>
305 protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) 305 protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
306 { 306 {
307 // Ensure that we persist this new scene object 307 // Ensure that we persist this new scene object if it's not an
308 sceneObject.HasGroupChanged = true; 308 // attachment
309 if (attachToBackup)
310 sceneObject.HasGroupChanged = true;
309 311
310 return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); 312 return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates);
311 } 313 }
@@ -1342,8 +1344,13 @@ namespace OpenSim.Region.Framework.Scenes
1342 { 1344 {
1343 if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) 1345 if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0))
1344 { 1346 {
1345 if (m_parentScene.AttachmentsModule != null) 1347 // Set the new attachment point data in the object
1346 m_parentScene.AttachmentsModule.UpdateAttachmentPosition(remoteClient, group, pos); 1348 byte attachmentPoint = group.GetAttachmentPoint();
1349 group.UpdateGroupPosition(pos);
1350 group.RootPart.IsAttachment = false;
1351 group.AbsolutePosition = group.RootPart.AttachedPos;
1352 group.SetAttachmentPoint(attachmentPoint);
1353 group.HasGroupChanged = true;
1347 } 1354 }
1348 else 1355 else
1349 { 1356 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 79f7162..ee08072 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -586,13 +586,15 @@ namespace OpenSim.Region.Framework.Scenes
586 XmlNodeList nodes = doc.GetElementsByTagName("SavedScriptState"); 586 XmlNodeList nodes = doc.GetElementsByTagName("SavedScriptState");
587 if (nodes.Count > 0) 587 if (nodes.Count > 0)
588 { 588 {
589 m_savedScriptState = new Dictionary<UUID, string>(); 589 if (m_savedScriptState == null)
590 m_savedScriptState = new Dictionary<UUID, string>();
590 foreach (XmlNode node in nodes) 591 foreach (XmlNode node in nodes)
591 { 592 {
592 if (node.Attributes["UUID"] != null) 593 if (node.Attributes["UUID"] != null)
593 { 594 {
594 UUID itemid = new UUID(node.Attributes["UUID"].Value); 595 UUID itemid = new UUID(node.Attributes["UUID"].Value);
595 m_savedScriptState.Add(itemid, node.InnerXml); 596 if (itemid != UUID.Zero)
597 m_savedScriptState[itemid] = node.InnerXml;
596 } 598 }
597 } 599 }
598 } 600 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index be3e87f..b615d42 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4822,7 +4822,7 @@ namespace OpenSim.Region.Framework.Scenes
4822 { 4822 {
4823 TaskInventoryItem item = Inventory.GetInventoryItem(itemID); 4823 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4824 item.OwnerChanged = false; 4824 item.OwnerChanged = false;
4825 Inventory.UpdateInventoryItem(item); 4825 Inventory.UpdateInventoryItem(item, false, false);
4826 } 4826 }
4827 } 4827 }
4828 } 4828 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 522f75e..8fcfcc5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -131,12 +131,6 @@ namespace OpenSim.Region.Framework.Scenes
131 return; 131 return;
132 } 132 }
133 133
134 HasInventoryChanged = true;
135 if (m_part.ParentGroup != null)
136 {
137 m_part.ParentGroup.HasGroupChanged = true;
138 }
139
140 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 134 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
141 Items.Clear(); 135 Items.Clear();
142 136
@@ -158,12 +152,6 @@ namespace OpenSim.Region.Framework.Scenes
158 return; 152 return;
159 } 153 }
160 154
161 HasInventoryChanged = true;
162 if (m_part.ParentGroup != null)
163 {
164 m_part.ParentGroup.HasGroupChanged = true;
165 }
166
167 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 155 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
168 Items.Clear(); 156 Items.Clear();
169 157
@@ -216,8 +204,15 @@ namespace OpenSim.Region.Framework.Scenes
216 return; 204 return;
217 } 205 }
218 206
219 HasInventoryChanged = true; 207 // Don't let this set the HasGroupChanged flag for attachments
220 m_part.ParentGroup.HasGroupChanged = true; 208 // as this happens during rez and we don't want a new asset
209 // for each attachment each time
210 if (!m_part.ParentGroup.RootPart.IsAttachment)
211 {
212 HasInventoryChanged = true;
213 m_part.ParentGroup.HasGroupChanged = true;
214 }
215
221 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 216 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
222 foreach (TaskInventoryItem item in items) 217 foreach (TaskInventoryItem item in items)
223 { 218 {
@@ -824,11 +819,16 @@ namespace OpenSim.Region.Framework.Scenes
824 /// <returns>false if the item did not exist, true if the update occurred successfully</returns> 819 /// <returns>false if the item did not exist, true if the update occurred successfully</returns>
825 public bool UpdateInventoryItem(TaskInventoryItem item) 820 public bool UpdateInventoryItem(TaskInventoryItem item)
826 { 821 {
827 return UpdateInventoryItem(item, true); 822 return UpdateInventoryItem(item, true, true);
828 } 823 }
829 824
830 public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) 825 public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents)
831 { 826 {
827 return UpdateInventoryItem(item, fireScriptEvents, true);
828 }
829
830 public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged)
831 {
832 m_items.LockItemsForWrite(true); 832 m_items.LockItemsForWrite(true);
833 833
834 if (m_items.ContainsKey(item.ItemID)) 834 if (m_items.ContainsKey(item.ItemID))
@@ -849,8 +849,11 @@ namespace OpenSim.Region.Framework.Scenes
849 m_inventorySerial++; 849 m_inventorySerial++;
850 if (fireScriptEvents) 850 if (fireScriptEvents)
851 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 851 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
852 HasInventoryChanged = true; 852 if (considerChanged)
853 m_part.ParentGroup.HasGroupChanged = true; 853 {
854 HasInventoryChanged = true;
855 m_part.ParentGroup.HasGroupChanged = true;
856 }
854 m_items.LockItemsForWrite(false); 857 m_items.LockItemsForWrite(false);
855 return true; 858 return true;
856 } 859 }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index cc9c445..dfaf06d 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -4340,6 +4340,24 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju
4340 return(new Vector3(x,y,z)); 4340 return(new Vector3(x,y,z));
4341 } 4341 }
4342 4342
4343 public void SaveChangedAttachments()
4344 {
4345 // Need to copy this list because DetachToInventoryPrep mods it
4346 List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(Attachments.ToArray());
4343 4347
4348 IAttachmentsModule attachmentsModule = m_scene.AttachmentsModule;
4349 if (attachmentsModule != null)
4350 {
4351 foreach (SceneObjectGroup grp in attachments)
4352 {
4353 if (grp.HasGroupChanged) // Resizer scripts?
4354 {
4355 grp.DetachToInventoryPrep();
4356 attachmentsModule.UpdateKnownItem(ControllingClient,
4357 grp, grp.GetFromItemID(), grp.OwnerID);
4358 }
4359 }
4360 }
4361 }
4344 } 4362 }
4345} 4363}