aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar
diff options
context:
space:
mode:
authorMelanie2010-11-16 20:44:39 +0100
committerMelanie2010-11-16 20:44:39 +0100
commit4f15b8d4e6be1e1fe88ad32aa43595861d1005ad (patch)
tree5c6dd29543347ea43c2a46658a451b355fdbf528 /OpenSim/Region/CoreModules/Avatar
parentCan't detach an object from within the script thread because it will throw. (diff)
downloadopensim-SC-4f15b8d4e6be1e1fe88ad32aa43595861d1005ad.zip
opensim-SC-4f15b8d4e6be1e1fe88ad32aa43595861d1005ad.tar.gz
opensim-SC-4f15b8d4e6be1e1fe88ad32aa43595861d1005ad.tar.bz2
opensim-SC-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/CoreModules/Avatar')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs40
1 files changed, 12 insertions, 28 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}