aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-08-25 22:46:49 +0100
committerJustin Clark-Casey (justincc)2010-08-25 22:46:49 +0100
commit46c6c35d4868e4ff538bdc2c65a7fade936c0ce1 (patch)
tree39dc65383f6294205882bb7e51df5c9a420e053a /OpenSim
parentTypo (diff)
downloadopensim-SC_OLD-46c6c35d4868e4ff538bdc2c65a7fade936c0ce1.zip
opensim-SC_OLD-46c6c35d4868e4ff538bdc2c65a7fade936c0ce1.tar.gz
opensim-SC_OLD-46c6c35d4868e4ff538bdc2c65a7fade936c0ce1.tar.bz2
opensim-SC_OLD-46c6c35d4868e4ff538bdc2c65a7fade936c0ce1.tar.xz
refactor: Push item retrieval and fixing part of Scene.RezObject() down into SceneObjectPartInventory
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs59
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs66
3 files changed, 82 insertions, 55 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index fd43923..ae2e844 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -29,6 +29,7 @@ using System.Collections.Generic;
29using System.Collections; 29using System.Collections;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
32 33
33namespace OpenSim.Region.Framework.Interfaces 34namespace OpenSim.Region.Framework.Interfaces
34{ 35{
@@ -153,6 +154,17 @@ namespace OpenSim.Region.Framework.Interfaces
153 /// If no inventory item has that name then an empty list is returned. 154 /// If no inventory item has that name then an empty list is returned.
154 /// </returns> 155 /// </returns>
155 IList<TaskInventoryItem> GetInventoryItems(string name); 156 IList<TaskInventoryItem> GetInventoryItems(string name);
157
158 /// <summary>
159 /// Get the scene object referenced by an inventory item.
160 /// </summary>
161 ///
162 /// This is returned in a 'rez ready' state. That is, name, description, permissions and other details have
163 /// been adjusted to reflect the part and item from which it originates.
164 ///
165 /// <param name="item"></param>
166 /// <returns>The scene object. Null if the scene object asset couldn't be found</returns>
167 SceneObjectGroup GetRezReadySceneObject(TaskInventoryItem item);
156 168
157 /// <summary> 169 /// <summary>
158 /// Update an existing inventory item. 170 /// Update an existing inventory item.
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
1969 if (null == item) 1969 if (null == item)
1970 return null; 1970 return null;
1971 1971
1972 UUID ownerID = item.OwnerID; 1972 SceneObjectGroup group = sourcePart.Inventory.GetRezReadySceneObject(item);
1973 AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); 1973
1974 1974 if (null == group)
1975 if (null == rezAsset)
1976 return null;
1977
1978 string xmlData = Utils.BytesToString(rezAsset.Data);
1979 SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
1980
1981 if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos))
1982 return null; 1975 return null;
1983
1984 group.ResetIDs();
1985
1986 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
1987
1988 // Since renaming the item in the inventory does not affect the name stored
1989 // in the serialization, transfer the correct name from the inventory to the
1990 // object itself before we rez.
1991 rootPart.Name = item.Name;
1992 rootPart.Description = item.Description;
1993
1994 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
1995
1996 group.SetGroup(sourcePart.GroupID, null);
1997
1998 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
1999 {
2000 if (Permissions.PropagatePermissions())
2001 {
2002 foreach (SceneObjectPart part in partList)
2003 {
2004 part.EveryoneMask = item.EveryonePermissions;
2005 part.NextOwnerMask = item.NextPermissions;
2006 }
2007
2008 group.ApplyNextOwnerPermissions();
2009 }
2010 }
2011
2012 foreach (SceneObjectPart part in partList)
2013 {
2014 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
2015 {
2016 part.LastOwnerID = part.OwnerID;
2017 part.OwnerID = item.OwnerID;
2018 part.Inventory.ChangeInventoryOwner(item.OwnerID);
2019 }
2020
2021 part.EveryoneMask = item.EveryonePermissions;
2022 part.NextOwnerMask = item.NextPermissions;
2023 }
2024 1976
2025 rootPart.TrimPermissions(); 1977 if (!Permissions.CanRezObject(group.Children.Count, item.OwnerID, pos))
1978 return null;
2026 1979
2027 if (!Permissions.BypassPermissions()) 1980 if (!Permissions.BypassPermissions())
2028 { 1981 {
@@ -2038,7 +1991,7 @@ namespace OpenSim.Region.Framework.Scenes
2038 1991
2039 group.ScheduleGroupForFullUpdate(); 1992 group.ScheduleGroupForFullUpdate();
2040 1993
2041 return rootPart.ParentGroup; 1994 return group;
2042 } 1995 }
2043 1996
2044 public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId) 1997 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;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes.Scripting; 39using OpenSim.Region.Framework.Scenes.Scripting;
40using OpenSim.Region.Framework.Scenes.Serialization;
40 41
41namespace OpenSim.Region.Framework.Scenes 42namespace OpenSim.Region.Framework.Scenes
42{ 43{
@@ -574,6 +575,68 @@ namespace OpenSim.Region.Framework.Scenes
574 return items; 575 return items;
575 } 576 }
576 577
578 public SceneObjectGroup GetRezReadySceneObject(TaskInventoryItem item)
579 {
580 UUID ownerID = item.OwnerID;
581 AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
582
583 if (null == rezAsset)
584 {
585 m_log.WarnFormat(
586 "[PRIM INVENTORY]: Could not find asset {0} for inventory item {1} in {2}",
587 item.AssetID, item.Name, m_part.Name);
588 return null;
589 }
590
591 string xmlData = Utils.BytesToString(rezAsset.Data);
592 SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
593
594 group.ResetIDs();
595
596 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
597
598 // Since renaming the item in the inventory does not affect the name stored
599 // in the serialization, transfer the correct name from the inventory to the
600 // object itself before we rez.
601 rootPart.Name = item.Name;
602 rootPart.Description = item.Description;
603
604 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
605
606 group.SetGroup(m_part.GroupID, null);
607
608 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
609 {
610 if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions())
611 {
612 foreach (SceneObjectPart part in partList)
613 {
614 part.EveryoneMask = item.EveryonePermissions;
615 part.NextOwnerMask = item.NextPermissions;
616 }
617
618 group.ApplyNextOwnerPermissions();
619 }
620 }
621
622 foreach (SceneObjectPart part in partList)
623 {
624 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
625 {
626 part.LastOwnerID = part.OwnerID;
627 part.OwnerID = item.OwnerID;
628 part.Inventory.ChangeInventoryOwner(item.OwnerID);
629 }
630
631 part.EveryoneMask = item.EveryonePermissions;
632 part.NextOwnerMask = item.NextPermissions;
633 }
634
635 rootPart.TrimPermissions();
636
637 return group;
638 }
639
577 /// <summary> 640 /// <summary>
578 /// Update an existing inventory item. 641 /// Update an existing inventory item.
579 /// </summary> 642 /// </summary>
@@ -1029,6 +1092,5 @@ namespace OpenSim.Region.Framework.Scenes
1029 } 1092 }
1030 } 1093 }
1031 } 1094 }
1032
1033 } 1095 }
1034} 1096} \ No newline at end of file