/// <summary> /// Update the attachment asset for the new sog details if they have changed. /// </summary> /// <remarks> /// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects, /// these details are not stored on the region. /// </remarks> /// <param name="sp"></param> /// <param name="grp"></param> private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, bool saveAllScripted) { // Saving attachments for NPCs messes them up for the real owner! INPCModule module = m_scene.RequestModuleInterface <INPCModule>(); if (module != null) { if (module.IsNPC(sp.UUID, m_scene)) { return; } } if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts())) { m_log.DebugFormat( "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", grp.UUID, grp.AttachmentPoint); string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); InventoryItemBase item = new InventoryItemBase(grp.GetFromItemID(), sp.UUID); item = m_scene.InventoryService.GetItem(item); if (item != null) { AssetBase asset = m_scene.CreateAsset( grp.GetPartName(grp.LocalId), grp.GetPartDescription(grp.LocalId), (sbyte)AssetType.Object, Utils.StringToBytes(sceneObjectXml), sp.UUID); m_scene.AssetService.Store(asset); item.AssetID = asset.FullID; item.Description = asset.Description; item.Name = asset.Name; item.AssetType = asset.Type; item.InvType = (int)InventoryType.Object; m_scene.InventoryService.UpdateItem(item); // this gets called when the agent logs off! if (sp.ControllingClient != null) { sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0); } } grp.HasGroupChanged = false; // Prevent it being saved over and over } else { m_log.DebugFormat( "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", grp.UUID, grp.AttachmentPoint); } }
/// <summary> /// Update the attachment asset for the new sog details if they have changed. /// </summary> /// <remarks> /// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects, /// these details are not stored on the region. /// </remarks> /// <param name="sp"></param> /// <param name="grp"></param> /// <param name="saveAllScripted"></param> private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, string scriptedState) { if (grp.FromItemID == UUID.Zero) { // We can't save temp attachments grp.HasGroupChanged = false; return; } // Saving attachments for NPCs messes them up for the real owner! INPCModule module = m_scene.RequestModuleInterface <INPCModule>(); if (module != null) { if (module.IsNPC(sp.UUID, m_scene)) { return; } } if (grp.HasGroupChanged) { m_log.DebugFormat( "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", grp.UUID, grp.AttachmentPoint); string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, scriptedState); InventoryItemBase item = new InventoryItemBase(grp.FromItemID, sp.UUID); item = m_scene.InventoryService.GetItem(item); if (item != null) { AssetBase asset = m_scene.CreateAsset( grp.GetPartName(grp.LocalId), grp.GetPartDescription(grp.LocalId), (sbyte)AssetType.Object, Utils.StringToBytes(sceneObjectXml), sp.UUID); m_scene.AssetService.Store(asset); item.AssetID = asset.FullID; item.Description = asset.Description; item.Name = asset.Name; item.AssetType = asset.Type; item.InvType = (int)InventoryType.Object; m_scene.InventoryService.UpdateItem(item); // If the name of the object has been changed whilst attached then we want to update the inventory // item in the viewer. if (sp.ControllingClient != null) { sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0); } } grp.HasGroupChanged = false; // Prevent it being saved over and over } // else // { // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", // grp.UUID, grp.AttachmentPoint); // } }