aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs40
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs21
-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
10 files changed, 97 insertions, 68 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 929db21..fc92fc3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -276,6 +276,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
276 276
277 if (objatt != null) 277 if (objatt != null)
278 { 278 {
279 // Loading the inventory from XML will have set this, but
280 // there is no way the object could have changed yet,
281 // since scripts aren't running yet. So, clear it here.
282 objatt.HasGroupChanged = false;
279 bool tainted = false; 283 bool tainted = false;
280 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) 284 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
281 tainted = true; 285 tainted = true;
@@ -486,9 +490,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
486 { 490 {
487 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); 491 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
488 // CM / XMREngine!!!! Needed to conclude attach event 492 // CM / XMREngine!!!! Needed to conclude attach event
489 SceneObjectSerializer.ToOriginalXmlFormat(group); 493 //SceneObjectSerializer.ToOriginalXmlFormat(group);
490 group.DetachToInventoryPrep(); 494 group.DetachToInventoryPrep();
491 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); 495 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
496
497 // If an item contains scripts, it's always changed.
498 // This ensures script state is saved on detach
499 foreach (SceneObjectPart p in group.Parts)
500 if (p.Inventory.ContainsScripts())
501 group.HasGroupChanged = true;
502
492 UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID); 503 UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID);
493 m_scene.DeleteSceneObject(group, false); 504 m_scene.DeleteSceneObject(group, false);
494 return; 505 return;
@@ -497,25 +508,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
497 } 508 }
498 } 509 }
499 510
500 public void UpdateAttachmentPosition(IClientAPI client, SceneObjectGroup sog, Vector3 pos)
501 {
502 // If this is an attachment, then we need to save the modified
503 // object back into the avatar's inventory. First we save the
504 // attachment point information, then we update the relative
505 // positioning (which caused this method to get driven in the
506 // first place. Then we have to mark the object as NOT an
507 // attachment. This is necessary in order to correctly save
508 // and retrieve GroupPosition information for the attachment.
509 // Then we save the asset back into the appropriate inventory
510 // entry. Finally, we restore the object's attachment status.
511 byte attachmentPoint = sog.GetAttachmentPoint();
512 sog.UpdateGroupPosition(pos);
513 sog.RootPart.IsAttachment = false;
514 sog.AbsolutePosition = sog.RootPart.AttachedPos;
515 UpdateKnownItem(client, sog, sog.GetFromItemID(), sog.OwnerID);
516 sog.SetAttachmentPoint(attachmentPoint);
517 }
518
519 /// <summary> 511 /// <summary>
520 /// Update the attachment asset for the new sog details if they have changed. 512 /// Update the attachment asset for the new sog details if they have changed.
521 /// </summary> 513 /// </summary>
@@ -531,12 +523,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
531 { 523 {
532 if (grp != null) 524 if (grp != null)
533 { 525 {
534 // If an item contains scripts, it's always changed.
535 // This ensures script state is saved on detach
536 foreach (SceneObjectPart p in grp.Parts)
537 if (p.Inventory.ContainsScripts())
538 grp.HasGroupChanged = true;
539
540 if (!grp.HasGroupChanged) 526 if (!grp.HasGroupChanged)
541 { 527 {
542 m_log.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID); 528 m_log.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID);
@@ -548,7 +534,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
548 grp.UUID, grp.GetAttachmentPoint()); 534 grp.UUID, grp.GetAttachmentPoint());
549 535
550 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); 536 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
551
552 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 537 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
553 item = m_scene.InventoryService.GetItem(item); 538 item = m_scene.InventoryService.GetItem(item);
554 539
@@ -642,7 +627,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
642 // In case it is later dropped again, don't let 627 // In case it is later dropped again, don't let
643 // it get cleaned up 628 // it get cleaned up
644 so.RootPart.RemFlag(PrimFlags.TemporaryOnRez); 629 so.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
645 so.HasGroupChanged = false;
646 } 630 }
647 } 631 }
648} 632}
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 0700aa5..2e3db48 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -719,15 +719,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
719 { 719 {
720 group.RootPart.Flags |= PrimFlags.Phantom; 720 group.RootPart.Flags |= PrimFlags.Phantom;
721 group.RootPart.IsAttachment = true; 721 group.RootPart.IsAttachment = true;
722 }
723 722
724 // If we're rezzing an attachment then don't ask 723 // If we're rezzing an attachment then don't ask
725 // AddNewSceneObject() to update the client since 724 // AddNewSceneObject() to update the client since
726 // we'll be doing that later on. Scheduling more than 725 // we'll be doing that later on. Scheduling more
727 // one full update during the attachment 726 // than one full update during the attachment
728 // process causes some clients to fail to display the 727 // process causes some clients to fail to display
729 // attachment properly. 728 // the attachment properly.
730 m_Scene.AddNewSceneObject(group, true, false); 729 // Also, don't persist attachments.
730 m_Scene.AddNewSceneObject(group, false, false);
731 }
732 else
733 {
734 m_Scene.AddNewSceneObject(group, true, false);
735 }
731 736
732 // if attachment we set it's asset id so object updates 737 // if attachment we set it's asset id so object updates
733 // can reflect that, if not, we set it's position in world. 738 // can reflect that, if not, we set it's position in world.
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}