aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2010-11-16 21:01:56 +0000
committerMelanie2010-11-16 21:01:56 +0000
commit7bb005b0d1a5ae63ca94a3a3f8ad98e0388ea76b (patch)
treeb73a2aa9f04e9c34281fb38512da3eb800396769 /OpenSim/Region
parentFix osTeleportAgent for hypergrid destinations. (diff)
downloadopensim-SC_OLD-7bb005b0d1a5ae63ca94a3a3f8ad98e0388ea76b.zip
opensim-SC_OLD-7bb005b0d1a5ae63ca94a3a3f8ad98e0388ea76b.tar.gz
opensim-SC_OLD-7bb005b0d1a5ae63ca94a3a3f8ad98e0388ea76b.tar.bz2
opensim-SC_OLD-7bb005b0d1a5ae63ca94a3a3f8ad98e0388ea76b.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')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs34
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs18
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs21
-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/SceneObjectPartInventory.cs40
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs20
9 files changed, 101 insertions, 60 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 348b8b9..1744fb3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -273,6 +273,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
273 273
274 if (objatt != null) 274 if (objatt != null)
275 { 275 {
276 // Loading the inventory from XML will have set this, but
277 // there is no way the object could have changed yet,
278 // since scripts aren't running yet. So, clear it here.
279 objatt.HasGroupChanged = false;
276 bool tainted = false; 280 bool tainted = false;
277 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) 281 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
278 tainted = true; 282 tainted = true;
@@ -470,6 +474,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
470 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); 474 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
471 group.DetachToInventoryPrep(); 475 group.DetachToInventoryPrep();
472 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); 476 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
477
478 // If an item contains scripts, it's always changed.
479 // This ensures script state is saved on detach
480 foreach (SceneObjectPart p in group.Parts)
481 if (p.Inventory.ContainsScripts())
482 group.HasGroupChanged = true;
483
473 UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID); 484 UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID);
474 m_scene.DeleteSceneObject(group, false); 485 m_scene.DeleteSceneObject(group, false);
475 return; 486 return;
@@ -478,25 +489,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
478 } 489 }
479 } 490 }
480 491
481 public void UpdateAttachmentPosition(IClientAPI client, SceneObjectGroup sog, Vector3 pos)
482 {
483 // If this is an attachment, then we need to save the modified
484 // object back into the avatar's inventory. First we save the
485 // attachment point information, then we update the relative
486 // positioning (which caused this method to get driven in the
487 // first place. Then we have to mark the object as NOT an
488 // attachment. This is necessary in order to correctly save
489 // and retrieve GroupPosition information for the attachment.
490 // Then we save the asset back into the appropriate inventory
491 // entry. Finally, we restore the object's attachment status.
492 byte attachmentPoint = sog.GetAttachmentPoint();
493 sog.UpdateGroupPosition(pos);
494 sog.RootPart.IsAttachment = false;
495 sog.AbsolutePosition = sog.RootPart.AttachedPos;
496 UpdateKnownItem(client, sog, sog.GetFromItemID(), sog.OwnerID);
497 sog.SetAttachmentPoint(attachmentPoint);
498 }
499
500 /// <summary> 492 /// <summary>
501 /// Update the attachment asset for the new sog details if they have changed. 493 /// Update the attachment asset for the new sog details if they have changed.
502 /// </summary> 494 /// </summary>
@@ -508,7 +500,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
508 /// <param name="grp"></param> 500 /// <param name="grp"></param>
509 /// <param name="itemID"></param> 501 /// <param name="itemID"></param>
510 /// <param name="agentID"></param> 502 /// <param name="agentID"></param>
511 protected void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) 503 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
512 { 504 {
513 if (grp != null) 505 if (grp != null)
514 { 506 {
@@ -523,7 +515,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
523 grp.UUID, grp.GetAttachmentPoint()); 515 grp.UUID, grp.GetAttachmentPoint());
524 516
525 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); 517 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
526
527 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 518 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
528 item = m_scene.InventoryService.GetItem(item); 519 item = m_scene.InventoryService.GetItem(item);
529 520
@@ -617,7 +608,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
617 // In case it is later dropped again, don't let 608 // In case it is later dropped again, don't let
618 // it get cleaned up 609 // it get cleaned up
619 so.RootPart.RemFlag(PrimFlags.TemporaryOnRez); 610 so.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
620 so.HasGroupChanged = false;
621 } 611 }
622 } 612 }
623} 613}
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 7a175ea..ef21834 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -569,12 +569,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
569 { 569 {
570 group.RootPart.Flags |= PrimFlags.Phantom; 570 group.RootPart.Flags |= PrimFlags.Phantom;
571 group.RootPart.IsAttachment = true; 571 group.RootPart.IsAttachment = true;
572 }
573 572
574 // If we're rezzing an attachment then don't ask AddNewSceneObject() to update the client since 573 // If we're rezzing an attachment then don't ask
575 // we'll be doing that later on. Scheduling more than one full update during the attachment 574 // AddNewSceneObject() to update the client since
576 // process causes some clients to fail to display the attachment properly. 575 // we'll be doing that later on. Scheduling more
577 m_Scene.AddNewSceneObject(group, true, false); 576 // than one full update during the attachment
577 // process causes some clients to fail to display
578 // the attachment properly.
579 // Also, don't persist attachments.
580 m_Scene.AddNewSceneObject(group, false, false);
581 }
582 else
583 {
584 m_Scene.AddNewSceneObject(group, true, false);
585 }
578 586
579 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); 587 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
580 // if attachment we set it's asset id so object updates can reflect that 588 // if attachment we set it's asset id so object updates can reflect that
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 24e481b..b3576c5 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -122,11 +122,20 @@ namespace OpenSim.Region.Framework.Interfaces
122 void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient); 122 void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient);
123 123
124 /// <summary> 124 /// <summary>
125 /// Update the position of an attachment 125 /// Update the user inventory with a changed attachment
126 /// </summary> 126 /// </summary>
127 /// <param name="client"></param> 127 /// <param name="remoteClient">
128 /// <param name="sog"></param> 128 /// A <see cref="IClientAPI"/>
129 /// <param name="pos"></param> 129 /// </param>
130 void UpdateAttachmentPosition(IClientAPI client, SceneObjectGroup sog, Vector3 pos); 130 /// <param name="grp">
131 /// A <see cref="SceneObjectGroup"/>
132 /// </param>
133 /// <param name="itemID">
134 /// A <see cref="UUID"/>
135 /// </param>
136 /// <param name="agentID">
137 /// A <see cref="UUID"/>
138 /// </param>
139 void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID);
131 } 140 }
132} \ No newline at end of file 141}
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 2e6faa0..64664ab 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -183,6 +183,7 @@ namespace OpenSim.Region.Framework.Interfaces
183 /// <returns>false if the item did not exist, true if the update occurred successfully</returns> 183 /// <returns>false if the item did not exist, true if the update occurred successfully</returns>
184 bool UpdateInventoryItem(TaskInventoryItem item); 184 bool UpdateInventoryItem(TaskInventoryItem item);
185 bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents); 185 bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents);
186 bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged);
186 187
187 /// <summary> 188 /// <summary>
188 /// Remove an item from this entity's inventory 189 /// 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 a4cc66d..96a9f99 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3152,7 +3152,6 @@ namespace OpenSim.Region.Framework.Scenes
3152 List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles); 3152 List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles);
3153 regions.Remove(RegionInfo.RegionHandle); 3153 regions.Remove(RegionInfo.RegionHandle);
3154 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3154 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3155
3156 } 3155 }
3157 m_eventManager.TriggerClientClosed(agentID, this); 3156 m_eventManager.TriggerClientClosed(agentID, this);
3158 } 3157 }
@@ -3164,6 +3163,9 @@ namespace OpenSim.Region.Framework.Scenes
3164 3163
3165 m_eventManager.TriggerOnRemovePresence(agentID); 3164 m_eventManager.TriggerOnRemovePresence(agentID);
3166 3165
3166 if (avatar != null && (!avatar.IsChildAgent))
3167 avatar.SaveChangedAttachments();
3168
3167 ForEachClient( 3169 ForEachClient(
3168 delegate(IClientAPI client) 3170 delegate(IClientAPI client)
3169 { 3171 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 24d7334..032c859 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -259,7 +259,7 @@ namespace OpenSim.Region.Framework.Scenes
259 protected internal bool AddRestoredSceneObject( 259 protected internal bool AddRestoredSceneObject(
260 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 260 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
261 { 261 {
262 if (!alreadyPersisted) 262 if (attachToBackup && (!alreadyPersisted))
263 { 263 {
264 sceneObject.ForceInventoryPersistence(); 264 sceneObject.ForceInventoryPersistence();
265 sceneObject.HasGroupChanged = true; 265 sceneObject.HasGroupChanged = true;
@@ -282,8 +282,10 @@ namespace OpenSim.Region.Framework.Scenes
282 /// </returns> 282 /// </returns>
283 protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) 283 protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
284 { 284 {
285 // Ensure that we persist this new scene object 285 // Ensure that we persist this new scene object if it's not an
286 sceneObject.HasGroupChanged = true; 286 // attachment
287 if (attachToBackup)
288 sceneObject.HasGroupChanged = true;
287 289
288 return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); 290 return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates);
289 } 291 }
@@ -1279,8 +1281,13 @@ namespace OpenSim.Region.Framework.Scenes
1279 { 1281 {
1280 if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) 1282 if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0))
1281 { 1283 {
1282 if (m_parentScene.AttachmentsModule != null) 1284 // Set the new attachment point data in the object
1283 m_parentScene.AttachmentsModule.UpdateAttachmentPosition(remoteClient, group, pos); 1285 byte attachmentPoint = group.GetAttachmentPoint();
1286 group.UpdateGroupPosition(pos);
1287 group.RootPart.IsAttachment = false;
1288 group.AbsolutePosition = group.RootPart.AttachedPos;
1289 group.SetAttachmentPoint(attachmentPoint);
1290 group.HasGroupChanged = true;
1284 } 1291 }
1285 else 1292 else
1286 { 1293 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 5f00f84..c2810b2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -491,13 +491,15 @@ namespace OpenSim.Region.Framework.Scenes
491 XmlNodeList nodes = doc.GetElementsByTagName("SavedScriptState"); 491 XmlNodeList nodes = doc.GetElementsByTagName("SavedScriptState");
492 if (nodes.Count > 0) 492 if (nodes.Count > 0)
493 { 493 {
494 m_savedScriptState = new Dictionary<UUID, string>(); 494 if (m_savedScriptState == null)
495 m_savedScriptState = new Dictionary<UUID, string>();
495 foreach (XmlNode node in nodes) 496 foreach (XmlNode node in nodes)
496 { 497 {
497 if (node.Attributes["UUID"] != null) 498 if (node.Attributes["UUID"] != null)
498 { 499 {
499 UUID itemid = new UUID(node.Attributes["UUID"].Value); 500 UUID itemid = new UUID(node.Attributes["UUID"].Value);
500 m_savedScriptState.Add(itemid, node.InnerXml); 501 if (itemid != UUID.Zero)
502 m_savedScriptState[itemid] = node.InnerXml;
501 } 503 }
502 } 504 }
503 } 505 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 0c5e62d..6a204c3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -127,8 +127,6 @@ namespace OpenSim.Region.Framework.Scenes
127 if (0 == m_items.Count) 127 if (0 == m_items.Count)
128 return; 128 return;
129 129
130 HasInventoryChanged = true;
131 m_part.ParentGroup.HasGroupChanged = true;
132 IList<TaskInventoryItem> items = GetInventoryItems(); 130 IList<TaskInventoryItem> items = GetInventoryItems();
133 m_items.Clear(); 131 m_items.Clear();
134 132
@@ -144,17 +142,6 @@ namespace OpenSim.Region.Framework.Scenes
144 { 142 {
145 lock (Items) 143 lock (Items)
146 { 144 {
147 if (Items.Count == 0)
148 {
149 return;
150 }
151
152 HasInventoryChanged = true;
153 if (m_part.ParentGroup != null)
154 {
155 m_part.ParentGroup.HasGroupChanged = true;
156 }
157
158 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 145 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
159 Items.Clear(); 146 Items.Clear();
160 147
@@ -208,8 +195,15 @@ namespace OpenSim.Region.Framework.Scenes
208 } 195 }
209 } 196 }
210 197
211 HasInventoryChanged = true; 198 // Don't let this set the HasGroupChanged flag for attachments
212 m_part.ParentGroup.HasGroupChanged = true; 199 // as this happens during rez and we don't want a new asset
200 // for each attachment each time
201 if (!m_part.ParentGroup.RootPart.IsAttachment)
202 {
203 HasInventoryChanged = true;
204 m_part.ParentGroup.HasGroupChanged = true;
205 }
206
213 List<TaskInventoryItem> items = GetInventoryItems(); 207 List<TaskInventoryItem> items = GetInventoryItems();
214 foreach (TaskInventoryItem item in items) 208 foreach (TaskInventoryItem item in items)
215 { 209 {
@@ -674,13 +668,19 @@ namespace OpenSim.Region.Framework.Scenes
674 /// <returns>false if the item did not exist, true if the update occurred successfully</returns> 668 /// <returns>false if the item did not exist, true if the update occurred successfully</returns>
675 public bool UpdateInventoryItem(TaskInventoryItem item) 669 public bool UpdateInventoryItem(TaskInventoryItem item)
676 { 670 {
677 return UpdateInventoryItem(item, true); 671 return UpdateInventoryItem(item, true, true);
678 } 672 }
679 673
680 public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) 674 public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents)
681 { 675 {
676 return UpdateInventoryItem(item, fireScriptEvents, true);
677 }
678
679 public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged)
680 {
682 TaskInventoryItem it = GetInventoryItem(item.ItemID); 681 TaskInventoryItem it = GetInventoryItem(item.ItemID);
683 if (it != null) 682 if (it != null)
683
684 { 684 {
685 item.ParentID = m_part.UUID; 685 item.ParentID = m_part.UUID;
686 item.ParentPartID = m_part.UUID; 686 item.ParentPartID = m_part.UUID;
@@ -702,9 +702,11 @@ namespace OpenSim.Region.Framework.Scenes
702 702
703 if (fireScriptEvents) 703 if (fireScriptEvents)
704 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 704 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
705 705 if (considerChanged)
706 HasInventoryChanged = true; 706 {
707 m_part.ParentGroup.HasGroupChanged = true; 707 HasInventoryChanged = true;
708 m_part.ParentGroup.HasGroupChanged = true;
709 }
708 return true; 710 return true;
709 } 711 }
710 else 712 else
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 34d1c39..bfc1bd6 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3746,5 +3746,25 @@ namespace OpenSim.Region.Framework.Scenes
3746 m_reprioritization_called = false; 3746 m_reprioritization_called = false;
3747 } 3747 }
3748 } 3748 }
3749
3750 public void SaveChangedAttachments()
3751 {
3752 // Need to copy this list because DetachToInventoryPrep mods it
3753 List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(Attachments.ToArray());
3754
3755 IAttachmentsModule attachmentsModule = m_scene.AttachmentsModule;
3756 if (attachmentsModule != null)
3757 {
3758 foreach (SceneObjectGroup grp in attachments)
3759 {
3760 if (grp.HasGroupChanged) // Resizer scripts?
3761 {
3762 grp.DetachToInventoryPrep();
3763 attachmentsModule.UpdateKnownItem(ControllingClient,
3764 grp, grp.GetFromItemID(), grp.OwnerID);
3765 }
3766 }
3767 }
3768 }
3749 } 3769 }
3750} 3770}