diff options
author | Justin Clark-Casey (justincc) | 2010-08-13 22:29:42 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-08-13 22:29:42 +0100 |
commit | e89f0b3f71dc8bd439fcfc23d12b305369eac36b (patch) | |
tree | e14eda03955229bdc32ebe51d735157dc09f4c90 /OpenSim/Region/Framework/Scenes/Scene.cs | |
parent | minor: remove mono compiler warning (diff) | |
download | opensim-SC-e89f0b3f71dc8bd439fcfc23d12b305369eac36b.zip opensim-SC-e89f0b3f71dc8bd439fcfc23d12b305369eac36b.tar.gz opensim-SC-e89f0b3f71dc8bd439fcfc23d12b305369eac36b.tar.bz2 opensim-SC-e89f0b3f71dc8bd439fcfc23d12b305369eac36b.tar.xz |
refactor: move Scene.PerformObjectBuy into BuySellModule
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 159 |
1 files changed, 0 insertions, 159 deletions
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(); |