refactor: Push item retrieval and fixing part of Scene.RezObject() down into SceneObjectPartInventory
parent
a2113ecc71
commit
46c6c35d48
|
@ -29,6 +29,7 @@ using System.Collections.Generic;
|
|||
using System.Collections;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
|
@ -153,6 +154,17 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// If no inventory item has that name then an empty list is returned.
|
||||
/// </returns>
|
||||
IList<TaskInventoryItem> GetInventoryItems(string name);
|
||||
|
||||
/// <summary>
|
||||
/// Get the scene object referenced by an inventory item.
|
||||
/// </summary>
|
||||
///
|
||||
/// This is returned in a 'rez ready' state. That is, name, description, permissions and other details have
|
||||
/// been adjusted to reflect the part and item from which it originates.
|
||||
///
|
||||
/// <param name="item"></param>
|
||||
/// <returns>The scene object. Null if the scene object asset couldn't be found</returns>
|
||||
SceneObjectGroup GetRezReadySceneObject(TaskInventoryItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing inventory item.
|
||||
|
|
|
@ -1969,60 +1969,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (null == item)
|
||||
return null;
|
||||
|
||||
UUID ownerID = item.OwnerID;
|
||||
AssetBase rezAsset = AssetService.Get(item.AssetID.ToString());
|
||||
|
||||
if (null == rezAsset)
|
||||
return null;
|
||||
|
||||
string xmlData = Utils.BytesToString(rezAsset.Data);
|
||||
SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
|
||||
|
||||
if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos))
|
||||
return null;
|
||||
|
||||
group.ResetIDs();
|
||||
|
||||
SceneObjectPart rootPart = group.GetChildPart(group.UUID);
|
||||
|
||||
// Since renaming the item in the inventory does not affect the name stored
|
||||
// in the serialization, transfer the correct name from the inventory to the
|
||||
// object itself before we rez.
|
||||
rootPart.Name = item.Name;
|
||||
rootPart.Description = item.Description;
|
||||
|
||||
List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
|
||||
|
||||
group.SetGroup(sourcePart.GroupID, null);
|
||||
|
||||
if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
|
||||
{
|
||||
if (Permissions.PropagatePermissions())
|
||||
{
|
||||
foreach (SceneObjectPart part in partList)
|
||||
{
|
||||
part.EveryoneMask = item.EveryonePermissions;
|
||||
part.NextOwnerMask = item.NextPermissions;
|
||||
}
|
||||
|
||||
group.ApplyNextOwnerPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (SceneObjectPart part in partList)
|
||||
{
|
||||
if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
|
||||
{
|
||||
part.LastOwnerID = part.OwnerID;
|
||||
part.OwnerID = item.OwnerID;
|
||||
part.Inventory.ChangeInventoryOwner(item.OwnerID);
|
||||
}
|
||||
|
||||
part.EveryoneMask = item.EveryonePermissions;
|
||||
part.NextOwnerMask = item.NextPermissions;
|
||||
}
|
||||
SceneObjectGroup group = sourcePart.Inventory.GetRezReadySceneObject(item);
|
||||
|
||||
rootPart.TrimPermissions();
|
||||
if (null == group)
|
||||
return null;
|
||||
|
||||
if (!Permissions.CanRezObject(group.Children.Count, item.OwnerID, pos))
|
||||
return null;
|
||||
|
||||
if (!Permissions.BypassPermissions())
|
||||
{
|
||||
|
@ -2038,7 +1991,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
group.ScheduleGroupForFullUpdate();
|
||||
|
||||
return rootPart.ParentGroup;
|
||||
return group;
|
||||
}
|
||||
|
||||
public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId)
|
||||
|
|
|
@ -37,6 +37,7 @@ using log4net;
|
|||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes.Scripting;
|
||||
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||
|
||||
namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
|
@ -574,6 +575,68 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return items;
|
||||
}
|
||||
|
||||
public SceneObjectGroup GetRezReadySceneObject(TaskInventoryItem item)
|
||||
{
|
||||
UUID ownerID = item.OwnerID;
|
||||
AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
|
||||
|
||||
if (null == rezAsset)
|
||||
{
|
||||
m_log.WarnFormat(
|
||||
"[PRIM INVENTORY]: Could not find asset {0} for inventory item {1} in {2}",
|
||||
item.AssetID, item.Name, m_part.Name);
|
||||
return null;
|
||||
}
|
||||
|
||||
string xmlData = Utils.BytesToString(rezAsset.Data);
|
||||
SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
|
||||
|
||||
group.ResetIDs();
|
||||
|
||||
SceneObjectPart rootPart = group.GetChildPart(group.UUID);
|
||||
|
||||
// Since renaming the item in the inventory does not affect the name stored
|
||||
// in the serialization, transfer the correct name from the inventory to the
|
||||
// object itself before we rez.
|
||||
rootPart.Name = item.Name;
|
||||
rootPart.Description = item.Description;
|
||||
|
||||
List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
|
||||
|
||||
group.SetGroup(m_part.GroupID, null);
|
||||
|
||||
if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
|
||||
{
|
||||
if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions())
|
||||
{
|
||||
foreach (SceneObjectPart part in partList)
|
||||
{
|
||||
part.EveryoneMask = item.EveryonePermissions;
|
||||
part.NextOwnerMask = item.NextPermissions;
|
||||
}
|
||||
|
||||
group.ApplyNextOwnerPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (SceneObjectPart part in partList)
|
||||
{
|
||||
if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
|
||||
{
|
||||
part.LastOwnerID = part.OwnerID;
|
||||
part.OwnerID = item.OwnerID;
|
||||
part.Inventory.ChangeInventoryOwner(item.OwnerID);
|
||||
}
|
||||
|
||||
part.EveryoneMask = item.EveryonePermissions;
|
||||
part.NextOwnerMask = item.NextPermissions;
|
||||
}
|
||||
|
||||
rootPart.TrimPermissions();
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing inventory item.
|
||||
/// </summary>
|
||||
|
@ -1029,6 +1092,5 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue