aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-08-13 22:29:42 +0100
committerJustin Clark-Casey (justincc)2010-08-13 22:29:42 +0100
commite89f0b3f71dc8bd439fcfc23d12b305369eac36b (patch)
treee14eda03955229bdc32ebe51d735157dc09f4c90 /OpenSim/Region/Framework
parentminor: remove mono compiler warning (diff)
downloadopensim-SC_OLD-e89f0b3f71dc8bd439fcfc23d12b305369eac36b.zip
opensim-SC_OLD-e89f0b3f71dc8bd439fcfc23d12b305369eac36b.tar.gz
opensim-SC_OLD-e89f0b3f71dc8bd439fcfc23d12b305369eac36b.tar.bz2
opensim-SC_OLD-e89f0b3f71dc8bd439fcfc23d12b305369eac36b.tar.xz
refactor: move Scene.PerformObjectBuy into BuySellModule
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IBuySellModule.cs47
-rw-r--r--OpenSim/Region/Framework/Interfaces/ICloudModule.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs159
4 files changed, 49 insertions, 162 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IBuySellModule.cs b/OpenSim/Region/Framework/Interfaces/IBuySellModule.cs
new file mode 100644
index 0000000..0132bae
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IBuySellModule.cs
@@ -0,0 +1,47 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using OpenMetaverse;
29using OpenSim.Framework;
30
31namespace OpenSim.Region.Framework.Interfaces
32{
33 public interface IBuySellModule
34 {
35 /// <summary>
36 /// Try to buy an object
37 /// </summary>
38 /// <param name="remoteClient"></param>
39 /// <param name="categoryID"></param>
40 /// <param name="localID"></param>
41 /// <param name="saleType"></param>
42 /// <returns>
43 /// True on a successful purchase, false on failure
44 /// </returns>
45 bool BuyObject(IClientAPI remoteClient, UUID categoryID, uint localID, byte saleType);
46 }
47} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/ICloudModule.cs b/OpenSim/Region/Framework/Interfaces/ICloudModule.cs
index f8a5bad..7296ac3 100644
--- a/OpenSim/Region/Framework/Interfaces/ICloudModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ICloudModule.cs
@@ -25,7 +25,6 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28
29namespace OpenSim.Region.Framework.Interfaces 28namespace OpenSim.Region.Framework.Interfaces
30{ 29{
31 public interface ICloudModule : IRegionModule 30 public interface ICloudModule : IRegionModule
@@ -35,4 +34,4 @@ namespace OpenSim.Region.Framework.Interfaces
35 /// </summary> 34 /// </summary>
36 float CloudCover(int x, int y, int z); 35 float CloudCover(int x, int y, int z);
37 } 36 }
38} 37} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 01edf51..4f5a65e 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -670,7 +670,7 @@ namespace OpenSim.Region.Framework.Scenes
670 /// <summary> 670 /// <summary>
671 /// Create a new asset data structure. 671 /// Create a new asset data structure.
672 /// </summary> 672 /// </summary>
673 private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, UUID creatorID) 673 public AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, UUID creatorID)
674 { 674 {
675 AssetBase asset = new AssetBase(UUID.Random(), name, assetType, creatorID.ToString()); 675 AssetBase asset = new AssetBase(UUID.Random(), name, assetType, creatorID.ToString());
676 asset.Description = description; 676 asset.Description = description;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index b6def14..5f6748e 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -4486,165 +4486,6 @@ namespace OpenSim.Region.Framework.Scenes
4486 return inv.NeedSceneCacheClear(agentID, this); 4486 return inv.NeedSceneCacheClear(agentID, this);
4487 } 4487 }
4488 4488
4489 public bool PerformObjectBuy(IClientAPI remoteClient, UUID categoryID,
4490 uint localID, byte saleType)
4491 {
4492 SceneObjectPart part = GetSceneObjectPart(localID);
4493
4494 if (part == null)
4495 return false;
4496
4497 if (part.ParentGroup == null)
4498 return false;
4499
4500 SceneObjectGroup group = part.ParentGroup;
4501
4502 switch (saleType)
4503 {
4504 case 1: // Sell as original (in-place sale)
4505 uint effectivePerms=group.GetEffectivePermissions();
4506
4507 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
4508 {
4509 m_dialogModule.SendAlertToUser(remoteClient, "This item doesn't appear to be for sale");
4510 return false;
4511 }
4512
4513 group.SetOwnerId(remoteClient.AgentId);
4514 group.SetRootPartOwner(part, remoteClient.AgentId,
4515 remoteClient.ActiveGroupId);
4516
4517 List<SceneObjectPart> partList =
4518 new List<SceneObjectPart>(group.Children.Values);
4519
4520 if (Permissions.PropagatePermissions())
4521 {
4522 foreach (SceneObjectPart child in partList)
4523 {
4524 child.Inventory.ChangeInventoryOwner(remoteClient.AgentId);
4525 child.TriggerScriptChangedEvent(Changed.OWNER);
4526 child.ApplyNextOwnerPermissions();
4527 }
4528 }
4529
4530 part.ObjectSaleType = 0;
4531 part.SalePrice = 10;
4532
4533 group.HasGroupChanged = true;
4534 part.GetProperties(remoteClient);
4535 part.TriggerScriptChangedEvent(Changed.OWNER);
4536 group.ResumeScripts();
4537 part.ScheduleFullUpdate();
4538
4539 break;
4540
4541 case 2: // Sell a copy
4542
4543
4544 Vector3 inventoryStoredPosition = new Vector3
4545 (((group.AbsolutePosition.X > (int)Constants.RegionSize)
4546 ? 250
4547 : group.AbsolutePosition.X)
4548 ,
4549 (group.AbsolutePosition.X > (int)Constants.RegionSize)
4550 ? 250
4551 : group.AbsolutePosition.X,
4552 group.AbsolutePosition.Z);
4553
4554 Vector3 originalPosition = group.AbsolutePosition;
4555
4556 group.AbsolutePosition = inventoryStoredPosition;
4557
4558 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
4559 group.AbsolutePosition = originalPosition;
4560
4561 uint perms=group.GetEffectivePermissions();
4562
4563 if ((perms & (uint)PermissionMask.Transfer) == 0)
4564 {
4565 m_dialogModule.SendAlertToUser(remoteClient, "This item doesn't appear to be for sale");
4566 return false;
4567 }
4568
4569 AssetBase asset = CreateAsset(
4570 group.GetPartName(localID),
4571 group.GetPartDescription(localID),
4572 (sbyte)AssetType.Object,
4573 Utils.StringToBytes(sceneObjectXml),
4574 group.OwnerID);
4575 AssetService.Store(asset);
4576
4577 InventoryItemBase item = new InventoryItemBase();
4578 item.CreatorId = part.CreatorID.ToString();
4579
4580 item.ID = UUID.Random();
4581 item.Owner = remoteClient.AgentId;
4582 item.AssetID = asset.FullID;
4583 item.Description = asset.Description;
4584 item.Name = asset.Name;
4585 item.AssetType = asset.Type;
4586 item.InvType = (int)InventoryType.Object;
4587 item.Folder = categoryID;
4588
4589 uint nextPerms=(perms & 7) << 13;
4590 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
4591 perms &= ~(uint)PermissionMask.Copy;
4592 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
4593 perms &= ~(uint)PermissionMask.Transfer;
4594 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
4595 perms &= ~(uint)PermissionMask.Modify;
4596
4597 item.BasePermissions = perms & part.NextOwnerMask;
4598 item.CurrentPermissions = perms & part.NextOwnerMask;
4599 item.NextPermissions = part.NextOwnerMask;
4600 item.EveryOnePermissions = part.EveryoneMask &
4601 part.NextOwnerMask;
4602 item.GroupPermissions = part.GroupMask &
4603 part.NextOwnerMask;
4604 item.CurrentPermissions |= 16; // Slam!
4605 item.CreationDate = Util.UnixTimeSinceEpoch();
4606
4607 if (InventoryService.AddItem(item))
4608 remoteClient.SendInventoryItemCreateUpdate(item, 0);
4609 else
4610 {
4611 m_dialogModule.SendAlertToUser(remoteClient, "Cannot buy now. Your inventory is unavailable");
4612 return false;
4613 }
4614 break;
4615
4616 case 3: // Sell contents
4617 List<UUID> invList = part.Inventory.GetInventoryList();
4618
4619 bool okToSell = true;
4620
4621 foreach (UUID invID in invList)
4622 {
4623 TaskInventoryItem item1 = part.Inventory.GetInventoryItem(invID);
4624 if ((item1.CurrentPermissions &
4625 (uint)PermissionMask.Transfer) == 0)
4626 {
4627 okToSell = false;
4628 break;
4629 }
4630 }
4631
4632 if (!okToSell)
4633 {
4634 m_dialogModule.SendAlertToUser(
4635 remoteClient, "This item's inventory doesn't appear to be for sale");
4636 return false;
4637 }
4638
4639 if (invList.Count > 0)
4640 MoveTaskInventoryItems(remoteClient.AgentId, part.Name,
4641 part, invList);
4642 break;
4643 }
4644
4645 return true;
4646 }
4647
4648 public void CleanTempObjects() 4489 public void CleanTempObjects()
4649 { 4490 {
4650 List<EntityBase> objs = GetEntities(); 4491 List<EntityBase> objs = GetEntities();