From d3a20a1e9257ecec417e219ebaf079370015f06d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 21 Mar 2011 21:37:06 +0000 Subject: On initial region registration, if the user chooses the option to make the region part of an existing estate, then list the existing region names. --- OpenSim/Region/Application/OpenSimBase.cs | 13 ++++++++++++- OpenSim/Region/Framework/Interfaces/IEstateDataService.cs | 14 ++++++++++++++ OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs | 14 ++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index e950613..f804cb7 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -828,7 +828,18 @@ namespace OpenSim } else { - response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); + List estates = estateDataService.LoadEstateSettingsAll(); + + List estateNames = new List(); + foreach (EstateSettings estate in estates) + estateNames.Add(estate.EstateName); + + response + = MainConsole.Instance.CmdPrompt( + string.Format( + "Name of estate to join. Existing estate names are ({0})", string.Join(", ", estateNames.ToArray())), + "None"); + if (response == "None") continue; diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs index 95c9659..12ed9e3 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs @@ -36,8 +36,22 @@ namespace OpenSim.Region.Framework.Interfaces { EstateSettings LoadEstateSettings(UUID regionID, bool create); EstateSettings LoadEstateSettings(int estateID); + + /// + /// Load/Get all estate settings. + /// + /// An empty list if no estates were found. + List LoadEstateSettingsAll(); + void StoreEstateSettings(EstateSettings es); List GetEstates(string search); + + /// + /// Get the IDs of all estates. + /// + /// An empty list if no estates were found. + List GetEstatesAll(); + bool LinkRegion(UUID regionID, int estateID); List GetRegions(int estateID); bool DeleteEstate(int estateID); diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs index 87c7a05..d78ad78 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs @@ -37,8 +37,22 @@ namespace OpenSim.Region.Framework.Interfaces EstateSettings LoadEstateSettings(UUID regionID, bool create); EstateSettings LoadEstateSettings(int estateID); + + /// + /// Load/Get all estate settings. + /// + /// An empty list if no estates were found. + List LoadEstateSettingsAll(); + void StoreEstateSettings(EstateSettings es); List GetEstates(string search); + + /// + /// Get the IDs of all estates. + /// + /// An empty list if no estates were found. + List GetEstatesAll(); + bool LinkRegion(UUID regionID, int estateID); List GetRegions(int estateID); bool DeleteEstate(int estateID); -- cgit v1.1 From 793bfb5a663879296789efa8350df0e9cabb2148 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 21 Mar 2011 22:25:20 +0000 Subject: add method doc to IEstateDataService and IEstateDataStore interfaces --- .../Framework/Interfaces/IEstateDataService.cs | 44 +++++++++++++++++++- .../Framework/Interfaces/IEstateDataStore.cs | 48 +++++++++++++++++++++- 2 files changed, 90 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs index 12ed9e3..55adef1 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs @@ -34,7 +34,19 @@ namespace OpenSim.Region.Framework.Interfaces { public interface IEstateDataService { + /// + /// Load estate settings for a region. + /// + /// + /// If true, then an estate is created if one is not found. This is used in migration. + /// EstateSettings LoadEstateSettings(UUID regionID, bool create); + + /// + /// Load estate settings for an estate ID. + /// + /// + /// EstateSettings LoadEstateSettings(int estateID); /// @@ -43,7 +55,19 @@ namespace OpenSim.Region.Framework.Interfaces /// An empty list if no estates were found. List LoadEstateSettingsAll(); + /// + /// Store estate settings. + /// + /// + /// This is also called by EstateSettings.Save() + /// void StoreEstateSettings(EstateSettings es); + + /// + /// Get estate IDs. + /// + /// Name of estate to search for. This is the exact name, no parttern matching is done. + /// List GetEstates(string search); /// @@ -52,8 +76,26 @@ namespace OpenSim.Region.Framework.Interfaces /// An empty list if no estates were found. List GetEstatesAll(); + /// + /// Link a region to an estate. + /// + /// + /// + /// true if the link succeeded, false otherwise bool LinkRegion(UUID regionID, int estateID); + + /// + /// Get the UUIDs of all the regions in an estate. + /// + /// + /// List GetRegions(int estateID); + + /// + /// Delete an estate + /// + /// + /// true if the delete succeeded, false otherwise bool DeleteEstate(int estateID); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs index d78ad78..4974d5d 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs @@ -33,9 +33,25 @@ namespace OpenSim.Region.Framework.Interfaces { public interface IEstateDataStore { + /// + /// Initialise the data store. + /// + /// void Initialise(string connectstring); + /// + /// Load estate settings for a region. + /// + /// + /// If true, then an estate is created if one is not found. This is used in migration. + /// EstateSettings LoadEstateSettings(UUID regionID, bool create); + + /// + /// Load estate settings for an estate ID. + /// + /// + /// EstateSettings LoadEstateSettings(int estateID); /// @@ -44,7 +60,19 @@ namespace OpenSim.Region.Framework.Interfaces /// An empty list if no estates were found. List LoadEstateSettingsAll(); + /// + /// Store estate settings. + /// + /// + /// This is also called by EstateSettings.Save() + /// void StoreEstateSettings(EstateSettings es); + + /// + /// Get estate IDs. + /// + /// Name of estate to search for. This is the exact name, no parttern matching is done. + /// List GetEstates(string search); /// @@ -53,8 +81,26 @@ namespace OpenSim.Region.Framework.Interfaces /// An empty list if no estates were found. List GetEstatesAll(); + /// + /// Link a region to an estate. + /// + /// + /// + /// true if the link succeeded, false otherwise bool LinkRegion(UUID regionID, int estateID); + + /// + /// Get the UUIDs of all the regions in an estate. + /// + /// + /// List GetRegions(int estateID); + + /// + /// Delete an estate + /// + /// + /// true if the delete succeeded, false otherwise bool DeleteEstate(int estateID); } -} +} \ No newline at end of file -- cgit v1.1 From 2d1f0d224c355e92997643cf849b8e9774dddbad Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 21 Mar 2011 22:27:16 +0000 Subject: minor: slightly adjust previous method doc. --- OpenSim/Region/Framework/Interfaces/IEstateDataService.cs | 2 +- OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs index 55adef1..38c10a6 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs @@ -38,7 +38,7 @@ namespace OpenSim.Region.Framework.Interfaces /// Load estate settings for a region. /// /// - /// If true, then an estate is created if one is not found. This is used in migration. + /// If true, then an estate is created if one is not found. /// EstateSettings LoadEstateSettings(UUID regionID, bool create); diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs index 4974d5d..c82661d 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs @@ -43,7 +43,7 @@ namespace OpenSim.Region.Framework.Interfaces /// Load estate settings for a region. /// /// - /// If true, then an estate is created if one is not found. This is used in migration. + /// If true, then an estate is created if one is not found. /// EstateSettings LoadEstateSettings(UUID regionID, bool create); -- cgit v1.1 From ee7cfc2854aba3572d5342b8c1bfd5bf4ea93841 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 21 Mar 2011 22:47:02 +0000 Subject: refactor: use EstateDataService property directly instead of loading it into a local variable --- OpenSim/Region/Application/OpenSimBase.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index f804cb7..eae3686 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -798,12 +798,8 @@ namespace OpenSim /// public void PopulateRegionEstateInfo(RegionInfo regInfo) { - IEstateDataService estateDataService = EstateDataService; - - if (estateDataService != null) - { - regInfo.EstateSettings = estateDataService.LoadEstateSettings(regInfo.RegionID, false); - } + if (EstateDataService != null) + regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, false); if (regInfo.EstateSettings.EstateID == 0) // No record at all { @@ -814,7 +810,7 @@ namespace OpenSim if (response == "no") { // Create a new estate - regInfo.EstateSettings = estateDataService.LoadEstateSettings(regInfo.RegionID, true); + regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); @@ -828,7 +824,7 @@ namespace OpenSim } else { - List estates = estateDataService.LoadEstateSettingsAll(); + List estates = EstateDataService.LoadEstateSettingsAll(); List estateNames = new List(); foreach (EstateSettings estate in estates) @@ -843,7 +839,7 @@ namespace OpenSim if (response == "None") continue; - List estateIDs = estateDataService.GetEstates(response); + List estateIDs = EstateDataService.GetEstates(response); if (estateIDs.Count < 1) { MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); @@ -852,9 +848,9 @@ namespace OpenSim int estateID = estateIDs[0]; - regInfo.EstateSettings = estateDataService.LoadEstateSettings(estateID); + regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID); - if (estateDataService.LinkRegion(regInfo.RegionID, estateID)) + if (EstateDataService.LinkRegion(regInfo.RegionID, estateID)) break; MainConsole.Instance.Output("Joining the estate failed. Please try again."); @@ -863,7 +859,6 @@ namespace OpenSim } } } - public class OpenSimConfigSource { -- cgit v1.1 From 060a53b896d338309458861161eb0b9e621d4171 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 21 Mar 2011 22:57:20 +0000 Subject: On initial opensim setup, don't ask the user whether they want to join an existing opensim estate when there aren't any. Proceed directly to estate setup instead. --- OpenSim/Region/Application/OpenSimBase.cs | 102 ++++++++++++++++++------------ 1 file changed, 63 insertions(+), 39 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index eae3686..81a10e3 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -793,6 +793,25 @@ namespace OpenSim } /// + /// Create an estate with an initial region. + /// + /// + public void CreateEstate(RegionInfo regInfo) + { + // Create a new estate + regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); + + regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); + + // FIXME: Later on, the scene constructor will reload the estate settings no matter what. + // Therefore, we need to do an initial save here otherwise the new estate name will be reset + // back to the default. The reloading of estate settings by scene could be eliminated if it + // knows that the passed in settings in RegionInfo are already valid. Also, it might be + // possible to eliminate some additional later saves made by callers of this method. + regInfo.EstateSettings.Save(); + } + + /// /// Load the estate information for the provided RegionInfo object. /// /// @@ -804,56 +823,61 @@ namespace OpenSim if (regInfo.EstateSettings.EstateID == 0) // No record at all { MainConsole.Instance.Output("Your region is not part of an estate."); + + List estates = EstateDataService.LoadEstateSettingsAll(); + while (true) { - string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List() { "yes", "no" }); - if (response == "no") - { - // Create a new estate - regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); - - regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); + if (estates.Count == 0) + { + MainConsole.Instance.Output( + "There aren't any existing estates. You will need to create a new one for this region."); - // FIXME: Later on, the scene constructor will reload the estate settings no matter what. - // Therefore, we need to do an initial save here otherwise the new estate name will be reset - // back to the default. The reloading of estate settings by scene could be eliminated if it - // knows that the passed in settings in RegionInfo are already valid. Also, it might be - // possible to eliminate some additional later saves made by callers of this method. - regInfo.EstateSettings.Save(); + CreateEstate(regInfo); break; } else { - List estates = EstateDataService.LoadEstateSettingsAll(); - - List estateNames = new List(); - foreach (EstateSettings estate in estates) - estateNames.Add(estate.EstateName); - - response + string response = MainConsole.Instance.CmdPrompt( - string.Format( - "Name of estate to join. Existing estate names are ({0})", string.Join(", ", estateNames.ToArray())), - "None"); + "Do you wish to join an existing estate (yes/no)?", "no", new List() { "yes", "no" }); - if (response == "None") - continue; - - List estateIDs = EstateDataService.GetEstates(response); - if (estateIDs.Count < 1) + if (response == "no") { - MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); - continue; - } - - int estateID = estateIDs[0]; - - regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID); - - if (EstateDataService.LinkRegion(regInfo.RegionID, estateID)) + CreateEstate(regInfo); break; - - MainConsole.Instance.Output("Joining the estate failed. Please try again."); + } + else + { + List estateNames = new List(); + foreach (EstateSettings estate in estates) + estateNames.Add(estate.EstateName); + + response + = MainConsole.Instance.CmdPrompt( + string.Format( + "Name of estate to join. Existing estate names are ({0})", string.Join(", ", estateNames.ToArray())), + "None"); + + if (response == "None") + continue; + + List estateIDs = EstateDataService.GetEstates(response); + if (estateIDs.Count < 1) + { + MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); + continue; + } + + int estateID = estateIDs[0]; + + regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID); + + if (EstateDataService.LinkRegion(regInfo.RegionID, estateID)) + break; + + MainConsole.Instance.Output("Joining the estate failed. Please try again."); + } } } } -- cgit v1.1 From 3382de4d8bcfce0c3f8e2e63ee63ed2428322461 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 21 Mar 2011 23:16:57 +0000 Subject: In initial setup, stop a user being able to create a new estate with the same name as an existing estate. --- OpenSim/Region/Application/OpenSimBase.cs | 45 +++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 81a10e3..3f5e35e 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -795,20 +795,34 @@ namespace OpenSim /// /// Create an estate with an initial region. /// + /// + /// This method doesn't allow an estate to be created with the same name as existing estates. + /// /// - public void CreateEstate(RegionInfo regInfo) + /// A list of estate names that already exist. + /// true if the estate was created, false otherwise + public bool CreateEstate(RegionInfo regInfo, List existingNames) { // Create a new estate regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); + string newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); - regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); + if (existingNames.Contains(newName)) + { + MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName); + return false; + } + + regInfo.EstateSettings.EstateName = newName; // FIXME: Later on, the scene constructor will reload the estate settings no matter what. // Therefore, we need to do an initial save here otherwise the new estate name will be reset // back to the default. The reloading of estate settings by scene could be eliminated if it // knows that the passed in settings in RegionInfo are already valid. Also, it might be // possible to eliminate some additional later saves made by callers of this method. - regInfo.EstateSettings.Save(); + regInfo.EstateSettings.Save(); + + return true; } /// @@ -825,16 +839,21 @@ namespace OpenSim MainConsole.Instance.Output("Your region is not part of an estate."); List estates = EstateDataService.LoadEstateSettingsAll(); + List estateNames = new List(); + foreach (EstateSettings estate in estates) + estateNames.Add(estate.EstateName); while (true) { if (estates.Count == 0) { MainConsole.Instance.Output( - "There aren't any existing estates. You will need to create a new one for this region."); + "No existing estates found. You must create a new one for this region."); - CreateEstate(regInfo); - break; + if (CreateEstate(regInfo, estateNames)) + break; + else + continue; } else { @@ -844,15 +863,13 @@ namespace OpenSim if (response == "no") { - CreateEstate(regInfo); - break; + if (CreateEstate(regInfo, estateNames)) + break; + else + continue; } else - { - List estateNames = new List(); - foreach (EstateSettings estate in estates) - estateNames.Add(estate.EstateName); - + { response = MainConsole.Instance.CmdPrompt( string.Format( @@ -865,7 +882,7 @@ namespace OpenSim List estateIDs = EstateDataService.GetEstates(response); if (estateIDs.Count < 1) { - MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); + MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again."); continue; } -- cgit v1.1 From 7acade00b9b34403e63656d5e2efc94322342653 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 21 Mar 2011 23:26:35 +0000 Subject: On initial setup, include estate and regions names in questions to make it clearer what they relate to. --- OpenSim/Region/Application/OpenSimBase.cs | 10 ++++++---- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 3f5e35e..6405811 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -836,7 +836,7 @@ namespace OpenSim if (regInfo.EstateSettings.EstateID == 0) // No record at all { - MainConsole.Instance.Output("Your region is not part of an estate."); + MainConsole.Instance.OutputFormat("Region {0} is not part of an estate.", regInfo.RegionName); List estates = EstateDataService.LoadEstateSettingsAll(); List estateNames = new List(); @@ -847,8 +847,7 @@ namespace OpenSim { if (estates.Count == 0) { - MainConsole.Instance.Output( - "No existing estates found. You must create a new one for this region."); + MainConsole.Instance.Output("No existing estates found. You must create a new one."); if (CreateEstate(regInfo, estateNames)) break; @@ -859,7 +858,10 @@ namespace OpenSim { string response = MainConsole.Instance.CmdPrompt( - "Do you wish to join an existing estate (yes/no)?", "no", new List() { "yes", "no" }); + string.Format( + "Do you wish to join region {0} to an existing estate (yes/no)?", regInfo.RegionName), + "no", + new List() { "yes", "no" }); if (response == "no") { diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1a6a70b..4d2519d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1109,7 +1109,7 @@ namespace OpenSim.Region.Framework.Scenes // while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) { - MainConsole.Instance.Output("The current estate has no owner set."); + MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", m_regInfo.EstateSettings.EstateName); List excluded = new List(new char[1]{' '}); string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded); string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded); -- cgit v1.1 From b34743e5fe6b0783caa62c014ff86e2ec76c8184 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 22 Mar 2011 23:47:36 +0000 Subject: Add an initial confidence-building TestAddObject() for prim counts. --- .../CoreModules/World/Land/LandManagementModule.cs | 29 +++++---- .../CoreModules/World/Land/PrimCountModule.cs | 23 +++++-- .../World/Land/Tests/PrimCountModuleTests.cs | 75 ++++++++++++++++++++++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 13 ++-- 4 files changed, 115 insertions(+), 25 deletions(-) create mode 100644 OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 98ba8c3..514be4f 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -306,6 +306,9 @@ namespace OpenSim.Region.CoreModules.World.Land /// The parcel created. protected ILandObject CreateDefaultParcel() { +// m_log.DebugFormat( +// "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); + ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; @@ -579,7 +582,7 @@ namespace OpenSim.Region.CoreModules.World.Land } else { - m_log.WarnFormat("[LAND]: Invalid local land ID {0}", landLocalID); + m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid local land ID {0}", landLocalID); } } @@ -630,7 +633,7 @@ namespace OpenSim.Region.CoreModules.World.Land { if (m_landIDList[x, y] == local_id) { - m_log.WarnFormat("[LAND]: Not removing land object {0}; still being used at {1}, {2}", + m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Not removing land object {0}; still being used at {1}, {2}", local_id, x, y); return; //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y); @@ -1198,7 +1201,7 @@ namespace OpenSim.Region.CoreModules.World.Land } else { - m_log.WarnFormat("[PARCEL]: Invalid land object {0} passed for parcel object owner request", local_id); + m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid land object {0} passed for parcel object owner request", local_id); } } @@ -1426,7 +1429,7 @@ namespace OpenSim.Region.CoreModules.World.Land { IClientAPI client; if (! m_scene.TryGetClient(agentID, out client)) { - m_log.WarnFormat("[LAND] unable to retrieve IClientAPI for {0}", agentID.ToString()); + m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to retrieve IClientAPI for {0}", agentID); return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); } @@ -1475,7 +1478,7 @@ namespace OpenSim.Region.CoreModules.World.Land } else { - m_log.WarnFormat("[LAND] unable to find parcelID {0}", parcelID); + m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID); } return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); } @@ -1533,17 +1536,17 @@ namespace OpenSim.Region.CoreModules.World.Land } catch (LLSD.LLSDParseException e) { - m_log.ErrorFormat("[LAND] Fetch error: {0}", e.Message); - m_log.ErrorFormat("[LAND] ... in request {0}", request); + m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Fetch error: {0}", e.Message); + m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: ... in request {0}", request); } - catch(InvalidCastException) + catch (InvalidCastException) { - m_log.ErrorFormat("[LAND] Wrong type in request {0}", request); + m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Wrong type in request {0}", request); } LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse(); response.parcel_id = parcelID; - m_log.DebugFormat("[LAND] got parcelID {0}", parcelID); + m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelID {0}", parcelID); return LLSDHelpers.SerialiseLLSDReply(response); } @@ -1564,7 +1567,7 @@ namespace OpenSim.Region.CoreModules.World.Land ExtendedLandData extLandData = new ExtendedLandData(); Util.ParseFakeParcelID(parcel, out extLandData.RegionHandle, out extLandData.X, out extLandData.Y); - m_log.DebugFormat("[LAND] got parcelinfo request for regionHandle {0}, x/y {1}/{2}", + m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelinfo request for regionHandle {0}, x/y {1}/{2}", extLandData.RegionHandle, extLandData.X, extLandData.Y); // for this region or for somewhere else? @@ -1605,7 +1608,7 @@ namespace OpenSim.Region.CoreModules.World.Land info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); } // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark. - m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...", + m_log.DebugFormat("[LAND MANAGEMENT MODULE]: got parcelinfo for parcel {0} in region {1}; sending...", data.LandData.Name, data.RegionHandle); // HACK for now RegionInfo r = new RegionInfo(); @@ -1616,7 +1619,7 @@ namespace OpenSim.Region.CoreModules.World.Land remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y); } else - m_log.Debug("[LAND] got no parcelinfo; not sending"); + m_log.Debug("[LAND MANAGEMENT MODULE]: got no parcelinfo; not sending"); } public void setParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime) diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 34ef67f..c71264c 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -51,8 +51,8 @@ namespace OpenSim.Region.CoreModules.World.Land public class PrimCountModule : IPrimCountModule, INonSharedRegionModule { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_Scene; private Dictionary m_PrimCounts = @@ -64,10 +64,16 @@ namespace OpenSim.Region.CoreModules.World.Land private Dictionary m_ParcelCounts = new Dictionary(); - // For now, a simple simwide taint to get this up. Later parcel based - // taint to allow recounting a parcel if only ownership has changed - // without recounting the whole sim. + + /// + /// For now, a simple simwide taint to get this up. Later parcel based + /// taint to allow recounting a parcel if only ownership has changed + /// without recounting the whole sim. + /// + /// We start out tainted so that the first get call resets the various prim counts. + /// private bool m_Tainted = true; + private Object m_TaintLock = new Object(); public Type ReplaceableInterface @@ -156,6 +162,8 @@ namespace OpenSim.Region.CoreModules.World.Land // NOTE: Call under Taint Lock private void AddObject(SceneObjectGroup obj) { +// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding object {0} to prim count", obj.Name); + if (obj.IsAttachment) return; if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)) @@ -299,18 +307,21 @@ namespace OpenSim.Region.CoreModules.World.Land // NOTE: This method MUST be called while holding the taint lock! private void Recount() { +// m_log.DebugFormat("[PRIM COUNT MODULE]: Recounting prims on {0}", m_Scene.RegionInfo.RegionName); + m_OwnerMap.Clear(); m_SimwideCounts.Clear(); m_ParcelCounts.Clear(); List land = m_Scene.LandChannel.AllParcels(); - + foreach (ILandObject l in land) { LandData landData = l.LandData; m_OwnerMap[landData.GlobalID] = landData.OwnerID; m_SimwideCounts[landData.OwnerID] = 0; +// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding parcel count for {0}", landData.GlobalID); m_ParcelCounts[landData.GlobalID] = new ParcelCounts(); } 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..402965f --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -0,0 +1,75 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using log4net.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenMetaverse.Assets; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; +using OpenSim.Tests.Common.Setup; + +namespace OpenSim.Region.CoreModules.World.Land.Tests +{ + [TestFixture] + public class PrimCountModuleTests + { + [Test] + public void TestAddObject() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + PrimCountModule pcm = new PrimCountModule(); + LandManagementModule lmm = new LandManagementModule(); + Scene scene = SceneSetupHelpers.SetupScene(); + SceneSetupHelpers.SetupSceneModules(scene, lmm, pcm); + + ILandObject lo = new LandObject(UUID.Zero, false, scene); + lo.SetLandBitmap(lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); + lmm.AddLandObject(lo); + //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID); + + string objName = "obj1"; + UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); + + SceneObjectPart part + = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { Name = objName, UUID = objUuid }; + + scene.AddNewSceneObject(new SceneObjectGroup(part), false); + + Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1)); + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 734ba22..eca2786 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -627,7 +627,7 @@ namespace OpenSim.Region.Framework.Scenes if (!Entities.Remove(agentID)) { m_log.WarnFormat( - "[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", + "[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", agentID); } @@ -650,7 +650,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_log.WarnFormat("[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); + m_log.WarnFormat("[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); } } } @@ -1079,7 +1079,8 @@ namespace OpenSim.Region.Framework.Scenes catch (Exception e) { // Catch it and move on. This includes situations where splist has inconsistent info - m_log.WarnFormat("[SCENE]: Problem processing action in ForEachSOG: ", e.ToString()); + m_log.WarnFormat( + "[SCENEGRAPH]: Problem processing action in ForEachSOG: {0} {1}", e.Message, e.StackTrace); } } } @@ -1103,8 +1104,8 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); - m_log.Info("[BUG] Stack Trace: " + e.StackTrace); + m_log.Info("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); + m_log.Info("[SCENEGRAPH]: Stack Trace: " + e.StackTrace); } }); Parallel.ForEach(GetScenePresences(), protectedAction); @@ -1119,7 +1120,7 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); + m_log.Error("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); } } } -- cgit v1.1 From d011896341d09ce6c10a801264e663b6a19f0b48 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 21:50:56 +0000 Subject: Add generic EventManager.OnObjectAddedToScene and get PrimCountModule to listen for that rather than EventManager.OnParcelPrimCountAdd OnParcelPrimCountAdd had the wrong semantics for the PrimCountModule - it was invoked for every entity in the scene, not just new ones, which would screw up the untainted count. Extend automated test for this scenario. --- .../CoreModules/World/Land/LandManagementModule.cs | 4 +++ .../CoreModules/World/Land/PrimCountModule.cs | 10 ++++++-- .../World/Land/Tests/PrimCountModuleTests.cs | 2 ++ OpenSim/Region/Framework/Scenes/EventManager.cs | 30 ++++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 18 ++++++++++--- 5 files changed, 59 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 514be4f..4d887a8 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -854,6 +854,10 @@ namespace OpenSim.Region.CoreModules.World.Land public void EventManagerOnParcelPrimCountUpdate() { +// m_log.DebugFormat( +// "[LAND MANAGEMENT MODULE]: Triggered EventManagerOnParcelPrimCountUpdate() for {0}", +// m_scene.RegionInfo.RegionName); + ResetAllLandPrimCounts(); EntityBase[] entities = m_scene.Entities.GetEntities(); foreach (EntityBase obj in entities) diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index c71264c..5371aaf 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -89,8 +89,7 @@ namespace OpenSim.Region.CoreModules.World.Land { m_Scene = scene; - m_Scene.EventManager.OnParcelPrimCountAdd += - OnParcelPrimCountAdd; + m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd; m_Scene.EventManager.OnObjectBeingRemovedFromScene += OnObjectBeingRemovedFromScene; m_Scene.EventManager.OnParcelPrimCountTainted += @@ -116,6 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Land private void OnParcelPrimCountAdd(SceneObjectGroup obj) { + Console.WriteLine("WIBBLE"); // If we're tainted already, don't bother to add. The next // access will cause a recount anyway lock (m_TaintLock) @@ -172,6 +172,10 @@ namespace OpenSim.Region.CoreModules.World.Land Vector3 pos = obj.AbsolutePosition; ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); LandData landData = landObject.LandData; + +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: Object {0} is owned by {1} over land owned by {2}", +// obj.Name, obj.OwnerID, landData.OwnerID); ParcelCounts parcelCounts; if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) @@ -228,6 +232,8 @@ namespace OpenSim.Region.CoreModules.World.Land public int GetOwnerCount(UUID parcelID) { +// m_log.DebugFormat("[PRIM COUNT MODULE]: GetOwnerCount for {0}", parcelID); + lock (m_TaintLock) { if (m_Tainted) diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 402965f..fd332ed 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -67,6 +67,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) { Name = objName, UUID = objUuid }; + Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(0)); + scene.AddNewSceneObject(new SceneObjectGroup(part), false); Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1)); 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 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID); public event EstateToolsSunUpdate OnEstateToolsSunUpdate; + + /// + /// Triggered when an object is added to the scene. + /// + public event Action OnObjectAddedToScene; + /// + /// Triggered when an object is removed from the scene. + /// public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene; @@ -345,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate void Attach(uint localID, UUID itemID, UUID avatarID); public event Attach OnAttach; + /// /// Called immediately after an object is loaded from storage. /// @@ -800,6 +809,27 @@ namespace OpenSim.Region.Framework.Scenes } } + public void TriggerObjectAddedToScene(SceneObjectGroup obj) + { + Action handler = OnObjectAddedToScene; + if (handler != null) + { + foreach (Action d in handler.GetInvocationList()) + { + try + { + d(obj); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerObjectAddedToScene failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } + public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj) { ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = OnObjectBeingRemovedFromScene; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4d2519d..d407a6f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1956,8 +1956,14 @@ namespace OpenSim.Region.Framework.Scenes /// If false, it is left to the caller to schedule the update /// public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) - { - return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); + { + if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates)) + { + EventManager.TriggerObjectAddedToScene(sceneObject); + return true; + } + + return false; } /// @@ -1974,7 +1980,13 @@ namespace OpenSim.Region.Framework.Scenes public bool AddNewSceneObject( SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) { - return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel); + if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel)) + { + EventManager.TriggerObjectAddedToScene(sceneObject); + return true; + } + + return false; } /// -- cgit v1.1 From 67cafbd33aeb1038f22aa775cbde96b4c89dd770 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 21:54:02 +0000 Subject: remove a rogue Console.WriteLine() from the last commit. --- OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 5371aaf..46c7eed 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -115,7 +115,6 @@ namespace OpenSim.Region.CoreModules.World.Land private void OnParcelPrimCountAdd(SceneObjectGroup obj) { - Console.WriteLine("WIBBLE"); // If we're tainted already, don't bother to add. The next // access will cause a recount anyway lock (m_TaintLock) -- cgit v1.1 From 08c3cd6b369e2bb8dfa08709c2ffddaea4cdbaa5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 22:04:14 +0000 Subject: Add method doc to the Get*() methods on PrimCountModule --- .../CoreModules/World/Land/PrimCountModule.cs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 46c7eed..ae85798 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -229,6 +229,12 @@ namespace OpenSim.Region.CoreModules.World.Land return primCounts; } + + /// + /// Get the number of prims on the parcel that are owned by the parcel owner. + /// + /// + /// public int GetOwnerCount(UUID parcelID) { // m_log.DebugFormat("[PRIM COUNT MODULE]: GetOwnerCount for {0}", parcelID); @@ -245,6 +251,11 @@ namespace OpenSim.Region.CoreModules.World.Land return 0; } + /// + /// Get the number of prims on the parcel that have been set to the group that owns the parcel. + /// + /// + /// public int GetGroupCount(UUID parcelID) { lock (m_TaintLock) @@ -259,6 +270,11 @@ namespace OpenSim.Region.CoreModules.World.Land return 0; } + /// + /// Get the number of prims on the parcel that are not owned by the parcel owner or set to the parcel group. + /// + /// + /// public int GetOthersCount(UUID parcelID) { lock (m_TaintLock) @@ -273,6 +289,11 @@ namespace OpenSim.Region.CoreModules.World.Land return 0; } + /// + /// Get the number of prims that are in the entire simulator for the owner of this parcel. + /// + /// + /// public int GetSimulatorCount(UUID parcelID) { lock (m_TaintLock) @@ -291,6 +312,12 @@ namespace OpenSim.Region.CoreModules.World.Land return 0; } + /// + /// Get the number of prims that a particular user owns on this parcel. + /// + /// + /// + /// public int GetUserCount(UUID parcelID, UUID userID) { lock (m_TaintLock) -- cgit v1.1 From 654aa7abeb497e024c87e2ef8d610ba3ca512c3e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 22:12:20 +0000 Subject: Extend simple PCM add object test to check all counts --- .../CoreModules/World/Land/Tests/PrimCountModuleTests.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index fd332ed..88c814e 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -55,6 +55,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Scene scene = SceneSetupHelpers.SetupScene(); SceneSetupHelpers.SetupSceneModules(scene, lmm, pcm); + UUID dummyUserId = new UUID("99999999-9999-9999-9999-999999999999"); ILandObject lo = new LandObject(UUID.Zero, false, scene); lo.SetLandBitmap(lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); lmm.AddLandObject(lo); @@ -68,10 +69,20 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests { Name = objName, UUID = objUuid }; Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(pcm.GetOthersCount(lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, UUID.Zero), Is.EqualTo(0)); + Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); + Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(0)); scene.AddNewSceneObject(new SceneObjectGroup(part), false); Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1)); + Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(pcm.GetOthersCount(lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, UUID.Zero), Is.EqualTo(1)); + Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); + Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(1)); } } } \ No newline at end of file -- cgit v1.1 From f1f4985ab6fc98daf2263f72397fe7db79b20ecd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 22:14:04 +0000 Subject: user a non UUID.Zero user in pcm test to avoid any special treatment of UUID.Zero --- .../Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 88c814e..639d781 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -55,8 +55,9 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Scene scene = SceneSetupHelpers.SetupScene(); SceneSetupHelpers.SetupSceneModules(scene, lmm, pcm); + UUID userId = new UUID("00000000-0000-0000-0000-000000000010"); UUID dummyUserId = new UUID("99999999-9999-9999-9999-999999999999"); - ILandObject lo = new LandObject(UUID.Zero, false, scene); + ILandObject lo = new LandObject(userId, false, scene); lo.SetLandBitmap(lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); lmm.AddLandObject(lo); //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID); @@ -65,13 +66,13 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); SceneObjectPart part - = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) { Name = objName, UUID = objUuid }; Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(0)); Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); Assert.That(pcm.GetOthersCount(lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, UUID.Zero), Is.EqualTo(0)); + Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, userId), Is.EqualTo(0)); Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(0)); @@ -80,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1)); Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); Assert.That(pcm.GetOthersCount(lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, UUID.Zero), Is.EqualTo(1)); + Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, userId), Is.EqualTo(1)); Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(1)); } -- cgit v1.1 From 88673c86a4b9cde729c62fbdc92b8c9076c54230 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 22:17:47 +0000 Subject: use a 3 part object for the pcm test rather than a 1 part, for improved test coverage --- .../World/Land/Tests/PrimCountModuleTests.cs | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 639d781..8c1b6a3 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -61,13 +61,17 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests lo.SetLandBitmap(lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); lmm.AddLandObject(lo); //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID); - - string objName = "obj1"; - UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); - - SceneObjectPart part + + SceneObjectPart part1 = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = objName, UUID = objUuid }; + { Name = "obj1", UUID = new UUID("00000000-0000-0000-0000-000000000001") }; + SceneObjectGroup sog = new SceneObjectGroup(part1); + sog.AddPart( + new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { Name = "obj2", UUID = new UUID("00000000-0000-0000-0000-000000000002") }); + sog.AddPart( + new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { Name = "obj3", UUID = new UUID("00000000-0000-0000-0000-000000000003") }); Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(0)); Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); @@ -76,14 +80,14 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(0)); - scene.AddNewSceneObject(new SceneObjectGroup(part), false); + scene.AddNewSceneObject(sog, false); - Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1)); + Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(3)); Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); Assert.That(pcm.GetOthersCount(lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, userId), Is.EqualTo(1)); + Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, userId), Is.EqualTo(3)); Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); - Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(1)); + Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(3)); } } } \ No newline at end of file -- cgit v1.1 From de88227bc486788197b3a7c842c8b60f82b0a29b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 22:29:27 +0000 Subject: refactor: simplify part of AddSceneObject() test setup by moving sog construction into SceneSetupHelpers.CreateSceneObject() --- .../CoreModules/World/Land/Tests/PrimCountModuleTests.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 8c1b6a3..72f74fa 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -62,16 +62,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests lmm.AddLandObject(lo); //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID); - SceneObjectPart part1 - = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = "obj1", UUID = new UUID("00000000-0000-0000-0000-000000000001") }; - SceneObjectGroup sog = new SceneObjectGroup(part1); - sog.AddPart( - new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = "obj2", UUID = new UUID("00000000-0000-0000-0000-000000000002") }); - sog.AddPart( - new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = "obj3", UUID = new UUID("00000000-0000-0000-0000-000000000003") }); + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, userId); Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(0)); Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); -- cgit v1.1 From ebbe3afaf15fa07f4a8d1c2db8795065b852ec8d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 23:14:55 +0000 Subject: Add PrimCountModuleTests.TestRemoveOwnerObject(). Also adds SceneSetupHelpers methods to easily create sogs with different part UUIDs --- .../World/Land/Tests/PrimCountModuleTests.cs | 39 +++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 72f74fa..e6b8627 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -44,8 +44,11 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests [TestFixture] public class PrimCountModuleTests { + /// + /// Test count after a parcel owner owned object is added. + /// [Test] - public void TestAddObject() + public void TestAddOwnerObject() { TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); @@ -80,5 +83,39 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(3)); } + + /// + /// Test count after a parcel owner owned object is removed. + /// + [Test] + public void TestRemoveOwnerObject() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + PrimCountModule pcm = new PrimCountModule(); + LandManagementModule lmm = new LandManagementModule(); + Scene scene = SceneSetupHelpers.SetupScene(); + SceneSetupHelpers.SetupSceneModules(scene, lmm, pcm); + + UUID userId = new UUID("00000000-0000-0000-0000-000000000010"); + UUID dummyUserId = new UUID("99999999-9999-9999-9999-999999999999"); + ILandObject lo = new LandObject(userId, false, scene); + lo.SetLandBitmap(lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); + lmm.AddLandObject(lo); + //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID); + + scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, userId, 0x1), false); + SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, userId, 0x10); + scene.AddNewSceneObject(sogToDelete, false); + scene.DeleteSceneObject(sogToDelete, false); + + Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1)); + Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(pcm.GetOthersCount(lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, userId), Is.EqualTo(1)); + Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); + Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(1)); + } } } \ No newline at end of file -- cgit v1.1 From f001aab8aa5f3ceebe259ff89673c7757b16c637 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 23:19:15 +0000 Subject: extend TestAddOwnerObject() to add a second object --- .../World/Land/Tests/PrimCountModuleTests.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index e6b8627..a0e7e4c 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -58,15 +58,13 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Scene scene = SceneSetupHelpers.SetupScene(); SceneSetupHelpers.SetupSceneModules(scene, lmm, pcm); - UUID userId = new UUID("00000000-0000-0000-0000-000000000010"); + UUID userId = new UUID("00000000-0000-0000-0000-100000000000"); UUID dummyUserId = new UUID("99999999-9999-9999-9999-999999999999"); ILandObject lo = new LandObject(userId, false, scene); lo.SetLandBitmap(lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); lmm.AddLandObject(lo); //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID); - - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, userId); - + Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(0)); Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); Assert.That(pcm.GetOthersCount(lo.LandData.GlobalID), Is.EqualTo(0)); @@ -74,6 +72,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(0)); + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, userId, 0x01); scene.AddNewSceneObject(sog, false); Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(3)); @@ -82,6 +81,17 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, userId), Is.EqualTo(3)); Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(3)); + + // Add a second object and retest + SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, userId, 0x10); + scene.AddNewSceneObject(sog2, false); + + Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(5)); + Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(pcm.GetOthersCount(lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, userId), Is.EqualTo(5)); + Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); + Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(5)); } /// -- cgit v1.1 From eaa37d15f26adda05cbcc44404b586551d86e983 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 23:28:10 +0000 Subject: factor out common test setup code in PCM tests --- .../World/Land/Tests/PrimCountModuleTests.cs | 110 ++++++++++----------- 1 file changed, 53 insertions(+), 57 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index a0e7e4c..45e579e 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -44,6 +44,26 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests [TestFixture] public class PrimCountModuleTests { + protected UUID m_userId = new UUID("00000000-0000-0000-0000-100000000000"); + protected UUID m_dummyUserId = new UUID("99999999-9999-9999-9999-999999999999"); + protected TestScene m_scene; + protected PrimCountModule m_pcm; + protected ILandObject m_lo; + + [SetUp] + public void SetUp() + { + m_pcm = new PrimCountModule(); + LandManagementModule lmm = new LandManagementModule(); + m_scene = SceneSetupHelpers.SetupScene(); + SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm); + + m_lo = new LandObject(m_userId, false, m_scene); + m_lo.SetLandBitmap(m_lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); + lmm.AddLandObject(m_lo); + //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID); + } + /// /// Test count after a parcel owner owned object is added. /// @@ -51,47 +71,35 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests public void TestAddOwnerObject() { TestHelper.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - PrimCountModule pcm = new PrimCountModule(); - LandManagementModule lmm = new LandManagementModule(); - Scene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, lmm, pcm); - - UUID userId = new UUID("00000000-0000-0000-0000-100000000000"); - UUID dummyUserId = new UUID("99999999-9999-9999-9999-999999999999"); - ILandObject lo = new LandObject(userId, false, scene); - lo.SetLandBitmap(lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); - lmm.AddLandObject(lo); - //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID); +// log4net.Config.XmlConfigurator.Configure(); - Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(pcm.GetOthersCount(lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, userId), Is.EqualTo(0)); - Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); - Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(m_pcm.GetOwnerCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(m_pcm.GetGroupCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(m_pcm.GetOthersCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_userId), Is.EqualTo(0)); + Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_dummyUserId), Is.EqualTo(0)); + Assert.That(m_pcm.GetSimulatorCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, userId, 0x01); - scene.AddNewSceneObject(sog, false); + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); + m_scene.AddNewSceneObject(sog, false); - Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(3)); - Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(pcm.GetOthersCount(lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, userId), Is.EqualTo(3)); - Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); - Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(3)); + Assert.That(m_pcm.GetOwnerCount(m_lo.LandData.GlobalID), Is.EqualTo(3)); + Assert.That(m_pcm.GetGroupCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(m_pcm.GetOthersCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_userId), Is.EqualTo(3)); + Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_dummyUserId), Is.EqualTo(0)); + Assert.That(m_pcm.GetSimulatorCount(m_lo.LandData.GlobalID), Is.EqualTo(3)); // Add a second object and retest - SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, userId, 0x10); - scene.AddNewSceneObject(sog2, false); + SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, 0x10); + m_scene.AddNewSceneObject(sog2, false); - Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(5)); - Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(pcm.GetOthersCount(lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, userId), Is.EqualTo(5)); - Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); - Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(5)); + Assert.That(m_pcm.GetOwnerCount(m_lo.LandData.GlobalID), Is.EqualTo(5)); + Assert.That(m_pcm.GetGroupCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(m_pcm.GetOthersCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_userId), Is.EqualTo(5)); + Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_dummyUserId), Is.EqualTo(0)); + Assert.That(m_pcm.GetSimulatorCount(m_lo.LandData.GlobalID), Is.EqualTo(5)); } /// @@ -103,29 +111,17 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - PrimCountModule pcm = new PrimCountModule(); - LandManagementModule lmm = new LandManagementModule(); - Scene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, lmm, pcm); - - UUID userId = new UUID("00000000-0000-0000-0000-000000000010"); - UUID dummyUserId = new UUID("99999999-9999-9999-9999-999999999999"); - ILandObject lo = new LandObject(userId, false, scene); - lo.SetLandBitmap(lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); - lmm.AddLandObject(lo); - //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID); - - scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, userId, 0x1), false); - SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, userId, 0x10); - scene.AddNewSceneObject(sogToDelete, false); - scene.DeleteSceneObject(sogToDelete, false); + m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, 0x1), false); + SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x10); + m_scene.AddNewSceneObject(sogToDelete, false); + m_scene.DeleteSceneObject(sogToDelete, false); - Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1)); - Assert.That(pcm.GetGroupCount(lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(pcm.GetOthersCount(lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, userId), Is.EqualTo(1)); - Assert.That(pcm.GetUserCount(lo.LandData.GlobalID, dummyUserId), Is.EqualTo(0)); - Assert.That(pcm.GetSimulatorCount(lo.LandData.GlobalID), Is.EqualTo(1)); + Assert.That(m_pcm.GetOwnerCount(m_lo.LandData.GlobalID), Is.EqualTo(1)); + Assert.That(m_pcm.GetGroupCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(m_pcm.GetOthersCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); + Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_userId), Is.EqualTo(1)); + Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_dummyUserId), Is.EqualTo(0)); + Assert.That(m_pcm.GetSimulatorCount(m_lo.LandData.GlobalID), Is.EqualTo(1)); } } } \ No newline at end of file -- cgit v1.1 From 7f5019b0f23959ca049f87b596bc2bd47725eb0d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Mar 2011 21:47:54 +0000 Subject: Add ILandObject.IPrimCounts for the new prim count module. Not functional yet, but tests now act against this object rather than interrogating the module directly --- .../CoreModules/World/Land/LandManagementModule.cs | 12 ++++- .../Region/CoreModules/World/Land/LandObject.cs | 4 +- .../CoreModules/World/Land/PrimCountModule.cs | 2 + .../World/Land/Tests/PrimCountModuleTests.cs | 60 ++++++++++++---------- OpenSim/Region/Framework/Interfaces/ILandObject.cs | 5 ++ 5 files changed, 52 insertions(+), 31 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 4d887a8..d0727d9 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -72,6 +72,7 @@ namespace OpenSim.Region.CoreModules.World.Land protected Commander m_commander = new Commander("land"); protected IUserManagement m_userManager; + protected IPrimCountModule m_primCountModule; // Minimum for parcels to work is 64m even if we don't actually use them. #pragma warning disable 0429 @@ -147,6 +148,7 @@ namespace OpenSim.Region.CoreModules.World.Land public void RegionLoaded(Scene scene) { m_userManager = m_scene.RequestModuleInterface(); + m_primCountModule = m_scene.RequestModuleInterface(); } public void RemoveRegion(Scene scene) @@ -309,10 +311,11 @@ namespace OpenSim.Region.CoreModules.World.Land // m_log.DebugFormat( // "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); - ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); + ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); + return AddLandObject(fullSimParcel); } @@ -593,6 +596,11 @@ namespace OpenSim.Region.CoreModules.World.Land public ILandObject AddLandObject(ILandObject land) { ILandObject new_land = land.Copy(); + + // Only now can we add the prim counts to the land object - we rely on the global ID which is generated + // as a random UUID inside LandData initialization + if (m_primCountModule != null) + new_land.PrimCounts = m_primCountModule.GetPrimCounts(new_land.LandData.GlobalID); lock (m_landList) { @@ -1368,7 +1376,7 @@ namespace OpenSim.Region.CoreModules.World.Land { ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); new_land.LandData = data.Copy(); - new_land.SetLandBitmapFromByteArray(); + new_land.SetLandBitmapFromByteArray(); AddLandObject(new_land); } diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 46c15ed..749bb3d 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 private int m_lastSeqId = 0; - protected LandData m_landData = new LandData(); + protected LandData m_landData = new LandData(); protected Scene m_scene; protected List primsOverMe = new List(); protected Dictionary m_listTransactions = new Dictionary(); @@ -79,6 +79,8 @@ namespace OpenSim.Region.CoreModules.World.Land set { m_landData = value; } } + + public IPrimCounts PrimCounts { get; set; } public UUID RegionUUID { diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index ae85798..9fd347e 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -88,6 +88,8 @@ namespace OpenSim.Region.CoreModules.World.Land public void AddRegion(Scene scene) { m_Scene = scene; + + m_Scene.RegisterModuleInterface(this); m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd; m_Scene.EventManager.OnObjectBeingRemovedFromScene += diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 45e579e..c9d393f 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -58,9 +58,9 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests m_scene = SceneSetupHelpers.SetupScene(); SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm); - m_lo = new LandObject(m_userId, false, m_scene); - m_lo.SetLandBitmap(m_lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); - lmm.AddLandObject(m_lo); + ILandObject lo = new LandObject(m_userId, false, m_scene); + lo.SetLandBitmap(lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); + m_lo = lmm.AddLandObject(lo); //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID); } @@ -72,34 +72,36 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests { TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - - Assert.That(m_pcm.GetOwnerCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(m_pcm.GetGroupCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(m_pcm.GetOthersCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_userId), Is.EqualTo(0)); - Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_dummyUserId), Is.EqualTo(0)); - Assert.That(m_pcm.GetSimulatorCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); + + IPrimCounts pc = m_lo.PrimCounts; + + Assert.That(pc.Owner, Is.EqualTo(0)); + Assert.That(pc.Group, Is.EqualTo(0)); + Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Users[m_userId], Is.EqualTo(0)); + Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); + Assert.That(pc.Simulator, Is.EqualTo(0)); SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); m_scene.AddNewSceneObject(sog, false); - Assert.That(m_pcm.GetOwnerCount(m_lo.LandData.GlobalID), Is.EqualTo(3)); - Assert.That(m_pcm.GetGroupCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(m_pcm.GetOthersCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_userId), Is.EqualTo(3)); - Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_dummyUserId), Is.EqualTo(0)); - Assert.That(m_pcm.GetSimulatorCount(m_lo.LandData.GlobalID), Is.EqualTo(3)); + Assert.That(pc.Owner, Is.EqualTo(3)); + Assert.That(pc.Group, Is.EqualTo(0)); + Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Users[m_userId], Is.EqualTo(3)); + Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); + Assert.That(pc.Simulator, Is.EqualTo(3)); // Add a second object and retest SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, 0x10); m_scene.AddNewSceneObject(sog2, false); - Assert.That(m_pcm.GetOwnerCount(m_lo.LandData.GlobalID), Is.EqualTo(5)); - Assert.That(m_pcm.GetGroupCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(m_pcm.GetOthersCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_userId), Is.EqualTo(5)); - Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_dummyUserId), Is.EqualTo(0)); - Assert.That(m_pcm.GetSimulatorCount(m_lo.LandData.GlobalID), Is.EqualTo(5)); + Assert.That(pc.Owner, Is.EqualTo(5)); + Assert.That(pc.Group, Is.EqualTo(0)); + Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Users[m_userId], Is.EqualTo(5)); + Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); + Assert.That(pc.Simulator, Is.EqualTo(5)); } /// @@ -111,17 +113,19 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); + IPrimCounts pc = m_lo.PrimCounts; + m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, 0x1), false); SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x10); m_scene.AddNewSceneObject(sogToDelete, false); m_scene.DeleteSceneObject(sogToDelete, false); - Assert.That(m_pcm.GetOwnerCount(m_lo.LandData.GlobalID), Is.EqualTo(1)); - Assert.That(m_pcm.GetGroupCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(m_pcm.GetOthersCount(m_lo.LandData.GlobalID), Is.EqualTo(0)); - Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_userId), Is.EqualTo(1)); - Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_dummyUserId), Is.EqualTo(0)); - Assert.That(m_pcm.GetSimulatorCount(m_lo.LandData.GlobalID), Is.EqualTo(1)); + Assert.That(pc.Owner, Is.EqualTo(1)); + Assert.That(pc.Group, Is.EqualTo(0)); + Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Users[m_userId], Is.EqualTo(1)); + Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); + Assert.That(pc.Simulator, Is.EqualTo(1)); } } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Interfaces/ILandObject.cs b/OpenSim/Region/Framework/Interfaces/ILandObject.cs index eeb9d3a..9c0abde 100644 --- a/OpenSim/Region/Framework/Interfaces/ILandObject.cs +++ b/OpenSim/Region/Framework/Interfaces/ILandObject.cs @@ -46,6 +46,11 @@ namespace OpenSim.Region.Framework.Interfaces UUID RegionUUID { get; } /// + /// Prim counts for this land object. + /// + IPrimCounts PrimCounts { get; set; } + + /// /// The start point for the land object. This is the western-most point as one scans land working from /// north to south. /// -- cgit v1.1 From f30bf429c274c9d6d0cfc99513820f759ca94d3e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 26 Mar 2011 00:42:48 +0000 Subject: refactor: rename SOG collections in SceneGraph to make it clearer that they are indexing each part's UUID, not just the root part. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 60 +++++++++++++-------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index eca2786..345ed7a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -89,8 +89,8 @@ namespace OpenSim.Region.Framework.Scenes protected internal PhysicsScene _PhyScene; - protected internal Dictionary SceneObjectGroupsByLocalID = new Dictionary(); - protected internal Dictionary SceneObjectGroupsByFullID = new Dictionary(); + protected internal Dictionary SceneObjectGroupsByLocalPartID = new Dictionary(); + protected internal Dictionary SceneObjectGroupsByFullPartID = new Dictionary(); private Object m_updateLock = new Object(); @@ -131,10 +131,10 @@ namespace OpenSim.Region.Framework.Scenes m_scenePresenceArray = newlist; } - lock (SceneObjectGroupsByFullID) - SceneObjectGroupsByFullID.Clear(); - lock (SceneObjectGroupsByLocalID) - SceneObjectGroupsByLocalID.Clear(); + lock (SceneObjectGroupsByFullPartID) + SceneObjectGroupsByFullPartID.Clear(); + lock (SceneObjectGroupsByLocalPartID) + SceneObjectGroupsByLocalPartID.Clear(); Entities.Clear(); } @@ -384,18 +384,18 @@ namespace OpenSim.Region.Framework.Scenes if (OnObjectCreate != null) OnObjectCreate(sceneObject); - lock (SceneObjectGroupsByFullID) + lock (SceneObjectGroupsByFullPartID) { - SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; + SceneObjectGroupsByFullPartID[sceneObject.UUID] = sceneObject; foreach (SceneObjectPart part in children) - SceneObjectGroupsByFullID[part.UUID] = sceneObject; + SceneObjectGroupsByFullPartID[part.UUID] = sceneObject; } - lock (SceneObjectGroupsByLocalID) + lock (SceneObjectGroupsByLocalPartID) { - SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; + SceneObjectGroupsByLocalPartID[sceneObject.LocalId] = sceneObject; foreach (SceneObjectPart part in children) - SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; + SceneObjectGroupsByLocalPartID[part.LocalId] = sceneObject; } return true; @@ -427,20 +427,20 @@ namespace OpenSim.Region.Framework.Scenes if (OnObjectRemove != null) OnObjectRemove(Entities[uuid]); - lock (SceneObjectGroupsByFullID) + lock (SceneObjectGroupsByFullPartID) { SceneObjectPart[] parts = grp.Parts; for (int i = 0; i < parts.Length; i++) - SceneObjectGroupsByFullID.Remove(parts[i].UUID); - SceneObjectGroupsByFullID.Remove(grp.RootPart.UUID); + SceneObjectGroupsByFullPartID.Remove(parts[i].UUID); + SceneObjectGroupsByFullPartID.Remove(grp.RootPart.UUID); } - lock (SceneObjectGroupsByLocalID) + lock (SceneObjectGroupsByLocalPartID) { SceneObjectPart[] parts = grp.Parts; for (int i = 0; i < parts.Length; i++) - SceneObjectGroupsByLocalID.Remove(parts[i].LocalId); - SceneObjectGroupsByLocalID.Remove(grp.RootPart.LocalId); + SceneObjectGroupsByLocalPartID.Remove(parts[i].LocalId); + SceneObjectGroupsByLocalPartID.Remove(grp.RootPart.LocalId); } return Entities.Remove(uuid); @@ -854,14 +854,14 @@ namespace OpenSim.Region.Framework.Scenes //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID); SceneObjectGroup sog; - lock (SceneObjectGroupsByLocalID) - SceneObjectGroupsByLocalID.TryGetValue(localID, out sog); + lock (SceneObjectGroupsByLocalPartID) + SceneObjectGroupsByLocalPartID.TryGetValue(localID, out sog); if (sog != null) { if (sog.HasChildPrim(localID)) return sog; - SceneObjectGroupsByLocalID.Remove(localID); + SceneObjectGroupsByLocalPartID.Remove(localID); } EntityBase[] entityList = GetEntities(); @@ -873,8 +873,8 @@ namespace OpenSim.Region.Framework.Scenes sog = (SceneObjectGroup)ent; if (sog.HasChildPrim(localID)) { - lock (SceneObjectGroupsByLocalID) - SceneObjectGroupsByLocalID[localID] = sog; + lock (SceneObjectGroupsByLocalPartID) + SceneObjectGroupsByLocalPartID[localID] = sog; return sog; } } @@ -891,16 +891,16 @@ namespace OpenSim.Region.Framework.Scenes private SceneObjectGroup GetGroupByPrim(UUID fullID) { SceneObjectGroup sog; - lock (SceneObjectGroupsByFullID) - SceneObjectGroupsByFullID.TryGetValue(fullID, out sog); + lock (SceneObjectGroupsByFullPartID) + SceneObjectGroupsByFullPartID.TryGetValue(fullID, out sog); if (sog != null) { if (sog.ContainsPart(fullID)) return sog; - lock (SceneObjectGroupsByFullID) - SceneObjectGroupsByFullID.Remove(fullID); + lock (SceneObjectGroupsByFullPartID) + SceneObjectGroupsByFullPartID.Remove(fullID); } EntityBase[] entityList = GetEntities(); @@ -911,8 +911,8 @@ namespace OpenSim.Region.Framework.Scenes sog = (SceneObjectGroup)ent; if (sog.HasChildPrim(fullID)) { - lock (SceneObjectGroupsByFullID) - SceneObjectGroupsByFullID[fullID] = sog; + lock (SceneObjectGroupsByFullPartID) + SceneObjectGroupsByFullPartID[fullID] = sog; return sog; } } @@ -1069,7 +1069,7 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal void ForEachSOG(Action action) { - List objlist = new List(SceneObjectGroupsByFullID.Values); + List objlist = new List(SceneObjectGroupsByFullPartID.Values); foreach (SceneObjectGroup obj in objlist) { try -- cgit v1.1 From 26d16567e1e2bf28a3eafce6d3acf8d9646aaf84 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 26 Mar 2011 00:53:19 +0000 Subject: Make SceneGraph.ForEachSOG() execute once for each SOG, not once for each prim (e.g. a SOG with 3 prims would have the action executed three times). To do this, a new SceneObjectGroupsByFullID index in SceneGraph which just index's prims by their root part UUID, in order to avoid the inefficiency of filtering existing lists. Existing callers to SceneGraph.ForEachSOG() did not fail due to the multiple per SOG action executions - they were probably just much less efficient. Code suggests that no callers expected ForEachSOG() to execute actions on sog multiple times --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 30 ++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 345ed7a..1621398 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -88,9 +88,21 @@ namespace OpenSim.Region.Framework.Scenes protected internal object m_syncRoot = new object(); protected internal PhysicsScene _PhyScene; - - protected internal Dictionary SceneObjectGroupsByLocalPartID = new Dictionary(); + + /// + /// Index the SceneObjectGroup for each part by the root part's UUID. + /// + protected internal Dictionary SceneObjectGroupsByFullID = new Dictionary(); + + /// + /// Index the SceneObjectGroup for each part by that part's UUID. + /// protected internal Dictionary SceneObjectGroupsByFullPartID = new Dictionary(); + + /// + /// Index the SceneObjectGroup for each part by that part's local ID. + /// + protected internal Dictionary SceneObjectGroupsByLocalPartID = new Dictionary(); private Object m_updateLock = new Object(); @@ -131,6 +143,8 @@ namespace OpenSim.Region.Framework.Scenes m_scenePresenceArray = newlist; } + lock (SceneObjectGroupsByFullID) + SceneObjectGroupsByFullID.Clear(); lock (SceneObjectGroupsByFullPartID) SceneObjectGroupsByFullPartID.Clear(); lock (SceneObjectGroupsByLocalPartID) @@ -384,6 +398,9 @@ namespace OpenSim.Region.Framework.Scenes if (OnObjectCreate != null) OnObjectCreate(sceneObject); + lock (SceneObjectGroupsByFullID) + SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; + lock (SceneObjectGroupsByFullPartID) { SceneObjectGroupsByFullPartID[sceneObject.UUID] = sceneObject; @@ -426,6 +443,9 @@ namespace OpenSim.Region.Framework.Scenes if (OnObjectRemove != null) OnObjectRemove(Entities[uuid]); + + lock (SceneObjectGroupsByFullID) + SceneObjectGroupsByFullID.Remove(grp.UUID); lock (SceneObjectGroupsByFullPartID) { @@ -1064,12 +1084,13 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Performs action on all scene object groups. + /// Performs action once on all scene object groups. /// /// protected internal void ForEachSOG(Action action) { - List objlist = new List(SceneObjectGroupsByFullPartID.Values); + // FIXME: Need to lock here, really. + List objlist = new List(SceneObjectGroupsByFullID.Values); foreach (SceneObjectGroup obj in objlist) { try @@ -1084,7 +1105,6 @@ namespace OpenSim.Region.Framework.Scenes } } } - /// /// Performs action on all scene presences. This can ultimately run the actions in parallel but -- cgit v1.1 From f2d2470c256486df585705313a7fdfdf3d344c1f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 26 Mar 2011 02:24:32 +0000 Subject: When an object is duplicated, add it to the full/local id SOG indexes as well as Entities --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 30 ++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 1621398..60855b2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -363,6 +363,10 @@ namespace OpenSim.Region.Framework.Scenes if (Entities.ContainsKey(sceneObject.UUID)) return false; + +// m_log.DebugFormat( +// "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}", +// sceneObject.Name, sceneObject.UUID, sceneObject.Parts.Length, m_parentScene.RegionInfo.RegionName); SceneObjectPart[] children = sceneObject.Parts; @@ -1798,7 +1802,10 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) { - //m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID); +// m_log.DebugFormat( +// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", +// originalPrimID, offset, AgentID); + SceneObjectGroup original = GetGroupByPrim(originalPrimID); if (original != null) { @@ -1829,7 +1836,28 @@ namespace OpenSim.Region.Framework.Scenes copy.RootPart.SalePrice = 10; } + // FIXME: This section needs to be refactored so that it just calls AddSceneObject() Entities.Add(copy); + + lock (SceneObjectGroupsByFullID) + SceneObjectGroupsByFullID[copy.UUID] = copy; + + SceneObjectPart[] children = copy.Parts; + + lock (SceneObjectGroupsByFullPartID) + { + SceneObjectGroupsByFullPartID[copy.UUID] = copy; + foreach (SceneObjectPart part in children) + SceneObjectGroupsByFullPartID[part.UUID] = copy; + } + + lock (SceneObjectGroupsByLocalPartID) + { + SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; + foreach (SceneObjectPart part in children) + SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; + } + // PROBABLE END OF FIXME // Since we copy from a source group that is in selected // state, but the copy is shown deselected in the viewer, -- cgit v1.1