From 07d5a0779a8330a56fd6ca6d30918de7c8161f98 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Aug 2010 20:53:25 +0100 Subject: refactor: make RezObject() more readable --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 137 ++++++++++----------- 1 file changed, 68 insertions(+), 69 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index fa9653f..9c62ad3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1951,7 +1951,7 @@ namespace OpenSim.Region.Framework.Scenes remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, RezSelected, RemoveItem, fromTaskID, false); } - + /// /// Rez an object into the scene from a prim's inventory. /// @@ -1966,95 +1966,94 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion rot, Vector3 vel, int param) { - // Rez object - if (item != null) - { - UUID ownerID = item.OwnerID; + if (null == item) + return null; + + UUID ownerID = item.OwnerID; + AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); - AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); + if (null == rezAsset) + return null; - if (rezAsset != null) - { - string xmlData = Utils.BytesToString(rezAsset.Data); - SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); + string xmlData = Utils.BytesToString(rezAsset.Data); + SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); - if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos)) - { - return null; - } - group.ResetIDs(); + if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos)) + return null; - AddNewSceneObject(group, true); + group.ResetIDs(); - // we set it's position in world. - group.AbsolutePosition = pos; + AddNewSceneObject(group, true); - SceneObjectPart rootPart = group.GetChildPart(group.UUID); + // we set it's position in world. + group.AbsolutePosition = pos; - // 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; + SceneObjectPart rootPart = group.GetChildPart(group.UUID); - List partList = new List(group.Children.Values); + // 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; - group.SetGroup(sourcePart.GroupID, null); + List partList = new List(group.Children.Values); - 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(); - } - } + group.SetGroup(sourcePart.GroupID, null); + if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) + { + if (Permissions.PropagatePermissions()) + { 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 (group.RootPart.Shape.PCode == (byte)PCode.Prim) - { - group.ClearPartAttachmentData(); - } - - group.UpdateGroupRotationR(rot); - - //group.ApplyPhysics(m_physicalPrim); - if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) - { - group.RootPart.ApplyImpulse((vel * group.GetMass()), false); - group.Velocity = vel; - rootPart.ScheduleFullUpdate(); - } - group.CreateScriptInstances(param, true, DefaultScriptEngine, 2); - rootPart.ScheduleFullUpdate(); + group.ApplyNextOwnerPermissions(); + } + } - if (!Permissions.BypassPermissions()) - { - if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) - sourcePart.Inventory.RemoveInventoryItem(item.ItemID); - } - return rootPart.ParentGroup; + 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 (group.RootPart.Shape.PCode == (byte)PCode.Prim) + { + group.ClearPartAttachmentData(); + } + + group.UpdateGroupRotationR(rot); + + //group.ApplyPhysics(m_physicalPrim); + if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) + { + group.RootPart.ApplyImpulse((vel * group.GetMass()), false); + group.Velocity = vel; + rootPart.ScheduleFullUpdate(); } + + group.CreateScriptInstances(param, true, DefaultScriptEngine, 2); + rootPart.ScheduleFullUpdate(); - return null; + if (!Permissions.BypassPermissions()) + { + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) + sourcePart.Inventory.RemoveInventoryItem(item.ItemID); + } + + return rootPart.ParentGroup; } public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId) -- cgit v1.1