From fb890e543f1684e0c01f7a57f312ab1d7140cdc0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 21 Mar 2011 05:52:29 +0100 Subject: Don't send a windlight profile to clients if windlight is not set for that region. This should restore normal day and night cycles for regions without WL settings. --- OpenSim/Region/CoreModules/LightShare/LightShareModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') 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 public void SendProfileToClient(ScenePresence presence) { IClientAPI client = presence.ControllingClient; - if (m_enableWindlight) + if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid) { if (presence.IsChildAgent == false) { @@ -165,7 +165,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare public void SendProfileToClient(ScenePresence presence, RegionLightShareData wl) { IClientAPI client = presence.ControllingClient; - if (m_enableWindlight) + if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid) { if (presence.IsChildAgent == false) { -- cgit v1.1 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/Data/MSSQL/MSSQLEstateData.cs | 17 +++++++++ OpenSim/Data/MySQL/MySQLEstateData.cs | 40 ++++++++++++++++++++++ OpenSim/Data/SQLite/SQLiteEstateData.cs | 32 +++++++++++++++++ OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs | 33 ++++++++++++++++++ OpenSim/Region/Application/OpenSimBase.cs | 13 ++++++- .../Framework/Interfaces/IEstateDataService.cs | 14 ++++++++ .../Framework/Interfaces/IEstateDataStore.cs | 14 ++++++++ .../Connectors/Simulation/EstateDataService.cs | 10 ++++++ 8 files changed, 172 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs index e9a0935..92a8d80 100644 --- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs +++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs @@ -350,26 +350,43 @@ namespace OpenSim.Data.MSSQL public EstateSettings LoadEstateSettings(int estateID) { + // TODO: Implementation! return new EstateSettings(); } + + public List LoadEstateSettingsAll() + { + // TODO: Implementation! + return new List(); + } public List GetEstates(string search) { + // TODO: Implementation! + return new List(); + } + + public List GetEstatesAll() + { + // TODO: Implementation! return new List(); } public bool LinkRegion(UUID regionID, int estateID) { + // TODO: Implementation! return false; } public List GetRegions(int estateID) { + // TODO: Implementation! return new List(); } public bool DeleteEstate(int estateID) { + // TODO: Implementation! return false; } #endregion diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index de72a6a..6d72e82 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -413,6 +413,46 @@ namespace OpenSim.Data.MySQL return DoLoad(cmd, UUID.Zero, false); } } + + public List LoadEstateSettingsAll() + { + List allEstateSettings = new List(); + + List allEstateIds = GetEstatesAll(); + + foreach (int estateId in allEstateIds) + allEstateSettings.Add(LoadEstateSettings(estateId)); + + return allEstateSettings; + } + + public List GetEstatesAll() + { + List result = new List(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select estateID from estate_settings"; + + using (IDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + { + result.Add(Convert.ToInt32(reader["EstateID"])); + } + reader.Close(); + } + } + + dbcon.Close(); + } + + return result; + } public List GetEstates(string search) { diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs index 63252aa..6afc540 100644 --- a/OpenSim/Data/SQLite/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs @@ -357,6 +357,17 @@ namespace OpenSim.Data.SQLite return DoLoad(cmd, UUID.Zero, false); } + + public List LoadEstateSettingsAll() + { + List estateSettings = new List(); + + List estateIds = GetEstatesAll(); + foreach (int estateId in estateIds) + estateSettings.Add(LoadEstateSettings(estateId)); + + return estateSettings; + } public List GetEstates(string search) { @@ -379,6 +390,27 @@ namespace OpenSim.Data.SQLite return result; } + + public List GetEstatesAll() + { + List result = new List(); + + string sql = "select EstateID from estate_settings"; + + SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + + cmd.CommandText = sql; + + IDataReader r = cmd.ExecuteReader(); + + while (r.Read()) + { + result.Add(Convert.ToInt32(r["EstateID"])); + } + r.Close(); + + return result; + } public bool LinkRegion(UUID regionID, int estateID) { diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs index 547ea6b..ad28c00 100644 --- a/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs @@ -100,6 +100,17 @@ namespace OpenSim.Data.SQLiteLegacy return DoLoad(cmd, regionID, create); } + + public List LoadEstateSettingsAll() + { + List estateSettings = new List(); + + List estateIds = GetEstatesAll(); + foreach (int estateId in estateIds) + estateSettings.Add(LoadEstateSettings(estateId)); + + return estateSettings; + } private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create) { @@ -369,6 +380,28 @@ namespace OpenSim.Data.SQLiteLegacy return result; } + + public List GetEstatesAll() + { + List result = new List(); + + string sql = "select EstateID from estate_settings"; + + SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + + cmd.CommandText = sql; + + IDataReader r = cmd.ExecuteReader(); + + while (r.Read()) + { + result.Add(Convert.ToInt32(r["EstateID"])); + } + r.Close(); + + return result; + } + public bool LinkRegion(UUID regionID, int estateID) { SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); 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); diff --git a/OpenSim/Services/Connectors/Simulation/EstateDataService.cs b/OpenSim/Services/Connectors/Simulation/EstateDataService.cs index b6df5a2..d0588bf 100644 --- a/OpenSim/Services/Connectors/Simulation/EstateDataService.cs +++ b/OpenSim/Services/Connectors/Simulation/EstateDataService.cs @@ -90,6 +90,11 @@ namespace OpenSim.Services.Connectors { return m_database.LoadEstateSettings(estateID); } + + public List LoadEstateSettingsAll() + { + return m_database.LoadEstateSettingsAll(); + } public void StoreEstateSettings(EstateSettings es) { @@ -100,6 +105,11 @@ namespace OpenSim.Services.Connectors { return m_database.GetEstates(search); } + + public List GetEstatesAll() + { + return m_database.GetEstatesAll(); + } public bool LinkRegion(UUID regionID, 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') 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') 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') 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') 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') 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') 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') 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') 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') 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') 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') 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') 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') 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() --- .../World/Land/Tests/PrimCountModuleTests.cs | 11 +------- OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 32 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 10 deletions(-) (limited to 'OpenSim') 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)); diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index aa4b285..b7b7383 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -465,5 +465,37 @@ namespace OpenSim.Tests.Common.Setup return part; } + + /// + /// Create a scene object but do not add it to the scene. + /// + /// + /// UUID always starts at 00000000-0000-0000-0000-000000000001 + /// + /// The number of parts that should be in the scene object + /// + /// + public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) + { + SceneObjectPart rootPart + = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { Name = "part1", UUID = new UUID("00000000-0000-0000-0000-000000000001") }; + SceneObjectGroup sog = new SceneObjectGroup(rootPart); + + if (parts > 1) + { + for (int i = 2; i <= parts; i++) + { + sog.AddPart( + new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { + Name = string.Format("obj{0}", i), + UUID = new UUID(string.Format("00000000-0000-0000-0000-{0:D12}", i)) + }); + } + } + + return sog; + } } } -- cgit v1.1 From d5c7ae5c6b55ae794f630ae55a100b19eef2362c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 22:40:23 +0000 Subject: refactor common sop setup parts into a single method --- OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 40 ++++++++++++++----------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index b7b7383..87b6389 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -454,9 +454,7 @@ namespace OpenSim.Tests.Common.Setup /// public static SceneObjectPart AddSceneObject(Scene scene, string name) { - SceneObjectPart part - = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); - part.Name = name; + SceneObjectPart part = CreateSceneObjectPart(name, UUID.Random(), UUID.Zero); //part.UpdatePrimFlags(false, false, true); //part.ObjectFlags |= (uint)PrimFlags.Phantom; @@ -467,6 +465,20 @@ namespace OpenSim.Tests.Common.Setup } /// + /// Create a scene object part. + /// + /// + /// + /// + /// + public static SceneObjectPart CreateSceneObjectPart(string name, UUID id, UUID ownerId) + { + return new SceneObjectPart( + ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { Name = name, UUID = id }; + } + + /// /// Create a scene object but do not add it to the scene. /// /// @@ -477,25 +489,19 @@ namespace OpenSim.Tests.Common.Setup /// public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) { - SceneObjectPart rootPart - = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = "part1", UUID = new UUID("00000000-0000-0000-0000-000000000001") }; - SceneObjectGroup sog = new SceneObjectGroup(rootPart); + SceneObjectGroup sog + = new SceneObjectGroup( + CreateSceneObjectPart("part1", new UUID("00000000-0000-0000-0000-000000000001"), ownerId)); if (parts > 1) - { for (int i = 2; i <= parts; i++) - { sog.AddPart( - new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { - Name = string.Format("obj{0}", i), - UUID = new UUID(string.Format("00000000-0000-0000-0000-{0:D12}", i)) - }); - } - } + CreateSceneObjectPart( + string.Format("obj{0}", i), + new UUID(string.Format("00000000-0000-0000-0000-{0:D12}", i)), + ownerId)); return sog; } } -} +} \ No newline at end of file -- 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 +++++++++++++++++++++- OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 27 ++++++++++++--- 2 files changed, 60 insertions(+), 6 deletions(-) (limited to 'OpenSim') 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 diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index 87b6389..57850c1 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -488,20 +488,37 @@ namespace OpenSim.Tests.Common.Setup /// /// public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) - { + { + return CreateSceneObject(parts, ownerId, 0x1); + } + + /// + /// Create a scene object but do not add it to the scene. + /// + /// The number of parts that should be in the scene object + /// + /// + /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" + /// will be given to the root part, and incremented for each part thereafter. + /// + /// + public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, int uuidTail) + { + string rawSogId = string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail); + SceneObjectGroup sog = new SceneObjectGroup( - CreateSceneObjectPart("part1", new UUID("00000000-0000-0000-0000-000000000001"), ownerId)); + CreateSceneObjectPart("part0", new UUID(rawSogId), ownerId)); if (parts > 1) - for (int i = 2; i <= parts; i++) + for (int i = 1; i < parts; i++) sog.AddPart( CreateSceneObjectPart( string.Format("obj{0}", i), - new UUID(string.Format("00000000-0000-0000-0000-{0:D12}", i)), + new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i)), ownerId)); return sog; - } + } } } \ 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') 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') 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') 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 6ae04448f73afdca791ea185fdc0e9c062dea87b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Mar 2011 23:05:51 +0000 Subject: Start using IPrimCounts populated by PrimCountModule instead of LandData counts populated by LandManagementModule. In order to pass ILandObject into IClientAPI.SendLandProperties(), had to push ILandObject and IPrimCounts into OpenSim.Framework from OpenSim.Region.Framework.Interfaces, in order to avoid ci Counts are showing odd behaviour at the moment, this will be addressed shortly. --- OpenSim/Client/MXP/ClientStack/MXPClientView.cs | 2 +- .../Client/VWoHTTP/ClientStack/VWHClientView.cs | 2 +- OpenSim/Framework/IClientAPI.cs | 12 ++- OpenSim/Framework/ILandChannel.cs | 91 ++++++++++++++++ OpenSim/Framework/IPrimCounts.cs | 45 ++++++++ .../Region/ClientStack/LindenUDP/LLClientView.cs | 35 +++--- .../CoreModules/Avatar/Combat/CombatModule.cs | 1 + .../CoreModules/World/Land/LandManagementModule.cs | 2 +- .../Region/CoreModules/World/Land/LandObject.cs | 2 +- .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 2 +- .../Region/Framework/Interfaces/ILandChannel.cs | 91 ---------------- OpenSim/Region/Framework/Interfaces/ILandObject.cs | 117 --------------------- .../Framework/Interfaces/IPrimCountModule.cs | 16 +-- .../Server/IRCClientView.cs | 2 +- .../Scripting/Minimodule/LOParcel.cs | 1 + .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +- OpenSim/Tests/Common/Mock/TestClient.cs | 2 +- 17 files changed, 180 insertions(+), 245 deletions(-) create mode 100644 OpenSim/Framework/ILandChannel.cs create mode 100644 OpenSim/Framework/IPrimCounts.cs delete mode 100644 OpenSim/Region/Framework/Interfaces/ILandChannel.cs delete mode 100644 OpenSim/Region/Framework/Interfaces/ILandObject.cs (limited to 'OpenSim') diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 1d93382..93c6c98 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs @@ -1252,7 +1252,7 @@ namespace OpenSim.Client.MXP.ClientStack // Need to translate to MXP somehow } - public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) + public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) { // Need to translate to MXP somehow } diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs index f2b58d3..fc27f01 100644 --- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs +++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs @@ -799,7 +799,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack throw new System.NotImplementedException(); } - public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) + public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) { throw new System.NotImplementedException(); } diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index a6be157..5bf0b7b 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1143,7 +1143,17 @@ namespace OpenSim.Framework void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner); - void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, + /// + /// Send land properties to the client. + /// + /// + /// + /// + /// + /// /param> + /// + /// + void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags); diff --git a/OpenSim/Framework/ILandChannel.cs b/OpenSim/Framework/ILandChannel.cs new file mode 100644 index 0000000..30bae16 --- /dev/null +++ b/OpenSim/Framework/ILandChannel.cs @@ -0,0 +1,91 @@ +/* + * 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.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Region.Framework.Interfaces +{ + public interface ILandChannel + { + /// + /// Get all parcels + /// + /// + List AllParcels(); + + /// + /// Get the parcel at the specified point + /// + /// Value between 0 - 256 on the x axis of the point + /// Value between 0 - 256 on the y axis of the point + /// Land object at the point supplied + ILandObject GetLandObject(int x, int y); + + /// + /// Get the parcel at the specified point + /// + /// Value between 0 - 256 on the x axis of the point + /// Value between 0 - 256 on the y axis of the point + /// Land object at the point supplied + ILandObject GetLandObject(float x, float y); + + /// + /// Get the parcels near the specified point + /// + /// + /// + List ParcelsNearPoint(Vector3 position); + + /// + /// Get the parcel given the land's local id. + /// + /// + /// + ILandObject GetLandObject(int localID); + + /// + /// Clear the land channel of all parcels. + /// + /// + /// If true, set up a default parcel covering the whole region owned by the estate owner. + /// + void Clear(bool setupDefaultParcel); + + bool IsLandPrimCountTainted(); + bool IsForcefulBansAllowed(); + void UpdateLandObject(int localID, LandData data); + void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient); + void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel); + void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel); + void SetParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime); + + void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id); + void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id); + } +} diff --git a/OpenSim/Framework/IPrimCounts.cs b/OpenSim/Framework/IPrimCounts.cs new file mode 100644 index 0000000..7d362c5 --- /dev/null +++ b/OpenSim/Framework/IPrimCounts.cs @@ -0,0 +1,45 @@ +/* + * 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 OpenMetaverse; + +namespace OpenSim.Framework +{ + public interface IPrimCounts + { + int Owner { get; } + int Group { get; } + int Others { get; } + int Simulator { get; } + IUserPrimCounts Users { get; } + } + + public interface IUserPrimCounts + { + int this[UUID agentID] { get; } + } +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 2c6795f..6138056 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4272,8 +4272,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(packet, ThrottleOutPacketType.Task); } - public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) + public void SendLandProperties( + int sequence_id, bool snap_selection, int request_result, ILandObject lo, + float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) { + LandData landData = lo.LandData; + ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage(); updateMessage.AABBMax = landData.AABBMax; @@ -4281,15 +4285,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP updateMessage.Area = landData.Area; updateMessage.AuctionID = landData.AuctionID; updateMessage.AuthBuyerID = landData.AuthBuyerID; - updateMessage.Bitmap = landData.Bitmap; - updateMessage.Desc = landData.Description; updateMessage.Category = landData.Category; updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate); updateMessage.ClaimPrice = landData.ClaimPrice; - updateMessage.GroupID = landData.GroupID; - updateMessage.GroupPrims = landData.GroupPrims; + updateMessage.GroupID = landData.GroupID; updateMessage.IsGroupOwned = landData.IsGroupOwned; updateMessage.LandingType = (LandingType) landData.LandingType; updateMessage.LocalID = landData.LocalID; @@ -4310,9 +4311,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP updateMessage.Name = landData.Name; updateMessage.OtherCleanTime = landData.OtherCleanTime; updateMessage.OtherCount = 0; //TODO: Unimplemented - updateMessage.OtherPrims = landData.OtherPrims; - updateMessage.OwnerID = landData.OwnerID; - updateMessage.OwnerPrims = landData.OwnerPrims; + updateMessage.OwnerID = landData.OwnerID; updateMessage.ParcelFlags = (ParcelFlags) landData.Flags; updateMessage.ParcelPrimBonus = simObjectBonusFactor; updateMessage.PassHours = landData.PassHours; @@ -4327,10 +4326,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP updateMessage.RentPrice = 0; updateMessage.RequestResult = (ParcelResult) request_result; - updateMessage.SalePrice = landData.SalePrice; - updateMessage.SelectedPrims = landData.SelectedPrims; + updateMessage.SalePrice = landData.SalePrice; updateMessage.SelfCount = 0; //TODO: Unimplemented updateMessage.SequenceID = sequence_id; + if (landData.SimwideArea > 0) { int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); @@ -4340,12 +4339,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP { updateMessage.SimWideMaxPrims = 0; } - updateMessage.SimWideTotalPrims = landData.SimwidePrims; + updateMessage.SnapSelection = snap_selection; updateMessage.SnapshotID = landData.SnapshotID; updateMessage.Status = (ParcelStatus) landData.Status; - updateMessage.TotalPrims = landData.OwnerPrims + landData.GroupPrims + landData.OtherPrims + - landData.SelectedPrims; updateMessage.UserLocation = landData.UserLocation; updateMessage.UserLookAt = landData.UserLookAt; @@ -4356,6 +4353,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP updateMessage.MediaLoop = landData.MediaLoop; updateMessage.ObscureMusic = landData.ObscureMusic; updateMessage.ObscureMedia = landData.ObscureMedia; + + IPrimCounts pc = lo.PrimCounts; + updateMessage.OwnerPrims = pc.Owner; + updateMessage.GroupPrims = pc.Group; + updateMessage.OtherPrims = pc.Others; + updateMessage.SimWideTotalPrims = pc.Simulator; + + // FIXME: Need to do selected prims once this is reimplemented. + updateMessage.TotalPrims = pc.Owner + pc.Group + pc.Others; + + // TODO: Need to transfer selected prims to new prim count structure. + updateMessage.SelectedPrims = landData.SelectedPrims; try { 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 @@ using System; using System.Collections.Generic; using Nini.Config; +using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenMetaverse; diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index d0727d9..52e3718 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -805,7 +805,7 @@ namespace OpenSim.Region.CoreModules.World.Land ILandObject landUnderPrim = GetLandObject(position.X, position.Y); if (landUnderPrim != null) { - landUnderPrim.AddPrimToCount(obj); + ((LandObject)landUnderPrim).AddPrimToCount(obj); } } diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 749bb3d..e7bdb19 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.World.Land } remote_client.SendLandProperties(seq_id, - snap_selection, request_result, LandData, + snap_selection, request_result, this, (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, GetParcelMaxPrimCount(this), GetSimulatorMaxPrimCount(this), regionFlags); 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 { } - public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) + public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) { } 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 @@ -/* - * 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.Collections.Generic; -using OpenMetaverse; -using OpenSim.Framework; - -namespace OpenSim.Region.Framework.Interfaces -{ - public interface ILandChannel - { - /// - /// Get all parcels - /// - /// - List AllParcels(); - - /// - /// Get the parcel at the specified point - /// - /// Value between 0 - 256 on the x axis of the point - /// Value between 0 - 256 on the y axis of the point - /// Land object at the point supplied - ILandObject GetLandObject(int x, int y); - - /// - /// Get the parcel at the specified point - /// - /// Value between 0 - 256 on the x axis of the point - /// Value between 0 - 256 on the y axis of the point - /// Land object at the point supplied - ILandObject GetLandObject(float x, float y); - - /// - /// Get the parcels near the specified point - /// - /// - /// - List ParcelsNearPoint(Vector3 position); - - /// - /// Get the parcel given the land's local id. - /// - /// - /// - ILandObject GetLandObject(int localID); - - /// - /// Clear the land channel of all parcels. - /// - /// - /// If true, set up a default parcel covering the whole region owned by the estate owner. - /// - void Clear(bool setupDefaultParcel); - - bool IsLandPrimCountTainted(); - bool IsForcefulBansAllowed(); - void UpdateLandObject(int localID, LandData data); - void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient); - void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel); - void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel); - void SetParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime); - - void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id); - void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id); - } -} diff --git a/OpenSim/Region/Framework/Interfaces/ILandObject.cs b/OpenSim/Region/Framework/Interfaces/ILandObject.cs deleted file mode 100644 index 9c0abde..0000000 --- a/OpenSim/Region/Framework/Interfaces/ILandObject.cs +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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.Collections.Generic; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.Framework.Interfaces -{ - public delegate int overrideParcelMaxPrimCountDelegate(ILandObject obj); - public delegate int overrideSimulatorMaxPrimCountDelegate(ILandObject obj); - - public interface ILandObject - { - int GetParcelMaxPrimCount(ILandObject thisObject); - int GetSimulatorMaxPrimCount(ILandObject thisObject); - int GetPrimsFree(); - - LandData LandData { get; set; } - bool[,] LandBitmap { get; set; } - 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. - /// - Vector3 StartPoint { get; } - - /// - /// The end point for the land object. This is the eastern-most point as one scans land working from - /// south to north. - /// - Vector3 EndPoint { get; } - - bool ContainsPoint(int x, int y); - - ILandObject Copy(); - - void SendLandUpdateToAvatarsOverMe(); - - void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client); - void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client); - bool IsEitherBannedOrRestricted(UUID avatar); - bool IsBannedFromLand(UUID avatar); - bool IsRestrictedFromLand(UUID avatar); - void SendLandUpdateToClient(IClientAPI remote_client); - void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client); - List CreateAccessListArrayByFlag(AccessList flag); - void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); - void UpdateAccessList(uint flags, UUID transactionID, int sequenceID, int sections, List entries, IClientAPI remote_client); - void UpdateLandBitmapByteArray(); - void SetLandBitmapFromByteArray(); - bool[,] GetLandBitmap(); - void ForceUpdateLandInfo(); - void SetLandBitmap(bool[,] bitmap); - - bool[,] BasicFullRegionLandBitmap(); - bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y); - bool[,] ModifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value); - bool[,] MergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add); - void SendForceObjectSelect(int local_id, int request_type, List returnIDs, IClientAPI remote_client); - void SendLandObjectOwners(IClientAPI remote_client); - void ReturnObject(SceneObjectGroup obj); - void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client); - void ResetLandPrimCounts(); - void AddPrimToCount(SceneObjectGroup obj); - void RemovePrimFromCount(SceneObjectGroup obj); - void UpdateLandSold(UUID avatarID, UUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area); - - void DeedToGroup(UUID groupID); - - void SetParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel); - void SetSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel); - - /// - /// Set the media url for this land parcel - /// - /// - void SetMediaUrl(string url); - - /// - /// Set the music url for this land parcel - /// - /// - void SetMusicUrl(string url); - } -} 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 IPrimCounts GetPrimCounts(UUID parcelID); } - - public interface IPrimCounts - { - int Owner { get; } - int Group { get; } - int Others { get; } - int Simulator { get; } - IUserPrimCounts Users { get; } - } - - public interface IUserPrimCounts - { - int this[UUID agentID] { get; } - } -} +} \ No newline at end of file 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 } - public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) + public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) { } 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 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; 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 { } - public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor,int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) + public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor,int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) { } public void SendLandAccessListData(List avatars, uint accessFlag, int localLandID) diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index ebe0a72..d1dc17f 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -957,7 +957,7 @@ namespace OpenSim.Tests.Common.Mock { } - public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) + public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) { } -- cgit v1.1 From ea72745d43c2c6eced8329801ff8765746be7ddd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Mar 2011 23:18:47 +0000 Subject: Log the xml/ini regions config files that opensim loads from, and the regions that it loaded from them This will show up with the lines [REGION LOADER FILE SYSTEM]: Loading config files from ./Regions, etc. --- .../Filesystem/RegionLoaderFileSystem.cs | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs index 63e09ae..7cbd5ed 100644 --- a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs +++ b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs @@ -25,15 +25,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using log4net; using System; using System.Collections.Generic; using System.IO; +using System.Reflection; using Nini.Config; namespace OpenSim.Framework.RegionLoader.Filesystem { public class RegionLoaderFileSystem : IRegionLoader { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private IConfigSource m_configSource; public void SetIniConfigSource(IConfigSource configSource) @@ -63,36 +67,48 @@ namespace OpenSim.Framework.RegionLoader.Filesystem string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); + // Create an empty Regions.ini if there are no existing config files. if (configFiles.Length == 0 && iniFiles.Length == 0) - { + { new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource); iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); } + + m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config files from {0}", regionConfigPath); List regionInfos = new List(); int i = 0; foreach (string file in iniFiles) { + m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file); + IConfigSource source = new IniConfigSource(file); foreach (IConfig config in source.Configs) - { - //m_log.Info("[REGIONLOADERFILESYSTEM]: Creating RegionInfo for " + config.Name); + { RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource, config.Name); regionInfos.Add(regionInfo); + + m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded region {0}", regionInfo.RegionName); + i++; } } foreach (string file in configFiles) { + m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file); + RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource); regionInfos.Add(regionInfo); + + m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded region {0}", regionInfo.RegionName); + i++; } return regionInfos.ToArray(); } } -} +} \ No newline at end of file -- cgit v1.1 From 3a55d59b45dc0cbff938f0101bb6338bd8949e86 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Mar 2011 23:29:06 +0000 Subject: in region web loader, print out url that config is being loaded from (this wasn't being done anywhere). --- OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs index 0ec4af5..de4898a 100644 --- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs +++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs @@ -66,9 +66,9 @@ namespace OpenSim.Framework.RegionLoader.Web { HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); webRequest.Timeout = 30000; //30 Second Timeout - m_log.Debug("[WEBLOADER]: Sending Download Request..."); + m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url); HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); - m_log.Debug("[WEBLOADER]: Downloading Region Information From Remote Server..."); + m_log.Debug("[WEBLOADER]: Downloading region information..."); StreamReader reader = new StreamReader(webResponse.GetResponseStream()); string xmlSource = String.Empty; string tempStr = reader.ReadLine(); -- cgit v1.1 From d8e1c380e67512e0476b2a7b7441ae3acbb4606f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Mar 2011 23:36:58 +0000 Subject: minor: make it clearer in the log where we're loading region config files and not the regions themselves --- .../LoadRegions/LoadRegionsPlugin.cs | 28 ++++++++++------------ .../Filesystem/RegionLoaderFileSystem.cs | 4 ++-- 2 files changed, 15 insertions(+), 17 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index f37c399..e26c1d2 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -68,7 +68,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions public void Initialise() { - m_log.Error("[LOADREGIONS]: " + Name + " cannot be default-initialized!"); + m_log.Error("[LOAD REGIONS PLUGIN]: " + Name + " cannot be default-initialized!"); throw new PluginNotInitialisedException(Name); } @@ -85,41 +85,39 @@ namespace OpenSim.ApplicationPlugins.LoadRegions IRegionLoader regionLoader; if (m_openSim.ConfigSource.Source.Configs["Startup"].GetString("region_info_source", "filesystem") == "filesystem") { - m_log.Info("[LOADREGIONS]: Loading region configurations from filesystem"); + m_log.Info("[LOAD REGIONS PLUGIN]: Loading region configurations from filesystem"); regionLoader = new RegionLoaderFileSystem(); } else { - m_log.Info("[LOADREGIONSPLUGIN]: Loading region configurations from web"); + m_log.Info("[LOAD REGIONS PLUGIN]: Loading region configurations from web"); regionLoader = new RegionLoaderWebServer(); } - m_log.Info("[LOADREGIONSPLUGIN]: Loading region configurations..."); - regionLoader.SetIniConfigSource(m_openSim.ConfigSource.Source); RegionInfo[] regionsToLoad = regionLoader.LoadRegions(); - m_log.Info("[LOADREGIONSPLUGIN]: Loading specific shared modules..."); - m_log.Info("[LOADREGIONSPLUGIN]: DynamicTextureModule..."); + m_log.Info("[LOAD REGIONS PLUGIN]: Loading specific shared modules..."); + m_log.Info("[LOAD REGIONS PLUGIN]: DynamicTextureModule..."); m_openSim.ModuleLoader.LoadDefaultSharedModule(new DynamicTextureModule()); - m_log.Info("[LOADREGIONSPLUGIN]: LoadImageURLModule..."); + m_log.Info("[LOAD REGIONS PLUGIN]: LoadImageURLModule..."); m_openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule()); - m_log.Info("[LOADREGIONSPLUGIN]: XMLRPCModule..."); + m_log.Info("[LOAD REGIONS PLUGIN]: XMLRPCModule..."); m_openSim.ModuleLoader.LoadDefaultSharedModule(new XMLRPCModule()); // m_log.Info("[LOADREGIONSPLUGIN]: AssetTransactionModule..."); // m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule()); - m_log.Info("[LOADREGIONSPLUGIN]: Done."); + m_log.Info("[LOAD REGIONS PLUGIN]: Done."); if (!CheckRegionsForSanity(regionsToLoad)) { - m_log.Error("[LOADREGIONS]: Halting startup due to conflicts in region configurations"); + m_log.Error("[LOAD REGIONS PLUGIN]: Halting startup due to conflicts in region configurations"); Environment.Exit(1); } for (int i = 0; i < regionsToLoad.Length; i++) { IScene scene; - m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + + m_log.Debug("[LOAD REGIONS PLUGIN]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() + ")"); @@ -164,7 +162,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions if (regions[i].RegionID == regions[j].RegionID) { m_log.ErrorFormat( - "[LOADREGIONS]: Regions {0} and {1} have the same UUID {2}", + "[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same UUID {2}", regions[i].RegionName, regions[j].RegionName, regions[i].RegionID); return false; } @@ -172,14 +170,14 @@ namespace OpenSim.ApplicationPlugins.LoadRegions regions[i].RegionLocX == regions[j].RegionLocX && regions[i].RegionLocY == regions[j].RegionLocY) { m_log.ErrorFormat( - "[LOADREGIONS]: Regions {0} and {1} have the same grid location ({2}, {3})", + "[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same grid location ({2}, {3})", regions[i].RegionName, regions[j].RegionName, regions[i].RegionLocX, regions[i].RegionLocY); return false; } else if (regions[i].InternalEndPoint.Port == regions[j].InternalEndPoint.Port) { m_log.ErrorFormat( - "[LOADREGIONS]: Regions {0} and {1} have the same internal IP port {2}", + "[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same internal IP port {2}", regions[i].RegionName, regions[j].RegionName, regions[i].InternalEndPoint.Port); return false; } diff --git a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs index 7cbd5ed..0aae4ff 100644 --- a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs +++ b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs @@ -90,7 +90,7 @@ namespace OpenSim.Framework.RegionLoader.Filesystem RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource, config.Name); regionInfos.Add(regionInfo); - m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded region {0}", regionInfo.RegionName); + m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName); i++; } @@ -103,7 +103,7 @@ namespace OpenSim.Framework.RegionLoader.Filesystem RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource); regionInfos.Add(regionInfo); - m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded region {0}", regionInfo.RegionName); + m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName); i++; } -- cgit v1.1 From cc8897fcebdc9d3e875c9bf745ecb77678a776e9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 26 Mar 2011 00:34:49 +0000 Subject: Add test for PCM taint. This currently fails due to unexpected behaviour of SceneGraph.ForEachSOG(). This will be corrected soon. Also adds lots of temproarily debug logging --- OpenSim/Framework/ILandObject.cs | 112 +++++++++++++++++++++ .../Region/ClientStack/LindenUDP/LLClientView.cs | 2 + .../CoreModules/World/Land/PrimCountModule.cs | 79 ++++++++++++--- .../World/Land/Tests/PrimCountModuleTests.cs | 24 ++++- 4 files changed, 201 insertions(+), 16 deletions(-) create mode 100644 OpenSim/Framework/ILandObject.cs (limited to 'OpenSim') diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs new file mode 100644 index 0000000..931e24a --- /dev/null +++ b/OpenSim/Framework/ILandObject.cs @@ -0,0 +1,112 @@ +/* + * 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.Collections.Generic; +using OpenMetaverse; + +namespace OpenSim.Framework +{ + public delegate int overrideParcelMaxPrimCountDelegate(ILandObject obj); + public delegate int overrideSimulatorMaxPrimCountDelegate(ILandObject obj); + + public interface ILandObject + { + int GetParcelMaxPrimCount(ILandObject thisObject); + int GetSimulatorMaxPrimCount(ILandObject thisObject); + int GetPrimsFree(); + + LandData LandData { get; set; } + bool[,] LandBitmap { get; set; } + 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. + /// + Vector3 StartPoint { get; } + + /// + /// The end point for the land object. This is the eastern-most point as one scans land working from + /// south to north. + /// + Vector3 EndPoint { get; } + + bool ContainsPoint(int x, int y); + + ILandObject Copy(); + + void SendLandUpdateToAvatarsOverMe(); + + void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client); + void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client); + bool IsEitherBannedOrRestricted(UUID avatar); + bool IsBannedFromLand(UUID avatar); + bool IsRestrictedFromLand(UUID avatar); + void SendLandUpdateToClient(IClientAPI remote_client); + void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client); + List CreateAccessListArrayByFlag(AccessList flag); + void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); + void UpdateAccessList(uint flags, UUID transactionID, int sequenceID, int sections, List entries, IClientAPI remote_client); + void UpdateLandBitmapByteArray(); + void SetLandBitmapFromByteArray(); + bool[,] GetLandBitmap(); + void ForceUpdateLandInfo(); + void SetLandBitmap(bool[,] bitmap); + + bool[,] BasicFullRegionLandBitmap(); + bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y); + bool[,] ModifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value); + bool[,] MergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add); + void SendForceObjectSelect(int local_id, int request_type, List returnIDs, IClientAPI remote_client); + void SendLandObjectOwners(IClientAPI remote_client); + void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client); + void ResetLandPrimCounts(); + void UpdateLandSold(UUID avatarID, UUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area); + + void DeedToGroup(UUID groupID); + + void SetParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel); + void SetSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel); + + /// + /// Set the media url for this land parcel + /// + /// + void SetMediaUrl(string url); + + /// + /// Set the music url for this land parcel + /// + /// + void SetMusicUrl(string url); + } +} diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 6138056..0b6b04d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4276,6 +4276,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) { + m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name); + LandData landData = lo.LandData; ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage(); diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 9fd347e..72115a8 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -51,8 +51,7 @@ 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 = @@ -123,6 +122,11 @@ namespace OpenSim.Region.CoreModules.World.Land { if (!m_Tainted) AddObject(obj); + else + m_log.DebugFormat( + "[PRIM COUNT MODULE]: Ignoring OnParcelPrimCountAdd() for {0} on {1} since count is tainted", + obj.Name, m_Scene.RegionInfo.RegionName); + } } @@ -133,11 +137,18 @@ namespace OpenSim.Region.CoreModules.World.Land { if (!m_Tainted) RemoveObject(obj); + else + m_log.DebugFormat( + "[PRIM COUNT MODULE]: Ignoring OnObjectBeingRemovedFromScene() for {0} on {1} since count is tainted", + obj.Name, m_Scene.RegionInfo.RegionName); } } private void OnParcelPrimCountTainted() { + m_log.DebugFormat( + "[PRIM COUNT MODULE]: OnParcelPrimCountTainted() called on {0}", m_Scene.RegionInfo.RegionName); + lock (m_TaintLock) m_Tainted = true; } @@ -163,7 +174,7 @@ 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); + m_log.DebugFormat("[PRIM COUNT MODULE]: Adding object {0} {1} to prim count", obj.Name, obj.UUID); if (obj.IsAttachment) return; @@ -214,10 +225,14 @@ namespace OpenSim.Region.CoreModules.World.Land // NOTE: Call under Taint Lock private void RemoveObject(SceneObjectGroup obj) { + m_log.DebugFormat("[PRIM COUNT MODULE]: Removing object {0} {1} from prim count", obj.Name, obj.UUID); } public IPrimCounts GetPrimCounts(UUID parcelID) { + m_log.DebugFormat( + "[PRIM COUNT MODULE]: GetPrimCounts for parcel {0} in {1}", parcelID, m_Scene.RegionInfo.RegionName); + PrimCounts primCounts; lock (m_PrimCounts) @@ -239,7 +254,7 @@ namespace OpenSim.Region.CoreModules.World.Land /// public int GetOwnerCount(UUID parcelID) { -// m_log.DebugFormat("[PRIM COUNT MODULE]: GetOwnerCount for {0}", parcelID); + int count = 0; lock (m_TaintLock) { @@ -248,9 +263,14 @@ namespace OpenSim.Region.CoreModules.World.Land ParcelCounts counts; if (m_ParcelCounts.TryGetValue(parcelID, out counts)) - return counts.Owner; + count = counts.Owner; } - return 0; + + m_log.DebugFormat( + "[PRIM COUNT MODULE]: GetOwnerCount for parcel {0} in {1} returning {2}", + parcelID, m_Scene.RegionInfo.RegionName, count); + + return count; } /// @@ -260,6 +280,8 @@ namespace OpenSim.Region.CoreModules.World.Land /// public int GetGroupCount(UUID parcelID) { + int count = 0; + lock (m_TaintLock) { if (m_Tainted) @@ -267,9 +289,14 @@ namespace OpenSim.Region.CoreModules.World.Land ParcelCounts counts; if (m_ParcelCounts.TryGetValue(parcelID, out counts)) - return counts.Group; + count = counts.Group; } - return 0; + + m_log.DebugFormat( + "[PRIM COUNT MODULE]: GetGroupCount for parcel {0} in {1} returning {2}", + parcelID, m_Scene.RegionInfo.RegionName, count); + + return count; } /// @@ -279,6 +306,8 @@ namespace OpenSim.Region.CoreModules.World.Land /// public int GetOthersCount(UUID parcelID) { + int count = 0; + lock (m_TaintLock) { if (m_Tainted) @@ -286,9 +315,14 @@ namespace OpenSim.Region.CoreModules.World.Land ParcelCounts counts; if (m_ParcelCounts.TryGetValue(parcelID, out counts)) - return counts.Others; + count = counts.Others; } - return 0; + + m_log.DebugFormat( + "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}", + parcelID, m_Scene.RegionInfo.RegionName, count); + + return count; } /// @@ -298,6 +332,8 @@ namespace OpenSim.Region.CoreModules.World.Land /// public int GetSimulatorCount(UUID parcelID) { + int count = 0; + lock (m_TaintLock) { if (m_Tainted) @@ -308,10 +344,15 @@ namespace OpenSim.Region.CoreModules.World.Land { int val; if (m_SimwideCounts.TryGetValue(owner, out val)) - return val; + count = val; } } - return 0; + + m_log.DebugFormat( + "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}", + parcelID, m_Scene.RegionInfo.RegionName, count); + + return count; } /// @@ -322,6 +363,8 @@ namespace OpenSim.Region.CoreModules.World.Land /// public int GetUserCount(UUID parcelID, UUID userID) { + int count = 0; + lock (m_TaintLock) { if (m_Tainted) @@ -332,16 +375,21 @@ namespace OpenSim.Region.CoreModules.World.Land { int val; if (counts.Users.TryGetValue(userID, out val)) - return val; + count = val; } } - return 0; + + m_log.DebugFormat( + "[PRIM COUNT MODULE]: GetUserCount for user {0} in parcel {1} in region {2} returning {3}", + userID, parcelID, m_Scene.RegionInfo.RegionName, count); + + return count; } // 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_log.DebugFormat("[PRIM COUNT MODULE]: Recounting prims on {0}", m_Scene.RegionInfo.RegionName); m_OwnerMap.Clear(); m_SimwideCounts.Clear(); @@ -367,6 +415,7 @@ namespace OpenSim.Region.CoreModules.World.Land if (!m_OwnerMap.ContainsKey(k)) m_PrimCounts.Remove(k); } + m_Tainted = false; } } diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index c9d393f..80b2859 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -126,6 +126,28 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests 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)); - } + } + + /// + /// Test the count is correct after is has been tainted. + /// + [Test] + public void TestTaint() + { + TestHelper.InMethod(); + IPrimCounts pc = m_lo.PrimCounts; + + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); + m_scene.AddNewSceneObject(sog, false); + + m_pcm.TaintPrimCount(); + + 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)); + } } } \ No newline at end of file -- 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') 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') 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 bfd9cc44b40e64af3c7504d43a15b7e1b44070a0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 26 Mar 2011 02:05:53 +0000 Subject: When an object is duplicated, add the dupe to the uuid/local id indexes as well as the basic entities list. Added a prim counts test to reinforce this - shift-copy was no incrementing prim count. This will sometime become a basic scene test. New code needs to be refactored so we just call SceneGraph.AddSceneObject(). This will happen in the near future. With this, basic owner prim counts on a single parcel appear to be working fine (with the same previous existing taint calls as used by the land management module). More work to do. --- .../World/Land/Tests/PrimCountModuleTests.cs | 23 +++++++++++++++++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 30 +++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 80b2859..dd55f98 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -105,6 +105,29 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests } /// + /// Test count after a parcel owner owned copied object is added. + /// + [Test] + public void TestCopiedOwnerObject() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + IPrimCounts pc = m_lo.PrimCounts; + + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); + m_scene.AddNewSceneObject(sog, false); + m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity); + + Assert.That(pc.Owner, Is.EqualTo(6)); + Assert.That(pc.Group, Is.EqualTo(0)); + Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Users[m_userId], Is.EqualTo(6)); + Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); + Assert.That(pc.Simulator, Is.EqualTo(6)); + } + + /// /// Test count after a parcel owner owned object is removed. /// [Test] 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 From 541cd3e8c84d3ccc13525206b1724ee931416a3c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 26 Mar 2011 02:19:28 +0000 Subject: move total parcel prim calculations into IPrimCounts instead of doing this in LLClientView need to move selected prim counts from LandData/LMM still --- OpenSim/Framework/IPrimCounts.cs | 24 +++++++++++++ .../CoreModules/World/Land/PrimCountModule.cs | 39 ++++++++++++++++++++++ .../World/Land/Tests/PrimCountModuleTests.cs | 8 ++++- 3 files changed, 70 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/IPrimCounts.cs b/OpenSim/Framework/IPrimCounts.cs index 7d362c5..8ae57fc 100644 --- a/OpenSim/Framework/IPrimCounts.cs +++ b/OpenSim/Framework/IPrimCounts.cs @@ -31,10 +31,34 @@ namespace OpenSim.Framework { public interface IPrimCounts { + /// + /// Parcel owner owned prims + /// int Owner { get; } + + /// + /// Parcel group owned prims + /// int Group { get; } + + /// + /// Prims owned by others (not parcel owner or parcel group). + /// int Others { get; } + + /// + /// Total prims on the parcel. + /// + int Total { get; } + + /// + /// Prims on the simulator that are owned by the parcel owner, even if they are in other parcels. + /// int Simulator { get; } + + /// + /// Prims per individual users. + /// IUserPrimCounts Users { get; } } diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 72115a8..2de5c16 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -324,6 +324,37 @@ namespace OpenSim.Region.CoreModules.World.Land return count; } + + /// + /// Get the total count of owner, group and others prims on the parcel. + /// FIXME: Need to do selected prims once this is reimplemented. + /// + /// + /// + public int GetTotalCount(UUID parcelID) + { + int count = 0; + + lock (m_TaintLock) + { + if (m_Tainted) + Recount(); + + ParcelCounts counts; + if (m_ParcelCounts.TryGetValue(parcelID, out counts)) + { + count = counts.Owner; + count += counts.Group; + count += counts.Others; + } + } + + m_log.DebugFormat( + "[PRIM COUNT MODULE]: GetTotalCount for parcel {0} in {1} returning {2}", + parcelID, m_Scene.RegionInfo.RegionName, count); + + return count; + } /// /// Get the number of prims that are in the entire simulator for the owner of this parcel. @@ -457,6 +488,14 @@ namespace OpenSim.Region.CoreModules.World.Land return m_Parent.GetOthersCount(m_ParcelID); } } + + public int Total + { + get + { + return m_Parent.GetTotalCount(m_ParcelID); + } + } public int Simulator { diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index dd55f98..58bd841 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -78,9 +78,10 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Owner, Is.EqualTo(0)); Assert.That(pc.Group, Is.EqualTo(0)); Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Total, 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)); + Assert.That(pc.Simulator, Is.EqualTo(0)); SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); m_scene.AddNewSceneObject(sog, false); @@ -88,6 +89,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Owner, Is.EqualTo(3)); Assert.That(pc.Group, Is.EqualTo(0)); Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Total, Is.EqualTo(3)); 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)); @@ -99,6 +101,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Owner, Is.EqualTo(5)); Assert.That(pc.Group, Is.EqualTo(0)); Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Total, Is.EqualTo(5)); 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)); @@ -122,6 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Owner, Is.EqualTo(6)); Assert.That(pc.Group, Is.EqualTo(0)); Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Total, Is.EqualTo(6)); Assert.That(pc.Users[m_userId], Is.EqualTo(6)); Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); Assert.That(pc.Simulator, Is.EqualTo(6)); @@ -146,6 +150,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Owner, Is.EqualTo(1)); Assert.That(pc.Group, Is.EqualTo(0)); Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Total, Is.EqualTo(1)); 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)); @@ -168,6 +173,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Owner, Is.EqualTo(3)); Assert.That(pc.Group, Is.EqualTo(0)); Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Total, Is.EqualTo(3)); 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)); -- cgit v1.1 From b11e3d33f112f4838ca8dde2d217780affbddce4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 26 Mar 2011 02:20:16 +0000 Subject: add save of LLClientView I forgot from last commit --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 0b6b04d..f50637c 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4360,10 +4360,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP updateMessage.OwnerPrims = pc.Owner; updateMessage.GroupPrims = pc.Group; updateMessage.OtherPrims = pc.Others; - updateMessage.SimWideTotalPrims = pc.Simulator; - - // FIXME: Need to do selected prims once this is reimplemented. - updateMessage.TotalPrims = pc.Owner + pc.Group + pc.Others; + updateMessage.TotalPrims = pc.Total; + updateMessage.SimWideTotalPrims = pc.Simulator; // TODO: Need to transfer selected prims to new prim count structure. updateMessage.SelectedPrims = landData.SelectedPrims; -- 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') 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 From 482686daab055d4d2d878b238059b442e64122f4 Mon Sep 17 00:00:00 2001 From: SignpostMarv Martin Date: Tue, 15 Mar 2011 10:29:24 +0000 Subject: WebkeyAuthenticationService is now no longer a stub! Signed-off-by: SignpostMarv Martin --- .../WebkeyAuthenticationService.cs | 40 +++++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs index d1a5b0f..a072958 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs @@ -31,6 +31,9 @@ using OpenSim.Services.Interfaces; using log4net; using Nini.Config; using System.Reflection; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Framework.Console; namespace OpenSim.Services.AuthenticationService { @@ -43,17 +46,44 @@ namespace OpenSim.Services.AuthenticationService public class WebkeyAuthenticationService : AuthenticationServiceBase, IAuthenticationService { -// private static readonly ILog m_log = -// LogManager.GetLogger( -// MethodBase.GetCurrentMethod().DeclaringType); - + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + public WebkeyAuthenticationService(IConfigSource config) : - base(config) + base(config) { } public string Authenticate(UUID principalID, string password, int lifetime) { + m_log.InfoFormat("[Authenticate]: Trying a web key authenticate"); + if (new UUID(password) == UUID.Zero) + { + m_log.InfoFormat("[Authenticate]: NULL_KEY is not a valid web_login_key"); + } + else + { + AuthenticationData data = m_Database.Get(principalID); + if (data != null && data.Data != null) + { + if (data.Data.ContainsKey("webLoginKey")) + { + m_log.InfoFormat("[Authenticate]: Trying a web key authentication"); + string key = data.Data["webLoginKey"].ToString(); + m_log.DebugFormat("[WEB LOGIN AUTH]: got {0} for key in db vs {1}", key, password); + if (key == password) + { + data.Data["webLoginKey"] = UUID.Zero.ToString(); + m_Database.Store(data); + return GetToken(principalID, lifetime); + } + }else{ + m_log.InfoFormat("[Authenticate]: no col webLoginKey in passwd.db"); + } + } + m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID); + } return String.Empty; } } -- cgit v1.1 From af3956348fc58613948889e5f85030a454684970 Mon Sep 17 00:00:00 2001 From: SignpostMarv Martin Date: Tue, 15 Mar 2011 10:29:42 +0000 Subject: Adding a combined auth service, allowing users to login with either web login or password Signed-off-by: SignpostMarv Martin --- .../WebkeyOrPasswordAuthenticationService.cs | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs (limited to 'OpenSim') diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs new file mode 100644 index 0000000..0f2fd93 --- /dev/null +++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Services.Interfaces; +using log4net; +using Nini.Config; +using System.Reflection; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Framework.Console; + +namespace OpenSim.Services.AuthenticationService +{ + public class WebkeyOrPasswordAuthenticationService : AuthenticationServiceBase, IAuthenticationService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public WebkeyOrPasswordAuthenticationService(IConfigSource config) + : base(config) + { + } + + public string Authenticate(UUID principalID, string password, int lifetime) + { + AuthenticationData data = m_Database.Get(principalID); + if (data != null && data.Data != null) + { + if (data.Data.ContainsKey("webLoginKey")) + { + m_log.InfoFormat("[Authenticate]: Trying a web key authentication"); + if (new UUID(password) == UUID.Zero) + { + m_log.InfoFormat("[Authenticate]: NULL_KEY is not a valid web_login_key"); + } + else + { + string key = data.Data["webLoginKey"].ToString(); + m_log.DebugFormat("[WEB LOGIN AUTH]: got {0} for key in db vs {1}", key, password); + if (key == password) + { + data.Data["webLoginKey"] = UUID.Zero.ToString(); + m_Database.Store(data); + return GetToken(principalID, lifetime); + } + } + } + if (data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt")) + { + m_log.InfoFormat("[Authenticate]: Trying a password authentication"); + string hashed = Util.Md5Hash(password + ":" + data.Data["passwordSalt"].ToString()); + m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString()); + if (data.Data["passwordHash"].ToString() == hashed) + { + return GetToken(principalID, lifetime); + } + } + m_log.DebugFormat("[AUTH SERVICE]: Both password and webLoginKey-based login failed for PrincipalID {0}", principalID); + } + else + { + m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID); + } + return string.Empty; + } + } +} -- cgit v1.1 From 6153c4597322ccef6bdb7662b6461faa260b13ea Mon Sep 17 00:00:00 2001 From: SignpostMarv Martin Date: Tue, 15 Mar 2011 10:29:51 +0000 Subject: LLLoginHandlers now supports both password & web login Signed-off-by: SignpostMarv Martin --- OpenSim/Server/Handlers/Login/LLLoginHandlers.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs index 48f5f99..8048f86 100644 --- a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs +++ b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs @@ -74,12 +74,23 @@ namespace OpenSim.Server.Handlers.Login if (requestData != null) { if (requestData.ContainsKey("first") && requestData["first"] != null && - requestData.ContainsKey("last") && requestData["last"] != null && - requestData.ContainsKey("passwd") && requestData["passwd"] != null) + requestData.ContainsKey("last") && requestData["last"] != null && ( + (requestData.ContainsKey("passwd") && requestData["passwd"] != null) || + (!requestData.ContainsKey("passwd") && requestData.ContainsKey("web_login_key") && requestData["web_login_key"] != null && requestData["web_login_key"].ToString() != UUID.Zero.ToString()) + )) { string first = requestData["first"].ToString(); string last = requestData["last"].ToString(); - string passwd = requestData["passwd"].ToString(); + string passwd = null; + if (requestData.ContainsKey("passwd")) + { + passwd = requestData["passwd"].ToString(); + } + else if (requestData.ContainsKey("web_login_key")) + { + passwd = "$1$" + requestData["web_login_key"].ToString(); + m_log.InfoFormat("[LOGIN]: XMLRPC Login Req key {0}", passwd); + } string startLocation = string.Empty; UUID scopeID = UUID.Zero; if (requestData["scope_id"] != null) @@ -103,7 +114,7 @@ namespace OpenSim.Server.Handlers.Login string id0 = "Unknown"; if (requestData.Contains("id0") && requestData["id0"] != null) id0 = requestData["id0"].ToString(); - + //m_log.InfoFormat("[LOGIN]: XMLRPC Login Requested for {0} {1}, starting in {2}, using {3}", first, last, startLocation, clientVersion); LoginResponse reply = null; -- cgit v1.1 From 0e808950fbb54271d478d29669bf035949731114 Mon Sep 17 00:00:00 2001 From: SignpostMarv Martin Date: Mon, 21 Mar 2011 14:47:10 +0000 Subject: InfoFormat > DebugFormat Signed-off-by: SignpostMarv Martin --- OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs index a072958..5924026 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs @@ -79,7 +79,7 @@ namespace OpenSim.Services.AuthenticationService return GetToken(principalID, lifetime); } }else{ - m_log.InfoFormat("[Authenticate]: no col webLoginKey in passwd.db"); + m_log.DebugFormat("[Authenticate]: no col webLoginKey in passwd.db"); } } m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID); -- cgit v1.1 From 3bc859a834c50634281df3d52166fc68d7c3c3ba Mon Sep 17 00:00:00 2001 From: SignpostMarv Martin Date: Mon, 21 Mar 2011 15:42:57 +0000 Subject: Making combined auth service re-use the existing auth services instead of duplicating code Signed-off-by: SignpostMarv Martin --- .../WebkeyOrPasswordAuthenticationService.cs | 40 ++++++++++------------ 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs index 0f2fd93..b8bb090 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs @@ -8,58 +8,56 @@ using System.Reflection; using OpenSim.Data; using OpenSim.Framework; using OpenSim.Framework.Console; +using OpenSim.Server.Base; namespace OpenSim.Services.AuthenticationService { public class WebkeyOrPasswordAuthenticationService : AuthenticationServiceBase, IAuthenticationService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private IConfigSource config; public WebkeyOrPasswordAuthenticationService(IConfigSource config) : base(config) { + this.config = config; } public string Authenticate(UUID principalID, string password, int lifetime) { AuthenticationData data = m_Database.Get(principalID); + IAuthenticationService svc; + Object[] args = new Object[] { config }; + string result = String.Empty; if (data != null && data.Data != null) { if (data.Data.ContainsKey("webLoginKey")) { - m_log.InfoFormat("[Authenticate]: Trying a web key authentication"); - if (new UUID(password) == UUID.Zero) + svc = ServerUtils.LoadPlugin("OpenSim.Services.AuthenticationService.dll", "WebkeyAuthenticationService", args); + result = svc.Authenticate(principalID, password, lifetime); + if (result == String.Empty) { - m_log.InfoFormat("[Authenticate]: NULL_KEY is not a valid web_login_key"); - } - else - { - string key = data.Data["webLoginKey"].ToString(); - m_log.DebugFormat("[WEB LOGIN AUTH]: got {0} for key in db vs {1}", key, password); - if (key == password) - { - data.Data["webLoginKey"] = UUID.Zero.ToString(); - m_Database.Store(data); - return GetToken(principalID, lifetime); - } + m_log.DebugFormat("[Authenticate]: Web Login failed for PrincipalID {0}", principalID); } } if (data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt")) { - m_log.InfoFormat("[Authenticate]: Trying a password authentication"); - string hashed = Util.Md5Hash(password + ":" + data.Data["passwordSalt"].ToString()); - m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString()); - if (data.Data["passwordHash"].ToString() == hashed) + svc = ServerUtils.LoadPlugin("OpenSim.Services.AuthenticationService.dll", "PasswordAuthenticationService", args); + result = svc.Authenticate(principalID, password, lifetime); + if (result == String.Empty) { - return GetToken(principalID, lifetime); + m_log.DebugFormat("[Authenticate]: Password login failed for PrincipalID {0}", principalID); } } - m_log.DebugFormat("[AUTH SERVICE]: Both password and webLoginKey-based login failed for PrincipalID {0}", principalID); + if (result == string.Empty) + { + m_log.DebugFormat("[AUTH SERVICE]: Both password and webLoginKey-based login failed for PrincipalID {0}", principalID); + } } else { m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID); } - return string.Empty; + return result; } } } -- cgit v1.1 From e93531e1240348f18abb4ef88a0def227026e8f3 Mon Sep 17 00:00:00 2001 From: SignpostMarv Martin Date: Thu, 24 Mar 2011 16:21:12 +0000 Subject: Fixing bug that occurs when using web login- the result was not checked --- .../AuthenticationService/WebkeyOrPasswordAuthenticationService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs index b8bb090..3a47e97 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs @@ -39,7 +39,7 @@ namespace OpenSim.Services.AuthenticationService m_log.DebugFormat("[Authenticate]: Web Login failed for PrincipalID {0}", principalID); } } - if (data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt")) + if (result == string.Empty && data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt")) { svc = ServerUtils.LoadPlugin("OpenSim.Services.AuthenticationService.dll", "PasswordAuthenticationService", args); result = svc.Authenticate(principalID, password, lifetime); -- cgit v1.1 From 3f4be42a87f77d5da7e6cafd4fb98ff6a502636d Mon Sep 17 00:00:00 2001 From: SignpostMarv Martin Date: Thu, 24 Mar 2011 16:46:21 +0000 Subject: Altering log feedback --- .../WebkeyAuthenticationService.cs | 23 +++++++++++----------- .../WebkeyOrPasswordAuthenticationService.cs | 8 +++++--- 2 files changed, 17 insertions(+), 14 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs index 5924026..2344c0e 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs @@ -57,10 +57,9 @@ namespace OpenSim.Services.AuthenticationService public string Authenticate(UUID principalID, string password, int lifetime) { - m_log.InfoFormat("[Authenticate]: Trying a web key authenticate"); if (new UUID(password) == UUID.Zero) { - m_log.InfoFormat("[Authenticate]: NULL_KEY is not a valid web_login_key"); + m_log.DebugFormat("[AUTH SERVICE]: UUID.Zero is not a valid web_login_key on PrincipalID {0}", principalID); } else { @@ -69,17 +68,19 @@ namespace OpenSim.Services.AuthenticationService { if (data.Data.ContainsKey("webLoginKey")) { - m_log.InfoFormat("[Authenticate]: Trying a web key authentication"); string key = data.Data["webLoginKey"].ToString(); - m_log.DebugFormat("[WEB LOGIN AUTH]: got {0} for key in db vs {1}", key, password); - if (key == password) - { - data.Data["webLoginKey"] = UUID.Zero.ToString(); - m_Database.Store(data); - return GetToken(principalID, lifetime); - } + if (key == password) + { + data.Data["webLoginKey"] = UUID.Zero.ToString(); + m_Database.Store(data); + return GetToken(principalID, lifetime); + } + else + { + m_log.DebugFormat("[AUTH SERVICE]: web login auth failed, got PrincipalID {0} gave {1} instead of {2}", principalID, password, key); + } }else{ - m_log.DebugFormat("[Authenticate]: no col webLoginKey in passwd.db"); + m_log.DebugFormat("[AUTH SERVICE]: no col webLoginKey in passwd.db"); } } m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID); diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs index 3a47e97..c315ef2 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs @@ -32,25 +32,27 @@ namespace OpenSim.Services.AuthenticationService { if (data.Data.ContainsKey("webLoginKey")) { + m_log.DebugFormat("[AUTH SERVICE]: Attempting web key authentication for PrincipalID {0}", principalID); svc = ServerUtils.LoadPlugin("OpenSim.Services.AuthenticationService.dll", "WebkeyAuthenticationService", args); result = svc.Authenticate(principalID, password, lifetime); if (result == String.Empty) { - m_log.DebugFormat("[Authenticate]: Web Login failed for PrincipalID {0}", principalID); + m_log.DebugFormat("[AUTH SERVICE]: Web Login failed for PrincipalID {0}", principalID); } } if (result == string.Empty && data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt")) { + m_log.DebugFormat("[AUTH SERVICE]: Attempting password authentication for PrincipalID {0}", principalID); svc = ServerUtils.LoadPlugin("OpenSim.Services.AuthenticationService.dll", "PasswordAuthenticationService", args); result = svc.Authenticate(principalID, password, lifetime); if (result == String.Empty) { - m_log.DebugFormat("[Authenticate]: Password login failed for PrincipalID {0}", principalID); + m_log.DebugFormat("[AUTH SERVICE]: Password login failed for PrincipalID {0}", principalID); } } if (result == string.Empty) { - m_log.DebugFormat("[AUTH SERVICE]: Both password and webLoginKey-based login failed for PrincipalID {0}", principalID); + m_log.DebugFormat("[AUTH SERVICE]: Both password and webLoginKey-based authentication failed for PrincipalID {0}", principalID); } } else -- cgit v1.1 From 361b3e7ab8313b89475bc644fdcd348e071b951a Mon Sep 17 00:00:00 2001 From: SignpostMarv Martin Date: Thu, 24 Mar 2011 17:04:29 +0000 Subject: Removing hard-coded plugin loading in favour of direct class instantiation --- .../WebkeyOrPasswordAuthenticationService.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs index c315ef2..15dc5be 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs @@ -16,25 +16,25 @@ namespace OpenSim.Services.AuthenticationService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IConfigSource config; + private Dictionary svc_checks; public WebkeyOrPasswordAuthenticationService(IConfigSource config) : base(config) { this.config = config; + svc_checks["web_login_key"] = new WebkeyAuthenticationService(config); + svc_checks["password"] = new PasswordAuthenticationService(config); } public string Authenticate(UUID principalID, string password, int lifetime) { AuthenticationData data = m_Database.Get(principalID); - IAuthenticationService svc; - Object[] args = new Object[] { config }; string result = String.Empty; if (data != null && data.Data != null) { if (data.Data.ContainsKey("webLoginKey")) { m_log.DebugFormat("[AUTH SERVICE]: Attempting web key authentication for PrincipalID {0}", principalID); - svc = ServerUtils.LoadPlugin("OpenSim.Services.AuthenticationService.dll", "WebkeyAuthenticationService", args); - result = svc.Authenticate(principalID, password, lifetime); + result = svc_checks["web_login_key"].Authenticate(principalID, password, lifetime); if (result == String.Empty) { m_log.DebugFormat("[AUTH SERVICE]: Web Login failed for PrincipalID {0}", principalID); @@ -43,8 +43,7 @@ namespace OpenSim.Services.AuthenticationService if (result == string.Empty && data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt")) { m_log.DebugFormat("[AUTH SERVICE]: Attempting password authentication for PrincipalID {0}", principalID); - svc = ServerUtils.LoadPlugin("OpenSim.Services.AuthenticationService.dll", "PasswordAuthenticationService", args); - result = svc.Authenticate(principalID, password, lifetime); + result = svc_checks["password"].Authenticate(principalID, password, lifetime); if (result == String.Empty) { m_log.DebugFormat("[AUTH SERVICE]: Password login failed for PrincipalID {0}", principalID); -- cgit v1.1 From de0730a54ca8b2ede0727212bfc2474c0eff979f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 26 Mar 2011 02:42:50 +0000 Subject: Add OpenSim.Server.Base reference in prebuild.xml. Initialize svc_checks dictionary in WebkeyOrPasswordAuthenticationService, which was what was causing the load failure. --- .../AuthenticationService/WebkeyOrPasswordAuthenticationService.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs index 15dc5be..bcfd03d 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs @@ -15,8 +15,11 @@ namespace OpenSim.Services.AuthenticationService public class WebkeyOrPasswordAuthenticationService : AuthenticationServiceBase, IAuthenticationService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private IConfigSource config; - private Dictionary svc_checks; + private Dictionary svc_checks + = new Dictionary(); + public WebkeyOrPasswordAuthenticationService(IConfigSource config) : base(config) { -- cgit v1.1 From 83f48c26d62b148c11776af6d4947fc2397a675d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 26 Mar 2011 02:43:41 +0000 Subject: add header file --- .../WebkeyOrPasswordAuthenticationService.cs | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs index bcfd03d..00056a6 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs @@ -1,4 +1,31 @@ -using System; +/* + * 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 OpenMetaverse; using OpenSim.Services.Interfaces; -- cgit v1.1 From 797128a6ad89ea4944074f99db0a30ad7a5e7a3d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 26 Mar 2011 02:44:46 +0000 Subject: Rename some member fields to standard m_ OpenSim code convention --- .../WebkeyOrPasswordAuthenticationService.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs index 00056a6..3590e12 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs @@ -43,16 +43,16 @@ namespace OpenSim.Services.AuthenticationService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private IConfigSource config; - private Dictionary svc_checks + private IConfigSource m_config; + private Dictionary m_svcChecks = new Dictionary(); public WebkeyOrPasswordAuthenticationService(IConfigSource config) : base(config) { - this.config = config; - svc_checks["web_login_key"] = new WebkeyAuthenticationService(config); - svc_checks["password"] = new PasswordAuthenticationService(config); + this.m_config = config; + m_svcChecks["web_login_key"] = new WebkeyAuthenticationService(config); + m_svcChecks["password"] = new PasswordAuthenticationService(config); } public string Authenticate(UUID principalID, string password, int lifetime) @@ -64,7 +64,7 @@ namespace OpenSim.Services.AuthenticationService if (data.Data.ContainsKey("webLoginKey")) { m_log.DebugFormat("[AUTH SERVICE]: Attempting web key authentication for PrincipalID {0}", principalID); - result = svc_checks["web_login_key"].Authenticate(principalID, password, lifetime); + result = m_svcChecks["web_login_key"].Authenticate(principalID, password, lifetime); if (result == String.Empty) { m_log.DebugFormat("[AUTH SERVICE]: Web Login failed for PrincipalID {0}", principalID); @@ -73,7 +73,7 @@ namespace OpenSim.Services.AuthenticationService if (result == string.Empty && data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt")) { m_log.DebugFormat("[AUTH SERVICE]: Attempting password authentication for PrincipalID {0}", principalID); - result = svc_checks["password"].Authenticate(principalID, password, lifetime); + result = m_svcChecks["password"].Authenticate(principalID, password, lifetime); if (result == String.Empty) { m_log.DebugFormat("[AUTH SERVICE]: Password login failed for PrincipalID {0}", principalID); @@ -91,4 +91,4 @@ namespace OpenSim.Services.AuthenticationService return result; } } -} +} \ No newline at end of file -- cgit v1.1 From 2d209d3844a58a4d27fe15aa5ccd497bbd530707 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Mar 2011 16:46:04 -0700 Subject: Fix mantis #5413. WARNING: new config variable in section [GridService] of the simulators called Gatekeeper -- intended to have the URL of the grid's Gatekeeper service (so that it can be checked against). See ini.examples. --- OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | 6 +++++- OpenSim/Services/GridService/HypergridLinker.cs | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'OpenSim') 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 // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region regionInfos = new List(); GridRegion info = m_scene.GridService.GetRegionByName(m_scene.RegionInfo.ScopeID, mapName); - if (info != null) regionInfos.Add(info); + if (info != null) + regionInfos.Add(info); } + else if (regionInfos.Count == 0 && mapName.StartsWith("http://")) + remoteClient.SendAlertMessage("Hyperlink could not be established."); + m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); List blocks = new List(); diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 12ea453..585d088 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -65,6 +65,7 @@ namespace OpenSim.Services.GridService protected UUID m_ScopeID = UUID.Zero; protected bool m_Check4096 = true; protected string m_MapTileDirectory = string.Empty; + protected string m_ThisGatekeeper = string.Empty; // Hyperlink regions are hyperlinks on the map public readonly Dictionary m_HyperlinkRegions = new Dictionary(); @@ -123,6 +124,8 @@ namespace OpenSim.Services.GridService m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles"); + m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", string.Empty); + m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); @@ -266,6 +269,13 @@ namespace OpenSim.Services.GridService regInfo.ScopeID = scopeID; regInfo.EstateOwner = ownerID; + // Make sure we're not hyperlinking to regions on this grid! + if (regInfo.ServerURI.Trim(new char[]{'/', ' '}) == m_ThisGatekeeper.Trim(new char[]{'/', ' '})) + { + reason = "Cannot hyperlink to regions on the same grid"; + return false; + } + // Check for free coordinates GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY); if (region != null) -- cgit v1.1 From d3771e536645f50401e9737a693fcbb1fb3b6a01 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Mar 2011 16:48:12 -0700 Subject: Added code to load a terrain tile of tiff/jpg format. Previously it only worked for one single region. --- .../World/Terrain/FileLoaders/GenericSystemDrawing.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'OpenSim') 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 return LoadBitmap(new Bitmap(filename)); } - public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) + public virtual ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int w, int h) { - throw new NotImplementedException(); + Bitmap bitmap = new Bitmap(filename); + ITerrainChannel retval = new TerrainChannel(true); + + for (int x = 0; x < retval.Width; x++) + { + for (int y = 0; y < retval.Height; y++) + { + retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128; + } + } + + return retval; } public virtual ITerrainChannel LoadStream(Stream stream) -- cgit v1.1 From 309eb712a32fe14f593941b9f0a5ce41f10bcd7f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Mar 2011 19:34:55 -0700 Subject: Improvement over 2 commits ago: make the hyperlink check understand port 80. --- OpenSim/Services/GridService/HypergridLinker.cs | 33 ++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 585d088..c539047 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -66,6 +66,7 @@ namespace OpenSim.Services.GridService protected bool m_Check4096 = true; protected string m_MapTileDirectory = string.Empty; protected string m_ThisGatekeeper = string.Empty; + protected Uri m_ThisGatekeeperURI = null; // Hyperlink regions are hyperlinks on the map public readonly Dictionary m_HyperlinkRegions = new Dictionary(); @@ -125,6 +126,14 @@ namespace OpenSim.Services.GridService m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles"); m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", string.Empty); + try + { + m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper); + } + catch + { + m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper); + } m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); @@ -249,6 +258,8 @@ namespace OpenSim.Services.GridService remoteRegionName, xloc / Constants.RegionSize, yloc / Constants.RegionSize); reason = string.Empty; + Uri uri = null; + regInfo = new GridRegion(); if ( externalPort > 0) regInfo.HttpPort = externalPort; @@ -259,8 +270,17 @@ namespace OpenSim.Services.GridService else regInfo.ExternalHostName = "0.0.0.0"; if ( serverURI != null) + { regInfo.ServerURI = serverURI; - + try + { + uri = new Uri(serverURI); + regInfo.ExternalHostName = uri.Host; + regInfo.HttpPort = (uint)uri.Port; + } + catch {} + } + if ( remoteRegionName != string.Empty ) regInfo.RegionName = remoteRegionName; @@ -270,11 +290,16 @@ namespace OpenSim.Services.GridService regInfo.EstateOwner = ownerID; // Make sure we're not hyperlinking to regions on this grid! - if (regInfo.ServerURI.Trim(new char[]{'/', ' '}) == m_ThisGatekeeper.Trim(new char[]{'/', ' '})) + if (m_ThisGatekeeperURI != null) { - reason = "Cannot hyperlink to regions on the same grid"; - return false; + if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port) + { + reason = "Cannot hyperlink to regions on the same grid"; + return false; + } } + else + m_log.WarnFormat("[HYPERGRID LINKER]: Please set this grid's Gatekeeper's address in [GridService]!"); // Check for free coordinates GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY); -- cgit v1.1 From fe258753a04706a0f760743b410611bb299b0bc1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 29 Mar 2011 23:07:01 +0100 Subject: disable prim count debug logging temporarily --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 2 +- .../CoreModules/World/Land/PrimCountModule.cs | 68 +++++++++++----------- 2 files changed, 36 insertions(+), 34 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index f50637c..8ebcabb 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4276,7 +4276,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) { - m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name); +// m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name); LandData landData = lo.LandData; diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 2de5c16..d126b26 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -122,10 +122,10 @@ namespace OpenSim.Region.CoreModules.World.Land { if (!m_Tainted) AddObject(obj); - else - m_log.DebugFormat( - "[PRIM COUNT MODULE]: Ignoring OnParcelPrimCountAdd() for {0} on {1} since count is tainted", - obj.Name, m_Scene.RegionInfo.RegionName); +// else +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: Ignoring OnParcelPrimCountAdd() for {0} on {1} since count is tainted", +// obj.Name, m_Scene.RegionInfo.RegionName); } } @@ -137,17 +137,17 @@ namespace OpenSim.Region.CoreModules.World.Land { if (!m_Tainted) RemoveObject(obj); - else - m_log.DebugFormat( - "[PRIM COUNT MODULE]: Ignoring OnObjectBeingRemovedFromScene() for {0} on {1} since count is tainted", - obj.Name, m_Scene.RegionInfo.RegionName); +// else +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: Ignoring OnObjectBeingRemovedFromScene() for {0} on {1} since count is tainted", +// obj.Name, m_Scene.RegionInfo.RegionName); } } private void OnParcelPrimCountTainted() { - m_log.DebugFormat( - "[PRIM COUNT MODULE]: OnParcelPrimCountTainted() called on {0}", m_Scene.RegionInfo.RegionName); +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: OnParcelPrimCountTainted() called on {0}", m_Scene.RegionInfo.RegionName); lock (m_TaintLock) m_Tainted = true; @@ -174,7 +174,7 @@ 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} {1} to prim count", obj.Name, obj.UUID); +// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding object {0} {1} to prim count", obj.Name, obj.UUID); if (obj.IsAttachment) return; @@ -225,13 +225,15 @@ namespace OpenSim.Region.CoreModules.World.Land // NOTE: Call under Taint Lock private void RemoveObject(SceneObjectGroup obj) { - m_log.DebugFormat("[PRIM COUNT MODULE]: Removing object {0} {1} from prim count", obj.Name, obj.UUID); +// m_log.DebugFormat("[PRIM COUNT MODULE]: Removing object {0} {1} from prim count", obj.Name, obj.UUID); + + // Currently this is being done by tainting the count instead. } public IPrimCounts GetPrimCounts(UUID parcelID) { - m_log.DebugFormat( - "[PRIM COUNT MODULE]: GetPrimCounts for parcel {0} in {1}", parcelID, m_Scene.RegionInfo.RegionName); +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: GetPrimCounts for parcel {0} in {1}", parcelID, m_Scene.RegionInfo.RegionName); PrimCounts primCounts; @@ -266,9 +268,9 @@ namespace OpenSim.Region.CoreModules.World.Land count = counts.Owner; } - m_log.DebugFormat( - "[PRIM COUNT MODULE]: GetOwnerCount for parcel {0} in {1} returning {2}", - parcelID, m_Scene.RegionInfo.RegionName, count); +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: GetOwnerCount for parcel {0} in {1} returning {2}", +// parcelID, m_Scene.RegionInfo.RegionName, count); return count; } @@ -292,9 +294,9 @@ namespace OpenSim.Region.CoreModules.World.Land count = counts.Group; } - m_log.DebugFormat( - "[PRIM COUNT MODULE]: GetGroupCount for parcel {0} in {1} returning {2}", - parcelID, m_Scene.RegionInfo.RegionName, count); +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: GetGroupCount for parcel {0} in {1} returning {2}", +// parcelID, m_Scene.RegionInfo.RegionName, count); return count; } @@ -318,9 +320,9 @@ namespace OpenSim.Region.CoreModules.World.Land count = counts.Others; } - m_log.DebugFormat( - "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}", - parcelID, m_Scene.RegionInfo.RegionName, count); +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}", +// parcelID, m_Scene.RegionInfo.RegionName, count); return count; } @@ -349,9 +351,9 @@ namespace OpenSim.Region.CoreModules.World.Land } } - m_log.DebugFormat( - "[PRIM COUNT MODULE]: GetTotalCount for parcel {0} in {1} returning {2}", - parcelID, m_Scene.RegionInfo.RegionName, count); +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: GetTotalCount for parcel {0} in {1} returning {2}", +// parcelID, m_Scene.RegionInfo.RegionName, count); return count; } @@ -379,9 +381,9 @@ namespace OpenSim.Region.CoreModules.World.Land } } - m_log.DebugFormat( - "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}", - parcelID, m_Scene.RegionInfo.RegionName, count); +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}", +// parcelID, m_Scene.RegionInfo.RegionName, count); return count; } @@ -410,9 +412,9 @@ namespace OpenSim.Region.CoreModules.World.Land } } - m_log.DebugFormat( - "[PRIM COUNT MODULE]: GetUserCount for user {0} in parcel {1} in region {2} returning {3}", - userID, parcelID, m_Scene.RegionInfo.RegionName, count); +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: GetUserCount for user {0} in parcel {1} in region {2} returning {3}", +// userID, parcelID, m_Scene.RegionInfo.RegionName, count); return count; } @@ -420,7 +422,7 @@ 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_log.DebugFormat("[PRIM COUNT MODULE]: Recounting prims on {0}", m_Scene.RegionInfo.RegionName); m_OwnerMap.Clear(); m_SimwideCounts.Clear(); -- cgit v1.1 From 8b16f7d976dc60b06f6d08e9d9d853ae69de5fc9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 30 Mar 2011 00:13:07 +0100 Subject: (re)implement selected prim count. This does not currently count objects that are sat upon (which the viewer ui implies should be included in this count) --- OpenSim/Framework/IPrimCounts.cs | 5 +++ .../Region/ClientStack/LindenUDP/LLClientView.cs | 46 +++++++++++----------- .../CoreModules/World/Land/PrimCountModule.cs | 43 ++++++++++++++++++-- .../World/Land/Tests/PrimCountModuleTests.cs | 6 +++ 4 files changed, 74 insertions(+), 26 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/IPrimCounts.cs b/OpenSim/Framework/IPrimCounts.cs index 8ae57fc..3e12348 100644 --- a/OpenSim/Framework/IPrimCounts.cs +++ b/OpenSim/Framework/IPrimCounts.cs @@ -45,6 +45,11 @@ namespace OpenSim.Framework /// Prims owned by others (not parcel owner or parcel group). /// int Others { get; } + + /// + /// Selected prims + /// + int Selected { get; } /// /// Total prims on the parcel. diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 8ebcabb..2faffae 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4343,28 +4343,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP } updateMessage.SnapSelection = snap_selection; - updateMessage.SnapshotID = landData.SnapshotID; - updateMessage.Status = (ParcelStatus) landData.Status; - updateMessage.UserLocation = landData.UserLocation; - updateMessage.UserLookAt = landData.UserLookAt; - - updateMessage.MediaType = landData.MediaType; - updateMessage.MediaDesc = landData.MediaDescription; - updateMessage.MediaWidth = landData.MediaWidth; - updateMessage.MediaHeight = landData.MediaHeight; - updateMessage.MediaLoop = landData.MediaLoop; - updateMessage.ObscureMusic = landData.ObscureMusic; - updateMessage.ObscureMedia = landData.ObscureMedia; + updateMessage.SnapshotID = landData.SnapshotID; + updateMessage.Status = (ParcelStatus) landData.Status; + updateMessage.UserLocation = landData.UserLocation; + updateMessage.UserLookAt = landData.UserLookAt; + + updateMessage.MediaType = landData.MediaType; + updateMessage.MediaDesc = landData.MediaDescription; + updateMessage.MediaWidth = landData.MediaWidth; + updateMessage.MediaHeight = landData.MediaHeight; + updateMessage.MediaLoop = landData.MediaLoop; + updateMessage.ObscureMusic = landData.ObscureMusic; + updateMessage.ObscureMedia = landData.ObscureMedia; IPrimCounts pc = lo.PrimCounts; - updateMessage.OwnerPrims = pc.Owner; - updateMessage.GroupPrims = pc.Group; - updateMessage.OtherPrims = pc.Others; - updateMessage.TotalPrims = pc.Total; - updateMessage.SimWideTotalPrims = pc.Simulator; - - // TODO: Need to transfer selected prims to new prim count structure. - updateMessage.SelectedPrims = landData.SelectedPrims; + updateMessage.OwnerPrims = pc.Owner; + updateMessage.GroupPrims = pc.Group; + updateMessage.OtherPrims = pc.Others; + updateMessage.SelectedPrims = pc.Selected; + updateMessage.TotalPrims = pc.Total; + updateMessage.SimWideTotalPrims = pc.Simulator; try { @@ -4372,13 +4370,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (eq != null) { eq.ParcelProperties(updateMessage, this.AgentId); - } else { - m_log.Warn("No EQ Interface when sending parcel data."); + } + else + { + m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data."); } } catch (Exception ex) { - m_log.Error("Unable to send parcel data via eventqueue - exception: " + ex.ToString()); + m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString()); } } diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index d126b26..ab0e88e 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -45,13 +45,13 @@ namespace OpenSim.Region.CoreModules.World.Land public int Owner = 0; public int Group = 0; public int Others = 0; - public Dictionary Users = - new Dictionary (); + public int Selected = 0; + public Dictionary Users = new Dictionary (); } 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 = @@ -219,6 +219,9 @@ namespace OpenSim.Region.CoreModules.World.Land else parcelCounts.Others += partCount; } + + if (obj.IsSelected) + parcelCounts.Selected += partCount; } } @@ -328,6 +331,32 @@ namespace OpenSim.Region.CoreModules.World.Land } /// + /// Get the number of selected prims. + /// + /// + /// + public int GetSelectedCount(UUID parcelID) + { + int count = 0; + + lock (m_TaintLock) + { + if (m_Tainted) + Recount(); + + ParcelCounts counts; + if (m_ParcelCounts.TryGetValue(parcelID, out counts)) + count = counts.Selected; + } + +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: GetSelectedCount for parcel {0} in {1} returning {2}", +// parcelID, m_Scene.RegionInfo.RegionName, count); + + return count; + } + + /// /// Get the total count of owner, group and others prims on the parcel. /// FIXME: Need to do selected prims once this is reimplemented. /// @@ -491,6 +520,14 @@ namespace OpenSim.Region.CoreModules.World.Land } } + public int Selected + { + get + { + return m_Parent.GetSelectedCount(m_ParcelID); + } + } + public int Total { get diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 58bd841..5a60f22 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -79,6 +79,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Group, Is.EqualTo(0)); Assert.That(pc.Others, Is.EqualTo(0)); Assert.That(pc.Total, Is.EqualTo(0)); + Assert.That(pc.Selected, 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)); @@ -90,6 +91,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Group, Is.EqualTo(0)); Assert.That(pc.Others, Is.EqualTo(0)); Assert.That(pc.Total, Is.EqualTo(3)); + Assert.That(pc.Selected, 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)); @@ -102,6 +104,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Group, Is.EqualTo(0)); Assert.That(pc.Others, Is.EqualTo(0)); Assert.That(pc.Total, Is.EqualTo(5)); + Assert.That(pc.Selected, 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)); @@ -126,6 +129,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Group, Is.EqualTo(0)); Assert.That(pc.Others, Is.EqualTo(0)); Assert.That(pc.Total, Is.EqualTo(6)); + Assert.That(pc.Selected, Is.EqualTo(0)); Assert.That(pc.Users[m_userId], Is.EqualTo(6)); Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); Assert.That(pc.Simulator, Is.EqualTo(6)); @@ -151,6 +155,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Group, Is.EqualTo(0)); Assert.That(pc.Others, Is.EqualTo(0)); Assert.That(pc.Total, Is.EqualTo(1)); + Assert.That(pc.Selected, 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)); @@ -174,6 +179,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Group, Is.EqualTo(0)); Assert.That(pc.Others, Is.EqualTo(0)); Assert.That(pc.Total, Is.EqualTo(3)); + Assert.That(pc.Selected, 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)); -- cgit v1.1 From f7ed7fc05d1c6cc02df43f787590d8b3adeda22b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 30 Mar 2011 00:42:02 +0100 Subject: When a new parcel is created, make sure the prim counts are updated. This is done by tainting the counts where appropriate --- OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index ab0e88e..d1e2328 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -51,7 +51,7 @@ 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 = @@ -63,7 +63,6 @@ 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 @@ -95,6 +94,7 @@ namespace OpenSim.Region.CoreModules.World.Land OnObjectBeingRemovedFromScene; m_Scene.EventManager.OnParcelPrimCountTainted += OnParcelPrimCountTainted; + m_Scene.EventManager.OnLandObjectAdded += delegate(ILandObject lo) { OnParcelPrimCountTainted(); }; } public void RegionLoaded(Scene scene) -- cgit v1.1 From 8022400bd4c852c3faf0db61006a2c60f5200342 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 31 Mar 2011 22:16:09 +0100 Subject: Remove unused Datastore parameter from RegionInfo (legacy from early 2008) --- OpenSim/Framework/RegionInfo.cs | 11 ----------- OpenSim/Region/Framework/Scenes/Scene.cs | 1 - OpenSim/Region/Framework/Scenes/SceneBase.cs | 2 -- 3 files changed, 14 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 680e702..afedcf5 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -347,7 +347,6 @@ namespace OpenSim.Framework public bool commFailTF = false; public ConfigurationMember configMember; - public string DataStore = String.Empty; public string RegionFile = String.Empty; public bool isSandbox = false; public bool Persistent = true; @@ -746,10 +745,6 @@ namespace OpenSim.Framework m_regionLocX = Convert.ToUInt32(locationElements[0]); m_regionLocY = Convert.ToUInt32(locationElements[1]); - - // Datastore (is this implemented? Omitted from example!) - DataStore = config.GetString("Datastore", String.Empty); - // Internal IP IPAddress address; @@ -846,9 +841,6 @@ namespace OpenSim.Framework string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY); config.Set("Location", location); - if (DataStore != String.Empty) - config.Set("Datastore", DataStore); - config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); config.Set("InternalPort", m_internalEndPoint.Port); @@ -1025,9 +1017,6 @@ namespace OpenSim.Framework case "sim_location_y": m_regionLocY = (uint) configuration_result; break; - case "datastore": - DataStore = (string) configuration_result; - break; case "internal_ip_address": IPAddress address = (IPAddress) configuration_result; m_internalEndPoint = new IPEndPoint(address, 0); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d407a6f..353b7c2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -563,7 +563,6 @@ namespace OpenSim.Region.Framework.Scenes m_regInfo = regInfo; m_regionHandle = m_regInfo.RegionHandle; m_regionName = m_regInfo.RegionName; - m_datastore = m_regInfo.DataStore; m_lastUpdate = Util.EnvironmentTickCount(); m_physicalPrim = physicalPrim; 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 get { return m_permissions; } } - protected string m_datastore; - /* Used by the loadbalancer plugin on GForge */ protected RegionStatus m_regStatus; public RegionStatus RegionStatus -- cgit v1.1 From 7bba31e8d943f03e2ea54317703e1bd9e243b70b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 31 Mar 2011 22:20:12 +0100 Subject: remove some mono compiler warnings --- OpenSim/Data/MSSQL/MSSQLAvatarData.cs | 2 +- OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs | 4 ++-- OpenSim/Data/MSSQL/MSSQLGridUserData.cs | 2 +- OpenSim/Data/MSSQL/MSSQLManager.cs | 4 +--- OpenSim/Data/MSSQL/MSSQLPresenceData.cs | 2 +- OpenSim/Data/MSSQL/MSSQLXInventoryData.cs | 4 ++-- 6 files changed, 8 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MSSQL/MSSQLAvatarData.cs b/OpenSim/Data/MSSQL/MSSQLAvatarData.cs index 49a6b09..301b424 100644 --- a/OpenSim/Data/MSSQL/MSSQLAvatarData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAvatarData.cs @@ -43,7 +43,7 @@ namespace OpenSim.Data.MSSQL public class MSSQLAvatarData : MSSQLGenericTableHandler, IAvatarData { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public MSSQLAvatarData(string connectionString, string realm) : base(connectionString, realm, "Avatar") diff --git a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs index 904366e..6a5d6eb 100644 --- a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs +++ b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs @@ -40,8 +40,8 @@ namespace OpenSim.Data.MSSQL { public class MSSQLGenericTableHandler where T : class, new() { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected string m_ConnectionString; protected MSSQLManager m_database; //used for parameter type translation diff --git a/OpenSim/Data/MSSQL/MSSQLGridUserData.cs b/OpenSim/Data/MSSQL/MSSQLGridUserData.cs index 1870273..9e215f9 100644 --- a/OpenSim/Data/MSSQL/MSSQLGridUserData.cs +++ b/OpenSim/Data/MSSQL/MSSQLGridUserData.cs @@ -43,7 +43,7 @@ namespace OpenSim.Data.MSSQL public class MSSQLGridUserData : MSSQLGenericTableHandler, IGridUserData { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public MSSQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") diff --git a/OpenSim/Data/MSSQL/MSSQLManager.cs b/OpenSim/Data/MSSQL/MSSQLManager.cs index 575fd21..cf963e3 100644 --- a/OpenSim/Data/MSSQL/MSSQLManager.cs +++ b/OpenSim/Data/MSSQL/MSSQLManager.cs @@ -41,7 +41,7 @@ namespace OpenSim.Data.MSSQL /// public class MSSQLManager { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// Connection string for ADO.net @@ -180,8 +180,6 @@ namespace OpenSim.Data.MSSQL return parameter; } - private static readonly Dictionary emptyDictionary = new Dictionary(); - /// /// Checks if we need to do some migrations to the database /// diff --git a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs b/OpenSim/Data/MSSQL/MSSQLPresenceData.cs index e7b3d9c..8068d23 100644 --- a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs +++ b/OpenSim/Data/MSSQL/MSSQLPresenceData.cs @@ -43,7 +43,7 @@ namespace OpenSim.Data.MSSQL public class MSSQLPresenceData : MSSQLGenericTableHandler, IPresenceData { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public MSSQLPresenceData(string connectionString, string realm) : base(connectionString, realm, "Presence") diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs index 739eb55..5bc4fe4 100644 --- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs @@ -40,8 +40,8 @@ namespace OpenSim.Data.MSSQL { public class MSSQLXInventoryData : IXInventoryData { - private static readonly ILog m_log = LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); private MSSQLGenericTableHandler m_Folders; private MSSQLItemHandler m_Items; -- cgit v1.1 From efd0c003a3baf3c8d1abd1bab422ae5bb015ab87 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 31 Mar 2011 22:47:18 +0100 Subject: Put in temporary logging message to find out if scene objects are requesting land objects for co-ordinates outside the region --- OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 52e3718..fac2574 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -762,13 +762,14 @@ namespace OpenSim.Region.CoreModules.World.Land { try { - //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4])) - return m_landList[m_landIDList[x / 4, y / 4]]; - //else - // return null; + return m_landList[m_landIDList[x / 4, y / 4]]; } catch (IndexOutOfRangeException) { + m_log.WarnFormat( + "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}", + x, y, m_scene.RegionInfo.RegionName); + return null; } } -- cgit v1.1 From 88bd38690a56f5e381f8038b971950c9f5842c51 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 31 Mar 2011 23:03:42 +0100 Subject: Remove unused RegionInfo.getInternalEndPointPort() in favour of RegionInfo.InternalEndPoint.Port --- OpenSim/Framework/RegionInfo.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index afedcf5..daf0a25 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -1164,11 +1164,6 @@ namespace OpenSim.Framework return regionInfo; } - public int getInternalEndPointPort() - { - return m_internalEndPoint.Port; - } - public Dictionary ToKeyValuePairs() { Dictionary kvp = new Dictionary(); @@ -1187,4 +1182,4 @@ namespace OpenSim.Framework return kvp; } } -} +} \ No newline at end of file -- cgit v1.1 From 6ae76ede98c3fa7731daf7149a8831f474770fee Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 31 Mar 2011 23:09:06 +0100 Subject: suspend check that IAR control file is loaded for now I was mistaken - some previous opensim versions don't save this file first. Will have to bump iar version number and only check iars after the bump --- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim') 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 /// private Stream m_loadStream; - protected bool m_controlFileLoaded; + /// + /// FIXME: Do not perform this check since older versions of OpenSim do save the control file after other things + /// (I thought they weren't). We will need to bump the version number and perform this check on all + /// subsequent IAR versions only + /// + protected bool m_controlFileLoaded = true; protected bool m_assetsLoaded; protected bool m_inventoryNodesLoaded; -- cgit v1.1 From 4d0cffa06e1c4071d137834e1d5c2cd06c933441 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 31 Mar 2011 23:56:26 +0100 Subject: If the prim count gets an object with invalid bounds, don't try to count it. This appears to be the more probable explanation for some failures seen. Either we're counting attachments which are temporarily out of bounds (shouldn't be due to the IsAttachment) check or we're counting scene objects which have out of bounds co-ordinates (seems more likely) --- OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 6 +++--- OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index fac2574..2b5f7a0 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -766,9 +766,9 @@ namespace OpenSim.Region.CoreModules.World.Land } catch (IndexOutOfRangeException) { - m_log.WarnFormat( - "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}", - x, y, m_scene.RegionInfo.RegionName); +// m_log.WarnFormat( +// "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}", +// x, y, m_scene.RegionInfo.RegionName); return null; } diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index d1e2328..f07ae31 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -183,6 +183,11 @@ namespace OpenSim.Region.CoreModules.World.Land Vector3 pos = obj.AbsolutePosition; ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); + + // If for some reason there is no land object (perhaps the object is out of bounds) then we can't count it + if (landObject == null) + return; + LandData landData = landObject.LandData; // m_log.DebugFormat( -- cgit v1.1 From 39c610c16554de05dae975cb9258881dce1d17ed Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 1 Apr 2011 00:41:52 +0100 Subject: Log which address and port the UDP listener is configured for. This will match that given for InternalAddress in the config (e.g. 0.0.0.0) Can't obtain actually bound address until the UDP socket is used for the first time. --- OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim') 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 const int SIO_UDP_CONNRESET = -1744830452; IPEndPoint ipep = new IPEndPoint(m_localBindAddress, m_udpPort); + + m_log.DebugFormat( + "[UDPBASE]: Binding UDP listener using internal IP address config {0}:{1}", + ipep.Address, ipep.Port); m_udpSocket = new Socket( AddressFamily.InterNetwork, -- cgit v1.1 From e1ceb461c0e37cfe56fdfeb91a9ac4b4aa54b931 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 1 Apr 2011 00:51:10 +0100 Subject: Make default answer for 'do you wish to join region to an existing estate' yes instead of no. --- OpenSim/Region/Application/OpenSimBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 6405811..f98d702 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -860,7 +860,7 @@ namespace OpenSim = MainConsole.Instance.CmdPrompt( string.Format( "Do you wish to join region {0} to an existing estate (yes/no)?", regInfo.RegionName), - "no", + "yes", new List() { "yes", "no" }); if (response == "no") -- cgit v1.1 From 8f4bf435344af76d7ff6436ec74eab92399c3a99 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 1 Apr 2011 00:55:05 +0100 Subject: When asked to join region to existing estate, make first estate name the default instead of None --- OpenSim/Region/Application/OpenSimBase.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index f98d702..ea9edf6 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -876,15 +876,12 @@ namespace OpenSim = MainConsole.Instance.CmdPrompt( string.Format( "Name of estate to join. Existing estate names are ({0})", string.Join(", ", estateNames.ToArray())), - "None"); - - if (response == "None") - continue; + estateNames[0]); 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 8c8a0a182e28f3486ce89fc0570b56fe53f69934 Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 31 Mar 2011 21:14:53 -0700 Subject: implement LSL "print()" API function --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 8 +++++++- OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 1 + OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 72ee495..e3e16bd 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 /// public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected IScriptEngine m_ScriptEngine; protected SceneObjectPart m_host; protected uint m_localID; @@ -10278,6 +10278,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return GetLinkPrimitiveParams(obj, rules); } + + public void print(string str) + { + // yes, this is a real LSL function. See: http://wiki.secondlife.com/wiki/Print + m_log.Info("LSL print():" + str); + } } public class NotecardCache diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 561e3b3..bd6a094 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -398,6 +398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Vector llWind(LSL_Vector offset); LSL_String llXorBase64Strings(string str1, string str2); LSL_String llXorBase64StringsCorrect(string str1, string str2); + void print(string str); void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 451163f..3b29861 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -1847,5 +1847,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_LSL_Functions.llClearPrimMedia(face); } + + public void print(string str) + { + m_LSL_Functions.print(str); + } } } -- cgit v1.1 From e974fde95313e17c239e4e35487da897f725a904 Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 31 Mar 2011 22:56:04 -0700 Subject: check threat configuration for LSL print() --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index e3e16bd..43b0da3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10282,7 +10282,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void print(string str) { // yes, this is a real LSL function. See: http://wiki.secondlife.com/wiki/Print - m_log.Info("LSL print():" + str); + IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_itemID, "OSSL"); + if (ossl != null) + { + ossl.CheckThreatLevel(ThreatLevel.High, "print"); + m_log.Info("LSL print():" + str); + } } } -- cgit v1.1 From 3a113f9902b859d11c200f9b0db06c2317eb53cc Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 1 Apr 2011 22:04:29 +0100 Subject: A stab at making CHANGED_OWNER work --- .../InventoryAccess/InventoryAccessModule.cs | 24 +++++++--------------- .../Framework/Scenes/SceneObjectPartInventory.cs | 10 ++++----- 2 files changed, 12 insertions(+), 22 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 798547a..8d0c35a 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -668,28 +668,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) part.GroupMask = item.GroupPermissions; } + + foreach (SceneObjectPart part in group.Parts) + { + part.LastOwnerID = part.OwnerID; + part.OwnerID = item.Owner; + part.Inventory.ChangeInventoryOwner(item.Owner); + } group.ApplyNextOwnerPermissions(); } } - foreach (SceneObjectPart part in group.Parts) - { - if ((part.OwnerID != item.Owner) || (item.CurrentPermissions & 16) != 0) - { - part.LastOwnerID = part.OwnerID; - part.OwnerID = item.Owner; - part.Inventory.ChangeInventoryOwner(item.Owner); - part.GroupMask = 0; // DO NOT propagate here - } - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) - part.EveryoneMask = item.EveryOnePermissions; - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) - part.NextOwnerMask = item.NextPermissions; - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) - part.GroupMask = item.GroupPermissions; - } - rootPart.TrimPermissions(); if (!attachment) 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 foreach (TaskInventoryItem item in items) { if (ownerId != item.OwnerID) - { item.LastOwnerID = item.OwnerID; - item.OwnerID = ownerId; - item.PermsMask = 0; - item.PermsGranter = UUID.Zero; - } + + item.OwnerID = ownerId; + item.PermsMask = 0; + item.PermsGranter = UUID.Zero; + item.OwnerChanged = true; } } -- cgit v1.1 From 5b0936d4b52a972af4f9efa2e69c938e334ad3c7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Apr 2011 01:07:52 +0100 Subject: If the land has no group ownership (it is UUID.Zero) then don't put prims in the group count when they are also not group owned. Also adds simple test for others owned count when an object is added --- .../CoreModules/World/Land/PrimCountModule.cs | 4 ++-- .../World/Land/Tests/PrimCountModuleTests.cs | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index f07ae31..992cd72 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.World.Land { if (obj.OwnerID == landData.GroupID) parcelCounts.Owner += partCount; - else if (obj.GroupID == landData.GroupID) + else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID) parcelCounts.Group += partCount; else parcelCounts.Others += partCount; @@ -219,7 +219,7 @@ namespace OpenSim.Region.CoreModules.World.Land { if (obj.OwnerID == landData.OwnerID) parcelCounts.Owner += partCount; - else if (obj.GroupID == landData.GroupID) + else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID) parcelCounts.Group += partCount; else parcelCounts.Others += partCount; diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 5a60f22..521effc 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -161,6 +161,27 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Simulator, Is.EqualTo(1)); } + [Test] + public void TestAddOthersObject() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + IPrimCounts pc = m_lo.PrimCounts; + + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_dummyUserId, 0x01); + m_scene.AddNewSceneObject(sog, false); + + Assert.That(pc.Owner, Is.EqualTo(0)); + Assert.That(pc.Group, Is.EqualTo(0)); + Assert.That(pc.Others, Is.EqualTo(3)); + Assert.That(pc.Total, Is.EqualTo(3)); + Assert.That(pc.Selected, Is.EqualTo(0)); + Assert.That(pc.Users[m_userId], Is.EqualTo(0)); + Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(3)); + Assert.That(pc.Simulator, Is.EqualTo(3)); + } + /// /// Test the count is correct after is has been tainted. /// -- cgit v1.1 From 2c86f6ba7ddcf4816618db5b19a8ca111a8425b5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Apr 2011 01:13:10 +0100 Subject: refactor: rename m_dummyUserId to m_otherUserId --- .../World/Land/Tests/PrimCountModuleTests.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 521effc..49ad705 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests 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 UUID m_otherUserId = new UUID("99999999-9999-9999-9999-999999999999"); protected TestScene m_scene; protected PrimCountModule m_pcm; protected ILandObject m_lo; @@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Total, Is.EqualTo(0)); Assert.That(pc.Selected, Is.EqualTo(0)); Assert.That(pc.Users[m_userId], Is.EqualTo(0)); - Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); + Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); Assert.That(pc.Simulator, Is.EqualTo(0)); SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); @@ -93,7 +93,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Total, Is.EqualTo(3)); Assert.That(pc.Selected, Is.EqualTo(0)); Assert.That(pc.Users[m_userId], Is.EqualTo(3)); - Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); + Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); Assert.That(pc.Simulator, Is.EqualTo(3)); // Add a second object and retest @@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Total, Is.EqualTo(5)); Assert.That(pc.Selected, Is.EqualTo(0)); Assert.That(pc.Users[m_userId], Is.EqualTo(5)); - Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); + Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); Assert.That(pc.Simulator, Is.EqualTo(5)); } @@ -131,7 +131,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Total, Is.EqualTo(6)); Assert.That(pc.Selected, Is.EqualTo(0)); Assert.That(pc.Users[m_userId], Is.EqualTo(6)); - Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); + Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); Assert.That(pc.Simulator, Is.EqualTo(6)); } @@ -157,7 +157,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Total, Is.EqualTo(1)); Assert.That(pc.Selected, Is.EqualTo(0)); Assert.That(pc.Users[m_userId], Is.EqualTo(1)); - Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); + Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); Assert.That(pc.Simulator, Is.EqualTo(1)); } @@ -169,7 +169,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_dummyUserId, 0x01); + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, 0x01); m_scene.AddNewSceneObject(sog, false); Assert.That(pc.Owner, Is.EqualTo(0)); @@ -178,7 +178,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Total, Is.EqualTo(3)); Assert.That(pc.Selected, Is.EqualTo(0)); Assert.That(pc.Users[m_userId], Is.EqualTo(0)); - Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(3)); + Assert.That(pc.Users[m_otherUserId], Is.EqualTo(3)); Assert.That(pc.Simulator, Is.EqualTo(3)); } @@ -202,7 +202,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Total, Is.EqualTo(3)); Assert.That(pc.Selected, Is.EqualTo(0)); Assert.That(pc.Users[m_userId], Is.EqualTo(3)); - Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); + Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); Assert.That(pc.Simulator, Is.EqualTo(3)); } } -- cgit v1.1 From c13502a5cf938e898ef27f471ac27f0707698543 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Apr 2011 01:15:17 +0100 Subject: add remove others object prim count test --- .../World/Land/Tests/PrimCountModuleTests.cs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 49ad705..b9eef79 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -182,6 +182,29 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Simulator, Is.EqualTo(3)); } + [Test] + public void TestRemoveOthersObject() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + IPrimCounts pc = m_lo.PrimCounts; + + m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_otherUserId, 0x1), false); + SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, 0x10); + m_scene.AddNewSceneObject(sogToDelete, false); + m_scene.DeleteSceneObject(sogToDelete, false); + + Assert.That(pc.Owner, Is.EqualTo(0)); + Assert.That(pc.Group, Is.EqualTo(0)); + Assert.That(pc.Others, Is.EqualTo(1)); + Assert.That(pc.Total, Is.EqualTo(1)); + Assert.That(pc.Selected, Is.EqualTo(0)); + Assert.That(pc.Users[m_userId], Is.EqualTo(0)); + Assert.That(pc.Users[m_otherUserId], Is.EqualTo(1)); + Assert.That(pc.Simulator, Is.EqualTo(1)); + } + /// /// Test the count is correct after is has been tainted. /// -- cgit v1.1 From 01b399055b06b69848ffcdeb3cafec83cbeb06d2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Apr 2011 01:37:46 +0100 Subject: add test for adding group object, factor out initial zero counts test --- .../World/Land/Tests/PrimCountModuleTests.cs | 52 +++++++++++++++++++--- 1 file changed, 45 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index b9eef79..38b2356 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -45,6 +45,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests public class PrimCountModuleTests { protected UUID m_userId = new UUID("00000000-0000-0000-0000-100000000000"); + protected UUID m_groupId = new UUID("00000000-0000-0000-8888-000000000000"); protected UUID m_otherUserId = new UUID("99999999-9999-9999-9999-999999999999"); protected TestScene m_scene; protected PrimCountModule m_pcm; @@ -65,14 +66,11 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests } /// - /// Test count after a parcel owner owned object is added. + /// Test that counts before we do anything are correct. /// [Test] - public void TestAddOwnerObject() + public void TestInitialCounts() { - TestHelper.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - IPrimCounts pc = m_lo.PrimCounts; Assert.That(pc.Owner, Is.EqualTo(0)); @@ -82,7 +80,19 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Selected, Is.EqualTo(0)); Assert.That(pc.Users[m_userId], Is.EqualTo(0)); Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); - Assert.That(pc.Simulator, Is.EqualTo(0)); + Assert.That(pc.Simulator, Is.EqualTo(0)); + } + + /// + /// Test count after a parcel owner owned object is added. + /// + [Test] + public void TestAddOwnerObject() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + IPrimCounts pc = m_lo.PrimCounts; SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); m_scene.AddNewSceneObject(sog, false); @@ -159,7 +169,35 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Users[m_userId], Is.EqualTo(1)); Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); Assert.That(pc.Simulator, Is.EqualTo(1)); - } + } + + [Test] + public void TestAddGroupObject() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + m_lo.DeedToGroup(m_groupId); + + IPrimCounts pc = m_lo.PrimCounts; + + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, 0x01); + sog.GroupID = m_groupId; + m_scene.AddNewSceneObject(sog, false); + + Assert.That(pc.Owner, Is.EqualTo(0)); + Assert.That(pc.Group, Is.EqualTo(3)); + Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Total, Is.EqualTo(3)); + Assert.That(pc.Selected, Is.EqualTo(0)); + + // Is this desired behaviour? Not totally sure. + Assert.That(pc.Users[m_userId], Is.EqualTo(0)); + Assert.That(pc.Users[m_groupId], Is.EqualTo(0)); + Assert.That(pc.Users[m_otherUserId], Is.EqualTo(3)); + + Assert.That(pc.Simulator, Is.EqualTo(3)); + } [Test] public void TestAddOthersObject() -- cgit v1.1 From 8e668abc6db47eb21d6eb294cf696d6bc10d51a6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Apr 2011 01:46:06 +0100 Subject: add test for removing group owned objects --- .../World/Land/Tests/PrimCountModuleTests.cs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 38b2356..f006db2 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -199,6 +199,38 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Simulator, Is.EqualTo(3)); } + /// + /// Test count after a parcel owner owned object is removed. + /// + [Test] + public void TestRemoveGroupObject() + { + TestHelper.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + m_lo.DeedToGroup(m_groupId); + + IPrimCounts pc = m_lo.PrimCounts; + + SceneObjectGroup sogToKeep = SceneSetupHelpers.CreateSceneObject(1, m_userId, 0x1); + sogToKeep.GroupID = m_groupId; + m_scene.AddNewSceneObject(sogToKeep, false); + + SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x10); + m_scene.AddNewSceneObject(sogToDelete, false); + m_scene.DeleteSceneObject(sogToDelete, false); + + Assert.That(pc.Owner, Is.EqualTo(0)); + Assert.That(pc.Group, Is.EqualTo(1)); + Assert.That(pc.Others, Is.EqualTo(0)); + Assert.That(pc.Total, Is.EqualTo(1)); + Assert.That(pc.Selected, Is.EqualTo(0)); + Assert.That(pc.Users[m_userId], Is.EqualTo(1)); + Assert.That(pc.Users[m_groupId], Is.EqualTo(0)); + Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); + Assert.That(pc.Simulator, Is.EqualTo(1)); + } + [Test] public void TestAddOthersObject() { -- cgit v1.1 From 7bba0177fea621fa7116df8dfc1680dc9045fbd3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Apr 2011 01:53:47 +0100 Subject: If land is not group owned (group ID is always UUID.Zero) then don't check if a prim should be added to the group count --- OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 992cd72..bc140ae 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -219,8 +219,6 @@ namespace OpenSim.Region.CoreModules.World.Land { if (obj.OwnerID == landData.OwnerID) parcelCounts.Owner += partCount; - else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID) - parcelCounts.Group += partCount; else parcelCounts.Others += partCount; } -- cgit v1.1 From 4f56c732bc00588cd8ced1be85bc4d13815f86bd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Apr 2011 02:29:42 +0100 Subject: Comment out some startup logging lines to make up for the one I added earlier on. Most of these are where the region modules are telling us they are disabled. Convention is only to log when enabled (even that is really noisy) --- OpenSim/Region/Application/OpenSim.cs | 2 +- .../Region/CoreModules/Scripting/EMailModules/EmailModule.cs | 2 -- .../Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs | 9 ++------- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 6 ------ .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 8 -------- .../Avatar/XmlRpcGroups/GroupsMessagingModule.cs | 3 --- .../Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 10 +--------- 7 files changed, 4 insertions(+), 36 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 4081888..ec1fb04 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -123,7 +123,7 @@ namespace OpenSim m_log.Info("===================================================================="); m_log.Info("========================= STARTING OPENSIM ========================="); m_log.Info("===================================================================="); - m_log.InfoFormat("[OPENSIM MAIN]: Running "); + //m_log.InfoFormat("[OPENSIM MAIN]: GC Is Server GC: {0}", GCSettings.IsServerGC.ToString()); // http://msdn.microsoft.com/en-us/library/bb384202.aspx //GCSettings.LatencyMode = GCLatencyMode.Batch; 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 { if ((SMTPConfig = m_Config.Configs["SMTP"]) == null) { - m_log.InfoFormat("[SMTP] SMTP server not configured"); m_Enabled = false; return; } if (!SMTPConfig.GetBoolean("enabled", false)) { - m_log.InfoFormat("[SMTP] module disabled in configuration"); m_Enabled = false; return; } 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 m_config = config.Configs["Concierge"]; if (null == m_config) - { - m_log.Info("[Concierge]: no config found, plugin disabled"); return; - } if (!m_config.GetBoolean("enabled", false)) - { - m_log.Info("[Concierge]: plugin disabled by configuration"); return; - } + m_enabled = true; @@ -113,9 +108,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge { m_replacingChatModule = false; } + m_log.InfoFormat("[Concierge] {0} ChatModule", m_replacingChatModule ? "replacing" : "not replacing"); - // take note of concierge channel and of identity m_conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", m_conciergeChannel); 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 m_Config = config.Configs["FreeSwitchVoice"]; if (m_Config == null) - { - m_log.Info("[FreeSwitchVoice] no config found, plugin disabled"); return; - } if (!m_Config.GetBoolean("Enabled", false)) - { - m_log.Info("[FreeSwitchVoice] plugin disabled by configuration"); return; - } try { 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 m_config = config.Configs["VivoxVoice"]; if (null == m_config) - { - m_log.Info("[VivoxVoice] no config found, plugin disabled"); return; - } if (!m_config.GetBoolean("enabled", false)) - { - m_log.Info("[VivoxVoice] plugin disabled by configuration"); return; - } try { @@ -218,7 +212,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice m_pluginEnabled = true; m_log.Info("[VivoxVoice] plugin enabled"); - } catch (Exception e) { @@ -228,7 +221,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice } } - // Called to indicate that the module has been added to the region public void AddRegion(Scene scene) { 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 return; } - m_log.Info("[GROUPS-MESSAGING]: Initializing GroupsMessagingModule"); - m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); } m_log.Info("[GROUPS-MESSAGING]: GroupsMessagingModule starting up"); - } public void AddRegion(Scene scene) 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 if (source.Configs["MRM"].GetBoolean("Enabled", false)) { - m_log.Info("[MRM] Enabling MRM Module"); + m_log.Info("[MRM]: Enabling MRM Module"); m_scene = scene; // when hidden, we don't listen for client initiated script events @@ -90,14 +90,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule scene.RegisterModuleInterface(this); } - else - { - m_log.Info("[MRM] Disabled MRM Module (Disabled in ini)"); - } - } - else - { - m_log.Info("[MRM] Disabled MRM Module (Default disabled)"); } } -- cgit v1.1 From e8e940e33e458622ef3c1f6fbd206fcf13b2f700 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 3 Apr 2011 13:50:19 +0200 Subject: Make CHANGED_OWNER work for deeding and god-mode in-world change --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index fcbcf59..73dd531 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2069,7 +2069,10 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart[] partList = sog.Parts; foreach (SceneObjectPart child in partList) + { child.Inventory.ChangeInventoryOwner(ownerID); + child.TriggerScriptChangedEvent(Changed.OWNER); + } } else { @@ -2085,6 +2088,7 @@ namespace OpenSim.Region.Framework.Scenes { child.LastOwnerID = child.OwnerID; child.Inventory.ChangeInventoryOwner(groupID); + child.TriggerScriptChangedEvent(Changed.OWNER); } sog.SetOwnerId(groupID); -- cgit v1.1 From b385d4aa036ad7bf58d033a9923452535c82ef69 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Oct 2010 01:13:17 +0200 Subject: Implement taking of coalesced objects. WARNING!!!!! You can TAKE them, but you can't REZ them again. Only the first of the contained objects will rez, the rest is inaccessible until rezzing them is implemented. Also, rotations are not explicitly stored. This MAY work. Or not. --- .../InventoryAccess/InventoryAccessModule.cs | 459 ++++++++++++--------- .../Scenes/AsyncSceneObjectGroupDeleter.cs | 4 +- OpenSim/Region/Framework/Scenes/Scene.cs | 9 + 3 files changed, 274 insertions(+), 198 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 8d0c35a..88dff02 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.Net; +using System.Xml; using System.Reflection; using System.Threading; @@ -205,11 +206,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, List objectGroups, IClientAPI remoteClient) { - // HACK: This is only working for lists containing a single item! - // It's just a hack to make this WIP compile and run. Nothing - // currently calls this with multiple items. UUID ret = UUID.Zero; + // The following code groups the SOG's by owner. No objects + // belonging to different people can be coalesced, for obvious + // reasons. Dictionary> deletes = new Dictionary>(); @@ -221,262 +222,328 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess deletes[g.OwnerID].Add(g); } + // This is pethod scoped and will be returned. It will be the + // last created asset id + UUID assetID = UUID.Zero; + + // Each iteration is really a separate asset being created, + // with distinct destinations as well. foreach (List objlist in deletes.Values) { - foreach (SceneObjectGroup g in objlist) - ret = DeleteToInventory(action, folderID, g, remoteClient); - } - - return ret; - } + Dictionary xmlStrings = + new Dictionary(); - private UUID DeleteToInventory(DeRezAction action, UUID folderID, - SceneObjectGroup objectGroup, IClientAPI remoteClient) - { - UUID assetID = UUID.Zero; + foreach (SceneObjectGroup objectGroup in objlist) + { + Vector3 inventoryStoredPosition = new Vector3 + (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) + ? 250 + : objectGroup.AbsolutePosition.X) + , + (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) + ? 250 + : objectGroup.AbsolutePosition.X, + objectGroup.AbsolutePosition.Z); - Vector3 inventoryStoredPosition = new Vector3 - (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) - ? 250 - : objectGroup.AbsolutePosition.X) - , - (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) - ? 250 - : objectGroup.AbsolutePosition.X, - objectGroup.AbsolutePosition.Z); + Vector3 originalPosition = objectGroup.AbsolutePosition; - Vector3 originalPosition = objectGroup.AbsolutePosition; + // Restore attachment data after trip through the sim + if (objectGroup.RootPart.AttachPoint > 0) + inventoryStoredPosition = objectGroup.RootPart.AttachOffset; + objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint; - objectGroup.AbsolutePosition = inventoryStoredPosition; + objectGroup.AbsolutePosition = inventoryStoredPosition; - string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); + // Make sure all bits but the ones we want are clear + // on take. + // This will be applied to the current perms, so + // it will do what we want. + objectGroup.RootPart.NextOwnerMask &= + ((uint)PermissionMask.Copy | + (uint)PermissionMask.Transfer | + (uint)PermissionMask.Modify); + objectGroup.RootPart.NextOwnerMask |= + (uint)PermissionMask.Move; - objectGroup.AbsolutePosition = originalPosition; + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); - // Get the user info of the item destination - // - UUID userID = UUID.Zero; + objectGroup.AbsolutePosition = originalPosition; - if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || - action == DeRezAction.SaveToExistingUserInventoryItem) - { - // Take or take copy require a taker - // Saving changes requires a local user - // - if (remoteClient == null) - return UUID.Zero; + xmlStrings[objectGroup.UUID] = sceneObjectXml; + } - userID = remoteClient.AgentId; - } - else - { - // All returns / deletes go to the object owner - // + string itemXml; - userID = objectGroup.RootPart.OwnerID; - } + if (objlist.Count > 1) + { + float minX, minY, minZ; + float maxX, maxY, maxZ; - if (userID == UUID.Zero) // Can't proceed - { - return UUID.Zero; - } + Vector3[] offsets = m_Scene.GetCombinedBoundingBox(objlist, + out minX, out maxX, out minY, out maxY, + out minZ, out maxZ); - // If we're returning someone's item, it goes back to the - // owner's Lost And Found folder. - // Delete is treated like return in this case - // Deleting your own items makes them go to trash - // + // CreateWrapper + XmlDocument itemDoc = new XmlDocument(); + XmlElement root = itemDoc.CreateElement("", "CoalescedObject", ""); + itemDoc.AppendChild(root); - InventoryFolderBase folder = null; - InventoryItemBase item = null; + // Embed the offsets into the group XML + for ( int i = 0 ; i < objlist.Count ; i++ ) + { + XmlDocument doc = new XmlDocument(); + SceneObjectGroup g = objlist[i]; + doc.LoadXml(xmlStrings[g.UUID]); + XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup"); + e.SetAttribute("offsetx", offsets[i].X.ToString()); + e.SetAttribute("offsety", offsets[i].Y.ToString()); + e.SetAttribute("offsetz", offsets[i].Z.ToString()); + + XmlNode objectNode = itemDoc.ImportNode(e, true); + root.AppendChild(objectNode); + } - if (DeRezAction.SaveToExistingUserInventoryItem == action) - { - item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); - item = m_Scene.InventoryService.GetItem(item); + float sizeX = maxX - minX; + float sizeY = maxY - minY; + float sizeZ = maxZ - minZ; - //item = userInfo.RootFolder.FindItem( - // objectGroup.RootPart.FromUserInventoryItemID); + root.SetAttribute("x", sizeX.ToString()); + root.SetAttribute("y", sizeY.ToString()); + root.SetAttribute("z", sizeZ.ToString()); - if (null == item) + itemXml = itemDoc.InnerXml; + } + else { - m_log.DebugFormat( - "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", - objectGroup.Name, objectGroup.UUID); - return UUID.Zero; + itemXml = xmlStrings[objlist[0].UUID]; } - } - else - { - // Folder magic + + // Get the user info of the item destination // - if (action == DeRezAction.Delete) + UUID userID = UUID.Zero; + + if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || + action == DeRezAction.SaveToExistingUserInventoryItem) { - // Deleting someone else's item + // Take or take copy require a taker + // Saving changes requires a local user // - if (remoteClient == null || - objectGroup.OwnerID != remoteClient.AgentId) - { + if (remoteClient == null) + return UUID.Zero; - folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); - } - else - { - folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); - } + userID = remoteClient.AgentId; } - else if (action == DeRezAction.Return) + else { - - // Dump to lost + found unconditionally + // All returns / deletes go to the object owner // - folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); + + userID = objlist[0].RootPart.OwnerID; } - if (folderID == UUID.Zero && folder == null) + if (userID == UUID.Zero) // Can't proceed { - if (action == DeRezAction.Delete) + return UUID.Zero; + } + + // If we're returning someone's item, it goes back to the + // owner's Lost And Found folder. + // Delete is treated like return in this case + // Deleting your own items makes them go to trash + // + + InventoryFolderBase folder = null; + InventoryItemBase item = null; + + if (DeRezAction.SaveToExistingUserInventoryItem == action) + { + item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID); + item = m_Scene.InventoryService.GetItem(item); + + //item = userInfo.RootFolder.FindItem( + // objectGroup.RootPart.FromUserInventoryItemID); + + if (null == item) { - // Deletes go to trash by default - // - folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); + m_log.DebugFormat( + "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", + objlist[0].Name, objlist[0].UUID); + return UUID.Zero; } - else + } + else + { + // Folder magic + // + if (action == DeRezAction.Delete) { + // Deleting someone else's item + // if (remoteClient == null || - objectGroup.OwnerID != remoteClient.AgentId) + objlist[0].OwnerID != remoteClient.AgentId) { - // Taking copy of another person's item. Take to - // Objects folder. - folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object); + + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); } else { - // Catch all. Use lost & found + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); + } + } + else if (action == DeRezAction.Return) + { + + // Dump to lost + found unconditionally + // + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); + } + + if (folderID == UUID.Zero && folder == null) + { + if (action == DeRezAction.Delete) + { + // Deletes go to trash by default // + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); + } + else + { + if (remoteClient == null || + objlist[0].OwnerID != remoteClient.AgentId) + { + // Taking copy of another person's item. Take to + // Objects folder. + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object); + } + else + { + // Catch all. Use lost & found + // - folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); + } } } - } - // Override and put into where it came from, if it came - // from anywhere in inventory - // - if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) - { - if (objectGroup.RootPart.FromFolderID != UUID.Zero) + // Override and put into where it came from, if it came + // from anywhere in inventory + // + if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) { - InventoryFolderBase f = new InventoryFolderBase(objectGroup.RootPart.FromFolderID, userID); - folder = m_Scene.InventoryService.GetFolder(f); + if (objlist[0].RootPart.FromFolderID != UUID.Zero) + { + InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID); + folder = m_Scene.InventoryService.GetFolder(f); + } } - } - - if (folder == null) // None of the above - { - folder = new InventoryFolderBase(folderID); - if (folder == null) // Nowhere to put it + if (folder == null) // None of the above { - return UUID.Zero; - } - } + folder = new InventoryFolderBase(folderID); - item = new InventoryItemBase(); - item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); - item.CreatorData = objectGroup.RootPart.CreatorData; - item.ID = UUID.Random(); - item.InvType = (int)InventoryType.Object; - item.Folder = folder.ID; - item.Owner = userID; - } + if (folder == null) // Nowhere to put it + { + return UUID.Zero; + } + } - AssetBase asset = CreateAsset( - objectGroup.GetPartName(objectGroup.RootPart.LocalId), - objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), - (sbyte)AssetType.Object, - Utils.StringToBytes(sceneObjectXml), - objectGroup.OwnerID.ToString()); - m_Scene.AssetService.Store(asset); - assetID = asset.FullID; + item = new InventoryItemBase(); + // Can't know creator is the same, so null it in inventory + if (objlist.Count > 1) + item.CreatorId = UUID.Zero.ToString(); + else + item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); + item.ID = UUID.Random(); + item.InvType = (int)InventoryType.Object; + item.Folder = folder.ID; + item.Owner = userID; + if (objlist.Count > 1) + item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; + } - if (DeRezAction.SaveToExistingUserInventoryItem == action) - { - item.AssetID = asset.FullID; - m_Scene.InventoryService.UpdateItem(item); - } - else - { - item.AssetID = asset.FullID; + AssetBase asset = CreateAsset( + objlist[0].GetPartName(objlist[0].RootPart.LocalId), + objlist[0].GetPartDescription(objlist[0].RootPart.LocalId), + (sbyte)AssetType.Object, + Utils.StringToBytes(itemXml), + objlist[0].OwnerID.ToString()); + m_Scene.AssetService.Store(asset); + assetID = asset.FullID; - if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) + if (DeRezAction.SaveToExistingUserInventoryItem == action) { - uint perms = objectGroup.GetEffectivePermissions(); - uint nextPerms = (perms & 7) << 13; - if ((nextPerms & (uint)PermissionMask.Copy) == 0) - perms &= ~(uint)PermissionMask.Copy; - if ((nextPerms & (uint)PermissionMask.Transfer) == 0) - perms &= ~(uint)PermissionMask.Transfer; - if ((nextPerms & (uint)PermissionMask.Modify) == 0) - perms &= ~(uint)PermissionMask.Modify; - - // Make sure all bits but the ones we want are clear - // on take. - // This will be applied to the current perms, so - // it will do what we want. - objectGroup.RootPart.NextOwnerMask &= - ((uint)PermissionMask.Copy | - (uint)PermissionMask.Transfer | - (uint)PermissionMask.Modify); - objectGroup.RootPart.NextOwnerMask |= - (uint)PermissionMask.Move; - - item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; - item.CurrentPermissions = item.BasePermissions; - item.NextPermissions = objectGroup.RootPart.NextOwnerMask; - item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; - item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask; - - item.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; + item.AssetID = asset.FullID; + m_Scene.InventoryService.UpdateItem(item); } else { - item.BasePermissions = objectGroup.GetEffectivePermissions(); - item.CurrentPermissions = objectGroup.GetEffectivePermissions(); - item.NextPermissions = objectGroup.RootPart.NextOwnerMask; - item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; - item.GroupPermissions = objectGroup.RootPart.GroupMask; + item.AssetID = asset.FullID; - item.CurrentPermissions &= - ((uint)PermissionMask.Copy | - (uint)PermissionMask.Transfer | - (uint)PermissionMask.Modify | - (uint)PermissionMask.Move | - 7); // Preserve folded permissions - } + uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; + foreach (SceneObjectGroup grp in objlist) + effectivePerms &= grp.GetEffectivePermissions(); + effectivePerms |= (uint)PermissionMask.Move; - // TODO: add the new fields (Flags, Sale info, etc) - item.CreationDate = Util.UnixTimeSinceEpoch(); - item.Description = asset.Description; - item.Name = asset.Name; - item.AssetType = asset.Type; + if (remoteClient != null && (remoteClient.AgentId != objlist[0].RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) + { + uint perms = effectivePerms; + uint nextPerms = (perms & 7) << 13; + if ((nextPerms & (uint)PermissionMask.Copy) == 0) + perms &= ~(uint)PermissionMask.Copy; + if ((nextPerms & (uint)PermissionMask.Transfer) == 0) + perms &= ~(uint)PermissionMask.Transfer; + if ((nextPerms & (uint)PermissionMask.Modify) == 0) + perms &= ~(uint)PermissionMask.Modify; + + item.BasePermissions = perms & objlist[0].RootPart.NextOwnerMask; + item.CurrentPermissions = item.BasePermissions; + item.NextPermissions = perms & objlist[0].RootPart.NextOwnerMask; + item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & objlist[0].RootPart.NextOwnerMask; + item.GroupPermissions = objlist[0].RootPart.GroupMask & objlist[0].RootPart.NextOwnerMask; + + // Magic number badness. Maybe this deserves an enum. + // bit 4 (16) is the "Slam" bit, it means treat as passed + // and apply next owner perms on rez + item.CurrentPermissions |= 16; // Slam! + } + else + { + item.BasePermissions = effectivePerms; + item.CurrentPermissions = effectivePerms; + item.NextPermissions = objlist[0].RootPart.NextOwnerMask & effectivePerms; + item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & effectivePerms; + item.GroupPermissions = objlist[0].RootPart.GroupMask & effectivePerms; + + item.CurrentPermissions &= + ((uint)PermissionMask.Copy | + (uint)PermissionMask.Transfer | + (uint)PermissionMask.Modify | + (uint)PermissionMask.Move | + 7); // Preserve folded permissions + } - m_Scene.AddInventoryItem(item); + // TODO: add the new fields (Flags, Sale info, etc) + item.CreationDate = Util.UnixTimeSinceEpoch(); + item.Description = asset.Description; + item.Name = asset.Name; + item.AssetType = asset.Type; - if (remoteClient != null && item.Owner == remoteClient.AgentId) - { - remoteClient.SendInventoryItemCreateUpdate(item, 0); - } - else - { - ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner); - if (notifyUser != null) + m_Scene.AddInventoryItem(item); + + if (remoteClient != null && item.Owner == remoteClient.AgentId) { - notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); + remoteClient.SendInventoryItemCreateUpdate(item, 0); + } + else + { + ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner); + if (notifyUser != null) + { + notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); + } } } } - return assetID; } 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 x = m_inventoryDeletes.Dequeue(); m_log.DebugFormat( - "[ASYNC DELETER]: Sending object to user's inventory, {0} item(s) remaining.", left); + "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.", left, x.action, x.objectGroups.Count); try { @@ -177,4 +177,4 @@ namespace OpenSim.Region.Framework.Scenes return false; } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 353b7c2..35a798e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4865,8 +4865,17 @@ namespace OpenSim.Region.Framework.Scenes { float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; + Vector3 vec = g.AbsolutePosition; + g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); + ominX += vec.X; + omaxX += vec.X; + ominY += vec.Y; + omaxY += vec.Y; + ominZ += vec.Z; + omaxZ += vec.Z; + if (minX > ominX) minX = ominX; if (minY > ominY) -- cgit v1.1 From a4b3439025f7ae8cf3a795f540675714d6324122 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Oct 2010 05:12:39 +0200 Subject: Implement rezzing coalesced objects --- .../InventoryAccess/InventoryAccessModule.cs | 277 +++++++++++++-------- 1 file changed, 172 insertions(+), 105 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 88dff02..a7d59c7 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -458,7 +458,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess item.Folder = folder.ID; item.Owner = userID; if (objlist.Count > 1) + { item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; + } + else + { + item.SaleType = objlist[0].RootPart.ObjectSaleType; + item.SalePrice = objlist[0].RootPart.SalePrice; + } } AssetBase asset = CreateAsset( @@ -522,7 +529,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess 7); // Preserve folded permissions } - // TODO: add the new fields (Flags, Sale info, etc) item.CreationDate = Util.UnixTimeSinceEpoch(); item.Description = asset.Description; item.Name = asset.Name; @@ -598,6 +604,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); + SceneObjectGroup group = null; + if (rezAsset != null) { UUID itemId = UUID.Zero; @@ -606,34 +614,78 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // item that it came from. This allows us to enable 'save object to inventory' if (!m_Scene.Permissions.BypassPermissions()) { - if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy) + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy && (item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) { itemId = item.ID; } } else { - // Brave new fullperm world - // - itemId = item.ID; + if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) + { + // Brave new fullperm world + itemId = item.ID; + } } string xmlData = Utils.BytesToString(rezAsset.Data); - SceneObjectGroup group - = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); + List objlist = + new List(); + List veclist = new List(); + + XmlDocument doc = new XmlDocument(); + doc.LoadXml(xmlData); + XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject"); + if (e == null || attachment) // Single + { + SceneObjectGroup g = + SceneObjectSerializer.FromOriginalXmlFormat( + itemId, xmlData); + objlist.Add(g); + veclist.Add(new Vector3(0, 0, 0)); - Util.FireAndForget(delegate { AddUserData(group); }); - - group.RootPart.FromFolderID = item.Folder; + float offsetHeight = 0; + pos = m_Scene.GetNewRezLocation( + RayStart, RayEnd, RayTargetID, Quaternion.Identity, + BypassRayCast, bRayEndIsIntersection, true, g.GetAxisAlignedBoundingBox(out offsetHeight), false); + pos.Z += offsetHeight; + } + else + { + XmlElement coll = (XmlElement)e; + float bx = Convert.ToSingle(coll.GetAttribute("x")); + float by = Convert.ToSingle(coll.GetAttribute("y")); + float bz = Convert.ToSingle(coll.GetAttribute("z")); + Vector3 bbox = new Vector3(bx, by, bz); - // If it's rezzed in world, select it. Much easier to - // find small items. - // - if (!attachment) - group.RootPart.CreateSelected = true; + pos = m_Scene.GetNewRezLocation(RayStart, RayEnd, + RayTargetID, Quaternion.Identity, + BypassRayCast, bRayEndIsIntersection, true, + bbox, false); + + pos -= bbox / 2; + + XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); + foreach (XmlNode n in groups) + { + SceneObjectGroup g = + SceneObjectSerializer.FromOriginalXmlFormat( + itemId, n.OuterXml); + objlist.Add(g); + XmlElement el = (XmlElement)n; + float x = Convert.ToSingle(el.GetAttribute("offsetx")); + float y = Convert.ToSingle(el.GetAttribute("offsety")); + float z = Convert.ToSingle(el.GetAttribute("offsetz")); + veclist.Add(new Vector3(x, y, z)); + } + } + + int primcount = 0; + foreach (SceneObjectGroup g in objlist) + primcount += g.PrimCount; if (!m_Scene.Permissions.CanRezObject( - group.PrimCount, remoteClient.AgentId, pos) + primcount, remoteClient.AgentId, pos) && !attachment) { // The client operates in no fail mode. It will @@ -646,121 +698,137 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess return null; } - group.ResetIDs(); - - if (attachment) + for (int i = 0 ; i < objlist.Count ; i++ ) { - group.RootPart.Flags |= PrimFlags.Phantom; - group.RootPart.IsAttachment = true; + group = objlist[i]; + + Vector3 storedPosition = group.AbsolutePosition; + if (group.UUID == UUID.Zero) + { + m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 3"); + } + group.RootPart.FromFolderID = item.Folder; + + // If it's rezzed in world, select it. Much easier to + // find small items. + // + if (!attachment) + { + group.RootPart.CreateSelected = true; + foreach (SceneObjectPart child in group.Parts) + child.CreateSelected = true; + } + group.ResetIDs(); + + if (attachment) + { + group.RootPart.Flags |= PrimFlags.Phantom; + group.RootPart.IsAttachment = true; + } // If we're rezzing an attachment then don't ask // AddNewSceneObject() to update the client since - // we'll be doing that later on. Scheduling more - // than one full update during the attachment - // process causes some clients to fail to display - // the attachment properly. - // Also, don't persist attachments. - m_Scene.AddNewSceneObject(group, false, false); - } - else - { + // we'll be doing that later on. Scheduling more than + // one full update during the attachment + // process causes some clients to fail to display the + // attachment properly. m_Scene.AddNewSceneObject(group, true, false); - } - // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); - // if attachment we set it's asset id so object updates can reflect that - // if not, we set it's position in world. - if (!attachment) - { - group.ScheduleGroupForFullUpdate(); - - float offsetHeight = 0; - pos = m_Scene.GetNewRezLocation( - RayStart, RayEnd, RayTargetID, Quaternion.Identity, - BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false); - pos.Z += offsetHeight; - group.AbsolutePosition = pos; - // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight); - - } - else - { - group.SetFromItemID(itemID); - } + // if attachment we set it's asset id so object updates + // can reflect that, if not, we set it's position in world. + if (!attachment) + { + group.ScheduleGroupForFullUpdate(); + + group.AbsolutePosition = pos + veclist[i]; + } + else + { + group.SetFromItemID(itemID); + } - SceneObjectPart rootPart = null; - try - { - rootPart = group.GetChildPart(group.UUID); - } - catch (NullReferenceException) - { - string isAttachment = ""; + SceneObjectPart rootPart = null; - if (attachment) - isAttachment = " Object was an attachment"; + try + { + rootPart = group.GetChildPart(group.UUID); + } + catch (NullReferenceException) + { + string isAttachment = ""; - m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); - } + if (attachment) + isAttachment = " Object was an attachment"; - // Since renaming the item in the inventory does not affect the name stored - // in the serialization, transfer the correct name from the inventory to the - // object itself before we rez. - rootPart.Name = item.Name; - rootPart.Description = item.Description; + m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); + } - if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0) - { + // Since renaming the item in the inventory does not + // affect the name stored in the serialization, transfer + // the correct name from the inventory to the + // object itself before we rez. + rootPart.Name = item.Name; + rootPart.Description = item.Description; rootPart.ObjectSaleType = item.SaleType; rootPart.SalePrice = item.SalePrice; - } - group.SetGroup(remoteClient.ActiveGroupId, remoteClient); - if ((rootPart.OwnerID != item.Owner) || - (item.CurrentPermissions & 16) != 0 || // Magic number - (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) - { - //Need to kill the for sale here - rootPart.ObjectSaleType = 0; - rootPart.SalePrice = 10; - - if (m_Scene.Permissions.PropagatePermissions()) + group.SetGroup(remoteClient.ActiveGroupId, remoteClient); + if ((rootPart.OwnerID != item.Owner) || + (item.CurrentPermissions & 16) != 0) { - foreach (SceneObjectPart part in group.Parts) + //Need to kill the for sale here + rootPart.ObjectSaleType = 0; + rootPart.SalePrice = 10; + + if (m_Scene.Permissions.PropagatePermissions()) { - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) - part.EveryoneMask = item.EveryOnePermissions; - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) - part.NextOwnerMask = item.NextPermissions; - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) - part.GroupMask = item.GroupPermissions; + foreach (SceneObjectPart part in group.Parts) + { + if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) + { + part.EveryoneMask = item.EveryOnePermissions; + part.NextOwnerMask = item.NextPermissions; + } + part.GroupMask = 0; // DO NOT propagate here + } + + group.ApplyNextOwnerPermissions(); } + } - foreach (SceneObjectPart part in group.Parts) + foreach (SceneObjectPart part in group.Parts) + { + if ((part.OwnerID != item.Owner) || + (item.CurrentPermissions & 16) != 0) { part.LastOwnerID = part.OwnerID; part.OwnerID = item.Owner; part.Inventory.ChangeInventoryOwner(item.Owner); + part.GroupMask = 0; // DO NOT propagate here } - - group.ApplyNextOwnerPermissions(); + part.EveryoneMask = item.EveryOnePermissions; + part.NextOwnerMask = item.NextPermissions; } - } - rootPart.TrimPermissions(); + rootPart.TrimPermissions(); - if (!attachment) - { - if (group.RootPart.Shape.PCode == (byte)PCode.Prim) + if (!attachment) { - group.ClearPartAttachmentData(); - } - - // Fire on_rez - group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); - rootPart.ParentGroup.ResumeScripts(); + if (group.RootPart.Shape.PCode == (byte)PCode.Prim) + { + // Save attachment data + group.RootPart.AttachPoint = group.RootPart.Shape.State; + group.RootPart.AttachOffset = storedPosition; - rootPart.ScheduleFullUpdate(); + group.ClearPartAttachmentData(); + } + + // Fire on_rez + group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); + rootPart.ParentGroup.ResumeScripts(); + + rootPart.ScheduleFullUpdate(); + } } if (!m_Scene.Permissions.BypassPermissions()) @@ -778,9 +846,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } } } - - return rootPart.ParentGroup; } + return group; } return null; -- cgit v1.1 From adb14ad20acce44cb4b269b0d518b210f9f5eae4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Oct 2010 05:12:39 +0200 Subject: Implement rezzing coalesced objects --- .../Framework/InventoryAccess/InventoryAccessModule.cs | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index a7d59c7..9fbfc34 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -247,11 +247,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess Vector3 originalPosition = objectGroup.AbsolutePosition; - // Restore attachment data after trip through the sim - if (objectGroup.RootPart.AttachPoint > 0) - inventoryStoredPosition = objectGroup.RootPart.AttachOffset; - objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint; - objectGroup.AbsolutePosition = inventoryStoredPosition; // Make sure all bits but the ones we want are clear @@ -815,13 +810,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (!attachment) { if (group.RootPart.Shape.PCode == (byte)PCode.Prim) - { - // Save attachment data - group.RootPart.AttachPoint = group.RootPart.Shape.State; - group.RootPart.AttachOffset = storedPosition; - group.ClearPartAttachmentData(); - } // Fire on_rez group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 1); -- cgit v1.1 From 6885b7220c6f782034d7c0220762244adf00e3d3 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 28 Mar 2011 10:00:53 -0700 Subject: Implements adaptive queue management and fair queueing for improved networking performance. Reprioritization algorithms need to be ported still. One is in place. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 353 ++++++++++++++------- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 71 ++++- 2 files changed, 304 insertions(+), 120 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 2faffae..e9e1fa3 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -49,6 +49,8 @@ using Timer = System.Timers.Timer; using AssetLandmark = OpenSim.Framework.AssetLandmark; using Nini.Config; +using System.IO; + namespace OpenSim.Region.ClientStack.LindenUDP { public delegate bool PacketMethod(IClientAPI simClient, Packet packet); @@ -298,6 +300,77 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Used to adjust Sun Orbit values so Linden based viewers properly position sun private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f; + // First log file or time has expired, start writing to a new log file +// +// ----------------------------------------------------------------- +// ----------------------------------------------------------------- +// THIS IS DEBUGGING CODE & SHOULD BE REMOVED +// ----------------------------------------------------------------- +// ----------------------------------------------------------------- + public class QueueLogger + { + public Int32 start = 0; + public StreamWriter Log = null; + private Dictionary m_idMap = new Dictionary(); + + public QueueLogger() + { + DateTime now = DateTime.Now; + String fname = String.Format("queue-{0}.log", now.ToString("yyyyMMddHHmmss")); + Log = new StreamWriter(fname); + + start = Util.EnvironmentTickCount(); + } + + public int LookupID(UUID uuid) + { + int localid; + if (! m_idMap.TryGetValue(uuid,out localid)) + { + localid = m_idMap.Count + 1; + m_idMap[uuid] = localid; + } + + return localid; + } + } + + public static QueueLogger QueueLog = null; + + // ----------------------------------------------------------------- + public void LogAvatarUpdateEvent(UUID client, UUID avatar, Int32 timeinqueue) + { + if (QueueLog == null) + QueueLog = new QueueLogger(); + + Int32 ticks = Util.EnvironmentTickCountSubtract(QueueLog.start); + lock(QueueLog) + { + int cid = QueueLog.LookupID(client); + int aid = QueueLog.LookupID(avatar); + QueueLog.Log.WriteLine("{0},AU,AV{1:D4},AV{2:D4},{3}",ticks,cid,aid,timeinqueue); + } + } + + // ----------------------------------------------------------------- + public void LogQueueProcessEvent(UUID client, PriorityQueue queue, uint maxup) + { + if (QueueLog == null) + QueueLog = new QueueLogger(); + + Int32 ticks = Util.EnvironmentTickCountSubtract(QueueLog.start); + lock(QueueLog) + { + int cid = QueueLog.LookupID(client); + QueueLog.Log.WriteLine("{0},PQ,AV{1:D4},{2},{3}",ticks,cid,maxup,queue.ToString()); + } + } +// ----------------------------------------------------------------- +// ----------------------------------------------------------------- +// ----------------------------------------------------------------- +// ----------------------------------------------------------------- +// + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected static Dictionary PacketHandlers = new Dictionary(); //Global/static handlers for all clients @@ -3547,18 +3620,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Primitive Packet/Data Sending Methods + /// /// Generate one of the object update packets based on PrimUpdateFlags /// and broadcast the packet to clients /// public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) { - double priority = m_prioritizer.GetUpdatePriority(this, entity); + //double priority = m_prioritizer.GetUpdatePriority(this, entity); + uint priority = m_prioritizer.GetUpdatePriority(this, entity); lock (m_entityUpdates.SyncRoot) - m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation), entity.LocalId); + m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation)); } + private Int32 m_LastQueueFill = 0; + private uint m_maxUpdates = 0; + private void ProcessEntityUpdates(int maxUpdates) { OpenSim.Framework.Lazy> objectUpdateBlocks = new OpenSim.Framework.Lazy>(); @@ -3566,23 +3644,55 @@ namespace OpenSim.Region.ClientStack.LindenUDP OpenSim.Framework.Lazy> terseUpdateBlocks = new OpenSim.Framework.Lazy>(); OpenSim.Framework.Lazy> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy>(); - if (maxUpdates <= 0) maxUpdates = Int32.MaxValue; + if (maxUpdates <= 0) + { + m_maxUpdates = Int32.MaxValue; + } + else + { + if (m_maxUpdates == 0 || m_LastQueueFill == 0) + { + m_maxUpdates = (uint)maxUpdates; + } + else + { + if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200) + m_maxUpdates += 5; + else + m_maxUpdates = m_maxUpdates >> 1; + } + m_maxUpdates = Util.Clamp(m_maxUpdates,10,500); + } + m_LastQueueFill = Util.EnvironmentTickCount(); + int updatesThisCall = 0; +// +// DEBUGGING CODE... REMOVE +// LogQueueProcessEvent(this.m_agentId,m_entityUpdates,m_maxUpdates); +// // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race // condition where a kill can be processed before an out-of-date update for the same object. lock (m_killRecord) { float avgTimeDilation = 1.0f; EntityUpdate update; - while (updatesThisCall < maxUpdates) + Int32 timeinqueue; // this is just debugging code & can be dropped later + + while (updatesThisCall < m_maxUpdates) { lock (m_entityUpdates.SyncRoot) - if (!m_entityUpdates.TryDequeue(out update)) + if (!m_entityUpdates.TryDequeue(out update, out timeinqueue)) break; avgTimeDilation += update.TimeDilation; avgTimeDilation *= 0.5f; +// +// DEBUGGING CODE... REMOVE +// if (update.Entity is ScenePresence) +// LogAvatarUpdateEvent(this.m_agentId,update.Entity.UUID,timeinqueue); +// + if (update.Entity is SceneObjectPart) { SceneObjectPart part = (SceneObjectPart)update.Entity; @@ -3679,36 +3789,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } else { - // if (update.Entity is SceneObjectPart && ((SceneObjectPart)update.Entity).IsAttachment) - // { - // SceneObjectPart sop = (SceneObjectPart)update.Entity; - // string text = sop.Text; - // if (text.IndexOf("\n") >= 0) - // text = text.Remove(text.IndexOf("\n")); - // - // if (m_attachmentsSent.Contains(sop.ParentID)) - // { - //// m_log.DebugFormat( - //// "[CLIENT]: Sending full info about attached prim {0} text {1}", - //// sop.LocalId, text); - // - // objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock(sop, this.m_agentId)); - // - // m_attachmentsSent.Add(sop.LocalId); - // } - // else - // { - // m_log.DebugFormat( - // "[CLIENT]: Requeueing full update of prim {0} text {1} since we haven't sent its parent {2} yet", - // sop.LocalId, text, sop.ParentID); - // - // m_entityUpdates.Enqueue(double.MaxValue, update, sop.LocalId); - // } - // } - // else - // { - objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId)); - // } + objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId)); } } else if (!canUseImproved) @@ -3802,26 +3883,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void ReprioritizeUpdates() { - //m_log.Debug("[CLIENT]: Reprioritizing prim updates for " + m_firstName + " " + m_lastName); - lock (m_entityUpdates.SyncRoot) m_entityUpdates.Reprioritize(UpdatePriorityHandler); } - private bool UpdatePriorityHandler(ref double priority, uint localID) + private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity) { - EntityBase entity; - if (m_scene.Entities.TryGetValue(localID, out entity)) + if (entity != null) { priority = m_prioritizer.GetUpdatePriority(this, entity); + return true; } - return priority != double.NaN; + return false; } public void FlushPrimUpdates() { - m_log.Debug("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName); + m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName); while (m_entityUpdates.Count > 0) ProcessEntityUpdates(-1); @@ -11713,86 +11792,85 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region PriorityQueue public class PriorityQueue { - internal delegate bool UpdatePriorityHandler(ref double priority, uint local_id); + internal delegate bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity); + + // Heap[0] for self updates + // Heap[1..12] for entity updates - private MinHeap[] m_heaps = new MinHeap[1]; + internal const uint m_numberOfQueues = 12; + private MinHeap[] m_heaps = new MinHeap[m_numberOfQueues]; private Dictionary m_lookupTable; - private Comparison m_comparison; private object m_syncRoot = new object(); - + private uint m_nextQueue = 0; + private UInt64 m_nextRequest = 0; + internal PriorityQueue() : - this(MinHeap.DEFAULT_CAPACITY, Comparer.Default) { } - internal PriorityQueue(int capacity) : - this(capacity, Comparer.Default) { } - internal PriorityQueue(IComparer comparer) : - this(new Comparison(comparer.Compare)) { } - internal PriorityQueue(Comparison comparison) : - this(MinHeap.DEFAULT_CAPACITY, comparison) { } - internal PriorityQueue(int capacity, IComparer comparer) : - this(capacity, new Comparison(comparer.Compare)) { } - internal PriorityQueue(int capacity, Comparison comparison) + this(MinHeap.DEFAULT_CAPACITY) { } + internal PriorityQueue(int capacity) { m_lookupTable = new Dictionary(capacity); for (int i = 0; i < m_heaps.Length; ++i) m_heaps[i] = new MinHeap(capacity); - this.m_comparison = comparison; } public object SyncRoot { get { return this.m_syncRoot; } } + internal int Count { get { int count = 0; for (int i = 0; i < m_heaps.Length; ++i) - count = m_heaps[i].Count; + count += m_heaps[i].Count; return count; } } - public bool Enqueue(double priority, EntityUpdate value, uint local_id) + public bool Enqueue(uint pqueue, EntityUpdate value) { - LookupItem item; + LookupItem lookup; - if (m_lookupTable.TryGetValue(local_id, out item)) + uint localid = value.Entity.LocalId; + UInt64 entry = m_nextRequest++; + if (m_lookupTable.TryGetValue(localid, out lookup)) { - // Combine flags - value.Flags |= item.Heap[item.Handle].Value.Flags; - - item.Heap[item.Handle] = new MinHeapItem(priority, value, local_id, this.m_comparison); - return false; - } - else - { - item.Heap = m_heaps[0]; - item.Heap.Add(new MinHeapItem(priority, value, local_id, this.m_comparison), ref item.Handle); - m_lookupTable.Add(local_id, item); - return true; + entry = lookup.Heap[lookup.Handle].EntryOrder; + value.Flags |= lookup.Heap[lookup.Handle].Value.Flags; + lookup.Heap.Remove(lookup.Handle); } - } - internal EntityUpdate Peek() - { - for (int i = 0; i < m_heaps.Length; ++i) - if (m_heaps[i].Count > 0) - return m_heaps[i].Min().Value; - throw new InvalidOperationException(string.Format("The {0} is empty", this.GetType().ToString())); + pqueue = Util.Clamp(pqueue, 0, m_numberOfQueues - 1); + lookup.Heap = m_heaps[pqueue]; + lookup.Heap.Add(new MinHeapItem(pqueue, entry, value), ref lookup.Handle); + m_lookupTable[localid] = lookup; + + return true; } - internal bool TryDequeue(out EntityUpdate value) + internal bool TryDequeue(out EntityUpdate value, out Int32 timeinqueue) { - for (int i = 0; i < m_heaps.Length; ++i) + for (int i = 0; i < m_numberOfQueues; ++i) { - if (m_heaps[i].Count > 0) + // To get the fair queing, we cycle through each of the + // queues when finding an element to dequeue, this code + // assumes that the distribution of updates in the queues + // is polynomial, probably quadractic (eg distance of PI * R^2) + uint h = (uint)((m_nextQueue + i) % m_numberOfQueues); + if (m_heaps[h].Count > 0) { - MinHeapItem item = m_heaps[i].RemoveMin(); - m_lookupTable.Remove(item.LocalID); + m_nextQueue = (uint)((h + 1) % m_numberOfQueues); + + MinHeapItem item = m_heaps[h].RemoveMin(); + m_lookupTable.Remove(item.Value.Entity.LocalId); + timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); value = item.Value; + return true; } } + timeinqueue = 0; value = default(EntityUpdate); return false; } @@ -11800,68 +11878,107 @@ namespace OpenSim.Region.ClientStack.LindenUDP internal void Reprioritize(UpdatePriorityHandler handler) { MinHeapItem item; - double priority; - foreach (LookupItem lookup in new List(this.m_lookupTable.Values)) { if (lookup.Heap.TryGetValue(lookup.Handle, out item)) { - priority = item.Priority; - if (handler(ref priority, item.LocalID)) + uint pqueue = item.PriorityQueue; + uint localid = item.Value.Entity.LocalId; + + if (handler(ref pqueue, item.Value.Entity)) { - if (lookup.Heap.ContainsHandle(lookup.Handle)) - lookup.Heap[lookup.Handle] = - new MinHeapItem(priority, item.Value, item.LocalID, this.m_comparison); + // unless the priority queue has changed, there is no need to modify + // the entry + pqueue = Util.Clamp(pqueue, 0, m_numberOfQueues - 1); + if (pqueue != item.PriorityQueue) + { + lookup.Heap.Remove(lookup.Handle); + + LookupItem litem = lookup; + litem.Heap = m_heaps[pqueue]; + litem.Heap.Add(new MinHeapItem(pqueue, item), ref litem.Handle); + m_lookupTable[localid] = litem; + } } else { - m_log.Warn("[LLCLIENTVIEW]: UpdatePriorityHandler returned false, dropping update"); + m_log.WarnFormat("[LLCLIENTVIEW]: UpdatePriorityHandler returned false for {0}",item.Value.Entity.UUID); lookup.Heap.Remove(lookup.Handle); - this.m_lookupTable.Remove(item.LocalID); + this.m_lookupTable.Remove(localid); } } } } + public override string ToString() + { + string s = ""; + for (int i = 0; i < m_numberOfQueues; i++) + { + if (s != "") s += ","; + s += m_heaps[i].Count.ToString(); + } + return s; + } + #region MinHeapItem private struct MinHeapItem : IComparable { - private double priority; private EntityUpdate value; - private uint local_id; - private Comparison comparison; + internal EntityUpdate Value { + get { + return this.value; + } + } + + private uint pqueue; + internal uint PriorityQueue { + get { + return this.pqueue; + } + } - internal MinHeapItem(double priority, EntityUpdate value, uint local_id) : - this(priority, value, local_id, Comparer.Default) { } - internal MinHeapItem(double priority, EntityUpdate value, uint local_id, IComparer comparer) : - this(priority, value, local_id, new Comparison(comparer.Compare)) { } - internal MinHeapItem(double priority, EntityUpdate value, uint local_id, Comparison comparison) + private Int32 entrytime; + internal Int32 EntryTime { + get { + return this.entrytime; + } + } + + private UInt64 entryorder; + internal UInt64 EntryOrder { - this.priority = priority; + get { + return this.entryorder; + } + } + + internal MinHeapItem(uint pqueue, MinHeapItem other) + { + this.entrytime = other.entrytime; + this.entryorder = other.entryorder; + this.value = other.value; + this.pqueue = pqueue; + } + + internal MinHeapItem(uint pqueue, UInt64 entryorder, EntityUpdate value) + { + this.entrytime = Util.EnvironmentTickCount(); + this.entryorder = entryorder; this.value = value; - this.local_id = local_id; - this.comparison = comparison; + this.pqueue = pqueue; } - internal double Priority { get { return this.priority; } } - internal EntityUpdate Value { get { return this.value; } } - internal uint LocalID { get { return this.local_id; } } - public override string ToString() { - StringBuilder sb = new StringBuilder(); - sb.Append("["); - sb.Append(this.priority.ToString()); - sb.Append(","); - if (this.value != null) - sb.Append(this.value.ToString()); - sb.Append("]"); - return sb.ToString(); + return String.Format("[{0},{1},{2}]",pqueue,entryorder,value.Entity.LocalId); } public int CompareTo(MinHeapItem other) { - return this.comparison(this.priority, other.priority); + // I'm assuming that the root part of an SOG is added to the update queue + // before the component parts + return Comparer.Default.Compare(this.EntryOrder, other.EntryOrder); } } #endregion diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index f9599f5..2764b05 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Scenes public class Prioritizer { -// private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); /// /// This is added to the priority of all child prims, to make sure that the root prim update is sent to the @@ -76,7 +76,74 @@ namespace OpenSim.Region.Framework.Scenes m_scene = scene; } - public double GetUpdatePriority(IClientAPI client, ISceneEntity entity) +// + public uint GetUpdatePriority(IClientAPI client, ISceneEntity entity) + { + if (entity == null) + { + m_log.WarnFormat("[PRIORITIZER] attempt to prioritize null entity"); + throw new InvalidOperationException("Prioritization entity not defined"); + } + + // If this is an update for our own avatar give it the highest priority + if (client.AgentId == entity.UUID) + return 0; + + // Get this agent's position + ScenePresence presence = m_scene.GetScenePresence(client.AgentId); + if (presence == null) + { + m_log.WarnFormat("[PRIORITIZER] attempt to prioritize agent no longer in the scene"); + throw new InvalidOperationException("Prioritization agent not defined"); + } + + // Use group position for child prims + Vector3 entityPos = entity.AbsolutePosition; + if (entity is SceneObjectPart) + { + SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup; + if (group != null) + entityPos = group.AbsolutePosition; + } + + // Use the camera position for local agents and avatar position for remote agents + Vector3 presencePos = (presence.IsChildAgent) ? + presence.AbsolutePosition : + presence.CameraPosition; + + // Compute the distance... + double distance = Vector3.Distance(presencePos, entityPos); + + // And convert the distance to a priority queue, this computation gives queues + // at 10, 20, 40, 80, 160, 320, 640, and 1280m + uint pqueue = 1; + for (int i = 0; i < 8; i++) + { + if (distance < 10 * Math.Pow(2.0,i)) + break; + pqueue++; + } + + // If this is a root agent, then determine front & back + // Bump up the priority queue for any objects behind the avatar + if (! presence.IsChildAgent) + { + // Root agent, decrease priority for objects behind us + Vector3 camPosition = presence.CameraPosition; + Vector3 camAtAxis = presence.CameraAtAxis; + + // Plane equation + float d = -Vector3.Dot(camPosition, camAtAxis); + float p = Vector3.Dot(camAtAxis, entityPos) + d; + if (p < 0.0f) + pqueue++; + } + + return pqueue; + } +// + + public double bGetUpdatePriority(IClientAPI client, ISceneEntity entity) { double priority = 0; -- cgit v1.1 From 15c4bbea59066c5d5ed3d76d253a096788ac295a Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 4 Apr 2011 13:19:45 -0700 Subject: Fixed the prioritizer functions for the new priority queues --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 292 +++++++------------------ 1 file changed, 82 insertions(+), 210 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 2764b05..a14bb70 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -60,15 +60,6 @@ namespace OpenSim.Region.Framework.Scenes { private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - /// - /// This is added to the priority of all child prims, to make sure that the root prim update is sent to the - /// viewer before child prim updates. - /// The adjustment is added to child prims and subtracted from root prims, so the gap ends up - /// being double. We do it both ways so that there is a still a priority delta even if the priority is already - /// double.MinValue or double.MaxValue. - /// - private double m_childPrimAdjustmentFactor = 0.05; - private Scene m_scene; public Prioritizer(Scene scene) @@ -76,9 +67,19 @@ namespace OpenSim.Region.Framework.Scenes m_scene = scene; } -// + /// + /// Returns the priority queue into which the update should be placed. Updates within a + /// queue will be processed in arrival order. There are currently 12 priority queues + /// implemented in PriorityQueue class in LLClientView. Queue 0 is generally retained + /// for avatar updates. The fair queuing discipline for processing the priority queues + /// assumes that the number of entities in each priority queues increases exponentially. + /// So for example... if queue 1 contains all updates within 10m of the avatar or camera + /// then queue 2 at 20m is about 3X bigger in space & about 3X bigger in total number + /// of updates. + /// public uint GetUpdatePriority(IClientAPI client, ISceneEntity entity) { + // If entity is null we have a serious problem if (entity == null) { m_log.WarnFormat("[PRIORITIZER] attempt to prioritize null entity"); @@ -89,71 +90,12 @@ namespace OpenSim.Region.Framework.Scenes if (client.AgentId == entity.UUID) return 0; - // Get this agent's position - ScenePresence presence = m_scene.GetScenePresence(client.AgentId); - if (presence == null) - { - m_log.WarnFormat("[PRIORITIZER] attempt to prioritize agent no longer in the scene"); - throw new InvalidOperationException("Prioritization agent not defined"); - } - - // Use group position for child prims - Vector3 entityPos = entity.AbsolutePosition; - if (entity is SceneObjectPart) - { - SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup; - if (group != null) - entityPos = group.AbsolutePosition; - } - - // Use the camera position for local agents and avatar position for remote agents - Vector3 presencePos = (presence.IsChildAgent) ? - presence.AbsolutePosition : - presence.CameraPosition; - - // Compute the distance... - double distance = Vector3.Distance(presencePos, entityPos); - - // And convert the distance to a priority queue, this computation gives queues - // at 10, 20, 40, 80, 160, 320, 640, and 1280m - uint pqueue = 1; - for (int i = 0; i < 8; i++) - { - if (distance < 10 * Math.Pow(2.0,i)) - break; - pqueue++; - } - - // If this is a root agent, then determine front & back - // Bump up the priority queue for any objects behind the avatar - if (! presence.IsChildAgent) - { - // Root agent, decrease priority for objects behind us - Vector3 camPosition = presence.CameraPosition; - Vector3 camAtAxis = presence.CameraAtAxis; - - // Plane equation - float d = -Vector3.Dot(camPosition, camAtAxis); - float p = Vector3.Dot(camAtAxis, entityPos) + d; - if (p < 0.0f) - pqueue++; - } - - return pqueue; - } -// - - public double bGetUpdatePriority(IClientAPI client, ISceneEntity entity) - { - double priority = 0; - - if (entity == null) - return 100000; + uint priority; switch (m_scene.UpdatePrioritizationScheme) { case UpdatePrioritizationSchemes.Time: - priority = GetPriorityByTime(); + priority = GetPriorityByTime(client, entity); break; case UpdatePrioritizationSchemes.Distance: priority = GetPriorityByDistance(client, entity); @@ -171,180 +113,110 @@ namespace OpenSim.Region.Framework.Scenes throw new InvalidOperationException("UpdatePrioritizationScheme not defined."); } - // Adjust priority so that root prims are sent to the viewer first. This is especially important for - // attachments acting as huds, since current viewers fail to display hud child prims if their updates - // arrive before the root one. - if (entity is SceneObjectPart) - { - SceneObjectPart sop = ((SceneObjectPart)entity); - - if (sop.IsRoot) - { - if (priority >= double.MinValue + m_childPrimAdjustmentFactor) - priority -= m_childPrimAdjustmentFactor; - } - else - { - if (priority <= double.MaxValue - m_childPrimAdjustmentFactor) - priority += m_childPrimAdjustmentFactor; - } - } - return priority; } - private double GetPriorityByTime() + + private uint GetPriorityByTime(IClientAPI client, ISceneEntity entity) { - return DateTime.UtcNow.ToOADate(); + return 1; } - private double GetPriorityByDistance(IClientAPI client, ISceneEntity entity) + private uint GetPriorityByDistance(IClientAPI client, ISceneEntity entity) { - ScenePresence presence = m_scene.GetScenePresence(client.AgentId); - if (presence != null) - { - // If this is an update for our own avatar give it the highest priority - if (presence == entity) - return 0.0; - - // Use the camera position for local agents and avatar position for remote agents - Vector3 presencePos = (presence.IsChildAgent) ? - presence.AbsolutePosition : - presence.CameraPosition; - - // Use group position for child prims - Vector3 entityPos; - if (entity is SceneObjectPart) - { - // Can't use Scene.GetGroupByPrim() here, since the entity may have been delete from the scene - // before its scheduled update was triggered - //entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition; - entityPos = ((SceneObjectPart)entity).ParentGroup.AbsolutePosition; - } - else - { - entityPos = entity.AbsolutePosition; - } - - return Vector3.DistanceSquared(presencePos, entityPos); - } - - return double.NaN; + return ComputeDistancePriority(client,entity,false); + } + + private uint GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity) + { + return ComputeDistancePriority(client,entity,true); } - private double GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity) + private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) { + uint pqueue = ComputeDistancePriority(client,entity,true); + ScenePresence presence = m_scene.GetScenePresence(client.AgentId); if (presence != null) { - // If this is an update for our own avatar give it the highest priority - if (presence == entity) - return 0.0; - - // Use group position for child prims - Vector3 entityPos = entity.AbsolutePosition; - if (entity is SceneObjectPart) - { - // Can't use Scene.GetGroupByPrim() here, since the entity may have been delete from the scene - // before its scheduled update was triggered - //entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition; - entityPos = ((SceneObjectPart)entity).ParentGroup.AbsolutePosition; - } - else - { - entityPos = entity.AbsolutePosition; - } - if (!presence.IsChildAgent) { - // Root agent. Use distance from camera and a priority decrease for objects behind us - Vector3 camPosition = presence.CameraPosition; - Vector3 camAtAxis = presence.CameraAtAxis; - - // Distance - double priority = Vector3.DistanceSquared(camPosition, entityPos); - - // Plane equation - float d = -Vector3.Dot(camPosition, camAtAxis); - float p = Vector3.Dot(camAtAxis, entityPos) + d; - if (p < 0.0f) priority *= 2.0; - - return priority; - } - else - { - // Child agent. Use the normal distance method - Vector3 presencePos = presence.AbsolutePosition; + if (entity is SceneObjectPart) + { + // Non physical prims are lower priority than physical prims + PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; + if (physActor == null || !physActor.IsPhysical) + pqueue++; - return Vector3.DistanceSquared(presencePos, entityPos); + // Attachments are high priority, + // MIC: shouldn't these already be in the highest priority queue already + // since their root position is same as the avatars? + if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) + pqueue = 1; + } } } - return double.NaN; + return pqueue; } - private double GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) + private uint ComputeDistancePriority(IClientAPI client, ISceneEntity entity, bool useFrontBack) { - // If this is an update for our own avatar give it the highest priority - if (client.AgentId == entity.UUID) - return 0.0; - if (entity == null) - return double.NaN; - - // Use group position for child prims + // Get this agent's position + ScenePresence presence = m_scene.GetScenePresence(client.AgentId); + if (presence == null) + { + m_log.WarnFormat("[PRIORITIZER] attempt to prioritize agent no longer in the scene"); + throw new InvalidOperationException("Prioritization agent not defined"); + } + + // Use group position for child prims, since we are putting child prims in + // the same queue with the root of the group, the root prim (which goes into + // the queue first) should always be sent first, no need to adjust child prim + // priorities Vector3 entityPos = entity.AbsolutePosition; if (entity is SceneObjectPart) { SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup; if (group != null) entityPos = group.AbsolutePosition; - else - entityPos = entity.AbsolutePosition; } - else - entityPos = entity.AbsolutePosition; - - ScenePresence presence = m_scene.GetScenePresence(client.AgentId); - if (presence != null) - { - if (!presence.IsChildAgent) - { - if (entity is ScenePresence) - return 1.0; - // Root agent. Use distance from camera and a priority decrease for objects behind us - Vector3 camPosition = presence.CameraPosition; - Vector3 camAtAxis = presence.CameraAtAxis; - - // Distance - double priority = Vector3.DistanceSquared(camPosition, entityPos); - - // Plane equation - float d = -Vector3.Dot(camPosition, camAtAxis); - float p = Vector3.Dot(camAtAxis, entityPos) + d; - if (p < 0.0f) priority *= 2.0; + // Use the camera position for local agents and avatar position for remote agents + Vector3 presencePos = (presence.IsChildAgent) ? + presence.AbsolutePosition : + presence.CameraPosition; - if (entity is SceneObjectPart) - { - PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; - if (physActor == null || !physActor.IsPhysical) - priority += 100; + // Compute the distance... + double distance = Vector3.Distance(presencePos, entityPos); - if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) - priority = 1.0; - } - return priority; - } - else - { - // Child agent. Use the normal distance method - Vector3 presencePos = presence.AbsolutePosition; + // And convert the distance to a priority queue, this computation gives queues + // at 10, 20, 40, 80, 160, 320, 640, and 1280m + uint pqueue = 1; + for (int i = 0; i < 8; i++) + { + if (distance < 10 * Math.Pow(2.0,i)) + break; + pqueue++; + } + + // If this is a root agent, then determine front & back + // Bump up the priority queue (drop the priority) for any objects behind the avatar + if (useFrontBack && ! presence.IsChildAgent) + { + // Root agent, decrease priority for objects behind us + Vector3 camPosition = presence.CameraPosition; + Vector3 camAtAxis = presence.CameraAtAxis; - return Vector3.DistanceSquared(presencePos, entityPos); - } + // Plane equation + float d = -Vector3.Dot(camPosition, camAtAxis); + float p = Vector3.Dot(camAtAxis, entityPos) + d; + if (p < 0.0f) + pqueue++; } - return double.NaN; + return pqueue; } + } } -- cgit v1.1 From 8b134f37f2c8cc7895153af2fdc79e785f3b93e2 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 4 Apr 2011 14:18:26 -0700 Subject: Fix a bug in the computation of the RTO. Basically... the RTO (the time to wait to retransmit packets) always maxed out (no retransmissions for 24 or 48 seconds. Note that this is going to cause faster (and more) retransmissions. Fix for dynamic throttling needs to go with this. --- OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') 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 /// Caches packed throttle information private byte[] m_packedThrottles; - private int m_defaultRTO = 3000; + private int m_defaultRTO = 1000; // 1sec is the recommendation in the RFC private int m_maxRTO = 60000; /// @@ -557,7 +557,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR)); // Clamp the retransmission timeout to manageable values - rto = Utils.Clamp(RTO, m_defaultRTO, m_maxRTO); + rto = Utils.Clamp(rto, m_defaultRTO, m_maxRTO); RTO = rto; -- cgit v1.1 From f58941e89f122c2e1fd54a2f817fb8114e6c80ed Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Apr 2011 01:30:13 +0100 Subject: Make the "All Estates" option work from the client (this makes chosen changes to all the estates that the user owns). This applies to adding/removing estate users, groups, managers and bans. This is the application of the AllEstates_0.5.patch from http://opensimulator.org/mantis/view.php?id=5420 Thanks very much, Snoopy! --- OpenSim/Data/MSSQL/MSSQLEstateData.cs | 5 + OpenSim/Data/MySQL/MySQLEstateData.cs | 30 +++++ OpenSim/Data/SQLite/SQLiteEstateData.cs | 22 +++ OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs | 24 +++- .../Region/ClientStack/LindenUDP/LLClientView.cs | 24 +++- .../World/Estate/EstateManagementModule.cs | 149 ++++++++++++++++++++- OpenSim/Region/CoreModules/World/Sun/SunModule.cs | 6 +- .../Framework/Interfaces/IEstateDataService.cs | 6 + .../Framework/Interfaces/IEstateDataStore.cs | 6 + .../BareBonesShared/BareBonesSharedModule.cs | 3 + .../Connectors/Simulation/EstateDataService.cs | 5 + 11 files changed, 268 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs index 92a8d80..d10ebe4 100644 --- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs +++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs @@ -372,6 +372,11 @@ namespace OpenSim.Data.MSSQL return new List(); } + public List GetEstatesByOwner(UUID ownerID) + { + return new List(); + } + public bool LinkRegion(UUID regionID, int estateID) { // TODO: Implementation! diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 6d72e82..86416d1 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -484,6 +484,36 @@ namespace OpenSim.Data.MySQL return result; } + public List GetEstatesByOwner(UUID ownerID) + { + List result = new List(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select estateID from estate_settings where EstateOwner = ?EstateOwner"; + cmd.Parameters.AddWithValue("?EstateOwner", ownerID); + + using (IDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + { + result.Add(Convert.ToInt32(reader["EstateID"])); + } + reader.Close(); + } + } + + + dbcon.Close(); + } + + return result; + } + public bool LinkRegion(UUID regionID, int estateID) { using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs index 6afc540..2f05a6e 100644 --- a/OpenSim/Data/SQLite/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs @@ -412,6 +412,28 @@ namespace OpenSim.Data.SQLite return result; } + public List GetEstatesByOwner(UUID ownerID) + { + List result = new List(); + + string sql = "select EstateID from estate_settings where estate_settings.EstateOwner = :EstateOwner"; + + SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + + cmd.CommandText = sql; + cmd.Parameters.AddWithValue(":EstateOwner", ownerID); + + IDataReader r = cmd.ExecuteReader(); + + while (r.Read()) + { + result.Add(Convert.ToInt32(r["EstateID"])); + } + r.Close(); + + return result; + } + public bool LinkRegion(UUID regionID, int estateID) { SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs index ad28c00..4dd225f 100644 --- a/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs @@ -401,7 +401,29 @@ namespace OpenSim.Data.SQLiteLegacy return result; } - + + public List GetEstatesByOwner(UUID ownerID) + { + List result = new List(); + + string sql = "select EstateID from estate_settings where estate_settings.EstateOwner = :EstateOwner"; + + SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + + cmd.CommandText = sql; + cmd.Parameters.Add(":EstateOwner", ownerID); + + IDataReader r = cmd.ExecuteReader(); + + while (r.Read()) + { + result.Add(Convert.ToInt32(r["EstateID"])); + } + r.Close(); + + return result; + } + public bool LinkRegion(UUID regionID, int estateID) { SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 2faffae..f8a0e07 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -8809,13 +8809,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP case "instantmessage": if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) { - if (messagePacket.ParamList.Length < 5) + if (messagePacket.ParamList.Length < 2) return true; + UUID invoice = messagePacket.MethodData.Invoice; - UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); - string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter); - string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter); UUID sessionID = messagePacket.AgentData.SessionID; + + UUID SenderID; + string SenderName; + string Message; + + if (messagePacket.ParamList.Length < 5) + { + SenderID = AgentId; + SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter); + Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter); + } + else + { + SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); + SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter); + Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter); + } + OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message); } return true; 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 } Scene.RegionInfo.RegionSettings.Save(); TriggerRegionInfoChange(); + sendRegionHandshakeToAll(); sendRegionInfoPacketToAll(); } private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient) { - sendRegionHandshakeToAll(); + // sendRegionHandshakeToAll(); } public void setRegionTerrainSettings(float WaterHeight, @@ -274,8 +275,25 @@ namespace OpenSim.Region.CoreModules.World.Estate { if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) { + if ((estateAccessType & 1) != 0) // All estates + { + List estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); + EstateSettings estateSettings; + + foreach (int estateID in estateIDs) + { + if (estateID != Scene.RegionInfo.EstateSettings.EstateID) + { + estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); + estateSettings.AddEstateUser(user); + estateSettings.Save(); + } + } + } + Scene.RegionInfo.EstateSettings.AddEstateUser(user); Scene.RegionInfo.EstateSettings.Save(); + TriggerEstateInfoChange(); remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID); } @@ -289,10 +307,26 @@ namespace OpenSim.Region.CoreModules.World.Estate { if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) { + if ((estateAccessType & 1) != 0) // All estates + { + List estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); + EstateSettings estateSettings; + + foreach (int estateID in estateIDs) + { + if (estateID != Scene.RegionInfo.EstateSettings.EstateID) + { + estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); + estateSettings.RemoveEstateUser(user); + estateSettings.Save(); + } + } + } + Scene.RegionInfo.EstateSettings.RemoveEstateUser(user); Scene.RegionInfo.EstateSettings.Save(); - TriggerEstateInfoChange(); + TriggerEstateInfoChange(); remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID); } else @@ -304,8 +338,25 @@ namespace OpenSim.Region.CoreModules.World.Estate { if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) { + if ((estateAccessType & 1) != 0) // All estates + { + List estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); + EstateSettings estateSettings; + + foreach (int estateID in estateIDs) + { + if (estateID != Scene.RegionInfo.EstateSettings.EstateID) + { + estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); + estateSettings.AddEstateGroup(user); + estateSettings.Save(); + } + } + } + Scene.RegionInfo.EstateSettings.AddEstateGroup(user); Scene.RegionInfo.EstateSettings.Save(); + TriggerEstateInfoChange(); remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID); } @@ -318,10 +369,26 @@ namespace OpenSim.Region.CoreModules.World.Estate { if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) { + if ((estateAccessType & 1) != 0) // All estates + { + List estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); + EstateSettings estateSettings; + + foreach (int estateID in estateIDs) + { + if (estateID != Scene.RegionInfo.EstateSettings.EstateID) + { + estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); + estateSettings.RemoveEstateGroup(user); + estateSettings.Save(); + } + } + } + Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user); Scene.RegionInfo.EstateSettings.Save(); - TriggerEstateInfoChange(); + TriggerEstateInfoChange(); remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID); } else @@ -349,6 +416,29 @@ namespace OpenSim.Region.CoreModules.World.Estate if (!alreadyInList) { + if ((estateAccessType & 1) != 0) // All estates + { + List estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); + EstateSettings estateSettings; + + foreach (int estateID in estateIDs) + { + if (estateID != Scene.RegionInfo.EstateSettings.EstateID) + { + EstateBan bitem = new EstateBan(); + + bitem.BannedUserID = user; + bitem.EstateID = (uint)estateID; + bitem.BannedHostAddress = "0.0.0.0"; + bitem.BannedHostIPMask = "0.0.0.0"; + + estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); + estateSettings.AddBan(bitem); + estateSettings.Save(); + } + } + } + EstateBan item = new EstateBan(); item.BannedUserID = user; @@ -358,6 +448,7 @@ namespace OpenSim.Region.CoreModules.World.Estate Scene.RegionInfo.EstateSettings.AddBan(item); Scene.RegionInfo.EstateSettings.Save(); + TriggerEstateInfoChange(); ScenePresence s = Scene.GetScenePresence(user); @@ -403,8 +494,25 @@ namespace OpenSim.Region.CoreModules.World.Estate if (alreadyInList && listitem != null) { + if ((estateAccessType & 1) != 0) // All estates + { + List estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); + EstateSettings estateSettings; + + foreach (int estateID in estateIDs) + { + if (estateID != Scene.RegionInfo.EstateSettings.EstateID) + { + estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); + estateSettings.RemoveBan(user); + estateSettings.Save(); + } + } + } + Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID); Scene.RegionInfo.EstateSettings.Save(); + TriggerEstateInfoChange(); } else @@ -424,8 +532,25 @@ namespace OpenSim.Region.CoreModules.World.Estate { if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) { + if ((estateAccessType & 1) != 0) // All estates + { + List estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); + EstateSettings estateSettings; + + foreach (int estateID in estateIDs) + { + if (estateID != Scene.RegionInfo.EstateSettings.EstateID) + { + estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); + estateSettings.AddEstateManager(user); + estateSettings.Save(); + } + } + } + Scene.RegionInfo.EstateSettings.AddEstateManager(user); Scene.RegionInfo.EstateSettings.Save(); + TriggerEstateInfoChange(); remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID); } @@ -438,10 +563,26 @@ namespace OpenSim.Region.CoreModules.World.Estate { if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) { + if ((estateAccessType & 1) != 0) // All estates + { + List estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner); + EstateSettings estateSettings; + + foreach (int estateID in estateIDs) + { + if (estateID != Scene.RegionInfo.EstateSettings.EstateID) + { + estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); + estateSettings.RemoveEstateManager(user); + estateSettings.Save(); + } + } + } + Scene.RegionInfo.EstateSettings.RemoveEstateManager(user); Scene.RegionInfo.EstateSettings.Save(); - TriggerEstateInfoChange(); + TriggerEstateInfoChange(); remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID); } else 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 m_SunFixedHour = FixedSunHour; m_SunFixed = FixedSun; - m_log.DebugFormat("[SUN]: Sun Settings Update: Fixed Sun? : {0}", m_SunFixed.ToString()); - m_log.DebugFormat("[SUN]: Sun Settings Update: Sun Hour : {0}", m_SunFixedHour.ToString()); + // m_log.DebugFormat("[SUN]: Sun Settings Update: Fixed Sun? : {0}", m_SunFixed.ToString()); + // m_log.DebugFormat("[SUN]: Sun Settings Update: Sun Hour : {0}", m_SunFixedHour.ToString()); receivedEstateToolsSunUpdate = true; @@ -480,7 +480,7 @@ namespace OpenSim.Region.CoreModules // When sun settings are updated, we should update all clients with new settings. SunUpdateToAllClients(); - m_log.DebugFormat("[SUN]: PosTime : {0}", PosTime.ToString()); + // m_log.DebugFormat("[SUN]: PosTime : {0}", PosTime.ToString()); } } diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs index 38c10a6..7066cf2 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs @@ -71,6 +71,12 @@ namespace OpenSim.Region.Framework.Interfaces List GetEstates(string search); /// + /// Get the IDs of all estates owned by the given user. + /// + /// An empty list if no estates were found. + List GetEstatesByOwner(UUID ownerID); + + /// /// Get the IDs of all estates. /// /// An empty list if no estates were found. diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs index c82661d..d790a30 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs @@ -74,6 +74,12 @@ namespace OpenSim.Region.Framework.Interfaces /// Name of estate to search for. This is the exact name, no parttern matching is done. /// List GetEstates(string search); + + /// + /// Get the IDs of all estates owned by the given user. + /// + /// An empty list if no estates were found. + List GetEstatesByOwner(UUID ownerID); /// /// Get the IDs of all estates. 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; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +[assembly: Addin("BareBonesSharedModule", "0.1")] +[assembly: AddinDependency("OpenSim", "0.5")] + namespace OpenSim.Region.OptionalModules.Example.BareBonesShared { /// diff --git a/OpenSim/Services/Connectors/Simulation/EstateDataService.cs b/OpenSim/Services/Connectors/Simulation/EstateDataService.cs index d0588bf..7184ba1 100644 --- a/OpenSim/Services/Connectors/Simulation/EstateDataService.cs +++ b/OpenSim/Services/Connectors/Simulation/EstateDataService.cs @@ -111,6 +111,11 @@ namespace OpenSim.Services.Connectors return m_database.GetEstatesAll(); } + public List GetEstatesByOwner(UUID ownerID) + { + return m_database.GetEstatesByOwner(ownerID); + } + public bool LinkRegion(UUID regionID, int estateID) { return m_database.LinkRegion(regionID, estateID); -- cgit v1.1 From b2fbadeae82f0bdbfb3b7bdc8e14cb7f5b693092 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 4 Apr 2011 20:02:13 -0700 Subject: Updates NullStorage plugin. Thanks MisterBlue... --- OpenSim/Data/Null/NullEstateData.cs | 123 ++++++++++++++++++++++++++++++++ OpenSim/Data/Null/NullSimulationData.cs | 17 +++++ 2 files changed, 140 insertions(+) create mode 100755 OpenSim/Data/Null/NullEstateData.cs (limited to 'OpenSim') diff --git a/OpenSim/Data/Null/NullEstateData.cs b/OpenSim/Data/Null/NullEstateData.cs new file mode 100755 index 0000000..6ce7a36 --- /dev/null +++ b/OpenSim/Data/Null/NullEstateData.cs @@ -0,0 +1,123 @@ +/* + * 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; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework; +using OpenSim.Region.Framework.Interfaces; + +namespace OpenSim.Data.Null +{ + public class NullEstateStore : IEstateDataStore + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private string m_connectionString; + + protected virtual Assembly Assembly + { + get { return GetType().Assembly; } + } + + public NullEstateStore() + { + } + + public NullEstateStore(string connectionString) + { + Initialise(connectionString); + } + + public void Initialise(string connectionString) + { + m_connectionString = connectionString; + } + + private string[] FieldList + { + get { return new string[0]; } + } + + public EstateSettings LoadEstateSettings(UUID regionID, bool create) + { + // This fools the initialization caller into thinking an estate was fetched (a check in OpenSimBase). + // The estate info is pretty empty so don't try banning anyone. + EstateSettings oneEstate = new EstateSettings(); + oneEstate.EstateID = 1; + return oneEstate; + } + + public void StoreEstateSettings(EstateSettings es) + { + return; + } + + public EstateSettings LoadEstateSettings(int estateID) + { + return new EstateSettings(); + } + + public List LoadEstateSettingsAll() + { + List allEstateSettings = new List(); + allEstateSettings.Add(new EstateSettings()); + return allEstateSettings; + } + + public List GetEstatesAll() + { + List result = new List(); + return result; + } + + public List GetEstates(string search) + { + List result = new List(); + return result; + } + + public bool LinkRegion(UUID regionID, int estateID) + { + return false; + } + + public List GetRegions(int estateID) + { + List result = new List(); + return result; + } + + public bool DeleteEstate(int estateID) + { + return false; + } + } +} diff --git a/OpenSim/Data/Null/NullSimulationData.cs b/OpenSim/Data/Null/NullSimulationData.cs index eb4e313..e8d733b 100644 --- a/OpenSim/Data/Null/NullSimulationData.cs +++ b/OpenSim/Data/Null/NullSimulationData.cs @@ -38,6 +38,15 @@ namespace OpenSim.Data.Null /// public class NullSimulationData : ISimulationDataStore { + public NullSimulationData() + { + } + + public NullSimulationData(string connectionString) + { + Initialise(connectionString); + } + public void Initialise(string dbfile) { return; @@ -85,12 +94,20 @@ namespace OpenSim.Data.Null return new List(); } + Dictionary m_terrains = new Dictionary(); public void StoreTerrain(double[,] ter, UUID regionID) { + if (m_terrains.ContainsKey(regionID)) + m_terrains.Remove(regionID); + m_terrains.Add(regionID, ter); } public double[,] LoadTerrain(UUID regionID) { + if (m_terrains.ContainsKey(regionID)) + { + return m_terrains[regionID]; + } return null; } -- cgit v1.1 From 18e206d2ed5cc1828f2ada27ff4698bdc0b84352 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Mon, 4 Apr 2011 23:45:28 -0400 Subject: * Bugfix - Compile NullEstateData implement public List IEstateDataStore.GetEstatesByOwner(UUID) --- OpenSim/Data/Null/NullEstateData.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Data/Null/NullEstateData.cs b/OpenSim/Data/Null/NullEstateData.cs index 6ce7a36..0cebff5 100755 --- a/OpenSim/Data/Null/NullEstateData.cs +++ b/OpenSim/Data/Null/NullEstateData.cs @@ -119,5 +119,15 @@ namespace OpenSim.Data.Null { return false; } + + #region IEstateDataStore Members + + + public List GetEstatesByOwner(UUID ownerID) + { + return new List(); + } + + #endregion } } -- cgit v1.1 From c1dec225abd09efc5061b2ffd40996ad13fd16e9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Apr 2011 17:47:11 +0100 Subject: Handle the client's parcel info requests asynchronously rather than synchronously. Handling these synchronously kills the inbound packet loop if many requests are made for remote land and those requests are handled slowly or timeout (timeout is 10s) This can happen if a user searches for "land for sale" and then clicks many of the parcels in the list (or just presses down arrow to move through every entry). --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index f8a0e07..34d72ac 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4938,7 +4938,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest); AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false); AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest); - AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest, false); + AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest); AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false); AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false); AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false); -- cgit v1.1 From 3d400fc663104b6d899ee37afeb7f83c68af45d4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Apr 2011 18:24:23 +0100 Subject: If an object is selected, then don't include it in owner/group/others prim counts. This fixes the total prim count that the viewer displays when prims are selected - it appears to ignore the total that we pass it and adds up the counts separately. --- .../CoreModules/World/Land/PrimCountModule.cs | 31 +++++++++++++--------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index bc140ae..7a04eb1 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -206,25 +206,29 @@ namespace OpenSim.Region.CoreModules.World.Land else parcelCounts.Users[obj.OwnerID] = partCount; - if (landData.IsGroupOwned) + if (obj.IsSelected) { - if (obj.OwnerID == landData.GroupID) - parcelCounts.Owner += partCount; - else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID) - parcelCounts.Group += partCount; - else - parcelCounts.Others += partCount; + parcelCounts.Selected += partCount; } else { - if (obj.OwnerID == landData.OwnerID) - parcelCounts.Owner += partCount; + if (landData.IsGroupOwned) + { + if (obj.OwnerID == landData.GroupID) + parcelCounts.Owner += partCount; + else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID) + parcelCounts.Group += partCount; + else + parcelCounts.Others += partCount; + } else - parcelCounts.Others += partCount; + { + if (obj.OwnerID == landData.OwnerID) + parcelCounts.Owner += partCount; + else + parcelCounts.Others += partCount; + } } - - if (obj.IsSelected) - parcelCounts.Selected += partCount; } } @@ -380,6 +384,7 @@ namespace OpenSim.Region.CoreModules.World.Land count = counts.Owner; count += counts.Group; count += counts.Others; + count += counts.Selected; } } -- cgit v1.1 From dc6ce2444385730a3ea1ba1104f2e2caa15a907a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Apr 2011 20:31:52 +0100 Subject: switch llGetParcelPrimCount() to use new prim counts module --- .../Shared/Api/Implementation/LSL_Api.cs | 85 ++++++++++------------ 1 file changed, 39 insertions(+), 46 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 43b0da3..5f8ca91 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -9835,63 +9835,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetParcelPrimCount(LSL_Vector pos, int category, int sim_wide) { m_host.AddScriptLPS(1); + + ILandObject lo = World.LandChannel.GetLandObject((float)pos.x, (float)pos.y); + + //LandData land = World.GetLandData((float)pos.x, (float)pos.y); - LandData land = World.GetLandData((float)pos.x, (float)pos.y); + if (lo == null) + return 0; + + IPrimCounts pc = lo.PrimCounts; - if (land == null) + if (sim_wide != 0) { - return 0; + if (category == 0) + { + return pc.Simulator; + } + else + { + // counts not implemented yet + return 0; + } } - else { - if (sim_wide != 0) + if (category == 0)//Total Prims { - if (category == 0) - { - return land.SimwidePrims; - } - - else - { - //public int simwideArea = 0; - return 0; - } + return pc.Total; } - - else + else if (category == 1)//Owner Prims { - if (category == 0)//Total Prims - { - return 0;//land. - } - - else if (category == 1)//Owner Prims - { - return land.OwnerPrims; - } - - else if (category == 2)//Group Prims - { - return land.GroupPrims; - } - - else if (category == 3)//Other Prims - { - return land.OtherPrims; - } - - else if (category == 4)//Selected - { - return land.SelectedPrims; - } - - else if (category == 5)//Temp - { - return 0;//land. - } + return pc.Owner; + } + else if (category == 2)//Group Prims + { + return pc.Group; + } + else if (category == 3)//Other Prims + { + return pc.Others; + } + else if (category == 4)//Selected + { + return pc.Selected; + } + else if (category == 5)//Temp + { + return 0; // counts not implemented yet } } + return 0; } -- cgit v1.1 From f030ba8992a17553b5824955c95096b8326b23c8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Apr 2011 20:39:58 +0100 Subject: replace magic numbers in llGetParcelPrimCount() with constants --- .../Shared/Api/Implementation/LSL_Api.cs | 30 ++++++---------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5f8ca91..e5be641 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -9837,17 +9837,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); ILandObject lo = World.LandChannel.GetLandObject((float)pos.x, (float)pos.y); - - //LandData land = World.GetLandData((float)pos.x, (float)pos.y); if (lo == null) return 0; IPrimCounts pc = lo.PrimCounts; - if (sim_wide != 0) + if (sim_wide != ScriptBaseClass.FALSE) { - if (category == 0) + if (category == ScriptBaseClass.PARCEL_COUNT_TOTAL) { return pc.Simulator; } @@ -9859,30 +9857,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else { - if (category == 0)//Total Prims - { + if (category == ScriptBaseClass.PARCEL_COUNT_TOTAL) return pc.Total; - } - else if (category == 1)//Owner Prims - { + else if (category == ScriptBaseClass.PARCEL_COUNT_OWNER) return pc.Owner; - } - else if (category == 2)//Group Prims - { + else if (category == ScriptBaseClass.PARCEL_COUNT_GROUP) return pc.Group; - } - else if (category == 3)//Other Prims - { + else if (category == ScriptBaseClass.PARCEL_COUNT_OTHER) return pc.Others; - } - else if (category == 4)//Selected - { + else if (category == ScriptBaseClass.PARCEL_COUNT_SELECTED) return pc.Selected; - } - else if (category == 5)//Temp - { + else if (category == ScriptBaseClass.PARCEL_COUNT_TEMP) return 0; // counts not implemented yet - } } return 0; -- cgit v1.1 From 0e465da187c93e7ff21f91742f75ee9f3b76b04e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Apr 2011 21:25:54 +0100 Subject: remove now unused individual LandData prim counts. However, the calls to the land management module to record prims need to remain, since they were also being used to return owner object lists, etc. This is probably why prim counts were being done there in the first place. --- OpenSim/Framework/ILandChannel.cs | 1 - OpenSim/Framework/ILandObject.cs | 2 +- OpenSim/Framework/LandData.cs | 65 +---------------- .../Serialization/Tests/LandDataSerializerTests.cs | 8 +-- .../Region/CoreModules/World/Land/LandChannel.cs | 10 --- .../CoreModules/World/Land/LandManagementModule.cs | 39 +++------- .../Region/CoreModules/World/Land/LandObject.cs | 83 +++++----------------- OpenSim/Region/Framework/Scenes/Scene.cs | 14 ---- .../RegionCombinerLargeLandChannel.cs | 5 -- 9 files changed, 31 insertions(+), 196 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/ILandChannel.cs b/OpenSim/Framework/ILandChannel.cs index 30bae16..869d4c8 100644 --- a/OpenSim/Framework/ILandChannel.cs +++ b/OpenSim/Framework/ILandChannel.cs @@ -77,7 +77,6 @@ namespace OpenSim.Region.Framework.Interfaces /// void Clear(bool setupDefaultParcel); - bool IsLandPrimCountTainted(); bool IsForcefulBansAllowed(); void UpdateLandObject(int localID, LandData data); void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient); diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs index 931e24a..98ea01e 100644 --- a/OpenSim/Framework/ILandObject.cs +++ b/OpenSim/Framework/ILandObject.cs @@ -89,7 +89,7 @@ namespace OpenSim.Framework void SendForceObjectSelect(int local_id, int request_type, List returnIDs, IClientAPI remote_client); void SendLandObjectOwners(IClientAPI remote_client); void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client); - void ResetLandPrimCounts(); + void ResetOverMeRecord(); void UpdateLandSold(UUID avatarID, UUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area); void DeedToGroup(UUID groupID); diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs index a9a493d..145ccdd 100644 --- a/OpenSim/Framework/LandData.cs +++ b/OpenSim/Framework/LandData.cs @@ -54,12 +54,10 @@ namespace OpenSim.Framework private int _claimPrice = 0; //Unemplemented private UUID _globalID = UUID.Zero; private UUID _groupID = UUID.Zero; - private int _groupPrims = 0; private bool _isGroupOwned = false; private byte[] _bitmap = new byte[512]; private string _description = String.Empty; - private uint _flags = (uint) ParcelFlags.AllowFly | (uint) ParcelFlags.AllowLandmark | (uint) ParcelFlags.AllowAPrimitiveEntry | (uint) ParcelFlags.AllowDeedToGroup | (uint) ParcelFlags.AllowTerraform | @@ -72,17 +70,13 @@ namespace OpenSim.Framework private int _localID = 0; private byte _mediaAutoScale = 0; private UUID _mediaID = UUID.Zero; - private string _mediaURL = String.Empty; private string _musicURL = String.Empty; - private int _otherPrims = 0; private UUID _ownerID = UUID.Zero; - private int _ownerPrims = 0; private List _parcelAccessList = new List(); private float _passHours = 0; private int _passPrice = 0; private int _salePrice = 0; //Unemeplemented. Parcels price. - private int _selectedPrims = 0; private int _simwideArea = 0; private int _simwidePrims = 0; private UUID _snapshotID = UUID.Zero; @@ -284,19 +278,6 @@ namespace OpenSim.Framework } /// - /// Number of SceneObjectPart that are owned by a Group - /// - [XmlIgnore] - public int GroupPrims { - get { - return _groupPrims; - } - set { - _groupPrims = value; - } - } - - /// /// Returns true if the Land Parcel is owned by a group /// public bool IsGroupOwned { @@ -454,20 +435,6 @@ namespace OpenSim.Framework } /// - /// Number of SceneObjectPart that are owned by users who do not own the parcel - /// and don't have the 'group. These are elegable for AutoReturn collection - /// - [XmlIgnore] - public int OtherPrims { - get { - return _otherPrims; - } - set { - _otherPrims = value; - } - } - - /// /// Owner Avatar or Group of the parcel. Naturally, all land masses must be /// owned by someone /// @@ -481,19 +448,6 @@ namespace OpenSim.Framework } /// - /// Number of SceneObjectPart that are owned by the owner of the parcel - /// - [XmlIgnore] - public int OwnerPrims { - get { - return _ownerPrims; - } - set { - _ownerPrims = value; - } - } - - /// /// List of access data for the parcel. User data, some bitflags, and a time /// public List ParcelAccessList { @@ -542,19 +496,6 @@ namespace OpenSim.Framework } /// - /// Number of SceneObjectPart that are currently selected by avatar - /// - [XmlIgnore] - public int SelectedPrims { - get { - return _selectedPrims; - } - set { - _selectedPrims = value; - } - } - - /// /// Number of meters^2 in the Simulator /// [XmlIgnore] @@ -666,10 +607,6 @@ namespace OpenSim.Framework landData._claimPrice = _claimPrice; landData._globalID = _globalID; landData._groupID = _groupID; - landData._groupPrims = _groupPrims; - landData._otherPrims = _otherPrims; - landData._ownerPrims = _ownerPrims; - landData._selectedPrims = _selectedPrims; landData._isGroupOwned = _isGroupOwned; landData._localID = _localID; landData._landingType = _landingType; @@ -731,4 +668,4 @@ namespace OpenSim.Framework return land; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs index 70e87b3..c69c89d 100644 --- a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs +++ b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs @@ -42,10 +42,7 @@ namespace OpenSim.Framework.Serialization.Tests private LandData landWithParcelAccessList; private static string preSerialized = "\n\n 128\n 0\n 00000000-0000-0000-0000-000000000000\n 10\n 0\n 0\n 54ff9641-dd40-4a2c-b1f1-47dd3af24e50\n d740204e-bbbf-44aa-949d-02c7d739f6a5\n False\n AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n land data to test LandDataSerializer\n 536870944\n 2\n LandDataSerializerTest Land\n 0\n 0\n 1\n d4452578-2f25-4b97-a81b-819af559cfd7\n http://videos.opensimulator.org/bumblebee.mp4\n \n 1b8eedf9-6d15-448b-8015-24286f1756bf\n \n 0\n 0\n 0\n 00000000-0000-0000-0000-000000000000\n <0, 0, 0>\n <0, 0, 0>\n 0\n 0\n"; - private static string preSerializedWithParcelAccessList = "\n\n 128\n 0\n 00000000-0000-0000-0000-000000000000\n 10\n 0\n 0\n 54ff9641-dd40-4a2c-b1f1-47dd3af24e50\n d740204e-bbbf-44aa-949d-02c7d739f6a5\n False\n AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n land data to test LandDataSerializer\n 536870944\n 2\n LandDataSerializerTest Land\n 0\n 0\n 1\n d4452578-2f25-4b97-a81b-819af559cfd7\n http://videos.opensimulator.org/bumblebee.mp4\n \n 1b8eedf9-6d15-448b-8015-24286f1756bf\n \n \n 62d65d45-c91a-4f77-862c-46557d978b6c\n \n 2\n \n \n ec2a8d18-2378-4fe0-8b68-2a31b57c481e\n \n 1\n \n \n 0\n 0\n 0\n 00000000-0000-0000-0000-000000000000\n <0, 0, 0>\n <0, 0, 0>\n 0\n 0\n"; - - - + private static string preSerializedWithParcelAccessList = "\n\n 128\n 0\n 00000000-0000-0000-0000-000000000000\n 10\n 0\n 0\n 54ff9641-dd40-4a2c-b1f1-47dd3af24e50\n d740204e-bbbf-44aa-949d-02c7d739f6a5\n False\n AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n land data to test LandDataSerializer\n 536870944\n 2\n LandDataSerializerTest Land\n 0\n 0\n 1\n d4452578-2f25-4b97-a81b-819af559cfd7\n http://videos.opensimulator.org/bumblebee.mp4\n \n 1b8eedf9-6d15-448b-8015-24286f1756bf\n \n \n 62d65d45-c91a-4f77-862c-46557d978b6c\n \n 2\n \n \n ec2a8d18-2378-4fe0-8b68-2a31b57c481e\n \n 1\n \n \n 0\n 0\n 0\n 00000000-0000-0000-0000-000000000000\n <0, 0, 0>\n <0, 0, 0>\n 0\n 0\n"; [SetUp] public void setup() @@ -62,7 +59,6 @@ namespace OpenSim.Framework.Serialization.Tests this.land.ClaimPrice = 0; this.land.GlobalID = new UUID("54ff9641-dd40-4a2c-b1f1-47dd3af24e50"); this.land.GroupID = new UUID("d740204e-bbbf-44aa-949d-02c7d739f6a5"); - this.land.GroupPrims = 0; this.land.Description = "land data to test LandDataSerializer"; this.land.Flags = (uint)(ParcelFlags.AllowDamage | ParcelFlags.AllowVoiceChat); this.land.LandingType = (byte)LandingType.Direct; @@ -132,4 +128,4 @@ namespace OpenSim.Framework.Serialization.Tests "Reified LandData.Name != original LandData.Name (pre-serialized with parcel access list)"); } } -} +} \ No newline at end of file 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 return new List(); } - public bool IsLandPrimCountTainted() - { - if (m_landManagementModule != null) - { - return m_landManagementModule.IsLandPrimCountTainted(); - } - - return false; - } - public bool IsForcefulBansAllowed() { if (m_landManagementModule != null) diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 2b5f7a0..adfac05 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -89,7 +89,6 @@ namespace OpenSim.Region.CoreModules.World.Land /// private readonly Dictionary m_landList = new Dictionary(); - private bool m_landPrimCountTainted; private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; private bool m_allowedForcefulBans = true; @@ -122,18 +121,18 @@ namespace OpenSim.Region.CoreModules.World.Land m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd; m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate; + m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene; + m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate; + m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel; m_scene.EventManager.OnClientMovement += EventManagerOnClientMovement; m_scene.EventManager.OnValidateLandBuy += EventManagerOnValidateLandBuy; m_scene.EventManager.OnLandBuy += EventManagerOnLandBuy; m_scene.EventManager.OnNewClient += EventManagerOnNewClient; m_scene.EventManager.OnSignificantClientMovement += EventManagerOnSignificantClientMovement; - m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene; m_scene.EventManager.OnNoticeNoLandDataFromStorage += EventManagerOnNoLandDataFromStorage; m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage; - m_scene.EventManager.OnSetAllowForcefulBan += EventManagerOnSetAllowedForcefulBan; - m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate; - m_scene.EventManager.OnParcelPrimCountTainted += EventManagerOnParcelPrimCountTainted; + m_scene.EventManager.OnSetAllowForcefulBan += EventManagerOnSetAllowedForcefulBan; m_scene.EventManager.OnRegisterCaps += EventManagerOnRegisterCaps; m_scene.EventManager.OnPluginConsole += EventManagerOnPluginConsole; @@ -779,34 +778,24 @@ namespace OpenSim.Region.CoreModules.World.Land #region Parcel Modification - public void ResetAllLandPrimCounts() + public void ResetOverMeRecord() { lock (m_landList) { foreach (LandObject p in m_landList.Values) { - p.ResetLandPrimCounts(); + p.ResetOverMeRecord(); } } } - public void EventManagerOnParcelPrimCountTainted() - { - m_landPrimCountTainted = true; - } - - public bool IsLandPrimCountTainted() - { - return m_landPrimCountTainted; - } - public void EventManagerOnParcelPrimCountAdd(SceneObjectGroup obj) { Vector3 position = obj.AbsolutePosition; ILandObject landUnderPrim = GetLandObject(position.X, position.Y); if (landUnderPrim != null) { - ((LandObject)landUnderPrim).AddPrimToCount(obj); + ((LandObject)landUnderPrim).AddPrimOverMe(obj); } } @@ -816,7 +805,7 @@ namespace OpenSim.Region.CoreModules.World.Land { foreach (LandObject p in m_landList.Values) { - p.RemovePrimFromCount(obj); + p.RemovePrimFromOverMe(obj); } } } @@ -849,8 +838,7 @@ namespace OpenSim.Region.CoreModules.World.Land foreach (LandObject p in landOwnersAndParcels[owner]) { simArea += p.LandData.Area; - simPrims += p.LandData.OwnerPrims + p.LandData.OtherPrims + p.LandData.GroupPrims + - p.LandData.SelectedPrims; + simPrims += p.PrimCounts.Total; } foreach (LandObject p in landOwnersAndParcels[owner]) @@ -867,7 +855,7 @@ namespace OpenSim.Region.CoreModules.World.Land // "[LAND MANAGEMENT MODULE]: Triggered EventManagerOnParcelPrimCountUpdate() for {0}", // m_scene.RegionInfo.RegionName); - ResetAllLandPrimCounts(); + ResetOverMeRecord(); EntityBase[] entities = m_scene.Entities.GetEntities(); foreach (EntityBase obj in entities) { @@ -880,15 +868,13 @@ namespace OpenSim.Region.CoreModules.World.Land } } FinalizeLandPrimCountUpdate(); - m_landPrimCountTainted = false; } public void EventManagerOnRequestParcelPrimCountUpdate() { - ResetAllLandPrimCounts(); + ResetOverMeRecord(); m_scene.EventManager.TriggerParcelPrimCountUpdate(); FinalizeLandPrimCountUpdate(); - m_landPrimCountTainted = false; } /// @@ -952,8 +938,6 @@ namespace OpenSim.Region.CoreModules.World.Land m_landList[startLandObjectIndex].ForceUpdateLandInfo(); } - EventManagerOnParcelPrimCountTainted(); - //Now add the new land object ILandObject result = AddLandObject(newLand); UpdateLandObject(startLandObject.LandData.LocalID, startLandObject.LandData); @@ -1020,7 +1004,6 @@ namespace OpenSim.Region.CoreModules.World.Land performFinalLandJoin(masterLandObject, slaveLandObject); } } - EventManagerOnParcelPrimCountTainted(); masterLandObject.SendLandUpdateToAvatarsOverMe(); } diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index e7bdb19..9803bdf 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -64,8 +64,6 @@ namespace OpenSim.Region.CoreModules.World.Land #endregion - #region ILandObject Members - public int GetPrimsFree() { m_scene.EventManager.TriggerParcelPrimCountUpdate(); @@ -213,6 +211,7 @@ namespace OpenSim.Region.CoreModules.World.Land return simMax; } } + #endregion #region Packet Request Handling @@ -909,9 +908,12 @@ namespace OpenSim.Region.CoreModules.World.Land lock (primsOverMe) { +// m_log.DebugFormat( +// "[LAND OBJECT]: Request for SendLandObjectOwners() from {0} with {1} known prims on region", +// remote_client.Name, primsOverMe.Count); + try { - foreach (SceneObjectGroup obj in primsOverMe) { try @@ -950,6 +952,7 @@ namespace OpenSim.Region.CoreModules.World.Land public Dictionary GetLandObjectOwners() { Dictionary ownersAndCount = new Dictionary(); + lock (primsOverMe) { try @@ -986,8 +989,10 @@ namespace OpenSim.Region.CoreModules.World.Land public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client) { - Dictionary> returns = - new Dictionary>(); +// m_log.DebugFormat( +// "[LAND OBJECT]: Request to return objects in {0} from {1}", LandData.Name, remote_client.Name); + + Dictionary> returns = new Dictionary>(); lock (primsOverMe) { @@ -1060,83 +1065,25 @@ namespace OpenSim.Region.CoreModules.World.Land #region Object Adding/Removing from Parcel - public void ResetLandPrimCounts() + public void ResetOverMeRecord() { - LandData.GroupPrims = 0; - LandData.OwnerPrims = 0; - LandData.OtherPrims = 0; - LandData.SelectedPrims = 0; - - lock (primsOverMe) primsOverMe.Clear(); } - public void AddPrimToCount(SceneObjectGroup obj) + public void AddPrimOverMe(SceneObjectGroup obj) { - - UUID prim_owner = obj.OwnerID; - int prim_count = obj.PrimCount; - - if (obj.IsSelected) - { - LandData.SelectedPrims += prim_count; - } - else - { - if (prim_owner == LandData.OwnerID) - { - LandData.OwnerPrims += prim_count; - } - else if ((obj.GroupID == LandData.GroupID || - prim_owner == LandData.GroupID) && - LandData.GroupID != UUID.Zero) - { - LandData.GroupPrims += prim_count; - } - else - { - LandData.OtherPrims += prim_count; - } - } - lock (primsOverMe) primsOverMe.Add(obj); } - public void RemovePrimFromCount(SceneObjectGroup obj) + public void RemovePrimFromOverMe(SceneObjectGroup obj) { lock (primsOverMe) - { - if (primsOverMe.Contains(obj)) - { - UUID prim_owner = obj.OwnerID; - int prim_count = obj.PrimCount; - - if (prim_owner == LandData.OwnerID) - { - LandData.OwnerPrims -= prim_count; - } - else if (obj.GroupID == LandData.GroupID || - prim_owner == LandData.GroupID) - { - LandData.GroupPrims -= prim_count; - } - else - { - LandData.OtherPrims -= prim_count; - } - - primsOverMe.Remove(obj); - } - } + primsOverMe.Remove(obj); } #endregion - - #endregion - - #endregion /// /// Set the media url for this land parcel @@ -1157,5 +1104,7 @@ namespace OpenSim.Region.CoreModules.World.Land LandData.MusicURL = url; SendLandUpdateToAvatarsOverMe(); } + + #endregion } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 35a798e..a62d6d7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1428,20 +1428,6 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Recount SceneObjectPart in parcel aabb - /// - private void UpdateLand() - { - if (LandChannel != null) - { - if (LandChannel.IsLandPrimCountTainted()) - { - EventManager.TriggerParcelPrimCountUpdate(); - } - } - } - - /// /// Update the terrain if it needs to be updated. /// private void UpdateTerrain() 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 } } - public bool IsLandPrimCountTainted() - { - return RootRegionLandChannel.IsLandPrimCountTainted(); - } - public bool IsForcefulBansAllowed() { return RootRegionLandChannel.IsForcefulBansAllowed(); -- cgit v1.1 From acacee98c6e4398b0ea808f23333a31689966133 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Apr 2011 22:15:06 +0100 Subject: properly refresh object owner list when refresh button is hit on land parcel object tab --- .../CoreModules/World/Land/LandManagementModule.cs | 17 +++++++++-------- OpenSim/Region/CoreModules/World/Land/LandObject.cs | 6 +++++- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index adfac05..abc7a3a 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 public class LandManagementModule : INonSharedRegionModule { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly string remoteParcelRequestPath = "0009/"; @@ -307,8 +306,8 @@ 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); + 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)); @@ -778,7 +777,7 @@ namespace OpenSim.Region.CoreModules.World.Land #region Parcel Modification - public void ResetOverMeRecord() + public void ResetOverMeRecords() { lock (m_landList) { @@ -855,7 +854,7 @@ namespace OpenSim.Region.CoreModules.World.Land // "[LAND MANAGEMENT MODULE]: Triggered EventManagerOnParcelPrimCountUpdate() for {0}", // m_scene.RegionInfo.RegionName); - ResetOverMeRecord(); + ResetOverMeRecords(); EntityBase[] entities = m_scene.Entities.GetEntities(); foreach (EntityBase obj in entities) { @@ -872,7 +871,7 @@ namespace OpenSim.Region.CoreModules.World.Land public void EventManagerOnRequestParcelPrimCountUpdate() { - ResetOverMeRecord(); + ResetOverMeRecords(); m_scene.EventManager.TriggerParcelPrimCountUpdate(); FinalizeLandPrimCountUpdate(); } @@ -1193,6 +1192,7 @@ namespace OpenSim.Region.CoreModules.World.Land if (land != null) { + m_scene.EventManager.TriggerParcelPrimCountUpdate(); m_landList[local_id].SendLandObjectOwners(remote_client); } else @@ -1424,7 +1424,8 @@ namespace OpenSim.Region.CoreModules.World.Land private string ProcessPropertiesUpdate(string request, string path, string param, UUID agentID, Caps caps) { IClientAPI client; - if (! m_scene.TryGetClient(agentID, out client)) { + if (!m_scene.TryGetClient(agentID, out client)) + { m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to retrieve IClientAPI for {0}", agentID); return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); } diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 9803bdf..c4fb11e 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -925,7 +925,7 @@ namespace OpenSim.Region.CoreModules.World.Land } catch (NullReferenceException) { - m_log.Info("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel"); + m_log.Error("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel"); } try { @@ -1073,12 +1073,16 @@ namespace OpenSim.Region.CoreModules.World.Land public void AddPrimOverMe(SceneObjectGroup obj) { +// m_log.DebugFormat("[LAND OBJECT]: Adding scene object {0} {1} over {2}", obj.Name, obj.LocalId, LandData.Name); + lock (primsOverMe) primsOverMe.Add(obj); } public void RemovePrimFromOverMe(SceneObjectGroup obj) { +// m_log.DebugFormat("[LAND OBJECT]: Removing scene object {0} {1} from over {2}", obj.Name, obj.LocalId, LandData.Name); + lock (primsOverMe) primsOverMe.Remove(obj); } -- cgit v1.1 From 2497962360258eb6cb1a78c7b4d5227d88eabb87 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Apr 2011 22:25:00 +0100 Subject: Change some text to make the autoreturn mechanism more obvious, and align with the fact that it's one word rather than two. --- OpenSim/Framework/LandData.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 5 ++++- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs index 145ccdd..c107143 100644 --- a/OpenSim/Framework/LandData.cs +++ b/OpenSim/Framework/LandData.cs @@ -560,7 +560,7 @@ namespace OpenSim.Framework } /// - /// Number of minutes to return SceneObjectGroup that are owned by someone who doesn't own + /// Autoreturn number of minutes to return SceneObjectGroup that are owned by someone who doesn't own /// the parcel and isn't set to the same 'group' as the parcel. /// public int OtherCleanTime { diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a62d6d7..f0acc38 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1521,8 +1521,11 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Return object to avatar Message + /// Tell an agent that their object has been returned. /// + /// + /// The actual return is handled by the caller. + /// /// Avatar Unique Id /// Name of object returned /// Location of object returned diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f17fb28..a7107f0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1313,8 +1313,10 @@ namespace OpenSim.Region.Framework.Scenes parcel.LandData.OtherCleanTime) { DetachFromBackup(); - m_log.InfoFormat("[SCENE]: Returning object {0} due to parcel auto return", RootPart.UUID.ToString()); - m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel auto return"); + m_log.DebugFormat( + "[SCENE OBJECT GROUP]: Returning object {0} due to parcel autoreturn", + RootPart.UUID); + m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel autoreturn"); m_scene.DeRezObjects(null, new List() { RootPart.LocalId }, UUID.Zero, DeRezAction.Return, UUID.Zero); -- cgit v1.1 From fa202a05e914395d5a1facf8bdadb6a553516bfe Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 6 Apr 2011 17:19:31 +0100 Subject: Add method doc to some land bitmap methods in ILandObject. Also changes prim count tests to use the correct upper region bounds, though the method actually ignores the overage. --- OpenSim/Framework/ILandObject.cs | 18 ++++++++ .../Region/CoreModules/World/Land/LandObject.cs | 14 +----- .../World/Land/Tests/PrimCountModuleTests.cs | 52 +++++++++++++++++++--- 3 files changed, 66 insertions(+), 18 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs index 98ea01e..02775e9 100644 --- a/OpenSim/Framework/ILandObject.cs +++ b/OpenSim/Framework/ILandObject.cs @@ -82,8 +82,26 @@ namespace OpenSim.Framework void ForceUpdateLandInfo(); void SetLandBitmap(bool[,] bitmap); + /// + /// Get a land bitmap that would cover an entire region. + /// + /// The bitmap created. bool[,] BasicFullRegionLandBitmap(); + + /// + /// Create a square land bitmap. + /// + /// + /// Land co-ordinates are zero indexed. At the moment, the smallest parcel of land is 4m x 4m, so if the + /// region is 256 x 256m (the SL size), the largest land parcel starts at (0,0) and ends at (63,63). + /// + /// + /// + /// + /// + /// The bitmap created. bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y); + bool[,] ModifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value); bool[,] MergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add); void SendForceObjectSelect(int local_id, int request_type, List returnIDs, IClientAPI remote_client); diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index c4fb11e..c2f104e 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -701,23 +701,11 @@ namespace OpenSim.Region.CoreModules.World.Land return LandBitmap; } - /// - /// Full sim land object creation - /// - /// public bool[,] BasicFullRegionLandBitmap() { return GetSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize); } - - /// - /// Used to modify the bitmap between the x and y points. Points use 64 scale - /// - /// - /// - /// - /// - /// + public bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y) { bool[,] tempBitmap = new bool[64,64]; diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index f006db2..4acba18 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -49,6 +49,10 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests protected UUID m_otherUserId = new UUID("99999999-9999-9999-9999-999999999999"); protected TestScene m_scene; protected PrimCountModule m_pcm; + + /// + /// A parcel that covers the entire sim. + /// protected ILandObject m_lo; [SetUp] @@ -60,9 +64,9 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm); 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); + lo.SetLandBitmap( + lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize / 4 - 1, (int)Constants.RegionSize / 4 - 1)); + m_lo = lmm.AddLandObject(lo); } /// @@ -124,7 +128,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests /// Test count after a parcel owner owned copied object is added. /// [Test] - public void TestCopiedOwnerObject() + public void TestCopyOwnerObject() { TestHelper.InMethod(); // log4net.Config.XmlConfigurator.Configure(); @@ -143,7 +147,45 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Users[m_userId], Is.EqualTo(6)); Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); Assert.That(pc.Simulator, Is.EqualTo(6)); - } + } + + /// + /// Test that parcel counts update correctly when an object is moved between parcels, where that movement + /// is not done directly by the user/ + /// + //[Test] + public void TestMoveOwnerObject() + { +// TestHelper.InMethod(); +//// log4net.Config.XmlConfigurator.Configure(); +// +// IPrimCounts pc = m_lo.PrimCounts; +// +// SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); +// m_scene.AddNewSceneObject(sog, false); +// +// Assert.That(pc.Owner, Is.EqualTo(3)); +// Assert.That(pc.Group, Is.EqualTo(0)); +// Assert.That(pc.Others, Is.EqualTo(0)); +// Assert.That(pc.Total, Is.EqualTo(3)); +// Assert.That(pc.Selected, Is.EqualTo(0)); +// Assert.That(pc.Users[m_userId], Is.EqualTo(3)); +// Assert.That(pc.Users[m_otherUserId], 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(pc.Owner, Is.EqualTo(5)); +// Assert.That(pc.Group, Is.EqualTo(0)); +// Assert.That(pc.Others, Is.EqualTo(0)); +// Assert.That(pc.Total, Is.EqualTo(5)); +// Assert.That(pc.Selected, Is.EqualTo(0)); +// Assert.That(pc.Users[m_userId], Is.EqualTo(5)); +// Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); +// Assert.That(pc.Simulator, Is.EqualTo(5)); + } /// /// Test count after a parcel owner owned object is removed. -- cgit v1.1 From 63533412f882fd55c0c40989d97f8a8262bc4e3c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 6 Apr 2011 18:57:50 +0100 Subject: Improve previous ILandObject method doc. For test code, take a part name prefix when creating objects, so that these can be more easily identified in the logs --- OpenSim/Framework/ILandObject.cs | 8 +- .../CoreModules/World/Land/LandManagementModule.cs | 12 +++ .../CoreModules/World/Land/PrimCountModule.cs | 22 +++-- .../World/Land/Tests/PrimCountModuleTests.cs | 102 ++++++++++++--------- OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 16 +++- 5 files changed, 104 insertions(+), 56 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs index 02775e9..5a55b02 100644 --- a/OpenSim/Framework/ILandObject.cs +++ b/OpenSim/Framework/ILandObject.cs @@ -92,8 +92,12 @@ namespace OpenSim.Framework /// Create a square land bitmap. /// /// - /// Land co-ordinates are zero indexed. At the moment, the smallest parcel of land is 4m x 4m, so if the - /// region is 256 x 256m (the SL size), the largest land parcel starts at (0,0) and ends at (63,63). + /// Land co-ordinates are zero indexed. The inputs are treated as points. So if you want to create a bitmap + /// that covers an entire 256 x 256m region apart from a strip of land on the east, then you would need to + /// specify start_x = 0, start_y = 0, end_x = 252 (or anything up to 255), end_y = 256. + /// + /// At the moment, the smallest parcel of land is 4m x 4m, so if the + /// region is 256 x 256m (the SL size), the bitmap returned will start at (0,0) and end at (63,63). /// /// /// diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index abc7a3a..bfab7b8 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -612,6 +612,10 @@ namespace OpenSim.Region.CoreModules.World.Land { if (landBitmap[x, y]) { +// m_log.DebugFormat( +// "[LAND MANAGEMENT MODULE]: Registering parcel {0} for land co-ord ({1}, {2}) on {3}", +// new_land.LandData.Name, x, y, m_scene.RegionInfo.RegionName); + m_landIDList[x, y] = newLandLocalID; } } @@ -741,8 +745,16 @@ namespace OpenSim.Region.CoreModules.World.Land // Corner case. If an autoreturn happens during sim startup // we will come here with the list uninitialized // + int landId = m_landIDList[x, y]; + +// if (landId == 0) +// m_log.DebugFormat( +// "[LAND MANAGEMENT MODULE]: No land object found at ({0}, {1}) on {2}", +// x, y, m_scene.RegionInfo.RegionName); + if (m_landList.ContainsKey(m_landIDList[x, y])) return m_landList[m_landIDList[x, y]]; + return null; } } diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 7a04eb1..dca842a 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -173,24 +173,32 @@ 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} {1} to prim count", obj.Name, obj.UUID); - + { if (obj.IsAttachment) return; if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)) - return; + return; Vector3 pos = obj.AbsolutePosition; ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); // If for some reason there is no land object (perhaps the object is out of bounds) then we can't count it if (landObject == null) + { +// m_log.WarnFormat( +// "[PRIM COUNT MODULE]: Found no land object for {0} at position ({1}, {2}) on {3}", +// obj.Name, pos.X, pos.Y, m_Scene.RegionInfo.RegionName); + return; + } LandData landData = landObject.LandData; // m_log.DebugFormat( +// "[PRIM COUNT MODULE]: Adding object {0} with {1} parts to prim count for parcel {2} on {3}", +// obj.Name, obj.Parts.Length, landData.Name, m_Scene.RegionInfo.RegionName); + +// m_log.DebugFormat( // "[PRIM COUNT MODULE]: Object {0} is owned by {1} over land owned by {2}", // obj.Name, obj.OwnerID, landData.OwnerID); @@ -473,7 +481,9 @@ namespace OpenSim.Region.CoreModules.World.Land 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_log.DebugFormat( +// "[PRIM COUNT MODULE]: Initializing parcel count for {0} on {1}", +// landData.Name, m_Scene.RegionInfo.RegionName); m_ParcelCounts[landData.GlobalID] = new ParcelCounts(); } @@ -583,4 +593,4 @@ namespace OpenSim.Region.CoreModules.World.Land } } } -} +} \ 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 index 4acba18..d161bb8 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -51,9 +51,14 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests protected PrimCountModule m_pcm; /// - /// A parcel that covers the entire sim. + /// A parcel that covers the entire sim except for a 1 unit wide strip on the eastern side. /// protected ILandObject m_lo; + + /// + /// A parcel that covers just the eastern strip of the sim. + /// + protected ILandObject m_lo2; [SetUp] public void SetUp() @@ -63,10 +68,19 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests m_scene = SceneSetupHelpers.SetupScene(); SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm); + int xParcelDivider = (int)Constants.RegionSize - 1; + ILandObject lo = new LandObject(m_userId, false, m_scene); + lo.LandData.Name = "m_lo"; lo.SetLandBitmap( - lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize / 4 - 1, (int)Constants.RegionSize / 4 - 1)); + lo.GetSquareLandBitmap(0, 0, xParcelDivider, (int)Constants.RegionSize)); m_lo = lmm.AddLandObject(lo); + + ILandObject lo2 = new LandObject(m_userId, false, m_scene); + lo2.SetLandBitmap( + lo2.GetSquareLandBitmap(xParcelDivider, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); + lo2.LandData.Name = "m_lo2"; + m_lo2 = lmm.AddLandObject(lo2); } /// @@ -98,7 +112,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); m_scene.AddNewSceneObject(sog, false); Assert.That(pc.Owner, Is.EqualTo(3)); @@ -111,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pc.Simulator, Is.EqualTo(3)); // Add a second object and retest - SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, 0x10); + SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10); m_scene.AddNewSceneObject(sog2, false); Assert.That(pc.Owner, Is.EqualTo(5)); @@ -135,7 +149,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); m_scene.AddNewSceneObject(sog, false); m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity); @@ -156,35 +170,37 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests //[Test] public void TestMoveOwnerObject() { -// TestHelper.InMethod(); -//// log4net.Config.XmlConfigurator.Configure(); -// -// IPrimCounts pc = m_lo.PrimCounts; -// -// SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); -// m_scene.AddNewSceneObject(sog, false); -// -// Assert.That(pc.Owner, Is.EqualTo(3)); -// Assert.That(pc.Group, Is.EqualTo(0)); -// Assert.That(pc.Others, Is.EqualTo(0)); -// Assert.That(pc.Total, Is.EqualTo(3)); -// Assert.That(pc.Selected, Is.EqualTo(0)); -// Assert.That(pc.Users[m_userId], Is.EqualTo(3)); -// Assert.That(pc.Users[m_otherUserId], 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(pc.Owner, Is.EqualTo(5)); -// Assert.That(pc.Group, Is.EqualTo(0)); -// Assert.That(pc.Others, Is.EqualTo(0)); -// Assert.That(pc.Total, Is.EqualTo(5)); -// Assert.That(pc.Selected, Is.EqualTo(0)); -// Assert.That(pc.Users[m_userId], Is.EqualTo(5)); -// Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); -// Assert.That(pc.Simulator, Is.EqualTo(5)); + TestHelper.InMethod(); + log4net.Config.XmlConfigurator.Configure(); + + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); + m_scene.AddNewSceneObject(sog, false); + SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10); + m_scene.AddNewSceneObject(sog2, false); + + sog.AbsolutePosition = new Vector3(254, 2, 2); + + IPrimCounts pclo1 = m_lo.PrimCounts; + + Assert.That(pclo1.Owner, Is.EqualTo(2)); + Assert.That(pclo1.Group, Is.EqualTo(0)); + Assert.That(pclo1.Others, Is.EqualTo(0)); + Assert.That(pclo1.Total, Is.EqualTo(2)); + Assert.That(pclo1.Selected, Is.EqualTo(0)); + Assert.That(pclo1.Users[m_userId], Is.EqualTo(2)); + Assert.That(pclo1.Users[m_otherUserId], Is.EqualTo(0)); + Assert.That(pclo1.Simulator, Is.EqualTo(2)); + + IPrimCounts pclo2 = m_lo2.PrimCounts; + + Assert.That(pclo2.Owner, Is.EqualTo(3)); + Assert.That(pclo2.Group, Is.EqualTo(0)); + Assert.That(pclo2.Others, Is.EqualTo(0)); + Assert.That(pclo2.Total, Is.EqualTo(3)); + Assert.That(pclo2.Selected, Is.EqualTo(0)); + Assert.That(pclo2.Users[m_userId], Is.EqualTo(3)); + Assert.That(pclo2.Users[m_otherUserId], Is.EqualTo(0)); + Assert.That(pclo2.Simulator, Is.EqualTo(3)); } /// @@ -198,8 +214,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests 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(SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1), false); + SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10); m_scene.AddNewSceneObject(sogToDelete, false); m_scene.DeleteSceneObject(sogToDelete, false); @@ -223,7 +239,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, 0x01); + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01); sog.GroupID = m_groupId; m_scene.AddNewSceneObject(sog, false); @@ -254,11 +270,11 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sogToKeep = SceneSetupHelpers.CreateSceneObject(1, m_userId, 0x1); + SceneObjectGroup sogToKeep = SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1); sogToKeep.GroupID = m_groupId; m_scene.AddNewSceneObject(sogToKeep, false); - SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x10); + SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10); m_scene.AddNewSceneObject(sogToDelete, false); m_scene.DeleteSceneObject(sogToDelete, false); @@ -281,7 +297,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, 0x01); + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01); m_scene.AddNewSceneObject(sog, false); Assert.That(pc.Owner, Is.EqualTo(0)); @@ -302,8 +318,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests IPrimCounts pc = m_lo.PrimCounts; - m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_otherUserId, 0x1), false); - SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, 0x10); + m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_otherUserId, "a", 0x1), false); + SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "b", 0x10); m_scene.AddNewSceneObject(sogToDelete, false); m_scene.DeleteSceneObject(sogToDelete, false); @@ -326,7 +342,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests TestHelper.InMethod(); IPrimCounts pc = m_lo.PrimCounts; - SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); + SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); m_scene.AddNewSceneObject(sog, false); m_pcm.TaintPrimCount(); diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index 57850c1..709dd78 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -489,32 +489,38 @@ namespace OpenSim.Tests.Common.Setup /// public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) { - return CreateSceneObject(parts, ownerId, 0x1); + return CreateSceneObject(parts, ownerId, "", 0x1); } /// /// Create a scene object but do not add it to the scene. /// - /// The number of parts that should be in the scene object + /// + /// The number of parts that should be in the scene object + /// /// + /// + /// The prefix to be given to part names. This will be suffixed with "Part" + /// (e.g. mynamePart0 for the root part) + /// /// /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" /// will be given to the root part, and incremented for each part thereafter. /// /// - public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, int uuidTail) + public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, string partNamePrefix, int uuidTail) { string rawSogId = string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail); SceneObjectGroup sog = new SceneObjectGroup( - CreateSceneObjectPart("part0", new UUID(rawSogId), ownerId)); + CreateSceneObjectPart(string.Format("{0}Part0", partNamePrefix), new UUID(rawSogId), ownerId)); if (parts > 1) for (int i = 1; i < parts; i++) sog.AddPart( CreateSceneObjectPart( - string.Format("obj{0}", i), + string.Format("{0}Part{1}", partNamePrefix, i), new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i)), ownerId)); -- cgit v1.1 From 8318915d7ec7ed3bd25ff1027a9a8dfb695f2609 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 6 Apr 2011 20:45:59 +0100 Subject: Signal prim count taint if the AbsolutePosition of a scene object changes. This updates prim counts correctly if an object is moved by something other than an avatar (e.g. scripts, region modules) Create TestMoveOwnerObject() regression test for this case. --- .../World/Land/Tests/PrimCountModuleTests.cs | 30 +++++++++++++++++++--- .../Region/Framework/Scenes/SceneObjectGroup.cs | 2 ++ 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index d161bb8..67b00ac 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs @@ -167,17 +167,18 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests /// Test that parcel counts update correctly when an object is moved between parcels, where that movement /// is not done directly by the user/ /// - //[Test] + [Test] public void TestMoveOwnerObject() { TestHelper.InMethod(); - log4net.Config.XmlConfigurator.Configure(); +// log4net.Config.XmlConfigurator.Configure(); SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01); m_scene.AddNewSceneObject(sog, false); SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10); m_scene.AddNewSceneObject(sog2, false); + // Move the first scene object to the eastern strip parcel sog.AbsolutePosition = new Vector3(254, 2, 2); IPrimCounts pclo1 = m_lo.PrimCounts; @@ -189,7 +190,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pclo1.Selected, Is.EqualTo(0)); Assert.That(pclo1.Users[m_userId], Is.EqualTo(2)); Assert.That(pclo1.Users[m_otherUserId], Is.EqualTo(0)); - Assert.That(pclo1.Simulator, Is.EqualTo(2)); + Assert.That(pclo1.Simulator, Is.EqualTo(5)); IPrimCounts pclo2 = m_lo2.PrimCounts; @@ -200,7 +201,28 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests Assert.That(pclo2.Selected, Is.EqualTo(0)); Assert.That(pclo2.Users[m_userId], Is.EqualTo(3)); Assert.That(pclo2.Users[m_otherUserId], Is.EqualTo(0)); - Assert.That(pclo2.Simulator, Is.EqualTo(3)); + Assert.That(pclo2.Simulator, Is.EqualTo(5)); + + // Now move it back again + sog.AbsolutePosition = new Vector3(2, 2, 2); + + Assert.That(pclo1.Owner, Is.EqualTo(5)); + Assert.That(pclo1.Group, Is.EqualTo(0)); + Assert.That(pclo1.Others, Is.EqualTo(0)); + Assert.That(pclo1.Total, Is.EqualTo(5)); + Assert.That(pclo1.Selected, Is.EqualTo(0)); + Assert.That(pclo1.Users[m_userId], Is.EqualTo(5)); + Assert.That(pclo1.Users[m_otherUserId], Is.EqualTo(0)); + Assert.That(pclo1.Simulator, Is.EqualTo(5)); + + Assert.That(pclo2.Owner, Is.EqualTo(0)); + Assert.That(pclo2.Group, Is.EqualTo(0)); + Assert.That(pclo2.Others, Is.EqualTo(0)); + Assert.That(pclo2.Total, Is.EqualTo(0)); + Assert.That(pclo2.Selected, Is.EqualTo(0)); + Assert.That(pclo2.Users[m_userId], Is.EqualTo(0)); + Assert.That(pclo2.Users[m_otherUserId], Is.EqualTo(0)); + Assert.That(pclo2.Simulator, Is.EqualTo(5)); } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a7107f0..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 //m_rootPart.GroupPosition.Z); //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); //} + + m_scene.EventManager.TriggerParcelPrimCountTainted(); } } -- cgit v1.1 From 9bc2705f37bfc057cdb74a4479d1c72fda4e0aa9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 6 Apr 2011 20:52:36 +0100 Subject: Fix bug where on duplication, the root part local id was continually used in populating the local id scene object index instead of each part's local id --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 60855b2..97af0a0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1855,7 +1855,7 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; foreach (SceneObjectPart part in children) - SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; + SceneObjectGroupsByLocalPartID[part.LocalId] = copy; } // PROBABLE END OF FIXME -- cgit v1.1 From a6b1927cff19c72fe0c879ab41fcca8052737617 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 6 Apr 2011 22:05:07 +0100 Subject: bump main branch version number to 0.7.2. A separate 0.7.1-post-fixes branch now exists. --- OpenSim/Framework/Servers/VersionInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index c9d4c93..53a3f17 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs @@ -29,7 +29,7 @@ namespace OpenSim { public class VersionInfo { - private const string VERSION_NUMBER = "0.7.1"; + private const string VERSION_NUMBER = "0.7.2"; private const Flavour VERSION_FLAVOUR = Flavour.Dev; public enum Flavour -- cgit v1.1 From 9d40c0dcc70462d78d6347676927b05eed245a9a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 7 Apr 2011 23:16:36 +0100 Subject: Remove the SQLite legacy adaptor. This is no longer needed now that the main adaptor works on Mac OS X. The SQLite legacy adapator was also not at all well maintained, even worse than the mainline sqlite adapator. --- .../Data/SQLiteLegacy/Properties/AssemblyInfo.cs | 65 - .../Data/SQLiteLegacy/Resources/001_AssetStore.sql | 12 - .../Data/SQLiteLegacy/Resources/001_AuthStore.sql | 18 - OpenSim/Data/SQLiteLegacy/Resources/001_Avatar.sql | 9 - .../SQLiteLegacy/Resources/001_FriendsStore.sql | 10 - .../SQLiteLegacy/Resources/001_InventoryStore.sql | 32 - .../SQLiteLegacy/Resources/001_RegionStore.sql | 144 -- .../SQLiteLegacy/Resources/001_UserAccount.sql | 17 - .../Data/SQLiteLegacy/Resources/001_UserStore.sql | 39 - .../Data/SQLiteLegacy/Resources/002_AssetStore.sql | 10 - .../Data/SQLiteLegacy/Resources/002_AuthStore.sql | 5 - .../SQLiteLegacy/Resources/002_FriendsStore.sql | 5 - .../SQLiteLegacy/Resources/002_InventoryStore.sql | 8 - .../SQLiteLegacy/Resources/002_RegionStore.sql | 10 - .../SQLiteLegacy/Resources/002_UserAccount.sql | 5 - .../Data/SQLiteLegacy/Resources/002_UserStore.sql | 5 - .../Data/SQLiteLegacy/Resources/003_AssetStore.sql | 1 - .../SQLiteLegacy/Resources/003_InventoryStore.sql | 5 - .../SQLiteLegacy/Resources/003_RegionStore.sql | 5 - .../Data/SQLiteLegacy/Resources/003_UserStore.sql | 6 - .../Data/SQLiteLegacy/Resources/004_AssetStore.sql | 7 - .../SQLiteLegacy/Resources/004_InventoryStore.sql | 36 - .../SQLiteLegacy/Resources/004_RegionStore.sql | 38 - .../Data/SQLiteLegacy/Resources/004_UserStore.sql | 6 - .../SQLiteLegacy/Resources/005_RegionStore.sql | 5 - .../Data/SQLiteLegacy/Resources/005_UserStore.sql | 5 - .../SQLiteLegacy/Resources/006_RegionStore.sql | 102 - .../Data/SQLiteLegacy/Resources/006_UserStore.sql | 20 - .../SQLiteLegacy/Resources/007_RegionStore.sql | 8 - .../Data/SQLiteLegacy/Resources/007_UserStore.sql | 7 - .../SQLiteLegacy/Resources/008_RegionStore.sql | 6 - .../Data/SQLiteLegacy/Resources/008_UserStore.sql | 5 - .../SQLiteLegacy/Resources/009_RegionStore.sql | 8 - .../Data/SQLiteLegacy/Resources/009_UserStore.sql | 11 - .../SQLiteLegacy/Resources/010_RegionStore.sql | 5 - .../Data/SQLiteLegacy/Resources/010_UserStore.sql | 37 - .../SQLiteLegacy/Resources/011_RegionStore.sql | 28 - .../SQLiteLegacy/Resources/012_RegionStore.sql | 5 - .../SQLiteLegacy/Resources/013_RegionStore.sql | 6 - .../SQLiteLegacy/Resources/014_RegionStore.sql | 8 - .../SQLiteLegacy/Resources/015_RegionStore.sql | 6 - .../SQLiteLegacy/Resources/016_RegionStore.sql | 5 - .../SQLiteLegacy/Resources/017_RegionStore.sql | 8 - .../SQLiteLegacy/Resources/018_RegionStore.sql | 79 - .../Resources/OpenSim.Data.SQLite.addin.xml | 20 - OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs | 347 --- .../Data/SQLiteLegacy/SQLiteAuthenticationData.cs | 266 --- OpenSim/Data/SQLiteLegacy/SQLiteAvatarData.cs | 74 - OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs | 451 ---- OpenSim/Data/SQLiteLegacy/SQLiteFramework.cs | 91 - OpenSim/Data/SQLiteLegacy/SQLiteFriendsData.cs | 70 - .../Data/SQLiteLegacy/SQLiteGenericTableHandler.cs | 268 --- OpenSim/Data/SQLiteLegacy/SQLiteInventoryStore.cs | 898 -------- OpenSim/Data/SQLiteLegacy/SQLiteSimulationData.cs | 2274 -------------------- OpenSim/Data/SQLiteLegacy/SQLiteUserAccountData.cs | 81 - OpenSim/Data/SQLiteLegacy/SQLiteUtils.cs | 307 --- OpenSim/Data/SQLiteLegacy/SQLiteXInventoryData.cs | 155 -- 57 files changed, 6164 deletions(-) delete mode 100644 OpenSim/Data/SQLiteLegacy/Properties/AssemblyInfo.cs delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/001_AssetStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/001_AuthStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/001_Avatar.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/001_FriendsStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/001_InventoryStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/001_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/001_UserAccount.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/001_UserStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/002_AssetStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/002_AuthStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/002_FriendsStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/002_InventoryStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/002_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/002_UserAccount.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/002_UserStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/003_AssetStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/003_InventoryStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/003_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/003_UserStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/004_AssetStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/004_InventoryStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/004_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/004_UserStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/005_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/005_UserStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/006_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/006_UserStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/007_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/007_UserStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/008_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/008_UserStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/009_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/009_UserStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/010_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/010_UserStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/011_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/012_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/013_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/014_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/015_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/016_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/017_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/018_RegionStore.sql delete mode 100644 OpenSim/Data/SQLiteLegacy/Resources/OpenSim.Data.SQLite.addin.xml delete mode 100644 OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs delete mode 100644 OpenSim/Data/SQLiteLegacy/SQLiteAuthenticationData.cs delete mode 100644 OpenSim/Data/SQLiteLegacy/SQLiteAvatarData.cs delete mode 100644 OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs delete mode 100644 OpenSim/Data/SQLiteLegacy/SQLiteFramework.cs delete mode 100644 OpenSim/Data/SQLiteLegacy/SQLiteFriendsData.cs delete mode 100644 OpenSim/Data/SQLiteLegacy/SQLiteGenericTableHandler.cs delete mode 100644 OpenSim/Data/SQLiteLegacy/SQLiteInventoryStore.cs delete mode 100644 OpenSim/Data/SQLiteLegacy/SQLiteSimulationData.cs delete mode 100644 OpenSim/Data/SQLiteLegacy/SQLiteUserAccountData.cs delete mode 100644 OpenSim/Data/SQLiteLegacy/SQLiteUtils.cs delete mode 100644 OpenSim/Data/SQLiteLegacy/SQLiteXInventoryData.cs (limited to 'OpenSim') diff --git a/OpenSim/Data/SQLiteLegacy/Properties/AssemblyInfo.cs b/OpenSim/Data/SQLiteLegacy/Properties/AssemblyInfo.cs deleted file mode 100644 index 609a024..0000000 --- a/OpenSim/Data/SQLiteLegacy/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.Reflection; -using System.Runtime.InteropServices; - -// General information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly : AssemblyTitle("OpenSim.Data.SQLiteLegacy")] -[assembly : AssemblyDescription("")] -[assembly : AssemblyConfiguration("")] -[assembly : AssemblyCompany("http://opensimulator.org")] -[assembly : AssemblyProduct("OpenSim.Data.SQLiteLegacy")] -[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] -[assembly : AssemblyTrademark("")] -[assembly : AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly : ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly : Guid("6113d5ce-4547-49f4-9236-0dcc503457b1")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly : AssemblyVersion("0.6.5.*")] -[assembly : AssemblyFileVersion("0.6.5.0")] diff --git a/OpenSim/Data/SQLiteLegacy/Resources/001_AssetStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_AssetStore.sql deleted file mode 100644 index 2e026ca..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/001_AssetStore.sql +++ /dev/null @@ -1,12 +0,0 @@ -BEGIN TRANSACTION; -CREATE TABLE assets( - UUID varchar(255) primary key, - Name varchar(255), - Description varchar(255), - Type integer, - InvType integer, - Local integer, - Temporary integer, - Data blob); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/001_AuthStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_AuthStore.sql deleted file mode 100644 index 468567d..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/001_AuthStore.sql +++ /dev/null @@ -1,18 +0,0 @@ -BEGIN TRANSACTION; - -CREATE TABLE auth ( - UUID char(36) NOT NULL, - passwordHash char(32) NOT NULL default '', - passwordSalt char(32) NOT NULL default '', - webLoginKey varchar(255) NOT NULL default '', - accountType VARCHAR(32) NOT NULL DEFAULT 'UserAccount', - PRIMARY KEY (`UUID`) -); - -CREATE TABLE tokens ( - UUID char(36) NOT NULL, - token varchar(255) NOT NULL, - validity datetime NOT NULL -); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/001_Avatar.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_Avatar.sql deleted file mode 100644 index 7ec906b..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/001_Avatar.sql +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN TRANSACTION; - -CREATE TABLE Avatars ( - PrincipalID CHAR(36) NOT NULL, - Name VARCHAR(32) NOT NULL, - Value VARCHAR(255) NOT NULL DEFAULT '', - PRIMARY KEY(PrincipalID, Name)); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/001_FriendsStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_FriendsStore.sql deleted file mode 100644 index f1b9ab9..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/001_FriendsStore.sql +++ /dev/null @@ -1,10 +0,0 @@ -BEGIN TRANSACTION; - -CREATE TABLE `Friends` ( - `PrincipalID` CHAR(36) NOT NULL, - `Friend` VARCHAR(255) NOT NULL, - `Flags` VARCHAR(16) NOT NULL DEFAULT 0, - `Offered` VARCHAR(32) NOT NULL DEFAULT 0, - PRIMARY KEY(`PrincipalID`, `Friend`)); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/001_InventoryStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_InventoryStore.sql deleted file mode 100644 index 554d5c2..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/001_InventoryStore.sql +++ /dev/null @@ -1,32 +0,0 @@ -BEGIN TRANSACTION; - -CREATE TABLE inventoryfolders( - UUID varchar(255) primary key, - name varchar(255), - agentID varchar(255), - parentID varchar(255), - type integer, - version integer); - -CREATE TABLE inventoryitems( - UUID varchar(255) primary key, - assetID varchar(255), - assetType integer, - invType integer, - parentFolderID varchar(255), - avatarID varchar(255), - creatorsID varchar(255), - inventoryName varchar(255), - inventoryDescription varchar(255), - inventoryNextPermissions integer, - inventoryCurrentPermissions integer, - inventoryBasePermissions integer, - inventoryEveryOnePermissions integer, - salePrice integer default 99, - saleType integer default 0, - creationDate integer default 2000, - groupID varchar(255) default '00000000-0000-0000-0000-000000000000', - groupOwned integer default 0, - flags integer default 0); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/001_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_RegionStore.sql deleted file mode 100644 index 39e8180..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/001_RegionStore.sql +++ /dev/null @@ -1,144 +0,0 @@ -BEGIN TRANSACTION; - -CREATE TABLE prims( - UUID varchar(255) primary key, - RegionUUID varchar(255), - ParentID integer, - CreationDate integer, - Name varchar(255), - SceneGroupID varchar(255), - Text varchar(255), - Description varchar(255), - SitName varchar(255), - TouchName varchar(255), - CreatorID varchar(255), - OwnerID varchar(255), - GroupID varchar(255), - LastOwnerID varchar(255), - OwnerMask integer, - NextOwnerMask integer, - GroupMask integer, - EveryoneMask integer, - BaseMask integer, - PositionX float, - PositionY float, - PositionZ float, - GroupPositionX float, - GroupPositionY float, - GroupPositionZ float, - VelocityX float, - VelocityY float, - VelocityZ float, - AngularVelocityX float, - AngularVelocityY float, - AngularVelocityZ float, - AccelerationX float, - AccelerationY float, - AccelerationZ float, - RotationX float, - RotationY float, - RotationZ float, - RotationW float, - ObjectFlags integer, - SitTargetOffsetX float NOT NULL default 0, - SitTargetOffsetY float NOT NULL default 0, - SitTargetOffsetZ float NOT NULL default 0, - SitTargetOrientW float NOT NULL default 0, - SitTargetOrientX float NOT NULL default 0, - SitTargetOrientY float NOT NULL default 0, - SitTargetOrientZ float NOT NULL default 0); - -CREATE TABLE primshapes( - UUID varchar(255) primary key, - Shape integer, - ScaleX float, - ScaleY float, - ScaleZ float, - PCode integer, - PathBegin integer, - PathEnd integer, - PathScaleX integer, - PathScaleY integer, - PathShearX integer, - PathShearY integer, - PathSkew integer, - PathCurve integer, - PathRadiusOffset integer, - PathRevolutions integer, - PathTaperX integer, - PathTaperY integer, - PathTwist integer, - PathTwistBegin integer, - ProfileBegin integer, - ProfileEnd integer, - ProfileCurve integer, - ProfileHollow integer, - Texture blob, - ExtraParams blob, - State Integer NOT NULL default 0); - -CREATE TABLE primitems( - itemID varchar(255) primary key, - primID varchar(255), - assetID varchar(255), - parentFolderID varchar(255), - invType integer, - assetType integer, - name varchar(255), - description varchar(255), - creationDate integer, - creatorID varchar(255), - ownerID varchar(255), - lastOwnerID varchar(255), - groupID varchar(255), - nextPermissions string, - currentPermissions string, - basePermissions string, - everyonePermissions string, - groupPermissions string); - -CREATE TABLE terrain( - RegionUUID varchar(255), - Revision integer, - Heightfield blob); - -CREATE TABLE land( - UUID varchar(255) primary key, - RegionUUID varchar(255), - LocalLandID string, - Bitmap blob, - Name varchar(255), - Desc varchar(255), - OwnerUUID varchar(255), - IsGroupOwned string, - Area integer, - AuctionID integer, - Category integer, - ClaimDate integer, - ClaimPrice integer, - GroupUUID varchar(255), - SalePrice integer, - LandStatus integer, - LandFlags string, - LandingType string, - MediaAutoScale string, - MediaTextureUUID varchar(255), - MediaURL varchar(255), - MusicURL varchar(255), - PassHours float, - PassPrice string, - SnapshotUUID varchar(255), - UserLocationX float, - UserLocationY float, - UserLocationZ float, - UserLookAtX float, - UserLookAtY float, - UserLookAtZ float, - AuthbuyerID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000'); - -CREATE TABLE landaccesslist( - LandUUID varchar(255), - AccessUUID varchar(255), - Flags string); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/001_UserAccount.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_UserAccount.sql deleted file mode 100644 index c38d9a7..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/001_UserAccount.sql +++ /dev/null @@ -1,17 +0,0 @@ -BEGIN TRANSACTION; - --- useraccounts table -CREATE TABLE UserAccounts ( - PrincipalID CHAR(36) primary key, - ScopeID CHAR(36) NOT NULL, - FirstName VARCHAR(64) NOT NULL, - LastName VARCHAR(64) NOT NULL, - Email VARCHAR(64), - ServiceURLs TEXT, - Created INT(11), - UserLevel integer NOT NULL DEFAULT 0, - UserFlags integer NOT NULL DEFAULT 0, - UserTitle varchar(64) NOT NULL DEFAULT '' -); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/SQLiteLegacy/Resources/001_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/001_UserStore.sql deleted file mode 100644 index b584594..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/001_UserStore.sql +++ /dev/null @@ -1,39 +0,0 @@ -BEGIN TRANSACTION; - --- users table -CREATE TABLE users( - UUID varchar(255) primary key, - username varchar(255), - surname varchar(255), - passwordHash varchar(255), - passwordSalt varchar(255), - homeRegionX integer, - homeRegionY integer, - homeLocationX float, - homeLocationY float, - homeLocationZ float, - homeLookAtX float, - homeLookAtY float, - homeLookAtZ float, - created integer, - lastLogin integer, - rootInventoryFolderID varchar(255), - userInventoryURI varchar(255), - userAssetURI varchar(255), - profileCanDoMask integer, - profileWantDoMask integer, - profileAboutText varchar(255), - profileFirstText varchar(255), - profileImage varchar(255), - profileFirstImage varchar(255), - webLoginKey text default '00000000-0000-0000-0000-000000000000'); --- friends table -CREATE TABLE userfriends( - ownerID varchar(255), - friendID varchar(255), - friendPerms integer, - ownerPerms integer, - datetimestamp integer); - -COMMIT; - diff --git a/OpenSim/Data/SQLiteLegacy/Resources/002_AssetStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_AssetStore.sql deleted file mode 100644 index 5339b84..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/002_AssetStore.sql +++ /dev/null @@ -1,10 +0,0 @@ -BEGIN TRANSACTION; - -CREATE TEMPORARY TABLE assets_backup(UUID,Name,Description,Type,Local,Temporary,Data); -INSERT INTO assets_backup SELECT UUID,Name,Description,Type,Local,Temporary,Data FROM assets; -DROP TABLE assets; -CREATE TABLE assets(UUID,Name,Description,Type,Local,Temporary,Data); -INSERT INTO assets SELECT UUID,Name,Description,Type,Local,Temporary,Data FROM assets_backup; -DROP TABLE assets_backup; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/002_AuthStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_AuthStore.sql deleted file mode 100644 index 3237b68..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/002_AuthStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN TRANSACTION; - -INSERT INTO auth (UUID, passwordHash, passwordSalt, webLoginKey) SELECT `UUID` AS UUID, `passwordHash` AS passwordHash, `passwordSalt` AS passwordSalt, `webLoginKey` AS webLoginKey FROM users; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/002_FriendsStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_FriendsStore.sql deleted file mode 100644 index 6733502..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/002_FriendsStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN TRANSACTION; - -INSERT INTO `Friends` SELECT `ownerID`, `friendID`, `friendPerms`, 0 FROM `userfriends`; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/002_InventoryStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_InventoryStore.sql deleted file mode 100644 index 01951d6..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/002_InventoryStore.sql +++ /dev/null @@ -1,8 +0,0 @@ -BEGIN TRANSACTION; - -create index inventoryfolders_agentid on inventoryfolders(agentid); -create index inventoryfolders_parentid on inventoryfolders(parentid); -create index inventoryitems_parentfolderid on inventoryitems(parentfolderid); -create index inventoryitems_avatarid on inventoryitems(avatarid); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/SQLiteLegacy/Resources/002_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_RegionStore.sql deleted file mode 100644 index c5c7c99..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/002_RegionStore.sql +++ /dev/null @@ -1,10 +0,0 @@ -BEGIN TRANSACTION; - -CREATE TABLE regionban( - regionUUID varchar (255), - bannedUUID varchar (255), - bannedIp varchar (255), - bannedIpHostMask varchar (255) - ); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/SQLiteLegacy/Resources/002_UserAccount.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_UserAccount.sql deleted file mode 100644 index c7a6293..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/002_UserAccount.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN TRANSACTION; - -INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, surname AS LastName, '' as Email, '' AS ServiceURLs, created as Created FROM users; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/002_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/002_UserStore.sql deleted file mode 100644 index 48fc680..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/002_UserStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE users add homeRegionID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000'; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/003_AssetStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/003_AssetStore.sql deleted file mode 100644 index f54f8d9..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/003_AssetStore.sql +++ /dev/null @@ -1 +0,0 @@ -DELETE FROM assets WHERE UUID = 'dc4b9f0bd00845c696a401dd947ac621' diff --git a/OpenSim/Data/SQLiteLegacy/Resources/003_InventoryStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/003_InventoryStore.sql deleted file mode 100644 index 4c6da91..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/003_InventoryStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -alter table inventoryitems add column inventoryGroupPermissions integer unsigned not null default 0; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/003_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/003_RegionStore.sql deleted file mode 100644 index 4db2f75..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/003_RegionStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE primitems add flags integer not null default 0; - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/SQLiteLegacy/Resources/003_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/003_UserStore.sql deleted file mode 100644 index 6f890ee..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/003_UserStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE users add userFlags integer NOT NULL default 0; -ALTER TABLE users add godLevel integer NOT NULL default 0; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/004_AssetStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/004_AssetStore.sql deleted file mode 100644 index 39421c4..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/004_AssetStore.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN; - -update assets - set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12) - where UUID not like '%-%'; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/004_InventoryStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/004_InventoryStore.sql deleted file mode 100644 index e8f4d46..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/004_InventoryStore.sql +++ /dev/null @@ -1,36 +0,0 @@ -BEGIN; - -update inventoryitems - set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12) - where UUID not like '%-%'; - -update inventoryitems - set assetID = substr(assetID, 1, 8) || "-" || substr(assetID, 9, 4) || "-" || substr(assetID, 13, 4) || "-" || substr(assetID, 17, 4) || "-" || substr(assetID, 21, 12) - where assetID not like '%-%'; - -update inventoryitems - set parentFolderID = substr(parentFolderID, 1, 8) || "-" || substr(parentFolderID, 9, 4) || "-" || substr(parentFolderID, 13, 4) || "-" || substr(parentFolderID, 17, 4) || "-" || substr(parentFolderID, 21, 12) - where parentFolderID not like '%-%'; - -update inventoryitems - set avatarID = substr(avatarID, 1, 8) || "-" || substr(avatarID, 9, 4) || "-" || substr(avatarID, 13, 4) || "-" || substr(avatarID, 17, 4) || "-" || substr(avatarID, 21, 12) - where avatarID not like '%-%'; - -update inventoryitems - set creatorsID = substr(creatorsID, 1, 8) || "-" || substr(creatorsID, 9, 4) || "-" || substr(creatorsID, 13, 4) || "-" || substr(creatorsID, 17, 4) || "-" || substr(creatorsID, 21, 12) - where creatorsID not like '%-%'; - - -update inventoryfolders - set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12) - where UUID not like '%-%'; - -update inventoryfolders - set agentID = substr(agentID, 1, 8) || "-" || substr(agentID, 9, 4) || "-" || substr(agentID, 13, 4) || "-" || substr(agentID, 17, 4) || "-" || substr(agentID, 21, 12) - where agentID not like '%-%'; - -update inventoryfolders - set parentID = substr(parentID, 1, 8) || "-" || substr(parentID, 9, 4) || "-" || substr(parentID, 13, 4) || "-" || substr(parentID, 17, 4) || "-" || substr(parentID, 21, 12) - where parentID not like '%-%'; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/004_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/004_RegionStore.sql deleted file mode 100644 index de328cb..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/004_RegionStore.sql +++ /dev/null @@ -1,38 +0,0 @@ -BEGIN; - -create table regionsettings ( - regionUUID char(36) not null, - block_terraform integer not null, - block_fly integer not null, - allow_damage integer not null, - restrict_pushing integer not null, - allow_land_resell integer not null, - allow_land_join_divide integer not null, - block_show_in_search integer not null, - agent_limit integer not null, - object_bonus float not null, - maturity integer not null, - disable_scripts integer not null, - disable_collisions integer not null, - disable_physics integer not null, - terrain_texture_1 char(36) not null, - terrain_texture_2 char(36) not null, - terrain_texture_3 char(36) not null, - terrain_texture_4 char(36) not null, - elevation_1_nw float not null, - elevation_2_nw float not null, - elevation_1_ne float not null, - elevation_2_ne float not null, - elevation_1_se float not null, - elevation_2_se float not null, - elevation_1_sw float not null, - elevation_2_sw float not null, - water_height float not null, - terrain_raise_limit float not null, - terrain_lower_limit float not null, - use_estate_sun integer not null, - fixed_sun integer not null, - sun_position float not null, - covenant char(36)); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/004_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/004_UserStore.sql deleted file mode 100644 index 03142af..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/004_UserStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE users add customType varchar(32) not null default ''; -ALTER TABLE users add partner char(36) not null default '00000000-0000-0000-0000-000000000000'; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/005_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/005_RegionStore.sql deleted file mode 100644 index 1f6d1bd..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/005_RegionStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -delete from regionsettings; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/005_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/005_UserStore.sql deleted file mode 100644 index e45c09a..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/005_UserStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -CREATE TABLE `avatarattachments` (`UUID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', `attachpoint` int(11) NOT NULL DEFAULT 0, `item` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', `asset` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/006_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/006_RegionStore.sql deleted file mode 100644 index 94ed818..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/006_RegionStore.sql +++ /dev/null @@ -1,102 +0,0 @@ -BEGIN TRANSACTION; - -CREATE TABLE estate_groups ( - EstateID int(10) NOT NULL, - uuid char(36) NOT NULL -); - -CREATE TABLE estate_managers ( - EstateID int(10) NOT NULL, - uuid char(36) NOT NULL -); - -CREATE TABLE estate_map ( - RegionID char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', - EstateID int(11) NOT NULL -); - -CREATE TABLE estate_settings ( - EstateID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - EstateName varchar(64) default NULL, - AbuseEmailToEstateOwner tinyint(4) NOT NULL, - DenyAnonymous tinyint(4) NOT NULL, - ResetHomeOnTeleport tinyint(4) NOT NULL, - FixedSun tinyint(4) NOT NULL, - DenyTransacted tinyint(4) NOT NULL, - BlockDwell tinyint(4) NOT NULL, - DenyIdentified tinyint(4) NOT NULL, - AllowVoice tinyint(4) NOT NULL, - UseGlobalTime tinyint(4) NOT NULL, - PricePerMeter int(11) NOT NULL, - TaxFree tinyint(4) NOT NULL, - AllowDirectTeleport tinyint(4) NOT NULL, - RedirectGridX int(11) NOT NULL, - RedirectGridY int(11) NOT NULL, - ParentEstateID int(10) NOT NULL, - SunPosition double NOT NULL, - EstateSkipScripts tinyint(4) NOT NULL, - BillableFactor float NOT NULL, - PublicAccess tinyint(4) NOT NULL -); -insert into estate_settings (EstateID,EstateName,AbuseEmailToEstateOwner,DenyAnonymous,ResetHomeOnTeleport,FixedSun,DenyTransacted,BlockDwell,DenyIdentified,AllowVoice,UseGlobalTime,PricePerMeter,TaxFree,AllowDirectTeleport,RedirectGridX,RedirectGridY,ParentEstateID,SunPosition,PublicAccess,EstateSkipScripts,BillableFactor) values ( 99, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); -delete from estate_settings; -CREATE TABLE estate_users ( - EstateID int(10) NOT NULL, - uuid char(36) NOT NULL -); - -CREATE TABLE estateban ( - EstateID int(10) NOT NULL, - bannedUUID varchar(36) NOT NULL, - bannedIp varchar(16) NOT NULL, - bannedIpHostMask varchar(16) NOT NULL, - bannedNameMask varchar(64) default NULL -); - -drop table regionsettings; -CREATE TABLE regionsettings ( - regionUUID char(36) NOT NULL, - block_terraform int(11) NOT NULL, - block_fly int(11) NOT NULL, - allow_damage int(11) NOT NULL, - restrict_pushing int(11) NOT NULL, - allow_land_resell int(11) NOT NULL, - allow_land_join_divide int(11) NOT NULL, - block_show_in_search int(11) NOT NULL, - agent_limit int(11) NOT NULL, - object_bonus float NOT NULL, - maturity int(11) NOT NULL, - disable_scripts int(11) NOT NULL, - disable_collisions int(11) NOT NULL, - disable_physics int(11) NOT NULL, - terrain_texture_1 char(36) NOT NULL, - terrain_texture_2 char(36) NOT NULL, - terrain_texture_3 char(36) NOT NULL, - terrain_texture_4 char(36) NOT NULL, - elevation_1_nw float NOT NULL, - elevation_2_nw float NOT NULL, - elevation_1_ne float NOT NULL, - elevation_2_ne float NOT NULL, - elevation_1_se float NOT NULL, - elevation_2_se float NOT NULL, - elevation_1_sw float NOT NULL, - elevation_2_sw float NOT NULL, - water_height float NOT NULL, - terrain_raise_limit float NOT NULL, - terrain_lower_limit float NOT NULL, - use_estate_sun int(11) NOT NULL, - fixed_sun int(11) NOT NULL, - sun_position float NOT NULL, - covenant char(36) default NULL, - Sandbox tinyint(4) NOT NULL, - PRIMARY KEY (regionUUID) -); - -CREATE INDEX estate_ban_estate_id on estateban(EstateID); -CREATE INDEX estate_groups_estate_id on estate_groups(EstateID); -CREATE INDEX estate_managers_estate_id on estate_managers(EstateID); -CREATE INDEX estate_map_estate_id on estate_map(EstateID); -CREATE UNIQUE INDEX estate_map_region_id on estate_map(RegionID); -CREATE INDEX estate_users_estate_id on estate_users(EstateID); - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/SQLiteLegacy/Resources/006_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/006_UserStore.sql deleted file mode 100644 index f9454c5..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/006_UserStore.sql +++ /dev/null @@ -1,20 +0,0 @@ -BEGIN TRANSACTION; - --- usersagents table -CREATE TABLE IF NOT EXISTS useragents( - UUID varchar(255) primary key, - agentIP varchar(255), - agentPort integer, - agentOnline boolean, - sessionID varchar(255), - secureSessionID varchar(255), - regionID varchar(255), - loginTime integer, - logoutTime integer, - currentRegion varchar(255), - currentHandle varchar(255), - currentPosX float, - currentPosY float, - currentPosZ float); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/007_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/007_RegionStore.sql deleted file mode 100644 index 1c813a0..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/007_RegionStore.sql +++ /dev/null @@ -1,8 +0,0 @@ -begin; - -alter table estate_settings add column AbuseEmail varchar(255) not null default ''; - -alter table estate_settings add column EstateOwner varchar(36) not null default ''; - -commit; - diff --git a/OpenSim/Data/SQLiteLegacy/Resources/007_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/007_UserStore.sql deleted file mode 100644 index 8b0cd28..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/007_UserStore.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN TRANSACTION; - -ALTER TABLE useragents add currentLookAtX float not null default 128; -ALTER TABLE useragents add currentLookAtY float not null default 128; -ALTER TABLE useragents add currentLookAtZ float not null default 70; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/008_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/008_RegionStore.sql deleted file mode 100644 index 28bfbf5..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/008_RegionStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -begin; - -alter table estate_settings add column DenyMinors tinyint not null default 0; - -commit; - diff --git a/OpenSim/Data/SQLiteLegacy/Resources/008_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/008_UserStore.sql deleted file mode 100644 index 97da818..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/008_UserStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN TRANSACTION; - -ALTER TABLE users add email varchar(250); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/009_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/009_RegionStore.sql deleted file mode 100644 index 1f40548..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/009_RegionStore.sql +++ /dev/null @@ -1,8 +0,0 @@ -BEGIN; - -ALTER TABLE prims ADD COLUMN ColorR integer not null default 0; -ALTER TABLE prims ADD COLUMN ColorG integer not null default 0; -ALTER TABLE prims ADD COLUMN ColorB integer not null default 0; -ALTER TABLE prims ADD COLUMN ColorA integer not null default 0; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/009_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/009_UserStore.sql deleted file mode 100644 index 8ab03ef..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/009_UserStore.sql +++ /dev/null @@ -1,11 +0,0 @@ -BEGIN; - -update users - set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12) - where UUID not like '%-%'; - -update useragents - set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12) - where UUID not like '%-%'; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/010_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/010_RegionStore.sql deleted file mode 100644 index b91ccf0..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/010_RegionStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE prims ADD COLUMN ClickAction INTEGER NOT NULL default 0; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/010_UserStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/010_UserStore.sql deleted file mode 100644 index 5f956da..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/010_UserStore.sql +++ /dev/null @@ -1,37 +0,0 @@ -BEGIN TRANSACTION; - -CREATE TABLE IF NOT EXISTS avatarappearance( - Owner varchar(36) NOT NULL primary key, - BodyItem varchar(36) DEFAULT NULL, - BodyAsset varchar(36) DEFAULT NULL, - SkinItem varchar(36) DEFAULT NULL, - SkinAsset varchar(36) DEFAULT NULL, - HairItem varchar(36) DEFAULT NULL, - HairAsset varchar(36) DEFAULT NULL, - EyesItem varchar(36) DEFAULT NULL, - EyesAsset varchar(36) DEFAULT NULL, - ShirtItem varchar(36) DEFAULT NULL, - ShirtAsset varchar(36) DEFAULT NULL, - PantsItem varchar(36) DEFAULT NULL, - PantsAsset varchar(36) DEFAULT NULL, - ShoesItem varchar(36) DEFAULT NULL, - ShoesAsset varchar(36) DEFAULT NULL, - SocksItem varchar(36) DEFAULT NULL, - SocksAsset varchar(36) DEFAULT NULL, - JacketItem varchar(36) DEFAULT NULL, - JacketAsset varchar(36) DEFAULT NULL, - GlovesItem varchar(36) DEFAULT NULL, - GlovesAsset varchar(36) DEFAULT NULL, - UnderShirtItem varchar(36) DEFAULT NULL, - UnderShirtAsset varchar(36) DEFAULT NULL, - UnderPantsItem varchar(36) DEFAULT NULL, - UnderPantsAsset varchar(36) DEFAULT NULL, - SkirtItem varchar(36) DEFAULT NULL, - SkirtAsset varchar(36) DEFAULT NULL, - Texture blob, - VisualParams blob, - Serial int DEFAULT NULL, - AvatarHeight float DEFAULT NULL -); - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/011_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/011_RegionStore.sql deleted file mode 100644 index 42bef89..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/011_RegionStore.sql +++ /dev/null @@ -1,28 +0,0 @@ -BEGIN; - -ALTER TABLE prims ADD COLUMN PayPrice INTEGER NOT NULL default 0; -ALTER TABLE prims ADD COLUMN PayButton1 INTEGER NOT NULL default 0; -ALTER TABLE prims ADD COLUMN PayButton2 INTEGER NOT NULL default 0; -ALTER TABLE prims ADD COLUMN PayButton3 INTEGER NOT NULL default 0; -ALTER TABLE prims ADD COLUMN PayButton4 INTEGER NOT NULL default 0; -ALTER TABLE prims ADD COLUMN LoopedSound varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000'; -ALTER TABLE prims ADD COLUMN LoopedSoundGain float NOT NULL default 0; -ALTER TABLE prims ADD COLUMN TextureAnimation string; -ALTER TABLE prims ADD COLUMN ParticleSystem string; -ALTER TABLE prims ADD COLUMN OmegaX float NOT NULL default 0; -ALTER TABLE prims ADD COLUMN OmegaY float NOT NULL default 0; -ALTER TABLE prims ADD COLUMN OmegaZ float NOT NULL default 0; -ALTER TABLE prims ADD COLUMN CameraEyeOffsetX float NOT NULL default 0; -ALTER TABLE prims ADD COLUMN CameraEyeOffsetY float NOT NULL default 0; -ALTER TABLE prims ADD COLUMN CameraEyeOffsetZ float NOT NULL default 0; -ALTER TABLE prims ADD COLUMN CameraAtOffsetX float NOT NULL default 0; -ALTER TABLE prims ADD COLUMN CameraAtOffsetY float NOT NULL default 0; -ALTER TABLE prims ADD COLUMN CameraAtOffsetZ float NOT NULL default 0; -ALTER TABLE prims ADD COLUMN ForceMouselook string NOT NULL default 0; -ALTER TABLE prims ADD COLUMN ScriptAccessPin INTEGER NOT NULL default 0; -ALTER TABLE prims ADD COLUMN AllowedDrop INTEGER NOT NULL default 0; -ALTER TABLE prims ADD COLUMN DieAtEdge string NOT NULL default 0; -ALTER TABLE prims ADD COLUMN SalePrice INTEGER NOT NULL default 0; -ALTER TABLE prims ADD COLUMN SaleType string NOT NULL default 0; - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/SQLiteLegacy/Resources/012_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/012_RegionStore.sql deleted file mode 100644 index d952b78..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/012_RegionStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE prims ADD COLUMN Material INTEGER NOT NULL default 3; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/013_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/013_RegionStore.sql deleted file mode 100644 index 11529cd..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/013_RegionStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE land ADD COLUMN OtherCleanTime INTEGER NOT NULL default 0; -ALTER TABLE land ADD COLUMN Dwell INTEGER NOT NULL default 0; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/014_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/014_RegionStore.sql deleted file mode 100644 index c59b27e..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/014_RegionStore.sql +++ /dev/null @@ -1,8 +0,0 @@ -begin; - -ALTER TABLE regionsettings ADD COLUMN sunvectorx double NOT NULL default 0; -ALTER TABLE regionsettings ADD COLUMN sunvectory double NOT NULL default 0; -ALTER TABLE regionsettings ADD COLUMN sunvectorz double NOT NULL default 0; - -commit; - diff --git a/OpenSim/Data/SQLiteLegacy/Resources/015_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/015_RegionStore.sql deleted file mode 100644 index c43f356..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/015_RegionStore.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE prims ADD COLUMN CollisionSound varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000'; -ALTER TABLE prims ADD COLUMN CollisionSoundVolume float NOT NULL default 0; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/016_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/016_RegionStore.sql deleted file mode 100644 index 52f160c..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/016_RegionStore.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE prims ADD COLUMN VolumeDetect INTEGER NOT NULL DEFAULT 0; - -COMMIT; diff --git a/OpenSim/Data/SQLiteLegacy/Resources/017_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/017_RegionStore.sql deleted file mode 100644 index 6c6b7b5..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/017_RegionStore.sql +++ /dev/null @@ -1,8 +0,0 @@ -BEGIN; -CREATE TEMPORARY TABLE prims_backup(UUID,RegionUUID,CreationDate,Name,SceneGroupID,Text,Description,SitName,TouchName,CreatorID,OwnerID,GroupID,LastOwnerID,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,PositionX,PositionY,PositionZ,GroupPositionX,GroupPositionY,GroupPositionZ,VelocityX,VelocityY,VelocityZ,AngularVelocityX,AngularVelocityY,AngularVelocityZ,AccelerationX,AccelerationY,AccelerationZ,RotationX,RotationY,RotationZ,RotationW,ObjectFlags,SitTargetOffsetX,SitTargetOffsetY,SitTargetOffsetZ,SitTargetOrientW,SitTargetOrientX,SitTargetOrientY,SitTargetOrientZ,ColorR,ColorG,ColorB,ColorA,ClickAction,PayPrice,PayButton1,PayButton2,PayButton3,PayButton4,LoopedSound,LoopedSoundGain,TextureAnimation,ParticleSystem,OmegaX,OmegaY,OmegaZ,CameraEyeOffsetX,CameraEyeOffsetY,CameraEyeOffsetZ,CameraAtOffsetX,CameraAtOffsetY,CameraAtOffsetZ,ForceMouselook,ScriptAccessPin,AllowedDrop,DieAtEdge,SalePrice,SaleType,Material,CollisionSound,CollisionSoundVolume,VolumeDetect); -INSERT INTO prims_backup SELECT UUID,RegionUUID,CreationDate,Name,SceneGroupID,Text,Description,SitName,TouchName,CreatorID,OwnerID,GroupID,LastOwnerID,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,PositionX,PositionY,PositionZ,GroupPositionX,GroupPositionY,GroupPositionZ,VelocityX,VelocityY,VelocityZ,AngularVelocityX,AngularVelocityY,AngularVelocityZ,AccelerationX,AccelerationY,AccelerationZ,RotationX,RotationY,RotationZ,RotationW,ObjectFlags,SitTargetOffsetX,SitTargetOffsetY,SitTargetOffsetZ,SitTargetOrientW,SitTargetOrientX,SitTargetOrientY,SitTargetOrientZ,ColorR,ColorG,ColorB,ColorA,ClickAction,PayPrice,PayButton1,PayButton2,PayButton3,PayButton4,LoopedSound,LoopedSoundGain,TextureAnimation,ParticleSystem,OmegaX,OmegaY,OmegaZ,CameraEyeOffsetX,CameraEyeOffsetY,CameraEyeOffsetZ,CameraAtOffsetX,CameraAtOffsetY,CameraAtOffsetZ,ForceMouselook,ScriptAccessPin,AllowedDrop,DieAtEdge,SalePrice,SaleType,Material,CollisionSound,CollisionSoundVolume,VolumeDetect FROM prims; -DROP TABLE prims; -CREATE TABLE prims(UUID,RegionUUID,CreationDate,Name,SceneGroupID,Text,Description,SitName,TouchName,CreatorID,OwnerID,GroupID,LastOwnerID,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,PositionX,PositionY,PositionZ,GroupPositionX,GroupPositionY,GroupPositionZ,VelocityX,VelocityY,VelocityZ,AngularVelocityX,AngularVelocityY,AngularVelocityZ,AccelerationX,AccelerationY,AccelerationZ,RotationX,RotationY,RotationZ,RotationW,ObjectFlags,SitTargetOffsetX,SitTargetOffsetY,SitTargetOffsetZ,SitTargetOrientW,SitTargetOrientX,SitTargetOrientY,SitTargetOrientZ,ColorR,ColorG,ColorB,ColorA,ClickAction,PayPrice,PayButton1,PayButton2,PayButton3,PayButton4,LoopedSound,LoopedSoundGain,TextureAnimation,ParticleSystem,OmegaX,OmegaY,OmegaZ,CameraEyeOffsetX,CameraEyeOffsetY,CameraEyeOffsetZ,CameraAtOffsetX,CameraAtOffsetY,CameraAtOffsetZ,ForceMouselook,ScriptAccessPin,AllowedDrop,DieAtEdge,SalePrice,SaleType,Material,CollisionSound,CollisionSoundVolume,VolumeDetect); -INSERT INTO prims SELECT UUID,RegionUUID,CreationDate,Name,SceneGroupID,Text,Description,SitName,TouchName,CreatorID,OwnerID,GroupID,LastOwnerID,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,PositionX,PositionY,PositionZ,GroupPositionX,GroupPositionY,GroupPositionZ,VelocityX,VelocityY,VelocityZ,AngularVelocityX,AngularVelocityY,AngularVelocityZ,AccelerationX,AccelerationY,AccelerationZ,RotationX,RotationY,RotationZ,RotationW,ObjectFlags,SitTargetOffsetX,SitTargetOffsetY,SitTargetOffsetZ,SitTargetOrientW,SitTargetOrientX,SitTargetOrientY,SitTargetOrientZ,ColorR,ColorG,ColorB,ColorA,ClickAction,PayPrice,PayButton1,PayButton2,PayButton3,PayButton4,LoopedSound,LoopedSoundGain,TextureAnimation,ParticleSystem,OmegaX,OmegaY,OmegaZ,CameraEyeOffsetX,CameraEyeOffsetY,CameraEyeOffsetZ,CameraAtOffsetX,CameraAtOffsetY,CameraAtOffsetZ,ForceMouselook,ScriptAccessPin,AllowedDrop,DieAtEdge,SalePrice,SaleType,Material,CollisionSound,CollisionSoundVolume,VolumeDetect FROM prims_backup; -DROP TABLE prims_backup; -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/SQLiteLegacy/Resources/018_RegionStore.sql b/OpenSim/Data/SQLiteLegacy/Resources/018_RegionStore.sql deleted file mode 100644 index 6a390c2..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/018_RegionStore.sql +++ /dev/null @@ -1,79 +0,0 @@ -BEGIN; - -update terrain - set RegionUUID = substr(RegionUUID, 1, 8) || "-" || substr(RegionUUID, 9, 4) || "-" || substr(RegionUUID, 13, 4) || "-" || substr(RegionUUID, 17, 4) || "-" || substr(RegionUUID, 21, 12) - where RegionUUID not like '%-%'; - - -update landaccesslist - set LandUUID = substr(LandUUID, 1, 8) || "-" || substr(LandUUID, 9, 4) || "-" || substr(LandUUID, 13, 4) || "-" || substr(LandUUID, 17, 4) || "-" || substr(LandUUID, 21, 12) - where LandUUID not like '%-%'; - -update landaccesslist - set AccessUUID = substr(AccessUUID, 1, 8) || "-" || substr(AccessUUID, 9, 4) || "-" || substr(AccessUUID, 13, 4) || "-" || substr(AccessUUID, 17, 4) || "-" || substr(AccessUUID, 21, 12) - where AccessUUID not like '%-%'; - - -update prims - set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12) - where UUID not like '%-%'; - -update prims - set RegionUUID = substr(RegionUUID, 1, 8) || "-" || substr(RegionUUID, 9, 4) || "-" || substr(RegionUUID, 13, 4) || "-" || substr(RegionUUID, 17, 4) || "-" || substr(RegionUUID, 21, 12) - where RegionUUID not like '%-%'; - -update prims - set SceneGroupID = substr(SceneGroupID, 1, 8) || "-" || substr(SceneGroupID, 9, 4) || "-" || substr(SceneGroupID, 13, 4) || "-" || substr(SceneGroupID, 17, 4) || "-" || substr(SceneGroupID, 21, 12) - where SceneGroupID not like '%-%'; - -update prims - set CreatorID = substr(CreatorID, 1, 8) || "-" || substr(CreatorID, 9, 4) || "-" || substr(CreatorID, 13, 4) || "-" || substr(CreatorID, 17, 4) || "-" || substr(CreatorID, 21, 12) - where CreatorID not like '%-%'; - -update prims - set OwnerID = substr(OwnerID, 1, 8) || "-" || substr(OwnerID, 9, 4) || "-" || substr(OwnerID, 13, 4) || "-" || substr(OwnerID, 17, 4) || "-" || substr(OwnerID, 21, 12) - where OwnerID not like '%-%'; - -update prims - set GroupID = substr(GroupID, 1, 8) || "-" || substr(GroupID, 9, 4) || "-" || substr(GroupID, 13, 4) || "-" || substr(GroupID, 17, 4) || "-" || substr(GroupID, 21, 12) - where GroupID not like '%-%'; - -update prims - set LastOwnerID = substr(LastOwnerID, 1, 8) || "-" || substr(LastOwnerID, 9, 4) || "-" || substr(LastOwnerID, 13, 4) || "-" || substr(LastOwnerID, 17, 4) || "-" || substr(LastOwnerID, 21, 12) - where LastOwnerID not like '%-%'; - - -update primshapes - set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12) - where UUID not like '%-%'; - - -update land - set UUID = substr(UUID, 1, 8) || "-" || substr(UUID, 9, 4) || "-" || substr(UUID, 13, 4) || "-" || substr(UUID, 17, 4) || "-" || substr(UUID, 21, 12) - where UUID not like '%-%'; - -update land - set RegionUUID = substr(RegionUUID, 1, 8) || "-" || substr(RegionUUID, 9, 4) || "-" || substr(RegionUUID, 13, 4) || "-" || substr(RegionUUID, 17, 4) || "-" || substr(RegionUUID, 21, 12) - where RegionUUID not like '%-%'; - -update land - set OwnerUUID = substr(OwnerUUID, 1, 8) || "-" || substr(OwnerUUID, 9, 4) || "-" || substr(OwnerUUID, 13, 4) || "-" || substr(OwnerUUID, 17, 4) || "-" || substr(OwnerUUID, 21, 12) - where OwnerUUID not like '%-%'; - -update land - set GroupUUID = substr(GroupUUID, 1, 8) || "-" || substr(GroupUUID, 9, 4) || "-" || substr(GroupUUID, 13, 4) || "-" || substr(GroupUUID, 17, 4) || "-" || substr(GroupUUID, 21, 12) - where GroupUUID not like '%-%'; - -update land - set MediaTextureUUID = substr(MediaTextureUUID, 1, 8) || "-" || substr(MediaTextureUUID, 9, 4) || "-" || substr(MediaTextureUUID, 13, 4) || "-" || substr(MediaTextureUUID, 17, 4) || "-" || substr(MediaTextureUUID, 21, 12) - where MediaTextureUUID not like '%-%'; - -update land - set SnapshotUUID = substr(SnapshotUUID, 1, 8) || "-" || substr(SnapshotUUID, 9, 4) || "-" || substr(SnapshotUUID, 13, 4) || "-" || substr(SnapshotUUID, 17, 4) || "-" || substr(SnapshotUUID, 21, 12) - where SnapshotUUID not like '%-%'; - -update land - set AuthbuyerID = substr(AuthbuyerID, 1, 8) || "-" || substr(AuthbuyerID, 9, 4) || "-" || substr(AuthbuyerID, 13, 4) || "-" || substr(AuthbuyerID, 17, 4) || "-" || substr(AuthbuyerID, 21, 12) - where AuthbuyerID not like '%-%'; - -COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/SQLiteLegacy/Resources/OpenSim.Data.SQLite.addin.xml b/OpenSim/Data/SQLiteLegacy/Resources/OpenSim.Data.SQLite.addin.xml deleted file mode 100644 index e6764fa..0000000 --- a/OpenSim/Data/SQLiteLegacy/Resources/OpenSim.Data.SQLite.addin.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs deleted file mode 100644 index df50902..0000000 --- a/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs +++ /dev/null @@ -1,347 +0,0 @@ -/* - * 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.Data; -using System.Reflection; -using System.Collections.Generic; -using log4net; -using Mono.Data.SqliteClient; -using OpenMetaverse; -using OpenSim.Framework; - -namespace OpenSim.Data.SQLiteLegacy -{ - /// - /// An asset storage interface for the SQLite database system - /// - public class SQLiteAssetData : AssetDataBase - { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; - private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, UUID from assets limit :start, :count"; - private const string DeleteAssetSQL = "delete from assets where UUID=:UUID"; - private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Data)"; - private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, Data=:Data where UUID=:UUID"; - private const string assetSelect = "select * from assets"; - - private SqliteConnection m_conn; - - override public void Dispose() - { - if (m_conn != null) - { - m_conn.Close(); - m_conn = null; - } - } - - /// - /// - /// Initialises AssetData interface - /// Loads and initialises a new SQLite connection and maintains it. - /// use default URI if connect string is empty. - /// - /// - /// connect string - override public void Initialise(string dbconnect) - { - if (dbconnect == string.Empty) - { - dbconnect = "URI=file:Asset.db,version=3"; - } - m_conn = new SqliteConnection(dbconnect); - m_conn.Open(); - - Assembly assem = GetType().Assembly; - Migration m = new Migration(m_conn, assem, "AssetStore"); - m.Update(); - - return; - } - - /// - /// Fetch Asset - /// - /// UUID of ... ? - /// Asset base - override public AssetBase GetAsset(UUID uuid) - { - lock (this) - { - using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); - using (IDataReader reader = cmd.ExecuteReader()) - { - if (reader.Read()) - { - AssetBase asset = buildAsset(reader); - reader.Close(); - return asset; - } - else - { - reader.Close(); - return null; - } - } - } - } - } - - /// - /// Create an asset - /// - /// Asset Base - override public void StoreAsset(AssetBase asset) - { - //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID.ToString()); - if (ExistsAsset(asset.FullID)) - { - //LogAssetLoad(asset); - - lock (this) - { - using (SqliteCommand cmd = new SqliteCommand(UpdateAssetSQL, m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name)); - cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description)); - cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); - cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); - cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); - cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); - - cmd.ExecuteNonQuery(); - } - } - } - else - { - lock (this) - { - using (SqliteCommand cmd = new SqliteCommand(InsertAssetSQL, m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name)); - cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description)); - cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); - cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); - cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); - cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); - - cmd.ExecuteNonQuery(); - } - } - } - } - -// /// -// /// Some... logging functionnality -// /// -// /// -// private static void LogAssetLoad(AssetBase asset) -// { -// string temporary = asset.Temporary ? "Temporary" : "Stored"; -// string local = asset.Local ? "Local" : "Remote"; -// -// int assetLength = (asset.Data != null) ? asset.Data.Length : 0; -// -// m_log.Debug("[ASSET DB]: " + -// string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)", -// asset.FullID, asset.Name, asset.Description, asset.Type, -// temporary, local, assetLength)); -// } - - /// - /// Check if an asset exist in database - /// - /// The asset UUID - /// True if exist, or false. - override public bool ExistsAsset(UUID uuid) - { - lock (this) { - using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); - using (IDataReader reader = cmd.ExecuteReader()) - { - if (reader.Read()) - { - reader.Close(); - return true; - } - else - { - reader.Close(); - return false; - } - } - } - } - } - - /// - /// Delete an asset from database - /// - /// - public void DeleteAsset(UUID uuid) - { - using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); - - cmd.ExecuteNonQuery(); - } - } - - /// - /// - /// - /// - /// - private static AssetBase buildAsset(IDataReader row) - { - // TODO: this doesn't work yet because something more - // interesting has to be done to actually get these values - // back out. Not enough time to figure it out yet. - AssetBase asset = new AssetBase( - new UUID((String)row["UUID"]), - (String)row["Name"], - Convert.ToSByte(row["Type"]), - UUID.Zero.ToString() - ); - - asset.Description = (String) row["Description"]; - asset.Local = Convert.ToBoolean(row["Local"]); - asset.Temporary = Convert.ToBoolean(row["Temporary"]); - asset.Data = (byte[]) row["Data"]; - return asset; - } - - private static AssetMetadata buildAssetMetadata(IDataReader row) - { - AssetMetadata metadata = new AssetMetadata(); - - metadata.FullID = new UUID((string) row["UUID"]); - metadata.Name = (string) row["Name"]; - metadata.Description = (string) row["Description"]; - metadata.Type = Convert.ToSByte(row["Type"]); - metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct. - - // Current SHA1s are not stored/computed. - metadata.SHA1 = new byte[] {}; - - return metadata; - } - - /// - /// Returns a list of AssetMetadata objects. The list is a subset of - /// the entire data set offset by containing - /// elements. - /// - /// The number of results to discard from the total data set. - /// The number of rows the returned list should contain. - /// A list of AssetMetadata objects. - public override List FetchAssetMetadataSet(int start, int count) - { - List retList = new List(count); - - lock (this) - { - using (SqliteCommand cmd = new SqliteCommand(SelectAssetMetadataSQL, m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":start", start)); - cmd.Parameters.Add(new SqliteParameter(":count", count)); - - using (IDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - AssetMetadata metadata = buildAssetMetadata(reader); - retList.Add(metadata); - } - } - } - } - - return retList; - } - - /*********************************************************************** - * - * Database Binding functions - * - * These will be db specific due to typing, and minor differences - * in databases. - * - **********************************************************************/ - - #region IPlugin interface - - /// - /// - /// - override public string Version - { - get - { - Module module = GetType().Module; - // string dllName = module.Assembly.ManifestModule.Name; - Version dllVersion = module.Assembly.GetName().Version; - - return - string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, - dllVersion.Revision); - } - } - - /// - /// Initialise the AssetData interface using default URI - /// - override public void Initialise() - { - Initialise("URI=file:Asset.db,version=3"); - } - - /// - /// Name of this DB provider - /// - override public string Name - { - get { return "SQLite Asset storage engine"; } - } - - public override bool Delete(string id) - { - return false; - } - #endregion - } -} diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteAuthenticationData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteAuthenticationData.cs deleted file mode 100644 index 760221d..0000000 --- a/OpenSim/Data/SQLiteLegacy/SQLiteAuthenticationData.cs +++ /dev/null @@ -1,266 +0,0 @@ -/* - * 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; -using System.Collections.Generic; -using System.Data; -using System.Reflection; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using Mono.Data.SqliteClient; - -namespace OpenSim.Data.SQLiteLegacy -{ - public class SQLiteAuthenticationData : SQLiteFramework, IAuthenticationData - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private string m_Realm; - private List m_ColumnNames; - private int m_LastExpire; - private string m_connectionString; - - protected static SqliteConnection m_Connection; - private static bool m_initialized = false; - - public SQLiteAuthenticationData(string connectionString, string realm) - : base(connectionString) - { - m_Realm = realm; - m_connectionString = connectionString; - - if (!m_initialized) - { - m_Connection = new SqliteConnection(connectionString); - m_Connection.Open(); - - using (SqliteConnection dbcon = (SqliteConnection)((ICloneable)m_Connection).Clone()) - { - dbcon.Open(); - Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); - m.Update(); - dbcon.Close(); - } - - m_initialized = true; - } - } - - public AuthenticationData Get(UUID principalID) - { - AuthenticationData ret = new AuthenticationData(); - ret.Data = new Dictionary(); - - SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID"); - cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); - - IDataReader result = ExecuteReader(cmd, m_Connection); - - try - { - if (result.Read()) - { - ret.PrincipalID = principalID; - - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - - foreach (string s in m_ColumnNames) - { - if (s == "UUID") - continue; - - ret.Data[s] = result[s].ToString(); - } - - return ret; - } - else - { - return null; - } - } - catch - { - } - finally - { - CloseCommand(cmd); - } - - return null; - } - - public bool Store(AuthenticationData data) - { - if (data.Data.ContainsKey("UUID")) - data.Data.Remove("UUID"); - - string[] fields = new List(data.Data.Keys).ToArray(); - string[] values = new string[data.Data.Count]; - int i = 0; - foreach (object o in data.Data.Values) - values[i++] = o.ToString(); - - SqliteCommand cmd = new SqliteCommand(); - - if (Get(data.PrincipalID) != null) - { - - - string update = "update `" + m_Realm + "` set "; - bool first = true; - foreach (string field in fields) - { - if (!first) - update += ", "; - update += "`" + field + "` = :" + field; - cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); - - first = false; - } - - update += " where UUID = :UUID"; - cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); - - cmd.CommandText = update; - try - { - if (ExecuteNonQuery(cmd, m_Connection) < 1) - { - CloseCommand(cmd); - return false; - } - } - catch (Exception e) - { - m_log.Error("[SQLITE]: Exception storing authentication data", e); - CloseCommand(cmd); - return false; - } - } - - else - { - string insert = "insert into `" + m_Realm + "` (`UUID`, `" + - String.Join("`, `", fields) + - "`) values (:UUID, :" + String.Join(", :", fields) + ")"; - - cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); - foreach (string field in fields) - cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); - - cmd.CommandText = insert; - - try - { - if (ExecuteNonQuery(cmd, m_Connection) < 1) - { - CloseCommand(cmd); - return false; - } - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - CloseCommand(cmd); - return false; - } - } - - CloseCommand(cmd); - - return true; - } - - public bool SetDataItem(UUID principalID, string item, string value) - { - SqliteCommand cmd = new SqliteCommand("update `" + m_Realm + - "` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'"); - - if (ExecuteNonQuery(cmd, m_Connection) > 0) - return true; - - return false; - } - - public bool SetToken(UUID principalID, string token, int lifetime) - { - if (System.Environment.TickCount - m_LastExpire > 30000) - DoExpire(); - - SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() + - "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))"); - - if (ExecuteNonQuery(cmd, m_Connection) > 0) - { - cmd.Dispose(); - return true; - } - - cmd.Dispose(); - return false; - } - - public bool CheckToken(UUID principalID, string token, int lifetime) - { - if (System.Environment.TickCount - m_LastExpire > 30000) - DoExpire(); - - SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() + - " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')"); - - if (ExecuteNonQuery(cmd, m_Connection) > 0) - { - cmd.Dispose(); - return true; - } - - cmd.Dispose(); - - return false; - } - - private void DoExpire() - { - SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')"); - ExecuteNonQuery(cmd, m_Connection); - - cmd.Dispose(); - - m_LastExpire = System.Environment.TickCount; - } - } -} diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteAvatarData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteAvatarData.cs deleted file mode 100644 index 660632c..0000000 --- a/OpenSim/Data/SQLiteLegacy/SQLiteAvatarData.cs +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.Data; -using System.Reflection; -using System.Threading; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using Mono.Data.SqliteClient; - -namespace OpenSim.Data.SQLiteLegacy -{ - /// - /// A SQLite Interface for Avatar Data - /// - public class SQLiteAvatarData : SQLiteGenericTableHandler, - IAvatarData - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public SQLiteAvatarData(string connectionString, string realm) : - base(connectionString, realm, "Avatar") - { - } - - public bool Delete(UUID principalID, string name) - { - SqliteCommand cmd = new SqliteCommand(); - - cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm); - cmd.Parameters.Add(":PrincipalID", principalID.ToString()); - cmd.Parameters.Add(":Name", name); - - try - { - if (ExecuteNonQuery(cmd, m_Connection) > 0) - return true; - - return false; - } - finally - { - CloseCommand(cmd); - } - } - } -} diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs deleted file mode 100644 index 4dd225f..0000000 --- a/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs +++ /dev/null @@ -1,451 +0,0 @@ -/* - * 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.Data; -using System.Reflection; -using log4net; -using Mono.Data.SqliteClient; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; - -namespace OpenSim.Data.SQLiteLegacy -{ - public class SQLiteEstateStore : IEstateDataStore - { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private SqliteConnection m_connection; - private string m_connectionString; - - private FieldInfo[] m_Fields; - private Dictionary m_FieldMap = - new Dictionary(); - - public SQLiteEstateStore() - { - } - - public SQLiteEstateStore(string connectionString) - { - Initialise(connectionString); - } - - public void Initialise(string connectionString) - { - m_connectionString = connectionString; - - m_log.Info("[ESTATE DB]: Sqlite - connecting: "+m_connectionString); - - m_connection = new SqliteConnection(m_connectionString); - m_connection.Open(); - - Assembly assem = GetType().Assembly; - Migration m = new Migration(m_connection, assem, "EstateStore"); - m.Update(); - - m_connection.Close(); - m_connection.Open(); - - Type t = typeof(EstateSettings); - m_Fields = t.GetFields(BindingFlags.NonPublic | - BindingFlags.Instance | - BindingFlags.DeclaredOnly); - - foreach (FieldInfo f in m_Fields) - if (f.Name.Substring(0, 2) == "m_") - m_FieldMap[f.Name.Substring(2)] = f; - } - - private string[] FieldList - { - get { return new List(m_FieldMap.Keys).ToArray(); } - } - - public EstateSettings LoadEstateSettings(UUID regionID, bool create) - { - string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID"; - - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = sql; - cmd.Parameters.Add(":RegionID", regionID.ToString()); - - return DoLoad(cmd, regionID, create); - } - - public List LoadEstateSettingsAll() - { - List estateSettings = new List(); - - List estateIds = GetEstatesAll(); - foreach (int estateId in estateIds) - estateSettings.Add(LoadEstateSettings(estateId)); - - return estateSettings; - } - - private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create) - { - EstateSettings es = new EstateSettings(); - es.OnSave += StoreEstateSettings; - - IDataReader r = cmd.ExecuteReader(); - - if (r.Read()) - { - foreach (string name in FieldList) - { - if (m_FieldMap[name].GetValue(es) is bool) - { - int v = Convert.ToInt32(r[name]); - if (v != 0) - m_FieldMap[name].SetValue(es, true); - else - m_FieldMap[name].SetValue(es, false); - } - else if (m_FieldMap[name].GetValue(es) is UUID) - { - UUID uuid = UUID.Zero; - - UUID.TryParse(r[name].ToString(), out uuid); - m_FieldMap[name].SetValue(es, uuid); - } - else - { - m_FieldMap[name].SetValue(es, Convert.ChangeType(r[name], m_FieldMap[name].FieldType)); - } - } - r.Close(); - } - else if (create) - { - r.Close(); - - List names = new List(FieldList); - - names.Remove("EstateID"); - - string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")"; - - cmd.CommandText = sql; - cmd.Parameters.Clear(); - - foreach (string name in FieldList) - { - if (m_FieldMap[name].GetValue(es) is bool) - { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.Add(":"+name, "1"); - else - cmd.Parameters.Add(":"+name, "0"); - } - else - { - cmd.Parameters.Add(":"+name, m_FieldMap[name].GetValue(es).ToString()); - } - } - - cmd.ExecuteNonQuery(); - - cmd.CommandText = "select LAST_INSERT_ROWID() as id"; - cmd.Parameters.Clear(); - - r = cmd.ExecuteReader(); - - r.Read(); - - es.EstateID = Convert.ToUInt32(r["id"]); - - r.Close(); - - cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)"; - cmd.Parameters.Add(":RegionID", regionID.ToString()); - cmd.Parameters.Add(":EstateID", es.EstateID.ToString()); - - // This will throw on dupe key - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception) - { - } - - es.Save(); - } - - LoadBanList(es); - - es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); - es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); - es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); - return es; - } - - public void StoreEstateSettings(EstateSettings es) - { - List fields = new List(FieldList); - fields.Remove("EstateID"); - - List terms = new List(); - - foreach (string f in fields) - terms.Add(f+" = :"+f); - - string sql = "update estate_settings set "+String.Join(", ", terms.ToArray())+" where EstateID = :EstateID"; - - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = sql; - - foreach (string name in FieldList) - { - if (m_FieldMap[name].GetValue(es) is bool) - { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.Add(":"+name, "1"); - else - cmd.Parameters.Add(":"+name, "0"); - } - else - { - cmd.Parameters.Add(":"+name, m_FieldMap[name].GetValue(es).ToString()); - } - } - - cmd.ExecuteNonQuery(); - - SaveBanList(es); - SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); - SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); - SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups); - } - - private void LoadBanList(EstateSettings es) - { - es.ClearBans(); - - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID"; - cmd.Parameters.Add(":EstateID", es.EstateID); - - IDataReader r = cmd.ExecuteReader(); - - while (r.Read()) - { - EstateBan eb = new EstateBan(); - - UUID uuid = new UUID(); - UUID.TryParse(r["bannedUUID"].ToString(), out uuid); - - eb.BannedUserID = uuid; - eb.BannedHostAddress = "0.0.0.0"; - eb.BannedHostIPMask = "0.0.0.0"; - es.AddBan(eb); - } - r.Close(); - } - - private void SaveBanList(EstateSettings es) - { - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = "delete from estateban where EstateID = :EstateID"; - cmd.Parameters.Add(":EstateID", es.EstateID.ToString()); - - cmd.ExecuteNonQuery(); - - cmd.Parameters.Clear(); - - cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( :EstateID, :bannedUUID, '', '', '' )"; - - foreach (EstateBan b in es.EstateBans) - { - cmd.Parameters.Add(":EstateID", es.EstateID.ToString()); - cmd.Parameters.Add(":bannedUUID", b.BannedUserID.ToString()); - - cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); - } - } - - void SaveUUIDList(uint EstateID, string table, UUID[] data) - { - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = "delete from "+table+" where EstateID = :EstateID"; - cmd.Parameters.Add(":EstateID", EstateID.ToString()); - - cmd.ExecuteNonQuery(); - - cmd.Parameters.Clear(); - - cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( :EstateID, :uuid )"; - - foreach (UUID uuid in data) - { - cmd.Parameters.Add(":EstateID", EstateID.ToString()); - cmd.Parameters.Add(":uuid", uuid.ToString()); - - cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); - } - } - - UUID[] LoadUUIDList(uint EstateID, string table) - { - List uuids = new List(); - - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID"; - cmd.Parameters.Add(":EstateID", EstateID); - - IDataReader r = cmd.ExecuteReader(); - - while (r.Read()) - { - // EstateBan eb = new EstateBan(); - - UUID uuid = new UUID(); - UUID.TryParse(r["uuid"].ToString(), out uuid); - - uuids.Add(uuid); - } - r.Close(); - - return uuids.ToArray(); - } - - public EstateSettings LoadEstateSettings(int estateID) - { - string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID = :EstateID"; - - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = sql; - cmd.Parameters.Add(":EstateID", estateID.ToString()); - - return DoLoad(cmd, UUID.Zero, false); - } - - public List GetEstates(string search) - { - List result = new List(); - - string sql = "select EstateID from estate_settings where estate_settings.EstateName = :EstateName"; - - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = sql; - cmd.Parameters.Add(":EstateName", search); - - IDataReader r = cmd.ExecuteReader(); - - while (r.Read()) - { - result.Add(Convert.ToInt32(r["EstateID"])); - } - r.Close(); - - return result; - } - - - public List GetEstatesAll() - { - List result = new List(); - - string sql = "select EstateID from estate_settings"; - - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = sql; - - IDataReader r = cmd.ExecuteReader(); - - while (r.Read()) - { - result.Add(Convert.ToInt32(r["EstateID"])); - } - r.Close(); - - return result; - } - - public List GetEstatesByOwner(UUID ownerID) - { - List result = new List(); - - string sql = "select EstateID from estate_settings where estate_settings.EstateOwner = :EstateOwner"; - - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = sql; - cmd.Parameters.Add(":EstateOwner", ownerID); - - IDataReader r = cmd.ExecuteReader(); - - while (r.Read()) - { - result.Add(Convert.ToInt32(r["EstateID"])); - } - r.Close(); - - return result; - } - - public bool LinkRegion(UUID regionID, int estateID) - { - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)"; - cmd.Parameters.Add(":RegionID", regionID.ToString()); - cmd.Parameters.Add(":EstateID", estateID.ToString()); - - if (cmd.ExecuteNonQuery() == 0) - return false; - - return true; - } - - public List GetRegions(int estateID) - { - return new List(); - } - - public bool DeleteEstate(int estateID) - { - return false; - } - } -} diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteFramework.cs b/OpenSim/Data/SQLiteLegacy/SQLiteFramework.cs deleted file mode 100644 index 606478e..0000000 --- a/OpenSim/Data/SQLiteLegacy/SQLiteFramework.cs +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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; -using System.Collections.Generic; -using System.Data; -using OpenMetaverse; -using OpenSim.Framework; -using Mono.Data.SqliteClient; - -namespace OpenSim.Data.SQLiteLegacy -{ - /// - /// A database interface class to a user profile storage system - /// - public class SQLiteFramework - { - protected Object m_lockObject = new Object(); - - protected SQLiteFramework(string connectionString) - { - } - - ////////////////////////////////////////////////////////////// - // - // All non queries are funneled through one connection - // to increase performance a little - // - protected int ExecuteNonQuery(SqliteCommand cmd, SqliteConnection connection) - { - lock (connection) - { - SqliteConnection newConnection = - (SqliteConnection)((ICloneable)connection).Clone(); - newConnection.Open(); - - cmd.Connection = newConnection; - //Console.WriteLine("XXX " + cmd.CommandText); - - return cmd.ExecuteNonQuery(); - } - } - - protected IDataReader ExecuteReader(SqliteCommand cmd, SqliteConnection connection) - { - lock (connection) - { - SqliteConnection newConnection = - (SqliteConnection)((ICloneable)connection).Clone(); - newConnection.Open(); - - cmd.Connection = newConnection; - //Console.WriteLine("XXX " + cmd.CommandText); - - return cmd.ExecuteReader(); - } - } - - protected void CloseCommand(SqliteCommand cmd) - { - cmd.Connection.Close(); - cmd.Connection.Dispose(); - cmd.Dispose(); - } - } -} diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteFriendsData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteFriendsData.cs deleted file mode 100644 index d529d4d..0000000 --- a/OpenSim/Data/SQLiteLegacy/SQLiteFriendsData.cs +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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; -using System.Collections.Generic; -using System.Data; -using OpenMetaverse; -using OpenSim.Framework; -using Mono.Data.SqliteClient; - -namespace OpenSim.Data.SQLiteLegacy -{ - public class SQLiteFriendsData : SQLiteGenericTableHandler, IFriendsData - { - public SQLiteFriendsData(string connectionString, string realm) - : base(connectionString, realm, "FriendsStore") - { - } - - public FriendsData[] GetFriends(UUID userID) - { - SqliteCommand cmd = new SqliteCommand(); - - cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm); - cmd.Parameters.Add(":PrincipalID", userID.ToString()); - - return DoQuery(cmd); - - } - - public bool Delete(UUID principalID, string friend) - { - SqliteCommand cmd = new SqliteCommand(); - - cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm); - cmd.Parameters.Add(":PrincipalID", principalID.ToString()); - cmd.Parameters.Add(":Friend", friend); - - ExecuteNonQuery(cmd, cmd.Connection); - - return true; - } - - } -} diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLiteLegacy/SQLiteGenericTableHandler.cs deleted file mode 100644 index 1c1fe8c..0000000 --- a/OpenSim/Data/SQLiteLegacy/SQLiteGenericTableHandler.cs +++ /dev/null @@ -1,268 +0,0 @@ -/* - * 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.Data; -using System.Reflection; -using log4net; -using Mono.Data.SqliteClient; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; - -namespace OpenSim.Data.SQLiteLegacy -{ - public class SQLiteGenericTableHandler : SQLiteFramework where T: class, new() - { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected Dictionary m_Fields = - new Dictionary(); - - protected List m_ColumnNames = null; - protected string m_Realm; - protected FieldInfo m_DataField = null; - - protected static SqliteConnection m_Connection; - private static bool m_initialized; - - public SQLiteGenericTableHandler(string connectionString, - string realm, string storeName) : base(connectionString) - { - m_Realm = realm; - - if (!m_initialized) - { - m_Connection = new SqliteConnection(connectionString); - m_Connection.Open(); - - if (storeName != String.Empty) - { - Assembly assem = GetType().Assembly; - SqliteConnection newConnection = - (SqliteConnection)((ICloneable)m_Connection).Clone(); - newConnection.Open(); - - Migration m = new Migration(newConnection, assem, storeName); - m.Update(); - newConnection.Close(); - newConnection.Dispose(); - } - - m_initialized = true; - } - - Type t = typeof(T); - FieldInfo[] fields = t.GetFields(BindingFlags.Public | - BindingFlags.Instance | - BindingFlags.DeclaredOnly); - - if (fields.Length == 0) - return; - - foreach (FieldInfo f in fields) - { - if (f.Name != "Data") - m_Fields[f.Name] = f; - else - m_DataField = f; - } - } - - private void CheckColumnNames(IDataReader reader) - { - if (m_ColumnNames != null) - return; - - m_ColumnNames = new List(); - - DataTable schemaTable = reader.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - { - if (row["ColumnName"] != null && - (!m_Fields.ContainsKey(row["ColumnName"].ToString()))) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - } - - public T[] Get(string field, string key) - { - return Get(new string[] { field }, new string[] { key }); - } - - public T[] Get(string[] fields, string[] keys) - { - if (fields.Length != keys.Length) - return new T[0]; - - List terms = new List(); - - SqliteCommand cmd = new SqliteCommand(); - - for (int i = 0 ; i < fields.Length ; i++) - { - cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); - terms.Add("`" + fields[i] + "` = :" + fields[i]); - } - - string where = String.Join(" and ", terms.ToArray()); - - string query = String.Format("select * from {0} where {1}", - m_Realm, where); - - cmd.CommandText = query; - - return DoQuery(cmd); - } - - protected T[] DoQuery(SqliteCommand cmd) - { - IDataReader reader = ExecuteReader(cmd, m_Connection); - if (reader == null) - return new T[0]; - - CheckColumnNames(reader); - - List result = new List(); - - while (reader.Read()) - { - T row = new T(); - - foreach (string name in m_Fields.Keys) - { - if (m_Fields[name].GetValue(row) is bool) - { - int v = Convert.ToInt32(reader[name]); - m_Fields[name].SetValue(row, v != 0 ? true : false); - } - else if (m_Fields[name].GetValue(row) is UUID) - { - UUID uuid = UUID.Zero; - - UUID.TryParse(reader[name].ToString(), out uuid); - m_Fields[name].SetValue(row, uuid); - } - else if (m_Fields[name].GetValue(row) is int) - { - int v = Convert.ToInt32(reader[name]); - m_Fields[name].SetValue(row, v); - } - else - { - m_Fields[name].SetValue(row, reader[name]); - } - } - - if (m_DataField != null) - { - Dictionary data = - new Dictionary(); - - foreach (string col in m_ColumnNames) - { - data[col] = reader[col].ToString(); - if (data[col] == null) - data[col] = String.Empty; - } - - m_DataField.SetValue(row, data); - } - - result.Add(row); - } - - CloseCommand(cmd); - - return result.ToArray(); - } - - public T[] Get(string where) - { - SqliteCommand cmd = new SqliteCommand(); - - string query = String.Format("select * from {0} where {1}", - m_Realm, where); - - cmd.CommandText = query; - - return DoQuery(cmd); - } - - public bool Store(T row) - { - SqliteCommand cmd = new SqliteCommand(); - - string query = ""; - List names = new List(); - List values = new List(); - - foreach (FieldInfo fi in m_Fields.Values) - { - names.Add(fi.Name); - values.Add(":" + fi.Name); - cmd.Parameters.Add(new SqliteParameter(":" + fi.Name, fi.GetValue(row).ToString())); - } - - if (m_DataField != null) - { - Dictionary data = - (Dictionary)m_DataField.GetValue(row); - - foreach (KeyValuePair kvp in data) - { - names.Add(kvp.Key); - values.Add(":" + kvp.Key); - cmd.Parameters.Add(new SqliteParameter(":" + kvp.Key, kvp.Value)); - } - } - - query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; - - cmd.CommandText = query; - - if (ExecuteNonQuery(cmd, m_Connection) > 0) - return true; - - return false; - } - - public bool Delete(string field, string val) - { - SqliteCommand cmd = new SqliteCommand(); - - cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field); - cmd.Parameters.Add(new SqliteParameter(field, val)); - - if (ExecuteNonQuery(cmd, m_Connection) > 0) - return true; - - return false; - } - } -} diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteInventoryStore.cs b/OpenSim/Data/SQLiteLegacy/SQLiteInventoryStore.cs deleted file mode 100644 index 8ca48f9..0000000 --- a/OpenSim/Data/SQLiteLegacy/SQLiteInventoryStore.cs +++ /dev/null @@ -1,898 +0,0 @@ -/* - * 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.Data; -using System.Reflection; -using log4net; -using Mono.Data.SqliteClient; -using OpenMetaverse; -using OpenSim.Framework; - -namespace OpenSim.Data.SQLiteLegacy -{ - /// - /// An Inventory Interface to the SQLite database - /// - public class SQLiteInventoryStore : SQLiteUtil, IInventoryDataPlugin - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private const string invItemsSelect = "select * from inventoryitems"; - private const string invFoldersSelect = "select * from inventoryfolders"; - - private static SqliteConnection conn; - private static DataSet ds; - private static SqliteDataAdapter invItemsDa; - private static SqliteDataAdapter invFoldersDa; - - private static bool m_Initialized = false; - - public void Initialise() - { - m_log.Info("[SQLiteInventoryData]: " + Name + " cannot be default-initialized!"); - throw new PluginNotInitialisedException(Name); - } - - /// - /// - /// Initialises Inventory interface - /// Loads and initialises a new SQLite connection and maintains it. - /// use default URI if connect string string is empty. - /// - /// - /// connect string - public void Initialise(string dbconnect) - { - if (!m_Initialized) - { - m_Initialized = true; - - if (dbconnect == string.Empty) - { - dbconnect = "URI=file:inventoryStore.db,version=3"; - } - m_log.Info("[INVENTORY DB]: Sqlite - connecting: " + dbconnect); - conn = new SqliteConnection(dbconnect); - - conn.Open(); - - Assembly assem = GetType().Assembly; - Migration m = new Migration(conn, assem, "InventoryStore"); - m.Update(); - - SqliteCommand itemsSelectCmd = new SqliteCommand(invItemsSelect, conn); - invItemsDa = new SqliteDataAdapter(itemsSelectCmd); - // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); - - SqliteCommand foldersSelectCmd = new SqliteCommand(invFoldersSelect, conn); - invFoldersDa = new SqliteDataAdapter(foldersSelectCmd); - - ds = new DataSet(); - - ds.Tables.Add(createInventoryFoldersTable()); - invFoldersDa.Fill(ds.Tables["inventoryfolders"]); - setupFoldersCommands(invFoldersDa, conn); - m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions"); - - ds.Tables.Add(createInventoryItemsTable()); - invItemsDa.Fill(ds.Tables["inventoryitems"]); - setupItemsCommands(invItemsDa, conn); - m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions"); - - ds.AcceptChanges(); - } - } - - /// - /// Closes the inventory interface - /// - public void Dispose() - { - if (conn != null) - { - conn.Close(); - conn = null; - } - if (invItemsDa != null) - { - invItemsDa.Dispose(); - invItemsDa = null; - } - if (invFoldersDa != null) - { - invFoldersDa.Dispose(); - invFoldersDa = null; - } - if (ds != null) - { - ds.Dispose(); - ds = null; - } - } - - /// - /// - /// - /// - /// - public InventoryItemBase buildItem(DataRow row) - { - InventoryItemBase item = new InventoryItemBase(); - item.ID = new UUID((string) row["UUID"]); - item.AssetID = new UUID((string) row["assetID"]); - item.AssetType = Convert.ToInt32(row["assetType"]); - item.InvType = Convert.ToInt32(row["invType"]); - item.Folder = new UUID((string) row["parentFolderID"]); - item.Owner = new UUID((string) row["avatarID"]); - item.CreatorIdentification = (string)row["creatorsID"]; - item.Name = (string) row["inventoryName"]; - item.Description = (string) row["inventoryDescription"]; - - item.NextPermissions = Convert.ToUInt32(row["inventoryNextPermissions"]); - item.CurrentPermissions = Convert.ToUInt32(row["inventoryCurrentPermissions"]); - item.BasePermissions = Convert.ToUInt32(row["inventoryBasePermissions"]); - item.EveryOnePermissions = Convert.ToUInt32(row["inventoryEveryOnePermissions"]); - item.GroupPermissions = Convert.ToUInt32(row["inventoryGroupPermissions"]); - - // new fields - if (!Convert.IsDBNull(row["salePrice"])) - item.SalePrice = Convert.ToInt32(row["salePrice"]); - - if (!Convert.IsDBNull(row["saleType"])) - item.SaleType = Convert.ToByte(row["saleType"]); - - if (!Convert.IsDBNull(row["creationDate"])) - item.CreationDate = Convert.ToInt32(row["creationDate"]); - - if (!Convert.IsDBNull(row["groupID"])) - item.GroupID = new UUID((string)row["groupID"]); - - if (!Convert.IsDBNull(row["groupOwned"])) - item.GroupOwned = Convert.ToBoolean(row["groupOwned"]); - - if (!Convert.IsDBNull(row["Flags"])) - item.Flags = Convert.ToUInt32(row["Flags"]); - - return item; - } - - /// - /// Fill a database row with item data - /// - /// - /// - private static void fillItemRow(DataRow row, InventoryItemBase item) - { - row["UUID"] = item.ID.ToString(); - row["assetID"] = item.AssetID.ToString(); - row["assetType"] = item.AssetType; - row["invType"] = item.InvType; - row["parentFolderID"] = item.Folder.ToString(); - row["avatarID"] = item.Owner.ToString(); - row["creatorsID"] = item.CreatorIdentification.ToString(); - row["inventoryName"] = item.Name; - row["inventoryDescription"] = item.Description; - - row["inventoryNextPermissions"] = item.NextPermissions; - row["inventoryCurrentPermissions"] = item.CurrentPermissions; - row["inventoryBasePermissions"] = item.BasePermissions; - row["inventoryEveryOnePermissions"] = item.EveryOnePermissions; - row["inventoryGroupPermissions"] = item.GroupPermissions; - - // new fields - row["salePrice"] = item.SalePrice; - row["saleType"] = item.SaleType; - row["creationDate"] = item.CreationDate; - row["groupID"] = item.GroupID.ToString(); - row["groupOwned"] = item.GroupOwned; - row["flags"] = item.Flags; - } - - /// - /// Add inventory folder - /// - /// Folder base - /// true=create folder. false=update existing folder - /// nasty - private void addFolder(InventoryFolderBase folder, bool add) - { - lock (ds) - { - DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; - - DataRow inventoryRow = inventoryFolderTable.Rows.Find(folder.ID.ToString()); - if (inventoryRow == null) - { - if (! add) - m_log.ErrorFormat("Interface Misuse: Attempting to Update non-existant inventory folder: {0}", folder.ID); - - inventoryRow = inventoryFolderTable.NewRow(); - fillFolderRow(inventoryRow, folder); - inventoryFolderTable.Rows.Add(inventoryRow); - } - else - { - if (add) - m_log.ErrorFormat("Interface Misuse: Attempting to Add inventory folder that already exists: {0}", folder.ID); - - fillFolderRow(inventoryRow, folder); - } - - invFoldersDa.Update(ds, "inventoryfolders"); - } - } - - /// - /// Move an inventory folder - /// - /// folder base - private void moveFolder(InventoryFolderBase folder) - { - lock (ds) - { - DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; - - DataRow inventoryRow = inventoryFolderTable.Rows.Find(folder.ID.ToString()); - if (inventoryRow == null) - { - inventoryRow = inventoryFolderTable.NewRow(); - fillFolderRow(inventoryRow, folder); - inventoryFolderTable.Rows.Add(inventoryRow); - } - else - { - moveFolderRow(inventoryRow, folder); - } - - invFoldersDa.Update(ds, "inventoryfolders"); - } - } - - /// - /// add an item in inventory - /// - /// the item - /// true=add item ; false=update existing item - private void addItem(InventoryItemBase item, bool add) - { - lock (ds) - { - DataTable inventoryItemTable = ds.Tables["inventoryitems"]; - - DataRow inventoryRow = inventoryItemTable.Rows.Find(item.ID.ToString()); - if (inventoryRow == null) - { - if (!add) - m_log.ErrorFormat("[INVENTORY DB]: Interface Misuse: Attempting to Update non-existant inventory item: {0}", item.ID); - - inventoryRow = inventoryItemTable.NewRow(); - fillItemRow(inventoryRow, item); - inventoryItemTable.Rows.Add(inventoryRow); - } - else - { - if (add) - m_log.ErrorFormat("[INVENTORY DB]: Interface Misuse: Attempting to Add inventory item that already exists: {0}", item.ID); - - fillItemRow(inventoryRow, item); - } - - invItemsDa.Update(ds, "inventoryitems"); - - DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; - - inventoryRow = inventoryFolderTable.Rows.Find(item.Folder.ToString()); - if (inventoryRow != null) //MySQL doesn't throw an exception here, so sqlite shouldn't either. - inventoryRow["version"] = (int)inventoryRow["version"] + 1; - - invFoldersDa.Update(ds, "inventoryfolders"); - } - } - - /// - /// TODO : DataSet commit - /// - public void Shutdown() - { - // TODO: DataSet commit - } - - /// - /// The name of this DB provider - /// - /// Name of DB provider - public string Name - { - get { return "SQLite Inventory Data Interface"; } - } - - /// - /// Returns the version of this DB provider - /// - /// A string containing the DB provider version - public string Version - { - get - { - Module module = GetType().Module; - // string dllName = module.Assembly.ManifestModule.Name; - Version dllVersion = module.Assembly.GetName().Version; - - - return - string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, - dllVersion.Revision); - } - } - - /// - /// Returns a list of inventory items contained within the specified folder - /// - /// The UUID of the target folder - /// A List of InventoryItemBase items - public List getInventoryInFolder(UUID folderID) - { - lock (ds) - { - List retval = new List(); - DataTable inventoryItemTable = ds.Tables["inventoryitems"]; - string selectExp = "parentFolderID = '" + folderID + "'"; - DataRow[] rows = inventoryItemTable.Select(selectExp); - foreach (DataRow row in rows) - { - retval.Add(buildItem(row)); - } - - return retval; - } - } - - /// - /// Returns a list of the root folders within a users inventory - /// - /// The user whos inventory is to be searched - /// A list of folder objects - public List getUserRootFolders(UUID user) - { - return new List(); - } - - // see InventoryItemBase.getUserRootFolder - public InventoryFolderBase getUserRootFolder(UUID user) - { - lock (ds) - { - List folders = new List(); - DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; - string selectExp = "agentID = '" + user + "' AND parentID = '" + UUID.Zero + "'"; - DataRow[] rows = inventoryFolderTable.Select(selectExp); - foreach (DataRow row in rows) - { - folders.Add(buildFolder(row)); - } - - // There should only ever be one root folder for a user. However, if there's more - // than one we'll simply use the first one rather than failing. It would be even - // nicer to print some message to this effect, but this feels like it's too low a - // to put such a message out, and it's too minor right now to spare the time to - // suitably refactor. - if (folders.Count > 0) - { - return folders[0]; - } - - return null; - } - } - - /// - /// Append a list of all the child folders of a parent folder - /// - /// list where folders will be appended - /// ID of parent - protected void getInventoryFolders(ref List folders, UUID parentID) - { - lock (ds) - { - DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; - string selectExp = "parentID = '" + parentID + "'"; - DataRow[] rows = inventoryFolderTable.Select(selectExp); - foreach (DataRow row in rows) - { - folders.Add(buildFolder(row)); - } - - } - } - - /// - /// Returns a list of inventory folders contained in the folder 'parentID' - /// - /// The folder to get subfolders for - /// A list of inventory folders - public List getInventoryFolders(UUID parentID) - { - List folders = new List(); - getInventoryFolders(ref folders, parentID); - return folders; - } - - /// - /// See IInventoryDataPlugin - /// - /// - /// - public List getFolderHierarchy(UUID parentID) - { - /* Note: There are subtle changes between this implementation of getFolderHierarchy and the previous one - * - We will only need to hit the database twice instead of n times. - * - We assume the database is well-formed - no stranded/dangling folders, all folders in heirarchy owned - * by the same person, each user only has 1 inventory heirarchy - * - The returned list is not ordered, instead of breadth-first ordered - There are basically 2 usage cases for getFolderHeirarchy: - 1) Getting the user's entire inventory heirarchy when they log in - 2) Finding a subfolder heirarchy to delete when emptying the trash. - This implementation will pull all inventory folders from the database, and then prune away any folder that - is not part of the requested sub-heirarchy. The theory is that it is cheaper to make 1 request from the - database than to make n requests. This pays off only if requested heirarchy is large. - By making this choice, we are making the worst case better at the cost of making the best case worse - - Francis - */ - - List folders = new List(); - DataRow[] folderRows = null, parentRow; - InventoryFolderBase parentFolder = null; - lock (ds) - { - /* Fetch the parent folder from the database to determine the agent ID. - * Then fetch all inventory folders for that agent from the agent ID. - */ - DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; - string selectExp = "UUID = '" + parentID + "'"; - parentRow = inventoryFolderTable.Select(selectExp); // Assume at most 1 result - if (parentRow.GetLength(0) >= 1) // No result means parent folder does not exist - { - parentFolder = buildFolder(parentRow[0]); - UUID agentID = parentFolder.Owner; - selectExp = "agentID = '" + agentID + "'"; - folderRows = inventoryFolderTable.Select(selectExp); - } - - if (folderRows != null && folderRows.GetLength(0) >= 1) // No result means parent folder does not exist - { // or has no children - /* if we're querying the root folder, just return an unordered list of all folders in the user's - * inventory - */ - if (parentFolder.ParentID == UUID.Zero) - { - foreach (DataRow row in folderRows) - { - InventoryFolderBase curFolder = buildFolder(row); - if (curFolder.ID != parentID) // Return all folders except the parent folder of heirarchy - folders.Add(buildFolder(row)); - } - } // If requesting root folder - /* else we are querying a non-root folder. We currently have a list of all of the user's folders, - * we must construct a list of all folders in the heirarchy below parentID. - * Our first step will be to construct a hash table of all folders, indexed by parent ID. - * Once we have constructed the hash table, we will do a breadth-first traversal on the tree using the - * hash table to find child folders. - */ - else - { // Querying a non-root folder - - // Build a hash table of all user's inventory folders, indexed by each folder's parent ID - Dictionary> hashtable = - new Dictionary>(folderRows.GetLength(0)); - - foreach (DataRow row in folderRows) - { - InventoryFolderBase curFolder = buildFolder(row); - if (curFolder.ParentID != UUID.Zero) // Discard root of tree - not needed - { - if (hashtable.ContainsKey(curFolder.ParentID)) - { - // Current folder already has a sibling - append to sibling list - hashtable[curFolder.ParentID].Add(curFolder); - } - else - { - List siblingList = new List(); - siblingList.Add(curFolder); - // Current folder has no known (yet) siblings - hashtable.Add(curFolder.ParentID, siblingList); - } - } - } // For all inventory folders - - // Note: Could release the ds lock here - we don't access folderRows or the database anymore. - // This is somewhat of a moot point as the callers of this function usually lock db anyways. - - if (hashtable.ContainsKey(parentID)) // if requested folder does have children - folders.AddRange(hashtable[parentID]); - - // BreadthFirstSearch build inventory tree **Note: folders.Count is *not* static - for (int i = 0; i < folders.Count; i++) - if (hashtable.ContainsKey(folders[i].ID)) - folders.AddRange(hashtable[folders[i].ID]); - - } // if requesting a subfolder heirarchy - } // if folder parentID exists and has children - } // lock ds - return folders; - } - - /// - /// Returns an inventory item by its UUID - /// - /// The UUID of the item to be returned - /// A class containing item information - public InventoryItemBase getInventoryItem(UUID item) - { - lock (ds) - { - DataRow row = ds.Tables["inventoryitems"].Rows.Find(item.ToString()); - if (row != null) - { - return buildItem(row); - } - else - { - return null; - } - } - } - - /// - /// Returns a specified inventory folder by its UUID - /// - /// The UUID of the folder to be returned - /// A class containing folder information - public InventoryFolderBase getInventoryFolder(UUID folder) - { - // TODO: Deep voodoo here. If you enable this code then - // multi region breaks. No idea why, but I figured it was - // better to leave multi region at this point. It does mean - // that you don't get to see system textures why creating - // clothes and the like. :( - lock (ds) - { - DataRow row = ds.Tables["inventoryfolders"].Rows.Find(folder.ToString()); - if (row != null) - { - return buildFolder(row); - } - else - { - return null; - } - } - } - - /// - /// Creates a new inventory item based on item - /// - /// The item to be created - public void addInventoryItem(InventoryItemBase item) - { - addItem(item, true); - } - - /// - /// Updates an inventory item with item (updates based on ID) - /// - /// The updated item - public void updateInventoryItem(InventoryItemBase item) - { - addItem(item, false); - } - - /// - /// Delete an inventory item - /// - /// The item UUID - public void deleteInventoryItem(UUID itemID) - { - lock (ds) - { - DataTable inventoryItemTable = ds.Tables["inventoryitems"]; - - DataRow inventoryRow = inventoryItemTable.Rows.Find(itemID.ToString()); - if (inventoryRow != null) - { - inventoryRow.Delete(); - } - - invItemsDa.Update(ds, "inventoryitems"); - } - } - - public InventoryItemBase queryInventoryItem(UUID itemID) - { - return getInventoryItem(itemID); - } - - public InventoryFolderBase queryInventoryFolder(UUID folderID) - { - return getInventoryFolder(folderID); - } - - /// - /// Delete all items in the specified folder - /// - /// id of the folder, whose item content should be deleted - /// this is horribly inefficient, but I don't want to ruin the overall structure of this implementation - private void deleteItemsInFolder(UUID folderId) - { - List items = getInventoryInFolder(folderId); - - foreach (InventoryItemBase i in items) - deleteInventoryItem(i.ID); - } - - /// - /// Adds a new folder specified by folder - /// - /// The inventory folder - public void addInventoryFolder(InventoryFolderBase folder) - { - addFolder(folder, true); - } - - /// - /// Updates a folder based on its ID with folder - /// - /// The inventory folder - public void updateInventoryFolder(InventoryFolderBase folder) - { - addFolder(folder, false); - } - - /// - /// Moves a folder based on its ID with folder - /// - /// The inventory folder - public void moveInventoryFolder(InventoryFolderBase folder) - { - moveFolder(folder); - } - - /// - /// Delete a folder - /// - /// - /// This will clean-up any child folders and child items as well - /// - /// the folder UUID - public void deleteInventoryFolder(UUID folderID) - { - lock (ds) - { - List subFolders = getFolderHierarchy(folderID); - - DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; - DataRow inventoryRow; - - //Delete all sub-folders - foreach (InventoryFolderBase f in subFolders) - { - inventoryRow = inventoryFolderTable.Rows.Find(f.ID.ToString()); - if (inventoryRow != null) - { - deleteItemsInFolder(f.ID); - inventoryRow.Delete(); - } - } - - //Delete the actual row - inventoryRow = inventoryFolderTable.Rows.Find(folderID.ToString()); - if (inventoryRow != null) - { - deleteItemsInFolder(folderID); - inventoryRow.Delete(); - } - - invFoldersDa.Update(ds, "inventoryfolders"); - } - } - - /*********************************************************************** - * - * Data Table definitions - * - **********************************************************************/ - - /// - /// Create the "inventoryitems" table - /// - private static DataTable createInventoryItemsTable() - { - DataTable inv = new DataTable("inventoryitems"); - - createCol(inv, "UUID", typeof (String)); //inventoryID - createCol(inv, "assetID", typeof (String)); - createCol(inv, "assetType", typeof (Int32)); - createCol(inv, "invType", typeof (Int32)); - createCol(inv, "parentFolderID", typeof (String)); - createCol(inv, "avatarID", typeof (String)); - createCol(inv, "creatorsID", typeof (String)); - - createCol(inv, "inventoryName", typeof (String)); - createCol(inv, "inventoryDescription", typeof (String)); - // permissions - createCol(inv, "inventoryNextPermissions", typeof (Int32)); - createCol(inv, "inventoryCurrentPermissions", typeof (Int32)); - createCol(inv, "inventoryBasePermissions", typeof (Int32)); - createCol(inv, "inventoryEveryOnePermissions", typeof (Int32)); - createCol(inv, "inventoryGroupPermissions", typeof (Int32)); - - // sale info - createCol(inv, "salePrice", typeof(Int32)); - createCol(inv, "saleType", typeof(Byte)); - - // creation date - createCol(inv, "creationDate", typeof(Int32)); - - // group info - createCol(inv, "groupID", typeof(String)); - createCol(inv, "groupOwned", typeof(Boolean)); - - // Flags - createCol(inv, "flags", typeof(UInt32)); - - inv.PrimaryKey = new DataColumn[] { inv.Columns["UUID"] }; - return inv; - } - - /// - /// Creates the "inventoryfolders" table - /// - /// - private static DataTable createInventoryFoldersTable() - { - DataTable fol = new DataTable("inventoryfolders"); - - createCol(fol, "UUID", typeof (String)); //folderID - createCol(fol, "name", typeof (String)); - createCol(fol, "agentID", typeof (String)); - createCol(fol, "parentID", typeof (String)); - createCol(fol, "type", typeof (Int32)); - createCol(fol, "version", typeof (Int32)); - - fol.PrimaryKey = new DataColumn[] {fol.Columns["UUID"]}; - return fol; - } - - /// - /// - /// - /// - /// - private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn) - { - lock (ds) - { - da.InsertCommand = createInsertCommand("inventoryitems", ds.Tables["inventoryitems"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("inventoryitems", "UUID=:UUID", ds.Tables["inventoryitems"]); - da.UpdateCommand.Connection = conn; - - SqliteCommand delete = new SqliteCommand("delete from inventoryitems where UUID = :UUID"); - delete.Parameters.Add(createSqliteParameter("UUID", typeof(String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - } - - /// - /// - /// - /// - /// - private void setupFoldersCommands(SqliteDataAdapter da, SqliteConnection conn) - { - lock (ds) - { - da.InsertCommand = createInsertCommand("inventoryfolders", ds.Tables["inventoryfolders"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("inventoryfolders", "UUID=:UUID", ds.Tables["inventoryfolders"]); - da.UpdateCommand.Connection = conn; - - SqliteCommand delete = new SqliteCommand("delete from inventoryfolders where UUID = :UUID"); - delete.Parameters.Add(createSqliteParameter("UUID", typeof(String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - } - - /// - /// - /// - /// - /// - private static InventoryFolderBase buildFolder(DataRow row) - { - InventoryFolderBase folder = new InventoryFolderBase(); - folder.ID = new UUID((string) row["UUID"]); - folder.Name = (string) row["name"]; - folder.Owner = new UUID((string) row["agentID"]); - folder.ParentID = new UUID((string) row["parentID"]); - folder.Type = Convert.ToInt16(row["type"]); - folder.Version = Convert.ToUInt16(row["version"]); - return folder; - } - - /// - /// - /// - /// - /// - private static void fillFolderRow(DataRow row, InventoryFolderBase folder) - { - row["UUID"] = folder.ID.ToString(); - row["name"] = folder.Name; - row["agentID"] = folder.Owner.ToString(); - row["parentID"] = folder.ParentID.ToString(); - row["type"] = folder.Type; - row["version"] = folder.Version; - } - - /// - /// - /// - /// - /// - private static void moveFolderRow(DataRow row, InventoryFolderBase folder) - { - row["UUID"] = folder.ID.ToString(); - row["parentID"] = folder.ParentID.ToString(); - } - - public List fetchActiveGestures (UUID avatarID) - { - lock (ds) - { - List items = new List(); - - DataTable inventoryItemTable = ds.Tables["inventoryitems"]; - string selectExp - = "avatarID = '" + avatarID + "' AND assetType = " + (int)AssetType.Gesture + " AND flags = 1"; - //m_log.DebugFormat("[SQL]: sql = " + selectExp); - DataRow[] rows = inventoryItemTable.Select(selectExp); - foreach (DataRow row in rows) - { - items.Add(buildItem(row)); - } - return items; - } - } - } -} diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteSimulationData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteSimulationData.cs deleted file mode 100644 index 644864a..0000000 --- a/OpenSim/Data/SQLiteLegacy/SQLiteSimulationData.cs +++ /dev/null @@ -1,2274 +0,0 @@ -/* - * 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.Data; -using System.Drawing; -using System.IO; -using System.Reflection; -using log4net; -using Mono.Data.SqliteClient; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Data.SQLiteLegacy -{ - /// - /// A RegionData Interface to the SQLite database - /// - public class SQLiteSimulationData : ISimulationDataStore - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private const string primSelect = "select * from prims"; - private const string shapeSelect = "select * from primshapes"; - private const string itemsSelect = "select * from primitems"; - private const string terrainSelect = "select * from terrain limit 1"; - private const string landSelect = "select * from land"; - private const string landAccessListSelect = "select distinct * from landaccesslist"; - private const string regionbanListSelect = "select * from regionban"; - private const string regionSettingsSelect = "select * from regionsettings"; - - private DataSet ds; - private SqliteDataAdapter primDa; - private SqliteDataAdapter shapeDa; - private SqliteDataAdapter itemsDa; - private SqliteDataAdapter terrainDa; - private SqliteDataAdapter landDa; - private SqliteDataAdapter landAccessListDa; - private SqliteDataAdapter regionSettingsDa; - - private SqliteConnection m_conn; - - private String m_connectionString; - - public SQLiteSimulationData() - { - } - - public SQLiteSimulationData(string connectionString) - { - Initialise(connectionString); - } - - // Temporary attribute while this is experimental - - /*********************************************************************** - * - * Public Interface Functions - * - **********************************************************************/ - - /// - /// - /// Initialises RegionData Interface - /// Loads and initialises a new SQLite connection and maintains it. - /// - /// - /// the connection string - public void Initialise(string connectionString) - { - m_connectionString = connectionString; - - ds = new DataSet(); - - m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString); - m_conn = new SqliteConnection(m_connectionString); - m_conn.Open(); - - - - SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn); - primDa = new SqliteDataAdapter(primSelectCmd); - // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); - - SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn); - shapeDa = new SqliteDataAdapter(shapeSelectCmd); - // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa); - - SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, m_conn); - itemsDa = new SqliteDataAdapter(itemsSelectCmd); - - SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, m_conn); - terrainDa = new SqliteDataAdapter(terrainSelectCmd); - - SqliteCommand landSelectCmd = new SqliteCommand(landSelect, m_conn); - landDa = new SqliteDataAdapter(landSelectCmd); - - SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); - landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); - - SqliteCommand regionSettingsSelectCmd = new SqliteCommand(regionSettingsSelect, m_conn); - regionSettingsDa = new SqliteDataAdapter(regionSettingsSelectCmd); - // This actually does the roll forward assembly stuff - Assembly assem = GetType().Assembly; - Migration m = new Migration(m_conn, assem, "RegionStore"); - m.Update(); - - lock (ds) - { - ds.Tables.Add(createPrimTable()); - setupPrimCommands(primDa, m_conn); - primDa.Fill(ds.Tables["prims"]); - - ds.Tables.Add(createShapeTable()); - setupShapeCommands(shapeDa, m_conn); - - ds.Tables.Add(createItemsTable()); - setupItemsCommands(itemsDa, m_conn); - itemsDa.Fill(ds.Tables["primitems"]); - - ds.Tables.Add(createTerrainTable()); - setupTerrainCommands(terrainDa, m_conn); - - ds.Tables.Add(createLandTable()); - setupLandCommands(landDa, m_conn); - - ds.Tables.Add(createLandAccessListTable()); - setupLandAccessCommands(landAccessListDa, m_conn); - - ds.Tables.Add(createRegionSettingsTable()); - - setupRegionSettingsCommands(regionSettingsDa, m_conn); - - // WORKAROUND: This is a work around for sqlite on - // windows, which gets really unhappy with blob columns - // that have no sample data in them. At some point we - // need to actually find a proper way to handle this. - try - { - shapeDa.Fill(ds.Tables["primshapes"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on primshapes table"); - } - - try - { - terrainDa.Fill(ds.Tables["terrain"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on terrain table"); - } - - try - { - landDa.Fill(ds.Tables["land"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on land table"); - } - - try - { - landAccessListDa.Fill(ds.Tables["landaccesslist"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on landaccesslist table"); - } - - try - { - regionSettingsDa.Fill(ds.Tables["regionsettings"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on regionsettings table"); - } - return; - } - } - - public void Dispose() - { - if (m_conn != null) - { - m_conn.Close(); - m_conn = null; - } - if (ds != null) - { - ds.Dispose(); - ds = null; - } - if (primDa != null) - { - primDa.Dispose(); - primDa = null; - } - if (shapeDa != null) - { - shapeDa.Dispose(); - shapeDa = null; - } - if (itemsDa != null) - { - itemsDa.Dispose(); - itemsDa = null; - } - if (terrainDa != null) - { - terrainDa.Dispose(); - terrainDa = null; - } - if (landDa != null) - { - landDa.Dispose(); - landDa = null; - } - if (landAccessListDa != null) - { - landAccessListDa.Dispose(); - landAccessListDa = null; - } - if (regionSettingsDa != null) - { - regionSettingsDa.Dispose(); - regionSettingsDa = null; - } - } - - public void StoreRegionSettings(RegionSettings rs) - { - lock (ds) - { - DataTable regionsettings = ds.Tables["regionsettings"]; - - DataRow settingsRow = regionsettings.Rows.Find(rs.RegionUUID.ToString()); - if (settingsRow == null) - { - settingsRow = regionsettings.NewRow(); - fillRegionSettingsRow(settingsRow, rs); - regionsettings.Rows.Add(settingsRow); - } - else - { - fillRegionSettingsRow(settingsRow, rs); - } - - Commit(); - } - } - public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) - { - //This connector doesn't support the windlight module yet - //Return default LL windlight settings - return new RegionLightShareData(); - } - public void RemoveRegionWindlightSettings(UUID regionID) - { - } - public void StoreRegionWindlightSettings(RegionLightShareData wl) - { - //This connector doesn't support the windlight module yet - } - public RegionSettings LoadRegionSettings(UUID regionUUID) - { - lock (ds) - { - DataTable regionsettings = ds.Tables["regionsettings"]; - - string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; - DataRow[] rawsettings = regionsettings.Select(searchExp); - if (rawsettings.Length == 0) - { - RegionSettings rs = new RegionSettings(); - rs.RegionUUID = regionUUID; - rs.OnSave += StoreRegionSettings; - - StoreRegionSettings(rs); - - return rs; - } - DataRow row = rawsettings[0]; - - RegionSettings newSettings = buildRegionSettings(row); - newSettings.OnSave += StoreRegionSettings; - - return newSettings; - } - } - - /// - /// Adds an object into region storage - /// - /// the object - /// the region UUID - public void StoreObject(SceneObjectGroup obj, UUID regionUUID) - { - uint flags = obj.RootPart.GetEffectiveObjectFlags(); - - // Eligibility check - // - if ((flags & (uint)PrimFlags.Temporary) != 0) - return; - if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) - return; - - lock (ds) - { - foreach (SceneObjectPart prim in obj.Parts) - { -// m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); - addPrim(prim, obj.UUID, regionUUID); - } - } - - Commit(); - // m_log.Info("[Dump of prims]: " + ds.GetXml()); - } - - /// - /// Removes an object from region storage - /// - /// the object - /// the region UUID - public void RemoveObject(UUID obj, UUID regionUUID) - { - // m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.Guid, regionUUID); - - DataTable prims = ds.Tables["prims"]; - DataTable shapes = ds.Tables["primshapes"]; - - string selectExp = "SceneGroupID = '" + obj + "' and RegionUUID = '" + regionUUID + "'"; - lock (ds) - { - DataRow[] primRows = prims.Select(selectExp); - foreach (DataRow row in primRows) - { - // Remove shape rows - UUID uuid = new UUID((string) row["UUID"]); - DataRow shapeRow = shapes.Rows.Find(uuid.ToString()); - if (shapeRow != null) - { - shapeRow.Delete(); - } - - RemoveItems(uuid); - - // Remove prim row - row.Delete(); - } - } - - Commit(); - } - - /// - /// Remove all persisted items of the given prim. - /// The caller must acquire the necessrary synchronization locks and commit or rollback changes. - /// - /// The item UUID - private void RemoveItems(UUID uuid) - { - DataTable items = ds.Tables["primitems"]; - - String sql = String.Format("primID = '{0}'", uuid); - DataRow[] itemRows = items.Select(sql); - - foreach (DataRow itemRow in itemRows) - { - itemRow.Delete(); - } - } - - /// - /// Load persisted objects from region storage. - /// - /// The region UUID - /// List of loaded groups - public List LoadObjects(UUID regionUUID) - { - Dictionary createdObjects = new Dictionary(); - - List retvals = new List(); - - DataTable prims = ds.Tables["prims"]; - DataTable shapes = ds.Tables["primshapes"]; - - string byRegion = "RegionUUID = '" + regionUUID + "'"; - - lock (ds) - { - DataRow[] primsForRegion = prims.Select(byRegion); - m_log.Info("[REGION DB]: Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); - - // First, create all groups - foreach (DataRow primRow in primsForRegion) - { - try - { - SceneObjectPart prim = null; - - string uuid = (string) primRow["UUID"]; - string objID = (string) primRow["SceneGroupID"]; - - if (uuid == objID) //is new SceneObjectGroup ? - { - prim = buildPrim(primRow); - DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString()); - if (shapeRow != null) - { - prim.Shape = buildShape(shapeRow); - } - else - { - m_log.Info( - "[REGION DB]: No shape found for prim in storage, so setting default box shape"); - prim.Shape = PrimitiveBaseShape.Default; - } - - SceneObjectGroup group = new SceneObjectGroup(prim); - createdObjects.Add(group.UUID, group); - retvals.Add(group); - LoadItems(prim); - } - } - catch (Exception e) - { - m_log.Error("[REGION DB]: Failed create prim object in new group, exception and data follows"); - m_log.Info("[REGION DB]: " + e.ToString()); - foreach (DataColumn col in prims.Columns) - { - m_log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); - } - } - } - - // Now fill the groups with part data - foreach (DataRow primRow in primsForRegion) - { - try - { - SceneObjectPart prim = null; - - string uuid = (string) primRow["UUID"]; - string objID = (string) primRow["SceneGroupID"]; - if (uuid != objID) //is new SceneObjectGroup ? - { - prim = buildPrim(primRow); - DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString()); - if (shapeRow != null) - { - prim.Shape = buildShape(shapeRow); - } - else - { - m_log.Warn( - "[REGION DB]: No shape found for prim in storage, so setting default box shape"); - prim.Shape = PrimitiveBaseShape.Default; - } - - createdObjects[new UUID(objID)].AddPart(prim); - LoadItems(prim); - } - } - catch (Exception e) - { - m_log.Error("[REGION DB]: Failed create prim object in group, exception and data follows"); - m_log.Info("[REGION DB]: " + e.ToString()); - foreach (DataColumn col in prims.Columns) - { - m_log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); - } - } - } - } - return retvals; - } - - /// - /// Load in a prim's persisted inventory. - /// - /// the prim - private void LoadItems(SceneObjectPart prim) - { - //m_log.DebugFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); - - DataTable dbItems = ds.Tables["primitems"]; - String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); - DataRow[] dbItemRows = dbItems.Select(sql); - IList inventory = new List(); - - foreach (DataRow row in dbItemRows) - { - TaskInventoryItem item = buildItem(row); - inventory.Add(item); - - //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); - } - - prim.Inventory.RestoreInventoryItems(inventory); - } - - /// - /// Store a terrain revision in region storage - /// - /// terrain heightfield - /// region UUID - public void StoreTerrain(double[,] ter, UUID regionID) - { - lock (ds) - { - int revision = Util.UnixTimeSinceEpoch(); - - // This is added to get rid of the infinitely growing - // terrain databases which negatively impact on SQLite - // over time. Before reenabling this feature there - // needs to be a limitter put on the number of - // revisions in the database, as this old - // implementation is a DOS attack waiting to happen. - - using ( - SqliteCommand cmd = - new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision <= :Revision", - m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); - cmd.ExecuteNonQuery(); - } - - // the following is an work around for .NET. The perf - // issues associated with it aren't as bad as you think. - m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString()); - String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + - " values(:RegionUUID, :Revision, :Heightfield)"; - - using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); - cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter))); - cmd.ExecuteNonQuery(); - } - } - } - - /// - /// Load the latest terrain revision from region storage - /// - /// the region UUID - /// Heightfield data - public double[,] LoadTerrain(UUID regionID) - { - lock (ds) - { - double[,] terret = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; - terret.Initialize(); - - String sql = "select RegionUUID, Revision, Heightfield from terrain" + - " where RegionUUID=:RegionUUID order by Revision desc"; - - using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); - - using (IDataReader row = cmd.ExecuteReader()) - { - int rev = 0; - if (row.Read()) - { - // TODO: put this into a function - using (MemoryStream str = new MemoryStream((byte[])row["Heightfield"])) - { - using (BinaryReader br = new BinaryReader(str)) - { - for (int x = 0; x < (int)Constants.RegionSize; x++) - { - for (int y = 0; y < (int)Constants.RegionSize; y++) - { - terret[x, y] = br.ReadDouble(); - } - } - } - } - rev = (int) row["Revision"]; - } - else - { - m_log.Info("[REGION DB]: No terrain found for region"); - return null; - } - - m_log.Info("[REGION DB]: Loaded terrain revision r" + rev.ToString()); - } - } - return terret; - } - } - - /// - /// - /// - /// - public void RemoveLandObject(UUID globalID) - { - lock (ds) - { - // Can't use blanket SQL statements when using SqlAdapters unless you re-read the data into the adapter - // after you're done. - // replaced below code with the SqliteAdapter version. - //using (SqliteCommand cmd = new SqliteCommand("delete from land where UUID=:UUID", m_conn)) - //{ - // cmd.Parameters.Add(new SqliteParameter(":UUID", globalID.ToString())); - // cmd.ExecuteNonQuery(); - //} - - //using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:UUID", m_conn)) - //{ - // cmd.Parameters.Add(new SqliteParameter(":UUID", globalID.ToString())); - // cmd.ExecuteNonQuery(); - //} - - DataTable land = ds.Tables["land"]; - DataTable landaccesslist = ds.Tables["landaccesslist"]; - DataRow landRow = land.Rows.Find(globalID.ToString()); - if (landRow != null) - { - landRow.Delete(); - land.Rows.Remove(landRow); - } - List rowsToDelete = new List(); - foreach (DataRow rowToCheck in landaccesslist.Rows) - { - if (rowToCheck["LandUUID"].ToString() == globalID.ToString()) - rowsToDelete.Add(rowToCheck); - } - for (int iter = 0; iter < rowsToDelete.Count; iter++) - { - rowsToDelete[iter].Delete(); - landaccesslist.Rows.Remove(rowsToDelete[iter]); - } - - - } - Commit(); - } - - /// - /// - /// - /// - public void StoreLandObject(ILandObject parcel) - { - lock (ds) - { - DataTable land = ds.Tables["land"]; - DataTable landaccesslist = ds.Tables["landaccesslist"]; - - DataRow landRow = land.Rows.Find(parcel.LandData.GlobalID.ToString()); - if (landRow == null) - { - landRow = land.NewRow(); - fillLandRow(landRow, parcel.LandData, parcel.RegionUUID); - land.Rows.Add(landRow); - } - else - { - fillLandRow(landRow, parcel.LandData, parcel.RegionUUID); - } - - // I know this caused someone issues before, but OpenSim is unusable if we leave this stuff around - //using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:LandUUID", m_conn)) - //{ - // cmd.Parameters.Add(new SqliteParameter(":LandUUID", parcel.LandData.GlobalID.ToString())); - // cmd.ExecuteNonQuery(); - -// } - - // This is the slower.. but more appropriate thing to do - - // We can't modify the table with direct queries before calling Commit() and re-filling them. - List rowsToDelete = new List(); - foreach (DataRow rowToCheck in landaccesslist.Rows) - { - if (rowToCheck["LandUUID"].ToString() == parcel.LandData.GlobalID.ToString()) - rowsToDelete.Add(rowToCheck); - } - for (int iter = 0; iter < rowsToDelete.Count; iter++) - { - rowsToDelete[iter].Delete(); - landaccesslist.Rows.Remove(rowsToDelete[iter]); - } - rowsToDelete.Clear(); - foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) - { - DataRow newAccessRow = landaccesslist.NewRow(); - fillLandAccessRow(newAccessRow, entry, parcel.LandData.GlobalID); - landaccesslist.Rows.Add(newAccessRow); - } - } - - Commit(); - } - - /// - /// - /// - /// - /// - public List LoadLandObjects(UUID regionUUID) - { - List landDataForRegion = new List(); - lock (ds) - { - DataTable land = ds.Tables["land"]; - DataTable landaccesslist = ds.Tables["landaccesslist"]; - string searchExp = "RegionUUID = '" + regionUUID + "'"; - DataRow[] rawDataForRegion = land.Select(searchExp); - foreach (DataRow rawDataLand in rawDataForRegion) - { - LandData newLand = buildLandData(rawDataLand); - string accessListSearchExp = "LandUUID = '" + newLand.GlobalID + "'"; - DataRow[] rawDataForLandAccessList = landaccesslist.Select(accessListSearchExp); - foreach (DataRow rawDataLandAccess in rawDataForLandAccessList) - { - newLand.ParcelAccessList.Add(buildLandAccessData(rawDataLandAccess)); - } - - landDataForRegion.Add(newLand); - } - } - return landDataForRegion; - } - - /// - /// - /// - public void Commit() - { - lock (ds) - { - primDa.Update(ds, "prims"); - shapeDa.Update(ds, "primshapes"); - - itemsDa.Update(ds, "primitems"); - - terrainDa.Update(ds, "terrain"); - landDa.Update(ds, "land"); - landAccessListDa.Update(ds, "landaccesslist"); - try - { - regionSettingsDa.Update(ds, "regionsettings"); - } - catch (SqliteExecutionException SqlEx) - { - if (SqlEx.Message.Contains("logic error")) - { - throw new Exception( - "There was a SQL error or connection string configuration error when saving the region settings. This could be a bug, it could also happen if ConnectionString is defined in the [DatabaseService] section of StandaloneCommon.ini in the config_include folder. This could also happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. If this is your first time running OpenSimulator, please restart the simulator and bug a developer to fix this!", - SqlEx); - } - else - { - throw SqlEx; - } - } - ds.AcceptChanges(); - } - } - - /// - /// See - /// - public void Shutdown() - { - Commit(); - } - - /*********************************************************************** - * - * Database Definition Functions - * - * This should be db agnostic as we define them in ADO.NET terms - * - **********************************************************************/ - - /// - /// - /// - /// - /// - /// - private static void createCol(DataTable dt, string name, Type type) - { - DataColumn col = new DataColumn(name, type); - dt.Columns.Add(col); - } - - /// - /// Creates the "terrain" table - /// - /// terrain table DataTable - private static DataTable createTerrainTable() - { - DataTable terrain = new DataTable("terrain"); - - createCol(terrain, "RegionUUID", typeof (String)); - createCol(terrain, "Revision", typeof (Int32)); - createCol(terrain, "Heightfield", typeof (Byte[])); - - return terrain; - } - - /// - /// Creates the "prims" table - /// - /// prim table DataTable - private static DataTable createPrimTable() - { - DataTable prims = new DataTable("prims"); - - createCol(prims, "UUID", typeof (String)); - createCol(prims, "RegionUUID", typeof (String)); - createCol(prims, "CreationDate", typeof (Int32)); - createCol(prims, "Name", typeof (String)); - createCol(prims, "SceneGroupID", typeof (String)); - // various text fields - createCol(prims, "Text", typeof (String)); - createCol(prims, "ColorR", typeof (Int32)); - createCol(prims, "ColorG", typeof (Int32)); - createCol(prims, "ColorB", typeof (Int32)); - createCol(prims, "ColorA", typeof (Int32)); - createCol(prims, "Description", typeof (String)); - createCol(prims, "SitName", typeof (String)); - createCol(prims, "TouchName", typeof (String)); - // permissions - createCol(prims, "ObjectFlags", typeof (Int32)); - createCol(prims, "CreatorID", typeof (String)); - createCol(prims, "OwnerID", typeof (String)); - createCol(prims, "GroupID", typeof (String)); - createCol(prims, "LastOwnerID", typeof (String)); - createCol(prims, "OwnerMask", typeof (Int32)); - createCol(prims, "NextOwnerMask", typeof (Int32)); - createCol(prims, "GroupMask", typeof (Int32)); - createCol(prims, "EveryoneMask", typeof (Int32)); - createCol(prims, "BaseMask", typeof (Int32)); - // vectors - createCol(prims, "PositionX", typeof (Double)); - createCol(prims, "PositionY", typeof (Double)); - createCol(prims, "PositionZ", typeof (Double)); - createCol(prims, "GroupPositionX", typeof (Double)); - createCol(prims, "GroupPositionY", typeof (Double)); - createCol(prims, "GroupPositionZ", typeof (Double)); - createCol(prims, "VelocityX", typeof (Double)); - createCol(prims, "VelocityY", typeof (Double)); - createCol(prims, "VelocityZ", typeof (Double)); - createCol(prims, "AngularVelocityX", typeof (Double)); - createCol(prims, "AngularVelocityY", typeof (Double)); - createCol(prims, "AngularVelocityZ", typeof (Double)); - createCol(prims, "AccelerationX", typeof (Double)); - createCol(prims, "AccelerationY", typeof (Double)); - createCol(prims, "AccelerationZ", typeof (Double)); - // quaternions - createCol(prims, "RotationX", typeof (Double)); - createCol(prims, "RotationY", typeof (Double)); - createCol(prims, "RotationZ", typeof (Double)); - createCol(prims, "RotationW", typeof (Double)); - - // sit target - createCol(prims, "SitTargetOffsetX", typeof (Double)); - createCol(prims, "SitTargetOffsetY", typeof (Double)); - createCol(prims, "SitTargetOffsetZ", typeof (Double)); - - createCol(prims, "SitTargetOrientW", typeof (Double)); - createCol(prims, "SitTargetOrientX", typeof (Double)); - createCol(prims, "SitTargetOrientY", typeof (Double)); - createCol(prims, "SitTargetOrientZ", typeof (Double)); - - createCol(prims, "PayPrice", typeof(Int32)); - createCol(prims, "PayButton1", typeof(Int32)); - createCol(prims, "PayButton2", typeof(Int32)); - createCol(prims, "PayButton3", typeof(Int32)); - createCol(prims, "PayButton4", typeof(Int32)); - - createCol(prims, "LoopedSound", typeof(String)); - createCol(prims, "LoopedSoundGain", typeof(Double)); - createCol(prims, "TextureAnimation", typeof(String)); - createCol(prims, "ParticleSystem", typeof(String)); - - createCol(prims, "OmegaX", typeof(Double)); - createCol(prims, "OmegaY", typeof(Double)); - createCol(prims, "OmegaZ", typeof(Double)); - - createCol(prims, "CameraEyeOffsetX", typeof(Double)); - createCol(prims, "CameraEyeOffsetY", typeof(Double)); - createCol(prims, "CameraEyeOffsetZ", typeof(Double)); - - createCol(prims, "CameraAtOffsetX", typeof(Double)); - createCol(prims, "CameraAtOffsetY", typeof(Double)); - createCol(prims, "CameraAtOffsetZ", typeof(Double)); - - createCol(prims, "ForceMouselook", typeof(Int16)); - - createCol(prims, "ScriptAccessPin", typeof(Int32)); - - createCol(prims, "AllowedDrop", typeof(Int16)); - createCol(prims, "DieAtEdge", typeof(Int16)); - - createCol(prims, "SalePrice", typeof(Int32)); - createCol(prims, "SaleType", typeof(Int16)); - - // click action - createCol(prims, "ClickAction", typeof (Byte)); - - createCol(prims, "Material", typeof(Byte)); - - createCol(prims, "CollisionSound", typeof(String)); - createCol(prims, "CollisionSoundVolume", typeof(Double)); - - createCol(prims, "VolumeDetect", typeof(Int16)); - - // Add in contraints - prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; - - return prims; - } - - /// - /// Creates "primshapes" table - /// - /// shape table DataTable - private static DataTable createShapeTable() - { - DataTable shapes = new DataTable("primshapes"); - createCol(shapes, "UUID", typeof (String)); - // shape is an enum - createCol(shapes, "Shape", typeof (Int32)); - // vectors - createCol(shapes, "ScaleX", typeof (Double)); - createCol(shapes, "ScaleY", typeof (Double)); - createCol(shapes, "ScaleZ", typeof (Double)); - // paths - createCol(shapes, "PCode", typeof (Int32)); - createCol(shapes, "PathBegin", typeof (Int32)); - createCol(shapes, "PathEnd", typeof (Int32)); - createCol(shapes, "PathScaleX", typeof (Int32)); - createCol(shapes, "PathScaleY", typeof (Int32)); - createCol(shapes, "PathShearX", typeof (Int32)); - createCol(shapes, "PathShearY", typeof (Int32)); - createCol(shapes, "PathSkew", typeof (Int32)); - createCol(shapes, "PathCurve", typeof (Int32)); - createCol(shapes, "PathRadiusOffset", typeof (Int32)); - createCol(shapes, "PathRevolutions", typeof (Int32)); - createCol(shapes, "PathTaperX", typeof (Int32)); - createCol(shapes, "PathTaperY", typeof (Int32)); - createCol(shapes, "PathTwist", typeof (Int32)); - createCol(shapes, "PathTwistBegin", typeof (Int32)); - // profile - createCol(shapes, "ProfileBegin", typeof (Int32)); - createCol(shapes, "ProfileEnd", typeof (Int32)); - createCol(shapes, "ProfileCurve", typeof (Int32)); - createCol(shapes, "ProfileHollow", typeof (Int32)); - createCol(shapes, "State", typeof(Int32)); - // text TODO: this isn't right, but I'm not sure the right - // way to specify this as a blob atm - createCol(shapes, "Texture", typeof (Byte[])); - createCol(shapes, "ExtraParams", typeof (Byte[])); - - shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; - - return shapes; - } - - /// - /// creates "primitems" table - /// - /// item table DataTable - private static DataTable createItemsTable() - { - DataTable items = new DataTable("primitems"); - - createCol(items, "itemID", typeof (String)); - createCol(items, "primID", typeof (String)); - createCol(items, "assetID", typeof (String)); - createCol(items, "parentFolderID", typeof (String)); - - createCol(items, "invType", typeof (Int32)); - createCol(items, "assetType", typeof (Int32)); - - createCol(items, "name", typeof (String)); - createCol(items, "description", typeof (String)); - - createCol(items, "creationDate", typeof (Int64)); - createCol(items, "creatorID", typeof (String)); - createCol(items, "ownerID", typeof (String)); - createCol(items, "lastOwnerID", typeof (String)); - createCol(items, "groupID", typeof (String)); - - createCol(items, "nextPermissions", typeof (UInt32)); - createCol(items, "currentPermissions", typeof (UInt32)); - createCol(items, "basePermissions", typeof (UInt32)); - createCol(items, "everyonePermissions", typeof (UInt32)); - createCol(items, "groupPermissions", typeof (UInt32)); - createCol(items, "flags", typeof (UInt32)); - - items.PrimaryKey = new DataColumn[] { items.Columns["itemID"] }; - - return items; - } - - /// - /// Creates "land" table - /// - /// land table DataTable - private static DataTable createLandTable() - { - DataTable land = new DataTable("land"); - createCol(land, "UUID", typeof (String)); - createCol(land, "RegionUUID", typeof (String)); - createCol(land, "LocalLandID", typeof (UInt32)); - - // Bitmap is a byte[512] - createCol(land, "Bitmap", typeof (Byte[])); - - createCol(land, "Name", typeof (String)); - createCol(land, "Desc", typeof (String)); - createCol(land, "OwnerUUID", typeof (String)); - createCol(land, "IsGroupOwned", typeof (Boolean)); - createCol(land, "Area", typeof (Int32)); - createCol(land, "AuctionID", typeof (Int32)); //Unemplemented - createCol(land, "Category", typeof (Int32)); //Enum OpenMetaverse.Parcel.ParcelCategory - createCol(land, "ClaimDate", typeof (Int32)); - createCol(land, "ClaimPrice", typeof (Int32)); - createCol(land, "GroupUUID", typeof (string)); - createCol(land, "SalePrice", typeof (Int32)); - createCol(land, "LandStatus", typeof (Int32)); //Enum. OpenMetaverse.Parcel.ParcelStatus - createCol(land, "LandFlags", typeof (UInt32)); - createCol(land, "LandingType", typeof (Byte)); - createCol(land, "MediaAutoScale", typeof (Byte)); - createCol(land, "MediaTextureUUID", typeof (String)); - createCol(land, "MediaURL", typeof (String)); - createCol(land, "MusicURL", typeof (String)); - createCol(land, "PassHours", typeof (Double)); - createCol(land, "PassPrice", typeof (UInt32)); - createCol(land, "SnapshotUUID", typeof (String)); - createCol(land, "UserLocationX", typeof (Double)); - createCol(land, "UserLocationY", typeof (Double)); - createCol(land, "UserLocationZ", typeof (Double)); - createCol(land, "UserLookAtX", typeof (Double)); - createCol(land, "UserLookAtY", typeof (Double)); - createCol(land, "UserLookAtZ", typeof (Double)); - createCol(land, "AuthbuyerID", typeof(String)); - createCol(land, "OtherCleanTime", typeof(Int32)); - - land.PrimaryKey = new DataColumn[] {land.Columns["UUID"]}; - - return land; - } - - /// - /// create "landaccesslist" table - /// - /// Landacceslist DataTable - private static DataTable createLandAccessListTable() - { - DataTable landaccess = new DataTable("landaccesslist"); - createCol(landaccess, "LandUUID", typeof (String)); - createCol(landaccess, "AccessUUID", typeof (String)); - createCol(landaccess, "Flags", typeof (UInt32)); - - return landaccess; - } - - private static DataTable createRegionSettingsTable() - { - DataTable regionsettings = new DataTable("regionsettings"); - createCol(regionsettings, "regionUUID", typeof(String)); - createCol(regionsettings, "block_terraform", typeof (Int32)); - createCol(regionsettings, "block_fly", typeof (Int32)); - createCol(regionsettings, "allow_damage", typeof (Int32)); - createCol(regionsettings, "restrict_pushing", typeof (Int32)); - createCol(regionsettings, "allow_land_resell", typeof (Int32)); - createCol(regionsettings, "allow_land_join_divide", typeof (Int32)); - createCol(regionsettings, "block_show_in_search", typeof (Int32)); - createCol(regionsettings, "agent_limit", typeof (Int32)); - createCol(regionsettings, "object_bonus", typeof (Double)); - createCol(regionsettings, "maturity", typeof (Int32)); - createCol(regionsettings, "disable_scripts", typeof (Int32)); - createCol(regionsettings, "disable_collisions", typeof (Int32)); - createCol(regionsettings, "disable_physics", typeof (Int32)); - createCol(regionsettings, "terrain_texture_1", typeof(String)); - createCol(regionsettings, "terrain_texture_2", typeof(String)); - createCol(regionsettings, "terrain_texture_3", typeof(String)); - createCol(regionsettings, "terrain_texture_4", typeof(String)); - createCol(regionsettings, "elevation_1_nw", typeof (Double)); - createCol(regionsettings, "elevation_2_nw", typeof (Double)); - createCol(regionsettings, "elevation_1_ne", typeof (Double)); - createCol(regionsettings, "elevation_2_ne", typeof (Double)); - createCol(regionsettings, "elevation_1_se", typeof (Double)); - createCol(regionsettings, "elevation_2_se", typeof (Double)); - createCol(regionsettings, "elevation_1_sw", typeof (Double)); - createCol(regionsettings, "elevation_2_sw", typeof (Double)); - createCol(regionsettings, "water_height", typeof (Double)); - createCol(regionsettings, "terrain_raise_limit", typeof (Double)); - createCol(regionsettings, "terrain_lower_limit", typeof (Double)); - createCol(regionsettings, "use_estate_sun", typeof (Int32)); - createCol(regionsettings, "sandbox", typeof (Int32)); - createCol(regionsettings, "sunvectorx",typeof (Double)); - createCol(regionsettings, "sunvectory",typeof (Double)); - createCol(regionsettings, "sunvectorz",typeof (Double)); - createCol(regionsettings, "fixed_sun", typeof (Int32)); - createCol(regionsettings, "sun_position", typeof (Double)); - createCol(regionsettings, "covenant", typeof(String)); - regionsettings.PrimaryKey = new DataColumn[] { regionsettings.Columns["regionUUID"] }; - return regionsettings; - } - - /*********************************************************************** - * - * Convert between ADO.NET <=> OpenSim Objects - * - * These should be database independant - * - **********************************************************************/ - - /// - /// - /// - /// - /// - private SceneObjectPart buildPrim(DataRow row) - { - // Code commented. Uncomment to test the unit test inline. - - // The unit test mentions this commented code for the purposes - // of debugging a unit test failure - - // SceneObjectGroup sog = new SceneObjectGroup(); - // SceneObjectPart sop = new SceneObjectPart(); - // sop.LocalId = 1; - // sop.Name = "object1"; - // sop.Description = "object1"; - // sop.Text = ""; - // sop.SitName = ""; - // sop.TouchName = ""; - // sop.UUID = UUID.Random(); - // sop.Shape = PrimitiveBaseShape.Default; - // sog.SetRootPart(sop); - // Add breakpoint in above line. Check sop fields. - - // TODO: this doesn't work yet because something more - // interesting has to be done to actually get these values - // back out. Not enough time to figure it out yet. - - SceneObjectPart prim = new SceneObjectPart(); - prim.UUID = new UUID((String) row["UUID"]); - // explicit conversion of integers is required, which sort - // of sucks. No idea if there is a shortcut here or not. - prim.CreationDate = Convert.ToInt32(row["CreationDate"]); - prim.Name = row["Name"] == DBNull.Value ? string.Empty : (string)row["Name"]; - // various text fields - prim.Text = (String) row["Text"]; - prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), - Convert.ToInt32(row["ColorR"]), - Convert.ToInt32(row["ColorG"]), - Convert.ToInt32(row["ColorB"])); - prim.Description = (String) row["Description"]; - prim.SitName = (String) row["SitName"]; - prim.TouchName = (String) row["TouchName"]; - // permissions - prim.Flags = (PrimFlags)Convert.ToUInt32(row["ObjectFlags"]); - prim.CreatorIdentification = (String) row["CreatorID"]; - prim.OwnerID = new UUID((String) row["OwnerID"]); - prim.GroupID = new UUID((String) row["GroupID"]); - prim.LastOwnerID = new UUID((String) row["LastOwnerID"]); - prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); - prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); - prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); - prim.EveryoneMask = Convert.ToUInt32(row["EveryoneMask"]); - prim.BaseMask = Convert.ToUInt32(row["BaseMask"]); - // vectors - prim.OffsetPosition = new Vector3( - Convert.ToSingle(row["PositionX"]), - Convert.ToSingle(row["PositionY"]), - Convert.ToSingle(row["PositionZ"]) - ); - prim.GroupPosition = new Vector3( - Convert.ToSingle(row["GroupPositionX"]), - Convert.ToSingle(row["GroupPositionY"]), - Convert.ToSingle(row["GroupPositionZ"]) - ); - prim.Velocity = new Vector3( - Convert.ToSingle(row["VelocityX"]), - Convert.ToSingle(row["VelocityY"]), - Convert.ToSingle(row["VelocityZ"]) - ); - prim.AngularVelocity = new Vector3( - Convert.ToSingle(row["AngularVelocityX"]), - Convert.ToSingle(row["AngularVelocityY"]), - Convert.ToSingle(row["AngularVelocityZ"]) - ); - prim.Acceleration = new Vector3( - Convert.ToSingle(row["AccelerationX"]), - Convert.ToSingle(row["AccelerationY"]), - Convert.ToSingle(row["AccelerationZ"]) - ); - // quaternions - prim.RotationOffset = new Quaternion( - Convert.ToSingle(row["RotationX"]), - Convert.ToSingle(row["RotationY"]), - Convert.ToSingle(row["RotationZ"]), - Convert.ToSingle(row["RotationW"]) - ); - - prim.SitTargetPositionLL = new Vector3( - Convert.ToSingle(row["SitTargetOffsetX"]), - Convert.ToSingle(row["SitTargetOffsetY"]), - Convert.ToSingle(row["SitTargetOffsetZ"])); - prim.SitTargetOrientationLL = new Quaternion( - Convert.ToSingle( - row["SitTargetOrientX"]), - Convert.ToSingle( - row["SitTargetOrientY"]), - Convert.ToSingle( - row["SitTargetOrientZ"]), - Convert.ToSingle( - row["SitTargetOrientW"])); - - prim.ClickAction = Convert.ToByte(row["ClickAction"]); - prim.PayPrice[0] = Convert.ToInt32(row["PayPrice"]); - prim.PayPrice[1] = Convert.ToInt32(row["PayButton1"]); - prim.PayPrice[2] = Convert.ToInt32(row["PayButton2"]); - prim.PayPrice[3] = Convert.ToInt32(row["PayButton3"]); - prim.PayPrice[4] = Convert.ToInt32(row["PayButton4"]); - - prim.Sound = new UUID(row["LoopedSound"].ToString()); - prim.SoundGain = Convert.ToSingle(row["LoopedSoundGain"]); - prim.SoundFlags = 1; // If it's persisted at all, it's looped - - if (!row.IsNull("TextureAnimation")) - prim.TextureAnimation = Convert.FromBase64String(row["TextureAnimation"].ToString()); - if (!row.IsNull("ParticleSystem")) - prim.ParticleSystem = Convert.FromBase64String(row["ParticleSystem"].ToString()); - - prim.AngularVelocity = new Vector3( - Convert.ToSingle(row["OmegaX"]), - Convert.ToSingle(row["OmegaY"]), - Convert.ToSingle(row["OmegaZ"]) - ); - - prim.SetCameraEyeOffset(new Vector3( - Convert.ToSingle(row["CameraEyeOffsetX"]), - Convert.ToSingle(row["CameraEyeOffsetY"]), - Convert.ToSingle(row["CameraEyeOffsetZ"]) - )); - - prim.SetCameraAtOffset(new Vector3( - Convert.ToSingle(row["CameraAtOffsetX"]), - Convert.ToSingle(row["CameraAtOffsetY"]), - Convert.ToSingle(row["CameraAtOffsetZ"]) - )); - - if (Convert.ToInt16(row["ForceMouselook"]) != 0) - prim.SetForceMouselook(true); - - prim.ScriptAccessPin = Convert.ToInt32(row["ScriptAccessPin"]); - - if (Convert.ToInt16(row["AllowedDrop"]) != 0) - prim.AllowedDrop = true; - - if (Convert.ToInt16(row["DieAtEdge"]) != 0) - prim.DIE_AT_EDGE = true; - - prim.SalePrice = Convert.ToInt32(row["SalePrice"]); - prim.ObjectSaleType = Convert.ToByte(row["SaleType"]); - - prim.Material = Convert.ToByte(row["Material"]); - - prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); - prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); - - if (Convert.ToInt16(row["VolumeDetect"]) != 0) - prim.VolumeDetectActive = true; - - return prim; - } - - /// - /// Build a prim inventory item from the persisted data. - /// - /// - /// - private static TaskInventoryItem buildItem(DataRow row) - { - TaskInventoryItem taskItem = new TaskInventoryItem(); - - taskItem.ItemID = new UUID((String)row["itemID"]); - taskItem.ParentPartID = new UUID((String)row["primID"]); - taskItem.AssetID = new UUID((String)row["assetID"]); - taskItem.ParentID = new UUID((String)row["parentFolderID"]); - - taskItem.InvType = Convert.ToInt32(row["invType"]); - taskItem.Type = Convert.ToInt32(row["assetType"]); - - taskItem.Name = (String)row["name"]; - taskItem.Description = (String)row["description"]; - taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); - taskItem.CreatorIdentification = (String)row["creatorID"]; - taskItem.OwnerID = new UUID((String)row["ownerID"]); - taskItem.LastOwnerID = new UUID((String)row["lastOwnerID"]); - taskItem.GroupID = new UUID((String)row["groupID"]); - - taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); - taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); - taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); - taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); - taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); - taskItem.Flags = Convert.ToUInt32(row["flags"]); - - return taskItem; - } - - /// - /// Build a Land Data from the persisted data. - /// - /// - /// - private LandData buildLandData(DataRow row) - { - LandData newData = new LandData(); - - newData.GlobalID = new UUID((String) row["UUID"]); - newData.LocalID = Convert.ToInt32(row["LocalLandID"]); - - // Bitmap is a byte[512] - newData.Bitmap = (Byte[]) row["Bitmap"]; - - newData.Name = (String) row["Name"]; - newData.Description = (String) row["Desc"]; - newData.OwnerID = (UUID)(String) row["OwnerUUID"]; - newData.IsGroupOwned = (Boolean) row["IsGroupOwned"]; - newData.Area = Convert.ToInt32(row["Area"]); - newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented - newData.Category = (ParcelCategory) Convert.ToInt32(row["Category"]); - //Enum OpenMetaverse.Parcel.ParcelCategory - newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); - newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); - newData.GroupID = new UUID((String) row["GroupUUID"]); - newData.SalePrice = Convert.ToInt32(row["SalePrice"]); - newData.Status = (ParcelStatus) Convert.ToInt32(row["LandStatus"]); - //Enum. OpenMetaverse.Parcel.ParcelStatus - newData.Flags = Convert.ToUInt32(row["LandFlags"]); - newData.LandingType = (Byte) row["LandingType"]; - newData.MediaAutoScale = (Byte) row["MediaAutoScale"]; - newData.MediaID = new UUID((String) row["MediaTextureUUID"]); - newData.MediaURL = (String) row["MediaURL"]; - newData.MusicURL = (String) row["MusicURL"]; - newData.PassHours = Convert.ToSingle(row["PassHours"]); - newData.PassPrice = Convert.ToInt32(row["PassPrice"]); - newData.SnapshotID = (UUID)(String) row["SnapshotUUID"]; - try - { - - newData.UserLocation = - new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), - Convert.ToSingle(row["UserLocationZ"])); - newData.UserLookAt = - new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), - Convert.ToSingle(row["UserLookAtZ"])); - - } - catch (InvalidCastException) - { - m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); - newData.UserLocation = Vector3.Zero; - newData.UserLookAt = Vector3.Zero; - } - newData.ParcelAccessList = new List(); - UUID authBuyerID = UUID.Zero; - - UUID.TryParse((string)row["AuthbuyerID"], out authBuyerID); - - newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); - - return newData; - } - - private RegionSettings buildRegionSettings(DataRow row) - { - RegionSettings newSettings = new RegionSettings(); - - newSettings.RegionUUID = new UUID((string) row["regionUUID"]); - newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); - newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); - newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); - newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]); - newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]); - newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]); - newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]); - newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]); - newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]); - newSettings.Maturity = Convert.ToInt32(row["maturity"]); - newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); - newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); - newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); - newSettings.TerrainTexture1 = new UUID((String) row["terrain_texture_1"]); - newSettings.TerrainTexture2 = new UUID((String) row["terrain_texture_2"]); - newSettings.TerrainTexture3 = new UUID((String) row["terrain_texture_3"]); - newSettings.TerrainTexture4 = new UUID((String) row["terrain_texture_4"]); - newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); - newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); - newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); - newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]); - newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]); - newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]); - newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]); - newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]); - newSettings.WaterHeight = Convert.ToDouble(row["water_height"]); - newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); - newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); - newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); - newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); - newSettings.SunVector = new Vector3 ( - Convert.ToSingle(row["sunvectorx"]), - Convert.ToSingle(row["sunvectory"]), - Convert.ToSingle(row["sunvectorz"]) - ); - newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); - newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); - newSettings.Covenant = new UUID((String) row["covenant"]); - - return newSettings; - } - - /// - /// Build a land access entry from the persisted data. - /// - /// - /// - private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) - { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); - entry.AgentID = new UUID((string) row["AccessUUID"]); - entry.Flags = (AccessList) row["Flags"]; - entry.Time = new DateTime(); - return entry; - } - - /// - /// - /// - /// - /// - private static Array serializeTerrain(double[,] val) - { - MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); - BinaryWriter bw = new BinaryWriter(str); - - // TODO: COMPATIBILITY - Add byte-order conversions - for (int x = 0; x < (int)Constants.RegionSize; x++) - for (int y = 0; y < (int)Constants.RegionSize; y++) - bw.Write(val[x, y]); - - return str.ToArray(); - } - -// private void fillTerrainRow(DataRow row, UUID regionUUID, int rev, double[,] val) -// { -// row["RegionUUID"] = regionUUID; -// row["Revision"] = rev; - - // MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize)*sizeof (double)); -// BinaryWriter bw = new BinaryWriter(str); - -// // TODO: COMPATIBILITY - Add byte-order conversions - // for (int x = 0; x < (int)Constants.RegionSize; x++) - // for (int y = 0; y < (int)Constants.RegionSize; y++) -// bw.Write(val[x, y]); - -// row["Heightfield"] = str.ToArray(); -// } - - /// - /// - /// - /// - /// - /// - /// - private static void fillPrimRow(DataRow row, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) - { - row["UUID"] = prim.UUID.ToString(); - row["RegionUUID"] = regionUUID.ToString(); - row["CreationDate"] = prim.CreationDate; - row["Name"] = prim.Name; - row["SceneGroupID"] = sceneGroupID.ToString(); - // the UUID of the root part for this SceneObjectGroup - // various text fields - row["Text"] = prim.Text; - row["Description"] = prim.Description; - row["SitName"] = prim.SitName; - row["TouchName"] = prim.TouchName; - // permissions - row["ObjectFlags"] = (uint)prim.Flags; - row["CreatorID"] = prim.CreatorIdentification.ToString(); - row["OwnerID"] = prim.OwnerID.ToString(); - row["GroupID"] = prim.GroupID.ToString(); - row["LastOwnerID"] = prim.LastOwnerID.ToString(); - row["OwnerMask"] = prim.OwnerMask; - row["NextOwnerMask"] = prim.NextOwnerMask; - row["GroupMask"] = prim.GroupMask; - row["EveryoneMask"] = prim.EveryoneMask; - row["BaseMask"] = prim.BaseMask; - // vectors - row["PositionX"] = prim.OffsetPosition.X; - row["PositionY"] = prim.OffsetPosition.Y; - row["PositionZ"] = prim.OffsetPosition.Z; - row["GroupPositionX"] = prim.GroupPosition.X; - row["GroupPositionY"] = prim.GroupPosition.Y; - row["GroupPositionZ"] = prim.GroupPosition.Z; - row["VelocityX"] = prim.Velocity.X; - row["VelocityY"] = prim.Velocity.Y; - row["VelocityZ"] = prim.Velocity.Z; - row["AngularVelocityX"] = prim.AngularVelocity.X; - row["AngularVelocityY"] = prim.AngularVelocity.Y; - row["AngularVelocityZ"] = prim.AngularVelocity.Z; - row["AccelerationX"] = prim.Acceleration.X; - row["AccelerationY"] = prim.Acceleration.Y; - row["AccelerationZ"] = prim.Acceleration.Z; - // quaternions - row["RotationX"] = prim.RotationOffset.X; - row["RotationY"] = prim.RotationOffset.Y; - row["RotationZ"] = prim.RotationOffset.Z; - row["RotationW"] = prim.RotationOffset.W; - - // Sit target - Vector3 sitTargetPos = prim.SitTargetPositionLL; - row["SitTargetOffsetX"] = sitTargetPos.X; - row["SitTargetOffsetY"] = sitTargetPos.Y; - row["SitTargetOffsetZ"] = sitTargetPos.Z; - - Quaternion sitTargetOrient = prim.SitTargetOrientationLL; - row["SitTargetOrientW"] = sitTargetOrient.W; - row["SitTargetOrientX"] = sitTargetOrient.X; - row["SitTargetOrientY"] = sitTargetOrient.Y; - row["SitTargetOrientZ"] = sitTargetOrient.Z; - row["ColorR"] = Convert.ToInt32(prim.Color.R); - row["ColorG"] = Convert.ToInt32(prim.Color.G); - row["ColorB"] = Convert.ToInt32(prim.Color.B); - row["ColorA"] = Convert.ToInt32(prim.Color.A); - row["PayPrice"] = prim.PayPrice[0]; - row["PayButton1"] = prim.PayPrice[1]; - row["PayButton2"] = prim.PayPrice[2]; - row["PayButton3"] = prim.PayPrice[3]; - row["PayButton4"] = prim.PayPrice[4]; - - - row["TextureAnimation"] = Convert.ToBase64String(prim.TextureAnimation); - row["ParticleSystem"] = Convert.ToBase64String(prim.ParticleSystem); - - row["OmegaX"] = prim.AngularVelocity.X; - row["OmegaY"] = prim.AngularVelocity.Y; - row["OmegaZ"] = prim.AngularVelocity.Z; - - row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().X; - row["CameraEyeOffsetY"] = prim.GetCameraEyeOffset().Y; - row["CameraEyeOffsetZ"] = prim.GetCameraEyeOffset().Z; - - row["CameraAtOffsetX"] = prim.GetCameraAtOffset().X; - row["CameraAtOffsetY"] = prim.GetCameraAtOffset().Y; - row["CameraAtOffsetZ"] = prim.GetCameraAtOffset().Z; - - - if ((prim.SoundFlags & 1) != 0) // Looped - { - row["LoopedSound"] = prim.Sound.ToString(); - row["LoopedSoundGain"] = prim.SoundGain; - } - else - { - row["LoopedSound"] = UUID.Zero.ToString(); - row["LoopedSoundGain"] = 0.0f; - } - - if (prim.GetForceMouselook()) - row["ForceMouselook"] = 1; - else - row["ForceMouselook"] = 0; - - row["ScriptAccessPin"] = prim.ScriptAccessPin; - - if (prim.AllowedDrop) - row["AllowedDrop"] = 1; - else - row["AllowedDrop"] = 0; - - if (prim.DIE_AT_EDGE) - row["DieAtEdge"] = 1; - else - row["DieAtEdge"] = 0; - - row["SalePrice"] = prim.SalePrice; - row["SaleType"] = Convert.ToInt16(prim.ObjectSaleType); - - // click action - row["ClickAction"] = prim.ClickAction; - - row["SalePrice"] = prim.SalePrice; - row["Material"] = prim.Material; - - row["CollisionSound"] = prim.CollisionSound.ToString(); - row["CollisionSoundVolume"] = prim.CollisionSoundVolume; - if (prim.VolumeDetectActive) - row["VolumeDetect"] = 1; - else - row["VolumeDetect"] = 0; - - } - - /// - /// - /// - /// - /// - private static void fillItemRow(DataRow row, TaskInventoryItem taskItem) - { - row["itemID"] = taskItem.ItemID.ToString(); - row["primID"] = taskItem.ParentPartID.ToString(); - row["assetID"] = taskItem.AssetID.ToString(); - row["parentFolderID"] = taskItem.ParentID.ToString(); - - row["invType"] = taskItem.InvType; - row["assetType"] = taskItem.Type; - - row["name"] = taskItem.Name; - row["description"] = taskItem.Description; - row["creationDate"] = taskItem.CreationDate; - row["creatorID"] = taskItem.CreatorIdentification.ToString(); - row["ownerID"] = taskItem.OwnerID.ToString(); - row["lastOwnerID"] = taskItem.LastOwnerID.ToString(); - row["groupID"] = taskItem.GroupID.ToString(); - row["nextPermissions"] = taskItem.NextPermissions; - row["currentPermissions"] = taskItem.CurrentPermissions; - row["basePermissions"] = taskItem.BasePermissions; - row["everyonePermissions"] = taskItem.EveryonePermissions; - row["groupPermissions"] = taskItem.GroupPermissions; - row["flags"] = taskItem.Flags; - } - - /// - /// - /// - /// - /// - /// - private static void fillLandRow(DataRow row, LandData land, UUID regionUUID) - { - row["UUID"] = land.GlobalID.ToString(); - row["RegionUUID"] = regionUUID.ToString(); - row["LocalLandID"] = land.LocalID; - - // Bitmap is a byte[512] - row["Bitmap"] = land.Bitmap; - - row["Name"] = land.Name; - row["Desc"] = land.Description; - row["OwnerUUID"] = land.OwnerID.ToString(); - row["IsGroupOwned"] = land.IsGroupOwned; - row["Area"] = land.Area; - row["AuctionID"] = land.AuctionID; //Unemplemented - row["Category"] = land.Category; //Enum OpenMetaverse.Parcel.ParcelCategory - row["ClaimDate"] = land.ClaimDate; - row["ClaimPrice"] = land.ClaimPrice; - row["GroupUUID"] = land.GroupID.ToString(); - row["SalePrice"] = land.SalePrice; - row["LandStatus"] = land.Status; //Enum. OpenMetaverse.Parcel.ParcelStatus - row["LandFlags"] = land.Flags; - row["LandingType"] = land.LandingType; - row["MediaAutoScale"] = land.MediaAutoScale; - row["MediaTextureUUID"] = land.MediaID.ToString(); - row["MediaURL"] = land.MediaURL; - row["MusicURL"] = land.MusicURL; - row["PassHours"] = land.PassHours; - row["PassPrice"] = land.PassPrice; - row["SnapshotUUID"] = land.SnapshotID.ToString(); - row["UserLocationX"] = land.UserLocation.X; - row["UserLocationY"] = land.UserLocation.Y; - row["UserLocationZ"] = land.UserLocation.Z; - row["UserLookAtX"] = land.UserLookAt.X; - row["UserLookAtY"] = land.UserLookAt.Y; - row["UserLookAtZ"] = land.UserLookAt.Z; - row["AuthbuyerID"] = land.AuthBuyerID.ToString(); - row["OtherCleanTime"] = land.OtherCleanTime; - } - - /// - /// - /// - /// - /// - /// - private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, UUID parcelID) - { - row["LandUUID"] = parcelID.ToString(); - row["AccessUUID"] = entry.AgentID.ToString(); - row["Flags"] = entry.Flags; - } - - private static void fillRegionSettingsRow(DataRow row, RegionSettings settings) - { - row["regionUUID"] = settings.RegionUUID.ToString(); - row["block_terraform"] = settings.BlockTerraform; - row["block_fly"] = settings.BlockFly; - row["allow_damage"] = settings.AllowDamage; - row["restrict_pushing"] = settings.RestrictPushing; - row["allow_land_resell"] = settings.AllowLandResell; - row["allow_land_join_divide"] = settings.AllowLandJoinDivide; - row["block_show_in_search"] = settings.BlockShowInSearch; - row["agent_limit"] = settings.AgentLimit; - row["object_bonus"] = settings.ObjectBonus; - row["maturity"] = settings.Maturity; - row["disable_scripts"] = settings.DisableScripts; - row["disable_collisions"] = settings.DisableCollisions; - row["disable_physics"] = settings.DisablePhysics; - row["terrain_texture_1"] = settings.TerrainTexture1.ToString(); - row["terrain_texture_2"] = settings.TerrainTexture2.ToString(); - row["terrain_texture_3"] = settings.TerrainTexture3.ToString(); - row["terrain_texture_4"] = settings.TerrainTexture4.ToString(); - row["elevation_1_nw"] = settings.Elevation1NW; - row["elevation_2_nw"] = settings.Elevation2NW; - row["elevation_1_ne"] = settings.Elevation1NE; - row["elevation_2_ne"] = settings.Elevation2NE; - row["elevation_1_se"] = settings.Elevation1SE; - row["elevation_2_se"] = settings.Elevation2SE; - row["elevation_1_sw"] = settings.Elevation1SW; - row["elevation_2_sw"] = settings.Elevation2SW; - row["water_height"] = settings.WaterHeight; - row["terrain_raise_limit"] = settings.TerrainRaiseLimit; - row["terrain_lower_limit"] = settings.TerrainLowerLimit; - row["use_estate_sun"] = settings.UseEstateSun; - row["Sandbox"] = settings.Sandbox; // database uses upper case S for sandbox - row["sunvectorx"] = settings.SunVector.X; - row["sunvectory"] = settings.SunVector.Y; - row["sunvectorz"] = settings.SunVector.Z; - row["fixed_sun"] = settings.FixedSun; - row["sun_position"] = settings.SunPosition; - row["covenant"] = settings.Covenant.ToString(); - } - - /// - /// - /// - /// - /// - private PrimitiveBaseShape buildShape(DataRow row) - { - PrimitiveBaseShape s = new PrimitiveBaseShape(); - s.Scale = new Vector3( - Convert.ToSingle(row["ScaleX"]), - Convert.ToSingle(row["ScaleY"]), - Convert.ToSingle(row["ScaleZ"]) - ); - // paths - s.PCode = Convert.ToByte(row["PCode"]); - s.PathBegin = Convert.ToUInt16(row["PathBegin"]); - s.PathEnd = Convert.ToUInt16(row["PathEnd"]); - s.PathScaleX = Convert.ToByte(row["PathScaleX"]); - s.PathScaleY = Convert.ToByte(row["PathScaleY"]); - s.PathShearX = Convert.ToByte(row["PathShearX"]); - s.PathShearY = Convert.ToByte(row["PathShearY"]); - s.PathSkew = Convert.ToSByte(row["PathSkew"]); - s.PathCurve = Convert.ToByte(row["PathCurve"]); - s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]); - s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]); - s.PathTaperX = Convert.ToSByte(row["PathTaperX"]); - s.PathTaperY = Convert.ToSByte(row["PathTaperY"]); - s.PathTwist = Convert.ToSByte(row["PathTwist"]); - s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]); - // profile - s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]); - s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); - s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); - s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); - s.State = Convert.ToByte(row["State"]); - - byte[] textureEntry = (byte[])row["Texture"]; - s.TextureEntry = textureEntry; - - s.ExtraParams = (byte[]) row["ExtraParams"]; - return s; - } - - /// - /// - /// - /// - /// - private static void fillShapeRow(DataRow row, SceneObjectPart prim) - { - PrimitiveBaseShape s = prim.Shape; - row["UUID"] = prim.UUID.ToString(); - // shape is an enum - row["Shape"] = 0; - // vectors - row["ScaleX"] = s.Scale.X; - row["ScaleY"] = s.Scale.Y; - row["ScaleZ"] = s.Scale.Z; - // paths - row["PCode"] = s.PCode; - row["PathBegin"] = s.PathBegin; - row["PathEnd"] = s.PathEnd; - row["PathScaleX"] = s.PathScaleX; - row["PathScaleY"] = s.PathScaleY; - row["PathShearX"] = s.PathShearX; - row["PathShearY"] = s.PathShearY; - row["PathSkew"] = s.PathSkew; - row["PathCurve"] = s.PathCurve; - row["PathRadiusOffset"] = s.PathRadiusOffset; - row["PathRevolutions"] = s.PathRevolutions; - row["PathTaperX"] = s.PathTaperX; - row["PathTaperY"] = s.PathTaperY; - row["PathTwist"] = s.PathTwist; - row["PathTwistBegin"] = s.PathTwistBegin; - // profile - row["ProfileBegin"] = s.ProfileBegin; - row["ProfileEnd"] = s.ProfileEnd; - row["ProfileCurve"] = s.ProfileCurve; - row["ProfileHollow"] = s.ProfileHollow; - row["State"] = s.State; - - row["Texture"] = s.TextureEntry; - row["ExtraParams"] = s.ExtraParams; - } - - /// - /// - /// - /// - /// - /// - private void addPrim(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) - { - - DataTable prims = ds.Tables["prims"]; - DataTable shapes = ds.Tables["primshapes"]; - - DataRow primRow = prims.Rows.Find(prim.UUID.ToString()); - if (primRow == null) - { - primRow = prims.NewRow(); - fillPrimRow(primRow, prim, sceneGroupID, regionUUID); - prims.Rows.Add(primRow); - } - else - { - fillPrimRow(primRow, prim, sceneGroupID, regionUUID); - } - - DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString()); - if (shapeRow == null) - { - shapeRow = shapes.NewRow(); - fillShapeRow(shapeRow, prim); - shapes.Rows.Add(shapeRow); - } - else - { - fillShapeRow(shapeRow, prim); - } - } - - /// - /// - /// - /// - public void StorePrimInventory(UUID primID, ICollection items) - { - m_log.InfoFormat("[REGION DB]: Entered StorePrimInventory with prim ID {0}", primID); - - DataTable dbItems = ds.Tables["primitems"]; - - // For now, we're just going to crudely remove all the previous inventory items - // no matter whether they have changed or not, and replace them with the current set. - lock (ds) - { - RemoveItems(primID); - - // repalce with current inventory details - foreach (TaskInventoryItem newItem in items) - { -// m_log.InfoFormat( -// "[DATASTORE]: ", -// "Adding item {0}, {1} to prim ID {2}", -// newItem.Name, newItem.ItemID, newItem.ParentPartID); - - DataRow newItemRow = dbItems.NewRow(); - fillItemRow(newItemRow, newItem); - dbItems.Rows.Add(newItemRow); - } - } - - Commit(); - } - - /*********************************************************************** - * - * SQL Statement Creation Functions - * - * These functions create SQL statements for update, insert, and create. - * They can probably be factored later to have a db independant - * portion and a db specific portion - * - **********************************************************************/ - - /// - /// Create an insert command - /// - /// table name - /// data table - /// the created command - /// - /// This is subtle enough to deserve some commentary. - /// Instead of doing *lots* and *lots of hardcoded strings - /// for database definitions we'll use the fact that - /// realistically all insert statements look like "insert - /// into A(b, c) values(:b, :c) on the parameterized query - /// front. If we just have a list of b, c, etc... we can - /// generate these strings instead of typing them out. - /// - private static SqliteCommand createInsertCommand(string table, DataTable dt) - { - string[] cols = new string[dt.Columns.Count]; - for (int i = 0; i < dt.Columns.Count; i++) - { - DataColumn col = dt.Columns[i]; - cols[i] = col.ColumnName; - } - - string sql = "insert into " + table + "("; - sql += String.Join(", ", cols); - // important, the first ':' needs to be here, the rest get added in the join - sql += ") values (:"; - sql += String.Join(", :", cols); - sql += ")"; - SqliteCommand cmd = new SqliteCommand(sql); - - // this provides the binding for all our parameters, so - // much less code than it used to be - foreach (DataColumn col in dt.Columns) - { - cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType)); - } - return cmd; - } - - - /// - /// create an update command - /// - /// table name - /// - /// - /// the created command - private static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt) - { - string sql = "update " + table + " set "; - string subsql = String.Empty; - foreach (DataColumn col in dt.Columns) - { - if (subsql.Length > 0) - { - // a map function would rock so much here - subsql += ", "; - } - subsql += col.ColumnName + "= :" + col.ColumnName; - } - sql += subsql; - sql += " where " + pk; - SqliteCommand cmd = new SqliteCommand(sql); - - // this provides the binding for all our parameters, so - // much less code than it used to be - - foreach (DataColumn col in dt.Columns) - { - cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType)); - } - return cmd; - } - - /// - /// create an update command - /// - /// table name - /// - /// - /// the created command - private static SqliteCommand createUpdateCommand(string table, string pk1, string pk2, DataTable dt) - { - string sql = "update " + table + " set "; - string subsql = String.Empty; - foreach (DataColumn col in dt.Columns) - { - if (subsql.Length > 0) - { - // a map function would rock so much here - subsql += ", "; - } - subsql += col.ColumnName + "= :" + col.ColumnName; - } - sql += subsql; - sql += " where " + pk1 + " and " + pk2; - SqliteCommand cmd = new SqliteCommand(sql); - - // this provides the binding for all our parameters, so - // much less code than it used to be - - foreach (DataColumn col in dt.Columns) - { - cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType)); - } - return cmd; - } - - /// - /// - /// - /// Data Table - /// - // private static string defineTable(DataTable dt) - // { - // string sql = "create table " + dt.TableName + "("; - // string subsql = String.Empty; - // foreach (DataColumn col in dt.Columns) - // { - // if (subsql.Length > 0) - // { - // // a map function would rock so much here - // subsql += ",\n"; - // } - // subsql += col.ColumnName + " " + sqliteType(col.DataType); - // if (dt.PrimaryKey.Length > 0 && col == dt.PrimaryKey[0]) - // { - // subsql += " primary key"; - // } - // } - // sql += subsql; - // sql += ")"; - // return sql; - // } - - /*********************************************************************** - * - * Database Binding functions - * - * These will be db specific due to typing, and minor differences - * in databases. - * - **********************************************************************/ - - /// - /// This is a convenience function that collapses 5 repetitive - /// lines for defining SqliteParameters to 2 parameters: - /// column name and database type. - /// - /// It assumes certain conventions like :param as the param - /// name to replace in parametrized queries, and that source - /// version is always current version, both of which are fine - /// for us. - /// - ///a built sqlite parameter - private static SqliteParameter createSqliteParameter(string name, Type type) - { - SqliteParameter param = new SqliteParameter(); - param.ParameterName = ":" + name; - param.DbType = dbtypeFromType(type); - param.SourceColumn = name; - param.SourceVersion = DataRowVersion.Current; - return param; - } - - /// - /// - /// - /// - /// - private void setupPrimCommands(SqliteDataAdapter da, SqliteConnection conn) - { - da.InsertCommand = createInsertCommand("prims", ds.Tables["prims"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("prims", "UUID=:UUID", ds.Tables["prims"]); - da.UpdateCommand.Connection = conn; - - SqliteCommand delete = new SqliteCommand("delete from prims where UUID = :UUID"); - delete.Parameters.Add(createSqliteParameter("UUID", typeof (String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - - /// - /// - /// - /// - /// - private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn) - { - da.InsertCommand = createInsertCommand("primitems", ds.Tables["primitems"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("primitems", "itemID = :itemID", ds.Tables["primitems"]); - da.UpdateCommand.Connection = conn; - - SqliteCommand delete = new SqliteCommand("delete from primitems where itemID = :itemID"); - delete.Parameters.Add(createSqliteParameter("itemID", typeof (String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - - /// - /// - /// - /// - /// - private void setupTerrainCommands(SqliteDataAdapter da, SqliteConnection conn) - { - da.InsertCommand = createInsertCommand("terrain", ds.Tables["terrain"]); - da.InsertCommand.Connection = conn; - } - - /// - /// - /// - /// - /// - private void setupLandCommands(SqliteDataAdapter da, SqliteConnection conn) - { - da.InsertCommand = createInsertCommand("land", ds.Tables["land"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("land", "UUID=:UUID", ds.Tables["land"]); - da.UpdateCommand.Connection = conn; - - SqliteCommand delete = new SqliteCommand("delete from land where UUID=:UUID"); - delete.Parameters.Add(createSqliteParameter("UUID", typeof(String))); - da.DeleteCommand = delete; - da.DeleteCommand.Connection = conn; - } - - /// - /// - /// - /// - /// - private void setupLandAccessCommands(SqliteDataAdapter da, SqliteConnection conn) - { - da.InsertCommand = createInsertCommand("landaccesslist", ds.Tables["landaccesslist"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("landaccesslist", "LandUUID=:landUUID", "AccessUUID=:AccessUUID", ds.Tables["landaccesslist"]); - da.UpdateCommand.Connection = conn; - - SqliteCommand delete = new SqliteCommand("delete from landaccesslist where LandUUID= :LandUUID and AccessUUID= :AccessUUID"); - delete.Parameters.Add(createSqliteParameter("LandUUID", typeof(String))); - delete.Parameters.Add(createSqliteParameter("AccessUUID", typeof(String))); - da.DeleteCommand = delete; - da.DeleteCommand.Connection = conn; - - } - - private void setupRegionSettingsCommands(SqliteDataAdapter da, SqliteConnection conn) - { - da.InsertCommand = createInsertCommand("regionsettings", ds.Tables["regionsettings"]); - da.InsertCommand.Connection = conn; - da.UpdateCommand = createUpdateCommand("regionsettings", "regionUUID=:regionUUID", ds.Tables["regionsettings"]); - da.UpdateCommand.Connection = conn; - } - - /// - /// - /// - /// - /// - private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn) - { - da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("primshapes", "UUID=:UUID", ds.Tables["primshapes"]); - da.UpdateCommand.Connection = conn; - - SqliteCommand delete = new SqliteCommand("delete from primshapes where UUID = :UUID"); - delete.Parameters.Add(createSqliteParameter("UUID", typeof (String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - - /*********************************************************************** - * - * Type conversion functions - * - **********************************************************************/ - - /// - /// Type conversion function - /// - /// - /// - private static DbType dbtypeFromType(Type type) - { - if (type == typeof (String)) - { - return DbType.String; - } - else if (type == typeof (Int32)) - { - return DbType.Int32; - } - else if (type == typeof (Double)) - { - return DbType.Double; - } - else if (type == typeof (Byte)) - { - return DbType.Byte; - } - else if (type == typeof (Double)) - { - return DbType.Double; - } - else if (type == typeof (Byte[])) - { - return DbType.Binary; - } - else - { - return DbType.String; - } - } - - } -} diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteUserAccountData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteUserAccountData.cs deleted file mode 100644 index 27553c6..0000000 --- a/OpenSim/Data/SQLiteLegacy/SQLiteUserAccountData.cs +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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; -using System.Collections.Generic; -using System.Data; -using OpenMetaverse; -using OpenSim.Framework; -using Mono.Data.SqliteClient; - -namespace OpenSim.Data.SQLiteLegacy -{ - public class SQLiteUserAccountData : SQLiteGenericTableHandler, IUserAccountData - { - public SQLiteUserAccountData(string connectionString, string realm) - : base(connectionString, realm, "UserAccount") - { - } - - public UserAccountData[] GetUsers(UUID scopeID, string query) - { - string[] words = query.Split(new char[] {' '}); - - for (int i = 0 ; i < words.Length ; i++) - { - if (words[i].Length < 3) - { - if (i != words.Length - 1) - Array.Copy(words, i + 1, words, i, words.Length - i - 1); - Array.Resize(ref words, words.Length - 1); - } - } - - if (words.Length == 0) - return new UserAccountData[0]; - - if (words.Length > 2) - return new UserAccountData[0]; - - SqliteCommand cmd = new SqliteCommand(); - - if (words.Length == 1) - { - cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", - m_Realm, scopeID.ToString(), words[0]); - } - else - { - cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')", - m_Realm, scopeID.ToString(), words[0], words[1]); - } - - return DoQuery(cmd); - } - } -} diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteUtils.cs b/OpenSim/Data/SQLiteLegacy/SQLiteUtils.cs deleted file mode 100644 index 095a262..0000000 --- a/OpenSim/Data/SQLiteLegacy/SQLiteUtils.cs +++ /dev/null @@ -1,307 +0,0 @@ -/* - * 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.Data; -using Mono.Data.SqliteClient; - -namespace OpenSim.Data.SQLiteLegacy -{ - /// - /// A base class for methods needed by all SQLite database classes - /// - public class SQLiteUtil - { - /*********************************************************************** - * - * Database Definition Helper Functions - * - * This should be db agnostic as we define them in ADO.NET terms - * - **********************************************************************/ - - /// - /// - /// - /// - /// - /// - public static void createCol(DataTable dt, string name, Type type) - { - DataColumn col = new DataColumn(name, type); - dt.Columns.Add(col); - } - - /*********************************************************************** - * - * SQL Statement Creation Functions - * - * These functions create SQL statements for update, insert, and create. - * They can probably be factored later to have a db independant - * portion and a db specific portion - * - **********************************************************************/ - - /// - /// Create an insert command - /// - /// table name - /// data table - /// the created command - /// - /// This is subtle enough to deserve some commentary. - /// Instead of doing *lots* and *lots of hardcoded strings - /// for database definitions we'll use the fact that - /// realistically all insert statements look like "insert - /// into A(b, c) values(:b, :c) on the parameterized query - /// front. If we just have a list of b, c, etc... we can - /// generate these strings instead of typing them out. - /// - public static SqliteCommand createInsertCommand(string table, DataTable dt) - { - - string[] cols = new string[dt.Columns.Count]; - for (int i = 0; i < dt.Columns.Count; i++) - { - DataColumn col = dt.Columns[i]; - cols[i] = col.ColumnName; - } - - string sql = "insert into " + table + "("; - sql += String.Join(", ", cols); - // important, the first ':' needs to be here, the rest get added in the join - sql += ") values (:"; - sql += String.Join(", :", cols); - sql += ")"; - SqliteCommand cmd = new SqliteCommand(sql); - - // this provides the binding for all our parameters, so - // much less code than it used to be - foreach (DataColumn col in dt.Columns) - { - cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType)); - } - return cmd; - } - - /// - /// create an update command - /// - /// table name - /// - /// - /// the created command - public static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt) - { - string sql = "update " + table + " set "; - string subsql = String.Empty; - foreach (DataColumn col in dt.Columns) - { - if (subsql.Length > 0) - { - // a map function would rock so much here - subsql += ", "; - } - subsql += col.ColumnName + "= :" + col.ColumnName; - } - sql += subsql; - sql += " where " + pk; - SqliteCommand cmd = new SqliteCommand(sql); - - // this provides the binding for all our parameters, so - // much less code than it used to be - - foreach (DataColumn col in dt.Columns) - { - cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType)); - } - return cmd; - } - - /// - /// - /// - /// Data Table - /// - public static string defineTable(DataTable dt) - { - string sql = "create table " + dt.TableName + "("; - string subsql = String.Empty; - foreach (DataColumn col in dt.Columns) - { - if (subsql.Length > 0) - { - // a map function would rock so much here - subsql += ",\n"; - } - subsql += col.ColumnName + " " + sqliteType(col.DataType); - if (dt.PrimaryKey.Length > 0) - { - if (col == dt.PrimaryKey[0]) - { - subsql += " primary key"; - } - } - } - sql += subsql; - sql += ")"; - return sql; - } - - /*********************************************************************** - * - * Database Binding functions - * - * These will be db specific due to typing, and minor differences - * in databases. - * - **********************************************************************/ - - /// - /// - /// This is a convenience function that collapses 5 repetitive - /// lines for defining SqliteParameters to 2 parameters: - /// column name and database type. - /// - /// - /// - /// It assumes certain conventions like :param as the param - /// name to replace in parametrized queries, and that source - /// version is always current version, both of which are fine - /// for us. - /// - /// - /// - /// - ///a built sqlite parameter - public static SqliteParameter createSqliteParameter(string name, Type type) - { - SqliteParameter param = new SqliteParameter(); - param.ParameterName = ":" + name; - param.DbType = dbtypeFromType(type); - param.SourceColumn = name; - param.SourceVersion = DataRowVersion.Current; - return param; - } - - /*********************************************************************** - * - * Type conversion functions - * - **********************************************************************/ - - /// - /// Type conversion function - /// - /// a type - /// a DbType - public static DbType dbtypeFromType(Type type) - { - if (type == typeof (String)) - { - return DbType.String; - } - else if (type == typeof (Int32)) - { - return DbType.Int32; - } - else if (type == typeof (UInt32)) - { - return DbType.UInt32; - } - else if (type == typeof (Int64)) - { - return DbType.Int64; - } - else if (type == typeof (UInt64)) - { - return DbType.UInt64; - } - else if (type == typeof (Double)) - { - return DbType.Double; - } - else if (type == typeof (Boolean)) - { - return DbType.Boolean; - } - else if (type == typeof (Byte[])) - { - return DbType.Binary; - } - else - { - return DbType.String; - } - } - - /// - /// - /// a Type - /// a string - /// this is something we'll need to implement for each db slightly differently. - public static string sqliteType(Type type) - { - if (type == typeof (String)) - { - return "varchar(255)"; - } - else if (type == typeof (Int32)) - { - return "integer"; - } - else if (type == typeof (UInt32)) - { - return "integer"; - } - else if (type == typeof (Int64)) - { - return "varchar(255)"; - } - else if (type == typeof (UInt64)) - { - return "varchar(255)"; - } - else if (type == typeof (Double)) - { - return "float"; - } - else if (type == typeof (Boolean)) - { - return "integer"; - } - else if (type == typeof (Byte[])) - { - return "blob"; - } - else - { - return "string"; - } - } - } -} diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteXInventoryData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteXInventoryData.cs deleted file mode 100644 index 5422cbf..0000000 --- a/OpenSim/Data/SQLiteLegacy/SQLiteXInventoryData.cs +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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.Data; -using System.Reflection; -using System.Collections.Generic; -using Mono.Data.SqliteClient; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; - -namespace OpenSim.Data.SQLiteLegacy -{ - /// - /// A MySQL Interface for the Asset Server - /// - public class SQLiteXInventoryData : IXInventoryData - { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private SQLiteGenericTableHandler m_Folders; - private SqliteItemHandler m_Items; - - public SQLiteXInventoryData(string conn, string realm) - { - m_Folders = new SQLiteGenericTableHandler( - conn, "inventoryfolders", "InventoryStore"); - m_Items = new SqliteItemHandler( - conn, "inventoryitems", String.Empty); - } - - public XInventoryFolder[] GetFolders(string[] fields, string[] vals) - { - return m_Folders.Get(fields, vals); - } - - public XInventoryItem[] GetItems(string[] fields, string[] vals) - { - return m_Items.Get(fields, vals); - } - - public bool StoreFolder(XInventoryFolder folder) - { - return m_Folders.Store(folder); - } - - public bool StoreItem(XInventoryItem item) - { - return m_Items.Store(item); - } - - public bool DeleteFolders(string field, string val) - { - return m_Folders.Delete(field, val); - } - - public bool DeleteItems(string field, string val) - { - return m_Items.Delete(field, val); - } - - public bool MoveItem(string id, string newParent) - { - return m_Items.MoveItem(id, newParent); - } - - public XInventoryItem[] GetActiveGestures(UUID principalID) - { - return m_Items.GetActiveGestures(principalID); - } - - public int GetAssetPermissions(UUID principalID, UUID assetID) - { - return m_Items.GetAssetPermissions(principalID, assetID); - } - } - - public class SqliteItemHandler : SQLiteGenericTableHandler - { - public SqliteItemHandler(string c, string t, string m) : - base(c, t, m) - { - } - - public bool MoveItem(string id, string newParent) - { - SqliteCommand cmd = new SqliteCommand(); - - cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm); - cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent)); - cmd.Parameters.Add(new SqliteParameter(":InventoryID", id)); - - return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true; - } - - public XInventoryItem[] GetActiveGestures(UUID principalID) - { - SqliteCommand cmd = new SqliteCommand(); - cmd.CommandText = String.Format("select * from inventoryitems where avatarId = :uuid and assetType = :type and flags = 1", m_Realm); - - cmd.Parameters.Add(new SqliteParameter(":uuid", principalID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":type", (int)AssetType.Gesture)); - - return DoQuery(cmd); - } - - public int GetAssetPermissions(UUID principalID, UUID assetID) - { - SqliteCommand cmd = new SqliteCommand(); - - cmd.CommandText = String.Format("select inventoryCurrentPermissions from inventoryitems where avatarID = :PrincipalID and assetID = :AssetID", m_Realm); - cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString())); - - IDataReader reader = ExecuteReader(cmd, m_Connection); - - int perms = 0; - - while (reader.Read()) - { - perms |= Convert.ToInt32(reader["inventoryCurrentPermissions"]); - } - - reader.Close(); - CloseCommand(cmd); - - return perms; - } - } -} -- cgit v1.1 From 0ced677510b0d270506dce4e80fa906f2a8ea649 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 7 Apr 2011 23:22:19 +0100 Subject: Revert master version number to 0.7.1 for now to make merging easier. --- OpenSim/Framework/Servers/VersionInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index 53a3f17..c9d4c93 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs @@ -29,7 +29,7 @@ namespace OpenSim { public class VersionInfo { - private const string VERSION_NUMBER = "0.7.2"; + private const string VERSION_NUMBER = "0.7.1"; private const Flavour VERSION_FLAVOUR = Flavour.Dev; public enum Flavour -- cgit v1.1 From d31175060f8133c42c84da5b8e701ff1fb16eed8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 8 Apr 2011 00:42:35 +0100 Subject: trivial whitespace removal to trigger a panda rebuild --- OpenSim/Region/Application/Application.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'OpenSim') 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 m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false); // load Crash directory config - m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir); - - + m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir); if (background) { @@ -260,15 +258,9 @@ namespace OpenSim m_sim.Startup(); } else - { - - - - + { m_sim = new OpenSim(configSource); - - - + m_sim.Startup(); while (true) -- cgit v1.1 From abea0c74c2b092d0474880a30433d9d0a2400aa8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 8 Apr 2011 04:19:17 +0100 Subject: Add support for the new display name related functions in LSL. This does not implement the display names functionality as such, but it allows scripts that are display name aware to function as if the display name were implemented and set to the avatar name. --- .../Shared/Api/Implementation/LSL_Api.cs | 49 ++++++++++++++++++++++ .../Api/Implementation/Plugins/SensorRepeat.cs | 26 ++++++++++-- .../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 4 ++ .../Shared/Api/Runtime/LSL_Constants.cs | 2 + .../ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 20 +++++++++ 5 files changed, 97 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index e5be641..c16a985 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10268,6 +10268,55 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_log.Info("LSL print():" + str); } } + + private string Name2Username(string name) + { + string[] parts = name.Split(new char[] {' '}); + if (parts.Length < 2) + return name.ToLower(); + if (parts[1] == "Resident") + return parts[0].ToLower(); + + return name.Replace(" ", ".").ToLower(); + } + + public LSL_String llGetUsername(string id) + { + return Name2Username(llKey2Name(id)); + } + + public LSL_String llRequestUsername(string id) + { + UUID rq = UUID.Random(); + + UUID tid = AsyncCommands. + DataserverPlugin.RegisterRequest(m_localID, + m_itemID, rq.ToString()); + + AsyncCommands. + DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); + + return rq.ToString(); + } + + public LSL_String llGetDisplayName(string id) + { + return llKey2Name(id); + } + + public LSL_String llRequestDisplayName(string id) + { + UUID rq = UUID.Random(); + + UUID tid = AsyncCommands. + DataserverPlugin.RegisterRequest(m_localID, + m_itemID, rq.ToString()); + + AsyncCommands. + DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); + + return rq.ToString(); + } } 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 private Object SenseLock = new Object(); private const int AGENT = 1; + private const int AGENT_BY_USERNAME = 0x10; private const int ACTIVE = 2; private const int PASSIVE = 4; private const int SCRIPTED = 8; @@ -202,7 +203,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins List sensedEntities = new List(); // Is the sensor type is AGENT and not SCRIPTED then include agents - if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) + if ((ts.type & (AGENT | AGENT_BY_USERNAME)) != 0 && (ts.type & SCRIPTED) == 0) { sensedEntities.AddRange(doAgentSensor(ts)); } @@ -493,9 +494,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins { ScenePresence sp; // Try lookup by name will return if/when found - if (!m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp)) - return sensedEntities; - senseEntity(sp); + if (((ts.type & AGENT) != 0) && m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp)) + senseEntity(sp); + if ((ts.type & AGENT_BY_USERNAME) != 0) + { + m_CmdManager.m_ScriptEngine.World.ForEachScenePresence( + delegate (ScenePresence ssp) + { + if (ssp.Lastname == "Resident") + { + if (ssp.Firstname.ToLower() == ts.name) + senseEntity(ssp); + return; + } + if (ssp.Name.Replace(" ", ".").ToLower() == ts.name) + senseEntity(ssp); + } + ); + } + + return sensedEntities; } else { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index bd6a094..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 void llInstantMessage(string user, string message); LSL_String llIntegerToBase64(int number); LSL_String llKey2Name(string id); + LSL_String llGetUsername(string id); + LSL_String llRequestUsername(string id); + LSL_String llGetDisplayName(string id); + LSL_String llRequestDisplayName(string id); void llLinkParticleSystem(int linknum, LSL_List rules); LSL_String llList2CSV(LSL_List src); LSL_Float llList2Float(LSL_List src, int index); 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 public const int STATUS_CAST_SHADOWS = 512; public const int AGENT = 1; + public const int AGENT_BY_LEGACY_NAME = 1; + public const int AGENT_BY_USERNAME = 0x10; public const int ACTIVE = 2; public const int PASSIVE = 4; 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 3b29861..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 return m_LSL_Functions.llKey2Name(id); } + public LSL_String llGetUsername(string id) + { + return m_LSL_Functions.llGetUsername(id); + } + + public LSL_String llRequestUsername(string id) + { + return m_LSL_Functions.llRequestUsername(id); + } + + public LSL_String llGetDisplayName(string id) + { + return m_LSL_Functions.llGetDisplayName(id); + } + + public LSL_String llRequestDisplayName(string id) + { + return m_LSL_Functions.llRequestDisplayName(id); + } + public void llLinkParticleSystem(int linknum, LSL_List rules) { m_LSL_Functions.llLinkParticleSystem(linknum, rules); -- cgit v1.1 From 707b6673c91733cd1298261f9f8150e7bc0c3970 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 9 Apr 2011 00:25:00 +0100 Subject: minor: remove mono compiler warnings --- OpenSim/Client/MXP/ClientStack/MXPClientView.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 93c6c98..d1a0440 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs @@ -66,8 +66,8 @@ namespace OpenSim.Client.MXP.ClientStack private readonly IScene m_scene; private readonly string m_firstName; private readonly string m_lastName; - private int m_objectsToSynchronize = 0; - private int m_objectsSynchronized = -1; +// private int m_objectsToSynchronize = 0; +// private int m_objectsSynchronized = -1; private Vector3 m_startPosition=new Vector3(128f, 128f, 128f); #endregion @@ -462,8 +462,8 @@ namespace OpenSim.Client.MXP.ClientStack public void MXPSendSynchronizationBegin(int objectCount) { - m_objectsToSynchronize = objectCount; - m_objectsSynchronized = 0; +// m_objectsToSynchronize = objectCount; +// m_objectsSynchronized = 0; SynchronizationBeginEventMessage synchronizationBeginEventMessage = new SynchronizationBeginEventMessage(); synchronizationBeginEventMessage.ObjectCount = (uint)objectCount; Session.Send(synchronizationBeginEventMessage); -- cgit v1.1 From 77cf9405de10f016d85d67b6016ed27d28ed898f Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 28 Mar 2011 10:00:53 -0700 Subject: Implements adaptive queue management and fair queueing for improved networking performance. Reprioritization algorithms need to be ported still. One is in place. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 353 ++++++++++++++------- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 71 ++++- 2 files changed, 304 insertions(+), 120 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 34d72ac..a3f2c15 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -49,6 +49,8 @@ using Timer = System.Timers.Timer; using AssetLandmark = OpenSim.Framework.AssetLandmark; using Nini.Config; +using System.IO; + namespace OpenSim.Region.ClientStack.LindenUDP { public delegate bool PacketMethod(IClientAPI simClient, Packet packet); @@ -298,6 +300,77 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Used to adjust Sun Orbit values so Linden based viewers properly position sun private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f; + // First log file or time has expired, start writing to a new log file +// +// ----------------------------------------------------------------- +// ----------------------------------------------------------------- +// THIS IS DEBUGGING CODE & SHOULD BE REMOVED +// ----------------------------------------------------------------- +// ----------------------------------------------------------------- + public class QueueLogger + { + public Int32 start = 0; + public StreamWriter Log = null; + private Dictionary m_idMap = new Dictionary(); + + public QueueLogger() + { + DateTime now = DateTime.Now; + String fname = String.Format("queue-{0}.log", now.ToString("yyyyMMddHHmmss")); + Log = new StreamWriter(fname); + + start = Util.EnvironmentTickCount(); + } + + public int LookupID(UUID uuid) + { + int localid; + if (! m_idMap.TryGetValue(uuid,out localid)) + { + localid = m_idMap.Count + 1; + m_idMap[uuid] = localid; + } + + return localid; + } + } + + public static QueueLogger QueueLog = null; + + // ----------------------------------------------------------------- + public void LogAvatarUpdateEvent(UUID client, UUID avatar, Int32 timeinqueue) + { + if (QueueLog == null) + QueueLog = new QueueLogger(); + + Int32 ticks = Util.EnvironmentTickCountSubtract(QueueLog.start); + lock(QueueLog) + { + int cid = QueueLog.LookupID(client); + int aid = QueueLog.LookupID(avatar); + QueueLog.Log.WriteLine("{0},AU,AV{1:D4},AV{2:D4},{3}",ticks,cid,aid,timeinqueue); + } + } + + // ----------------------------------------------------------------- + public void LogQueueProcessEvent(UUID client, PriorityQueue queue, uint maxup) + { + if (QueueLog == null) + QueueLog = new QueueLogger(); + + Int32 ticks = Util.EnvironmentTickCountSubtract(QueueLog.start); + lock(QueueLog) + { + int cid = QueueLog.LookupID(client); + QueueLog.Log.WriteLine("{0},PQ,AV{1:D4},{2},{3}",ticks,cid,maxup,queue.ToString()); + } + } +// ----------------------------------------------------------------- +// ----------------------------------------------------------------- +// ----------------------------------------------------------------- +// ----------------------------------------------------------------- +// + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected static Dictionary PacketHandlers = new Dictionary(); //Global/static handlers for all clients @@ -3547,18 +3620,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Primitive Packet/Data Sending Methods + /// /// Generate one of the object update packets based on PrimUpdateFlags /// and broadcast the packet to clients /// public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) { - double priority = m_prioritizer.GetUpdatePriority(this, entity); + //double priority = m_prioritizer.GetUpdatePriority(this, entity); + uint priority = m_prioritizer.GetUpdatePriority(this, entity); lock (m_entityUpdates.SyncRoot) - m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation), entity.LocalId); + m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation)); } + private Int32 m_LastQueueFill = 0; + private uint m_maxUpdates = 0; + private void ProcessEntityUpdates(int maxUpdates) { OpenSim.Framework.Lazy> objectUpdateBlocks = new OpenSim.Framework.Lazy>(); @@ -3566,23 +3644,55 @@ namespace OpenSim.Region.ClientStack.LindenUDP OpenSim.Framework.Lazy> terseUpdateBlocks = new OpenSim.Framework.Lazy>(); OpenSim.Framework.Lazy> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy>(); - if (maxUpdates <= 0) maxUpdates = Int32.MaxValue; + if (maxUpdates <= 0) + { + m_maxUpdates = Int32.MaxValue; + } + else + { + if (m_maxUpdates == 0 || m_LastQueueFill == 0) + { + m_maxUpdates = (uint)maxUpdates; + } + else + { + if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200) + m_maxUpdates += 5; + else + m_maxUpdates = m_maxUpdates >> 1; + } + m_maxUpdates = Util.Clamp(m_maxUpdates,10,500); + } + m_LastQueueFill = Util.EnvironmentTickCount(); + int updatesThisCall = 0; +// +// DEBUGGING CODE... REMOVE +// LogQueueProcessEvent(this.m_agentId,m_entityUpdates,m_maxUpdates); +// // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race // condition where a kill can be processed before an out-of-date update for the same object. lock (m_killRecord) { float avgTimeDilation = 1.0f; EntityUpdate update; - while (updatesThisCall < maxUpdates) + Int32 timeinqueue; // this is just debugging code & can be dropped later + + while (updatesThisCall < m_maxUpdates) { lock (m_entityUpdates.SyncRoot) - if (!m_entityUpdates.TryDequeue(out update)) + if (!m_entityUpdates.TryDequeue(out update, out timeinqueue)) break; avgTimeDilation += update.TimeDilation; avgTimeDilation *= 0.5f; +// +// DEBUGGING CODE... REMOVE +// if (update.Entity is ScenePresence) +// LogAvatarUpdateEvent(this.m_agentId,update.Entity.UUID,timeinqueue); +// + if (update.Entity is SceneObjectPart) { SceneObjectPart part = (SceneObjectPart)update.Entity; @@ -3679,36 +3789,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } else { - // if (update.Entity is SceneObjectPart && ((SceneObjectPart)update.Entity).IsAttachment) - // { - // SceneObjectPart sop = (SceneObjectPart)update.Entity; - // string text = sop.Text; - // if (text.IndexOf("\n") >= 0) - // text = text.Remove(text.IndexOf("\n")); - // - // if (m_attachmentsSent.Contains(sop.ParentID)) - // { - //// m_log.DebugFormat( - //// "[CLIENT]: Sending full info about attached prim {0} text {1}", - //// sop.LocalId, text); - // - // objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock(sop, this.m_agentId)); - // - // m_attachmentsSent.Add(sop.LocalId); - // } - // else - // { - // m_log.DebugFormat( - // "[CLIENT]: Requeueing full update of prim {0} text {1} since we haven't sent its parent {2} yet", - // sop.LocalId, text, sop.ParentID); - // - // m_entityUpdates.Enqueue(double.MaxValue, update, sop.LocalId); - // } - // } - // else - // { - objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId)); - // } + objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId)); } } else if (!canUseImproved) @@ -3802,26 +3883,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void ReprioritizeUpdates() { - //m_log.Debug("[CLIENT]: Reprioritizing prim updates for " + m_firstName + " " + m_lastName); - lock (m_entityUpdates.SyncRoot) m_entityUpdates.Reprioritize(UpdatePriorityHandler); } - private bool UpdatePriorityHandler(ref double priority, uint localID) + private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity) { - EntityBase entity; - if (m_scene.Entities.TryGetValue(localID, out entity)) + if (entity != null) { priority = m_prioritizer.GetUpdatePriority(this, entity); + return true; } - return priority != double.NaN; + return false; } public void FlushPrimUpdates() { - m_log.Debug("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName); + m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName); while (m_entityUpdates.Count > 0) ProcessEntityUpdates(-1); @@ -11729,86 +11808,85 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region PriorityQueue public class PriorityQueue { - internal delegate bool UpdatePriorityHandler(ref double priority, uint local_id); + internal delegate bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity); + + // Heap[0] for self updates + // Heap[1..12] for entity updates - private MinHeap[] m_heaps = new MinHeap[1]; + internal const uint m_numberOfQueues = 12; + private MinHeap[] m_heaps = new MinHeap[m_numberOfQueues]; private Dictionary m_lookupTable; - private Comparison m_comparison; private object m_syncRoot = new object(); - + private uint m_nextQueue = 0; + private UInt64 m_nextRequest = 0; + internal PriorityQueue() : - this(MinHeap.DEFAULT_CAPACITY, Comparer.Default) { } - internal PriorityQueue(int capacity) : - this(capacity, Comparer.Default) { } - internal PriorityQueue(IComparer comparer) : - this(new Comparison(comparer.Compare)) { } - internal PriorityQueue(Comparison comparison) : - this(MinHeap.DEFAULT_CAPACITY, comparison) { } - internal PriorityQueue(int capacity, IComparer comparer) : - this(capacity, new Comparison(comparer.Compare)) { } - internal PriorityQueue(int capacity, Comparison comparison) + this(MinHeap.DEFAULT_CAPACITY) { } + internal PriorityQueue(int capacity) { m_lookupTable = new Dictionary(capacity); for (int i = 0; i < m_heaps.Length; ++i) m_heaps[i] = new MinHeap(capacity); - this.m_comparison = comparison; } public object SyncRoot { get { return this.m_syncRoot; } } + internal int Count { get { int count = 0; for (int i = 0; i < m_heaps.Length; ++i) - count = m_heaps[i].Count; + count += m_heaps[i].Count; return count; } } - public bool Enqueue(double priority, EntityUpdate value, uint local_id) + public bool Enqueue(uint pqueue, EntityUpdate value) { - LookupItem item; + LookupItem lookup; - if (m_lookupTable.TryGetValue(local_id, out item)) + uint localid = value.Entity.LocalId; + UInt64 entry = m_nextRequest++; + if (m_lookupTable.TryGetValue(localid, out lookup)) { - // Combine flags - value.Flags |= item.Heap[item.Handle].Value.Flags; - - item.Heap[item.Handle] = new MinHeapItem(priority, value, local_id, this.m_comparison); - return false; - } - else - { - item.Heap = m_heaps[0]; - item.Heap.Add(new MinHeapItem(priority, value, local_id, this.m_comparison), ref item.Handle); - m_lookupTable.Add(local_id, item); - return true; + entry = lookup.Heap[lookup.Handle].EntryOrder; + value.Flags |= lookup.Heap[lookup.Handle].Value.Flags; + lookup.Heap.Remove(lookup.Handle); } - } - internal EntityUpdate Peek() - { - for (int i = 0; i < m_heaps.Length; ++i) - if (m_heaps[i].Count > 0) - return m_heaps[i].Min().Value; - throw new InvalidOperationException(string.Format("The {0} is empty", this.GetType().ToString())); + pqueue = Util.Clamp(pqueue, 0, m_numberOfQueues - 1); + lookup.Heap = m_heaps[pqueue]; + lookup.Heap.Add(new MinHeapItem(pqueue, entry, value), ref lookup.Handle); + m_lookupTable[localid] = lookup; + + return true; } - internal bool TryDequeue(out EntityUpdate value) + internal bool TryDequeue(out EntityUpdate value, out Int32 timeinqueue) { - for (int i = 0; i < m_heaps.Length; ++i) + for (int i = 0; i < m_numberOfQueues; ++i) { - if (m_heaps[i].Count > 0) + // To get the fair queing, we cycle through each of the + // queues when finding an element to dequeue, this code + // assumes that the distribution of updates in the queues + // is polynomial, probably quadractic (eg distance of PI * R^2) + uint h = (uint)((m_nextQueue + i) % m_numberOfQueues); + if (m_heaps[h].Count > 0) { - MinHeapItem item = m_heaps[i].RemoveMin(); - m_lookupTable.Remove(item.LocalID); + m_nextQueue = (uint)((h + 1) % m_numberOfQueues); + + MinHeapItem item = m_heaps[h].RemoveMin(); + m_lookupTable.Remove(item.Value.Entity.LocalId); + timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); value = item.Value; + return true; } } + timeinqueue = 0; value = default(EntityUpdate); return false; } @@ -11816,68 +11894,107 @@ namespace OpenSim.Region.ClientStack.LindenUDP internal void Reprioritize(UpdatePriorityHandler handler) { MinHeapItem item; - double priority; - foreach (LookupItem lookup in new List(this.m_lookupTable.Values)) { if (lookup.Heap.TryGetValue(lookup.Handle, out item)) { - priority = item.Priority; - if (handler(ref priority, item.LocalID)) + uint pqueue = item.PriorityQueue; + uint localid = item.Value.Entity.LocalId; + + if (handler(ref pqueue, item.Value.Entity)) { - if (lookup.Heap.ContainsHandle(lookup.Handle)) - lookup.Heap[lookup.Handle] = - new MinHeapItem(priority, item.Value, item.LocalID, this.m_comparison); + // unless the priority queue has changed, there is no need to modify + // the entry + pqueue = Util.Clamp(pqueue, 0, m_numberOfQueues - 1); + if (pqueue != item.PriorityQueue) + { + lookup.Heap.Remove(lookup.Handle); + + LookupItem litem = lookup; + litem.Heap = m_heaps[pqueue]; + litem.Heap.Add(new MinHeapItem(pqueue, item), ref litem.Handle); + m_lookupTable[localid] = litem; + } } else { - m_log.Warn("[LLCLIENTVIEW]: UpdatePriorityHandler returned false, dropping update"); + m_log.WarnFormat("[LLCLIENTVIEW]: UpdatePriorityHandler returned false for {0}",item.Value.Entity.UUID); lookup.Heap.Remove(lookup.Handle); - this.m_lookupTable.Remove(item.LocalID); + this.m_lookupTable.Remove(localid); } } } } + public override string ToString() + { + string s = ""; + for (int i = 0; i < m_numberOfQueues; i++) + { + if (s != "") s += ","; + s += m_heaps[i].Count.ToString(); + } + return s; + } + #region MinHeapItem private struct MinHeapItem : IComparable { - private double priority; private EntityUpdate value; - private uint local_id; - private Comparison comparison; + internal EntityUpdate Value { + get { + return this.value; + } + } + + private uint pqueue; + internal uint PriorityQueue { + get { + return this.pqueue; + } + } - internal MinHeapItem(double priority, EntityUpdate value, uint local_id) : - this(priority, value, local_id, Comparer.Default) { } - internal MinHeapItem(double priority, EntityUpdate value, uint local_id, IComparer comparer) : - this(priority, value, local_id, new Comparison(comparer.Compare)) { } - internal MinHeapItem(double priority, EntityUpdate value, uint local_id, Comparison comparison) + private Int32 entrytime; + internal Int32 EntryTime { + get { + return this.entrytime; + } + } + + private UInt64 entryorder; + internal UInt64 EntryOrder { - this.priority = priority; + get { + return this.entryorder; + } + } + + internal MinHeapItem(uint pqueue, MinHeapItem other) + { + this.entrytime = other.entrytime; + this.entryorder = other.entryorder; + this.value = other.value; + this.pqueue = pqueue; + } + + internal MinHeapItem(uint pqueue, UInt64 entryorder, EntityUpdate value) + { + this.entrytime = Util.EnvironmentTickCount(); + this.entryorder = entryorder; this.value = value; - this.local_id = local_id; - this.comparison = comparison; + this.pqueue = pqueue; } - internal double Priority { get { return this.priority; } } - internal EntityUpdate Value { get { return this.value; } } - internal uint LocalID { get { return this.local_id; } } - public override string ToString() { - StringBuilder sb = new StringBuilder(); - sb.Append("["); - sb.Append(this.priority.ToString()); - sb.Append(","); - if (this.value != null) - sb.Append(this.value.ToString()); - sb.Append("]"); - return sb.ToString(); + return String.Format("[{0},{1},{2}]",pqueue,entryorder,value.Entity.LocalId); } public int CompareTo(MinHeapItem other) { - return this.comparison(this.priority, other.priority); + // I'm assuming that the root part of an SOG is added to the update queue + // before the component parts + return Comparer.Default.Compare(this.EntryOrder, other.EntryOrder); } } #endregion diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index f9599f5..2764b05 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Scenes public class Prioritizer { -// private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); /// /// This is added to the priority of all child prims, to make sure that the root prim update is sent to the @@ -76,7 +76,74 @@ namespace OpenSim.Region.Framework.Scenes m_scene = scene; } - public double GetUpdatePriority(IClientAPI client, ISceneEntity entity) +// + public uint GetUpdatePriority(IClientAPI client, ISceneEntity entity) + { + if (entity == null) + { + m_log.WarnFormat("[PRIORITIZER] attempt to prioritize null entity"); + throw new InvalidOperationException("Prioritization entity not defined"); + } + + // If this is an update for our own avatar give it the highest priority + if (client.AgentId == entity.UUID) + return 0; + + // Get this agent's position + ScenePresence presence = m_scene.GetScenePresence(client.AgentId); + if (presence == null) + { + m_log.WarnFormat("[PRIORITIZER] attempt to prioritize agent no longer in the scene"); + throw new InvalidOperationException("Prioritization agent not defined"); + } + + // Use group position for child prims + Vector3 entityPos = entity.AbsolutePosition; + if (entity is SceneObjectPart) + { + SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup; + if (group != null) + entityPos = group.AbsolutePosition; + } + + // Use the camera position for local agents and avatar position for remote agents + Vector3 presencePos = (presence.IsChildAgent) ? + presence.AbsolutePosition : + presence.CameraPosition; + + // Compute the distance... + double distance = Vector3.Distance(presencePos, entityPos); + + // And convert the distance to a priority queue, this computation gives queues + // at 10, 20, 40, 80, 160, 320, 640, and 1280m + uint pqueue = 1; + for (int i = 0; i < 8; i++) + { + if (distance < 10 * Math.Pow(2.0,i)) + break; + pqueue++; + } + + // If this is a root agent, then determine front & back + // Bump up the priority queue for any objects behind the avatar + if (! presence.IsChildAgent) + { + // Root agent, decrease priority for objects behind us + Vector3 camPosition = presence.CameraPosition; + Vector3 camAtAxis = presence.CameraAtAxis; + + // Plane equation + float d = -Vector3.Dot(camPosition, camAtAxis); + float p = Vector3.Dot(camAtAxis, entityPos) + d; + if (p < 0.0f) + pqueue++; + } + + return pqueue; + } +// + + public double bGetUpdatePriority(IClientAPI client, ISceneEntity entity) { double priority = 0; -- cgit v1.1 From 0bd06d8ba85595a1707d2093a08a901b950ca120 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 4 Apr 2011 13:19:45 -0700 Subject: Fixed the prioritizer functions for the new priority queues --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 292 +++++++------------------ 1 file changed, 82 insertions(+), 210 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 2764b05..a14bb70 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -60,15 +60,6 @@ namespace OpenSim.Region.Framework.Scenes { private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - /// - /// This is added to the priority of all child prims, to make sure that the root prim update is sent to the - /// viewer before child prim updates. - /// The adjustment is added to child prims and subtracted from root prims, so the gap ends up - /// being double. We do it both ways so that there is a still a priority delta even if the priority is already - /// double.MinValue or double.MaxValue. - /// - private double m_childPrimAdjustmentFactor = 0.05; - private Scene m_scene; public Prioritizer(Scene scene) @@ -76,9 +67,19 @@ namespace OpenSim.Region.Framework.Scenes m_scene = scene; } -// + /// + /// Returns the priority queue into which the update should be placed. Updates within a + /// queue will be processed in arrival order. There are currently 12 priority queues + /// implemented in PriorityQueue class in LLClientView. Queue 0 is generally retained + /// for avatar updates. The fair queuing discipline for processing the priority queues + /// assumes that the number of entities in each priority queues increases exponentially. + /// So for example... if queue 1 contains all updates within 10m of the avatar or camera + /// then queue 2 at 20m is about 3X bigger in space & about 3X bigger in total number + /// of updates. + /// public uint GetUpdatePriority(IClientAPI client, ISceneEntity entity) { + // If entity is null we have a serious problem if (entity == null) { m_log.WarnFormat("[PRIORITIZER] attempt to prioritize null entity"); @@ -89,71 +90,12 @@ namespace OpenSim.Region.Framework.Scenes if (client.AgentId == entity.UUID) return 0; - // Get this agent's position - ScenePresence presence = m_scene.GetScenePresence(client.AgentId); - if (presence == null) - { - m_log.WarnFormat("[PRIORITIZER] attempt to prioritize agent no longer in the scene"); - throw new InvalidOperationException("Prioritization agent not defined"); - } - - // Use group position for child prims - Vector3 entityPos = entity.AbsolutePosition; - if (entity is SceneObjectPart) - { - SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup; - if (group != null) - entityPos = group.AbsolutePosition; - } - - // Use the camera position for local agents and avatar position for remote agents - Vector3 presencePos = (presence.IsChildAgent) ? - presence.AbsolutePosition : - presence.CameraPosition; - - // Compute the distance... - double distance = Vector3.Distance(presencePos, entityPos); - - // And convert the distance to a priority queue, this computation gives queues - // at 10, 20, 40, 80, 160, 320, 640, and 1280m - uint pqueue = 1; - for (int i = 0; i < 8; i++) - { - if (distance < 10 * Math.Pow(2.0,i)) - break; - pqueue++; - } - - // If this is a root agent, then determine front & back - // Bump up the priority queue for any objects behind the avatar - if (! presence.IsChildAgent) - { - // Root agent, decrease priority for objects behind us - Vector3 camPosition = presence.CameraPosition; - Vector3 camAtAxis = presence.CameraAtAxis; - - // Plane equation - float d = -Vector3.Dot(camPosition, camAtAxis); - float p = Vector3.Dot(camAtAxis, entityPos) + d; - if (p < 0.0f) - pqueue++; - } - - return pqueue; - } -// - - public double bGetUpdatePriority(IClientAPI client, ISceneEntity entity) - { - double priority = 0; - - if (entity == null) - return 100000; + uint priority; switch (m_scene.UpdatePrioritizationScheme) { case UpdatePrioritizationSchemes.Time: - priority = GetPriorityByTime(); + priority = GetPriorityByTime(client, entity); break; case UpdatePrioritizationSchemes.Distance: priority = GetPriorityByDistance(client, entity); @@ -171,180 +113,110 @@ namespace OpenSim.Region.Framework.Scenes throw new InvalidOperationException("UpdatePrioritizationScheme not defined."); } - // Adjust priority so that root prims are sent to the viewer first. This is especially important for - // attachments acting as huds, since current viewers fail to display hud child prims if their updates - // arrive before the root one. - if (entity is SceneObjectPart) - { - SceneObjectPart sop = ((SceneObjectPart)entity); - - if (sop.IsRoot) - { - if (priority >= double.MinValue + m_childPrimAdjustmentFactor) - priority -= m_childPrimAdjustmentFactor; - } - else - { - if (priority <= double.MaxValue - m_childPrimAdjustmentFactor) - priority += m_childPrimAdjustmentFactor; - } - } - return priority; } - private double GetPriorityByTime() + + private uint GetPriorityByTime(IClientAPI client, ISceneEntity entity) { - return DateTime.UtcNow.ToOADate(); + return 1; } - private double GetPriorityByDistance(IClientAPI client, ISceneEntity entity) + private uint GetPriorityByDistance(IClientAPI client, ISceneEntity entity) { - ScenePresence presence = m_scene.GetScenePresence(client.AgentId); - if (presence != null) - { - // If this is an update for our own avatar give it the highest priority - if (presence == entity) - return 0.0; - - // Use the camera position for local agents and avatar position for remote agents - Vector3 presencePos = (presence.IsChildAgent) ? - presence.AbsolutePosition : - presence.CameraPosition; - - // Use group position for child prims - Vector3 entityPos; - if (entity is SceneObjectPart) - { - // Can't use Scene.GetGroupByPrim() here, since the entity may have been delete from the scene - // before its scheduled update was triggered - //entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition; - entityPos = ((SceneObjectPart)entity).ParentGroup.AbsolutePosition; - } - else - { - entityPos = entity.AbsolutePosition; - } - - return Vector3.DistanceSquared(presencePos, entityPos); - } - - return double.NaN; + return ComputeDistancePriority(client,entity,false); + } + + private uint GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity) + { + return ComputeDistancePriority(client,entity,true); } - private double GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity) + private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) { + uint pqueue = ComputeDistancePriority(client,entity,true); + ScenePresence presence = m_scene.GetScenePresence(client.AgentId); if (presence != null) { - // If this is an update for our own avatar give it the highest priority - if (presence == entity) - return 0.0; - - // Use group position for child prims - Vector3 entityPos = entity.AbsolutePosition; - if (entity is SceneObjectPart) - { - // Can't use Scene.GetGroupByPrim() here, since the entity may have been delete from the scene - // before its scheduled update was triggered - //entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition; - entityPos = ((SceneObjectPart)entity).ParentGroup.AbsolutePosition; - } - else - { - entityPos = entity.AbsolutePosition; - } - if (!presence.IsChildAgent) { - // Root agent. Use distance from camera and a priority decrease for objects behind us - Vector3 camPosition = presence.CameraPosition; - Vector3 camAtAxis = presence.CameraAtAxis; - - // Distance - double priority = Vector3.DistanceSquared(camPosition, entityPos); - - // Plane equation - float d = -Vector3.Dot(camPosition, camAtAxis); - float p = Vector3.Dot(camAtAxis, entityPos) + d; - if (p < 0.0f) priority *= 2.0; - - return priority; - } - else - { - // Child agent. Use the normal distance method - Vector3 presencePos = presence.AbsolutePosition; + if (entity is SceneObjectPart) + { + // Non physical prims are lower priority than physical prims + PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; + if (physActor == null || !physActor.IsPhysical) + pqueue++; - return Vector3.DistanceSquared(presencePos, entityPos); + // Attachments are high priority, + // MIC: shouldn't these already be in the highest priority queue already + // since their root position is same as the avatars? + if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) + pqueue = 1; + } } } - return double.NaN; + return pqueue; } - private double GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) + private uint ComputeDistancePriority(IClientAPI client, ISceneEntity entity, bool useFrontBack) { - // If this is an update for our own avatar give it the highest priority - if (client.AgentId == entity.UUID) - return 0.0; - if (entity == null) - return double.NaN; - - // Use group position for child prims + // Get this agent's position + ScenePresence presence = m_scene.GetScenePresence(client.AgentId); + if (presence == null) + { + m_log.WarnFormat("[PRIORITIZER] attempt to prioritize agent no longer in the scene"); + throw new InvalidOperationException("Prioritization agent not defined"); + } + + // Use group position for child prims, since we are putting child prims in + // the same queue with the root of the group, the root prim (which goes into + // the queue first) should always be sent first, no need to adjust child prim + // priorities Vector3 entityPos = entity.AbsolutePosition; if (entity is SceneObjectPart) { SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup; if (group != null) entityPos = group.AbsolutePosition; - else - entityPos = entity.AbsolutePosition; } - else - entityPos = entity.AbsolutePosition; - - ScenePresence presence = m_scene.GetScenePresence(client.AgentId); - if (presence != null) - { - if (!presence.IsChildAgent) - { - if (entity is ScenePresence) - return 1.0; - // Root agent. Use distance from camera and a priority decrease for objects behind us - Vector3 camPosition = presence.CameraPosition; - Vector3 camAtAxis = presence.CameraAtAxis; - - // Distance - double priority = Vector3.DistanceSquared(camPosition, entityPos); - - // Plane equation - float d = -Vector3.Dot(camPosition, camAtAxis); - float p = Vector3.Dot(camAtAxis, entityPos) + d; - if (p < 0.0f) priority *= 2.0; + // Use the camera position for local agents and avatar position for remote agents + Vector3 presencePos = (presence.IsChildAgent) ? + presence.AbsolutePosition : + presence.CameraPosition; - if (entity is SceneObjectPart) - { - PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; - if (physActor == null || !physActor.IsPhysical) - priority += 100; + // Compute the distance... + double distance = Vector3.Distance(presencePos, entityPos); - if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) - priority = 1.0; - } - return priority; - } - else - { - // Child agent. Use the normal distance method - Vector3 presencePos = presence.AbsolutePosition; + // And convert the distance to a priority queue, this computation gives queues + // at 10, 20, 40, 80, 160, 320, 640, and 1280m + uint pqueue = 1; + for (int i = 0; i < 8; i++) + { + if (distance < 10 * Math.Pow(2.0,i)) + break; + pqueue++; + } + + // If this is a root agent, then determine front & back + // Bump up the priority queue (drop the priority) for any objects behind the avatar + if (useFrontBack && ! presence.IsChildAgent) + { + // Root agent, decrease priority for objects behind us + Vector3 camPosition = presence.CameraPosition; + Vector3 camAtAxis = presence.CameraAtAxis; - return Vector3.DistanceSquared(presencePos, entityPos); - } + // Plane equation + float d = -Vector3.Dot(camPosition, camAtAxis); + float p = Vector3.Dot(camAtAxis, entityPos) + d; + if (p < 0.0f) + pqueue++; } - return double.NaN; + return pqueue; } + } } -- cgit v1.1 From 83dc2470f2e815f6f9d469104be3a2806438a29a Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 4 Apr 2011 14:18:26 -0700 Subject: Fix a bug in the computation of the RTO. Basically... the RTO (the time to wait to retransmit packets) always maxed out (no retransmissions for 24 or 48 seconds. Note that this is going to cause faster (and more) retransmissions. Fix for dynamic throttling needs to go with this. --- OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') 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 /// Caches packed throttle information private byte[] m_packedThrottles; - private int m_defaultRTO = 3000; + private int m_defaultRTO = 1000; // 1sec is the recommendation in the RFC private int m_maxRTO = 60000; /// @@ -557,7 +557,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR)); // Clamp the retransmission timeout to manageable values - rto = Utils.Clamp(RTO, m_defaultRTO, m_maxRTO); + rto = Utils.Clamp(rto, m_defaultRTO, m_maxRTO); RTO = rto; -- cgit v1.1 From 19c6d1d569e081418e139d139c15ea66640288ba Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Wed, 6 Apr 2011 09:26:38 -0700 Subject: Split the priority queue class into a seperate file. LLClientView is big enough. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 205 ----------------- .../Region/ClientStack/LindenUDP/PriorityQueue.cs | 245 +++++++++++++++++++++ 2 files changed, 245 insertions(+), 205 deletions(-) create mode 100644 OpenSim/Region/ClientStack/LindenUDP/PriorityQueue.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index a3f2c15..a724099 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -11805,209 +11805,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(pack, ThrottleOutPacketType.Task); } - #region PriorityQueue - public class PriorityQueue - { - internal delegate bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity); - - // Heap[0] for self updates - // Heap[1..12] for entity updates - - internal const uint m_numberOfQueues = 12; - private MinHeap[] m_heaps = new MinHeap[m_numberOfQueues]; - private Dictionary m_lookupTable; - private object m_syncRoot = new object(); - private uint m_nextQueue = 0; - private UInt64 m_nextRequest = 0; - - internal PriorityQueue() : - this(MinHeap.DEFAULT_CAPACITY) { } - internal PriorityQueue(int capacity) - { - m_lookupTable = new Dictionary(capacity); - - for (int i = 0; i < m_heaps.Length; ++i) - m_heaps[i] = new MinHeap(capacity); - } - - public object SyncRoot { get { return this.m_syncRoot; } } - - internal int Count - { - get - { - int count = 0; - for (int i = 0; i < m_heaps.Length; ++i) - count += m_heaps[i].Count; - return count; - } - } - - public bool Enqueue(uint pqueue, EntityUpdate value) - { - LookupItem lookup; - - uint localid = value.Entity.LocalId; - UInt64 entry = m_nextRequest++; - if (m_lookupTable.TryGetValue(localid, out lookup)) - { - entry = lookup.Heap[lookup.Handle].EntryOrder; - value.Flags |= lookup.Heap[lookup.Handle].Value.Flags; - lookup.Heap.Remove(lookup.Handle); - } - - pqueue = Util.Clamp(pqueue, 0, m_numberOfQueues - 1); - lookup.Heap = m_heaps[pqueue]; - lookup.Heap.Add(new MinHeapItem(pqueue, entry, value), ref lookup.Handle); - m_lookupTable[localid] = lookup; - - return true; - } - - internal bool TryDequeue(out EntityUpdate value, out Int32 timeinqueue) - { - for (int i = 0; i < m_numberOfQueues; ++i) - { - // To get the fair queing, we cycle through each of the - // queues when finding an element to dequeue, this code - // assumes that the distribution of updates in the queues - // is polynomial, probably quadractic (eg distance of PI * R^2) - uint h = (uint)((m_nextQueue + i) % m_numberOfQueues); - if (m_heaps[h].Count > 0) - { - m_nextQueue = (uint)((h + 1) % m_numberOfQueues); - - MinHeapItem item = m_heaps[h].RemoveMin(); - m_lookupTable.Remove(item.Value.Entity.LocalId); - timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); - value = item.Value; - - return true; - } - } - - timeinqueue = 0; - value = default(EntityUpdate); - return false; - } - - internal void Reprioritize(UpdatePriorityHandler handler) - { - MinHeapItem item; - foreach (LookupItem lookup in new List(this.m_lookupTable.Values)) - { - if (lookup.Heap.TryGetValue(lookup.Handle, out item)) - { - uint pqueue = item.PriorityQueue; - uint localid = item.Value.Entity.LocalId; - - if (handler(ref pqueue, item.Value.Entity)) - { - // unless the priority queue has changed, there is no need to modify - // the entry - pqueue = Util.Clamp(pqueue, 0, m_numberOfQueues - 1); - if (pqueue != item.PriorityQueue) - { - lookup.Heap.Remove(lookup.Handle); - - LookupItem litem = lookup; - litem.Heap = m_heaps[pqueue]; - litem.Heap.Add(new MinHeapItem(pqueue, item), ref litem.Handle); - m_lookupTable[localid] = litem; - } - } - else - { - m_log.WarnFormat("[LLCLIENTVIEW]: UpdatePriorityHandler returned false for {0}",item.Value.Entity.UUID); - lookup.Heap.Remove(lookup.Handle); - this.m_lookupTable.Remove(localid); - } - } - } - } - - public override string ToString() - { - string s = ""; - for (int i = 0; i < m_numberOfQueues; i++) - { - if (s != "") s += ","; - s += m_heaps[i].Count.ToString(); - } - return s; - } - - #region MinHeapItem - private struct MinHeapItem : IComparable - { - private EntityUpdate value; - internal EntityUpdate Value { - get { - return this.value; - } - } - - private uint pqueue; - internal uint PriorityQueue { - get { - return this.pqueue; - } - } - - private Int32 entrytime; - internal Int32 EntryTime { - get { - return this.entrytime; - } - } - - private UInt64 entryorder; - internal UInt64 EntryOrder - { - get { - return this.entryorder; - } - } - - internal MinHeapItem(uint pqueue, MinHeapItem other) - { - this.entrytime = other.entrytime; - this.entryorder = other.entryorder; - this.value = other.value; - this.pqueue = pqueue; - } - - internal MinHeapItem(uint pqueue, UInt64 entryorder, EntityUpdate value) - { - this.entrytime = Util.EnvironmentTickCount(); - this.entryorder = entryorder; - this.value = value; - this.pqueue = pqueue; - } - - public override string ToString() - { - return String.Format("[{0},{1},{2}]",pqueue,entryorder,value.Entity.LocalId); - } - - public int CompareTo(MinHeapItem other) - { - // I'm assuming that the root part of an SOG is added to the update queue - // before the component parts - return Comparer.Default.Compare(this.EntryOrder, other.EntryOrder); - } - } - #endregion - - #region LookupItem - private struct LookupItem - { - internal MinHeap Heap; - internal IHandle Handle; - } - #endregion - } - public struct PacketProcessor { public PacketMethod method; @@ -12028,8 +11825,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - #endregion - public static OSD BuildEvent(string eventName, OSD eventBody) { OSDMap osdEvent = new OSDMap(2); 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 @@ +/* + * 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; +using System.Collections.Generic; +using System.Reflection; + +using OpenSim.Framework; +using OpenSim.Framework.Client; +using log4net; + +namespace OpenSim.Region.ClientStack.LindenUDP +{ + public class PriorityQueue + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + internal delegate bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity); + + // Heap[0] for self updates + // Heap[1..12] for entity updates + + internal const uint m_numberOfQueues = 12; + + private MinHeap[] m_heaps = new MinHeap[m_numberOfQueues]; + private Dictionary m_lookupTable; + private uint m_nextQueue = 0; + private UInt64 m_nextRequest = 0; + + private object m_syncRoot = new object(); + public object SyncRoot { + get { return this.m_syncRoot; } + } + + internal PriorityQueue() : this(MinHeap.DEFAULT_CAPACITY) { } + + internal PriorityQueue(int capacity) + { + m_lookupTable = new Dictionary(capacity); + + for (int i = 0; i < m_heaps.Length; ++i) + m_heaps[i] = new MinHeap(capacity); + } + + internal int Count + { + get + { + int count = 0; + for (int i = 0; i < m_heaps.Length; ++i) + count += m_heaps[i].Count; + return count; + } + } + + public bool Enqueue(uint pqueue, EntityUpdate value) + { + LookupItem lookup; + + uint localid = value.Entity.LocalId; + UInt64 entry = m_nextRequest++; + if (m_lookupTable.TryGetValue(localid, out lookup)) + { + entry = lookup.Heap[lookup.Handle].EntryOrder; + value.Flags |= lookup.Heap[lookup.Handle].Value.Flags; + lookup.Heap.Remove(lookup.Handle); + } + + pqueue = Util.Clamp(pqueue, 0, m_numberOfQueues - 1); + lookup.Heap = m_heaps[pqueue]; + lookup.Heap.Add(new MinHeapItem(pqueue, entry, value), ref lookup.Handle); + m_lookupTable[localid] = lookup; + + return true; + } + + internal bool TryDequeue(out EntityUpdate value, out Int32 timeinqueue) + { + for (int i = 0; i < m_numberOfQueues; ++i) + { + // To get the fair queing, we cycle through each of the + // queues when finding an element to dequeue, this code + // assumes that the distribution of updates in the queues + // is polynomial, probably quadractic (eg distance of PI * R^2) + uint h = (uint)((m_nextQueue + i) % m_numberOfQueues); + if (m_heaps[h].Count > 0) + { + m_nextQueue = (uint)((h + 1) % m_numberOfQueues); + + MinHeapItem item = m_heaps[h].RemoveMin(); + m_lookupTable.Remove(item.Value.Entity.LocalId); + timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); + value = item.Value; + + return true; + } + } + + timeinqueue = 0; + value = default(EntityUpdate); + return false; + } + + internal void Reprioritize(UpdatePriorityHandler handler) + { + MinHeapItem item; + foreach (LookupItem lookup in new List(this.m_lookupTable.Values)) + { + if (lookup.Heap.TryGetValue(lookup.Handle, out item)) + { + uint pqueue = item.PriorityQueue; + uint localid = item.Value.Entity.LocalId; + + if (handler(ref pqueue, item.Value.Entity)) + { + // unless the priority queue has changed, there is no need to modify + // the entry + pqueue = Util.Clamp(pqueue, 0, m_numberOfQueues - 1); + if (pqueue != item.PriorityQueue) + { + lookup.Heap.Remove(lookup.Handle); + + LookupItem litem = lookup; + litem.Heap = m_heaps[pqueue]; + litem.Heap.Add(new MinHeapItem(pqueue, item), ref litem.Handle); + m_lookupTable[localid] = litem; + } + } + else + { + // m_log.WarnFormat("[PQUEUE]: UpdatePriorityHandler returned false for {0}",item.Value.Entity.UUID); + lookup.Heap.Remove(lookup.Handle); + this.m_lookupTable.Remove(localid); + } + } + } + } + + public override string ToString() + { + string s = ""; + for (int i = 0; i < m_numberOfQueues; i++) + { + if (s != "") s += ","; + s += m_heaps[i].Count.ToString(); + } + return s; + } + +#region MinHeapItem + private struct MinHeapItem : IComparable + { + private EntityUpdate value; + internal EntityUpdate Value { + get { + return this.value; + } + } + + private uint pqueue; + internal uint PriorityQueue { + get { + return this.pqueue; + } + } + + private Int32 entrytime; + internal Int32 EntryTime { + get { + return this.entrytime; + } + } + + private UInt64 entryorder; + internal UInt64 EntryOrder + { + get { + return this.entryorder; + } + } + + internal MinHeapItem(uint pqueue, MinHeapItem other) + { + this.entrytime = other.entrytime; + this.entryorder = other.entryorder; + this.value = other.value; + this.pqueue = pqueue; + } + + internal MinHeapItem(uint pqueue, UInt64 entryorder, EntityUpdate value) + { + this.entrytime = Util.EnvironmentTickCount(); + this.entryorder = entryorder; + this.value = value; + this.pqueue = pqueue; + } + + public override string ToString() + { + return String.Format("[{0},{1},{2}]",pqueue,entryorder,value.Entity.LocalId); + } + + public int CompareTo(MinHeapItem other) + { + // I'm assuming that the root part of an SOG is added to the update queue + // before the component parts + return Comparer.Default.Compare(this.EntryOrder, other.EntryOrder); + } + } +#endregion + +#region LookupItem + private struct LookupItem + { + internal MinHeap Heap; + internal IHandle Handle; + } +#endregion + } +} -- cgit v1.1 From ebc249e3bef57aee656936f5e63842d83ee29fff Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Sun, 10 Apr 2011 17:02:40 -0700 Subject: Changed the "not in scene" check in the prioritizier to just a warning. There appears to be a race condition on slow logins that attempts to prioritize before the scene presence is fully initialized. --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index a14bb70..4694e2b 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -166,8 +166,9 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence presence = m_scene.GetScenePresence(client.AgentId); if (presence == null) { - m_log.WarnFormat("[PRIORITIZER] attempt to prioritize agent no longer in the scene"); - throw new InvalidOperationException("Prioritization agent not defined"); + m_log.WarnFormat("[PRIORITIZER] attempt to use agent {0} not in the scene",client.AgentId); + // throw new InvalidOperationException("Prioritization agent not defined"); + return Int32.MaxValue; } // Use group position for child prims, since we are putting child prims in -- cgit v1.1 From f778056c7a81443b11c0c4288979af3a8c6b5b9f Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 11 Apr 2011 08:37:43 -0700 Subject: Removed some priority queue debugging code --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 80 ---------------------- 1 file changed, 80 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index a724099..b5bf26d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -300,77 +300,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Used to adjust Sun Orbit values so Linden based viewers properly position sun private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f; - // First log file or time has expired, start writing to a new log file -// -// ----------------------------------------------------------------- -// ----------------------------------------------------------------- -// THIS IS DEBUGGING CODE & SHOULD BE REMOVED -// ----------------------------------------------------------------- -// ----------------------------------------------------------------- - public class QueueLogger - { - public Int32 start = 0; - public StreamWriter Log = null; - private Dictionary m_idMap = new Dictionary(); - - public QueueLogger() - { - DateTime now = DateTime.Now; - String fname = String.Format("queue-{0}.log", now.ToString("yyyyMMddHHmmss")); - Log = new StreamWriter(fname); - - start = Util.EnvironmentTickCount(); - } - - public int LookupID(UUID uuid) - { - int localid; - if (! m_idMap.TryGetValue(uuid,out localid)) - { - localid = m_idMap.Count + 1; - m_idMap[uuid] = localid; - } - - return localid; - } - } - - public static QueueLogger QueueLog = null; - - // ----------------------------------------------------------------- - public void LogAvatarUpdateEvent(UUID client, UUID avatar, Int32 timeinqueue) - { - if (QueueLog == null) - QueueLog = new QueueLogger(); - - Int32 ticks = Util.EnvironmentTickCountSubtract(QueueLog.start); - lock(QueueLog) - { - int cid = QueueLog.LookupID(client); - int aid = QueueLog.LookupID(avatar); - QueueLog.Log.WriteLine("{0},AU,AV{1:D4},AV{2:D4},{3}",ticks,cid,aid,timeinqueue); - } - } - - // ----------------------------------------------------------------- - public void LogQueueProcessEvent(UUID client, PriorityQueue queue, uint maxup) - { - if (QueueLog == null) - QueueLog = new QueueLogger(); - - Int32 ticks = Util.EnvironmentTickCountSubtract(QueueLog.start); - lock(QueueLog) - { - int cid = QueueLog.LookupID(client); - QueueLog.Log.WriteLine("{0},PQ,AV{1:D4},{2},{3}",ticks,cid,maxup,queue.ToString()); - } - } -// ----------------------------------------------------------------- -// ----------------------------------------------------------------- -// ----------------------------------------------------------------- -// ----------------------------------------------------------------- -// - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected static Dictionary PacketHandlers = new Dictionary(); //Global/static handlers for all clients @@ -3667,10 +3596,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP int updatesThisCall = 0; -// -// DEBUGGING CODE... REMOVE -// LogQueueProcessEvent(this.m_agentId,m_entityUpdates,m_maxUpdates); -// // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race // condition where a kill can be processed before an out-of-date update for the same object. lock (m_killRecord) @@ -3687,11 +3612,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP avgTimeDilation += update.TimeDilation; avgTimeDilation *= 0.5f; -// -// DEBUGGING CODE... REMOVE -// if (update.Entity is ScenePresence) -// LogAvatarUpdateEvent(this.m_agentId,update.Entity.UUID,timeinqueue); -// if (update.Entity is SceneObjectPart) { -- cgit v1.1 From d6948b15c47fd067be6d7cef31caf8e49e9c9afa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 11 Apr 2011 21:51:17 +0100 Subject: Make it more obvious when it happens that DLL plugin loading fails. Improve exception output on Windows. --- OpenSim/Region/Framework/ModuleLoader.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim') 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 catch (Exception e) { m_log.ErrorFormat( - "[MODULES]: Could not load types for [{0}]. Exception {1}", pluginAssembly.FullName, e); + "[MODULES]: Could not load types for plugin DLL {0}. Exception {1} {2}", + pluginAssembly.FullName, e.Message, e.StackTrace); // justincc: Right now this is fatal to really get the user's attention throw e; -- cgit v1.1 From 0bd6bc8fba1ed35344218e2aa25e30a3294f2ed1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 11 Apr 2011 21:59:26 +0100 Subject: create "config show" as a region console command synonym for "config get". This is to create greater consistency with all the other show commands. --- OpenSim/Region/Application/OpenSim.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index ec1fb04..39004d4 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -341,10 +341,15 @@ namespace OpenSim m_console.Commands.AddCommand("region", false, "config get", "config get [
] []", - "Show a config option", + "Synonym for config show", + HandleConfig); + + m_console.Commands.AddCommand("region", false, "config show", + "config show [
] []", + "Show config information", "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine + "If a section is given but not a field, then all fields in that section are printed.", - HandleConfig); + HandleConfig); m_console.Commands.AddCommand("region", false, "config save", "config save ", @@ -593,7 +598,9 @@ namespace OpenSim if (cmdparams.Length > 0) { - switch (cmdparams[0].ToLower()) + string firstParam = cmdparams[0].ToLower(); + + switch (firstParam) { case "set": if (cmdparams.Length < 4) @@ -618,6 +625,7 @@ namespace OpenSim break; case "get": + case "show": if (cmdparams.Length == 1) { foreach (IConfig config in m_config.Source.Configs) @@ -654,8 +662,8 @@ namespace OpenSim } else { - Notice("Syntax: config get [
] []"); - Notice("Example: config get ScriptEngine.DotNetEngine NumberOfScriptThreads"); + Notice("Syntax: config {0} [
] []", firstParam); + Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam); } break; -- cgit v1.1 From 464fa45ec90767af13bd8edcc7c67de4ec3db6a7 Mon Sep 17 00:00:00 2001 From: E. Allen Soard Date: Fri, 8 Apr 2011 18:30:20 -0700 Subject: Implimented HTTP_VERIFY_CERT for llHttpRequest --- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 34 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index d78931a..a37c781 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -29,8 +29,10 @@ using System; using System.Collections.Generic; using System.IO; using System.Net; +using System.Net.Security; using System.Text; using System.Threading; +using System.Security.Cryptography.X509Certificates; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; @@ -84,6 +86,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Scripting.HttpRequest { + public class HttpRequestModule : IRegionModule, IHttpRequestModule { private object HttpListLock = new object(); @@ -100,8 +103,23 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest public HttpRequestModule() { + ServicePointManager.ServerCertificateValidationCallback +=ValidateServerCertificate; } + public static bool ValidateServerCertificate( + object sender, + X509Certificate certificate, + X509Chain chain, + SslPolicyErrors sslPolicyErrors) + { + HttpWebRequest Request = (HttpWebRequest)sender; + + if(Request.Headers.Get("NoVerifyCert") != null) + { + return true; + } + return chain.Build(new X509Certificate2(certificate)); + } #region IHttpRequestModule Members public UUID MakeHttpRequest(string url, string parameters, string body) @@ -141,8 +159,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest break; case (int)HttpRequestConstants.HTTP_VERIFY_CERT: - - // TODO implement me + htc.HttpVerifyCert = (int.Parse(parms[i + 1]) != 0); break; } } @@ -282,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest public string HttpMethod = "GET"; public string HttpMIMEType = "text/plain;charset=utf-8"; public int HttpTimeout; - // public bool HttpVerifyCert = true; // not implemented + public bool HttpVerifyCert = true; // not implemented private Thread httpThread; // Request info @@ -344,6 +361,17 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest Request.Method = HttpMethod; Request.ContentType = HttpMIMEType; + if(!HttpVerifyCert) + { + // Connection Group Name is probably not used so we hijack it to identify + // a desired security exception +// Request.ConnectionGroupName="NoVerify"; + Request.Headers.Add("NoVerifyCert" , "true"); + } +// else +// { +// Request.ConnectionGroupName="Verify"; +// } if (proxyurl != null && proxyurl.Length > 0) { if (proxyexcepts != null && proxyexcepts.Length > 0) -- cgit v1.1 From 3a98fb080a751d21999bb2baa769462426b5d776 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 11 Apr 2011 22:29:08 +0100 Subject: minor: adjust some spacing and indentation --- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index a37c781..23e15ef 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -86,7 +86,6 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Scripting.HttpRequest { - public class HttpRequestModule : IRegionModule, IHttpRequestModule { private object HttpListLock = new object(); @@ -114,10 +113,11 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest { HttpWebRequest Request = (HttpWebRequest)sender; - if(Request.Headers.Get("NoVerifyCert") != null) + if (Request.Headers.Get("NoVerifyCert") != null) { return true; } + return chain.Build(new X509Certificate2(certificate)); } #region IHttpRequestModule Members @@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest * Not sure how important ordering is is here - the next first * one completed in the list is returned, based soley on its list * position, not the order in which the request was started or - * finsihed. I thought about setting up a queue for this, but + * finished. I thought about setting up a queue for this, but * it will need some refactoring and this works 'enough' right now */ @@ -254,8 +254,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest m_scene.RegisterModuleInterface(this); - m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); - m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); + m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); + m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); m_pendingRequests = new Dictionary(); } @@ -363,10 +363,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest if(!HttpVerifyCert) { - // Connection Group Name is probably not used so we hijack it to identify - // a desired security exception -// Request.ConnectionGroupName="NoVerify"; - Request.Headers.Add("NoVerifyCert" , "true"); + // We could hijack Connection Group Name to identify + // a desired security exception. But at the moment we'll use a dummy header instead. +// Request.ConnectionGroupName = "NoVerify"; + Request.Headers.Add("NoVerifyCert", "true"); } // else // { @@ -464,4 +464,4 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest } } } -} +} \ No newline at end of file -- cgit v1.1 From e8ecb2898c55bb97d47e9b1efb7dac98d40609cd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 11 Apr 2011 22:33:24 +0100 Subject: minor: remove some mono compiler warnings --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c16a985..aa28fa0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10289,12 +10289,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { UUID rq = UUID.Random(); - UUID tid = AsyncCommands. - DataserverPlugin.RegisterRequest(m_localID, - m_itemID, rq.ToString()); + AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); - AsyncCommands. - DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); + AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); return rq.ToString(); } @@ -10308,12 +10305,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { UUID rq = UUID.Random(); - UUID tid = AsyncCommands. - DataserverPlugin.RegisterRequest(m_localID, - m_itemID, rq.ToString()); + AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); - AsyncCommands. - DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); + AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); return rq.ToString(); } -- cgit v1.1 From 64dc7e9f141fd0f168ed90c11f932a8bdb077dc7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 11 Apr 2011 22:35:07 +0100 Subject: minor: remove now inaccurate comment --- OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 23e15ef..4c8424d 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -299,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest public string HttpMethod = "GET"; public string HttpMIMEType = "text/plain;charset=utf-8"; public int HttpTimeout; - public bool HttpVerifyCert = true; // not implemented + public bool HttpVerifyCert = true; private Thread httpThread; // Request info -- cgit v1.1 From 49d80f5711e1bc1afb6c650038619ade6d9a9e97 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 11 Apr 2011 23:07:56 +0100 Subject: Include code to return more information about the NullReferenceException seen in http://opensimulator.org/mantis/view.php?id=5403 prior to doing something about it. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 8efe4e9..50b6dbe 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -39,6 +39,8 @@ namespace OpenSim.Data.MySQL { public class MySQLGenericTableHandler : MySqlFramework where T: class, new() { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + protected Dictionary m_Fields = new Dictionary(); @@ -217,7 +219,6 @@ namespace OpenSim.Data.MySQL { using (MySqlCommand cmd = new MySqlCommand()) { - string query = ""; List names = new List(); List values = new List(); @@ -226,6 +227,16 @@ namespace OpenSim.Data.MySQL { names.Add(fi.Name); values.Add("?" + fi.Name); + + // Temporarily return more information about what field is unexpectedly null for + // http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the + // InventoryTransferModule or we may be required to substitute a DBNull here. + if (fi.GetValue(row) == null) + throw new NullReferenceException( + string.Format( + "[MYSQL GENERIC TABLE HANDLER]: Trying to store field {0} for {1} which is unexpectedly null", + fi.Name, row)); + cmd.Parameters.AddWithValue(fi.Name, fi.GetValue(row).ToString()); } @@ -268,4 +279,4 @@ namespace OpenSim.Data.MySQL } } } -} +} \ No newline at end of file -- cgit v1.1 From 621d5b58e1a9bc24aab384a5e9bd6eb881928505 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 11 Apr 2011 23:56:04 +0100 Subject: minor: add a bit more method doc to IInventoryService.GetItem() --- OpenSim/Services/Interfaces/IInventoryService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs index d19faed..a8bfe47 100644 --- a/OpenSim/Services/Interfaces/IInventoryService.cs +++ b/OpenSim/Services/Interfaces/IInventoryService.cs @@ -169,7 +169,7 @@ namespace OpenSim.Services.Interfaces /// Get an item, given by its UUID ///
/// - /// + /// null if no item was found, otherwise the found item InventoryItemBase GetItem(InventoryItemBase item); /// -- cgit v1.1 From 98d7de22dc44ca1e5971301c02a6a1fe49620889 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 12 Apr 2011 18:31:41 +0100 Subject: Fix (add) ability to rez objects by dragging them out of another prim's inventory. This should happen if the client supplies a task ID with the RezObject call. The rez goes through the same code as llRezObject(), so the same perms are applied. Rotation isn't yet preserved, this should be fixed shortly. --- .../InventoryAccess/InventoryAccessModule.cs | 4 ++ OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 59 ++++++++++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 9fbfc34..cdee53c 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -552,8 +552,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess /// /// Rez an object into the scene from the user's inventory /// + /// /// FIXME: It would be really nice if inventory access modules didn't also actually do the work of rezzing /// things to the scene. The caller should be doing that, I think. + /// /// /// /// @@ -570,6 +572,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) { +// m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); + // Work out position details byte bRayEndIsIntersection = (byte)0; diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 73dd531..4370850 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1955,11 +1955,60 @@ namespace OpenSim.Region.Framework.Scenes UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, bool RezSelected, bool RemoveItem, UUID fromTaskID) { - IInventoryAccessModule invAccess = RequestModuleInterface(); - if (invAccess != null) - invAccess.RezObject( - remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, - RezSelected, RemoveItem, fromTaskID, false); +// m_log.DebugFormat( +// "[PRIM INVENTORY]: RezObject from {0} for item {1} from task id {2}", +// remoteClient.Name, itemID, fromTaskID); + + if (fromTaskID == UUID.Zero) + { + IInventoryAccessModule invAccess = RequestModuleInterface(); + if (invAccess != null) + invAccess.RezObject( + remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, + RezSelected, RemoveItem, fromTaskID, false); + } + else + { + SceneObjectPart part = GetSceneObjectPart(fromTaskID); + if (part == null) + { + m_log.ErrorFormat( + "[TASK INVENTORY]: {0} tried to rez item id {1} from object id {2} but there is no such scene object", + remoteClient.Name, itemID, fromTaskID); + + return; + } + + TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID); + if (item == null) + { + m_log.ErrorFormat( + "[TASK INVENTORY]: {0} tried to rez item id {1} from object id {2} but there is no such item", + remoteClient.Name, itemID, fromTaskID); + + return; + } + + // Work out position details + byte bRayEndIsIntersection = (byte)0; + + if (RayEndIsIntersection) + { + bRayEndIsIntersection = (byte)1; + } + else + { + bRayEndIsIntersection = (byte)0; + } + + Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); + Vector3 pos + = GetNewRezLocation( + RayStart, RayEnd, RayTargetID, Quaternion.Identity, + BypassRayCast, bRayEndIsIntersection, true, scale, false); + + RezObject(part, item, pos, Quaternion.Identity, Vector3.Zero, 0); + } } /// -- cgit v1.1 From 3ba5eeb6c3b7c6381ca1e0ed87bce44049f96e37 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 12 Apr 2011 22:15:40 +0100 Subject: Allow a null rotation to be passed in to RezObject so that we can control whether to use the serialized rotation or not. Not used yet. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 4370850..87b4cb8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2016,14 +2016,14 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - /// - /// - /// + /// The position of the rezzed object. + /// The rotation of the rezzed object. If null, then the rotation stored with the object + /// will be used if it exists. + /// The velocity of the rezzed object. /// /// The SceneObjectGroup rezzed or null if rez was unsuccessful public virtual SceneObjectGroup RezObject( - SceneObjectPart sourcePart, TaskInventoryItem item, - Vector3 pos, Quaternion rot, Vector3 vel, int param) + SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion? rot, Vector3 vel, int param) { if (null == item) return null; @@ -2041,8 +2041,14 @@ namespace OpenSim.Region.Framework.Scenes if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) sourcePart.Inventory.RemoveInventoryItem(item.ItemID); } - - AddNewSceneObject(group, true, pos, rot, vel); + + AddNewSceneObject(group, true); + + group.AbsolutePosition = pos; + group.Velocity = vel; + + if (rot != null) + group.UpdateGroupRotationR((Quaternion)rot); // We can only call this after adding the scene object, since the scene object references the scene // to find out if scripts should be activated at all. -- cgit v1.1 From 8e0d2cc43b63046b0dd6b9a3a7dafd70a70362d0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 12 Apr 2011 22:21:46 +0100 Subject: If an object is rezzed directly from a prim inventory then give it the rotation it was stored with. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 87b4cb8..254879b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2007,7 +2007,7 @@ namespace OpenSim.Region.Framework.Scenes RayStart, RayEnd, RayTargetID, Quaternion.Identity, BypassRayCast, bRayEndIsIntersection, true, scale, false); - RezObject(part, item, pos, Quaternion.Identity, Vector3.Zero, 0); + RezObject(part, item, pos, null, Vector3.Zero, 0); } } -- cgit v1.1 From b0889ed92a3c7d152f9b05aec1ce00dfc010e34e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 12 Apr 2011 22:30:43 +0100 Subject: refactor: simplify bRayEndIsIntersection boolean set from RayEndIsIntersection byte --- .../Framework/InventoryAccess/InventoryAccessModule.cs | 15 +-------------- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 13 +------------ 2 files changed, 2 insertions(+), 26 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index cdee53c..73b0a35 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -574,21 +574,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess { // m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); - // Work out position details - byte bRayEndIsIntersection = (byte)0; - - if (RayEndIsIntersection) - { - bRayEndIsIntersection = (byte)1; - } - else - { - bRayEndIsIntersection = (byte)0; - } - + byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); - - Vector3 pos = m_Scene.GetNewRezLocation( RayStart, RayEnd, RayTargetID, Quaternion.Identity, BypassRayCast, bRayEndIsIntersection, true, scale, false); diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 254879b..0f85925 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1989,18 +1989,7 @@ namespace OpenSim.Region.Framework.Scenes return; } - // Work out position details - byte bRayEndIsIntersection = (byte)0; - - if (RayEndIsIntersection) - { - bRayEndIsIntersection = (byte)1; - } - else - { - bRayEndIsIntersection = (byte)0; - } - + byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); Vector3 pos = GetNewRezLocation( -- cgit v1.1 From da4a9653a27cbb1ecc779774a3d8715afb079086 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 12 Apr 2011 22:33:06 +0100 Subject: minor: remove some mono compiler warnings --- OpenSim/Data/Null/NullEstateData.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/Null/NullEstateData.cs b/OpenSim/Data/Null/NullEstateData.cs index 0cebff5..8db8064 100755 --- a/OpenSim/Data/Null/NullEstateData.cs +++ b/OpenSim/Data/Null/NullEstateData.cs @@ -38,9 +38,9 @@ namespace OpenSim.Data.Null { public class NullEstateStore : IEstateDataStore { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private string m_connectionString; +// private string m_connectionString; protected virtual Assembly Assembly { @@ -58,7 +58,7 @@ namespace OpenSim.Data.Null public void Initialise(string connectionString) { - m_connectionString = connectionString; +// m_connectionString = connectionString; } private string[] FieldList -- cgit v1.1