diff options
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 267 |
1 files changed, 133 insertions, 134 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 847d32d..0c6ad0d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -1200,7 +1200,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1200 | "[PRIM INVENTORY]: " + | 1200 | "[PRIM INVENTORY]: " + |
1201 | "Avatar {0} cannot be found to add item", | 1201 | "Avatar {0} cannot be found to add item", |
1202 | avatarId); | 1202 | avatarId); |
1203 | return null; | ||
1203 | } | 1204 | } |
1205 | |||
1204 | if (!profile.HasReceivedInventory) | 1206 | if (!profile.HasReceivedInventory) |
1205 | profile.FetchInventory(); | 1207 | profile.FetchInventory(); |
1206 | 1208 | ||
@@ -1845,173 +1847,170 @@ namespace OpenSim.Region.Framework.Scenes | |||
1845 | userInfo.FetchInventory(); | 1847 | userInfo.FetchInventory(); |
1846 | } | 1848 | } |
1847 | 1849 | ||
1848 | if (userInfo != null) | 1850 | // If we're returning someone's item, it goes back to the |
1849 | { | 1851 | // owner's Lost And Found folder. |
1850 | // If we're returning someone's item, it goes back to the | 1852 | // Delete is treated like return in this case |
1851 | // owner's Lost And Found folder. | 1853 | // Deleting your own items makes them go to trash |
1852 | // Delete is treated like return in this case | 1854 | // |
1853 | // Deleting your own items makes them go to trash | ||
1854 | // | ||
1855 | 1855 | ||
1856 | InventoryFolderBase folder = null; | 1856 | InventoryFolderBase folder = null; |
1857 | InventoryItemBase item = null; | 1857 | InventoryItemBase item = null; |
1858 | 1858 | ||
1859 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | 1859 | if (DeRezAction.SaveToExistingUserInventoryItem == action) |
1860 | { | 1860 | { |
1861 | item = userInfo.RootFolder.FindItem( | 1861 | item = userInfo.RootFolder.FindItem( |
1862 | objectGroup.RootPart.FromUserInventoryItemID); | 1862 | objectGroup.RootPart.FromUserInventoryItemID); |
1863 | 1863 | ||
1864 | if (null == item) | 1864 | if (null == item) |
1865 | { | 1865 | { |
1866 | m_log.DebugFormat( | 1866 | m_log.DebugFormat( |
1867 | "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", | 1867 | "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", |
1868 | objectGroup.Name, objectGroup.UUID); | 1868 | objectGroup.Name, objectGroup.UUID); |
1869 | return UUID.Zero; | 1869 | return UUID.Zero; |
1870 | } | ||
1871 | } | 1870 | } |
1872 | else | 1871 | } |
1872 | else | ||
1873 | { | ||
1874 | // Folder magic | ||
1875 | // | ||
1876 | if (action == DeRezAction.Delete) | ||
1873 | { | 1877 | { |
1874 | // Folder magic | 1878 | // Deleting someone else's item |
1875 | // | 1879 | // |
1876 | if (action == DeRezAction.Delete) | 1880 | if (remoteClient == null || |
1881 | objectGroup.OwnerID != remoteClient.AgentId) | ||
1877 | { | 1882 | { |
1878 | // Deleting someone else's item | 1883 | // Folder skeleton may not be loaded and we |
1879 | // | 1884 | // have to wait for the inventory to find |
1880 | if (remoteClient == null || | 1885 | // the destination folder |
1881 | objectGroup.OwnerID != remoteClient.AgentId) | ||
1882 | { | ||
1883 | // Folder skeleton may not be loaded and we | ||
1884 | // have to wait for the inventory to find | ||
1885 | // the destination folder | ||
1886 | // | ||
1887 | if (!WaitForInventory(userInfo)) | ||
1888 | return UUID.Zero; | ||
1889 | folder = userInfo.FindFolderForType( | ||
1890 | (int)AssetType.LostAndFoundFolder); | ||
1891 | } | ||
1892 | else | ||
1893 | { | ||
1894 | // Assume inventory skeleton was loaded during login | ||
1895 | // and all folders can be found | ||
1896 | // | ||
1897 | folder = userInfo.FindFolderForType( | ||
1898 | (int)AssetType.TrashFolder); | ||
1899 | } | ||
1900 | } | ||
1901 | else if (action == DeRezAction.Return) | ||
1902 | { | ||
1903 | // Wait if needed | ||
1904 | // | ||
1905 | if (!userInfo.HasReceivedInventory) | ||
1906 | { | ||
1907 | if (!WaitForInventory(userInfo)) | ||
1908 | return UUID.Zero; | ||
1909 | } | ||
1910 | |||
1911 | // Dump to lost + found unconditionally | ||
1912 | // | 1886 | // |
1887 | if (!WaitForInventory(userInfo)) | ||
1888 | return UUID.Zero; | ||
1913 | folder = userInfo.FindFolderForType( | 1889 | folder = userInfo.FindFolderForType( |
1914 | (int)AssetType.LostAndFoundFolder); | 1890 | (int)AssetType.LostAndFoundFolder); |
1915 | } | 1891 | } |
1916 | 1892 | else | |
1917 | if (folderID == UUID.Zero && folder == null) | ||
1918 | { | 1893 | { |
1919 | // Catch all. Use lost & found | 1894 | // Assume inventory skeleton was loaded during login |
1895 | // and all folders can be found | ||
1920 | // | 1896 | // |
1921 | if (!userInfo.HasReceivedInventory) | ||
1922 | { | ||
1923 | if (!WaitForInventory(userInfo)) | ||
1924 | return UUID.Zero; | ||
1925 | } | ||
1926 | |||
1927 | folder = userInfo.FindFolderForType( | 1897 | folder = userInfo.FindFolderForType( |
1928 | (int)AssetType.LostAndFoundFolder); | 1898 | (int)AssetType.TrashFolder); |
1929 | } | 1899 | } |
1930 | 1900 | } | |
1931 | if (folder == null) // None of the above | 1901 | else if (action == DeRezAction.Return) |
1902 | { | ||
1903 | // Wait if needed | ||
1904 | // | ||
1905 | if (!userInfo.HasReceivedInventory) | ||
1932 | { | 1906 | { |
1933 | folder = userInfo.RootFolder.FindFolder(folderID); | 1907 | if (!WaitForInventory(userInfo)) |
1908 | return UUID.Zero; | ||
1909 | } | ||
1934 | 1910 | ||
1935 | if (folder == null) // Nowhere to put it | 1911 | // Dump to lost + found unconditionally |
1936 | { | 1912 | // |
1913 | folder = userInfo.FindFolderForType( | ||
1914 | (int)AssetType.LostAndFoundFolder); | ||
1915 | } | ||
1916 | |||
1917 | if (folderID == UUID.Zero && folder == null) | ||
1918 | { | ||
1919 | // Catch all. Use lost & found | ||
1920 | // | ||
1921 | if (!userInfo.HasReceivedInventory) | ||
1922 | { | ||
1923 | if (!WaitForInventory(userInfo)) | ||
1937 | return UUID.Zero; | 1924 | return UUID.Zero; |
1938 | } | ||
1939 | } | 1925 | } |
1940 | 1926 | ||
1941 | item = new InventoryItemBase(); | 1927 | folder = userInfo.FindFolderForType( |
1942 | item.Creator = objectGroup.RootPart.CreatorID; | 1928 | (int)AssetType.LostAndFoundFolder); |
1943 | item.ID = UUID.Random(); | 1929 | } |
1944 | item.InvType = (int)InventoryType.Object; | 1930 | |
1945 | item.Folder = folder.ID; | 1931 | if (folder == null) // None of the above |
1946 | item.Owner = userInfo.UserProfile.ID; | 1932 | { |
1933 | folder = userInfo.RootFolder.FindFolder(folderID); | ||
1947 | 1934 | ||
1935 | if (folder == null) // Nowhere to put it | ||
1936 | { | ||
1937 | return UUID.Zero; | ||
1938 | } | ||
1948 | } | 1939 | } |
1949 | 1940 | ||
1950 | AssetBase asset = CreateAsset( | 1941 | item = new InventoryItemBase(); |
1951 | objectGroup.GetPartName(objectGroup.RootPart.LocalId), | 1942 | item.Creator = objectGroup.RootPart.CreatorID; |
1952 | objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), | 1943 | item.ID = UUID.Random(); |
1953 | (sbyte)AssetType.Object, | 1944 | item.InvType = (int)InventoryType.Object; |
1954 | Utils.StringToBytes(sceneObjectXml)); | 1945 | item.Folder = folder.ID; |
1955 | AssetCache.AddAsset(asset); | 1946 | item.Owner = userInfo.UserProfile.ID; |
1956 | assetID = asset.Metadata.FullID; | 1947 | |
1948 | } | ||
1949 | |||
1950 | AssetBase asset = CreateAsset( | ||
1951 | objectGroup.GetPartName(objectGroup.RootPart.LocalId), | ||
1952 | objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), | ||
1953 | (sbyte)AssetType.Object, | ||
1954 | Utils.StringToBytes(sceneObjectXml)); | ||
1955 | AssetCache.AddAsset(asset); | ||
1956 | assetID = asset.Metadata.FullID; | ||
1957 | 1957 | ||
1958 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | 1958 | if (DeRezAction.SaveToExistingUserInventoryItem == action) |
1959 | { | ||
1960 | item.AssetID = asset.Metadata.FullID; | ||
1961 | userInfo.UpdateItem(item); | ||
1962 | } | ||
1963 | else | ||
1964 | { | ||
1965 | item.AssetID = asset.Metadata.FullID; | ||
1966 | |||
1967 | if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
1959 | { | 1968 | { |
1960 | item.AssetID = asset.Metadata.FullID; | 1969 | uint perms=objectGroup.GetEffectivePermissions(); |
1961 | userInfo.UpdateItem(item); | 1970 | uint nextPerms=(perms & 7) << 13; |
1971 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
1972 | perms &= ~(uint)PermissionMask.Copy; | ||
1973 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
1974 | perms &= ~(uint)PermissionMask.Transfer; | ||
1975 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
1976 | perms &= ~(uint)PermissionMask.Modify; | ||
1977 | |||
1978 | item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; | ||
1979 | item.CurrentPermissions = item.BasePermissions; | ||
1980 | item.NextPermissions = objectGroup.RootPart.NextOwnerMask; | ||
1981 | item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; | ||
1982 | item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask; | ||
1983 | item.CurrentPermissions |= 8; // Slam! | ||
1962 | } | 1984 | } |
1963 | else | 1985 | else |
1964 | { | 1986 | { |
1965 | item.AssetID = asset.Metadata.FullID; | 1987 | item.BasePermissions = objectGroup.GetEffectivePermissions(); |
1966 | 1988 | item.CurrentPermissions = objectGroup.GetEffectivePermissions(); | |
1967 | if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions()) | 1989 | item.NextPermissions = objectGroup.RootPart.NextOwnerMask; |
1968 | { | 1990 | item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; |
1969 | uint perms=objectGroup.GetEffectivePermissions(); | 1991 | item.GroupPermissions = objectGroup.RootPart.GroupMask; |
1970 | uint nextPerms=(perms & 7) << 13; | ||
1971 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
1972 | perms &= ~(uint)PermissionMask.Copy; | ||
1973 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
1974 | perms &= ~(uint)PermissionMask.Transfer; | ||
1975 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
1976 | perms &= ~(uint)PermissionMask.Modify; | ||
1977 | |||
1978 | item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; | ||
1979 | item.CurrentPermissions = item.BasePermissions; | ||
1980 | item.NextPermissions = objectGroup.RootPart.NextOwnerMask; | ||
1981 | item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; | ||
1982 | item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask; | ||
1983 | item.CurrentPermissions |= 8; // Slam! | ||
1984 | } | ||
1985 | else | ||
1986 | { | ||
1987 | item.BasePermissions = objectGroup.GetEffectivePermissions(); | ||
1988 | item.CurrentPermissions = objectGroup.GetEffectivePermissions(); | ||
1989 | item.NextPermissions = objectGroup.RootPart.NextOwnerMask; | ||
1990 | item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; | ||
1991 | item.GroupPermissions = objectGroup.RootPart.GroupMask; | ||
1992 | 1992 | ||
1993 | item.CurrentPermissions |= 8; // Slam! | 1993 | item.CurrentPermissions |= 8; // Slam! |
1994 | } | 1994 | } |
1995 | 1995 | ||
1996 | // TODO: add the new fields (Flags, Sale info, etc) | 1996 | // TODO: add the new fields (Flags, Sale info, etc) |
1997 | item.CreationDate = Util.UnixTimeSinceEpoch(); | 1997 | item.CreationDate = Util.UnixTimeSinceEpoch(); |
1998 | item.Description = asset.Metadata.Description; | 1998 | item.Description = asset.Metadata.Description; |
1999 | item.Name = asset.Metadata.Name; | 1999 | item.Name = asset.Metadata.Name; |
2000 | item.AssetType = asset.Metadata.Type; | 2000 | item.AssetType = asset.Metadata.Type; |
2001 | 2001 | ||
2002 | userInfo.AddItem(item); | 2002 | userInfo.AddItem(item); |
2003 | 2003 | ||
2004 | if (remoteClient != null && item.Owner == remoteClient.AgentId) | 2004 | if (remoteClient != null && item.Owner == remoteClient.AgentId) |
2005 | { | 2005 | { |
2006 | remoteClient.SendInventoryItemCreateUpdate(item); | 2006 | remoteClient.SendInventoryItemCreateUpdate(item); |
2007 | } | 2007 | } |
2008 | else | 2008 | else |
2009 | { | ||
2010 | ScenePresence notifyUser = GetScenePresence(item.Owner); | ||
2011 | if (notifyUser != null) | ||
2009 | { | 2012 | { |
2010 | ScenePresence notifyUser = GetScenePresence(item.Owner); | 2013 | notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item); |
2011 | if (notifyUser != null) | ||
2012 | { | ||
2013 | notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item); | ||
2014 | } | ||
2015 | } | 2014 | } |
2016 | } | 2015 | } |
2017 | } | 2016 | } |