don't sell objects not for sale

This commit is contained in:
UbitUmarov
2020-08-01 18:07:58 +01:00
parent fab0748a54
commit cda415b8df
2 changed files with 127 additions and 124 deletions

View File

@@ -124,154 +124,157 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
// make sure we are not buying a child part
rootpart = group.RootPart;
switch (saleType)
switch ((SaleType)saleType)
{
case 1: // Sell as original (in-place sale)
uint effectivePerms = group.EffectiveOwnerPerms;
case SaleType.Original: // Sell as original (in-place sale)
uint effectivePerms = group.EffectiveOwnerPerms;
if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
{
if (m_dialogModule != null)
m_dialogModule.SendAlertToUser(remoteClient, "This item doesn't appear to be for sale");
return false;
}
group.SetOwner(remoteClient.AgentId, remoteClient.ActiveGroupId);
if (m_scene.Permissions.PropagatePermissions())
{
foreach (SceneObjectPart child in group.Parts)
if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
{
child.Inventory.ChangeInventoryOwner(remoteClient.AgentId);
child.TriggerScriptChangedEvent(Changed.OWNER);
child.ApplyNextOwnerPermissions();
if (m_dialogModule != null)
m_dialogModule.SendAlertToUser(remoteClient, "This item doesn't appear to be for sale");
return false;
}
group.InvalidateDeepEffectivePerms();
}
rootpart.ObjectSaleType = 0;
rootpart.SalePrice = 10;
rootpart.ClickAction = 0;
group.SetOwner(remoteClient.AgentId, remoteClient.ActiveGroupId);
group.HasGroupChanged = true;
rootpart.SendPropertiesToClient(remoteClient);
rootpart.TriggerScriptChangedEvent(Changed.OWNER);
group.ResumeScripts();
rootpart.ScheduleFullUpdate();
if (m_scene.Permissions.PropagatePermissions())
{
foreach (SceneObjectPart child in group.Parts)
{
child.Inventory.ChangeInventoryOwner(remoteClient.AgentId);
child.TriggerScriptChangedEvent(Changed.OWNER);
child.ApplyNextOwnerPermissions();
}
group.InvalidateDeepEffectivePerms();
}
break;
rootpart.ObjectSaleType = 0;
rootpart.SalePrice = 10;
rootpart.ClickAction = 0;
case 2: // Sell a copy
uint perms = group.EffectiveOwnerPerms;
group.HasGroupChanged = true;
rootpart.SendPropertiesToClient(remoteClient);
rootpart.TriggerScriptChangedEvent(Changed.OWNER);
group.ResumeScripts();
rootpart.ScheduleFullUpdate();
if ((perms & (uint)PermissionMask.Transfer) == 0)
{
if (m_dialogModule != null)
m_dialogModule.SendAlertToUser(remoteClient, "This item doesn't appear to be for sale");
return false;
}
break;
if ((perms & (uint)PermissionMask.Copy) == 0)
{
if (m_dialogModule != null)
m_dialogModule.SendAlertToUser(remoteClient, "This sale has been blocked by the permissions system");
return false;
}
case SaleType.Copy: // Sell a copy
uint perms = group.EffectiveOwnerPerms;
// save sell data
int price = rootpart.SalePrice;
byte clickAction = rootpart.ClickAction;
if ((perms & (uint)PermissionMask.Transfer) == 0)
{
if (m_dialogModule != null)
m_dialogModule.SendAlertToUser(remoteClient, "This item doesn't appear to be for sale");
return false;
}
// reset sale data for the copy
rootpart.ObjectSaleType = 0;
rootpart.SalePrice = 10;
rootpart.ClickAction = 0;
if ((perms & (uint)PermissionMask.Copy) == 0)
{
if (m_dialogModule != null)
m_dialogModule.SendAlertToUser(remoteClient, "This sale has been blocked by the permissions system");
return false;
}
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
// save sell data
int price = rootpart.SalePrice;
byte clickAction = rootpart.ClickAction;
rootpart.ObjectSaleType = saleType;
rootpart.SalePrice = price;
rootpart.ClickAction = clickAction;
// reset sale data for the copy
rootpart.ObjectSaleType = 0;
rootpart.SalePrice = 10;
rootpart.ClickAction = 0;
string name = rootpart.Name;
string desc = rootpart.Description;
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
AssetBase asset = m_scene.CreateAsset(
name, desc,
(sbyte)AssetType.Object,
Utils.StringToBytes(sceneObjectXml),
rootpart.CreatorID);
m_scene.AssetService.Store(asset);
rootpart.ObjectSaleType = saleType;
rootpart.SalePrice = price;
rootpart.ClickAction = clickAction;
InventoryItemBase item = new InventoryItemBase();
item.CreatorId = rootpart.CreatorID.ToString();
item.CreatorData = rootpart.CreatorData;
string name = rootpart.Name;
string desc = rootpart.Description;
item.ID = UUID.Random();
item.Owner = remoteClient.AgentId;
item.AssetID = asset.FullID;
item.Description = desc;
item.Name = name;
item.AssetType = asset.Type;
item.InvType = (int)InventoryType.Object;
item.Folder = categoryID;
AssetBase asset = m_scene.CreateAsset(
name, desc,
(sbyte)AssetType.Object,
Utils.StringToBytes(sceneObjectXml),
rootpart.CreatorID);
m_scene.AssetService.Store(asset);
InventoryItemBase item = new InventoryItemBase();
item.CreatorId = rootpart.CreatorID.ToString();
item.CreatorData = rootpart.CreatorData;
item.ID = UUID.Random();
item.Owner = remoteClient.AgentId;
item.AssetID = asset.FullID;
item.Description = desc;
item.Name = name;
item.AssetType = asset.Type;
item.InvType = (int)InventoryType.Object;
item.Folder = categoryID;
perms = group.CurrentAndFoldedNextPermissions();
// apply parts inventory next perms
PermissionsUtil.ApplyNoModFoldedPermissions(perms, ref perms);
// change to next owner perms
perms &= rootpart.NextOwnerMask;
// update folded
perms = PermissionsUtil.FixAndFoldPermissions(perms);
perms = group.CurrentAndFoldedNextPermissions();
// apply parts inventory next perms
PermissionsUtil.ApplyNoModFoldedPermissions(perms, ref perms);
// change to next owner perms
perms &= rootpart.NextOwnerMask;
// update folded
perms = PermissionsUtil.FixAndFoldPermissions(perms);
item.BasePermissions = perms;
item.CurrentPermissions = perms;
item.NextPermissions = rootpart.NextOwnerMask & perms;
item.EveryOnePermissions = rootpart.EveryoneMask & perms;
item.GroupPermissions = rootpart.GroupMask & perms;
item.BasePermissions = perms;
item.CurrentPermissions = perms;
item.NextPermissions = rootpart.NextOwnerMask & perms;
item.EveryOnePermissions = rootpart.EveryoneMask & perms;
item.GroupPermissions = rootpart.GroupMask & perms;
item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
item.CreationDate = Util.UnixTimeSinceEpoch();
item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
item.CreationDate = Util.UnixTimeSinceEpoch();
if (m_scene.AddInventoryItem(item))
{
remoteClient.SendInventoryItemCreateUpdate(item, 0);
}
else
{
if (m_dialogModule != null)
m_dialogModule.SendAlertToUser(remoteClient, "Cannot buy now. Your inventory is unavailable");
return false;
}
break;
case 3: // Sell contents
List<UUID> invList = rootpart.Inventory.GetInventoryList();
bool okToSell = true;
foreach (UUID invID in invList)
{
TaskInventoryItem item1 = rootpart.Inventory.GetInventoryItem(invID);
if ((item1.CurrentPermissions &
(uint)PermissionMask.Transfer) == 0)
if (m_scene.AddInventoryItem(item))
{
okToSell = false;
break;
remoteClient.SendInventoryItemCreateUpdate(item, 0);
}
}
else
{
if (m_dialogModule != null)
m_dialogModule.SendAlertToUser(remoteClient, "Cannot buy now. Your inventory is unavailable");
return false;
}
break;
if (!okToSell)
{
if (m_dialogModule != null)
m_dialogModule.SendAlertToUser(
remoteClient, "This item's inventory doesn't appear to be for sale");
case SaleType.Contents: // Sell contents
List<UUID> invList = rootpart.Inventory.GetInventoryList();
bool okToSell = true;
foreach (UUID invID in invList)
{
TaskInventoryItem item1 = rootpart.Inventory.GetInventoryItem(invID);
if ((item1.CurrentPermissions &
(uint)PermissionMask.Transfer) == 0)
{
okToSell = false;
break;
}
}
if (!okToSell)
{
if (m_dialogModule != null)
m_dialogModule.SendAlertToUser(
remoteClient, "This item's inventory doesn't appear to be for sale");
return false;
}
if (invList.Count > 0)
m_scene.MoveTaskInventoryItems(remoteClient.AgentId, rootpart.Name, rootpart, invList);
break;
default:
return false;
}
if (invList.Count > 0)
m_scene.MoveTaskInventoryItems(remoteClient.AgentId, rootpart.Name, rootpart, invList);
break;
}
return true;

View File

@@ -859,7 +859,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
return;
}
if (part.ObjectSaleType == 0)
if (part.ObjectSaleType == (byte)SaleType.Not)
{
string e = string.Format("Object {0} is not for sale", part.Name);
remoteClient.SendAgentAlertMessage(e, false);
@@ -877,7 +877,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
// Validate that the client sent the proper sale type the object has set
if (part.ObjectSaleType != saleType)
{
string e = string.Format("Object {0} sell type does not match selected one", part.Name);
string e = string.Format("Object {0} sell type does not match selected type", part.Name);
remoteClient.SendAgentAlertMessage(e, false);
return;
}