diff options
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 386 |
1 files changed, 11 insertions, 375 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7c89e65..73472a9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -496,73 +496,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
496 | 496 | ||
497 | #endregion | 497 | #endregion |
498 | 498 | ||
499 | #region BinaryStats | ||
500 | |||
501 | public class StatLogger | ||
502 | { | ||
503 | public DateTime StartTime; | ||
504 | public string Path; | ||
505 | public System.IO.BinaryWriter Log; | ||
506 | } | ||
507 | static StatLogger m_statLog = null; | ||
508 | static TimeSpan m_statLogPeriod = TimeSpan.FromSeconds(300); | ||
509 | static string m_statsDir = String.Empty; | ||
510 | static Object m_statLockObject = new Object(); | ||
511 | private void LogSimStats(SimStats stats) | ||
512 | { | ||
513 | SimStatsPacket pack = new SimStatsPacket(); | ||
514 | pack.Region = new SimStatsPacket.RegionBlock(); | ||
515 | pack.Region.RegionX = stats.RegionX; | ||
516 | pack.Region.RegionY = stats.RegionY; | ||
517 | pack.Region.RegionFlags = stats.RegionFlags; | ||
518 | pack.Region.ObjectCapacity = stats.ObjectCapacity; | ||
519 | //pack.Region = //stats.RegionBlock; | ||
520 | pack.Stat = stats.StatsBlock; | ||
521 | pack.Header.Reliable = false; | ||
522 | |||
523 | // note that we are inside the reporter lock when called | ||
524 | DateTime now = DateTime.Now; | ||
525 | |||
526 | // hide some time information into the packet | ||
527 | pack.Header.Sequence = (uint)now.Ticks; | ||
528 | |||
529 | lock (m_statLockObject) // m_statLog is shared so make sure there is only executer here | ||
530 | { | ||
531 | try | ||
532 | { | ||
533 | if (m_statLog == null || now > m_statLog.StartTime + m_statLogPeriod) | ||
534 | { | ||
535 | // First log file or time has expired, start writing to a new log file | ||
536 | if (m_statLog != null && m_statLog.Log != null) | ||
537 | { | ||
538 | m_statLog.Log.Close(); | ||
539 | } | ||
540 | m_statLog = new StatLogger(); | ||
541 | m_statLog.StartTime = now; | ||
542 | m_statLog.Path = (m_statsDir.Length > 0 ? m_statsDir + System.IO.Path.DirectorySeparatorChar.ToString() : "") | ||
543 | + String.Format("stats-{0}.log", now.ToString("yyyyMMddHHmmss")); | ||
544 | m_statLog.Log = new BinaryWriter(File.Open(m_statLog.Path, FileMode.Append, FileAccess.Write)); | ||
545 | } | ||
546 | |||
547 | // Write the serialized data to disk | ||
548 | if (m_statLog != null && m_statLog.Log != null) | ||
549 | m_statLog.Log.Write(pack.ToBytes()); | ||
550 | } | ||
551 | catch (Exception ex) | ||
552 | { | ||
553 | m_log.Error("statistics gathering failed: " + ex.Message, ex); | ||
554 | if (m_statLog != null && m_statLog.Log != null) | ||
555 | { | ||
556 | m_statLog.Log.Close(); | ||
557 | } | ||
558 | m_statLog = null; | ||
559 | } | ||
560 | } | ||
561 | return; | ||
562 | } | ||
563 | |||
564 | #endregion | ||
565 | |||
566 | #region Constructors | 499 | #region Constructors |
567 | 500 | ||
568 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, | 501 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, |
@@ -628,45 +561,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
628 | if (m_storageManager.EstateDataStore != null) | 561 | if (m_storageManager.EstateDataStore != null) |
629 | { | 562 | { |
630 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); | 563 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); |
631 | if (m_regInfo.EstateSettings.EstateID == 0) // No record at all | ||
632 | { | ||
633 | MainConsole.Instance.Output("Your region is not part of an estate."); | ||
634 | while (true) | ||
635 | { | ||
636 | string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List<string>() {"yes", "no"}); | ||
637 | if (response == "no") | ||
638 | { | ||
639 | // Create a new estate | ||
640 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true); | ||
641 | |||
642 | m_regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", m_regInfo.EstateSettings.EstateName); | ||
643 | m_regInfo.EstateSettings.Save(); | ||
644 | break; | ||
645 | } | ||
646 | else | ||
647 | { | ||
648 | response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); | ||
649 | if (response == "None") | ||
650 | continue; | ||
651 | |||
652 | List<int> estateIDs = m_storageManager.EstateDataStore.GetEstates(response); | ||
653 | if (estateIDs.Count < 1) | ||
654 | { | ||
655 | MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); | ||
656 | continue; | ||
657 | } | ||
658 | |||
659 | int estateID = estateIDs[0]; | ||
660 | |||
661 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(estateID); | ||
662 | |||
663 | if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID)) | ||
664 | break; | ||
665 | |||
666 | MainConsole.Instance.Output("Joining the estate failed. Please try again."); | ||
667 | } | ||
668 | } | ||
669 | } | ||
670 | } | 564 | } |
671 | 565 | ||
672 | #endregion Region Settings | 566 | #endregion Region Settings |
@@ -771,38 +665,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
771 | 665 | ||
772 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 666 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
773 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | 667 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); |
774 | |||
775 | #region BinaryStats | ||
776 | |||
777 | try | ||
778 | { | ||
779 | IConfig statConfig = m_config.Configs["Statistics.Binary"]; | ||
780 | if (statConfig.Contains("enabled") && statConfig.GetBoolean("enabled")) | ||
781 | { | ||
782 | if (statConfig.Contains("collect_region_stats")) | ||
783 | { | ||
784 | if (statConfig.GetBoolean("collect_region_stats")) | ||
785 | { | ||
786 | // if enabled, add us to the event. If not enabled, I won't get called | ||
787 | StatsReporter.OnSendStatsResult += LogSimStats; | ||
788 | } | ||
789 | } | ||
790 | if (statConfig.Contains("region_stats_period_seconds")) | ||
791 | { | ||
792 | m_statLogPeriod = TimeSpan.FromSeconds(statConfig.GetInt("region_stats_period_seconds")); | ||
793 | } | ||
794 | if (statConfig.Contains("stats_dir")) | ||
795 | { | ||
796 | m_statsDir = statConfig.GetString("stats_dir"); | ||
797 | } | ||
798 | } | ||
799 | } | ||
800 | catch | ||
801 | { | ||
802 | // if it doesn't work, we don't collect anything | ||
803 | } | ||
804 | |||
805 | #endregion BinaryStats | ||
806 | } | 668 | } |
807 | catch | 669 | catch |
808 | { | 670 | { |
@@ -1844,33 +1706,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1844 | 1706 | ||
1845 | } | 1707 | } |
1846 | 1708 | ||
1847 | /// <summary> | ||
1848 | /// Create a terrain texture for this scene | ||
1849 | /// </summary> | ||
1850 | public void CreateTerrainTexture() | ||
1851 | { | ||
1852 | //create a texture asset of the terrain | ||
1853 | IMapImageGenerator terrain = RequestModuleInterface<IMapImageGenerator>(); | ||
1854 | |||
1855 | // Cannot create a map for a nonexistant heightmap yet. | ||
1856 | if (Heightmap == null) | ||
1857 | return; | ||
1858 | |||
1859 | if (terrain == null) | ||
1860 | return; | ||
1861 | |||
1862 | byte[] data = terrain.WriteJpeg2000Image("defaultstripe.png"); | ||
1863 | if (data != null) | ||
1864 | { | ||
1865 | IWorldMapModule mapModule = RequestModuleInterface<IWorldMapModule>(); | ||
1866 | |||
1867 | if (mapModule != null) | ||
1868 | mapModule.RegenerateMaptile(data); | ||
1869 | else | ||
1870 | m_log.DebugFormat("[SCENE]: MapModule is null, can't save maptile"); | ||
1871 | } | ||
1872 | } | ||
1873 | |||
1874 | #endregion | 1709 | #endregion |
1875 | 1710 | ||
1876 | #region Load Land | 1711 | #region Load Land |
@@ -1929,7 +1764,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1929 | 1764 | ||
1930 | AddRestoredSceneObject(group, true, true); | 1765 | AddRestoredSceneObject(group, true, true); |
1931 | SceneObjectPart rootPart = group.GetChildPart(group.UUID); | 1766 | SceneObjectPart rootPart = group.GetChildPart(group.UUID); |
1932 | rootPart.ObjectFlags &= ~(uint)PrimFlags.Scripted; | 1767 | rootPart.Flags &= ~PrimFlags.Scripted; |
1933 | rootPart.TrimPermissions(); | 1768 | rootPart.TrimPermissions(); |
1934 | group.CheckSculptAndLoad(); | 1769 | group.CheckSculptAndLoad(); |
1935 | //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); | 1770 | //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); |
@@ -2248,7 +2083,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2248 | 2083 | ||
2249 | foreach (SceneObjectPart part in group.Children.Values) | 2084 | foreach (SceneObjectPart part in group.Children.Values) |
2250 | { | 2085 | { |
2251 | if (part.IsJoint() && ((part.ObjectFlags&(uint)PrimFlags.Physics) != 0)) | 2086 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) |
2252 | { | 2087 | { |
2253 | PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? | 2088 | PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? |
2254 | } | 2089 | } |
@@ -2761,7 +2596,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2761 | if (!VerifyClient(aCircuit, ep, out vialogin)) | 2596 | if (!VerifyClient(aCircuit, ep, out vialogin)) |
2762 | { | 2597 | { |
2763 | // uh-oh, this is fishy | 2598 | // uh-oh, this is fishy |
2764 | m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.", | 2599 | m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.", |
2765 | client.AgentId, client.SessionId, ep.ToString()); | 2600 | client.AgentId, client.SessionId, ep.ToString()); |
2766 | try | 2601 | try |
2767 | { | 2602 | { |
@@ -2769,13 +2604,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2769 | } | 2604 | } |
2770 | catch (Exception e) | 2605 | catch (Exception e) |
2771 | { | 2606 | { |
2772 | m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace); | 2607 | m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace); |
2773 | } | 2608 | } |
2774 | return; | 2609 | return; |
2775 | } | 2610 | } |
2776 | } | 2611 | } |
2777 | 2612 | ||
2778 | m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); | 2613 | m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); |
2779 | 2614 | ||
2780 | ScenePresence sp = CreateAndAddScenePresence(client); | 2615 | ScenePresence sp = CreateAndAddScenePresence(client); |
2781 | if (aCircuit != null) | 2616 | if (aCircuit != null) |
@@ -2804,7 +2639,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2804 | // Do the verification here | 2639 | // Do the verification here |
2805 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) | 2640 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) |
2806 | { | 2641 | { |
2807 | m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | 2642 | m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); |
2808 | vialogin = true; | 2643 | vialogin = true; |
2809 | IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); | 2644 | IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); |
2810 | if (userVerification != null && ep != null) | 2645 | if (userVerification != null && ep != null) |
@@ -2814,11 +2649,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2814 | if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString())) | 2649 | if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString())) |
2815 | { | 2650 | { |
2816 | // uh-oh, this is fishy | 2651 | // uh-oh, this is fishy |
2817 | m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | 2652 | m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); |
2818 | return false; | 2653 | return false; |
2819 | } | 2654 | } |
2820 | else | 2655 | else |
2821 | m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} in {2} returned true", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | 2656 | m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned true", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); |
2822 | } | 2657 | } |
2823 | } | 2658 | } |
2824 | 2659 | ||
@@ -2849,7 +2684,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2849 | } | 2684 | } |
2850 | catch (Exception e) | 2685 | catch (Exception e) |
2851 | { | 2686 | { |
2852 | m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace); | 2687 | m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace); |
2853 | } | 2688 | } |
2854 | } | 2689 | } |
2855 | else | 2690 | else |
@@ -2879,7 +2714,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2879 | public virtual void SubscribeToClientTerrainEvents(IClientAPI client) | 2714 | public virtual void SubscribeToClientTerrainEvents(IClientAPI client) |
2880 | { | 2715 | { |
2881 | client.OnRegionHandShakeReply += SendLayerData; | 2716 | client.OnRegionHandShakeReply += SendLayerData; |
2882 | client.OnUnackedTerrain += TerrainUnAcked; | ||
2883 | } | 2717 | } |
2884 | 2718 | ||
2885 | public virtual void SubscribeToClientPrimEvents(IClientAPI client) | 2719 | public virtual void SubscribeToClientPrimEvents(IClientAPI client) |
@@ -2919,8 +2753,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2919 | client.OnUndo += m_sceneGraph.HandleUndo; | 2753 | client.OnUndo += m_sceneGraph.HandleUndo; |
2920 | client.OnRedo += m_sceneGraph.HandleRedo; | 2754 | client.OnRedo += m_sceneGraph.HandleRedo; |
2921 | client.OnObjectDescription += m_sceneGraph.PrimDescription; | 2755 | client.OnObjectDescription += m_sceneGraph.PrimDescription; |
2922 | client.OnObjectDrop += m_sceneGraph.DropObject; | 2756 | client.OnObjectDrop += m_sceneGraph.DropObject; |
2923 | client.OnObjectSaleInfo += ObjectSaleInfo; | ||
2924 | client.OnObjectIncludeInSearch += m_sceneGraph.MakeObjectSearchable; | 2757 | client.OnObjectIncludeInSearch += m_sceneGraph.MakeObjectSearchable; |
2925 | client.OnObjectOwner += ObjectOwner; | 2758 | client.OnObjectOwner += ObjectOwner; |
2926 | } | 2759 | } |
@@ -3011,7 +2844,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3011 | public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) | 2844 | public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) |
3012 | { | 2845 | { |
3013 | client.OnRegionHandShakeReply -= SendLayerData; | 2846 | client.OnRegionHandShakeReply -= SendLayerData; |
3014 | client.OnUnackedTerrain -= TerrainUnAcked; | ||
3015 | } | 2847 | } |
3016 | 2848 | ||
3017 | public virtual void UnSubscribeToClientPrimEvents(IClientAPI client) | 2849 | public virtual void UnSubscribeToClientPrimEvents(IClientAPI client) |
@@ -3050,7 +2882,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3050 | client.OnRedo -= m_sceneGraph.HandleRedo; | 2882 | client.OnRedo -= m_sceneGraph.HandleRedo; |
3051 | client.OnObjectDescription -= m_sceneGraph.PrimDescription; | 2883 | client.OnObjectDescription -= m_sceneGraph.PrimDescription; |
3052 | client.OnObjectDrop -= m_sceneGraph.DropObject; | 2884 | client.OnObjectDrop -= m_sceneGraph.DropObject; |
3053 | client.OnObjectSaleInfo -= ObjectSaleInfo; | ||
3054 | client.OnObjectIncludeInSearch -= m_sceneGraph.MakeObjectSearchable; | 2885 | client.OnObjectIncludeInSearch -= m_sceneGraph.MakeObjectSearchable; |
3055 | client.OnObjectOwner -= ObjectOwner; | 2886 | client.OnObjectOwner -= ObjectOwner; |
3056 | } | 2887 | } |
@@ -4625,23 +4456,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4625 | client.SendRegionHandle(regionID, handle); | 4456 | client.SendRegionHandle(regionID, handle); |
4626 | } | 4457 | } |
4627 | 4458 | ||
4628 | public void TerrainUnAcked(IClientAPI client, int patchX, int patchY) | ||
4629 | { | ||
4630 | //m_log.Debug("Terrain packet unacked, resending patch: " + patchX + " , " + patchY); | ||
4631 | client.SendLayerData(patchX, patchY, Heightmap.GetFloatsSerialised()); | ||
4632 | } | ||
4633 | |||
4634 | public void SetRootAgentScene(UUID agentID) | ||
4635 | { | ||
4636 | IInventoryTransferModule inv = RequestModuleInterface<IInventoryTransferModule>(); | ||
4637 | if (inv == null) | ||
4638 | return; | ||
4639 | |||
4640 | inv.SetRootAgentScene(agentID, this); | ||
4641 | |||
4642 | EventManager.TriggerSetRootAgentScene(agentID, this); | ||
4643 | } | ||
4644 | |||
4645 | public bool NeedSceneCacheClear(UUID agentID) | 4459 | public bool NeedSceneCacheClear(UUID agentID) |
4646 | { | 4460 | { |
4647 | IInventoryTransferModule inv = RequestModuleInterface<IInventoryTransferModule>(); | 4461 | IInventoryTransferModule inv = RequestModuleInterface<IInventoryTransferModule>(); |
@@ -4651,184 +4465,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4651 | return inv.NeedSceneCacheClear(agentID, this); | 4465 | return inv.NeedSceneCacheClear(agentID, this); |
4652 | } | 4466 | } |
4653 | 4467 | ||
4654 | public void ObjectSaleInfo(IClientAPI client, UUID agentID, UUID sessionID, uint localID, byte saleType, int salePrice) | ||
4655 | { | ||
4656 | SceneObjectPart part = GetSceneObjectPart(localID); | ||
4657 | if (part == null || part.ParentGroup == null) | ||
4658 | return; | ||
4659 | |||
4660 | if (part.ParentGroup.IsDeleted) | ||
4661 | return; | ||
4662 | |||
4663 | part = part.ParentGroup.RootPart; | ||
4664 | |||
4665 | part.ObjectSaleType = saleType; | ||
4666 | part.SalePrice = salePrice; | ||
4667 | |||
4668 | part.ParentGroup.HasGroupChanged = true; | ||
4669 | |||
4670 | part.GetProperties(client); | ||
4671 | } | ||
4672 | |||
4673 | public bool PerformObjectBuy(IClientAPI remoteClient, UUID categoryID, | ||
4674 | uint localID, byte saleType) | ||
4675 | { | ||
4676 | SceneObjectPart part = GetSceneObjectPart(localID); | ||
4677 | |||
4678 | if (part == null) | ||
4679 | return false; | ||
4680 | |||
4681 | if (part.ParentGroup == null) | ||
4682 | return false; | ||
4683 | |||
4684 | SceneObjectGroup group = part.ParentGroup; | ||
4685 | |||
4686 | switch (saleType) | ||
4687 | { | ||
4688 | case 1: // Sell as original (in-place sale) | ||
4689 | uint effectivePerms=group.GetEffectivePermissions(); | ||
4690 | |||
4691 | if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) | ||
4692 | { | ||
4693 | m_dialogModule.SendAlertToUser(remoteClient, "This item doesn't appear to be for sale"); | ||
4694 | return false; | ||
4695 | } | ||
4696 | |||
4697 | group.SetOwnerId(remoteClient.AgentId); | ||
4698 | group.SetRootPartOwner(part, remoteClient.AgentId, | ||
4699 | remoteClient.ActiveGroupId); | ||
4700 | |||
4701 | List<SceneObjectPart> partList = | ||
4702 | new List<SceneObjectPart>(group.Children.Values); | ||
4703 | |||
4704 | if (Permissions.PropagatePermissions()) | ||
4705 | { | ||
4706 | foreach (SceneObjectPart child in partList) | ||
4707 | { | ||
4708 | child.Inventory.ChangeInventoryOwner(remoteClient.AgentId); | ||
4709 | child.TriggerScriptChangedEvent(Changed.OWNER); | ||
4710 | child.ApplyNextOwnerPermissions(); | ||
4711 | } | ||
4712 | } | ||
4713 | |||
4714 | part.ObjectSaleType = 0; | ||
4715 | part.SalePrice = 10; | ||
4716 | |||
4717 | group.HasGroupChanged = true; | ||
4718 | part.GetProperties(remoteClient); | ||
4719 | part.TriggerScriptChangedEvent(Changed.OWNER); | ||
4720 | group.ResumeScripts(); | ||
4721 | part.ScheduleFullUpdate(); | ||
4722 | |||
4723 | break; | ||
4724 | |||
4725 | case 2: // Sell a copy | ||
4726 | |||
4727 | |||
4728 | Vector3 inventoryStoredPosition = new Vector3 | ||
4729 | (((group.AbsolutePosition.X > (int)Constants.RegionSize) | ||
4730 | ? 250 | ||
4731 | : group.AbsolutePosition.X) | ||
4732 | , | ||
4733 | (group.AbsolutePosition.X > (int)Constants.RegionSize) | ||
4734 | ? 250 | ||
4735 | : group.AbsolutePosition.X, | ||
4736 | group.AbsolutePosition.Z); | ||
4737 | |||
4738 | Vector3 originalPosition = group.AbsolutePosition; | ||
4739 | |||
4740 | group.AbsolutePosition = inventoryStoredPosition; | ||
4741 | |||
4742 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group); | ||
4743 | group.AbsolutePosition = originalPosition; | ||
4744 | |||
4745 | uint perms=group.GetEffectivePermissions(); | ||
4746 | |||
4747 | if ((perms & (uint)PermissionMask.Transfer) == 0) | ||
4748 | { | ||
4749 | m_dialogModule.SendAlertToUser(remoteClient, "This item doesn't appear to be for sale"); | ||
4750 | return false; | ||
4751 | } | ||
4752 | |||
4753 | AssetBase asset = CreateAsset( | ||
4754 | group.GetPartName(localID), | ||
4755 | group.GetPartDescription(localID), | ||
4756 | (sbyte)AssetType.Object, | ||
4757 | Utils.StringToBytes(sceneObjectXml), | ||
4758 | group.OwnerID); | ||
4759 | AssetService.Store(asset); | ||
4760 | |||
4761 | InventoryItemBase item = new InventoryItemBase(); | ||
4762 | item.CreatorId = part.CreatorID.ToString(); | ||
4763 | |||
4764 | item.ID = UUID.Random(); | ||
4765 | item.Owner = remoteClient.AgentId; | ||
4766 | item.AssetID = asset.FullID; | ||
4767 | item.Description = asset.Description; | ||
4768 | item.Name = asset.Name; | ||
4769 | item.AssetType = asset.Type; | ||
4770 | item.InvType = (int)InventoryType.Object; | ||
4771 | item.Folder = categoryID; | ||
4772 | |||
4773 | uint nextPerms=(perms & 7) << 13; | ||
4774 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
4775 | perms &= ~(uint)PermissionMask.Copy; | ||
4776 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
4777 | perms &= ~(uint)PermissionMask.Transfer; | ||
4778 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
4779 | perms &= ~(uint)PermissionMask.Modify; | ||
4780 | |||
4781 | item.BasePermissions = perms & part.NextOwnerMask; | ||
4782 | item.CurrentPermissions = perms & part.NextOwnerMask; | ||
4783 | item.NextPermissions = part.NextOwnerMask; | ||
4784 | item.EveryOnePermissions = part.EveryoneMask & | ||
4785 | part.NextOwnerMask; | ||
4786 | item.GroupPermissions = part.GroupMask & | ||
4787 | part.NextOwnerMask; | ||
4788 | item.CurrentPermissions |= 16; // Slam! | ||
4789 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
4790 | |||
4791 | if (InventoryService.AddItem(item)) | ||
4792 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
4793 | else | ||
4794 | { | ||
4795 | m_dialogModule.SendAlertToUser(remoteClient, "Cannot buy now. Your inventory is unavailable"); | ||
4796 | return false; | ||
4797 | } | ||
4798 | break; | ||
4799 | |||
4800 | case 3: // Sell contents | ||
4801 | List<UUID> invList = part.Inventory.GetInventoryList(); | ||
4802 | |||
4803 | bool okToSell = true; | ||
4804 | |||
4805 | foreach (UUID invID in invList) | ||
4806 | { | ||
4807 | TaskInventoryItem item1 = part.Inventory.GetInventoryItem(invID); | ||
4808 | if ((item1.CurrentPermissions & | ||
4809 | (uint)PermissionMask.Transfer) == 0) | ||
4810 | { | ||
4811 | okToSell = false; | ||
4812 | break; | ||
4813 | } | ||
4814 | } | ||
4815 | |||
4816 | if (!okToSell) | ||
4817 | { | ||
4818 | m_dialogModule.SendAlertToUser( | ||
4819 | remoteClient, "This item's inventory doesn't appear to be for sale"); | ||
4820 | return false; | ||
4821 | } | ||
4822 | |||
4823 | if (invList.Count > 0) | ||
4824 | MoveTaskInventoryItems(remoteClient.AgentId, part.Name, | ||
4825 | part, invList); | ||
4826 | break; | ||
4827 | } | ||
4828 | |||
4829 | return true; | ||
4830 | } | ||
4831 | |||
4832 | public void CleanTempObjects() | 4468 | public void CleanTempObjects() |
4833 | { | 4469 | { |
4834 | List<EntityBase> objs = GetEntities(); | 4470 | List<EntityBase> objs = GetEntities(); |
@@ -4969,7 +4605,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4969 | } | 4605 | } |
4970 | 4606 | ||
4971 | // turn the proxy non-physical, which also stops its client-side interpolation | 4607 | // turn the proxy non-physical, which also stops its client-side interpolation |
4972 | bool wasUsingPhysics = ((jointProxyObject.ObjectFlags & (uint)PrimFlags.Physics) != 0); | 4608 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4973 | if (wasUsingPhysics) | 4609 | if (wasUsingPhysics) |
4974 | { | 4610 | { |
4975 | jointProxyObject.UpdatePrimFlags(false, false, true, false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock | 4611 | jointProxyObject.UpdatePrimFlags(false, false, true, false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock |