From d5b48ecbe145bee3b40797f19e770530c47a2f14 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 24 Aug 2008 07:16:47 +0000 Subject: [PATCH] Selling a copy of a prim (prim vendor) now works. Sack of bolts to go with the nuts? --- OpenSim/Region/Environment/Scenes/Scene.cs | 65 +++++++++++++++++++--- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 01a0fc8a93..0052dd3f6f 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -3953,18 +3953,20 @@ namespace OpenSim.Region.Environment.Scenes if(part == null) return; + if(part.ParentGroup == null) + return; + + SceneObjectGroup group = part.ParentGroup; + switch (saleType) { case 1: // Sell as original (in-place sale) - if(part.ParentGroup == null) - return; - - part.ParentGroup.SetOwnerId(remoteClient.AgentId); - part.ParentGroup.SetRootPartOwner(part, remoteClient.AgentId, + group.SetOwnerId(remoteClient.AgentId); + group.SetRootPartOwner(part, remoteClient.AgentId, remoteClient.ActiveGroupId); List partList = - new List(part.ParentGroup.Children.Values); + new List(group.Children.Values); if (ExternalChecks.ExternalChecksPropagatePermissions()) { @@ -3980,11 +3982,60 @@ namespace OpenSim.Region.Environment.Scenes part.ObjectSaleType = 0; part.SalePrice = 10; - part.ParentGroup.HasGroupChanged = true; + group.HasGroupChanged = true; part.GetProperties(remoteClient); part.ScheduleFullUpdate(); break; + + case 2: // Sell a copy + string sceneObjectXml = group.ToXmlString(); + + CachedUserInfo userInfo = + CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); + + if (userInfo != null) + { + AssetBase asset = CreateAsset( + group.GetPartName(localID), + group.GetPartDescription(localID), + (sbyte)AssetType.Object, + Helpers.StringToField(sceneObjectXml)); + AssetCache.AddAsset(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.Creator = part.CreatorID; + + item.ID = LLUUID.Random(); + item.Owner = remoteClient.AgentId; + item.AssetID = asset.FullID; + item.Description = asset.Description; + item.Name = asset.Name; + item.AssetType = asset.Type; + item.InvType = (int)InventoryType.Object; + item.Folder = categoryID; + + uint perms=group.GetEffectivePermissions(); + uint nextPerms=(perms & 7) << 13; + if ((nextPerms & (uint)PermissionMask.Copy) == 0) + perms &= ~(uint)PermissionMask.Copy; + if ((nextPerms & (uint)PermissionMask.Transfer) == 0) + perms &= ~(uint)PermissionMask.Transfer; + if ((nextPerms & (uint)PermissionMask.Modify) == 0) + perms &= ~(uint)PermissionMask.Modify; + + item.BasePermissions = perms & part.NextOwnerMask; + item.CurrentPermissions = perms & part.NextOwnerMask; + item.NextPermissions = part.NextOwnerMask; + item.EveryOnePermissions = part.EveryoneMask & + part.NextOwnerMask; + item.CurrentPermissions |= 8; // Slam! + item.CreationDate = Util.UnixTimeSinceEpoch(); + + userInfo.AddItem(item); + remoteClient.SendInventoryItemCreateUpdate(item); + } + break; } } }