diff options
author | Justin Clark-Casey (justincc) | 2010-08-26 22:09:52 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-08-26 22:09:52 +0100 |
commit | 2b0f924557575777511432e5d72d21297a8002fd (patch) | |
tree | 1c36dcf3c28470adbc8cbe9277f07848aeff31d4 /OpenSim/Region/CoreModules/Avatar/Attachments | |
parent | refactor: break out attachment position change code in Scene.UpdatePrimPositi... (diff) | |
download | opensim-SC_OLD-2b0f924557575777511432e5d72d21297a8002fd.zip opensim-SC_OLD-2b0f924557575777511432e5d72d21297a8002fd.tar.gz opensim-SC_OLD-2b0f924557575777511432e5d72d21297a8002fd.tar.bz2 opensim-SC_OLD-2b0f924557575777511432e5d72d21297a8002fd.tar.xz |
refactor: Move Scene.Inventory.UpdateKnownItem() into Attachments module since this appears to relate solely to attachments
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index b3811bf..d56145a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -37,6 +37,7 @@ using OpenSim.Framework; | |||
37 | using OpenSim.Region.Framework; | 37 | using OpenSim.Region.Framework; |
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
40 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
40 | 41 | ||
41 | namespace OpenSim.Region.CoreModules.Avatar.Attachments | 42 | namespace OpenSim.Region.CoreModules.Avatar.Attachments |
42 | { | 43 | { |
@@ -448,7 +449,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
448 | m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); | 449 | m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); |
449 | group.DetachToInventoryPrep(); | 450 | group.DetachToInventoryPrep(); |
450 | m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); | 451 | m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); |
451 | m_scene.UpdateKnownItem(remoteClient, group,group.GetFromItemID(), group.OwnerID); | 452 | UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID); |
452 | m_scene.DeleteSceneObject(group, false); | 453 | m_scene.DeleteSceneObject(group, false); |
453 | return; | 454 | return; |
454 | } | 455 | } |
@@ -471,8 +472,63 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
471 | sog.UpdateGroupPosition(pos); | 472 | sog.UpdateGroupPosition(pos); |
472 | sog.RootPart.IsAttachment = false; | 473 | sog.RootPart.IsAttachment = false; |
473 | sog.AbsolutePosition = sog.RootPart.AttachedPos; | 474 | sog.AbsolutePosition = sog.RootPart.AttachedPos; |
474 | m_scene.UpdateKnownItem(client, sog, sog.GetFromItemID(), sog.OwnerID); | 475 | UpdateKnownItem(client, sog, sog.GetFromItemID(), sog.OwnerID); |
475 | sog.SetAttachmentPoint(attachmentPoint); | 476 | sog.SetAttachmentPoint(attachmentPoint); |
476 | } | 477 | } |
478 | |||
479 | /// <summary> | ||
480 | /// Update the attachment asset for the new sog details if they have changed. | ||
481 | /// </summary> | ||
482 | /// | ||
483 | /// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects, | ||
484 | /// these details are not stored on the region. | ||
485 | /// | ||
486 | /// <param name="remoteClient"></param> | ||
487 | /// <param name="grp"></param> | ||
488 | /// <param name="itemID"></param> | ||
489 | /// <param name="agentID"></param> | ||
490 | protected void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) | ||
491 | { | ||
492 | if (grp != null) | ||
493 | { | ||
494 | if (!grp.HasGroupChanged) | ||
495 | { | ||
496 | m_log.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID); | ||
497 | return; | ||
498 | } | ||
499 | |||
500 | m_log.DebugFormat( | ||
501 | "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", | ||
502 | grp.UUID, grp.GetAttachmentPoint()); | ||
503 | |||
504 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | ||
505 | |||
506 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
507 | item = m_scene.InventoryService.GetItem(item); | ||
508 | |||
509 | if (item != null) | ||
510 | { | ||
511 | AssetBase asset = m_scene.CreateAsset( | ||
512 | grp.GetPartName(grp.LocalId), | ||
513 | grp.GetPartDescription(grp.LocalId), | ||
514 | (sbyte)AssetType.Object, | ||
515 | Utils.StringToBytes(sceneObjectXml), | ||
516 | remoteClient.AgentId); | ||
517 | m_scene.AssetService.Store(asset); | ||
518 | |||
519 | item.AssetID = asset.FullID; | ||
520 | item.Description = asset.Description; | ||
521 | item.Name = asset.Name; | ||
522 | item.AssetType = asset.Type; | ||
523 | item.InvType = (int)InventoryType.Object; | ||
524 | |||
525 | m_scene.InventoryService.UpdateItem(item); | ||
526 | |||
527 | // this gets called when the agent logs off! | ||
528 | if (remoteClient != null) | ||
529 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
530 | } | ||
531 | } | ||
532 | } | ||
477 | } | 533 | } |
478 | } \ No newline at end of file | 534 | } \ No newline at end of file |