refactor: Move Scene.Inventory.UpdateKnownItem() into Attachments module since this appears to relate solely to attachments
parent
f3f4428700
commit
2b0f924557
|
@ -37,6 +37,7 @@ using OpenSim.Framework;
|
|||
using OpenSim.Region.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
{
|
||||
|
@ -448,7 +449,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
|
||||
group.DetachToInventoryPrep();
|
||||
m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
|
||||
m_scene.UpdateKnownItem(remoteClient, group,group.GetFromItemID(), group.OwnerID);
|
||||
UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID);
|
||||
m_scene.DeleteSceneObject(group, false);
|
||||
return;
|
||||
}
|
||||
|
@ -471,8 +472,63 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
sog.UpdateGroupPosition(pos);
|
||||
sog.RootPart.IsAttachment = false;
|
||||
sog.AbsolutePosition = sog.RootPart.AttachedPos;
|
||||
m_scene.UpdateKnownItem(client, sog, sog.GetFromItemID(), sog.OwnerID);
|
||||
UpdateKnownItem(client, sog, sog.GetFromItemID(), sog.OwnerID);
|
||||
sog.SetAttachmentPoint(attachmentPoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the attachment asset for the new sog details if they have changed.
|
||||
/// </summary>
|
||||
///
|
||||
/// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects,
|
||||
/// these details are not stored on the region.
|
||||
///
|
||||
/// <param name="remoteClient"></param>
|
||||
/// <param name="grp"></param>
|
||||
/// <param name="itemID"></param>
|
||||
/// <param name="agentID"></param>
|
||||
protected void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
|
||||
{
|
||||
if (grp != null)
|
||||
{
|
||||
if (!grp.HasGroupChanged)
|
||||
{
|
||||
m_log.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID);
|
||||
return;
|
||||
}
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
|
||||
grp.UUID, grp.GetAttachmentPoint());
|
||||
|
||||
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
|
||||
|
||||
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
|
||||
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),
|
||||
remoteClient.AgentId);
|
||||
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 (remoteClient != null)
|
||||
remoteClient.SendInventoryItemCreateUpdate(item, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1799,53 +1799,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
|
||||
{
|
||||
SceneObjectGroup objectGroup = grp;
|
||||
if (objectGroup != null)
|
||||
{
|
||||
if (!grp.HasGroupChanged)
|
||||
{
|
||||
m_log.InfoFormat("[ATTACHMENT]: Save request for {0} which is unchanged", grp.UUID);
|
||||
return;
|
||||
}
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[ATTACHMENT]: Updating asset for attachment {0}, attachpoint {1}",
|
||||
grp.UUID, grp.GetAttachmentPoint());
|
||||
|
||||
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
|
||||
|
||||
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
|
||||
item = InventoryService.GetItem(item);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
AssetBase asset = CreateAsset(
|
||||
objectGroup.GetPartName(objectGroup.LocalId),
|
||||
objectGroup.GetPartDescription(objectGroup.LocalId),
|
||||
(sbyte)AssetType.Object,
|
||||
Utils.StringToBytes(sceneObjectXml),
|
||||
remoteClient.AgentId);
|
||||
AssetService.Store(asset);
|
||||
|
||||
item.AssetID = asset.FullID;
|
||||
item.Description = asset.Description;
|
||||
item.Name = asset.Name;
|
||||
item.AssetType = asset.Type;
|
||||
item.InvType = (int)InventoryType.Object;
|
||||
|
||||
InventoryService.UpdateItem(item);
|
||||
|
||||
// this gets called when the agent loggs off!
|
||||
if (remoteClient != null)
|
||||
{
|
||||
remoteClient.SendInventoryItemCreateUpdate(item, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
|
||||
{
|
||||
itemID = UUID.Zero;
|
||||
|
|
Loading…
Reference in New Issue