aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorBlueWall2011-04-13 09:53:44 -0400
committerBlueWall2011-04-13 09:53:44 -0400
commitd3457eae7a33f01a8fa906c4040792cdc4a67857 (patch)
treef92e60733b8397576b86c486e05aa5219f27d034 /OpenSim/Region
parentMerge branch 'master' of /home/opensim/src/OpenSim/Core (diff)
parentMove example HttpProxy setting to OpenSim.ini.example and tidy (diff)
downloadopensim-SC-d3457eae7a33f01a8fa906c4040792cdc4a67857.zip
opensim-SC-d3457eae7a33f01a8fa906c4040792cdc4a67857.tar.gz
opensim-SC-d3457eae7a33f01a8fa906c4040792cdc4a67857.tar.bz2
opensim-SC-d3457eae7a33f01a8fa906c4040792cdc4a67857.tar.xz
Merge branch 'master' of /home/git/repo/OpenSim
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/Application.cs14
-rw-r--r--OpenSim/Region/Application/OpenSim.cs20
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs122
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs415
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs4
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs4
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/PriorityQueue.cs245
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs7
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs754
-rw-r--r--OpenSim/Region/CoreModules/LightShare/LightShareModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs42
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs149
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandChannel.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs112
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs109
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs260
-rw-r--r--OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs382
-rw-r--r--OpenSim/Region/CoreModules/World/Sun/SunModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs6
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateDataService.cs64
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs68
-rw-r--r--OpenSim/Region/Framework/Interfaces/ILandChannel.cs91
-rw-r--r--OpenSim/Region/Framework/Interfaces/ILandObject.cs112
-rw-r--r--OpenSim/Region/Framework/Interfaces/IPrimCountModule.cs16
-rw-r--r--OpenSim/Region/Framework/ModuleLoader.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs30
-rw-r--r--OpenSim/Region/Framework/Scenes/Prioritizer.cs250
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs72
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs49
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs119
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs10
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs9
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs8
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs3
-rw-r--r--OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs3
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs1
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs10
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs2
-rw-r--r--OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs129
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs26
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs25
53 files changed, 2448 insertions, 1371 deletions
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs
index d120f03..7e320e6 100644
--- a/OpenSim/Region/Application/Application.cs
+++ b/OpenSim/Region/Application/Application.cs
@@ -250,9 +250,7 @@ namespace OpenSim
250 m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false); 250 m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);
251 251
252 // load Crash directory config 252 // load Crash directory config
253 m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir); 253 m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);
254
255
256 254
257 if (background) 255 if (background)
258 { 256 {
@@ -260,15 +258,9 @@ namespace OpenSim
260 m_sim.Startup(); 258 m_sim.Startup();
261 } 259 }
262 else 260 else
263 { 261 {
264
265
266
267
268 m_sim = new OpenSim(configSource); 262 m_sim = new OpenSim(configSource);
269 263
270
271
272 m_sim.Startup(); 264 m_sim.Startup();
273 265
274 while (true) 266 while (true)
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 4081888..39004d4 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -123,7 +123,7 @@ namespace OpenSim
123 m_log.Info("===================================================================="); 123 m_log.Info("====================================================================");
124 m_log.Info("========================= STARTING OPENSIM ========================="); 124 m_log.Info("========================= STARTING OPENSIM =========================");
125 m_log.Info("===================================================================="); 125 m_log.Info("====================================================================");
126 m_log.InfoFormat("[OPENSIM MAIN]: Running "); 126
127 //m_log.InfoFormat("[OPENSIM MAIN]: GC Is Server GC: {0}", GCSettings.IsServerGC.ToString()); 127 //m_log.InfoFormat("[OPENSIM MAIN]: GC Is Server GC: {0}", GCSettings.IsServerGC.ToString());
128 // http://msdn.microsoft.com/en-us/library/bb384202.aspx 128 // http://msdn.microsoft.com/en-us/library/bb384202.aspx
129 //GCSettings.LatencyMode = GCLatencyMode.Batch; 129 //GCSettings.LatencyMode = GCLatencyMode.Batch;
@@ -341,10 +341,15 @@ namespace OpenSim
341 341
342 m_console.Commands.AddCommand("region", false, "config get", 342 m_console.Commands.AddCommand("region", false, "config get",
343 "config get [<section>] [<key>]", 343 "config get [<section>] [<key>]",
344 "Show a config option", 344 "Synonym for config show",
345 HandleConfig);
346
347 m_console.Commands.AddCommand("region", false, "config show",
348 "config show [<section>] [<key>]",
349 "Show config information",
345 "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine 350 "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
346 + "If a section is given but not a field, then all fields in that section are printed.", 351 + "If a section is given but not a field, then all fields in that section are printed.",
347 HandleConfig); 352 HandleConfig);
348 353
349 m_console.Commands.AddCommand("region", false, "config save", 354 m_console.Commands.AddCommand("region", false, "config save",
350 "config save <path>", 355 "config save <path>",
@@ -593,7 +598,9 @@ namespace OpenSim
593 598
594 if (cmdparams.Length > 0) 599 if (cmdparams.Length > 0)
595 { 600 {
596 switch (cmdparams[0].ToLower()) 601 string firstParam = cmdparams[0].ToLower();
602
603 switch (firstParam)
597 { 604 {
598 case "set": 605 case "set":
599 if (cmdparams.Length < 4) 606 if (cmdparams.Length < 4)
@@ -618,6 +625,7 @@ namespace OpenSim
618 break; 625 break;
619 626
620 case "get": 627 case "get":
628 case "show":
621 if (cmdparams.Length == 1) 629 if (cmdparams.Length == 1)
622 { 630 {
623 foreach (IConfig config in m_config.Source.Configs) 631 foreach (IConfig config in m_config.Source.Configs)
@@ -654,8 +662,8 @@ namespace OpenSim
654 } 662 }
655 else 663 else
656 { 664 {
657 Notice("Syntax: config get [<section>] [<key>]"); 665 Notice("Syntax: config {0} [<section>] [<key>]", firstParam);
658 Notice("Example: config get ScriptEngine.DotNetEngine NumberOfScriptThreads"); 666 Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam);
659 } 667 }
660 668
661 break; 669 break;
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index e950613..ea9edf6 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -793,66 +793,112 @@ namespace OpenSim
793 } 793 }
794 794
795 /// <summary> 795 /// <summary>
796 /// Load the estate information for the provided RegionInfo object. 796 /// Create an estate with an initial region.
797 /// </summary> 797 /// </summary>
798 /// <remarks>
799 /// This method doesn't allow an estate to be created with the same name as existing estates.
800 /// </remarks>
798 /// <param name="regInfo"></param> 801 /// <param name="regInfo"></param>
799 public void PopulateRegionEstateInfo(RegionInfo regInfo) 802 /// <param name="existingName">A list of estate names that already exist.</param>
803 /// <returns>true if the estate was created, false otherwise</returns>
804 public bool CreateEstate(RegionInfo regInfo, List<string> existingNames)
800 { 805 {
801 IEstateDataService estateDataService = EstateDataService; 806 // Create a new estate
807 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true);
808 string newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
802 809
803 if (estateDataService != null) 810 if (existingNames.Contains(newName))
804 { 811 {
805 regInfo.EstateSettings = estateDataService.LoadEstateSettings(regInfo.RegionID, false); 812 MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName);
813 return false;
806 } 814 }
815
816 regInfo.EstateSettings.EstateName = newName;
817
818 // FIXME: Later on, the scene constructor will reload the estate settings no matter what.
819 // Therefore, we need to do an initial save here otherwise the new estate name will be reset
820 // back to the default. The reloading of estate settings by scene could be eliminated if it
821 // knows that the passed in settings in RegionInfo are already valid. Also, it might be
822 // possible to eliminate some additional later saves made by callers of this method.
823 regInfo.EstateSettings.Save();
824
825 return true;
826 }
827
828 /// <summary>
829 /// Load the estate information for the provided RegionInfo object.
830 /// </summary>
831 /// <param name="regInfo"></param>
832 public void PopulateRegionEstateInfo(RegionInfo regInfo)
833 {
834 if (EstateDataService != null)
835 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, false);
807 836
808 if (regInfo.EstateSettings.EstateID == 0) // No record at all 837 if (regInfo.EstateSettings.EstateID == 0) // No record at all
809 { 838 {
810 MainConsole.Instance.Output("Your region is not part of an estate."); 839 MainConsole.Instance.OutputFormat("Region {0} is not part of an estate.", regInfo.RegionName);
840
841 List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll();
842 List<string> estateNames = new List<string>();
843 foreach (EstateSettings estate in estates)
844 estateNames.Add(estate.EstateName);
845
811 while (true) 846 while (true)
812 { 847 {
813 string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List<string>() { "yes", "no" }); 848 if (estates.Count == 0)
814 if (response == "no") 849 {
815 { 850 MainConsole.Instance.Output("No existing estates found. You must create a new one.");
816 // Create a new estate
817 regInfo.EstateSettings = estateDataService.LoadEstateSettings(regInfo.RegionID, true);
818
819 regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
820 851
821 // FIXME: Later on, the scene constructor will reload the estate settings no matter what. 852 if (CreateEstate(regInfo, estateNames))
822 // Therefore, we need to do an initial save here otherwise the new estate name will be reset 853 break;
823 // back to the default. The reloading of estate settings by scene could be eliminated if it 854 else
824 // knows that the passed in settings in RegionInfo are already valid. Also, it might be 855 continue;
825 // possible to eliminate some additional later saves made by callers of this method.
826 regInfo.EstateSettings.Save();
827 break;
828 } 856 }
829 else 857 else
830 { 858 {
831 response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); 859 string response
832 if (response == "None") 860 = MainConsole.Instance.CmdPrompt(
833 continue; 861 string.Format(
834 862 "Do you wish to join region {0} to an existing estate (yes/no)?", regInfo.RegionName),
835 List<int> estateIDs = estateDataService.GetEstates(response); 863 "yes",
836 if (estateIDs.Count < 1) 864 new List<string>() { "yes", "no" });
865
866 if (response == "no")
837 { 867 {
838 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); 868 if (CreateEstate(regInfo, estateNames))
839 continue; 869 break;
870 else
871 continue;
872 }
873 else
874 {
875 response
876 = MainConsole.Instance.CmdPrompt(
877 string.Format(
878 "Name of estate to join. Existing estate names are ({0})", string.Join(", ", estateNames.ToArray())),
879 estateNames[0]);
880
881 List<int> estateIDs = EstateDataService.GetEstates(response);
882 if (estateIDs.Count < 1)
883 {
884 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again.");
885 continue;
886 }
887
888 int estateID = estateIDs[0];
889
890 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID);
891
892 if (EstateDataService.LinkRegion(regInfo.RegionID, estateID))
893 break;
894
895 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
840 } 896 }
841
842 int estateID = estateIDs[0];
843
844 regInfo.EstateSettings = estateDataService.LoadEstateSettings(estateID);
845
846 if (estateDataService.LinkRegion(regInfo.RegionID, estateID))
847 break;
848
849 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
850 } 897 }
851 } 898 }
852 } 899 }
853 } 900 }
854 } 901 }
855
856 902
857 public class OpenSimConfigSource 903 public class OpenSimConfigSource
858 { 904 {
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 2c6795f..8de31d7 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -49,6 +49,8 @@ using Timer = System.Timers.Timer;
49using AssetLandmark = OpenSim.Framework.AssetLandmark; 49using AssetLandmark = OpenSim.Framework.AssetLandmark;
50using Nini.Config; 50using Nini.Config;
51 51
52using System.IO;
53
52namespace OpenSim.Region.ClientStack.LindenUDP 54namespace OpenSim.Region.ClientStack.LindenUDP
53{ 55{
54 public delegate bool PacketMethod(IClientAPI simClient, Packet packet); 56 public delegate bool PacketMethod(IClientAPI simClient, Packet packet);
@@ -298,6 +300,77 @@ namespace OpenSim.Region.ClientStack.LindenUDP
298 /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary> 300 /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary>
299 private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f; 301 private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
300 302
303 // First log file or time has expired, start writing to a new log file
304//<MIC>
305// -----------------------------------------------------------------
306// -----------------------------------------------------------------
307// THIS IS DEBUGGING CODE & SHOULD BE REMOVED
308// -----------------------------------------------------------------
309// -----------------------------------------------------------------
310 public class QueueLogger
311 {
312 public Int32 start = 0;
313 public StreamWriter Log = null;
314 private Dictionary<UUID,int> m_idMap = new Dictionary<UUID,int>();
315
316 public QueueLogger()
317 {
318 DateTime now = DateTime.Now;
319 String fname = String.Format("queue-{0}.log", now.ToString("yyyyMMddHHmmss"));
320 Log = new StreamWriter(fname);
321
322 start = Util.EnvironmentTickCount();
323 }
324
325 public int LookupID(UUID uuid)
326 {
327 int localid;
328 if (! m_idMap.TryGetValue(uuid,out localid))
329 {
330 localid = m_idMap.Count + 1;
331 m_idMap[uuid] = localid;
332 }
333
334 return localid;
335 }
336 }
337
338 public static QueueLogger QueueLog = null;
339
340 // -----------------------------------------------------------------
341 public void LogAvatarUpdateEvent(UUID client, UUID avatar, Int32 timeinqueue)
342 {
343 if (QueueLog == null)
344 QueueLog = new QueueLogger();
345
346 Int32 ticks = Util.EnvironmentTickCountSubtract(QueueLog.start);
347 lock(QueueLog)
348 {
349 int cid = QueueLog.LookupID(client);
350 int aid = QueueLog.LookupID(avatar);
351 QueueLog.Log.WriteLine("{0},AU,AV{1:D4},AV{2:D4},{3}",ticks,cid,aid,timeinqueue);
352 }
353 }
354
355 // -----------------------------------------------------------------
356 public void LogQueueProcessEvent(UUID client, PriorityQueue queue, uint maxup)
357 {
358 if (QueueLog == null)
359 QueueLog = new QueueLogger();
360
361 Int32 ticks = Util.EnvironmentTickCountSubtract(QueueLog.start);
362 lock(QueueLog)
363 {
364 int cid = QueueLog.LookupID(client);
365 QueueLog.Log.WriteLine("{0},PQ,AV{1:D4},{2},{3}",ticks,cid,maxup,queue.ToString());
366 }
367 }
368// -----------------------------------------------------------------
369// -----------------------------------------------------------------
370// -----------------------------------------------------------------
371// -----------------------------------------------------------------
372//</MIC>
373
301 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 374 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
302 protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients 375 protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
303 376
@@ -3547,18 +3620,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3547 3620
3548 #region Primitive Packet/Data Sending Methods 3621 #region Primitive Packet/Data Sending Methods
3549 3622
3623
3550 /// <summary> 3624 /// <summary>
3551 /// Generate one of the object update packets based on PrimUpdateFlags 3625 /// Generate one of the object update packets based on PrimUpdateFlags
3552 /// and broadcast the packet to clients 3626 /// and broadcast the packet to clients
3553 /// </summary> 3627 /// </summary>
3554 public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) 3628 public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
3555 { 3629 {
3556 double priority = m_prioritizer.GetUpdatePriority(this, entity); 3630 //double priority = m_prioritizer.GetUpdatePriority(this, entity);
3631 uint priority = m_prioritizer.GetUpdatePriority(this, entity);
3557 3632
3558 lock (m_entityUpdates.SyncRoot) 3633 lock (m_entityUpdates.SyncRoot)
3559 m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation), entity.LocalId); 3634 m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation));
3560 } 3635 }
3561 3636
3637 private Int32 m_LastQueueFill = 0;
3638 private uint m_maxUpdates = 0;
3639
3562 private void ProcessEntityUpdates(int maxUpdates) 3640 private void ProcessEntityUpdates(int maxUpdates)
3563 { 3641 {
3564 OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>(); 3642 OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
@@ -3566,19 +3644,45 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3566 OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>(); 3644 OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
3567 OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>(); 3645 OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
3568 3646
3569 if (maxUpdates <= 0) maxUpdates = Int32.MaxValue; 3647 if (maxUpdates <= 0)
3648 {
3649 m_maxUpdates = Int32.MaxValue;
3650 }
3651 else
3652 {
3653 if (m_maxUpdates == 0 || m_LastQueueFill == 0)
3654 {
3655 m_maxUpdates = (uint)maxUpdates;
3656 }
3657 else
3658 {
3659 if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200)
3660 m_maxUpdates += 5;
3661 else
3662 m_maxUpdates = m_maxUpdates >> 1;
3663 }
3664 m_maxUpdates = Util.Clamp<uint>(m_maxUpdates,10,500);
3665 }
3666 m_LastQueueFill = Util.EnvironmentTickCount();
3667
3570 int updatesThisCall = 0; 3668 int updatesThisCall = 0;
3571 3669
3670//<MIC>
3671// DEBUGGING CODE... REMOVE
3672// LogQueueProcessEvent(this.m_agentId,m_entityUpdates,m_maxUpdates);
3673//</MIC>
3572 // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race 3674 // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
3573 // condition where a kill can be processed before an out-of-date update for the same object. 3675 // condition where a kill can be processed before an out-of-date update for the same object.
3574 lock (m_killRecord) 3676 lock (m_killRecord)
3575 { 3677 {
3576 float avgTimeDilation = 1.0f; 3678 float avgTimeDilation = 1.0f;
3577 EntityUpdate update; 3679 EntityUpdate update;
3578 while (updatesThisCall < maxUpdates) 3680 Int32 timeinqueue; // this is just debugging code & can be dropped later
3681
3682 while (updatesThisCall < m_maxUpdates)
3579 { 3683 {
3580 lock (m_entityUpdates.SyncRoot) 3684 lock (m_entityUpdates.SyncRoot)
3581 if (!m_entityUpdates.TryDequeue(out update)) 3685 if (!m_entityUpdates.TryDequeue(out update, out timeinqueue))
3582 break; 3686 break;
3583 avgTimeDilation += update.TimeDilation; 3687 avgTimeDilation += update.TimeDilation;
3584 avgTimeDilation *= 0.5f; 3688 avgTimeDilation *= 0.5f;
@@ -3679,36 +3783,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3679 } 3783 }
3680 else 3784 else
3681 { 3785 {
3682 // if (update.Entity is SceneObjectPart && ((SceneObjectPart)update.Entity).IsAttachment) 3786 objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId));
3683 // {
3684 // SceneObjectPart sop = (SceneObjectPart)update.Entity;
3685 // string text = sop.Text;
3686 // if (text.IndexOf("\n") >= 0)
3687 // text = text.Remove(text.IndexOf("\n"));
3688 //
3689 // if (m_attachmentsSent.Contains(sop.ParentID))
3690 // {
3691 //// m_log.DebugFormat(
3692 //// "[CLIENT]: Sending full info about attached prim {0} text {1}",
3693 //// sop.LocalId, text);
3694 //
3695 // objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock(sop, this.m_agentId));
3696 //
3697 // m_attachmentsSent.Add(sop.LocalId);
3698 // }
3699 // else
3700 // {
3701 // m_log.DebugFormat(
3702 // "[CLIENT]: Requeueing full update of prim {0} text {1} since we haven't sent its parent {2} yet",
3703 // sop.LocalId, text, sop.ParentID);
3704 //
3705 // m_entityUpdates.Enqueue(double.MaxValue, update, sop.LocalId);
3706 // }
3707 // }
3708 // else
3709 // {
3710 objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId));
3711 // }
3712 } 3787 }
3713 } 3788 }
3714 else if (!canUseImproved) 3789 else if (!canUseImproved)
@@ -3802,26 +3877,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3802 3877
3803 public void ReprioritizeUpdates() 3878 public void ReprioritizeUpdates()
3804 { 3879 {
3805 //m_log.Debug("[CLIENT]: Reprioritizing prim updates for " + m_firstName + " " + m_lastName);
3806
3807 lock (m_entityUpdates.SyncRoot) 3880 lock (m_entityUpdates.SyncRoot)
3808 m_entityUpdates.Reprioritize(UpdatePriorityHandler); 3881 m_entityUpdates.Reprioritize(UpdatePriorityHandler);
3809 } 3882 }
3810 3883
3811 private bool UpdatePriorityHandler(ref double priority, uint localID) 3884 private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
3812 { 3885 {
3813 EntityBase entity; 3886 if (entity != null)
3814 if (m_scene.Entities.TryGetValue(localID, out entity))
3815 { 3887 {
3816 priority = m_prioritizer.GetUpdatePriority(this, entity); 3888 priority = m_prioritizer.GetUpdatePriority(this, entity);
3889 return true;
3817 } 3890 }
3818 3891
3819 return priority != double.NaN; 3892 return false;
3820 } 3893 }
3821 3894
3822 public void FlushPrimUpdates() 3895 public void FlushPrimUpdates()
3823 { 3896 {
3824 m_log.Debug("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName); 3897 m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName);
3825 3898
3826 while (m_entityUpdates.Count > 0) 3899 while (m_entityUpdates.Count > 0)
3827 ProcessEntityUpdates(-1); 3900 ProcessEntityUpdates(-1);
@@ -4272,8 +4345,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4272 OutPacket(packet, ThrottleOutPacketType.Task); 4345 OutPacket(packet, ThrottleOutPacketType.Task);
4273 } 4346 }
4274 4347
4275 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) 4348 public void SendLandProperties(
4349 int sequence_id, bool snap_selection, int request_result, ILandObject lo,
4350 float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
4276 { 4351 {
4352// m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name);
4353
4354 LandData landData = lo.LandData;
4355
4277 ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage(); 4356 ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage();
4278 4357
4279 updateMessage.AABBMax = landData.AABBMax; 4358 updateMessage.AABBMax = landData.AABBMax;
@@ -4281,15 +4360,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4281 updateMessage.Area = landData.Area; 4360 updateMessage.Area = landData.Area;
4282 updateMessage.AuctionID = landData.AuctionID; 4361 updateMessage.AuctionID = landData.AuctionID;
4283 updateMessage.AuthBuyerID = landData.AuthBuyerID; 4362 updateMessage.AuthBuyerID = landData.AuthBuyerID;
4284
4285 updateMessage.Bitmap = landData.Bitmap; 4363 updateMessage.Bitmap = landData.Bitmap;
4286
4287 updateMessage.Desc = landData.Description; 4364 updateMessage.Desc = landData.Description;
4288 updateMessage.Category = landData.Category; 4365 updateMessage.Category = landData.Category;
4289 updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate); 4366 updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate);
4290 updateMessage.ClaimPrice = landData.ClaimPrice; 4367 updateMessage.ClaimPrice = landData.ClaimPrice;
4291 updateMessage.GroupID = landData.GroupID; 4368 updateMessage.GroupID = landData.GroupID;
4292 updateMessage.GroupPrims = landData.GroupPrims;
4293 updateMessage.IsGroupOwned = landData.IsGroupOwned; 4369 updateMessage.IsGroupOwned = landData.IsGroupOwned;
4294 updateMessage.LandingType = (LandingType) landData.LandingType; 4370 updateMessage.LandingType = (LandingType) landData.LandingType;
4295 updateMessage.LocalID = landData.LocalID; 4371 updateMessage.LocalID = landData.LocalID;
@@ -4310,9 +4386,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4310 updateMessage.Name = landData.Name; 4386 updateMessage.Name = landData.Name;
4311 updateMessage.OtherCleanTime = landData.OtherCleanTime; 4387 updateMessage.OtherCleanTime = landData.OtherCleanTime;
4312 updateMessage.OtherCount = 0; //TODO: Unimplemented 4388 updateMessage.OtherCount = 0; //TODO: Unimplemented
4313 updateMessage.OtherPrims = landData.OtherPrims; 4389 updateMessage.OwnerID = landData.OwnerID;
4314 updateMessage.OwnerID = landData.OwnerID;
4315 updateMessage.OwnerPrims = landData.OwnerPrims;
4316 updateMessage.ParcelFlags = (ParcelFlags) landData.Flags; 4390 updateMessage.ParcelFlags = (ParcelFlags) landData.Flags;
4317 updateMessage.ParcelPrimBonus = simObjectBonusFactor; 4391 updateMessage.ParcelPrimBonus = simObjectBonusFactor;
4318 updateMessage.PassHours = landData.PassHours; 4392 updateMessage.PassHours = landData.PassHours;
@@ -4327,10 +4401,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4327 4401
4328 updateMessage.RentPrice = 0; 4402 updateMessage.RentPrice = 0;
4329 updateMessage.RequestResult = (ParcelResult) request_result; 4403 updateMessage.RequestResult = (ParcelResult) request_result;
4330 updateMessage.SalePrice = landData.SalePrice; 4404 updateMessage.SalePrice = landData.SalePrice;
4331 updateMessage.SelectedPrims = landData.SelectedPrims;
4332 updateMessage.SelfCount = 0; //TODO: Unimplemented 4405 updateMessage.SelfCount = 0; //TODO: Unimplemented
4333 updateMessage.SequenceID = sequence_id; 4406 updateMessage.SequenceID = sequence_id;
4407
4334 if (landData.SimwideArea > 0) 4408 if (landData.SimwideArea > 0)
4335 { 4409 {
4336 int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); 4410 int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
@@ -4340,22 +4414,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4340 { 4414 {
4341 updateMessage.SimWideMaxPrims = 0; 4415 updateMessage.SimWideMaxPrims = 0;
4342 } 4416 }
4343 updateMessage.SimWideTotalPrims = landData.SimwidePrims; 4417
4344 updateMessage.SnapSelection = snap_selection; 4418 updateMessage.SnapSelection = snap_selection;
4345 updateMessage.SnapshotID = landData.SnapshotID; 4419 updateMessage.SnapshotID = landData.SnapshotID;
4346 updateMessage.Status = (ParcelStatus) landData.Status; 4420 updateMessage.Status = (ParcelStatus) landData.Status;
4347 updateMessage.TotalPrims = landData.OwnerPrims + landData.GroupPrims + landData.OtherPrims + 4421 updateMessage.UserLocation = landData.UserLocation;
4348 landData.SelectedPrims; 4422 updateMessage.UserLookAt = landData.UserLookAt;
4349 updateMessage.UserLocation = landData.UserLocation; 4423
4350 updateMessage.UserLookAt = landData.UserLookAt; 4424 updateMessage.MediaType = landData.MediaType;
4351 4425 updateMessage.MediaDesc = landData.MediaDescription;
4352 updateMessage.MediaType = landData.MediaType; 4426 updateMessage.MediaWidth = landData.MediaWidth;
4353 updateMessage.MediaDesc = landData.MediaDescription; 4427 updateMessage.MediaHeight = landData.MediaHeight;
4354 updateMessage.MediaWidth = landData.MediaWidth; 4428 updateMessage.MediaLoop = landData.MediaLoop;
4355 updateMessage.MediaHeight = landData.MediaHeight; 4429 updateMessage.ObscureMusic = landData.ObscureMusic;
4356 updateMessage.MediaLoop = landData.MediaLoop; 4430 updateMessage.ObscureMedia = landData.ObscureMedia;
4357 updateMessage.ObscureMusic = landData.ObscureMusic; 4431
4358 updateMessage.ObscureMedia = landData.ObscureMedia; 4432 IPrimCounts pc = lo.PrimCounts;
4433 updateMessage.OwnerPrims = pc.Owner;
4434 updateMessage.GroupPrims = pc.Group;
4435 updateMessage.OtherPrims = pc.Others;
4436 updateMessage.SelectedPrims = pc.Selected;
4437 updateMessage.TotalPrims = pc.Total;
4438 updateMessage.SimWideTotalPrims = pc.Simulator;
4359 4439
4360 try 4440 try
4361 { 4441 {
@@ -4363,13 +4443,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4363 if (eq != null) 4443 if (eq != null)
4364 { 4444 {
4365 eq.ParcelProperties(updateMessage, this.AgentId); 4445 eq.ParcelProperties(updateMessage, this.AgentId);
4366 } else { 4446 }
4367 m_log.Warn("No EQ Interface when sending parcel data."); 4447 else
4448 {
4449 m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data.");
4368 } 4450 }
4369 } 4451 }
4370 catch (Exception ex) 4452 catch (Exception ex)
4371 { 4453 {
4372 m_log.Error("Unable to send parcel data via eventqueue - exception: " + ex.ToString()); 4454 m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString());
4373 } 4455 }
4374 } 4456 }
4375 4457
@@ -4929,7 +5011,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4929 AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest); 5011 AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
4930 AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false); 5012 AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
4931 AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest); 5013 AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest);
4932 AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest, false); 5014 AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
4933 AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false); 5015 AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
4934 AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false); 5016 AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
4935 AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false); 5017 AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
@@ -8800,13 +8882,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP
8800 case "instantmessage": 8882 case "instantmessage":
8801 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) 8883 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
8802 { 8884 {
8803 if (messagePacket.ParamList.Length < 5) 8885 if (messagePacket.ParamList.Length < 2)
8804 return true; 8886 return true;
8887
8805 UUID invoice = messagePacket.MethodData.Invoice; 8888 UUID invoice = messagePacket.MethodData.Invoice;
8806 UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
8807 string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
8808 string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
8809 UUID sessionID = messagePacket.AgentData.SessionID; 8889 UUID sessionID = messagePacket.AgentData.SessionID;
8890
8891 UUID SenderID;
8892 string SenderName;
8893 string Message;
8894
8895 if (messagePacket.ParamList.Length < 5)
8896 {
8897 SenderID = AgentId;
8898 SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
8899 Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
8900 }
8901 else
8902 {
8903 SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
8904 SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
8905 Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
8906 }
8907
8810 OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message); 8908 OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
8811 } 8909 }
8812 return true; 8910 return true;
@@ -11701,171 +11799,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11701 OutPacket(pack, ThrottleOutPacketType.Task); 11799 OutPacket(pack, ThrottleOutPacketType.Task);
11702 } 11800 }
11703 11801
11704 #region PriorityQueue
11705 public class PriorityQueue
11706 {
11707 internal delegate bool UpdatePriorityHandler(ref double priority, uint local_id);
11708
11709 private MinHeap<MinHeapItem>[] m_heaps = new MinHeap<MinHeapItem>[1];
11710 private Dictionary<uint, LookupItem> m_lookupTable;
11711 private Comparison<double> m_comparison;
11712 private object m_syncRoot = new object();
11713
11714 internal PriorityQueue() :
11715 this(MinHeap<MinHeapItem>.DEFAULT_CAPACITY, Comparer<double>.Default) { }
11716 internal PriorityQueue(int capacity) :
11717 this(capacity, Comparer<double>.Default) { }
11718 internal PriorityQueue(IComparer<double> comparer) :
11719 this(new Comparison<double>(comparer.Compare)) { }
11720 internal PriorityQueue(Comparison<double> comparison) :
11721 this(MinHeap<MinHeapItem>.DEFAULT_CAPACITY, comparison) { }
11722 internal PriorityQueue(int capacity, IComparer<double> comparer) :
11723 this(capacity, new Comparison<double>(comparer.Compare)) { }
11724 internal PriorityQueue(int capacity, Comparison<double> comparison)
11725 {
11726 m_lookupTable = new Dictionary<uint, LookupItem>(capacity);
11727
11728 for (int i = 0; i < m_heaps.Length; ++i)
11729 m_heaps[i] = new MinHeap<MinHeapItem>(capacity);
11730 this.m_comparison = comparison;
11731 }
11732
11733 public object SyncRoot { get { return this.m_syncRoot; } }
11734 internal int Count
11735 {
11736 get
11737 {
11738 int count = 0;
11739 for (int i = 0; i < m_heaps.Length; ++i)
11740 count = m_heaps[i].Count;
11741 return count;
11742 }
11743 }
11744
11745 public bool Enqueue(double priority, EntityUpdate value, uint local_id)
11746 {
11747 LookupItem item;
11748
11749 if (m_lookupTable.TryGetValue(local_id, out item))
11750 {
11751 // Combine flags
11752 value.Flags |= item.Heap[item.Handle].Value.Flags;
11753
11754 item.Heap[item.Handle] = new MinHeapItem(priority, value, local_id, this.m_comparison);
11755 return false;
11756 }
11757 else
11758 {
11759 item.Heap = m_heaps[0];
11760 item.Heap.Add(new MinHeapItem(priority, value, local_id, this.m_comparison), ref item.Handle);
11761 m_lookupTable.Add(local_id, item);
11762 return true;
11763 }
11764 }
11765
11766 internal EntityUpdate Peek()
11767 {
11768 for (int i = 0; i < m_heaps.Length; ++i)
11769 if (m_heaps[i].Count > 0)
11770 return m_heaps[i].Min().Value;
11771 throw new InvalidOperationException(string.Format("The {0} is empty", this.GetType().ToString()));
11772 }
11773
11774 internal bool TryDequeue(out EntityUpdate value)
11775 {
11776 for (int i = 0; i < m_heaps.Length; ++i)
11777 {
11778 if (m_heaps[i].Count > 0)
11779 {
11780 MinHeapItem item = m_heaps[i].RemoveMin();
11781 m_lookupTable.Remove(item.LocalID);
11782 value = item.Value;
11783 return true;
11784 }
11785 }
11786
11787 value = default(EntityUpdate);
11788 return false;
11789 }
11790
11791 internal void Reprioritize(UpdatePriorityHandler handler)
11792 {
11793 MinHeapItem item;
11794 double priority;
11795
11796 foreach (LookupItem lookup in new List<LookupItem>(this.m_lookupTable.Values))
11797 {
11798 if (lookup.Heap.TryGetValue(lookup.Handle, out item))
11799 {
11800 priority = item.Priority;
11801 if (handler(ref priority, item.LocalID))
11802 {
11803 if (lookup.Heap.ContainsHandle(lookup.Handle))
11804 lookup.Heap[lookup.Handle] =
11805 new MinHeapItem(priority, item.Value, item.LocalID, this.m_comparison);
11806 }
11807 else
11808 {
11809 m_log.Warn("[LLCLIENTVIEW]: UpdatePriorityHandler returned false, dropping update");
11810 lookup.Heap.Remove(lookup.Handle);
11811 this.m_lookupTable.Remove(item.LocalID);
11812 }
11813 }
11814 }
11815 }
11816
11817 #region MinHeapItem
11818 private struct MinHeapItem : IComparable<MinHeapItem>
11819 {
11820 private double priority;
11821 private EntityUpdate value;
11822 private uint local_id;
11823 private Comparison<double> comparison;
11824
11825 internal MinHeapItem(double priority, EntityUpdate value, uint local_id) :
11826 this(priority, value, local_id, Comparer<double>.Default) { }
11827 internal MinHeapItem(double priority, EntityUpdate value, uint local_id, IComparer<double> comparer) :
11828 this(priority, value, local_id, new Comparison<double>(comparer.Compare)) { }
11829 internal MinHeapItem(double priority, EntityUpdate value, uint local_id, Comparison<double> comparison)
11830 {
11831 this.priority = priority;
11832 this.value = value;
11833 this.local_id = local_id;
11834 this.comparison = comparison;
11835 }
11836
11837 internal double Priority { get { return this.priority; } }
11838 internal EntityUpdate Value { get { return this.value; } }
11839 internal uint LocalID { get { return this.local_id; } }
11840
11841 public override string ToString()
11842 {
11843 StringBuilder sb = new StringBuilder();
11844 sb.Append("[");
11845 sb.Append(this.priority.ToString());
11846 sb.Append(",");
11847 if (this.value != null)
11848 sb.Append(this.value.ToString());
11849 sb.Append("]");
11850 return sb.ToString();
11851 }
11852
11853 public int CompareTo(MinHeapItem other)
11854 {
11855 return this.comparison(this.priority, other.priority);
11856 }
11857 }
11858 #endregion
11859
11860 #region LookupItem
11861 private struct LookupItem
11862 {
11863 internal MinHeap<MinHeapItem> Heap;
11864 internal IHandle Handle;
11865 }
11866 #endregion
11867 }
11868
11869 public struct PacketProcessor 11802 public struct PacketProcessor
11870 { 11803 {
11871 public PacketMethod method; 11804 public PacketMethod method;
@@ -11886,8 +11819,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11886 } 11819 }
11887 } 11820 }
11888 11821
11889 #endregion
11890
11891 public static OSD BuildEvent(string eventName, OSD eventBody) 11822 public static OSD BuildEvent(string eventName, OSD eventBody)
11892 { 11823 {
11893 OSDMap osdEvent = new OSDMap(2); 11824 OSDMap osdEvent = new OSDMap(2);
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index 65a8fe3..9a8bfd3 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -149,7 +149,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
149 /// <summary>Caches packed throttle information</summary> 149 /// <summary>Caches packed throttle information</summary>
150 private byte[] m_packedThrottles; 150 private byte[] m_packedThrottles;
151 151
152 private int m_defaultRTO = 3000; 152 private int m_defaultRTO = 1000; // 1sec is the recommendation in the RFC
153 private int m_maxRTO = 60000; 153 private int m_maxRTO = 60000;
154 154
155 /// <summary> 155 /// <summary>
@@ -557,7 +557,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
557 int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR)); 557 int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR));
558 558
559 // Clamp the retransmission timeout to manageable values 559 // Clamp the retransmission timeout to manageable values
560 rto = Utils.Clamp(RTO, m_defaultRTO, m_maxRTO); 560 rto = Utils.Clamp(rto, m_defaultRTO, m_maxRTO);
561 561
562 RTO = rto; 562 RTO = rto;
563 563
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
index d2779ba..6eebd9d 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
@@ -100,6 +100,10 @@ namespace OpenMetaverse
100 const int SIO_UDP_CONNRESET = -1744830452; 100 const int SIO_UDP_CONNRESET = -1744830452;
101 101
102 IPEndPoint ipep = new IPEndPoint(m_localBindAddress, m_udpPort); 102 IPEndPoint ipep = new IPEndPoint(m_localBindAddress, m_udpPort);
103
104 m_log.DebugFormat(
105 "[UDPBASE]: Binding UDP listener using internal IP address config {0}:{1}",
106 ipep.Address, ipep.Port);
103 107
104 m_udpSocket = new Socket( 108 m_udpSocket = new Socket(
105 AddressFamily.InterNetwork, 109 AddressFamily.InterNetwork,
diff --git a/OpenSim/Region/ClientStack/LindenUDP/PriorityQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/PriorityQueue.cs
new file mode 100644
index 0000000..364ce4b
--- /dev/null
+++ b/OpenSim/Region/ClientStack/LindenUDP/PriorityQueue.cs
@@ -0,0 +1,245 @@
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 System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32
33using OpenSim.Framework;
34using OpenSim.Framework.Client;
35using log4net;
36
37namespace OpenSim.Region.ClientStack.LindenUDP
38{
39 public class PriorityQueue
40 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42
43 internal delegate bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity);
44
45 // Heap[0] for self updates
46 // Heap[1..12] for entity updates
47
48 internal const uint m_numberOfQueues = 12;
49
50 private MinHeap<MinHeapItem>[] m_heaps = new MinHeap<MinHeapItem>[m_numberOfQueues];
51 private Dictionary<uint, LookupItem> m_lookupTable;
52 private uint m_nextQueue = 0;
53 private UInt64 m_nextRequest = 0;
54
55 private object m_syncRoot = new object();
56 public object SyncRoot {
57 get { return this.m_syncRoot; }
58 }
59
60 internal PriorityQueue() : this(MinHeap<MinHeapItem>.DEFAULT_CAPACITY) { }
61
62 internal PriorityQueue(int capacity)
63 {
64 m_lookupTable = new Dictionary<uint, LookupItem>(capacity);
65
66 for (int i = 0; i < m_heaps.Length; ++i)
67 m_heaps[i] = new MinHeap<MinHeapItem>(capacity);
68 }
69
70 internal int Count
71 {
72 get
73 {
74 int count = 0;
75 for (int i = 0; i < m_heaps.Length; ++i)
76 count += m_heaps[i].Count;
77 return count;
78 }
79 }
80
81 public bool Enqueue(uint pqueue, EntityUpdate value)
82 {
83 LookupItem lookup;
84
85 uint localid = value.Entity.LocalId;
86 UInt64 entry = m_nextRequest++;
87 if (m_lookupTable.TryGetValue(localid, out lookup))
88 {
89 entry = lookup.Heap[lookup.Handle].EntryOrder;
90 value.Flags |= lookup.Heap[lookup.Handle].Value.Flags;
91 lookup.Heap.Remove(lookup.Handle);
92 }
93
94 pqueue = Util.Clamp<uint>(pqueue, 0, m_numberOfQueues - 1);
95 lookup.Heap = m_heaps[pqueue];
96 lookup.Heap.Add(new MinHeapItem(pqueue, entry, value), ref lookup.Handle);
97 m_lookupTable[localid] = lookup;
98
99 return true;
100 }
101
102 internal bool TryDequeue(out EntityUpdate value, out Int32 timeinqueue)
103 {
104 for (int i = 0; i < m_numberOfQueues; ++i)
105 {
106 // To get the fair queing, we cycle through each of the
107 // queues when finding an element to dequeue, this code
108 // assumes that the distribution of updates in the queues
109 // is polynomial, probably quadractic (eg distance of PI * R^2)
110 uint h = (uint)((m_nextQueue + i) % m_numberOfQueues);
111 if (m_heaps[h].Count > 0)
112 {
113 m_nextQueue = (uint)((h + 1) % m_numberOfQueues);
114
115 MinHeapItem item = m_heaps[h].RemoveMin();
116 m_lookupTable.Remove(item.Value.Entity.LocalId);
117 timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime);
118 value = item.Value;
119
120 return true;
121 }
122 }
123
124 timeinqueue = 0;
125 value = default(EntityUpdate);
126 return false;
127 }
128
129 internal void Reprioritize(UpdatePriorityHandler handler)
130 {
131 MinHeapItem item;
132 foreach (LookupItem lookup in new List<LookupItem>(this.m_lookupTable.Values))
133 {
134 if (lookup.Heap.TryGetValue(lookup.Handle, out item))
135 {
136 uint pqueue = item.PriorityQueue;
137 uint localid = item.Value.Entity.LocalId;
138
139 if (handler(ref pqueue, item.Value.Entity))
140 {
141 // unless the priority queue has changed, there is no need to modify
142 // the entry
143 pqueue = Util.Clamp<uint>(pqueue, 0, m_numberOfQueues - 1);
144 if (pqueue != item.PriorityQueue)
145 {
146 lookup.Heap.Remove(lookup.Handle);
147
148 LookupItem litem = lookup;
149 litem.Heap = m_heaps[pqueue];
150 litem.Heap.Add(new MinHeapItem(pqueue, item), ref litem.Handle);
151 m_lookupTable[localid] = litem;
152 }
153 }
154 else
155 {
156 // m_log.WarnFormat("[PQUEUE]: UpdatePriorityHandler returned false for {0}",item.Value.Entity.UUID);
157 lookup.Heap.Remove(lookup.Handle);
158 this.m_lookupTable.Remove(localid);
159 }
160 }
161 }
162 }
163
164 public override string ToString()
165 {
166 string s = "";
167 for (int i = 0; i < m_numberOfQueues; i++)
168 {
169 if (s != "") s += ",";
170 s += m_heaps[i].Count.ToString();
171 }
172 return s;
173 }
174
175#region MinHeapItem
176 private struct MinHeapItem : IComparable<MinHeapItem>
177 {
178 private EntityUpdate value;
179 internal EntityUpdate Value {
180 get {
181 return this.value;
182 }
183 }
184
185 private uint pqueue;
186 internal uint PriorityQueue {
187 get {
188 return this.pqueue;
189 }
190 }
191
192 private Int32 entrytime;
193 internal Int32 EntryTime {
194 get {
195 return this.entrytime;
196 }
197 }
198
199 private UInt64 entryorder;
200 internal UInt64 EntryOrder
201 {
202 get {
203 return this.entryorder;
204 }
205 }
206
207 internal MinHeapItem(uint pqueue, MinHeapItem other)
208 {
209 this.entrytime = other.entrytime;
210 this.entryorder = other.entryorder;
211 this.value = other.value;
212 this.pqueue = pqueue;
213 }
214
215 internal MinHeapItem(uint pqueue, UInt64 entryorder, EntityUpdate value)
216 {
217 this.entrytime = Util.EnvironmentTickCount();
218 this.entryorder = entryorder;
219 this.value = value;
220 this.pqueue = pqueue;
221 }
222
223 public override string ToString()
224 {
225 return String.Format("[{0},{1},{2}]",pqueue,entryorder,value.Entity.LocalId);
226 }
227
228 public int CompareTo(MinHeapItem other)
229 {
230 // I'm assuming that the root part of an SOG is added to the update queue
231 // before the component parts
232 return Comparer<UInt64>.Default.Compare(this.EntryOrder, other.EntryOrder);
233 }
234 }
235#endregion
236
237#region LookupItem
238 private struct LookupItem
239 {
240 internal MinHeap<MinHeapItem> Heap;
241 internal IHandle Handle;
242 }
243#endregion
244 }
245}
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
index a5fcb49..0babeb5 100644
--- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using Nini.Config; 30using Nini.Config;
31using OpenSim.Framework;
31using OpenSim.Region.Framework.Interfaces; 32using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
33using OpenMetaverse; 34using OpenMetaverse;
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 9b98de3..01170aa 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -77,7 +77,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
77 /// </value> 77 /// </value>
78 private Stream m_loadStream; 78 private Stream m_loadStream;
79 79
80 protected bool m_controlFileLoaded; 80 /// <summary>
81 /// FIXME: Do not perform this check since older versions of OpenSim do save the control file after other things
82 /// (I thought they weren't). We will need to bump the version number and perform this check on all
83 /// subsequent IAR versions only
84 /// </summary>
85 protected bool m_controlFileLoaded = true;
81 protected bool m_assetsLoaded; 86 protected bool m_assetsLoaded;
82 protected bool m_inventoryNodesLoaded; 87 protected bool m_inventoryNodesLoaded;
83 88
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 798547a..73b0a35 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Xml;
31using System.Reflection; 32using System.Reflection;
32using System.Threading; 33using System.Threading;
33 34
@@ -205,11 +206,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
205 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, 206 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
206 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient) 207 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient)
207 { 208 {
208 // HACK: This is only working for lists containing a single item!
209 // It's just a hack to make this WIP compile and run. Nothing
210 // currently calls this with multiple items.
211 UUID ret = UUID.Zero; 209 UUID ret = UUID.Zero;
212 210
211 // The following code groups the SOG's by owner. No objects
212 // belonging to different people can be coalesced, for obvious
213 // reasons.
213 Dictionary<UUID, List<SceneObjectGroup>> deletes = 214 Dictionary<UUID, List<SceneObjectGroup>> deletes =
214 new Dictionary<UUID, List<SceneObjectGroup>>(); 215 new Dictionary<UUID, List<SceneObjectGroup>>();
215 216
@@ -221,262 +222,329 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
221 deletes[g.OwnerID].Add(g); 222 deletes[g.OwnerID].Add(g);
222 } 223 }
223 224
225 // This is pethod scoped and will be returned. It will be the
226 // last created asset id
227 UUID assetID = UUID.Zero;
228
229 // Each iteration is really a separate asset being created,
230 // with distinct destinations as well.
224 foreach (List<SceneObjectGroup> objlist in deletes.Values) 231 foreach (List<SceneObjectGroup> objlist in deletes.Values)
225 { 232 {
226 foreach (SceneObjectGroup g in objlist) 233 Dictionary<UUID, string> xmlStrings =
227 ret = DeleteToInventory(action, folderID, g, remoteClient); 234 new Dictionary<UUID, string>();
228 }
229 235
230 return ret; 236 foreach (SceneObjectGroup objectGroup in objlist)
231 } 237 {
238 Vector3 inventoryStoredPosition = new Vector3
239 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
240 ? 250
241 : objectGroup.AbsolutePosition.X)
242 ,
243 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
244 ? 250
245 : objectGroup.AbsolutePosition.X,
246 objectGroup.AbsolutePosition.Z);
232 247
233 private UUID DeleteToInventory(DeRezAction action, UUID folderID, 248 Vector3 originalPosition = objectGroup.AbsolutePosition;
234 SceneObjectGroup objectGroup, IClientAPI remoteClient)
235 {
236 UUID assetID = UUID.Zero;
237 249
238 Vector3 inventoryStoredPosition = new Vector3 250 objectGroup.AbsolutePosition = inventoryStoredPosition;
239 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
240 ? 250
241 : objectGroup.AbsolutePosition.X)
242 ,
243 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
244 ? 250
245 : objectGroup.AbsolutePosition.X,
246 objectGroup.AbsolutePosition.Z);
247 251
248 Vector3 originalPosition = objectGroup.AbsolutePosition; 252 // Make sure all bits but the ones we want are clear
253 // on take.
254 // This will be applied to the current perms, so
255 // it will do what we want.
256 objectGroup.RootPart.NextOwnerMask &=
257 ((uint)PermissionMask.Copy |
258 (uint)PermissionMask.Transfer |
259 (uint)PermissionMask.Modify);
260 objectGroup.RootPart.NextOwnerMask |=
261 (uint)PermissionMask.Move;
249 262
250 objectGroup.AbsolutePosition = inventoryStoredPosition; 263 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
251 264
252 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); 265 objectGroup.AbsolutePosition = originalPosition;
253 266
254 objectGroup.AbsolutePosition = originalPosition; 267 xmlStrings[objectGroup.UUID] = sceneObjectXml;
268 }
255 269
256 // Get the user info of the item destination 270 string itemXml;
257 //
258 UUID userID = UUID.Zero;
259 271
260 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || 272 if (objlist.Count > 1)
261 action == DeRezAction.SaveToExistingUserInventoryItem) 273 {
262 { 274 float minX, minY, minZ;
263 // Take or take copy require a taker 275 float maxX, maxY, maxZ;
264 // Saving changes requires a local user
265 //
266 if (remoteClient == null)
267 return UUID.Zero;
268 276
269 userID = remoteClient.AgentId; 277 Vector3[] offsets = m_Scene.GetCombinedBoundingBox(objlist,
270 } 278 out minX, out maxX, out minY, out maxY,
271 else 279 out minZ, out maxZ);
272 {
273 // All returns / deletes go to the object owner
274 //
275 280
276 userID = objectGroup.RootPart.OwnerID; 281 // CreateWrapper
277 } 282 XmlDocument itemDoc = new XmlDocument();
283 XmlElement root = itemDoc.CreateElement("", "CoalescedObject", "");
284 itemDoc.AppendChild(root);
278 285
279 if (userID == UUID.Zero) // Can't proceed 286 // Embed the offsets into the group XML
280 { 287 for ( int i = 0 ; i < objlist.Count ; i++ )
281 return UUID.Zero; 288 {
282 } 289 XmlDocument doc = new XmlDocument();
290 SceneObjectGroup g = objlist[i];
291 doc.LoadXml(xmlStrings[g.UUID]);
292 XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup");
293 e.SetAttribute("offsetx", offsets[i].X.ToString());
294 e.SetAttribute("offsety", offsets[i].Y.ToString());
295 e.SetAttribute("offsetz", offsets[i].Z.ToString());
296
297 XmlNode objectNode = itemDoc.ImportNode(e, true);
298 root.AppendChild(objectNode);
299 }
283 300
284 // If we're returning someone's item, it goes back to the 301 float sizeX = maxX - minX;
285 // owner's Lost And Found folder. 302 float sizeY = maxY - minY;
286 // Delete is treated like return in this case 303 float sizeZ = maxZ - minZ;
287 // Deleting your own items makes them go to trash
288 //
289 304
290 InventoryFolderBase folder = null; 305 root.SetAttribute("x", sizeX.ToString());
291 InventoryItemBase item = null; 306 root.SetAttribute("y", sizeY.ToString());
307 root.SetAttribute("z", sizeZ.ToString());
292 308
293 if (DeRezAction.SaveToExistingUserInventoryItem == action) 309 itemXml = itemDoc.InnerXml;
294 { 310 }
295 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); 311 else
296 item = m_Scene.InventoryService.GetItem(item); 312 {
313 itemXml = xmlStrings[objlist[0].UUID];
314 }
315
316 // Get the user info of the item destination
317 //
318 UUID userID = UUID.Zero;
319
320 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
321 action == DeRezAction.SaveToExistingUserInventoryItem)
322 {
323 // Take or take copy require a taker
324 // Saving changes requires a local user
325 //
326 if (remoteClient == null)
327 return UUID.Zero;
328
329 userID = remoteClient.AgentId;
330 }
331 else
332 {
333 // All returns / deletes go to the object owner
334 //
297 335
298 //item = userInfo.RootFolder.FindItem( 336 userID = objlist[0].RootPart.OwnerID;
299 // objectGroup.RootPart.FromUserInventoryItemID); 337 }
300 338
301 if (null == item) 339 if (userID == UUID.Zero) // Can't proceed
302 { 340 {
303 m_log.DebugFormat(
304 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
305 objectGroup.Name, objectGroup.UUID);
306 return UUID.Zero; 341 return UUID.Zero;
307 } 342 }
308 } 343
309 else 344 // If we're returning someone's item, it goes back to the
310 { 345 // owner's Lost And Found folder.
311 // Folder magic 346 // Delete is treated like return in this case
347 // Deleting your own items makes them go to trash
312 // 348 //
313 if (action == DeRezAction.Delete) 349
350 InventoryFolderBase folder = null;
351 InventoryItemBase item = null;
352
353 if (DeRezAction.SaveToExistingUserInventoryItem == action)
314 { 354 {
315 // Deleting someone else's item 355 item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID);
316 // 356 item = m_Scene.InventoryService.GetItem(item);
317 if (remoteClient == null ||
318 objectGroup.OwnerID != remoteClient.AgentId)
319 {
320 357
321 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 358 //item = userInfo.RootFolder.FindItem(
322 } 359 // objectGroup.RootPart.FromUserInventoryItemID);
323 else 360
361 if (null == item)
324 { 362 {
325 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); 363 m_log.DebugFormat(
364 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
365 objlist[0].Name, objlist[0].UUID);
366 return UUID.Zero;
326 } 367 }
327 } 368 }
328 else if (action == DeRezAction.Return) 369 else
329 { 370 {
330 371 // Folder magic
331 // Dump to lost + found unconditionally
332 // 372 //
333 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
334 }
335
336 if (folderID == UUID.Zero && folder == null)
337 {
338 if (action == DeRezAction.Delete) 373 if (action == DeRezAction.Delete)
339 { 374 {
340 // Deletes go to trash by default 375 // Deleting someone else's item
341 // 376 //
342 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
343 }
344 else
345 {
346 if (remoteClient == null || 377 if (remoteClient == null ||
347 objectGroup.OwnerID != remoteClient.AgentId) 378 objlist[0].OwnerID != remoteClient.AgentId)
348 { 379 {
349 // Taking copy of another person's item. Take to 380
350 // Objects folder. 381 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
351 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
352 } 382 }
353 else 383 else
354 { 384 {
355 // Catch all. Use lost & found 385 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
386 }
387 }
388 else if (action == DeRezAction.Return)
389 {
390
391 // Dump to lost + found unconditionally
392 //
393 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
394 }
395
396 if (folderID == UUID.Zero && folder == null)
397 {
398 if (action == DeRezAction.Delete)
399 {
400 // Deletes go to trash by default
356 // 401 //
402 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
403 }
404 else
405 {
406 if (remoteClient == null ||
407 objlist[0].OwnerID != remoteClient.AgentId)
408 {
409 // Taking copy of another person's item. Take to
410 // Objects folder.
411 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object);
412 }
413 else
414 {
415 // Catch all. Use lost & found
416 //
357 417
358 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); 418 folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
419 }
359 } 420 }
360 } 421 }
361 }
362 422
363 // Override and put into where it came from, if it came 423 // Override and put into where it came from, if it came
364 // from anywhere in inventory 424 // from anywhere in inventory
365 // 425 //
366 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) 426 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
367 {
368 if (objectGroup.RootPart.FromFolderID != UUID.Zero)
369 { 427 {
370 InventoryFolderBase f = new InventoryFolderBase(objectGroup.RootPart.FromFolderID, userID); 428 if (objlist[0].RootPart.FromFolderID != UUID.Zero)
371 folder = m_Scene.InventoryService.GetFolder(f); 429 {
430 InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID);
431 folder = m_Scene.InventoryService.GetFolder(f);
432 }
372 } 433 }
373 }
374 434
375 if (folder == null) // None of the above 435 if (folder == null) // None of the above
376 { 436 {
377 folder = new InventoryFolderBase(folderID); 437 folder = new InventoryFolderBase(folderID);
378 438
379 if (folder == null) // Nowhere to put it 439 if (folder == null) // Nowhere to put it
440 {
441 return UUID.Zero;
442 }
443 }
444
445 item = new InventoryItemBase();
446 // Can't know creator is the same, so null it in inventory
447 if (objlist.Count > 1)
448 item.CreatorId = UUID.Zero.ToString();
449 else
450 item.CreatorId = objlist[0].RootPart.CreatorID.ToString();
451 item.ID = UUID.Random();
452 item.InvType = (int)InventoryType.Object;
453 item.Folder = folder.ID;
454 item.Owner = userID;
455 if (objlist.Count > 1)
380 { 456 {
381 return UUID.Zero; 457 item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems;
458 }
459 else
460 {
461 item.SaleType = objlist[0].RootPart.ObjectSaleType;
462 item.SalePrice = objlist[0].RootPart.SalePrice;
382 } 463 }
383 } 464 }
384 465
385 item = new InventoryItemBase(); 466 AssetBase asset = CreateAsset(
386 item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); 467 objlist[0].GetPartName(objlist[0].RootPart.LocalId),
387 item.CreatorData = objectGroup.RootPart.CreatorData; 468 objlist[0].GetPartDescription(objlist[0].RootPart.LocalId),
388 item.ID = UUID.Random(); 469 (sbyte)AssetType.Object,
389 item.InvType = (int)InventoryType.Object; 470 Utils.StringToBytes(itemXml),
390 item.Folder = folder.ID; 471 objlist[0].OwnerID.ToString());
391 item.Owner = userID; 472 m_Scene.AssetService.Store(asset);
392 } 473 assetID = asset.FullID;
393
394 AssetBase asset = CreateAsset(
395 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
396 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
397 (sbyte)AssetType.Object,
398 Utils.StringToBytes(sceneObjectXml),
399 objectGroup.OwnerID.ToString());
400 m_Scene.AssetService.Store(asset);
401 assetID = asset.FullID;
402
403 if (DeRezAction.SaveToExistingUserInventoryItem == action)
404 {
405 item.AssetID = asset.FullID;
406 m_Scene.InventoryService.UpdateItem(item);
407 }
408 else
409 {
410 item.AssetID = asset.FullID;
411 474
412 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 475 if (DeRezAction.SaveToExistingUserInventoryItem == action)
413 { 476 {
414 uint perms = objectGroup.GetEffectivePermissions(); 477 item.AssetID = asset.FullID;
415 uint nextPerms = (perms & 7) << 13; 478 m_Scene.InventoryService.UpdateItem(item);
416 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
417 perms &= ~(uint)PermissionMask.Copy;
418 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
419 perms &= ~(uint)PermissionMask.Transfer;
420 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
421 perms &= ~(uint)PermissionMask.Modify;
422
423 // Make sure all bits but the ones we want are clear
424 // on take.
425 // This will be applied to the current perms, so
426 // it will do what we want.
427 objectGroup.RootPart.NextOwnerMask &=
428 ((uint)PermissionMask.Copy |
429 (uint)PermissionMask.Transfer |
430 (uint)PermissionMask.Modify);
431 objectGroup.RootPart.NextOwnerMask |=
432 (uint)PermissionMask.Move;
433
434 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
435 item.CurrentPermissions = item.BasePermissions;
436 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
437 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
438 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
439
440 item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
441 } 479 }
442 else 480 else
443 { 481 {
444 item.BasePermissions = objectGroup.GetEffectivePermissions(); 482 item.AssetID = asset.FullID;
445 item.CurrentPermissions = objectGroup.GetEffectivePermissions();
446 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
447 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
448 item.GroupPermissions = objectGroup.RootPart.GroupMask;
449 483
450 item.CurrentPermissions &= 484 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7;
451 ((uint)PermissionMask.Copy | 485 foreach (SceneObjectGroup grp in objlist)
452 (uint)PermissionMask.Transfer | 486 effectivePerms &= grp.GetEffectivePermissions();
453 (uint)PermissionMask.Modify | 487 effectivePerms |= (uint)PermissionMask.Move;
454 (uint)PermissionMask.Move |
455 7); // Preserve folded permissions
456 }
457 488
458 // TODO: add the new fields (Flags, Sale info, etc) 489 if (remoteClient != null && (remoteClient.AgentId != objlist[0].RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
459 item.CreationDate = Util.UnixTimeSinceEpoch(); 490 {
460 item.Description = asset.Description; 491 uint perms = effectivePerms;
461 item.Name = asset.Name; 492 uint nextPerms = (perms & 7) << 13;
462 item.AssetType = asset.Type; 493 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
494 perms &= ~(uint)PermissionMask.Copy;
495 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
496 perms &= ~(uint)PermissionMask.Transfer;
497 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
498 perms &= ~(uint)PermissionMask.Modify;
499
500 item.BasePermissions = perms & objlist[0].RootPart.NextOwnerMask;
501 item.CurrentPermissions = item.BasePermissions;
502 item.NextPermissions = perms & objlist[0].RootPart.NextOwnerMask;
503 item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & objlist[0].RootPart.NextOwnerMask;
504 item.GroupPermissions = objlist[0].RootPart.GroupMask & objlist[0].RootPart.NextOwnerMask;
505
506 // Magic number badness. Maybe this deserves an enum.
507 // bit 4 (16) is the "Slam" bit, it means treat as passed
508 // and apply next owner perms on rez
509 item.CurrentPermissions |= 16; // Slam!
510 }
511 else
512 {
513 item.BasePermissions = effectivePerms;
514 item.CurrentPermissions = effectivePerms;
515 item.NextPermissions = objlist[0].RootPart.NextOwnerMask & effectivePerms;
516 item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & effectivePerms;
517 item.GroupPermissions = objlist[0].RootPart.GroupMask & effectivePerms;
518
519 item.CurrentPermissions &=
520 ((uint)PermissionMask.Copy |
521 (uint)PermissionMask.Transfer |
522 (uint)PermissionMask.Modify |
523 (uint)PermissionMask.Move |
524 7); // Preserve folded permissions
525 }
463 526
464 m_Scene.AddInventoryItem(item); 527 item.CreationDate = Util.UnixTimeSinceEpoch();
528 item.Description = asset.Description;
529 item.Name = asset.Name;
530 item.AssetType = asset.Type;
465 531
466 if (remoteClient != null && item.Owner == remoteClient.AgentId) 532 m_Scene.AddInventoryItem(item);
467 { 533
468 remoteClient.SendInventoryItemCreateUpdate(item, 0); 534 if (remoteClient != null && item.Owner == remoteClient.AgentId)
469 }
470 else
471 {
472 ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner);
473 if (notifyUser != null)
474 { 535 {
475 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); 536 remoteClient.SendInventoryItemCreateUpdate(item, 0);
537 }
538 else
539 {
540 ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner);
541 if (notifyUser != null)
542 {
543 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
544 }
476 } 545 }
477 } 546 }
478 } 547 }
479
480 return assetID; 548 return assetID;
481 } 549 }
482 550
@@ -484,8 +552,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
484 /// <summary> 552 /// <summary>
485 /// Rez an object into the scene from the user's inventory 553 /// Rez an object into the scene from the user's inventory
486 /// </summary> 554 /// </summary>
555 /// <remarks>
487 /// FIXME: It would be really nice if inventory access modules didn't also actually do the work of rezzing 556 /// FIXME: It would be really nice if inventory access modules didn't also actually do the work of rezzing
488 /// things to the scene. The caller should be doing that, I think. 557 /// things to the scene. The caller should be doing that, I think.
558 /// </remarks>
489 /// <param name="remoteClient"></param> 559 /// <param name="remoteClient"></param>
490 /// <param name="itemID"></param> 560 /// <param name="itemID"></param>
491 /// <param name="RayEnd"></param> 561 /// <param name="RayEnd"></param>
@@ -502,21 +572,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
502 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 572 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
503 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) 573 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
504 { 574 {
505 // Work out position details 575// m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID);
506 byte bRayEndIsIntersection = (byte)0; 576
507 577 byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0);
508 if (RayEndIsIntersection)
509 {
510 bRayEndIsIntersection = (byte)1;
511 }
512 else
513 {
514 bRayEndIsIntersection = (byte)0;
515 }
516
517 Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); 578 Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f);
518
519
520 Vector3 pos = m_Scene.GetNewRezLocation( 579 Vector3 pos = m_Scene.GetNewRezLocation(
521 RayStart, RayEnd, RayTargetID, Quaternion.Identity, 580 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
522 BypassRayCast, bRayEndIsIntersection, true, scale, false); 581 BypassRayCast, bRayEndIsIntersection, true, scale, false);
@@ -531,6 +590,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
531 590
532 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); 591 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
533 592
593 SceneObjectGroup group = null;
594
534 if (rezAsset != null) 595 if (rezAsset != null)
535 { 596 {
536 UUID itemId = UUID.Zero; 597 UUID itemId = UUID.Zero;
@@ -539,34 +600,78 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
539 // item that it came from. This allows us to enable 'save object to inventory' 600 // item that it came from. This allows us to enable 'save object to inventory'
540 if (!m_Scene.Permissions.BypassPermissions()) 601 if (!m_Scene.Permissions.BypassPermissions())
541 { 602 {
542 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy) 603 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
543 { 604 {
544 itemId = item.ID; 605 itemId = item.ID;
545 } 606 }
546 } 607 }
547 else 608 else
548 { 609 {
549 // Brave new fullperm world 610 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
550 // 611 {
551 itemId = item.ID; 612 // Brave new fullperm world
613 itemId = item.ID;
614 }
552 } 615 }
553 616
554 string xmlData = Utils.BytesToString(rezAsset.Data); 617 string xmlData = Utils.BytesToString(rezAsset.Data);
555 SceneObjectGroup group 618 List<SceneObjectGroup> objlist =
556 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); 619 new List<SceneObjectGroup>();
620 List<Vector3> veclist = new List<Vector3>();
621
622 XmlDocument doc = new XmlDocument();
623 doc.LoadXml(xmlData);
624 XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject");
625 if (e == null || attachment) // Single
626 {
627 SceneObjectGroup g =
628 SceneObjectSerializer.FromOriginalXmlFormat(
629 itemId, xmlData);
630 objlist.Add(g);
631 veclist.Add(new Vector3(0, 0, 0));
557 632
558 Util.FireAndForget(delegate { AddUserData(group); }); 633 float offsetHeight = 0;
559 634 pos = m_Scene.GetNewRezLocation(
560 group.RootPart.FromFolderID = item.Folder; 635 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
636 BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false);
637 pos.Z += offsetHeight;
638 }
639 else
640 {
641 XmlElement coll = (XmlElement)e;
642 float bx = Convert.ToSingle(coll.GetAttribute("x"));
643 float by = Convert.ToSingle(coll.GetAttribute("y"));
644 float bz = Convert.ToSingle(coll.GetAttribute("z"));
645 Vector3 bbox = new Vector3(bx, by, bz);
561 646
562 // If it's rezzed in world, select it. Much easier to 647 pos = m_Scene.GetNewRezLocation(RayStart, RayEnd,
563 // find small items. 648 RayTargetID, Quaternion.Identity,
564 // 649 BypassRayCast, bRayEndIsIntersection, true,
565 if (!attachment) 650 bbox, false);
566 group.RootPart.CreateSelected = true; 651
652 pos -= bbox / 2;
653
654 XmlNodeList groups = e.SelectNodes("SceneObjectGroup");
655 foreach (XmlNode n in groups)
656 {
657 SceneObjectGroup g =
658 SceneObjectSerializer.FromOriginalXmlFormat(
659 itemId, n.OuterXml);
660 objlist.Add(g);
661 XmlElement el = (XmlElement)n;
662 float x = Convert.ToSingle(el.GetAttribute("offsetx"));
663 float y = Convert.ToSingle(el.GetAttribute("offsety"));
664 float z = Convert.ToSingle(el.GetAttribute("offsetz"));
665 veclist.Add(new Vector3(x, y, z));
666 }
667 }
668
669 int primcount = 0;
670 foreach (SceneObjectGroup g in objlist)
671 primcount += g.PrimCount;
567 672
568 if (!m_Scene.Permissions.CanRezObject( 673 if (!m_Scene.Permissions.CanRezObject(
569 group.PrimCount, remoteClient.AgentId, pos) 674 primcount, remoteClient.AgentId, pos)
570 && !attachment) 675 && !attachment)
571 { 676 {
572 // The client operates in no fail mode. It will 677 // The client operates in no fail mode. It will
@@ -579,131 +684,131 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
579 return null; 684 return null;
580 } 685 }
581 686
582 group.ResetIDs(); 687 for (int i = 0 ; i < objlist.Count ; i++ )
583
584 if (attachment)
585 { 688 {
586 group.RootPart.Flags |= PrimFlags.Phantom; 689 group = objlist[i];
587 group.RootPart.IsAttachment = true; 690
691 Vector3 storedPosition = group.AbsolutePosition;
692 if (group.UUID == UUID.Zero)
693 {
694 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3");
695 }
696 group.RootPart.FromFolderID = item.Folder;
697
698 // If it's rezzed in world, select it. Much easier to
699 // find small items.
700 //
701 if (!attachment)
702 {
703 group.RootPart.CreateSelected = true;
704 foreach (SceneObjectPart child in group.Parts)
705 child.CreateSelected = true;
706 }
707 group.ResetIDs();
708
709 if (attachment)
710 {
711 group.RootPart.Flags |= PrimFlags.Phantom;
712 group.RootPart.IsAttachment = true;
713 }
588 714
589 // If we're rezzing an attachment then don't ask 715 // If we're rezzing an attachment then don't ask
590 // AddNewSceneObject() to update the client since 716 // AddNewSceneObject() to update the client since
591 // we'll be doing that later on. Scheduling more 717 // we'll be doing that later on. Scheduling more than
592 // than one full update during the attachment 718 // one full update during the attachment
593 // process causes some clients to fail to display 719 // process causes some clients to fail to display the
594 // the attachment properly. 720 // attachment properly.
595 // Also, don't persist attachments.
596 m_Scene.AddNewSceneObject(group, false, false);
597 }
598 else
599 {
600 m_Scene.AddNewSceneObject(group, true, false); 721 m_Scene.AddNewSceneObject(group, true, false);
601 }
602 722
603 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); 723 // if attachment we set it's asset id so object updates
604 // if attachment we set it's asset id so object updates can reflect that 724 // can reflect that, if not, we set it's position in world.
605 // if not, we set it's position in world. 725 if (!attachment)
606 if (!attachment) 726 {
607 { 727 group.ScheduleGroupForFullUpdate();
608 group.ScheduleGroupForFullUpdate(); 728
609 729 group.AbsolutePosition = pos + veclist[i];
610 float offsetHeight = 0; 730 }
611 pos = m_Scene.GetNewRezLocation( 731 else
612 RayStart, RayEnd, RayTargetID, Quaternion.Identity, 732 {
613 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false); 733 group.SetFromItemID(itemID);
614 pos.Z += offsetHeight; 734 }
615 group.AbsolutePosition = pos;
616 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
617
618 }
619 else
620 {
621 group.SetFromItemID(itemID);
622 }
623 735
624 SceneObjectPart rootPart = null; 736 SceneObjectPart rootPart = null;
625 try
626 {
627 rootPart = group.GetChildPart(group.UUID);
628 }
629 catch (NullReferenceException)
630 {
631 string isAttachment = "";
632 737
633 if (attachment) 738 try
634 isAttachment = " Object was an attachment"; 739 {
740 rootPart = group.GetChildPart(group.UUID);
741 }
742 catch (NullReferenceException)
743 {
744 string isAttachment = "";
635 745
636 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); 746 if (attachment)
637 } 747 isAttachment = " Object was an attachment";
638 748
639 // Since renaming the item in the inventory does not affect the name stored 749 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
640 // in the serialization, transfer the correct name from the inventory to the 750 }
641 // object itself before we rez.
642 rootPart.Name = item.Name;
643 rootPart.Description = item.Description;
644 751
645 if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0) 752 // Since renaming the item in the inventory does not
646 { 753 // affect the name stored in the serialization, transfer
754 // the correct name from the inventory to the
755 // object itself before we rez.
756 rootPart.Name = item.Name;
757 rootPart.Description = item.Description;
647 rootPart.ObjectSaleType = item.SaleType; 758 rootPart.ObjectSaleType = item.SaleType;
648 rootPart.SalePrice = item.SalePrice; 759 rootPart.SalePrice = item.SalePrice;
649 }
650
651 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
652 if ((rootPart.OwnerID != item.Owner) ||
653 (item.CurrentPermissions & 16) != 0 || // Magic number
654 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
655 {
656 //Need to kill the for sale here
657 rootPart.ObjectSaleType = 0;
658 rootPart.SalePrice = 10;
659 760
660 if (m_Scene.Permissions.PropagatePermissions()) 761 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
762 if ((rootPart.OwnerID != item.Owner) ||
763 (item.CurrentPermissions & 16) != 0)
661 { 764 {
662 foreach (SceneObjectPart part in group.Parts) 765 //Need to kill the for sale here
766 rootPart.ObjectSaleType = 0;
767 rootPart.SalePrice = 10;
768
769 if (m_Scene.Permissions.PropagatePermissions())
663 { 770 {
664 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) 771 foreach (SceneObjectPart part in group.Parts)
665 part.EveryoneMask = item.EveryOnePermissions; 772 {
666 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) 773 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
667 part.NextOwnerMask = item.NextPermissions; 774 {
668 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) 775 part.EveryoneMask = item.EveryOnePermissions;
669 part.GroupMask = item.GroupPermissions; 776 part.NextOwnerMask = item.NextPermissions;
777 }
778 part.GroupMask = 0; // DO NOT propagate here
779 }
780
781 group.ApplyNextOwnerPermissions();
670 } 782 }
671
672 group.ApplyNextOwnerPermissions();
673 } 783 }
674 }
675 784
676 foreach (SceneObjectPart part in group.Parts) 785 foreach (SceneObjectPart part in group.Parts)
677 {
678 if ((part.OwnerID != item.Owner) || (item.CurrentPermissions & 16) != 0)
679 { 786 {
680 part.LastOwnerID = part.OwnerID; 787 if ((part.OwnerID != item.Owner) ||
681 part.OwnerID = item.Owner; 788 (item.CurrentPermissions & 16) != 0)
682 part.Inventory.ChangeInventoryOwner(item.Owner); 789 {
683 part.GroupMask = 0; // DO NOT propagate here 790 part.LastOwnerID = part.OwnerID;
684 } 791 part.OwnerID = item.Owner;
685 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) 792 part.Inventory.ChangeInventoryOwner(item.Owner);
793 part.GroupMask = 0; // DO NOT propagate here
794 }
686 part.EveryoneMask = item.EveryOnePermissions; 795 part.EveryoneMask = item.EveryOnePermissions;
687 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
688 part.NextOwnerMask = item.NextPermissions; 796 part.NextOwnerMask = item.NextPermissions;
689 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) 797 }
690 part.GroupMask = item.GroupPermissions;
691 }
692 798
693 rootPart.TrimPermissions(); 799 rootPart.TrimPermissions();
694 800
695 if (!attachment) 801 if (!attachment)
696 {
697 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
698 { 802 {
699 group.ClearPartAttachmentData(); 803 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
700 } 804 group.ClearPartAttachmentData();
701 805
702 // Fire on_rez 806 // Fire on_rez
703 group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); 807 group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1);
704 rootPart.ParentGroup.ResumeScripts(); 808 rootPart.ParentGroup.ResumeScripts();
705 809
706 rootPart.ScheduleFullUpdate(); 810 rootPart.ScheduleFullUpdate();
811 }
707 } 812 }
708 813
709 if (!m_Scene.Permissions.BypassPermissions()) 814 if (!m_Scene.Permissions.BypassPermissions())
@@ -721,9 +826,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
721 } 826 }
722 } 827 }
723 } 828 }
724
725 return rootPart.ParentGroup;
726 } 829 }
830 return group;
727 } 831 }
728 832
729 return null; 833 return null;
diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
index 00b0aa9..2de8d7a 100644
--- a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
+++ b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
@@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
148 public void SendProfileToClient(ScenePresence presence) 148 public void SendProfileToClient(ScenePresence presence)
149 { 149 {
150 IClientAPI client = presence.ControllingClient; 150 IClientAPI client = presence.ControllingClient;
151 if (m_enableWindlight) 151 if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
152 { 152 {
153 if (presence.IsChildAgent == false) 153 if (presence.IsChildAgent == false)
154 { 154 {
@@ -165,7 +165,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
165 public void SendProfileToClient(ScenePresence presence, RegionLightShareData wl) 165 public void SendProfileToClient(ScenePresence presence, RegionLightShareData wl)
166 { 166 {
167 IClientAPI client = presence.ControllingClient; 167 IClientAPI client = presence.ControllingClient;
168 if (m_enableWindlight) 168 if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
169 { 169 {
170 if (presence.IsChildAgent == false) 170 if (presence.IsChildAgent == false)
171 { 171 {
diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
index c0975ea..9255791 100644
--- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
@@ -111,14 +111,12 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
111 { 111 {
112 if ((SMTPConfig = m_Config.Configs["SMTP"]) == null) 112 if ((SMTPConfig = m_Config.Configs["SMTP"]) == null)
113 { 113 {
114 m_log.InfoFormat("[SMTP] SMTP server not configured");
115 m_Enabled = false; 114 m_Enabled = false;
116 return; 115 return;
117 } 116 }
118 117
119 if (!SMTPConfig.GetBoolean("enabled", false)) 118 if (!SMTPConfig.GetBoolean("enabled", false))
120 { 119 {
121 m_log.InfoFormat("[SMTP] module disabled in configuration");
122 m_Enabled = false; 120 m_Enabled = false;
123 return; 121 return;
124 } 122 }
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
index d78931a..4c8424d 100644
--- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -29,8 +29,10 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Net; 31using System.Net;
32using System.Net.Security;
32using System.Text; 33using System.Text;
33using System.Threading; 34using System.Threading;
35using System.Security.Cryptography.X509Certificates;
34using Nini.Config; 36using Nini.Config;
35using OpenMetaverse; 37using OpenMetaverse;
36using OpenSim.Framework; 38using OpenSim.Framework;
@@ -100,8 +102,24 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
100 102
101 public HttpRequestModule() 103 public HttpRequestModule()
102 { 104 {
105 ServicePointManager.ServerCertificateValidationCallback +=ValidateServerCertificate;
103 } 106 }
104 107
108 public static bool ValidateServerCertificate(
109 object sender,
110 X509Certificate certificate,
111 X509Chain chain,
112 SslPolicyErrors sslPolicyErrors)
113 {
114 HttpWebRequest Request = (HttpWebRequest)sender;
115
116 if (Request.Headers.Get("NoVerifyCert") != null)
117 {
118 return true;
119 }
120
121 return chain.Build(new X509Certificate2(certificate));
122 }
105 #region IHttpRequestModule Members 123 #region IHttpRequestModule Members
106 124
107 public UUID MakeHttpRequest(string url, string parameters, string body) 125 public UUID MakeHttpRequest(string url, string parameters, string body)
@@ -141,8 +159,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
141 break; 159 break;
142 160
143 case (int)HttpRequestConstants.HTTP_VERIFY_CERT: 161 case (int)HttpRequestConstants.HTTP_VERIFY_CERT:
144 162 htc.HttpVerifyCert = (int.Parse(parms[i + 1]) != 0);
145 // TODO implement me
146 break; 163 break;
147 } 164 }
148 } 165 }
@@ -189,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
189 * Not sure how important ordering is is here - the next first 206 * Not sure how important ordering is is here - the next first
190 * one completed in the list is returned, based soley on its list 207 * one completed in the list is returned, based soley on its list
191 * position, not the order in which the request was started or 208 * position, not the order in which the request was started or
192 * finsihed. I thought about setting up a queue for this, but 209 * finished. I thought about setting up a queue for this, but
193 * it will need some refactoring and this works 'enough' right now 210 * it will need some refactoring and this works 'enough' right now
194 */ 211 */
195 212
@@ -237,8 +254,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
237 254
238 m_scene.RegisterModuleInterface<IHttpRequestModule>(this); 255 m_scene.RegisterModuleInterface<IHttpRequestModule>(this);
239 256
240 m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); 257 m_proxyurl = config.Configs["Startup"].GetString("HttpProxy");
241 m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); 258 m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions");
242 259
243 m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); 260 m_pendingRequests = new Dictionary<UUID, HttpRequestClass>();
244 } 261 }
@@ -282,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
282 public string HttpMethod = "GET"; 299 public string HttpMethod = "GET";
283 public string HttpMIMEType = "text/plain;charset=utf-8"; 300 public string HttpMIMEType = "text/plain;charset=utf-8";
284 public int HttpTimeout; 301 public int HttpTimeout;
285 // public bool HttpVerifyCert = true; // not implemented 302 public bool HttpVerifyCert = true;
286 private Thread httpThread; 303 private Thread httpThread;
287 304
288 // Request info 305 // Request info
@@ -344,6 +361,17 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
344 Request.Method = HttpMethod; 361 Request.Method = HttpMethod;
345 Request.ContentType = HttpMIMEType; 362 Request.ContentType = HttpMIMEType;
346 363
364 if(!HttpVerifyCert)
365 {
366 // We could hijack Connection Group Name to identify
367 // a desired security exception. But at the moment we'll use a dummy header instead.
368// Request.ConnectionGroupName = "NoVerify";
369 Request.Headers.Add("NoVerifyCert", "true");
370 }
371// else
372// {
373// Request.ConnectionGroupName="Verify";
374// }
347 if (proxyurl != null && proxyurl.Length > 0) 375 if (proxyurl != null && proxyurl.Length > 0)
348 { 376 {
349 if (proxyexcepts != null && proxyexcepts.Length > 0) 377 if (proxyexcepts != null && proxyexcepts.Length > 0)
@@ -436,4 +464,4 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
436 } 464 }
437 } 465 }
438 } 466 }
439} 467} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 57ab135..b6d64ac 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -200,12 +200,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
200 } 200 }
201 Scene.RegionInfo.RegionSettings.Save(); 201 Scene.RegionInfo.RegionSettings.Save();
202 TriggerRegionInfoChange(); 202 TriggerRegionInfoChange();
203 sendRegionHandshakeToAll();
203 sendRegionInfoPacketToAll(); 204 sendRegionInfoPacketToAll();
204 } 205 }
205 206
206 private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient) 207 private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient)
207 { 208 {
208 sendRegionHandshakeToAll(); 209 // sendRegionHandshakeToAll();
209 } 210 }
210 211
211 public void setRegionTerrainSettings(float WaterHeight, 212 public void setRegionTerrainSettings(float WaterHeight,
@@ -274,8 +275,25 @@ namespace OpenSim.Region.CoreModules.World.Estate
274 { 275 {
275 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) 276 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
276 { 277 {
278 if ((estateAccessType & 1) != 0) // All estates
279 {
280 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
281 EstateSettings estateSettings;
282
283 foreach (int estateID in estateIDs)
284 {
285 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
286 {
287 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
288 estateSettings.AddEstateUser(user);
289 estateSettings.Save();
290 }
291 }
292 }
293
277 Scene.RegionInfo.EstateSettings.AddEstateUser(user); 294 Scene.RegionInfo.EstateSettings.AddEstateUser(user);
278 Scene.RegionInfo.EstateSettings.Save(); 295 Scene.RegionInfo.EstateSettings.Save();
296
279 TriggerEstateInfoChange(); 297 TriggerEstateInfoChange();
280 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID); 298 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
281 } 299 }
@@ -289,10 +307,26 @@ namespace OpenSim.Region.CoreModules.World.Estate
289 { 307 {
290 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) 308 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
291 { 309 {
310 if ((estateAccessType & 1) != 0) // All estates
311 {
312 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
313 EstateSettings estateSettings;
314
315 foreach (int estateID in estateIDs)
316 {
317 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
318 {
319 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
320 estateSettings.RemoveEstateUser(user);
321 estateSettings.Save();
322 }
323 }
324 }
325
292 Scene.RegionInfo.EstateSettings.RemoveEstateUser(user); 326 Scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
293 Scene.RegionInfo.EstateSettings.Save(); 327 Scene.RegionInfo.EstateSettings.Save();
294 TriggerEstateInfoChange();
295 328
329 TriggerEstateInfoChange();
296 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID); 330 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
297 } 331 }
298 else 332 else
@@ -304,8 +338,25 @@ namespace OpenSim.Region.CoreModules.World.Estate
304 { 338 {
305 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) 339 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
306 { 340 {
341 if ((estateAccessType & 1) != 0) // All estates
342 {
343 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
344 EstateSettings estateSettings;
345
346 foreach (int estateID in estateIDs)
347 {
348 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
349 {
350 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
351 estateSettings.AddEstateGroup(user);
352 estateSettings.Save();
353 }
354 }
355 }
356
307 Scene.RegionInfo.EstateSettings.AddEstateGroup(user); 357 Scene.RegionInfo.EstateSettings.AddEstateGroup(user);
308 Scene.RegionInfo.EstateSettings.Save(); 358 Scene.RegionInfo.EstateSettings.Save();
359
309 TriggerEstateInfoChange(); 360 TriggerEstateInfoChange();
310 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID); 361 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
311 } 362 }
@@ -318,10 +369,26 @@ namespace OpenSim.Region.CoreModules.World.Estate
318 { 369 {
319 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) 370 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
320 { 371 {
372 if ((estateAccessType & 1) != 0) // All estates
373 {
374 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
375 EstateSettings estateSettings;
376
377 foreach (int estateID in estateIDs)
378 {
379 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
380 {
381 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
382 estateSettings.RemoveEstateGroup(user);
383 estateSettings.Save();
384 }
385 }
386 }
387
321 Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user); 388 Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
322 Scene.RegionInfo.EstateSettings.Save(); 389 Scene.RegionInfo.EstateSettings.Save();
323 TriggerEstateInfoChange();
324 390
391 TriggerEstateInfoChange();
325 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID); 392 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
326 } 393 }
327 else 394 else
@@ -349,6 +416,29 @@ namespace OpenSim.Region.CoreModules.World.Estate
349 if (!alreadyInList) 416 if (!alreadyInList)
350 { 417 {
351 418
419 if ((estateAccessType & 1) != 0) // All estates
420 {
421 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
422 EstateSettings estateSettings;
423
424 foreach (int estateID in estateIDs)
425 {
426 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
427 {
428 EstateBan bitem = new EstateBan();
429
430 bitem.BannedUserID = user;
431 bitem.EstateID = (uint)estateID;
432 bitem.BannedHostAddress = "0.0.0.0";
433 bitem.BannedHostIPMask = "0.0.0.0";
434
435 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
436 estateSettings.AddBan(bitem);
437 estateSettings.Save();
438 }
439 }
440 }
441
352 EstateBan item = new EstateBan(); 442 EstateBan item = new EstateBan();
353 443
354 item.BannedUserID = user; 444 item.BannedUserID = user;
@@ -358,6 +448,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
358 448
359 Scene.RegionInfo.EstateSettings.AddBan(item); 449 Scene.RegionInfo.EstateSettings.AddBan(item);
360 Scene.RegionInfo.EstateSettings.Save(); 450 Scene.RegionInfo.EstateSettings.Save();
451
361 TriggerEstateInfoChange(); 452 TriggerEstateInfoChange();
362 453
363 ScenePresence s = Scene.GetScenePresence(user); 454 ScenePresence s = Scene.GetScenePresence(user);
@@ -403,8 +494,25 @@ namespace OpenSim.Region.CoreModules.World.Estate
403 494
404 if (alreadyInList && listitem != null) 495 if (alreadyInList && listitem != null)
405 { 496 {
497 if ((estateAccessType & 1) != 0) // All estates
498 {
499 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
500 EstateSettings estateSettings;
501
502 foreach (int estateID in estateIDs)
503 {
504 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
505 {
506 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
507 estateSettings.RemoveBan(user);
508 estateSettings.Save();
509 }
510 }
511 }
512
406 Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID); 513 Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
407 Scene.RegionInfo.EstateSettings.Save(); 514 Scene.RegionInfo.EstateSettings.Save();
515
408 TriggerEstateInfoChange(); 516 TriggerEstateInfoChange();
409 } 517 }
410 else 518 else
@@ -424,8 +532,25 @@ namespace OpenSim.Region.CoreModules.World.Estate
424 { 532 {
425 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) 533 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
426 { 534 {
535 if ((estateAccessType & 1) != 0) // All estates
536 {
537 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
538 EstateSettings estateSettings;
539
540 foreach (int estateID in estateIDs)
541 {
542 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
543 {
544 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
545 estateSettings.AddEstateManager(user);
546 estateSettings.Save();
547 }
548 }
549 }
550
427 Scene.RegionInfo.EstateSettings.AddEstateManager(user); 551 Scene.RegionInfo.EstateSettings.AddEstateManager(user);
428 Scene.RegionInfo.EstateSettings.Save(); 552 Scene.RegionInfo.EstateSettings.Save();
553
429 TriggerEstateInfoChange(); 554 TriggerEstateInfoChange();
430 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID); 555 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
431 } 556 }
@@ -438,10 +563,26 @@ namespace OpenSim.Region.CoreModules.World.Estate
438 { 563 {
439 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) 564 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
440 { 565 {
566 if ((estateAccessType & 1) != 0) // All estates
567 {
568 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
569 EstateSettings estateSettings;
570
571 foreach (int estateID in estateIDs)
572 {
573 if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
574 {
575 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
576 estateSettings.RemoveEstateManager(user);
577 estateSettings.Save();
578 }
579 }
580 }
581
441 Scene.RegionInfo.EstateSettings.RemoveEstateManager(user); 582 Scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
442 Scene.RegionInfo.EstateSettings.Save(); 583 Scene.RegionInfo.EstateSettings.Save();
443 TriggerEstateInfoChange();
444 584
585 TriggerEstateInfoChange();
445 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID); 586 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
446 } 587 }
447 else 588 else
diff --git a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs
index 7d990c2..7fc358d 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs
@@ -133,16 +133,6 @@ namespace OpenSim.Region.CoreModules.World.Land
133 return new List<ILandObject>(); 133 return new List<ILandObject>();
134 } 134 }
135 135
136 public bool IsLandPrimCountTainted()
137 {
138 if (m_landManagementModule != null)
139 {
140 return m_landManagementModule.IsLandPrimCountTainted();
141 }
142
143 return false;
144 }
145
146 public bool IsForcefulBansAllowed() 136 public bool IsForcefulBansAllowed()
147 { 137 {
148 if (m_landManagementModule != null) 138 if (m_landManagementModule != null)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 98ba8c3..bfab7b8 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -62,8 +62,7 @@ namespace OpenSim.Region.CoreModules.World.Land
62 62
63 public class LandManagementModule : INonSharedRegionModule 63 public class LandManagementModule : INonSharedRegionModule
64 { 64 {
65 private static readonly ILog m_log = 65 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
66 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
67 66
68 private static readonly string remoteParcelRequestPath = "0009/"; 67 private static readonly string remoteParcelRequestPath = "0009/";
69 68
@@ -72,6 +71,7 @@ namespace OpenSim.Region.CoreModules.World.Land
72 protected Commander m_commander = new Commander("land"); 71 protected Commander m_commander = new Commander("land");
73 72
74 protected IUserManagement m_userManager; 73 protected IUserManagement m_userManager;
74 protected IPrimCountModule m_primCountModule;
75 75
76 // Minimum for parcels to work is 64m even if we don't actually use them. 76 // Minimum for parcels to work is 64m even if we don't actually use them.
77 #pragma warning disable 0429 77 #pragma warning disable 0429
@@ -88,7 +88,6 @@ namespace OpenSim.Region.CoreModules.World.Land
88 /// </value> 88 /// </value>
89 private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); 89 private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
90 90
91 private bool m_landPrimCountTainted;
92 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 91 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
93 92
94 private bool m_allowedForcefulBans = true; 93 private bool m_allowedForcefulBans = true;
@@ -121,18 +120,18 @@ namespace OpenSim.Region.CoreModules.World.Land
121 120
122 m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd; 121 m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd;
123 m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate; 122 m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate;
123 m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene;
124 m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate;
125
124 m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel; 126 m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel;
125 m_scene.EventManager.OnClientMovement += EventManagerOnClientMovement; 127 m_scene.EventManager.OnClientMovement += EventManagerOnClientMovement;
126 m_scene.EventManager.OnValidateLandBuy += EventManagerOnValidateLandBuy; 128 m_scene.EventManager.OnValidateLandBuy += EventManagerOnValidateLandBuy;
127 m_scene.EventManager.OnLandBuy += EventManagerOnLandBuy; 129 m_scene.EventManager.OnLandBuy += EventManagerOnLandBuy;
128 m_scene.EventManager.OnNewClient += EventManagerOnNewClient; 130 m_scene.EventManager.OnNewClient += EventManagerOnNewClient;
129 m_scene.EventManager.OnSignificantClientMovement += EventManagerOnSignificantClientMovement; 131 m_scene.EventManager.OnSignificantClientMovement += EventManagerOnSignificantClientMovement;
130 m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene;
131 m_scene.EventManager.OnNoticeNoLandDataFromStorage += EventManagerOnNoLandDataFromStorage; 132 m_scene.EventManager.OnNoticeNoLandDataFromStorage += EventManagerOnNoLandDataFromStorage;
132 m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage; 133 m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage;
133 m_scene.EventManager.OnSetAllowForcefulBan += EventManagerOnSetAllowedForcefulBan; 134 m_scene.EventManager.OnSetAllowForcefulBan += EventManagerOnSetAllowedForcefulBan;
134 m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate;
135 m_scene.EventManager.OnParcelPrimCountTainted += EventManagerOnParcelPrimCountTainted;
136 m_scene.EventManager.OnRegisterCaps += EventManagerOnRegisterCaps; 135 m_scene.EventManager.OnRegisterCaps += EventManagerOnRegisterCaps;
137 m_scene.EventManager.OnPluginConsole += EventManagerOnPluginConsole; 136 m_scene.EventManager.OnPluginConsole += EventManagerOnPluginConsole;
138 137
@@ -147,6 +146,7 @@ namespace OpenSim.Region.CoreModules.World.Land
147 public void RegionLoaded(Scene scene) 146 public void RegionLoaded(Scene scene)
148 { 147 {
149 m_userManager = m_scene.RequestModuleInterface<IUserManagement>(); 148 m_userManager = m_scene.RequestModuleInterface<IUserManagement>();
149 m_primCountModule = m_scene.RequestModuleInterface<IPrimCountModule>();
150 } 150 }
151 151
152 public void RemoveRegion(Scene scene) 152 public void RemoveRegion(Scene scene)
@@ -306,10 +306,14 @@ namespace OpenSim.Region.CoreModules.World.Land
306 /// <returns>The parcel created.</returns> 306 /// <returns>The parcel created.</returns>
307 protected ILandObject CreateDefaultParcel() 307 protected ILandObject CreateDefaultParcel()
308 { 308 {
309 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); 309 m_log.DebugFormat(
310 "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName);
311
312 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
310 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); 313 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
311 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 314 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
312 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 315 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
316
313 return AddLandObject(fullSimParcel); 317 return AddLandObject(fullSimParcel);
314 } 318 }
315 319
@@ -579,7 +583,7 @@ namespace OpenSim.Region.CoreModules.World.Land
579 } 583 }
580 else 584 else
581 { 585 {
582 m_log.WarnFormat("[LAND]: Invalid local land ID {0}", landLocalID); 586 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid local land ID {0}", landLocalID);
583 } 587 }
584 } 588 }
585 589
@@ -590,6 +594,11 @@ namespace OpenSim.Region.CoreModules.World.Land
590 public ILandObject AddLandObject(ILandObject land) 594 public ILandObject AddLandObject(ILandObject land)
591 { 595 {
592 ILandObject new_land = land.Copy(); 596 ILandObject new_land = land.Copy();
597
598 // Only now can we add the prim counts to the land object - we rely on the global ID which is generated
599 // as a random UUID inside LandData initialization
600 if (m_primCountModule != null)
601 new_land.PrimCounts = m_primCountModule.GetPrimCounts(new_land.LandData.GlobalID);
593 602
594 lock (m_landList) 603 lock (m_landList)
595 { 604 {
@@ -603,6 +612,10 @@ namespace OpenSim.Region.CoreModules.World.Land
603 { 612 {
604 if (landBitmap[x, y]) 613 if (landBitmap[x, y])
605 { 614 {
615// m_log.DebugFormat(
616// "[LAND MANAGEMENT MODULE]: Registering parcel {0} for land co-ord ({1}, {2}) on {3}",
617// new_land.LandData.Name, x, y, m_scene.RegionInfo.RegionName);
618
606 m_landIDList[x, y] = newLandLocalID; 619 m_landIDList[x, y] = newLandLocalID;
607 } 620 }
608 } 621 }
@@ -630,7 +643,7 @@ namespace OpenSim.Region.CoreModules.World.Land
630 { 643 {
631 if (m_landIDList[x, y] == local_id) 644 if (m_landIDList[x, y] == local_id)
632 { 645 {
633 m_log.WarnFormat("[LAND]: Not removing land object {0}; still being used at {1}, {2}", 646 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Not removing land object {0}; still being used at {1}, {2}",
634 local_id, x, y); 647 local_id, x, y);
635 return; 648 return;
636 //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y); 649 //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y);
@@ -732,8 +745,16 @@ namespace OpenSim.Region.CoreModules.World.Land
732 // Corner case. If an autoreturn happens during sim startup 745 // Corner case. If an autoreturn happens during sim startup
733 // we will come here with the list uninitialized 746 // we will come here with the list uninitialized
734 // 747 //
748 int landId = m_landIDList[x, y];
749
750// if (landId == 0)
751// m_log.DebugFormat(
752// "[LAND MANAGEMENT MODULE]: No land object found at ({0}, {1}) on {2}",
753// x, y, m_scene.RegionInfo.RegionName);
754
735 if (m_landList.ContainsKey(m_landIDList[x, y])) 755 if (m_landList.ContainsKey(m_landIDList[x, y]))
736 return m_landList[m_landIDList[x, y]]; 756 return m_landList[m_landIDList[x, y]];
757
737 return null; 758 return null;
738 } 759 }
739 } 760 }
@@ -751,13 +772,14 @@ namespace OpenSim.Region.CoreModules.World.Land
751 { 772 {
752 try 773 try
753 { 774 {
754 //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4])) 775 return m_landList[m_landIDList[x / 4, y / 4]];
755 return m_landList[m_landIDList[x / 4, y / 4]];
756 //else
757 // return null;
758 } 776 }
759 catch (IndexOutOfRangeException) 777 catch (IndexOutOfRangeException)
760 { 778 {
779// m_log.WarnFormat(
780// "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}",
781// x, y, m_scene.RegionInfo.RegionName);
782
761 return null; 783 return null;
762 } 784 }
763 } 785 }
@@ -767,34 +789,24 @@ namespace OpenSim.Region.CoreModules.World.Land
767 789
768 #region Parcel Modification 790 #region Parcel Modification
769 791
770 public void ResetAllLandPrimCounts() 792 public void ResetOverMeRecords()
771 { 793 {
772 lock (m_landList) 794 lock (m_landList)
773 { 795 {
774 foreach (LandObject p in m_landList.Values) 796 foreach (LandObject p in m_landList.Values)
775 { 797 {
776 p.ResetLandPrimCounts(); 798 p.ResetOverMeRecord();
777 } 799 }
778 } 800 }
779 } 801 }
780 802
781 public void EventManagerOnParcelPrimCountTainted()
782 {
783 m_landPrimCountTainted = true;
784 }
785
786 public bool IsLandPrimCountTainted()
787 {
788 return m_landPrimCountTainted;
789 }
790
791 public void EventManagerOnParcelPrimCountAdd(SceneObjectGroup obj) 803 public void EventManagerOnParcelPrimCountAdd(SceneObjectGroup obj)
792 { 804 {
793 Vector3 position = obj.AbsolutePosition; 805 Vector3 position = obj.AbsolutePosition;
794 ILandObject landUnderPrim = GetLandObject(position.X, position.Y); 806 ILandObject landUnderPrim = GetLandObject(position.X, position.Y);
795 if (landUnderPrim != null) 807 if (landUnderPrim != null)
796 { 808 {
797 landUnderPrim.AddPrimToCount(obj); 809 ((LandObject)landUnderPrim).AddPrimOverMe(obj);
798 } 810 }
799 } 811 }
800 812
@@ -804,7 +816,7 @@ namespace OpenSim.Region.CoreModules.World.Land
804 { 816 {
805 foreach (LandObject p in m_landList.Values) 817 foreach (LandObject p in m_landList.Values)
806 { 818 {
807 p.RemovePrimFromCount(obj); 819 p.RemovePrimFromOverMe(obj);
808 } 820 }
809 } 821 }
810 } 822 }
@@ -837,8 +849,7 @@ namespace OpenSim.Region.CoreModules.World.Land
837 foreach (LandObject p in landOwnersAndParcels[owner]) 849 foreach (LandObject p in landOwnersAndParcels[owner])
838 { 850 {
839 simArea += p.LandData.Area; 851 simArea += p.LandData.Area;
840 simPrims += p.LandData.OwnerPrims + p.LandData.OtherPrims + p.LandData.GroupPrims + 852 simPrims += p.PrimCounts.Total;
841 p.LandData.SelectedPrims;
842 } 853 }
843 854
844 foreach (LandObject p in landOwnersAndParcels[owner]) 855 foreach (LandObject p in landOwnersAndParcels[owner])
@@ -851,7 +862,11 @@ namespace OpenSim.Region.CoreModules.World.Land
851 862
852 public void EventManagerOnParcelPrimCountUpdate() 863 public void EventManagerOnParcelPrimCountUpdate()
853 { 864 {
854 ResetAllLandPrimCounts(); 865// m_log.DebugFormat(
866// "[LAND MANAGEMENT MODULE]: Triggered EventManagerOnParcelPrimCountUpdate() for {0}",
867// m_scene.RegionInfo.RegionName);
868
869 ResetOverMeRecords();
855 EntityBase[] entities = m_scene.Entities.GetEntities(); 870 EntityBase[] entities = m_scene.Entities.GetEntities();
856 foreach (EntityBase obj in entities) 871 foreach (EntityBase obj in entities)
857 { 872 {
@@ -864,15 +879,13 @@ namespace OpenSim.Region.CoreModules.World.Land
864 } 879 }
865 } 880 }
866 FinalizeLandPrimCountUpdate(); 881 FinalizeLandPrimCountUpdate();
867 m_landPrimCountTainted = false;
868 } 882 }
869 883
870 public void EventManagerOnRequestParcelPrimCountUpdate() 884 public void EventManagerOnRequestParcelPrimCountUpdate()
871 { 885 {
872 ResetAllLandPrimCounts(); 886 ResetOverMeRecords();
873 m_scene.EventManager.TriggerParcelPrimCountUpdate(); 887 m_scene.EventManager.TriggerParcelPrimCountUpdate();
874 FinalizeLandPrimCountUpdate(); 888 FinalizeLandPrimCountUpdate();
875 m_landPrimCountTainted = false;
876 } 889 }
877 890
878 /// <summary> 891 /// <summary>
@@ -936,8 +949,6 @@ namespace OpenSim.Region.CoreModules.World.Land
936 m_landList[startLandObjectIndex].ForceUpdateLandInfo(); 949 m_landList[startLandObjectIndex].ForceUpdateLandInfo();
937 } 950 }
938 951
939 EventManagerOnParcelPrimCountTainted();
940
941 //Now add the new land object 952 //Now add the new land object
942 ILandObject result = AddLandObject(newLand); 953 ILandObject result = AddLandObject(newLand);
943 UpdateLandObject(startLandObject.LandData.LocalID, startLandObject.LandData); 954 UpdateLandObject(startLandObject.LandData.LocalID, startLandObject.LandData);
@@ -1004,7 +1015,6 @@ namespace OpenSim.Region.CoreModules.World.Land
1004 performFinalLandJoin(masterLandObject, slaveLandObject); 1015 performFinalLandJoin(masterLandObject, slaveLandObject);
1005 } 1016 }
1006 } 1017 }
1007 EventManagerOnParcelPrimCountTainted();
1008 1018
1009 masterLandObject.SendLandUpdateToAvatarsOverMe(); 1019 masterLandObject.SendLandUpdateToAvatarsOverMe();
1010 } 1020 }
@@ -1194,11 +1204,12 @@ namespace OpenSim.Region.CoreModules.World.Land
1194 1204
1195 if (land != null) 1205 if (land != null)
1196 { 1206 {
1207 m_scene.EventManager.TriggerParcelPrimCountUpdate();
1197 m_landList[local_id].SendLandObjectOwners(remote_client); 1208 m_landList[local_id].SendLandObjectOwners(remote_client);
1198 } 1209 }
1199 else 1210 else
1200 { 1211 {
1201 m_log.WarnFormat("[PARCEL]: Invalid land object {0} passed for parcel object owner request", local_id); 1212 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid land object {0} passed for parcel object owner request", local_id);
1202 } 1213 }
1203 } 1214 }
1204 1215
@@ -1361,7 +1372,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1361 { 1372 {
1362 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); 1373 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
1363 new_land.LandData = data.Copy(); 1374 new_land.LandData = data.Copy();
1364 new_land.SetLandBitmapFromByteArray(); 1375 new_land.SetLandBitmapFromByteArray();
1365 AddLandObject(new_land); 1376 AddLandObject(new_land);
1366 } 1377 }
1367 1378
@@ -1425,8 +1436,9 @@ namespace OpenSim.Region.CoreModules.World.Land
1425 private string ProcessPropertiesUpdate(string request, string path, string param, UUID agentID, Caps caps) 1436 private string ProcessPropertiesUpdate(string request, string path, string param, UUID agentID, Caps caps)
1426 { 1437 {
1427 IClientAPI client; 1438 IClientAPI client;
1428 if (! m_scene.TryGetClient(agentID, out client)) { 1439 if (!m_scene.TryGetClient(agentID, out client))
1429 m_log.WarnFormat("[LAND] unable to retrieve IClientAPI for {0}", agentID.ToString()); 1440 {
1441 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to retrieve IClientAPI for {0}", agentID);
1430 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); 1442 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty());
1431 } 1443 }
1432 1444
@@ -1475,7 +1487,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1475 } 1487 }
1476 else 1488 else
1477 { 1489 {
1478 m_log.WarnFormat("[LAND] unable to find parcelID {0}", parcelID); 1490 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID);
1479 } 1491 }
1480 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); 1492 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty());
1481 } 1493 }
@@ -1533,17 +1545,17 @@ namespace OpenSim.Region.CoreModules.World.Land
1533 } 1545 }
1534 catch (LLSD.LLSDParseException e) 1546 catch (LLSD.LLSDParseException e)
1535 { 1547 {
1536 m_log.ErrorFormat("[LAND] Fetch error: {0}", e.Message); 1548 m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Fetch error: {0}", e.Message);
1537 m_log.ErrorFormat("[LAND] ... in request {0}", request); 1549 m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: ... in request {0}", request);
1538 } 1550 }
1539 catch(InvalidCastException) 1551 catch (InvalidCastException)
1540 { 1552 {
1541 m_log.ErrorFormat("[LAND] Wrong type in request {0}", request); 1553 m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Wrong type in request {0}", request);
1542 } 1554 }
1543 1555
1544 LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse(); 1556 LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse();
1545 response.parcel_id = parcelID; 1557 response.parcel_id = parcelID;
1546 m_log.DebugFormat("[LAND] got parcelID {0}", parcelID); 1558 m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelID {0}", parcelID);
1547 1559
1548 return LLSDHelpers.SerialiseLLSDReply(response); 1560 return LLSDHelpers.SerialiseLLSDReply(response);
1549 } 1561 }
@@ -1564,7 +1576,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1564 ExtendedLandData extLandData = new ExtendedLandData(); 1576 ExtendedLandData extLandData = new ExtendedLandData();
1565 Util.ParseFakeParcelID(parcel, out extLandData.RegionHandle, 1577 Util.ParseFakeParcelID(parcel, out extLandData.RegionHandle,
1566 out extLandData.X, out extLandData.Y); 1578 out extLandData.X, out extLandData.Y);
1567 m_log.DebugFormat("[LAND] got parcelinfo request for regionHandle {0}, x/y {1}/{2}", 1579 m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelinfo request for regionHandle {0}, x/y {1}/{2}",
1568 extLandData.RegionHandle, extLandData.X, extLandData.Y); 1580 extLandData.RegionHandle, extLandData.X, extLandData.Y);
1569 1581
1570 // for this region or for somewhere else? 1582 // for this region or for somewhere else?
@@ -1605,7 +1617,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1605 info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); 1617 info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1606 } 1618 }
1607 // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark. 1619 // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark.
1608 m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...", 1620 m_log.DebugFormat("[LAND MANAGEMENT MODULE]: got parcelinfo for parcel {0} in region {1}; sending...",
1609 data.LandData.Name, data.RegionHandle); 1621 data.LandData.Name, data.RegionHandle);
1610 // HACK for now 1622 // HACK for now
1611 RegionInfo r = new RegionInfo(); 1623 RegionInfo r = new RegionInfo();
@@ -1616,7 +1628,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1616 remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y); 1628 remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y);
1617 } 1629 }
1618 else 1630 else
1619 m_log.Debug("[LAND] got no parcelinfo; not sending"); 1631 m_log.Debug("[LAND MANAGEMENT MODULE]: got no parcelinfo; not sending");
1620 } 1632 }
1621 1633
1622 public void setParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime) 1634 public void setParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 46c15ed..c2f104e 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Land
51 51
52 private int m_lastSeqId = 0; 52 private int m_lastSeqId = 0;
53 53
54 protected LandData m_landData = new LandData(); 54 protected LandData m_landData = new LandData();
55 protected Scene m_scene; 55 protected Scene m_scene;
56 protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); 56 protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
57 protected Dictionary<uint, UUID> m_listTransactions = new Dictionary<uint, UUID>(); 57 protected Dictionary<uint, UUID> m_listTransactions = new Dictionary<uint, UUID>();
@@ -64,8 +64,6 @@ namespace OpenSim.Region.CoreModules.World.Land
64 64
65 #endregion 65 #endregion
66 66
67 #region ILandObject Members
68
69 public int GetPrimsFree() 67 public int GetPrimsFree()
70 { 68 {
71 m_scene.EventManager.TriggerParcelPrimCountUpdate(); 69 m_scene.EventManager.TriggerParcelPrimCountUpdate();
@@ -79,6 +77,8 @@ namespace OpenSim.Region.CoreModules.World.Land
79 77
80 set { m_landData = value; } 78 set { m_landData = value; }
81 } 79 }
80
81 public IPrimCounts PrimCounts { get; set; }
82 82
83 public UUID RegionUUID 83 public UUID RegionUUID
84 { 84 {
@@ -211,6 +211,7 @@ namespace OpenSim.Region.CoreModules.World.Land
211 return simMax; 211 return simMax;
212 } 212 }
213 } 213 }
214
214 #endregion 215 #endregion
215 216
216 #region Packet Request Handling 217 #region Packet Request Handling
@@ -241,7 +242,7 @@ namespace OpenSim.Region.CoreModules.World.Land
241 } 242 }
242 243
243 remote_client.SendLandProperties(seq_id, 244 remote_client.SendLandProperties(seq_id,
244 snap_selection, request_result, LandData, 245 snap_selection, request_result, this,
245 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, 246 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus,
246 GetParcelMaxPrimCount(this), 247 GetParcelMaxPrimCount(this),
247 GetSimulatorMaxPrimCount(this), regionFlags); 248 GetSimulatorMaxPrimCount(this), regionFlags);
@@ -700,23 +701,11 @@ namespace OpenSim.Region.CoreModules.World.Land
700 return LandBitmap; 701 return LandBitmap;
701 } 702 }
702 703
703 /// <summary>
704 /// Full sim land object creation
705 /// </summary>
706 /// <returns></returns>
707 public bool[,] BasicFullRegionLandBitmap() 704 public bool[,] BasicFullRegionLandBitmap()
708 { 705 {
709 return GetSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize); 706 return GetSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize);
710 } 707 }
711 708
712 /// <summary>
713 /// Used to modify the bitmap between the x and y points. Points use 64 scale
714 /// </summary>
715 /// <param name="start_x"></param>
716 /// <param name="start_y"></param>
717 /// <param name="end_x"></param>
718 /// <param name="end_y"></param>
719 /// <returns></returns>
720 public bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y) 709 public bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y)
721 { 710 {
722 bool[,] tempBitmap = new bool[64,64]; 711 bool[,] tempBitmap = new bool[64,64];
@@ -907,9 +896,12 @@ namespace OpenSim.Region.CoreModules.World.Land
907 896
908 lock (primsOverMe) 897 lock (primsOverMe)
909 { 898 {
899// m_log.DebugFormat(
900// "[LAND OBJECT]: Request for SendLandObjectOwners() from {0} with {1} known prims on region",
901// remote_client.Name, primsOverMe.Count);
902
910 try 903 try
911 { 904 {
912
913 foreach (SceneObjectGroup obj in primsOverMe) 905 foreach (SceneObjectGroup obj in primsOverMe)
914 { 906 {
915 try 907 try
@@ -921,7 +913,7 @@ namespace OpenSim.Region.CoreModules.World.Land
921 } 913 }
922 catch (NullReferenceException) 914 catch (NullReferenceException)
923 { 915 {
924 m_log.Info("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel"); 916 m_log.Error("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel");
925 } 917 }
926 try 918 try
927 { 919 {
@@ -948,6 +940,7 @@ namespace OpenSim.Region.CoreModules.World.Land
948 public Dictionary<UUID, int> GetLandObjectOwners() 940 public Dictionary<UUID, int> GetLandObjectOwners()
949 { 941 {
950 Dictionary<UUID, int> ownersAndCount = new Dictionary<UUID, int>(); 942 Dictionary<UUID, int> ownersAndCount = new Dictionary<UUID, int>();
943
951 lock (primsOverMe) 944 lock (primsOverMe)
952 { 945 {
953 try 946 try
@@ -984,8 +977,10 @@ namespace OpenSim.Region.CoreModules.World.Land
984 977
985 public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client) 978 public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client)
986 { 979 {
987 Dictionary<UUID,List<SceneObjectGroup>> returns = 980// m_log.DebugFormat(
988 new Dictionary<UUID,List<SceneObjectGroup>>(); 981// "[LAND OBJECT]: Request to return objects in {0} from {1}", LandData.Name, remote_client.Name);
982
983 Dictionary<UUID,List<SceneObjectGroup>> returns = new Dictionary<UUID,List<SceneObjectGroup>>();
989 984
990 lock (primsOverMe) 985 lock (primsOverMe)
991 { 986 {
@@ -1058,83 +1053,29 @@ namespace OpenSim.Region.CoreModules.World.Land
1058 1053
1059 #region Object Adding/Removing from Parcel 1054 #region Object Adding/Removing from Parcel
1060 1055
1061 public void ResetLandPrimCounts() 1056 public void ResetOverMeRecord()
1062 { 1057 {
1063 LandData.GroupPrims = 0;
1064 LandData.OwnerPrims = 0;
1065 LandData.OtherPrims = 0;
1066 LandData.SelectedPrims = 0;
1067
1068
1069 lock (primsOverMe) 1058 lock (primsOverMe)
1070 primsOverMe.Clear(); 1059 primsOverMe.Clear();
1071 } 1060 }
1072 1061
1073 public void AddPrimToCount(SceneObjectGroup obj) 1062 public void AddPrimOverMe(SceneObjectGroup obj)
1074 { 1063 {
1075 1064// m_log.DebugFormat("[LAND OBJECT]: Adding scene object {0} {1} over {2}", obj.Name, obj.LocalId, LandData.Name);
1076 UUID prim_owner = obj.OwnerID; 1065
1077 int prim_count = obj.PrimCount;
1078
1079 if (obj.IsSelected)
1080 {
1081 LandData.SelectedPrims += prim_count;
1082 }
1083 else
1084 {
1085 if (prim_owner == LandData.OwnerID)
1086 {
1087 LandData.OwnerPrims += prim_count;
1088 }
1089 else if ((obj.GroupID == LandData.GroupID ||
1090 prim_owner == LandData.GroupID) &&
1091 LandData.GroupID != UUID.Zero)
1092 {
1093 LandData.GroupPrims += prim_count;
1094 }
1095 else
1096 {
1097 LandData.OtherPrims += prim_count;
1098 }
1099 }
1100
1101 lock (primsOverMe) 1066 lock (primsOverMe)
1102 primsOverMe.Add(obj); 1067 primsOverMe.Add(obj);
1103 } 1068 }
1104 1069
1105 public void RemovePrimFromCount(SceneObjectGroup obj) 1070 public void RemovePrimFromOverMe(SceneObjectGroup obj)
1106 { 1071 {
1072// m_log.DebugFormat("[LAND OBJECT]: Removing scene object {0} {1} from over {2}", obj.Name, obj.LocalId, LandData.Name);
1073
1107 lock (primsOverMe) 1074 lock (primsOverMe)
1108 { 1075 primsOverMe.Remove(obj);
1109 if (primsOverMe.Contains(obj))
1110 {
1111 UUID prim_owner = obj.OwnerID;
1112 int prim_count = obj.PrimCount;
1113
1114 if (prim_owner == LandData.OwnerID)
1115 {
1116 LandData.OwnerPrims -= prim_count;
1117 }
1118 else if (obj.GroupID == LandData.GroupID ||
1119 prim_owner == LandData.GroupID)
1120 {
1121 LandData.GroupPrims -= prim_count;
1122 }
1123 else
1124 {
1125 LandData.OtherPrims -= prim_count;
1126 }
1127
1128 primsOverMe.Remove(obj);
1129 }
1130 }
1131 } 1076 }
1132 1077
1133 #endregion 1078 #endregion
1134
1135 #endregion
1136
1137 #endregion
1138 1079
1139 /// <summary> 1080 /// <summary>
1140 /// Set the media url for this land parcel 1081 /// Set the media url for this land parcel
@@ -1155,5 +1096,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1155 LandData.MusicURL = url; 1096 LandData.MusicURL = url;
1156 SendLandUpdateToAvatarsOverMe(); 1097 SendLandUpdateToAvatarsOverMe();
1157 } 1098 }
1099
1100 #endregion
1158 } 1101 }
1159} 1102}
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index 34ef67f..dca842a 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -45,14 +45,13 @@ namespace OpenSim.Region.CoreModules.World.Land
45 public int Owner = 0; 45 public int Owner = 0;
46 public int Group = 0; 46 public int Group = 0;
47 public int Others = 0; 47 public int Others = 0;
48 public Dictionary <UUID, int> Users = 48 public int Selected = 0;
49 new Dictionary <UUID, int>(); 49 public Dictionary <UUID, int> Users = new Dictionary <UUID, int>();
50 } 50 }
51 51
52 public class PrimCountModule : IPrimCountModule, INonSharedRegionModule 52 public class PrimCountModule : IPrimCountModule, INonSharedRegionModule
53 { 53 {
54 private static readonly ILog m_log = 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 55
57 private Scene m_Scene; 56 private Scene m_Scene;
58 private Dictionary<UUID, PrimCounts> m_PrimCounts = 57 private Dictionary<UUID, PrimCounts> m_PrimCounts =
@@ -64,10 +63,15 @@ namespace OpenSim.Region.CoreModules.World.Land
64 private Dictionary<UUID, ParcelCounts> m_ParcelCounts = 63 private Dictionary<UUID, ParcelCounts> m_ParcelCounts =
65 new Dictionary<UUID, ParcelCounts>(); 64 new Dictionary<UUID, ParcelCounts>();
66 65
67 // For now, a simple simwide taint to get this up. Later parcel based 66 /// <value>
68 // taint to allow recounting a parcel if only ownership has changed 67 /// For now, a simple simwide taint to get this up. Later parcel based
69 // without recounting the whole sim. 68 /// taint to allow recounting a parcel if only ownership has changed
69 /// without recounting the whole sim.
70 ///
71 /// We start out tainted so that the first get call resets the various prim counts.
72 /// <value>
70 private bool m_Tainted = true; 73 private bool m_Tainted = true;
74
71 private Object m_TaintLock = new Object(); 75 private Object m_TaintLock = new Object();
72 76
73 public Type ReplaceableInterface 77 public Type ReplaceableInterface
@@ -82,13 +86,15 @@ namespace OpenSim.Region.CoreModules.World.Land
82 public void AddRegion(Scene scene) 86 public void AddRegion(Scene scene)
83 { 87 {
84 m_Scene = scene; 88 m_Scene = scene;
89
90 m_Scene.RegisterModuleInterface<IPrimCountModule>(this);
85 91
86 m_Scene.EventManager.OnParcelPrimCountAdd += 92 m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd;
87 OnParcelPrimCountAdd;
88 m_Scene.EventManager.OnObjectBeingRemovedFromScene += 93 m_Scene.EventManager.OnObjectBeingRemovedFromScene +=
89 OnObjectBeingRemovedFromScene; 94 OnObjectBeingRemovedFromScene;
90 m_Scene.EventManager.OnParcelPrimCountTainted += 95 m_Scene.EventManager.OnParcelPrimCountTainted +=
91 OnParcelPrimCountTainted; 96 OnParcelPrimCountTainted;
97 m_Scene.EventManager.OnLandObjectAdded += delegate(ILandObject lo) { OnParcelPrimCountTainted(); };
92 } 98 }
93 99
94 public void RegionLoaded(Scene scene) 100 public void RegionLoaded(Scene scene)
@@ -116,6 +122,11 @@ namespace OpenSim.Region.CoreModules.World.Land
116 { 122 {
117 if (!m_Tainted) 123 if (!m_Tainted)
118 AddObject(obj); 124 AddObject(obj);
125// else
126// m_log.DebugFormat(
127// "[PRIM COUNT MODULE]: Ignoring OnParcelPrimCountAdd() for {0} on {1} since count is tainted",
128// obj.Name, m_Scene.RegionInfo.RegionName);
129
119 } 130 }
120 } 131 }
121 132
@@ -126,11 +137,18 @@ namespace OpenSim.Region.CoreModules.World.Land
126 { 137 {
127 if (!m_Tainted) 138 if (!m_Tainted)
128 RemoveObject(obj); 139 RemoveObject(obj);
140// else
141// m_log.DebugFormat(
142// "[PRIM COUNT MODULE]: Ignoring OnObjectBeingRemovedFromScene() for {0} on {1} since count is tainted",
143// obj.Name, m_Scene.RegionInfo.RegionName);
129 } 144 }
130 } 145 }
131 146
132 private void OnParcelPrimCountTainted() 147 private void OnParcelPrimCountTainted()
133 { 148 {
149// m_log.DebugFormat(
150// "[PRIM COUNT MODULE]: OnParcelPrimCountTainted() called on {0}", m_Scene.RegionInfo.RegionName);
151
134 lock (m_TaintLock) 152 lock (m_TaintLock)
135 m_Tainted = true; 153 m_Tainted = true;
136 } 154 }
@@ -155,15 +173,34 @@ namespace OpenSim.Region.CoreModules.World.Land
155 173
156 // NOTE: Call under Taint Lock 174 // NOTE: Call under Taint Lock
157 private void AddObject(SceneObjectGroup obj) 175 private void AddObject(SceneObjectGroup obj)
158 { 176 {
159 if (obj.IsAttachment) 177 if (obj.IsAttachment)
160 return; 178 return;
161 if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)) 179 if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0))
162 return; 180 return;
163 181
164 Vector3 pos = obj.AbsolutePosition; 182 Vector3 pos = obj.AbsolutePosition;
165 ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); 183 ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
184
185 // If for some reason there is no land object (perhaps the object is out of bounds) then we can't count it
186 if (landObject == null)
187 {
188// m_log.WarnFormat(
189// "[PRIM COUNT MODULE]: Found no land object for {0} at position ({1}, {2}) on {3}",
190// obj.Name, pos.X, pos.Y, m_Scene.RegionInfo.RegionName);
191
192 return;
193 }
194
166 LandData landData = landObject.LandData; 195 LandData landData = landObject.LandData;
196
197// m_log.DebugFormat(
198// "[PRIM COUNT MODULE]: Adding object {0} with {1} parts to prim count for parcel {2} on {3}",
199// obj.Name, obj.Parts.Length, landData.Name, m_Scene.RegionInfo.RegionName);
200
201// m_log.DebugFormat(
202// "[PRIM COUNT MODULE]: Object {0} is owned by {1} over land owned by {2}",
203// obj.Name, obj.OwnerID, landData.OwnerID);
167 204
168 ParcelCounts parcelCounts; 205 ParcelCounts parcelCounts;
169 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) 206 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
@@ -177,23 +214,28 @@ namespace OpenSim.Region.CoreModules.World.Land
177 else 214 else
178 parcelCounts.Users[obj.OwnerID] = partCount; 215 parcelCounts.Users[obj.OwnerID] = partCount;
179 216
180 if (landData.IsGroupOwned) 217 if (obj.IsSelected)
181 { 218 {
182 if (obj.OwnerID == landData.GroupID) 219 parcelCounts.Selected += partCount;
183 parcelCounts.Owner += partCount;
184 else if (obj.GroupID == landData.GroupID)
185 parcelCounts.Group += partCount;
186 else
187 parcelCounts.Others += partCount;
188 } 220 }
189 else 221 else
190 { 222 {
191 if (obj.OwnerID == landData.OwnerID) 223 if (landData.IsGroupOwned)
192 parcelCounts.Owner += partCount; 224 {
193 else if (obj.GroupID == landData.GroupID) 225 if (obj.OwnerID == landData.GroupID)
194 parcelCounts.Group += partCount; 226 parcelCounts.Owner += partCount;
227 else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID)
228 parcelCounts.Group += partCount;
229 else
230 parcelCounts.Others += partCount;
231 }
195 else 232 else
196 parcelCounts.Others += partCount; 233 {
234 if (obj.OwnerID == landData.OwnerID)
235 parcelCounts.Owner += partCount;
236 else
237 parcelCounts.Others += partCount;
238 }
197 } 239 }
198 } 240 }
199 } 241 }
@@ -201,10 +243,16 @@ namespace OpenSim.Region.CoreModules.World.Land
201 // NOTE: Call under Taint Lock 243 // NOTE: Call under Taint Lock
202 private void RemoveObject(SceneObjectGroup obj) 244 private void RemoveObject(SceneObjectGroup obj)
203 { 245 {
246// m_log.DebugFormat("[PRIM COUNT MODULE]: Removing object {0} {1} from prim count", obj.Name, obj.UUID);
247
248 // Currently this is being done by tainting the count instead.
204 } 249 }
205 250
206 public IPrimCounts GetPrimCounts(UUID parcelID) 251 public IPrimCounts GetPrimCounts(UUID parcelID)
207 { 252 {
253// m_log.DebugFormat(
254// "[PRIM COUNT MODULE]: GetPrimCounts for parcel {0} in {1}", parcelID, m_Scene.RegionInfo.RegionName);
255
208 PrimCounts primCounts; 256 PrimCounts primCounts;
209 257
210 lock (m_PrimCounts) 258 lock (m_PrimCounts)
@@ -218,8 +266,16 @@ namespace OpenSim.Region.CoreModules.World.Land
218 return primCounts; 266 return primCounts;
219 } 267 }
220 268
269
270 /// <summary>
271 /// Get the number of prims on the parcel that are owned by the parcel owner.
272 /// </summary>
273 /// <param name="parcelID"></param>
274 /// <returns></returns>
221 public int GetOwnerCount(UUID parcelID) 275 public int GetOwnerCount(UUID parcelID)
222 { 276 {
277 int count = 0;
278
223 lock (m_TaintLock) 279 lock (m_TaintLock)
224 { 280 {
225 if (m_Tainted) 281 if (m_Tainted)
@@ -227,13 +283,25 @@ namespace OpenSim.Region.CoreModules.World.Land
227 283
228 ParcelCounts counts; 284 ParcelCounts counts;
229 if (m_ParcelCounts.TryGetValue(parcelID, out counts)) 285 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
230 return counts.Owner; 286 count = counts.Owner;
231 } 287 }
232 return 0; 288
289// m_log.DebugFormat(
290// "[PRIM COUNT MODULE]: GetOwnerCount for parcel {0} in {1} returning {2}",
291// parcelID, m_Scene.RegionInfo.RegionName, count);
292
293 return count;
233 } 294 }
234 295
296 /// <summary>
297 /// Get the number of prims on the parcel that have been set to the group that owns the parcel.
298 /// </summary>
299 /// <param name="parcelID"></param>
300 /// <returns></returns>
235 public int GetGroupCount(UUID parcelID) 301 public int GetGroupCount(UUID parcelID)
236 { 302 {
303 int count = 0;
304
237 lock (m_TaintLock) 305 lock (m_TaintLock)
238 { 306 {
239 if (m_Tainted) 307 if (m_Tainted)
@@ -241,13 +309,25 @@ namespace OpenSim.Region.CoreModules.World.Land
241 309
242 ParcelCounts counts; 310 ParcelCounts counts;
243 if (m_ParcelCounts.TryGetValue(parcelID, out counts)) 311 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
244 return counts.Group; 312 count = counts.Group;
245 } 313 }
246 return 0; 314
315// m_log.DebugFormat(
316// "[PRIM COUNT MODULE]: GetGroupCount for parcel {0} in {1} returning {2}",
317// parcelID, m_Scene.RegionInfo.RegionName, count);
318
319 return count;
247 } 320 }
248 321
322 /// <summary>
323 /// Get the number of prims on the parcel that are not owned by the parcel owner or set to the parcel group.
324 /// </summary>
325 /// <param name="parcelID"></param>
326 /// <returns></returns>
249 public int GetOthersCount(UUID parcelID) 327 public int GetOthersCount(UUID parcelID)
250 { 328 {
329 int count = 0;
330
251 lock (m_TaintLock) 331 lock (m_TaintLock)
252 { 332 {
253 if (m_Tainted) 333 if (m_Tainted)
@@ -255,13 +335,83 @@ namespace OpenSim.Region.CoreModules.World.Land
255 335
256 ParcelCounts counts; 336 ParcelCounts counts;
257 if (m_ParcelCounts.TryGetValue(parcelID, out counts)) 337 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
258 return counts.Others; 338 count = counts.Others;
259 } 339 }
260 return 0; 340
341// m_log.DebugFormat(
342// "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}",
343// parcelID, m_Scene.RegionInfo.RegionName, count);
344
345 return count;
261 } 346 }
347
348 /// <summary>
349 /// Get the number of selected prims.
350 /// </summary>
351 /// <param name="parcelID"></param>
352 /// <returns></returns>
353 public int GetSelectedCount(UUID parcelID)
354 {
355 int count = 0;
356
357 lock (m_TaintLock)
358 {
359 if (m_Tainted)
360 Recount();
262 361
362 ParcelCounts counts;
363 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
364 count = counts.Selected;
365 }
366
367// m_log.DebugFormat(
368// "[PRIM COUNT MODULE]: GetSelectedCount for parcel {0} in {1} returning {2}",
369// parcelID, m_Scene.RegionInfo.RegionName, count);
370
371 return count;
372 }
373
374 /// <summary>
375 /// Get the total count of owner, group and others prims on the parcel.
376 /// FIXME: Need to do selected prims once this is reimplemented.
377 /// </summary>
378 /// <param name="parcelID"></param>
379 /// <returns></returns>
380 public int GetTotalCount(UUID parcelID)
381 {
382 int count = 0;
383
384 lock (m_TaintLock)
385 {
386 if (m_Tainted)
387 Recount();
388
389 ParcelCounts counts;
390 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
391 {
392 count = counts.Owner;
393 count += counts.Group;
394 count += counts.Others;
395 count += counts.Selected;
396 }
397 }
398
399// m_log.DebugFormat(
400// "[PRIM COUNT MODULE]: GetTotalCount for parcel {0} in {1} returning {2}",
401// parcelID, m_Scene.RegionInfo.RegionName, count);
402
403 return count;
404 }
405
406 /// <summary>
407 /// Get the number of prims that are in the entire simulator for the owner of this parcel.
408 /// </summary>
409 /// <param name="parcelID"></param>
410 /// <returns></returns>
263 public int GetSimulatorCount(UUID parcelID) 411 public int GetSimulatorCount(UUID parcelID)
264 { 412 {
413 int count = 0;
414
265 lock (m_TaintLock) 415 lock (m_TaintLock)
266 { 416 {
267 if (m_Tainted) 417 if (m_Tainted)
@@ -272,14 +422,27 @@ namespace OpenSim.Region.CoreModules.World.Land
272 { 422 {
273 int val; 423 int val;
274 if (m_SimwideCounts.TryGetValue(owner, out val)) 424 if (m_SimwideCounts.TryGetValue(owner, out val))
275 return val; 425 count = val;
276 } 426 }
277 } 427 }
278 return 0; 428
429// m_log.DebugFormat(
430// "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}",
431// parcelID, m_Scene.RegionInfo.RegionName, count);
432
433 return count;
279 } 434 }
280 435
436 /// <summary>
437 /// Get the number of prims that a particular user owns on this parcel.
438 /// </summary>
439 /// <param name="parcelID"></param>
440 /// <param name="userID"></param>
441 /// <returns></returns>
281 public int GetUserCount(UUID parcelID, UUID userID) 442 public int GetUserCount(UUID parcelID, UUID userID)
282 { 443 {
444 int count = 0;
445
283 lock (m_TaintLock) 446 lock (m_TaintLock)
284 { 447 {
285 if (m_Tainted) 448 if (m_Tainted)
@@ -290,27 +453,37 @@ namespace OpenSim.Region.CoreModules.World.Land
290 { 453 {
291 int val; 454 int val;
292 if (counts.Users.TryGetValue(userID, out val)) 455 if (counts.Users.TryGetValue(userID, out val))
293 return val; 456 count = val;
294 } 457 }
295 } 458 }
296 return 0; 459
460// m_log.DebugFormat(
461// "[PRIM COUNT MODULE]: GetUserCount for user {0} in parcel {1} in region {2} returning {3}",
462// userID, parcelID, m_Scene.RegionInfo.RegionName, count);
463
464 return count;
297 } 465 }
298 466
299 // NOTE: This method MUST be called while holding the taint lock! 467 // NOTE: This method MUST be called while holding the taint lock!
300 private void Recount() 468 private void Recount()
301 { 469 {
470// m_log.DebugFormat("[PRIM COUNT MODULE]: Recounting prims on {0}", m_Scene.RegionInfo.RegionName);
471
302 m_OwnerMap.Clear(); 472 m_OwnerMap.Clear();
303 m_SimwideCounts.Clear(); 473 m_SimwideCounts.Clear();
304 m_ParcelCounts.Clear(); 474 m_ParcelCounts.Clear();
305 475
306 List<ILandObject> land = m_Scene.LandChannel.AllParcels(); 476 List<ILandObject> land = m_Scene.LandChannel.AllParcels();
307 477
308 foreach (ILandObject l in land) 478 foreach (ILandObject l in land)
309 { 479 {
310 LandData landData = l.LandData; 480 LandData landData = l.LandData;
311 481
312 m_OwnerMap[landData.GlobalID] = landData.OwnerID; 482 m_OwnerMap[landData.GlobalID] = landData.OwnerID;
313 m_SimwideCounts[landData.OwnerID] = 0; 483 m_SimwideCounts[landData.OwnerID] = 0;
484// m_log.DebugFormat(
485// "[PRIM COUNT MODULE]: Initializing parcel count for {0} on {1}",
486// landData.Name, m_Scene.RegionInfo.RegionName);
314 m_ParcelCounts[landData.GlobalID] = new ParcelCounts(); 487 m_ParcelCounts[landData.GlobalID] = new ParcelCounts();
315 } 488 }
316 489
@@ -322,6 +495,7 @@ namespace OpenSim.Region.CoreModules.World.Land
322 if (!m_OwnerMap.ContainsKey(k)) 495 if (!m_OwnerMap.ContainsKey(k))
323 m_PrimCounts.Remove(k); 496 m_PrimCounts.Remove(k);
324 } 497 }
498
325 m_Tainted = false; 499 m_Tainted = false;
326 } 500 }
327 } 501 }
@@ -363,6 +537,22 @@ namespace OpenSim.Region.CoreModules.World.Land
363 return m_Parent.GetOthersCount(m_ParcelID); 537 return m_Parent.GetOthersCount(m_ParcelID);
364 } 538 }
365 } 539 }
540
541 public int Selected
542 {
543 get
544 {
545 return m_Parent.GetSelectedCount(m_ParcelID);
546 }
547 }
548
549 public int Total
550 {
551 get
552 {
553 return m_Parent.GetTotalCount(m_ParcelID);
554 }
555 }
366 556
367 public int Simulator 557 public int Simulator
368 { 558 {
@@ -403,4 +593,4 @@ namespace OpenSim.Region.CoreModules.World.Land
403 } 593 }
404 } 594 }
405 } 595 }
406} 596} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
new file mode 100644
index 0000000..67b00ac
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
@@ -0,0 +1,382 @@
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 System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenMetaverse.Assets;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock;
40using OpenSim.Tests.Common.Setup;
41
42namespace OpenSim.Region.CoreModules.World.Land.Tests
43{
44 [TestFixture]
45 public class PrimCountModuleTests
46 {
47 protected UUID m_userId = new UUID("00000000-0000-0000-0000-100000000000");
48 protected UUID m_groupId = new UUID("00000000-0000-0000-8888-000000000000");
49 protected UUID m_otherUserId = new UUID("99999999-9999-9999-9999-999999999999");
50 protected TestScene m_scene;
51 protected PrimCountModule m_pcm;
52
53 /// <summary>
54 /// A parcel that covers the entire sim except for a 1 unit wide strip on the eastern side.
55 /// </summary>
56 protected ILandObject m_lo;
57
58 /// <summary>
59 /// A parcel that covers just the eastern strip of the sim.
60 /// </summary>
61 protected ILandObject m_lo2;
62
63 [SetUp]
64 public void SetUp()
65 {
66 m_pcm = new PrimCountModule();
67 LandManagementModule lmm = new LandManagementModule();
68 m_scene = SceneSetupHelpers.SetupScene();
69 SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm);
70
71 int xParcelDivider = (int)Constants.RegionSize - 1;
72
73 ILandObject lo = new LandObject(m_userId, false, m_scene);
74 lo.LandData.Name = "m_lo";
75 lo.SetLandBitmap(
76 lo.GetSquareLandBitmap(0, 0, xParcelDivider, (int)Constants.RegionSize));
77 m_lo = lmm.AddLandObject(lo);
78
79 ILandObject lo2 = new LandObject(m_userId, false, m_scene);
80 lo2.SetLandBitmap(
81 lo2.GetSquareLandBitmap(xParcelDivider, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
82 lo2.LandData.Name = "m_lo2";
83 m_lo2 = lmm.AddLandObject(lo2);
84 }
85
86 /// <summary>
87 /// Test that counts before we do anything are correct.
88 /// </summary>
89 [Test]
90 public void TestInitialCounts()
91 {
92 IPrimCounts pc = m_lo.PrimCounts;
93
94 Assert.That(pc.Owner, Is.EqualTo(0));
95 Assert.That(pc.Group, Is.EqualTo(0));
96 Assert.That(pc.Others, Is.EqualTo(0));
97 Assert.That(pc.Total, Is.EqualTo(0));
98 Assert.That(pc.Selected, Is.EqualTo(0));
99 Assert.That(pc.Users[m_userId], Is.EqualTo(0));
100 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
101 Assert.That(pc.Simulator, Is.EqualTo(0));
102 }
103
104 /// <summary>
105 /// Test count after a parcel owner owned object is added.
106 /// </summary>
107 [Test]
108 public void TestAddOwnerObject()
109 {
110 TestHelper.InMethod();
111// log4net.Config.XmlConfigurator.Configure();
112
113 IPrimCounts pc = m_lo.PrimCounts;
114
115 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
116 m_scene.AddNewSceneObject(sog, false);
117
118 Assert.That(pc.Owner, Is.EqualTo(3));
119 Assert.That(pc.Group, Is.EqualTo(0));
120 Assert.That(pc.Others, Is.EqualTo(0));
121 Assert.That(pc.Total, Is.EqualTo(3));
122 Assert.That(pc.Selected, Is.EqualTo(0));
123 Assert.That(pc.Users[m_userId], Is.EqualTo(3));
124 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
125 Assert.That(pc.Simulator, Is.EqualTo(3));
126
127 // Add a second object and retest
128 SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10);
129 m_scene.AddNewSceneObject(sog2, false);
130
131 Assert.That(pc.Owner, Is.EqualTo(5));
132 Assert.That(pc.Group, Is.EqualTo(0));
133 Assert.That(pc.Others, Is.EqualTo(0));
134 Assert.That(pc.Total, Is.EqualTo(5));
135 Assert.That(pc.Selected, Is.EqualTo(0));
136 Assert.That(pc.Users[m_userId], Is.EqualTo(5));
137 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
138 Assert.That(pc.Simulator, Is.EqualTo(5));
139 }
140
141 /// <summary>
142 /// Test count after a parcel owner owned copied object is added.
143 /// </summary>
144 [Test]
145 public void TestCopyOwnerObject()
146 {
147 TestHelper.InMethod();
148// log4net.Config.XmlConfigurator.Configure();
149
150 IPrimCounts pc = m_lo.PrimCounts;
151
152 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
153 m_scene.AddNewSceneObject(sog, false);
154 m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity);
155
156 Assert.That(pc.Owner, Is.EqualTo(6));
157 Assert.That(pc.Group, Is.EqualTo(0));
158 Assert.That(pc.Others, Is.EqualTo(0));
159 Assert.That(pc.Total, Is.EqualTo(6));
160 Assert.That(pc.Selected, Is.EqualTo(0));
161 Assert.That(pc.Users[m_userId], Is.EqualTo(6));
162 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
163 Assert.That(pc.Simulator, Is.EqualTo(6));
164 }
165
166 /// <summary>
167 /// Test that parcel counts update correctly when an object is moved between parcels, where that movement
168 /// is not done directly by the user/
169 /// </summary>
170 [Test]
171 public void TestMoveOwnerObject()
172 {
173 TestHelper.InMethod();
174// log4net.Config.XmlConfigurator.Configure();
175
176 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
177 m_scene.AddNewSceneObject(sog, false);
178 SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10);
179 m_scene.AddNewSceneObject(sog2, false);
180
181 // Move the first scene object to the eastern strip parcel
182 sog.AbsolutePosition = new Vector3(254, 2, 2);
183
184 IPrimCounts pclo1 = m_lo.PrimCounts;
185
186 Assert.That(pclo1.Owner, Is.EqualTo(2));
187 Assert.That(pclo1.Group, Is.EqualTo(0));
188 Assert.That(pclo1.Others, Is.EqualTo(0));
189 Assert.That(pclo1.Total, Is.EqualTo(2));
190 Assert.That(pclo1.Selected, Is.EqualTo(0));
191 Assert.That(pclo1.Users[m_userId], Is.EqualTo(2));
192 Assert.That(pclo1.Users[m_otherUserId], Is.EqualTo(0));
193 Assert.That(pclo1.Simulator, Is.EqualTo(5));
194
195 IPrimCounts pclo2 = m_lo2.PrimCounts;
196
197 Assert.That(pclo2.Owner, Is.EqualTo(3));
198 Assert.That(pclo2.Group, Is.EqualTo(0));
199 Assert.That(pclo2.Others, Is.EqualTo(0));
200 Assert.That(pclo2.Total, Is.EqualTo(3));
201 Assert.That(pclo2.Selected, Is.EqualTo(0));
202 Assert.That(pclo2.Users[m_userId], Is.EqualTo(3));
203 Assert.That(pclo2.Users[m_otherUserId], Is.EqualTo(0));
204 Assert.That(pclo2.Simulator, Is.EqualTo(5));
205
206 // Now move it back again
207 sog.AbsolutePosition = new Vector3(2, 2, 2);
208
209 Assert.That(pclo1.Owner, Is.EqualTo(5));
210 Assert.That(pclo1.Group, Is.EqualTo(0));
211 Assert.That(pclo1.Others, Is.EqualTo(0));
212 Assert.That(pclo1.Total, Is.EqualTo(5));
213 Assert.That(pclo1.Selected, Is.EqualTo(0));
214 Assert.That(pclo1.Users[m_userId], Is.EqualTo(5));
215 Assert.That(pclo1.Users[m_otherUserId], Is.EqualTo(0));
216 Assert.That(pclo1.Simulator, Is.EqualTo(5));
217
218 Assert.That(pclo2.Owner, Is.EqualTo(0));
219 Assert.That(pclo2.Group, Is.EqualTo(0));
220 Assert.That(pclo2.Others, Is.EqualTo(0));
221 Assert.That(pclo2.Total, Is.EqualTo(0));
222 Assert.That(pclo2.Selected, Is.EqualTo(0));
223 Assert.That(pclo2.Users[m_userId], Is.EqualTo(0));
224 Assert.That(pclo2.Users[m_otherUserId], Is.EqualTo(0));
225 Assert.That(pclo2.Simulator, Is.EqualTo(5));
226 }
227
228 /// <summary>
229 /// Test count after a parcel owner owned object is removed.
230 /// </summary>
231 [Test]
232 public void TestRemoveOwnerObject()
233 {
234 TestHelper.InMethod();
235// log4net.Config.XmlConfigurator.Configure();
236
237 IPrimCounts pc = m_lo.PrimCounts;
238
239 m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1), false);
240 SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10);
241 m_scene.AddNewSceneObject(sogToDelete, false);
242 m_scene.DeleteSceneObject(sogToDelete, false);
243
244 Assert.That(pc.Owner, Is.EqualTo(1));
245 Assert.That(pc.Group, Is.EqualTo(0));
246 Assert.That(pc.Others, Is.EqualTo(0));
247 Assert.That(pc.Total, Is.EqualTo(1));
248 Assert.That(pc.Selected, Is.EqualTo(0));
249 Assert.That(pc.Users[m_userId], Is.EqualTo(1));
250 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
251 Assert.That(pc.Simulator, Is.EqualTo(1));
252 }
253
254 [Test]
255 public void TestAddGroupObject()
256 {
257 TestHelper.InMethod();
258// log4net.Config.XmlConfigurator.Configure();
259
260 m_lo.DeedToGroup(m_groupId);
261
262 IPrimCounts pc = m_lo.PrimCounts;
263
264 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01);
265 sog.GroupID = m_groupId;
266 m_scene.AddNewSceneObject(sog, false);
267
268 Assert.That(pc.Owner, Is.EqualTo(0));
269 Assert.That(pc.Group, Is.EqualTo(3));
270 Assert.That(pc.Others, Is.EqualTo(0));
271 Assert.That(pc.Total, Is.EqualTo(3));
272 Assert.That(pc.Selected, Is.EqualTo(0));
273
274 // Is this desired behaviour? Not totally sure.
275 Assert.That(pc.Users[m_userId], Is.EqualTo(0));
276 Assert.That(pc.Users[m_groupId], Is.EqualTo(0));
277 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(3));
278
279 Assert.That(pc.Simulator, Is.EqualTo(3));
280 }
281
282 /// <summary>
283 /// Test count after a parcel owner owned object is removed.
284 /// </summary>
285 [Test]
286 public void TestRemoveGroupObject()
287 {
288 TestHelper.InMethod();
289// log4net.Config.XmlConfigurator.Configure();
290
291 m_lo.DeedToGroup(m_groupId);
292
293 IPrimCounts pc = m_lo.PrimCounts;
294
295 SceneObjectGroup sogToKeep = SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1);
296 sogToKeep.GroupID = m_groupId;
297 m_scene.AddNewSceneObject(sogToKeep, false);
298
299 SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10);
300 m_scene.AddNewSceneObject(sogToDelete, false);
301 m_scene.DeleteSceneObject(sogToDelete, false);
302
303 Assert.That(pc.Owner, Is.EqualTo(0));
304 Assert.That(pc.Group, Is.EqualTo(1));
305 Assert.That(pc.Others, Is.EqualTo(0));
306 Assert.That(pc.Total, Is.EqualTo(1));
307 Assert.That(pc.Selected, Is.EqualTo(0));
308 Assert.That(pc.Users[m_userId], Is.EqualTo(1));
309 Assert.That(pc.Users[m_groupId], Is.EqualTo(0));
310 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
311 Assert.That(pc.Simulator, Is.EqualTo(1));
312 }
313
314 [Test]
315 public void TestAddOthersObject()
316 {
317 TestHelper.InMethod();
318// log4net.Config.XmlConfigurator.Configure();
319
320 IPrimCounts pc = m_lo.PrimCounts;
321
322 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01);
323 m_scene.AddNewSceneObject(sog, false);
324
325 Assert.That(pc.Owner, Is.EqualTo(0));
326 Assert.That(pc.Group, Is.EqualTo(0));
327 Assert.That(pc.Others, Is.EqualTo(3));
328 Assert.That(pc.Total, Is.EqualTo(3));
329 Assert.That(pc.Selected, Is.EqualTo(0));
330 Assert.That(pc.Users[m_userId], Is.EqualTo(0));
331 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(3));
332 Assert.That(pc.Simulator, Is.EqualTo(3));
333 }
334
335 [Test]
336 public void TestRemoveOthersObject()
337 {
338 TestHelper.InMethod();
339// log4net.Config.XmlConfigurator.Configure();
340
341 IPrimCounts pc = m_lo.PrimCounts;
342
343 m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_otherUserId, "a", 0x1), false);
344 SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "b", 0x10);
345 m_scene.AddNewSceneObject(sogToDelete, false);
346 m_scene.DeleteSceneObject(sogToDelete, false);
347
348 Assert.That(pc.Owner, Is.EqualTo(0));
349 Assert.That(pc.Group, Is.EqualTo(0));
350 Assert.That(pc.Others, Is.EqualTo(1));
351 Assert.That(pc.Total, Is.EqualTo(1));
352 Assert.That(pc.Selected, Is.EqualTo(0));
353 Assert.That(pc.Users[m_userId], Is.EqualTo(0));
354 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(1));
355 Assert.That(pc.Simulator, Is.EqualTo(1));
356 }
357
358 /// <summary>
359 /// Test the count is correct after is has been tainted.
360 /// </summary>
361 [Test]
362 public void TestTaint()
363 {
364 TestHelper.InMethod();
365 IPrimCounts pc = m_lo.PrimCounts;
366
367 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
368 m_scene.AddNewSceneObject(sog, false);
369
370 m_pcm.TaintPrimCount();
371
372 Assert.That(pc.Owner, Is.EqualTo(3));
373 Assert.That(pc.Group, Is.EqualTo(0));
374 Assert.That(pc.Others, Is.EqualTo(0));
375 Assert.That(pc.Total, Is.EqualTo(3));
376 Assert.That(pc.Selected, Is.EqualTo(0));
377 Assert.That(pc.Users[m_userId], Is.EqualTo(3));
378 Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
379 Assert.That(pc.Simulator, Is.EqualTo(3));
380 }
381 }
382} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
index cea7c78..4e14c73 100644
--- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
@@ -469,8 +469,8 @@ namespace OpenSim.Region.CoreModules
469 m_SunFixedHour = FixedSunHour; 469 m_SunFixedHour = FixedSunHour;
470 m_SunFixed = FixedSun; 470 m_SunFixed = FixedSun;
471 471
472 m_log.DebugFormat("[SUN]: Sun Settings Update: Fixed Sun? : {0}", m_SunFixed.ToString()); 472 // m_log.DebugFormat("[SUN]: Sun Settings Update: Fixed Sun? : {0}", m_SunFixed.ToString());
473 m_log.DebugFormat("[SUN]: Sun Settings Update: Sun Hour : {0}", m_SunFixedHour.ToString()); 473 // m_log.DebugFormat("[SUN]: Sun Settings Update: Sun Hour : {0}", m_SunFixedHour.ToString());
474 474
475 receivedEstateToolsSunUpdate = true; 475 receivedEstateToolsSunUpdate = true;
476 476
@@ -480,7 +480,7 @@ namespace OpenSim.Region.CoreModules
480 // When sun settings are updated, we should update all clients with new settings. 480 // When sun settings are updated, we should update all clients with new settings.
481 SunUpdateToAllClients(); 481 SunUpdateToAllClients();
482 482
483 m_log.DebugFormat("[SUN]: PosTime : {0}", PosTime.ToString()); 483 // m_log.DebugFormat("[SUN]: PosTime : {0}", PosTime.ToString());
484 } 484 }
485 } 485 }
486 486
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
index 6676ec8..d6fa093 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
@@ -62,9 +62,20 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
62 return LoadBitmap(new Bitmap(filename)); 62 return LoadBitmap(new Bitmap(filename));
63 } 63 }
64 64
65 public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) 65 public virtual ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int w, int h)
66 { 66 {
67 throw new NotImplementedException(); 67 Bitmap bitmap = new Bitmap(filename);
68 ITerrainChannel retval = new TerrainChannel(true);
69
70 for (int x = 0; x < retval.Width; x++)
71 {
72 for (int y = 0; y < retval.Height; y++)
73 {
74 retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128;
75 }
76 }
77
78 return retval;
68 } 79 }
69 80
70 public virtual ITerrainChannel LoadStream(Stream stream) 81 public virtual ITerrainChannel LoadStream(Stream stream)
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 7bb7544..f9ef286 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -100,8 +100,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
100 // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region 100 // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region
101 regionInfos = new List<GridRegion>(); 101 regionInfos = new List<GridRegion>();
102 GridRegion info = m_scene.GridService.GetRegionByName(m_scene.RegionInfo.ScopeID, mapName); 102 GridRegion info = m_scene.GridService.GetRegionByName(m_scene.RegionInfo.ScopeID, mapName);
103 if (info != null) regionInfos.Add(info); 103 if (info != null)
104 regionInfos.Add(info);
104 } 105 }
106 else if (regionInfos.Count == 0 && mapName.StartsWith("http://"))
107 remoteClient.SendAlertMessage("Hyperlink could not be established.");
108
105 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); 109 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count);
106 List<MapBlockData> blocks = new List<MapBlockData>(); 110 List<MapBlockData> blocks = new List<MapBlockData>();
107 111
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 41d6628..d939329 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -909,7 +909,7 @@ namespace OpenSim.Region.Examples.SimpleModule
909 { 909 {
910 } 910 }
911 911
912 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) 912 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
913 { 913 {
914 } 914 }
915 915
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs
index 95c9659..7066cf2 100644
--- a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs
@@ -34,12 +34,74 @@ namespace OpenSim.Region.Framework.Interfaces
34{ 34{
35 public interface IEstateDataService 35 public interface IEstateDataService
36 { 36 {
37 /// <summary>
38 /// Load estate settings for a region.
39 /// </summary>
40 /// <param name="regionID"></param>
41 /// <param name="create">If true, then an estate is created if one is not found.</param>
42 /// <returns></returns>
37 EstateSettings LoadEstateSettings(UUID regionID, bool create); 43 EstateSettings LoadEstateSettings(UUID regionID, bool create);
44
45 /// <summary>
46 /// Load estate settings for an estate ID.
47 /// </summary>
48 /// <param name="estateID"></param>
49 /// <returns></returns>
38 EstateSettings LoadEstateSettings(int estateID); 50 EstateSettings LoadEstateSettings(int estateID);
51
52 /// <summary>
53 /// Load/Get all estate settings.
54 /// </summary>
55 /// <returns>An empty list if no estates were found.</returns>
56 List<EstateSettings> LoadEstateSettingsAll();
57
58 /// <summary>
59 /// Store estate settings.
60 /// </summary>
61 /// <remarks>
62 /// This is also called by EstateSettings.Save()</remarks>
63 /// <param name="es"></param>
39 void StoreEstateSettings(EstateSettings es); 64 void StoreEstateSettings(EstateSettings es);
65
66 /// <summary>
67 /// Get estate IDs.
68 /// </summary>
69 /// <param name="search">Name of estate to search for. This is the exact name, no parttern matching is done.</param>
70 /// <returns></returns>
40 List<int> GetEstates(string search); 71 List<int> GetEstates(string search);
72
73 /// <summary>
74 /// Get the IDs of all estates owned by the given user.
75 /// </summary>
76 /// <returns>An empty list if no estates were found.</returns>
77 List<int> GetEstatesByOwner(UUID ownerID);
78
79 /// <summary>
80 /// Get the IDs of all estates.
81 /// </summary>
82 /// <returns>An empty list if no estates were found.</returns>
83 List<int> GetEstatesAll();
84
85 /// <summary>
86 /// Link a region to an estate.
87 /// </summary>
88 /// <param name="regionID"></param>
89 /// <param name="estateID"></param>
90 /// <returns>true if the link succeeded, false otherwise</returns>
41 bool LinkRegion(UUID regionID, int estateID); 91 bool LinkRegion(UUID regionID, int estateID);
92
93 /// <summary>
94 /// Get the UUIDs of all the regions in an estate.
95 /// </summary>
96 /// <param name="estateID"></param>
97 /// <returns></returns>
42 List<UUID> GetRegions(int estateID); 98 List<UUID> GetRegions(int estateID);
99
100 /// <summary>
101 /// Delete an estate
102 /// </summary>
103 /// <param name="estateID"></param>
104 /// <returns>true if the delete succeeded, false otherwise</returns>
43 bool DeleteEstate(int estateID); 105 bool DeleteEstate(int estateID);
44 } 106 }
45} 107} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
index 87c7a05..d790a30 100644
--- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
@@ -33,14 +33,80 @@ namespace OpenSim.Region.Framework.Interfaces
33{ 33{
34 public interface IEstateDataStore 34 public interface IEstateDataStore
35 { 35 {
36 /// <summary>
37 /// Initialise the data store.
38 /// </summary>
39 /// <param name="connectstring"></param>
36 void Initialise(string connectstring); 40 void Initialise(string connectstring);
37 41
42 /// <summary>
43 /// Load estate settings for a region.
44 /// </summary>
45 /// <param name="regionID"></param>
46 /// <param name="create">If true, then an estate is created if one is not found.</param>
47 /// <returns></returns>
38 EstateSettings LoadEstateSettings(UUID regionID, bool create); 48 EstateSettings LoadEstateSettings(UUID regionID, bool create);
49
50 /// <summary>
51 /// Load estate settings for an estate ID.
52 /// </summary>
53 /// <param name="estateID"></param>
54 /// <returns></returns>
39 EstateSettings LoadEstateSettings(int estateID); 55 EstateSettings LoadEstateSettings(int estateID);
56
57 /// <summary>
58 /// Load/Get all estate settings.
59 /// </summary>
60 /// <returns>An empty list if no estates were found.</returns>
61 List<EstateSettings> LoadEstateSettingsAll();
62
63 /// <summary>
64 /// Store estate settings.
65 /// </summary>
66 /// <remarks>
67 /// This is also called by EstateSettings.Save()</remarks>
68 /// <param name="es"></param>
40 void StoreEstateSettings(EstateSettings es); 69 void StoreEstateSettings(EstateSettings es);
70
71 /// <summary>
72 /// Get estate IDs.
73 /// </summary>
74 /// <param name="search">Name of estate to search for. This is the exact name, no parttern matching is done.</param>
75 /// <returns></returns>
41 List<int> GetEstates(string search); 76 List<int> GetEstates(string search);
77
78 /// <summary>
79 /// Get the IDs of all estates owned by the given user.
80 /// </summary>
81 /// <returns>An empty list if no estates were found.</returns>
82 List<int> GetEstatesByOwner(UUID ownerID);
83
84 /// <summary>
85 /// Get the IDs of all estates.
86 /// </summary>
87 /// <returns>An empty list if no estates were found.</returns>
88 List<int> GetEstatesAll();
89
90 /// <summary>
91 /// Link a region to an estate.
92 /// </summary>
93 /// <param name="regionID"></param>
94 /// <param name="estateID"></param>
95 /// <returns>true if the link succeeded, false otherwise</returns>
42 bool LinkRegion(UUID regionID, int estateID); 96 bool LinkRegion(UUID regionID, int estateID);
97
98 /// <summary>
99 /// Get the UUIDs of all the regions in an estate.
100 /// </summary>
101 /// <param name="estateID"></param>
102 /// <returns></returns>
43 List<UUID> GetRegions(int estateID); 103 List<UUID> GetRegions(int estateID);
104
105 /// <summary>
106 /// Delete an estate
107 /// </summary>
108 /// <param name="estateID"></param>
109 /// <returns>true if the delete succeeded, false otherwise</returns>
44 bool DeleteEstate(int estateID); 110 bool DeleteEstate(int estateID);
45 } 111 }
46} 112} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/ILandChannel.cs b/OpenSim/Region/Framework/Interfaces/ILandChannel.cs
deleted file mode 100644
index 30bae16..0000000
--- a/OpenSim/Region/Framework/Interfaces/ILandChannel.cs
+++ /dev/null
@@ -1,91 +0,0 @@
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 System.Collections.Generic;
29using OpenMetaverse;
30using OpenSim.Framework;
31
32namespace OpenSim.Region.Framework.Interfaces
33{
34 public interface ILandChannel
35 {
36 /// <summary>
37 /// Get all parcels
38 /// </summary>
39 /// <returns></returns>
40 List<ILandObject> AllParcels();
41
42 /// <summary>
43 /// Get the parcel at the specified point
44 /// </summary>
45 /// <param name="x">Value between 0 - 256 on the x axis of the point</param>
46 /// <param name="y">Value between 0 - 256 on the y axis of the point</param>
47 /// <returns>Land object at the point supplied</returns>
48 ILandObject GetLandObject(int x, int y);
49
50 /// <summary>
51 /// Get the parcel at the specified point
52 /// </summary>
53 /// <param name="x">Value between 0 - 256 on the x axis of the point</param>
54 /// <param name="y">Value between 0 - 256 on the y axis of the point</param>
55 /// <returns>Land object at the point supplied</returns>
56 ILandObject GetLandObject(float x, float y);
57
58 /// <summary>
59 /// Get the parcels near the specified point
60 /// </summary>
61 /// <param name="position"></param>
62 /// <returns></returns>
63 List<ILandObject> ParcelsNearPoint(Vector3 position);
64
65 /// <summary>
66 /// Get the parcel given the land's local id.
67 /// </summary>
68 /// <param name="localID"></param>
69 /// <returns></returns>
70 ILandObject GetLandObject(int localID);
71
72 /// <summary>
73 /// Clear the land channel of all parcels.
74 /// </summary>
75 /// <param name="setupDefaultParcel">
76 /// If true, set up a default parcel covering the whole region owned by the estate owner.
77 /// </param>
78 void Clear(bool setupDefaultParcel);
79
80 bool IsLandPrimCountTainted();
81 bool IsForcefulBansAllowed();
82 void UpdateLandObject(int localID, LandData data);
83 void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient);
84 void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel);
85 void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel);
86 void SetParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime);
87
88 void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id);
89 void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id);
90 }
91}
diff --git a/OpenSim/Region/Framework/Interfaces/ILandObject.cs b/OpenSim/Region/Framework/Interfaces/ILandObject.cs
deleted file mode 100644
index eeb9d3a..0000000
--- a/OpenSim/Region/Framework/Interfaces/ILandObject.cs
+++ /dev/null
@@ -1,112 +0,0 @@
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 System.Collections.Generic;
29using OpenMetaverse;
30using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes;
32
33namespace OpenSim.Region.Framework.Interfaces
34{
35 public delegate int overrideParcelMaxPrimCountDelegate(ILandObject obj);
36 public delegate int overrideSimulatorMaxPrimCountDelegate(ILandObject obj);
37
38 public interface ILandObject
39 {
40 int GetParcelMaxPrimCount(ILandObject thisObject);
41 int GetSimulatorMaxPrimCount(ILandObject thisObject);
42 int GetPrimsFree();
43
44 LandData LandData { get; set; }
45 bool[,] LandBitmap { get; set; }
46 UUID RegionUUID { get; }
47
48 /// <summary>
49 /// The start point for the land object. This is the western-most point as one scans land working from
50 /// north to south.
51 /// </summary>
52 Vector3 StartPoint { get; }
53
54 /// <summary>
55 /// The end point for the land object. This is the eastern-most point as one scans land working from
56 /// south to north.
57 /// </summary>
58 Vector3 EndPoint { get; }
59
60 bool ContainsPoint(int x, int y);
61
62 ILandObject Copy();
63
64 void SendLandUpdateToAvatarsOverMe();
65
66 void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client);
67 void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client);
68 bool IsEitherBannedOrRestricted(UUID avatar);
69 bool IsBannedFromLand(UUID avatar);
70 bool IsRestrictedFromLand(UUID avatar);
71 void SendLandUpdateToClient(IClientAPI remote_client);
72 void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client);
73 List<UUID> CreateAccessListArrayByFlag(AccessList flag);
74 void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client);
75 void UpdateAccessList(uint flags, UUID transactionID, int sequenceID, int sections, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client);
76 void UpdateLandBitmapByteArray();
77 void SetLandBitmapFromByteArray();
78 bool[,] GetLandBitmap();
79 void ForceUpdateLandInfo();
80 void SetLandBitmap(bool[,] bitmap);
81
82 bool[,] BasicFullRegionLandBitmap();
83 bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y);
84 bool[,] ModifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value);
85 bool[,] MergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add);
86 void SendForceObjectSelect(int local_id, int request_type, List<UUID> returnIDs, IClientAPI remote_client);
87 void SendLandObjectOwners(IClientAPI remote_client);
88 void ReturnObject(SceneObjectGroup obj);
89 void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client);
90 void ResetLandPrimCounts();
91 void AddPrimToCount(SceneObjectGroup obj);
92 void RemovePrimFromCount(SceneObjectGroup obj);
93 void UpdateLandSold(UUID avatarID, UUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area);
94
95 void DeedToGroup(UUID groupID);
96
97 void SetParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel);
98 void SetSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel);
99
100 /// <summary>
101 /// Set the media url for this land parcel
102 /// </summary>
103 /// <param name="url"></param>
104 void SetMediaUrl(string url);
105
106 /// <summary>
107 /// Set the music url for this land parcel
108 /// </summary>
109 /// <param name="url"></param>
110 void SetMusicUrl(string url);
111 }
112}
diff --git a/OpenSim/Region/Framework/Interfaces/IPrimCountModule.cs b/OpenSim/Region/Framework/Interfaces/IPrimCountModule.cs
index 65158e1..d63da2e 100644
--- a/OpenSim/Region/Framework/Interfaces/IPrimCountModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IPrimCountModule.cs
@@ -38,18 +38,4 @@ namespace OpenSim.Region.Framework.Interfaces
38 38
39 IPrimCounts GetPrimCounts(UUID parcelID); 39 IPrimCounts GetPrimCounts(UUID parcelID);
40 } 40 }
41 41} \ No newline at end of file
42 public interface IPrimCounts
43 {
44 int Owner { get; }
45 int Group { get; }
46 int Others { get; }
47 int Simulator { get; }
48 IUserPrimCounts Users { get; }
49 }
50
51 public interface IUserPrimCounts
52 {
53 int this[UUID agentID] { get; }
54 }
55}
diff --git a/OpenSim/Region/Framework/ModuleLoader.cs b/OpenSim/Region/Framework/ModuleLoader.cs
index 23be9c2..14ecd44 100644
--- a/OpenSim/Region/Framework/ModuleLoader.cs
+++ b/OpenSim/Region/Framework/ModuleLoader.cs
@@ -223,7 +223,8 @@ namespace OpenSim.Region.Framework
223 catch (Exception e) 223 catch (Exception e)
224 { 224 {
225 m_log.ErrorFormat( 225 m_log.ErrorFormat(
226 "[MODULES]: Could not load types for [{0}]. Exception {1}", pluginAssembly.FullName, e); 226 "[MODULES]: Could not load types for plugin DLL {0}. Exception {1} {2}",
227 pluginAssembly.FullName, e.Message, e.StackTrace);
227 228
228 // justincc: Right now this is fatal to really get the user's attention 229 // justincc: Right now this is fatal to really get the user's attention
229 throw e; 230 throw e;
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
index 64567db..8feb022 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -137,7 +137,7 @@ namespace OpenSim.Region.Framework.Scenes
137 x = m_inventoryDeletes.Dequeue(); 137 x = m_inventoryDeletes.Dequeue();
138 138
139 m_log.DebugFormat( 139 m_log.DebugFormat(
140 "[ASYNC DELETER]: Sending object to user's inventory, {0} item(s) remaining.", left); 140 "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.", left, x.action, x.objectGroups.Count);
141 141
142 try 142 try
143 { 143 {
@@ -177,4 +177,4 @@ namespace OpenSim.Region.Framework.Scenes
177 return false; 177 return false;
178 } 178 }
179 } 179 }
180} \ No newline at end of file 180}
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index c321a15..fd62535 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -242,7 +242,15 @@ namespace OpenSim.Region.Framework.Scenes
242 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID); 242 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID);
243 243
244 public event EstateToolsSunUpdate OnEstateToolsSunUpdate; 244 public event EstateToolsSunUpdate OnEstateToolsSunUpdate;
245
246 /// <summary>
247 /// Triggered when an object is added to the scene.
248 /// </summary>
249 public event Action<SceneObjectGroup> OnObjectAddedToScene;
245 250
251 /// <summary>
252 /// Triggered when an object is removed from the scene.
253 /// </summary>
246 public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); 254 public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj);
247 public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene; 255 public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene;
248 256
@@ -345,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes
345 public delegate void Attach(uint localID, UUID itemID, UUID avatarID); 353 public delegate void Attach(uint localID, UUID itemID, UUID avatarID);
346 public event Attach OnAttach; 354 public event Attach OnAttach;
347 355
356
348 /// <summary> 357 /// <summary>
349 /// Called immediately after an object is loaded from storage. 358 /// Called immediately after an object is loaded from storage.
350 /// </summary> 359 /// </summary>
@@ -800,6 +809,27 @@ namespace OpenSim.Region.Framework.Scenes
800 } 809 }
801 } 810 }
802 811
812 public void TriggerObjectAddedToScene(SceneObjectGroup obj)
813 {
814 Action<SceneObjectGroup> handler = OnObjectAddedToScene;
815 if (handler != null)
816 {
817 foreach (Action<SceneObjectGroup> d in handler.GetInvocationList())
818 {
819 try
820 {
821 d(obj);
822 }
823 catch (Exception e)
824 {
825 m_log.ErrorFormat(
826 "[EVENT MANAGER]: Delegate for TriggerObjectAddedToScene failed - continuing. {0} {1}",
827 e.Message, e.StackTrace);
828 }
829 }
830 }
831 }
832
803 public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj) 833 public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj)
804 { 834 {
805 ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = OnObjectBeingRemovedFromScene; 835 ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = OnObjectBeingRemovedFromScene;
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs
index f9599f5..4694e2b 100644
--- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs
+++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs
@@ -58,17 +58,8 @@ namespace OpenSim.Region.Framework.Scenes
58 58
59 public class Prioritizer 59 public class Prioritizer
60 { 60 {
61// private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 61 private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
62 62
63 /// <summary>
64 /// This is added to the priority of all child prims, to make sure that the root prim update is sent to the
65 /// viewer before child prim updates.
66 /// The adjustment is added to child prims and subtracted from root prims, so the gap ends up
67 /// being double. We do it both ways so that there is a still a priority delta even if the priority is already
68 /// double.MinValue or double.MaxValue.
69 /// </summary>
70 private double m_childPrimAdjustmentFactor = 0.05;
71
72 private Scene m_scene; 63 private Scene m_scene;
73 64
74 public Prioritizer(Scene scene) 65 public Prioritizer(Scene scene)
@@ -76,17 +67,35 @@ namespace OpenSim.Region.Framework.Scenes
76 m_scene = scene; 67 m_scene = scene;
77 } 68 }
78 69
79 public double GetUpdatePriority(IClientAPI client, ISceneEntity entity) 70 /// <summary>
71 /// Returns the priority queue into which the update should be placed. Updates within a
72 /// queue will be processed in arrival order. There are currently 12 priority queues
73 /// implemented in PriorityQueue class in LLClientView. Queue 0 is generally retained
74 /// for avatar updates. The fair queuing discipline for processing the priority queues
75 /// assumes that the number of entities in each priority queues increases exponentially.
76 /// So for example... if queue 1 contains all updates within 10m of the avatar or camera
77 /// then queue 2 at 20m is about 3X bigger in space & about 3X bigger in total number
78 /// of updates.
79 /// </summary>
80 public uint GetUpdatePriority(IClientAPI client, ISceneEntity entity)
80 { 81 {
81 double priority = 0; 82 // If entity is null we have a serious problem
82
83 if (entity == null) 83 if (entity == null)
84 return 100000; 84 {
85 m_log.WarnFormat("[PRIORITIZER] attempt to prioritize null entity");
86 throw new InvalidOperationException("Prioritization entity not defined");
87 }
88
89 // If this is an update for our own avatar give it the highest priority
90 if (client.AgentId == entity.UUID)
91 return 0;
92
93 uint priority;
85 94
86 switch (m_scene.UpdatePrioritizationScheme) 95 switch (m_scene.UpdatePrioritizationScheme)
87 { 96 {
88 case UpdatePrioritizationSchemes.Time: 97 case UpdatePrioritizationSchemes.Time:
89 priority = GetPriorityByTime(); 98 priority = GetPriorityByTime(client, entity);
90 break; 99 break;
91 case UpdatePrioritizationSchemes.Distance: 100 case UpdatePrioritizationSchemes.Distance:
92 priority = GetPriorityByDistance(client, entity); 101 priority = GetPriorityByDistance(client, entity);
@@ -104,180 +113,111 @@ namespace OpenSim.Region.Framework.Scenes
104 throw new InvalidOperationException("UpdatePrioritizationScheme not defined."); 113 throw new InvalidOperationException("UpdatePrioritizationScheme not defined.");
105 } 114 }
106 115
107 // Adjust priority so that root prims are sent to the viewer first. This is especially important for
108 // attachments acting as huds, since current viewers fail to display hud child prims if their updates
109 // arrive before the root one.
110 if (entity is SceneObjectPart)
111 {
112 SceneObjectPart sop = ((SceneObjectPart)entity);
113
114 if (sop.IsRoot)
115 {
116 if (priority >= double.MinValue + m_childPrimAdjustmentFactor)
117 priority -= m_childPrimAdjustmentFactor;
118 }
119 else
120 {
121 if (priority <= double.MaxValue - m_childPrimAdjustmentFactor)
122 priority += m_childPrimAdjustmentFactor;
123 }
124 }
125
126 return priority; 116 return priority;
127 } 117 }
128 118
129 private double GetPriorityByTime() 119
120 private uint GetPriorityByTime(IClientAPI client, ISceneEntity entity)
130 { 121 {
131 return DateTime.UtcNow.ToOADate(); 122 return 1;
132 } 123 }
133 124
134 private double GetPriorityByDistance(IClientAPI client, ISceneEntity entity) 125 private uint GetPriorityByDistance(IClientAPI client, ISceneEntity entity)
135 { 126 {
136 ScenePresence presence = m_scene.GetScenePresence(client.AgentId); 127 return ComputeDistancePriority(client,entity,false);
137 if (presence != null) 128 }
138 { 129
139 // If this is an update for our own avatar give it the highest priority 130 private uint GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity)
140 if (presence == entity) 131 {
141 return 0.0; 132 return ComputeDistancePriority(client,entity,true);
142
143 // Use the camera position for local agents and avatar position for remote agents
144 Vector3 presencePos = (presence.IsChildAgent) ?
145 presence.AbsolutePosition :
146 presence.CameraPosition;
147
148 // Use group position for child prims
149 Vector3 entityPos;
150 if (entity is SceneObjectPart)
151 {
152 // Can't use Scene.GetGroupByPrim() here, since the entity may have been delete from the scene
153 // before its scheduled update was triggered
154 //entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition;
155 entityPos = ((SceneObjectPart)entity).ParentGroup.AbsolutePosition;
156 }
157 else
158 {
159 entityPos = entity.AbsolutePosition;
160 }
161
162 return Vector3.DistanceSquared(presencePos, entityPos);
163 }
164
165 return double.NaN;
166 } 133 }
167 134
168 private double GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity) 135 private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity)
169 { 136 {
137 uint pqueue = ComputeDistancePriority(client,entity,true);
138
170 ScenePresence presence = m_scene.GetScenePresence(client.AgentId); 139 ScenePresence presence = m_scene.GetScenePresence(client.AgentId);
171 if (presence != null) 140 if (presence != null)
172 { 141 {
173 // If this is an update for our own avatar give it the highest priority
174 if (presence == entity)
175 return 0.0;
176
177 // Use group position for child prims
178 Vector3 entityPos = entity.AbsolutePosition;
179 if (entity is SceneObjectPart)
180 {
181 // Can't use Scene.GetGroupByPrim() here, since the entity may have been delete from the scene
182 // before its scheduled update was triggered
183 //entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition;
184 entityPos = ((SceneObjectPart)entity).ParentGroup.AbsolutePosition;
185 }
186 else
187 {
188 entityPos = entity.AbsolutePosition;
189 }
190
191 if (!presence.IsChildAgent) 142 if (!presence.IsChildAgent)
192 { 143 {
193 // Root agent. Use distance from camera and a priority decrease for objects behind us 144 if (entity is SceneObjectPart)
194 Vector3 camPosition = presence.CameraPosition; 145 {
195 Vector3 camAtAxis = presence.CameraAtAxis; 146 // Non physical prims are lower priority than physical prims
196 147 PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor;
197 // Distance 148 if (physActor == null || !physActor.IsPhysical)
198 double priority = Vector3.DistanceSquared(camPosition, entityPos); 149 pqueue++;
199
200 // Plane equation
201 float d = -Vector3.Dot(camPosition, camAtAxis);
202 float p = Vector3.Dot(camAtAxis, entityPos) + d;
203 if (p < 0.0f) priority *= 2.0;
204
205 return priority;
206 }
207 else
208 {
209 // Child agent. Use the normal distance method
210 Vector3 presencePos = presence.AbsolutePosition;
211 150
212 return Vector3.DistanceSquared(presencePos, entityPos); 151 // Attachments are high priority,
152 // MIC: shouldn't these already be in the highest priority queue already
153 // since their root position is same as the avatars?
154 if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment)
155 pqueue = 1;
156 }
213 } 157 }
214 } 158 }
215 159
216 return double.NaN; 160 return pqueue;
217 } 161 }
218 162
219 private double GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) 163 private uint ComputeDistancePriority(IClientAPI client, ISceneEntity entity, bool useFrontBack)
220 { 164 {
221 // If this is an update for our own avatar give it the highest priority 165 // Get this agent's position
222 if (client.AgentId == entity.UUID) 166 ScenePresence presence = m_scene.GetScenePresence(client.AgentId);
223 return 0.0; 167 if (presence == null)
224 if (entity == null) 168 {
225 return double.NaN; 169 m_log.WarnFormat("[PRIORITIZER] attempt to use agent {0} not in the scene",client.AgentId);
226 170 // throw new InvalidOperationException("Prioritization agent not defined");
227 // Use group position for child prims 171 return Int32.MaxValue;
172 }
173
174 // Use group position for child prims, since we are putting child prims in
175 // the same queue with the root of the group, the root prim (which goes into
176 // the queue first) should always be sent first, no need to adjust child prim
177 // priorities
228 Vector3 entityPos = entity.AbsolutePosition; 178 Vector3 entityPos = entity.AbsolutePosition;
229 if (entity is SceneObjectPart) 179 if (entity is SceneObjectPart)
230 { 180 {
231 SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup; 181 SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup;
232 if (group != null) 182 if (group != null)
233 entityPos = group.AbsolutePosition; 183 entityPos = group.AbsolutePosition;
234 else
235 entityPos = entity.AbsolutePosition;
236 } 184 }
237 else
238 entityPos = entity.AbsolutePosition;
239 185
240 ScenePresence presence = m_scene.GetScenePresence(client.AgentId); 186 // Use the camera position for local agents and avatar position for remote agents
241 if (presence != null) 187 Vector3 presencePos = (presence.IsChildAgent) ?
242 { 188 presence.AbsolutePosition :
243 if (!presence.IsChildAgent) 189 presence.CameraPosition;
244 {
245 if (entity is ScenePresence)
246 return 1.0;
247
248 // Root agent. Use distance from camera and a priority decrease for objects behind us
249 Vector3 camPosition = presence.CameraPosition;
250 Vector3 camAtAxis = presence.CameraAtAxis;
251 190
252 // Distance 191 // Compute the distance...
253 double priority = Vector3.DistanceSquared(camPosition, entityPos); 192 double distance = Vector3.Distance(presencePos, entityPos);
254 193
255 // Plane equation 194 // And convert the distance to a priority queue, this computation gives queues
256 float d = -Vector3.Dot(camPosition, camAtAxis); 195 // at 10, 20, 40, 80, 160, 320, 640, and 1280m
257 float p = Vector3.Dot(camAtAxis, entityPos) + d; 196 uint pqueue = 1;
258 if (p < 0.0f) priority *= 2.0; 197 for (int i = 0; i < 8; i++)
259 198 {
260 if (entity is SceneObjectPart) 199 if (distance < 10 * Math.Pow(2.0,i))
261 { 200 break;
262 PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; 201 pqueue++;
263 if (physActor == null || !physActor.IsPhysical) 202 }
264 priority += 100; 203
265 204 // If this is a root agent, then determine front & back
266 if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) 205 // Bump up the priority queue (drop the priority) for any objects behind the avatar
267 priority = 1.0; 206 if (useFrontBack && ! presence.IsChildAgent)
268 } 207 {
269 return priority; 208 // Root agent, decrease priority for objects behind us
270 } 209 Vector3 camPosition = presence.CameraPosition;
271 else 210 Vector3 camAtAxis = presence.CameraAtAxis;
272 { 211
273 // Child agent. Use the normal distance method 212 // Plane equation
274 Vector3 presencePos = presence.AbsolutePosition; 213 float d = -Vector3.Dot(camPosition, camAtAxis);
275 214 float p = Vector3.Dot(camAtAxis, entityPos) + d;
276 return Vector3.DistanceSquared(presencePos, entityPos); 215 if (p < 0.0f)
277 } 216 pqueue++;
278 } 217 }
279 218
280 return double.NaN; 219 return pqueue;
281 } 220 }
221
282 } 222 }
283} 223}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index fcbcf59..0f85925 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1955,11 +1955,49 @@ namespace OpenSim.Region.Framework.Scenes
1955 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 1955 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1956 bool RezSelected, bool RemoveItem, UUID fromTaskID) 1956 bool RezSelected, bool RemoveItem, UUID fromTaskID)
1957 { 1957 {
1958 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); 1958// m_log.DebugFormat(
1959 if (invAccess != null) 1959// "[PRIM INVENTORY]: RezObject from {0} for item {1} from task id {2}",
1960 invAccess.RezObject( 1960// remoteClient.Name, itemID, fromTaskID);
1961 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 1961
1962 RezSelected, RemoveItem, fromTaskID, false); 1962 if (fromTaskID == UUID.Zero)
1963 {
1964 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
1965 if (invAccess != null)
1966 invAccess.RezObject(
1967 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
1968 RezSelected, RemoveItem, fromTaskID, false);
1969 }
1970 else
1971 {
1972 SceneObjectPart part = GetSceneObjectPart(fromTaskID);
1973 if (part == null)
1974 {
1975 m_log.ErrorFormat(
1976 "[TASK INVENTORY]: {0} tried to rez item id {1} from object id {2} but there is no such scene object",
1977 remoteClient.Name, itemID, fromTaskID);
1978
1979 return;
1980 }
1981
1982 TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID);
1983 if (item == null)
1984 {
1985 m_log.ErrorFormat(
1986 "[TASK INVENTORY]: {0} tried to rez item id {1} from object id {2} but there is no such item",
1987 remoteClient.Name, itemID, fromTaskID);
1988
1989 return;
1990 }
1991
1992 byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0);
1993 Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f);
1994 Vector3 pos
1995 = GetNewRezLocation(
1996 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
1997 BypassRayCast, bRayEndIsIntersection, true, scale, false);
1998
1999 RezObject(part, item, pos, null, Vector3.Zero, 0);
2000 }
1963 } 2001 }
1964 2002
1965 /// <summary> 2003 /// <summary>
@@ -1967,14 +2005,14 @@ namespace OpenSim.Region.Framework.Scenes
1967 /// </summary> 2005 /// </summary>
1968 /// <param name="sourcePart"></param> 2006 /// <param name="sourcePart"></param>
1969 /// <param name="item"></param> 2007 /// <param name="item"></param>
1970 /// <param name="pos"></param> 2008 /// <param name="pos">The position of the rezzed object.</param>
1971 /// <param name="rot"></param> 2009 /// <param name="rot">The rotation of the rezzed object. If null, then the rotation stored with the object
1972 /// <param name="vel"></param> 2010 /// will be used if it exists.</param>
2011 /// <param name="vel">The velocity of the rezzed object.</param>
1973 /// <param name="param"></param> 2012 /// <param name="param"></param>
1974 /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful</returns> 2013 /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful</returns>
1975 public virtual SceneObjectGroup RezObject( 2014 public virtual SceneObjectGroup RezObject(
1976 SceneObjectPart sourcePart, TaskInventoryItem item, 2015 SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion? rot, Vector3 vel, int param)
1977 Vector3 pos, Quaternion rot, Vector3 vel, int param)
1978 { 2016 {
1979 if (null == item) 2017 if (null == item)
1980 return null; 2018 return null;
@@ -1992,8 +2030,14 @@ namespace OpenSim.Region.Framework.Scenes
1992 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 2030 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
1993 sourcePart.Inventory.RemoveInventoryItem(item.ItemID); 2031 sourcePart.Inventory.RemoveInventoryItem(item.ItemID);
1994 } 2032 }
1995 2033
1996 AddNewSceneObject(group, true, pos, rot, vel); 2034 AddNewSceneObject(group, true);
2035
2036 group.AbsolutePosition = pos;
2037 group.Velocity = vel;
2038
2039 if (rot != null)
2040 group.UpdateGroupRotationR((Quaternion)rot);
1997 2041
1998 // We can only call this after adding the scene object, since the scene object references the scene 2042 // We can only call this after adding the scene object, since the scene object references the scene
1999 // to find out if scripts should be activated at all. 2043 // to find out if scripts should be activated at all.
@@ -2069,7 +2113,10 @@ namespace OpenSim.Region.Framework.Scenes
2069 SceneObjectPart[] partList = sog.Parts; 2113 SceneObjectPart[] partList = sog.Parts;
2070 2114
2071 foreach (SceneObjectPart child in partList) 2115 foreach (SceneObjectPart child in partList)
2116 {
2072 child.Inventory.ChangeInventoryOwner(ownerID); 2117 child.Inventory.ChangeInventoryOwner(ownerID);
2118 child.TriggerScriptChangedEvent(Changed.OWNER);
2119 }
2073 } 2120 }
2074 else 2121 else
2075 { 2122 {
@@ -2085,6 +2132,7 @@ namespace OpenSim.Region.Framework.Scenes
2085 { 2132 {
2086 child.LastOwnerID = child.OwnerID; 2133 child.LastOwnerID = child.OwnerID;
2087 child.Inventory.ChangeInventoryOwner(groupID); 2134 child.Inventory.ChangeInventoryOwner(groupID);
2135 child.TriggerScriptChangedEvent(Changed.OWNER);
2088 } 2136 }
2089 2137
2090 sog.SetOwnerId(groupID); 2138 sog.SetOwnerId(groupID);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 1a6a70b..f0acc38 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -563,7 +563,6 @@ namespace OpenSim.Region.Framework.Scenes
563 m_regInfo = regInfo; 563 m_regInfo = regInfo;
564 m_regionHandle = m_regInfo.RegionHandle; 564 m_regionHandle = m_regInfo.RegionHandle;
565 m_regionName = m_regInfo.RegionName; 565 m_regionName = m_regInfo.RegionName;
566 m_datastore = m_regInfo.DataStore;
567 m_lastUpdate = Util.EnvironmentTickCount(); 566 m_lastUpdate = Util.EnvironmentTickCount();
568 567
569 m_physicalPrim = physicalPrim; 568 m_physicalPrim = physicalPrim;
@@ -1109,7 +1108,7 @@ namespace OpenSim.Region.Framework.Scenes
1109 // 1108 //
1110 while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) 1109 while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null)
1111 { 1110 {
1112 MainConsole.Instance.Output("The current estate has no owner set."); 1111 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", m_regInfo.EstateSettings.EstateName);
1113 List<char> excluded = new List<char>(new char[1]{' '}); 1112 List<char> excluded = new List<char>(new char[1]{' '});
1114 string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded); 1113 string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded);
1115 string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded); 1114 string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded);
@@ -1429,20 +1428,6 @@ namespace OpenSim.Region.Framework.Scenes
1429 } 1428 }
1430 1429
1431 /// <summary> 1430 /// <summary>
1432 /// Recount SceneObjectPart in parcel aabb
1433 /// </summary>
1434 private void UpdateLand()
1435 {
1436 if (LandChannel != null)
1437 {
1438 if (LandChannel.IsLandPrimCountTainted())
1439 {
1440 EventManager.TriggerParcelPrimCountUpdate();
1441 }
1442 }
1443 }
1444
1445 /// <summary>
1446 /// Update the terrain if it needs to be updated. 1431 /// Update the terrain if it needs to be updated.
1447 /// </summary> 1432 /// </summary>
1448 private void UpdateTerrain() 1433 private void UpdateTerrain()
@@ -1536,8 +1521,11 @@ namespace OpenSim.Region.Framework.Scenes
1536 } 1521 }
1537 1522
1538 /// <summary> 1523 /// <summary>
1539 /// Return object to avatar Message 1524 /// Tell an agent that their object has been returned.
1540 /// </summary> 1525 /// </summary>
1526 /// <remarks>
1527 /// The actual return is handled by the caller.
1528 /// </remarks>
1541 /// <param name="agentID">Avatar Unique Id</param> 1529 /// <param name="agentID">Avatar Unique Id</param>
1542 /// <param name="objectName">Name of object returned</param> 1530 /// <param name="objectName">Name of object returned</param>
1543 /// <param name="location">Location of object returned</param> 1531 /// <param name="location">Location of object returned</param>
@@ -1956,8 +1944,14 @@ namespace OpenSim.Region.Framework.Scenes
1956 /// If false, it is left to the caller to schedule the update 1944 /// If false, it is left to the caller to schedule the update
1957 /// </param> 1945 /// </param>
1958 public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) 1946 public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
1959 { 1947 {
1960 return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); 1948 if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates))
1949 {
1950 EventManager.TriggerObjectAddedToScene(sceneObject);
1951 return true;
1952 }
1953
1954 return false;
1961 } 1955 }
1962 1956
1963 /// <summary> 1957 /// <summary>
@@ -1974,7 +1968,13 @@ namespace OpenSim.Region.Framework.Scenes
1974 public bool AddNewSceneObject( 1968 public bool AddNewSceneObject(
1975 SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) 1969 SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel)
1976 { 1970 {
1977 return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel); 1971 if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel))
1972 {
1973 EventManager.TriggerObjectAddedToScene(sceneObject);
1974 return true;
1975 }
1976
1977 return false;
1978 } 1978 }
1979 1979
1980 /// <summary> 1980 /// <summary>
@@ -4854,8 +4854,17 @@ namespace OpenSim.Region.Framework.Scenes
4854 { 4854 {
4855 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; 4855 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ;
4856 4856
4857 Vector3 vec = g.AbsolutePosition;
4858
4857 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); 4859 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
4858 4860
4861 ominX += vec.X;
4862 omaxX += vec.X;
4863 ominY += vec.Y;
4864 omaxY += vec.Y;
4865 ominZ += vec.Z;
4866 omaxZ += vec.Z;
4867
4859 if (minX > ominX) 4868 if (minX > ominX)
4860 minX = ominX; 4869 minX = ominX;
4861 if (minY > ominY) 4870 if (minY > ominY)
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index f343bc8..c4547f2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -136,8 +136,6 @@ namespace OpenSim.Region.Framework.Scenes
136 get { return m_permissions; } 136 get { return m_permissions; }
137 } 137 }
138 138
139 protected string m_datastore;
140
141 /* Used by the loadbalancer plugin on GForge */ 139 /* Used by the loadbalancer plugin on GForge */
142 protected RegionStatus m_regStatus; 140 protected RegionStatus m_regStatus;
143 public RegionStatus RegionStatus 141 public RegionStatus RegionStatus
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 734ba22..97af0a0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -88,9 +88,21 @@ namespace OpenSim.Region.Framework.Scenes
88 protected internal object m_syncRoot = new object(); 88 protected internal object m_syncRoot = new object();
89 89
90 protected internal PhysicsScene _PhyScene; 90 protected internal PhysicsScene _PhyScene;
91 91
92 protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalID = new Dictionary<uint, SceneObjectGroup>(); 92 /// <summary>
93 /// Index the SceneObjectGroup for each part by the root part's UUID.
94 /// </summary>
93 protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullID = new Dictionary<UUID, SceneObjectGroup>(); 95 protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullID = new Dictionary<UUID, SceneObjectGroup>();
96
97 /// <summary>
98 /// Index the SceneObjectGroup for each part by that part's UUID.
99 /// </summary>
100 protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullPartID = new Dictionary<UUID, SceneObjectGroup>();
101
102 /// <summary>
103 /// Index the SceneObjectGroup for each part by that part's local ID.
104 /// </summary>
105 protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>();
94 106
95 private Object m_updateLock = new Object(); 107 private Object m_updateLock = new Object();
96 108
@@ -133,8 +145,10 @@ namespace OpenSim.Region.Framework.Scenes
133 145
134 lock (SceneObjectGroupsByFullID) 146 lock (SceneObjectGroupsByFullID)
135 SceneObjectGroupsByFullID.Clear(); 147 SceneObjectGroupsByFullID.Clear();
136 lock (SceneObjectGroupsByLocalID) 148 lock (SceneObjectGroupsByFullPartID)
137 SceneObjectGroupsByLocalID.Clear(); 149 SceneObjectGroupsByFullPartID.Clear();
150 lock (SceneObjectGroupsByLocalPartID)
151 SceneObjectGroupsByLocalPartID.Clear();
138 152
139 Entities.Clear(); 153 Entities.Clear();
140 } 154 }
@@ -349,6 +363,10 @@ namespace OpenSim.Region.Framework.Scenes
349 363
350 if (Entities.ContainsKey(sceneObject.UUID)) 364 if (Entities.ContainsKey(sceneObject.UUID))
351 return false; 365 return false;
366
367// m_log.DebugFormat(
368// "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}",
369// sceneObject.Name, sceneObject.UUID, sceneObject.Parts.Length, m_parentScene.RegionInfo.RegionName);
352 370
353 SceneObjectPart[] children = sceneObject.Parts; 371 SceneObjectPart[] children = sceneObject.Parts;
354 372
@@ -385,17 +403,20 @@ namespace OpenSim.Region.Framework.Scenes
385 OnObjectCreate(sceneObject); 403 OnObjectCreate(sceneObject);
386 404
387 lock (SceneObjectGroupsByFullID) 405 lock (SceneObjectGroupsByFullID)
388 {
389 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; 406 SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject;
407
408 lock (SceneObjectGroupsByFullPartID)
409 {
410 SceneObjectGroupsByFullPartID[sceneObject.UUID] = sceneObject;
390 foreach (SceneObjectPart part in children) 411 foreach (SceneObjectPart part in children)
391 SceneObjectGroupsByFullID[part.UUID] = sceneObject; 412 SceneObjectGroupsByFullPartID[part.UUID] = sceneObject;
392 } 413 }
393 414
394 lock (SceneObjectGroupsByLocalID) 415 lock (SceneObjectGroupsByLocalPartID)
395 { 416 {
396 SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; 417 SceneObjectGroupsByLocalPartID[sceneObject.LocalId] = sceneObject;
397 foreach (SceneObjectPart part in children) 418 foreach (SceneObjectPart part in children)
398 SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; 419 SceneObjectGroupsByLocalPartID[part.LocalId] = sceneObject;
399 } 420 }
400 421
401 return true; 422 return true;
@@ -426,21 +447,24 @@ namespace OpenSim.Region.Framework.Scenes
426 447
427 if (OnObjectRemove != null) 448 if (OnObjectRemove != null)
428 OnObjectRemove(Entities[uuid]); 449 OnObjectRemove(Entities[uuid]);
429 450
430 lock (SceneObjectGroupsByFullID) 451 lock (SceneObjectGroupsByFullID)
452 SceneObjectGroupsByFullID.Remove(grp.UUID);
453
454 lock (SceneObjectGroupsByFullPartID)
431 { 455 {
432 SceneObjectPart[] parts = grp.Parts; 456 SceneObjectPart[] parts = grp.Parts;
433 for (int i = 0; i < parts.Length; i++) 457 for (int i = 0; i < parts.Length; i++)
434 SceneObjectGroupsByFullID.Remove(parts[i].UUID); 458 SceneObjectGroupsByFullPartID.Remove(parts[i].UUID);
435 SceneObjectGroupsByFullID.Remove(grp.RootPart.UUID); 459 SceneObjectGroupsByFullPartID.Remove(grp.RootPart.UUID);
436 } 460 }
437 461
438 lock (SceneObjectGroupsByLocalID) 462 lock (SceneObjectGroupsByLocalPartID)
439 { 463 {
440 SceneObjectPart[] parts = grp.Parts; 464 SceneObjectPart[] parts = grp.Parts;
441 for (int i = 0; i < parts.Length; i++) 465 for (int i = 0; i < parts.Length; i++)
442 SceneObjectGroupsByLocalID.Remove(parts[i].LocalId); 466 SceneObjectGroupsByLocalPartID.Remove(parts[i].LocalId);
443 SceneObjectGroupsByLocalID.Remove(grp.RootPart.LocalId); 467 SceneObjectGroupsByLocalPartID.Remove(grp.RootPart.LocalId);
444 } 468 }
445 469
446 return Entities.Remove(uuid); 470 return Entities.Remove(uuid);
@@ -627,7 +651,7 @@ namespace OpenSim.Region.Framework.Scenes
627 if (!Entities.Remove(agentID)) 651 if (!Entities.Remove(agentID))
628 { 652 {
629 m_log.WarnFormat( 653 m_log.WarnFormat(
630 "[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", 654 "[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list",
631 agentID); 655 agentID);
632 } 656 }
633 657
@@ -650,7 +674,7 @@ namespace OpenSim.Region.Framework.Scenes
650 } 674 }
651 else 675 else
652 { 676 {
653 m_log.WarnFormat("[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); 677 m_log.WarnFormat("[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID);
654 } 678 }
655 } 679 }
656 } 680 }
@@ -854,14 +878,14 @@ namespace OpenSim.Region.Framework.Scenes
854 878
855 //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID); 879 //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID);
856 SceneObjectGroup sog; 880 SceneObjectGroup sog;
857 lock (SceneObjectGroupsByLocalID) 881 lock (SceneObjectGroupsByLocalPartID)
858 SceneObjectGroupsByLocalID.TryGetValue(localID, out sog); 882 SceneObjectGroupsByLocalPartID.TryGetValue(localID, out sog);
859 883
860 if (sog != null) 884 if (sog != null)
861 { 885 {
862 if (sog.HasChildPrim(localID)) 886 if (sog.HasChildPrim(localID))
863 return sog; 887 return sog;
864 SceneObjectGroupsByLocalID.Remove(localID); 888 SceneObjectGroupsByLocalPartID.Remove(localID);
865 } 889 }
866 890
867 EntityBase[] entityList = GetEntities(); 891 EntityBase[] entityList = GetEntities();
@@ -873,8 +897,8 @@ namespace OpenSim.Region.Framework.Scenes
873 sog = (SceneObjectGroup)ent; 897 sog = (SceneObjectGroup)ent;
874 if (sog.HasChildPrim(localID)) 898 if (sog.HasChildPrim(localID))
875 { 899 {
876 lock (SceneObjectGroupsByLocalID) 900 lock (SceneObjectGroupsByLocalPartID)
877 SceneObjectGroupsByLocalID[localID] = sog; 901 SceneObjectGroupsByLocalPartID[localID] = sog;
878 return sog; 902 return sog;
879 } 903 }
880 } 904 }
@@ -891,16 +915,16 @@ namespace OpenSim.Region.Framework.Scenes
891 private SceneObjectGroup GetGroupByPrim(UUID fullID) 915 private SceneObjectGroup GetGroupByPrim(UUID fullID)
892 { 916 {
893 SceneObjectGroup sog; 917 SceneObjectGroup sog;
894 lock (SceneObjectGroupsByFullID) 918 lock (SceneObjectGroupsByFullPartID)
895 SceneObjectGroupsByFullID.TryGetValue(fullID, out sog); 919 SceneObjectGroupsByFullPartID.TryGetValue(fullID, out sog);
896 920
897 if (sog != null) 921 if (sog != null)
898 { 922 {
899 if (sog.ContainsPart(fullID)) 923 if (sog.ContainsPart(fullID))
900 return sog; 924 return sog;
901 925
902 lock (SceneObjectGroupsByFullID) 926 lock (SceneObjectGroupsByFullPartID)
903 SceneObjectGroupsByFullID.Remove(fullID); 927 SceneObjectGroupsByFullPartID.Remove(fullID);
904 } 928 }
905 929
906 EntityBase[] entityList = GetEntities(); 930 EntityBase[] entityList = GetEntities();
@@ -911,8 +935,8 @@ namespace OpenSim.Region.Framework.Scenes
911 sog = (SceneObjectGroup)ent; 935 sog = (SceneObjectGroup)ent;
912 if (sog.HasChildPrim(fullID)) 936 if (sog.HasChildPrim(fullID))
913 { 937 {
914 lock (SceneObjectGroupsByFullID) 938 lock (SceneObjectGroupsByFullPartID)
915 SceneObjectGroupsByFullID[fullID] = sog; 939 SceneObjectGroupsByFullPartID[fullID] = sog;
916 return sog; 940 return sog;
917 } 941 }
918 } 942 }
@@ -1064,11 +1088,12 @@ namespace OpenSim.Region.Framework.Scenes
1064 } 1088 }
1065 1089
1066 /// <summary> 1090 /// <summary>
1067 /// Performs action on all scene object groups. 1091 /// Performs action once on all scene object groups.
1068 /// </summary> 1092 /// </summary>
1069 /// <param name="action"></param> 1093 /// <param name="action"></param>
1070 protected internal void ForEachSOG(Action<SceneObjectGroup> action) 1094 protected internal void ForEachSOG(Action<SceneObjectGroup> action)
1071 { 1095 {
1096 // FIXME: Need to lock here, really.
1072 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); 1097 List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
1073 foreach (SceneObjectGroup obj in objlist) 1098 foreach (SceneObjectGroup obj in objlist)
1074 { 1099 {
@@ -1079,11 +1104,11 @@ namespace OpenSim.Region.Framework.Scenes
1079 catch (Exception e) 1104 catch (Exception e)
1080 { 1105 {
1081 // Catch it and move on. This includes situations where splist has inconsistent info 1106 // Catch it and move on. This includes situations where splist has inconsistent info
1082 m_log.WarnFormat("[SCENE]: Problem processing action in ForEachSOG: ", e.ToString()); 1107 m_log.WarnFormat(
1108 "[SCENEGRAPH]: Problem processing action in ForEachSOG: {0} {1}", e.Message, e.StackTrace);
1083 } 1109 }
1084 } 1110 }
1085 } 1111 }
1086
1087 1112
1088 /// <summary> 1113 /// <summary>
1089 /// Performs action on all scene presences. This can ultimately run the actions in parallel but 1114 /// Performs action on all scene presences. This can ultimately run the actions in parallel but
@@ -1103,8 +1128,8 @@ namespace OpenSim.Region.Framework.Scenes
1103 } 1128 }
1104 catch (Exception e) 1129 catch (Exception e)
1105 { 1130 {
1106 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); 1131 m_log.Info("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1107 m_log.Info("[BUG] Stack Trace: " + e.StackTrace); 1132 m_log.Info("[SCENEGRAPH]: Stack Trace: " + e.StackTrace);
1108 } 1133 }
1109 }); 1134 });
1110 Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction); 1135 Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction);
@@ -1119,7 +1144,7 @@ namespace OpenSim.Region.Framework.Scenes
1119 } 1144 }
1120 catch (Exception e) 1145 catch (Exception e)
1121 { 1146 {
1122 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); 1147 m_log.Error("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1123 } 1148 }
1124 } 1149 }
1125 } 1150 }
@@ -1777,7 +1802,10 @@ namespace OpenSim.Region.Framework.Scenes
1777 /// <param name="rot"></param> 1802 /// <param name="rot"></param>
1778 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) 1803 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot)
1779 { 1804 {
1780 //m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID); 1805// m_log.DebugFormat(
1806// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}",
1807// originalPrimID, offset, AgentID);
1808
1781 SceneObjectGroup original = GetGroupByPrim(originalPrimID); 1809 SceneObjectGroup original = GetGroupByPrim(originalPrimID);
1782 if (original != null) 1810 if (original != null)
1783 { 1811 {
@@ -1808,7 +1836,28 @@ namespace OpenSim.Region.Framework.Scenes
1808 copy.RootPart.SalePrice = 10; 1836 copy.RootPart.SalePrice = 10;
1809 } 1837 }
1810 1838
1839 // FIXME: This section needs to be refactored so that it just calls AddSceneObject()
1811 Entities.Add(copy); 1840 Entities.Add(copy);
1841
1842 lock (SceneObjectGroupsByFullID)
1843 SceneObjectGroupsByFullID[copy.UUID] = copy;
1844
1845 SceneObjectPart[] children = copy.Parts;
1846
1847 lock (SceneObjectGroupsByFullPartID)
1848 {
1849 SceneObjectGroupsByFullPartID[copy.UUID] = copy;
1850 foreach (SceneObjectPart part in children)
1851 SceneObjectGroupsByFullPartID[part.UUID] = copy;
1852 }
1853
1854 lock (SceneObjectGroupsByLocalPartID)
1855 {
1856 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy;
1857 foreach (SceneObjectPart part in children)
1858 SceneObjectGroupsByLocalPartID[part.LocalId] = copy;
1859 }
1860 // PROBABLE END OF FIXME
1812 1861
1813 // Since we copy from a source group that is in selected 1862 // Since we copy from a source group that is in selected
1814 // state, but the copy is shown deselected in the viewer, 1863 // state, but the copy is shown deselected in the viewer,
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index f17fb28..ca7d9d9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -325,6 +325,8 @@ namespace OpenSim.Region.Framework.Scenes
325 //m_rootPart.GroupPosition.Z); 325 //m_rootPart.GroupPosition.Z);
326 //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 326 //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
327 //} 327 //}
328
329 m_scene.EventManager.TriggerParcelPrimCountTainted();
328 } 330 }
329 } 331 }
330 332
@@ -1313,8 +1315,10 @@ namespace OpenSim.Region.Framework.Scenes
1313 parcel.LandData.OtherCleanTime) 1315 parcel.LandData.OtherCleanTime)
1314 { 1316 {
1315 DetachFromBackup(); 1317 DetachFromBackup();
1316 m_log.InfoFormat("[SCENE]: Returning object {0} due to parcel auto return", RootPart.UUID.ToString()); 1318 m_log.DebugFormat(
1317 m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel auto return"); 1319 "[SCENE OBJECT GROUP]: Returning object {0} due to parcel autoreturn",
1320 RootPart.UUID);
1321 m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel autoreturn");
1318 m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero, 1322 m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero,
1319 DeRezAction.Return, UUID.Zero); 1323 DeRezAction.Return, UUID.Zero);
1320 1324
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index fa404c0..3281eab 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -175,12 +175,12 @@ namespace OpenSim.Region.Framework.Scenes
175 foreach (TaskInventoryItem item in items) 175 foreach (TaskInventoryItem item in items)
176 { 176 {
177 if (ownerId != item.OwnerID) 177 if (ownerId != item.OwnerID)
178 {
179 item.LastOwnerID = item.OwnerID; 178 item.LastOwnerID = item.OwnerID;
180 item.OwnerID = ownerId; 179
181 item.PermsMask = 0; 180 item.OwnerID = ownerId;
182 item.PermsGranter = UUID.Zero; 181 item.PermsMask = 0;
183 } 182 item.PermsGranter = UUID.Zero;
183 item.OwnerChanged = true;
184 } 184 }
185 } 185 }
186 186
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 49382f0..821cd4b 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -1247,7 +1247,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1247 1247
1248 } 1248 }
1249 1249
1250 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) 1250 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
1251 { 1251 {
1252 1252
1253 } 1253 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
index 2fcc477..0d6313a 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
@@ -80,16 +80,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
80 m_config = config.Configs["Concierge"]; 80 m_config = config.Configs["Concierge"];
81 81
82 if (null == m_config) 82 if (null == m_config)
83 {
84 m_log.Info("[Concierge]: no config found, plugin disabled");
85 return; 83 return;
86 }
87 84
88 if (!m_config.GetBoolean("enabled", false)) 85 if (!m_config.GetBoolean("enabled", false))
89 {
90 m_log.Info("[Concierge]: plugin disabled by configuration");
91 return; 86 return;
92 } 87
93 m_enabled = true; 88 m_enabled = true;
94 89
95 90
@@ -113,9 +108,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
113 { 108 {
114 m_replacingChatModule = false; 109 m_replacingChatModule = false;
115 } 110 }
111
116 m_log.InfoFormat("[Concierge] {0} ChatModule", m_replacingChatModule ? "replacing" : "not replacing"); 112 m_log.InfoFormat("[Concierge] {0} ChatModule", m_replacingChatModule ? "replacing" : "not replacing");
117 113
118
119 // take note of concierge channel and of identity 114 // take note of concierge channel and of identity
120 m_conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", m_conciergeChannel); 115 m_conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", m_conciergeChannel);
121 m_whoami = m_config.GetString("whoami", "conferencier"); 116 m_whoami = m_config.GetString("whoami", "conferencier");
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index 05a1c3b..7909d8a 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -106,16 +106,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
106 m_Config = config.Configs["FreeSwitchVoice"]; 106 m_Config = config.Configs["FreeSwitchVoice"];
107 107
108 if (m_Config == null) 108 if (m_Config == null)
109 {
110 m_log.Info("[FreeSwitchVoice] no config found, plugin disabled");
111 return; 109 return;
112 }
113 110
114 if (!m_Config.GetBoolean("Enabled", false)) 111 if (!m_Config.GetBoolean("Enabled", false))
115 {
116 m_log.Info("[FreeSwitchVoice] plugin disabled by configuration");
117 return; 112 return;
118 }
119 113
120 try 114 try
121 { 115 {
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
index 34d0e24..534bf92 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
@@ -121,16 +121,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
121 m_config = config.Configs["VivoxVoice"]; 121 m_config = config.Configs["VivoxVoice"];
122 122
123 if (null == m_config) 123 if (null == m_config)
124 {
125 m_log.Info("[VivoxVoice] no config found, plugin disabled");
126 return; 124 return;
127 }
128 125
129 if (!m_config.GetBoolean("enabled", false)) 126 if (!m_config.GetBoolean("enabled", false))
130 {
131 m_log.Info("[VivoxVoice] plugin disabled by configuration");
132 return; 127 return;
133 }
134 128
135 try 129 try
136 { 130 {
@@ -218,7 +212,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
218 m_pluginEnabled = true; 212 m_pluginEnabled = true;
219 213
220 m_log.Info("[VivoxVoice] plugin enabled"); 214 m_log.Info("[VivoxVoice] plugin enabled");
221
222 } 215 }
223 catch (Exception e) 216 catch (Exception e)
224 { 217 {
@@ -228,7 +221,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
228 } 221 }
229 } 222 }
230 223
231
232 // Called to indicate that the module has been added to the region 224 // Called to indicate that the module has been added to the region
233 public void AddRegion(Scene scene) 225 public void AddRegion(Scene scene)
234 { 226 {
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
index 3d34441..8c01d75 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
@@ -86,13 +86,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
86 return; 86 return;
87 } 87 }
88 88
89 m_log.Info("[GROUPS-MESSAGING]: Initializing GroupsMessagingModule");
90
91 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); 89 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
92 } 90 }
93 91
94 m_log.Info("[GROUPS-MESSAGING]: GroupsMessagingModule starting up"); 92 m_log.Info("[GROUPS-MESSAGING]: GroupsMessagingModule starting up");
95
96 } 93 }
97 94
98 public void AddRegion(Scene scene) 95 public void AddRegion(Scene scene)
diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
index 781fe95..dddea3e 100644
--- a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
+++ b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
@@ -33,6 +33,9 @@ using Nini.Config;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
35 35
36[assembly: Addin("BareBonesSharedModule", "0.1")]
37[assembly: AddinDependency("OpenSim", "0.5")]
38
36namespace OpenSim.Region.OptionalModules.Example.BareBonesShared 39namespace OpenSim.Region.OptionalModules.Example.BareBonesShared
37{ 40{
38 /// <summary> 41 /// <summary>
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs
index 8df020f..c898da6 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs
@@ -25,6 +25,7 @@
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
28using OpenSim.Framework;
28using OpenSim.Region.Framework.Interfaces; 29using OpenSim.Region.Framework.Interfaces;
29using OpenSim.Region.Framework.Scenes; 30using OpenSim.Region.Framework.Scenes;
30 31
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
index df60709..74f5208 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
75 75
76 if (source.Configs["MRM"].GetBoolean("Enabled", false)) 76 if (source.Configs["MRM"].GetBoolean("Enabled", false))
77 { 77 {
78 m_log.Info("[MRM] Enabling MRM Module"); 78 m_log.Info("[MRM]: Enabling MRM Module");
79 m_scene = scene; 79 m_scene = scene;
80 80
81 // when hidden, we don't listen for client initiated script events 81 // when hidden, we don't listen for client initiated script events
@@ -90,14 +90,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
90 90
91 scene.RegisterModuleInterface<IMRMModule>(this); 91 scene.RegisterModuleInterface<IMRMModule>(this);
92 } 92 }
93 else
94 {
95 m_log.Info("[MRM] Disabled MRM Module (Disabled in ini)");
96 }
97 }
98 else
99 {
100 m_log.Info("[MRM] Disabled MRM Module (Default disabled)");
101 } 93 }
102 } 94 }
103 95
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 5d44aa1..96760a2 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -925,7 +925,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
925 { 925 {
926 } 926 }
927 927
928 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor,int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) 928 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor,int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
929 { 929 {
930 } 930 }
931 public void SendLandAccessListData(List<UUID> avatars, uint accessFlag, int localLandID) 931 public void SendLandAccessListData(List<UUID> avatars, uint accessFlag, int localLandID)
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs
index 98e5453..a133e51 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs
+++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs
@@ -130,11 +130,6 @@ public class RegionCombinerLargeLandChannel : ILandChannel
130 } 130 }
131 } 131 }
132 132
133 public bool IsLandPrimCountTainted()
134 {
135 return RootRegionLandChannel.IsLandPrimCountTainted();
136 }
137
138 public bool IsForcefulBansAllowed() 133 public bool IsForcefulBansAllowed()
139 { 134 {
140 return RootRegionLandChannel.IsForcefulBansAllowed(); 135 return RootRegionLandChannel.IsForcefulBansAllowed();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 72ee495..aa28fa0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -81,7 +81,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
81 /// </summary> 81 /// </summary>
82 public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi 82 public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi
83 { 83 {
84 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 84 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
85 protected IScriptEngine m_ScriptEngine; 85 protected IScriptEngine m_ScriptEngine;
86 protected SceneObjectPart m_host; 86 protected SceneObjectPart m_host;
87 protected uint m_localID; 87 protected uint m_localID;
@@ -9835,63 +9835,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9835 public LSL_Integer llGetParcelPrimCount(LSL_Vector pos, int category, int sim_wide) 9835 public LSL_Integer llGetParcelPrimCount(LSL_Vector pos, int category, int sim_wide)
9836 { 9836 {
9837 m_host.AddScriptLPS(1); 9837 m_host.AddScriptLPS(1);
9838
9839 ILandObject lo = World.LandChannel.GetLandObject((float)pos.x, (float)pos.y);
9838 9840
9839 LandData land = World.GetLandData((float)pos.x, (float)pos.y); 9841 if (lo == null)
9840
9841 if (land == null)
9842 {
9843 return 0; 9842 return 0;
9844 } 9843
9844 IPrimCounts pc = lo.PrimCounts;
9845 9845
9846 else 9846 if (sim_wide != ScriptBaseClass.FALSE)
9847 { 9847 {
9848 if (sim_wide != 0) 9848 if (category == ScriptBaseClass.PARCEL_COUNT_TOTAL)
9849 { 9849 {
9850 if (category == 0) 9850 return pc.Simulator;
9851 {
9852 return land.SimwidePrims;
9853 }
9854
9855 else
9856 {
9857 //public int simwideArea = 0;
9858 return 0;
9859 }
9860 } 9851 }
9861
9862 else 9852 else
9863 { 9853 {
9864 if (category == 0)//Total Prims 9854 // counts not implemented yet
9865 { 9855 return 0;
9866 return 0;//land.
9867 }
9868
9869 else if (category == 1)//Owner Prims
9870 {
9871 return land.OwnerPrims;
9872 }
9873
9874 else if (category == 2)//Group Prims
9875 {
9876 return land.GroupPrims;
9877 }
9878
9879 else if (category == 3)//Other Prims
9880 {
9881 return land.OtherPrims;
9882 }
9883
9884 else if (category == 4)//Selected
9885 {
9886 return land.SelectedPrims;
9887 }
9888
9889 else if (category == 5)//Temp
9890 {
9891 return 0;//land.
9892 }
9893 } 9856 }
9894 } 9857 }
9858 else
9859 {
9860 if (category == ScriptBaseClass.PARCEL_COUNT_TOTAL)
9861 return pc.Total;
9862 else if (category == ScriptBaseClass.PARCEL_COUNT_OWNER)
9863 return pc.Owner;
9864 else if (category == ScriptBaseClass.PARCEL_COUNT_GROUP)
9865 return pc.Group;
9866 else if (category == ScriptBaseClass.PARCEL_COUNT_OTHER)
9867 return pc.Others;
9868 else if (category == ScriptBaseClass.PARCEL_COUNT_SELECTED)
9869 return pc.Selected;
9870 else if (category == ScriptBaseClass.PARCEL_COUNT_TEMP)
9871 return 0; // counts not implemented yet
9872 }
9873
9895 return 0; 9874 return 0;
9896 } 9875 }
9897 9876
@@ -10278,6 +10257,60 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10278 10257
10279 return GetLinkPrimitiveParams(obj, rules); 10258 return GetLinkPrimitiveParams(obj, rules);
10280 } 10259 }
10260
10261 public void print(string str)
10262 {
10263 // yes, this is a real LSL function. See: http://wiki.secondlife.com/wiki/Print
10264 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_itemID, "OSSL");
10265 if (ossl != null)
10266 {
10267 ossl.CheckThreatLevel(ThreatLevel.High, "print");
10268 m_log.Info("LSL print():" + str);
10269 }
10270 }
10271
10272 private string Name2Username(string name)
10273 {
10274 string[] parts = name.Split(new char[] {' '});
10275 if (parts.Length < 2)
10276 return name.ToLower();
10277 if (parts[1] == "Resident")
10278 return parts[0].ToLower();
10279
10280 return name.Replace(" ", ".").ToLower();
10281 }
10282
10283 public LSL_String llGetUsername(string id)
10284 {
10285 return Name2Username(llKey2Name(id));
10286 }
10287
10288 public LSL_String llRequestUsername(string id)
10289 {
10290 UUID rq = UUID.Random();
10291
10292 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString());
10293
10294 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id)));
10295
10296 return rq.ToString();
10297 }
10298
10299 public LSL_String llGetDisplayName(string id)
10300 {
10301 return llKey2Name(id);
10302 }
10303
10304 public LSL_String llRequestDisplayName(string id)
10305 {
10306 UUID rq = UUID.Random();
10307
10308 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString());
10309
10310 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id));
10311
10312 return rq.ToString();
10313 }
10281 } 10314 }
10282 10315
10283 public class NotecardCache 10316 public class NotecardCache
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index fefbb35..47c7915 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -50,6 +50,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
50 private Object SenseLock = new Object(); 50 private Object SenseLock = new Object();
51 51
52 private const int AGENT = 1; 52 private const int AGENT = 1;
53 private const int AGENT_BY_USERNAME = 0x10;
53 private const int ACTIVE = 2; 54 private const int ACTIVE = 2;
54 private const int PASSIVE = 4; 55 private const int PASSIVE = 4;
55 private const int SCRIPTED = 8; 56 private const int SCRIPTED = 8;
@@ -202,7 +203,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
202 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 203 List<SensedEntity> sensedEntities = new List<SensedEntity>();
203 204
204 // Is the sensor type is AGENT and not SCRIPTED then include agents 205 // Is the sensor type is AGENT and not SCRIPTED then include agents
205 if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) 206 if ((ts.type & (AGENT | AGENT_BY_USERNAME)) != 0 && (ts.type & SCRIPTED) == 0)
206 { 207 {
207 sensedEntities.AddRange(doAgentSensor(ts)); 208 sensedEntities.AddRange(doAgentSensor(ts));
208 } 209 }
@@ -493,9 +494,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
493 { 494 {
494 ScenePresence sp; 495 ScenePresence sp;
495 // Try lookup by name will return if/when found 496 // Try lookup by name will return if/when found
496 if (!m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp)) 497 if (((ts.type & AGENT) != 0) && m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp))
497 return sensedEntities; 498 senseEntity(sp);
498 senseEntity(sp); 499 if ((ts.type & AGENT_BY_USERNAME) != 0)
500 {
501 m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(
502 delegate (ScenePresence ssp)
503 {
504 if (ssp.Lastname == "Resident")
505 {
506 if (ssp.Firstname.ToLower() == ts.name)
507 senseEntity(ssp);
508 return;
509 }
510 if (ssp.Name.Replace(" ", ".").ToLower() == ts.name)
511 senseEntity(ssp);
512 }
513 );
514 }
515
516 return sensedEntities;
499 } 517 }
500 else 518 else
501 { 519 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 561e3b3..654ea81 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -209,6 +209,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
209 void llInstantMessage(string user, string message); 209 void llInstantMessage(string user, string message);
210 LSL_String llIntegerToBase64(int number); 210 LSL_String llIntegerToBase64(int number);
211 LSL_String llKey2Name(string id); 211 LSL_String llKey2Name(string id);
212 LSL_String llGetUsername(string id);
213 LSL_String llRequestUsername(string id);
214 LSL_String llGetDisplayName(string id);
215 LSL_String llRequestDisplayName(string id);
212 void llLinkParticleSystem(int linknum, LSL_List rules); 216 void llLinkParticleSystem(int linknum, LSL_List rules);
213 LSL_String llList2CSV(LSL_List src); 217 LSL_String llList2CSV(LSL_List src);
214 LSL_Float llList2Float(LSL_List src, int index); 218 LSL_Float llList2Float(LSL_List src, int index);
@@ -398,6 +402,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
398 LSL_Vector llWind(LSL_Vector offset); 402 LSL_Vector llWind(LSL_Vector offset);
399 LSL_String llXorBase64Strings(string str1, string str2); 403 LSL_String llXorBase64Strings(string str1, string str2);
400 LSL_String llXorBase64StringsCorrect(string str1, string str2); 404 LSL_String llXorBase64StringsCorrect(string str1, string str2);
405 void print(string str);
401 406
402 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 407 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
403 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 408 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index b3c4d95..9377cda 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -50,6 +50,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
50 public const int STATUS_CAST_SHADOWS = 512; 50 public const int STATUS_CAST_SHADOWS = 512;
51 51
52 public const int AGENT = 1; 52 public const int AGENT = 1;
53 public const int AGENT_BY_LEGACY_NAME = 1;
54 public const int AGENT_BY_USERNAME = 0x10;
53 public const int ACTIVE = 2; 55 public const int ACTIVE = 2;
54 public const int PASSIVE = 4; 56 public const int PASSIVE = 4;
55 public const int SCRIPTED = 8; 57 public const int SCRIPTED = 8;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 451163f..303d75e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -894,6 +894,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
894 return m_LSL_Functions.llKey2Name(id); 894 return m_LSL_Functions.llKey2Name(id);
895 } 895 }
896 896
897 public LSL_String llGetUsername(string id)
898 {
899 return m_LSL_Functions.llGetUsername(id);
900 }
901
902 public LSL_String llRequestUsername(string id)
903 {
904 return m_LSL_Functions.llRequestUsername(id);
905 }
906
907 public LSL_String llGetDisplayName(string id)
908 {
909 return m_LSL_Functions.llGetDisplayName(id);
910 }
911
912 public LSL_String llRequestDisplayName(string id)
913 {
914 return m_LSL_Functions.llRequestDisplayName(id);
915 }
916
897 public void llLinkParticleSystem(int linknum, LSL_List rules) 917 public void llLinkParticleSystem(int linknum, LSL_List rules)
898 { 918 {
899 m_LSL_Functions.llLinkParticleSystem(linknum, rules); 919 m_LSL_Functions.llLinkParticleSystem(linknum, rules);
@@ -1847,5 +1867,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1847 { 1867 {
1848 return m_LSL_Functions.llClearPrimMedia(face); 1868 return m_LSL_Functions.llClearPrimMedia(face);
1849 } 1869 }
1870
1871 public void print(string str)
1872 {
1873 m_LSL_Functions.print(str);
1874 }
1850 } 1875 }
1851} 1876}