aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-24 21:23:10 +0100
committerJustin Clark-Casey (justincc)2011-08-24 21:23:10 +0100
commit274e354006a7a8426ebf339c333f1d4994231eed (patch)
tree747097100662f4bfe98f93460860fc12e367a2eb /OpenSim/Region
parentminor: remove hardcoded region numbers with the region size constant and a cu... (diff)
downloadopensim-SC-274e354006a7a8426ebf339c333f1d4994231eed.zip
opensim-SC-274e354006a7a8426ebf339c333f1d4994231eed.tar.gz
opensim-SC-274e354006a7a8426ebf339c333f1d4994231eed.tar.bz2
opensim-SC-274e354006a7a8426ebf339c333f1d4994231eed.tar.xz
get rid of pointless grp null check in attachObjectAssetStore()
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs142
1 files changed, 69 insertions, 73 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 3e87578..ac73abd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1876,87 +1876,83 @@ namespace OpenSim.Region.Framework.Scenes
1876// m_log.DebugFormat("[SCENE]: Called attachObjectAssetStore for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); 1876// m_log.DebugFormat("[SCENE]: Called attachObjectAssetStore for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
1877 1877
1878 itemID = UUID.Zero; 1878 itemID = UUID.Zero;
1879 if (grp != null)
1880 {
1881 Vector3 inventoryStoredPosition = new Vector3
1882 (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
1883 ? Constants.RegionSize - 6
1884 : grp.AbsolutePosition.X)
1885 ,
1886 (grp.AbsolutePosition.Y > (int)Constants.RegionSize)
1887 ? Constants.RegionSize - 6
1888 : grp.AbsolutePosition.Y,
1889 grp.AbsolutePosition.Z);
1890
1891 Vector3 originalPosition = grp.AbsolutePosition;
1892
1893 grp.AbsolutePosition = inventoryStoredPosition;
1894
1895 // If we're being called from a script, then trying to serialize that same script's state will not complete
1896 // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
1897 // the client/server crashes rather than logging out normally, the attachment's scripts will resume
1898 // without state on relog. Arguably, this is what we want anyway.
1899 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false);
1900
1901 grp.AbsolutePosition = originalPosition;
1902
1903 AssetBase asset = CreateAsset(
1904 grp.GetPartName(grp.LocalId),
1905 grp.GetPartDescription(grp.LocalId),
1906 (sbyte)AssetType.Object,
1907 Utils.StringToBytes(sceneObjectXml),
1908 remoteClient.AgentId);
1909 1879
1910 AssetService.Store(asset); 1880 Vector3 inventoryStoredPosition = new Vector3
1881 (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
1882 ? Constants.RegionSize - 6
1883 : grp.AbsolutePosition.X)
1884 ,
1885 (grp.AbsolutePosition.Y > (int)Constants.RegionSize)
1886 ? Constants.RegionSize - 6
1887 : grp.AbsolutePosition.Y,
1888 grp.AbsolutePosition.Z);
1911 1889
1912 InventoryItemBase item = new InventoryItemBase(); 1890 Vector3 originalPosition = grp.AbsolutePosition;
1913 item.CreatorId = grp.RootPart.CreatorID.ToString();
1914 item.CreatorData = grp.RootPart.CreatorData;
1915 item.Owner = remoteClient.AgentId;
1916 item.ID = UUID.Random();
1917 item.AssetID = asset.FullID;
1918 item.Description = asset.Description;
1919 item.Name = asset.Name;
1920 item.AssetType = asset.Type;
1921 item.InvType = (int)InventoryType.Object;
1922
1923 InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
1924 if (folder != null)
1925 item.Folder = folder.ID;
1926 else // oopsies
1927 item.Folder = UUID.Zero;
1928 1891
1929 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) 1892 grp.AbsolutePosition = inventoryStoredPosition;
1930 {
1931 item.BasePermissions = grp.RootPart.NextOwnerMask;
1932 item.CurrentPermissions = grp.RootPart.NextOwnerMask;
1933 item.NextPermissions = grp.RootPart.NextOwnerMask;
1934 item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
1935 item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
1936 }
1937 else
1938 {
1939 item.BasePermissions = grp.RootPart.BaseMask;
1940 item.CurrentPermissions = grp.RootPart.OwnerMask;
1941 item.NextPermissions = grp.RootPart.NextOwnerMask;
1942 item.EveryOnePermissions = grp.RootPart.EveryoneMask;
1943 item.GroupPermissions = grp.RootPart.GroupMask;
1944 }
1945 item.CreationDate = Util.UnixTimeSinceEpoch();
1946 1893
1947 // sets itemID so client can show item as 'attached' in inventory 1894 // If we're being called from a script, then trying to serialize that same script's state will not complete
1948 grp.SetFromItemID(item.ID); 1895 // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
1896 // the client/server crashes rather than logging out normally, the attachment's scripts will resume
1897 // without state on relog. Arguably, this is what we want anyway.
1898 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false);
1949 1899
1950 if (AddInventoryItem(item)) 1900 grp.AbsolutePosition = originalPosition;
1951 remoteClient.SendInventoryItemCreateUpdate(item, 0); 1901
1952 else 1902 AssetBase asset = CreateAsset(
1953 m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); 1903 grp.GetPartName(grp.LocalId),
1904 grp.GetPartDescription(grp.LocalId),
1905 (sbyte)AssetType.Object,
1906 Utils.StringToBytes(sceneObjectXml),
1907 remoteClient.AgentId);
1908
1909 AssetService.Store(asset);
1954 1910
1955 itemID = item.ID; 1911 InventoryItemBase item = new InventoryItemBase();
1956 return item.AssetID; 1912 item.CreatorId = grp.RootPart.CreatorID.ToString();
1913 item.CreatorData = grp.RootPart.CreatorData;
1914 item.Owner = remoteClient.AgentId;
1915 item.ID = UUID.Random();
1916 item.AssetID = asset.FullID;
1917 item.Description = asset.Description;
1918 item.Name = asset.Name;
1919 item.AssetType = asset.Type;
1920 item.InvType = (int)InventoryType.Object;
1921
1922 InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
1923 if (folder != null)
1924 item.Folder = folder.ID;
1925 else // oopsies
1926 item.Folder = UUID.Zero;
1927
1928 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
1929 {
1930 item.BasePermissions = grp.RootPart.NextOwnerMask;
1931 item.CurrentPermissions = grp.RootPart.NextOwnerMask;
1932 item.NextPermissions = grp.RootPart.NextOwnerMask;
1933 item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
1934 item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
1935 }
1936 else
1937 {
1938 item.BasePermissions = grp.RootPart.BaseMask;
1939 item.CurrentPermissions = grp.RootPart.OwnerMask;
1940 item.NextPermissions = grp.RootPart.NextOwnerMask;
1941 item.EveryOnePermissions = grp.RootPart.EveryoneMask;
1942 item.GroupPermissions = grp.RootPart.GroupMask;
1957 } 1943 }
1944 item.CreationDate = Util.UnixTimeSinceEpoch();
1958 1945
1959 return UUID.Zero; 1946 // sets itemID so client can show item as 'attached' in inventory
1947 grp.SetFromItemID(item.ID);
1948
1949 if (AddInventoryItem(item))
1950 remoteClient.SendInventoryItemCreateUpdate(item, 0);
1951 else
1952 m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
1953
1954 itemID = item.ID;
1955 return item.AssetID;
1960 } 1956 }
1961 1957
1962 /// <summary> 1958 /// <summary>