From 46c6c35d4868e4ff538bdc2c65a7fade936c0ce1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Aug 2010 22:46:49 +0100 Subject: refactor: Push item retrieval and fixing part of Scene.RezObject() down into SceneObjectPartInventory --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 59 ++----------------- .../Framework/Scenes/SceneObjectPartInventory.cs | 66 +++++++++++++++++++++- 2 files changed, 70 insertions(+), 55 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 01be491..9fef8f4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -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)) + SceneObjectGroup group = sourcePart.Inventory.GetRezReadySceneObject(item); + + if (null == group) 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 partList = new List(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; - } - rootPart.TrimPermissions(); + 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) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 4ae53a2..84b7365 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -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 partList = new List(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; + } + /// /// Update an existing inventory item. /// @@ -1029,6 +1092,5 @@ namespace OpenSim.Region.Framework.Scenes } } } - } -} +} \ No newline at end of file -- cgit v1.1