diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs index b15b3375ab..4333ef14eb 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs @@ -123,10 +123,15 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests private void DoMove(RequestData rdata) { - if (rdata.Parameters.Length >= 6) + if (rdata.Parameters.Length < 6) + { + Rest.Log.WarnFormat("{0} Move: No movement information provided", MsgId); + rdata.Fail(Rest.HttpStatusCodeBadRequest, "no movement information provided"); + } + else { string[] names = rdata.Parameters[PARM_MOVE_AVATAR].Split(Rest.CA_SPACE); - ScenePresence avatar = null; + ScenePresence presence = null; Scene scene = null; if (names.Length != 2) @@ -141,21 +146,19 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests // The first parameter should be an avatar name, look for the // avatar in the known regions first. - foreach (Scene cs in Rest.main.SceneManager.Scenes) + Rest.main.SceneManager.ForEachScene(delegate(Scene s) { - foreach (ScenePresence presence in cs.GetAvatars()) + s.ForEachScenePresence(delegate(ScenePresence sp) { - if (presence.Firstname == names[0] && - presence.Lastname == names[1]) + if (sp.Firstname == names[0] && sp.Lastname == names[1]) { - scene = cs; - avatar = presence; - break; + scene = s; + presence = sp; } - } - } + }); + }); - if (avatar != null) + if (presence != null) { Rest.Log.DebugFormat("{0} Move : Avatar {1} located in region {2}", MsgId, rdata.Parameters[PARM_MOVE_AVATAR], scene.RegionInfo.RegionName); @@ -166,14 +169,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests float y = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Y]); float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]); Vector3 vector = new Vector3(x,y,z); - avatar.DoAutoPilot(0,vector,avatar.ControllingClient); + presence.DoAutoPilot(0,vector,presence.ControllingClient); } catch (Exception e) { rdata.Fail(Rest.HttpStatusCodeBadRequest, String.Format("invalid parameters: {0}", e.Message)); } - } else { @@ -183,12 +185,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests rdata.Complete(); rdata.Respond("OK"); - - } - else - { - Rest.Log.WarnFormat("{0} Move: No movement information provided", MsgId); - rdata.Fail(Rest.HttpStatusCodeBadRequest, "no movement information provided"); } } diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs index ed18207216..dea166d2ec 100644 --- a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs +++ b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs @@ -192,7 +192,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions protected string RegionStats(OSHttpResponse httpResponse, Scene scene) { - int users = scene.GetAvatars().Count; + int users = scene.GetRootAgentCount(); int objects = scene.Entities.Count - users; RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs index 734b6685d2..279db4cbe4 100644 --- a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs +++ b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs @@ -117,7 +117,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString()); rxw.WriteEndAttribute(); - int users = s.GetAvatars().Count; + int users = s.GetRootAgentCount(); rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty); rxw.WriteValue(users); rxw.WriteEndAttribute(); diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs index 6f6f076e68..474f706ed3 100644 --- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs +++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs @@ -83,7 +83,7 @@ namespace OpenSim.Data.MSSQL /// /// region ID. /// - public EstateSettings LoadEstateSettings(UUID regionID) + public EstateSettings LoadEstateSettings(UUID regionID, bool create) { EstateSettings es = new EstateSettings(); @@ -127,7 +127,7 @@ namespace OpenSim.Data.MSSQL } - if (insertEstate) + if (insertEstate && create) { List names = new List(FieldList); @@ -173,25 +173,6 @@ namespace OpenSim.Data.MSSQL } } - // Munge and transfer the ban list - - sql = string.Format("insert into estateban select {0}, bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = @UUID", es.EstateID); - using (SqlConnection conn = new SqlConnection(m_connectionString)) - using (SqlCommand cmd = new SqlCommand(sql, conn)) - { - - cmd.Parameters.Add(_Database.CreateParameter("@UUID", regionID)); - try - { - conn.Open(); - cmd.ExecuteNonQuery(); - } - catch (Exception) - { - _Log.Debug("[ESTATE DB]: Error setting up estateban from regionban"); - } - } - //TODO check if this is needed?? es.Save(); } @@ -365,6 +346,31 @@ namespace OpenSim.Data.MSSQL } } } + + public EstateSettings LoadEstateSettings(int estateID) + { + return new EstateSettings(); + } + + public List GetEstates(string search) + { + return new List(); + } + + public bool LinkRegion(UUID regionID, int estateID) + { + return false; + } + + public List GetRegions(int estateID) + { + return new List(); + } + + public bool DeleteEstate(int estateID) + { + return false; + } #endregion } } diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 2eae2d82b2..7fe1fcc9cc 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -121,111 +121,110 @@ namespace OpenSim.Data.MySQL } } - public EstateSettings LoadEstateSettings(UUID regionID) + public EstateSettings LoadEstateSettings(UUID regionID, bool create) { - EstateSettings es = new EstateSettings(); - es.OnSave += StoreEstateSettings; - 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"; - bool migration = true; + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = sql; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + + return DoLoad(cmd, regionID, create); + } + } + + private EstateSettings DoLoad(MySqlCommand cmd, UUID regionID, bool create) + { + EstateSettings es = new EstateSettings(); + es.OnSave += StoreEstateSettings; using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - using (MySqlCommand cmd = dbcon.CreateCommand()) + cmd.Connection = dbcon; + + bool found = false; + + using (IDataReader r = cmd.ExecuteReader()) { - cmd.CommandText = sql; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - - using (IDataReader r = cmd.ExecuteReader()) + if (r.Read()) { - if (r.Read()) + found = true; + + foreach (string name in FieldList) { - migration = false; - - foreach (string name in FieldList) + if (m_FieldMap[name].GetValue(es) is bool) { - 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); - } + int v = Convert.ToInt32(r[name]); + if (v != 0) + m_FieldMap[name].SetValue(es, true); else - { - m_FieldMap[name].SetValue(es, r[name]); - } + 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, r[name]); } } } } - if (migration) + if (!found && create) { // Migration case List names = new List(FieldList); names.Remove("EstateID"); - sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; + string sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; - using (MySqlCommand cmd = dbcon.CreateCommand()) + using (MySqlCommand cmd2 = dbcon.CreateCommand()) { - cmd.CommandText = sql; - cmd.Parameters.Clear(); + cmd2.CommandText = sql; + cmd2.Parameters.Clear(); foreach (string name in FieldList) { if (m_FieldMap[name].GetValue(es) is bool) { if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue("?" + name, "1"); + cmd2.Parameters.AddWithValue("?" + name, "1"); else - cmd.Parameters.AddWithValue("?" + name, "0"); + cmd2.Parameters.AddWithValue("?" + name, "0"); } else { - cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); + cmd2.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); } } - cmd.ExecuteNonQuery(); + cmd2.ExecuteNonQuery(); - cmd.CommandText = "select LAST_INSERT_ID() as id"; - cmd.Parameters.Clear(); + cmd2.CommandText = "select LAST_INSERT_ID() as id"; + cmd2.Parameters.Clear(); - using (IDataReader r = cmd.ExecuteReader()) + using (IDataReader r = cmd2.ExecuteReader()) { r.Read(); es.EstateID = Convert.ToUInt32(r["id"]); } - cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + cmd2.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; + cmd2.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd2.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); // This will throw on dupe key - try { cmd.ExecuteNonQuery(); } - catch (Exception) { } - - // Munge and transfer the ban list - cmd.Parameters.Clear(); - cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); - - try { cmd.ExecuteNonQuery(); } + try { cmd2.ExecuteNonQuery(); } catch (Exception) { } es.Save(); @@ -398,5 +397,83 @@ namespace OpenSim.Data.MySQL return uuids.ToArray(); } + + public EstateSettings LoadEstateSettings(int estateID) + { + using (MySqlCommand cmd = new MySqlCommand()) + { + string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_settings where EstateID = ?EstateID"; + + cmd.CommandText = sql; + cmd.Parameters.AddWithValue("?EstateID", estateID); + + return DoLoad(cmd, UUID.Zero, false); + } + } + + public List GetEstates(string search) + { + 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 EstateName = ?EstateName"; + cmd.Parameters.AddWithValue("?EstateName", search); + + 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)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; + cmd.Parameters.AddWithValue("?RegionID", regionID); + cmd.Parameters.AddWithValue("?EstateID", estateID); + + if (cmd.ExecuteNonQuery() == 0) + { + dbcon.Close(); + return false; + } + } + + dbcon.Close(); + } + + return true; + } + + public List GetRegions(int estateID) + { + return new List(); + } + + public bool DeleteEstate(int estateID) + { + return false; + } } } diff --git a/OpenSim/Data/MySQL/Resources/032_RegionStore.sql b/OpenSim/Data/MySQL/Resources/032_RegionStore.sql new file mode 100644 index 0000000000..dca5de7144 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/032_RegionStore.sql @@ -0,0 +1,3 @@ +BEGIN; +ALTER TABLE estate_settings AUTO_INCREMENT = 100; +COMMIT; diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs index 1be99eedab..bd6b776f80 100644 --- a/OpenSim/Data/SQLite/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs @@ -80,11 +80,8 @@ namespace OpenSim.Data.SQLite get { return new List(m_FieldMap.Keys).ToArray(); } } - public EstateSettings LoadEstateSettings(UUID regionID) + public EstateSettings LoadEstateSettings(UUID regionID, bool create) { - EstateSettings es = new EstateSettings(); - es.OnSave += StoreEstateSettings; - 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(); @@ -92,6 +89,14 @@ namespace OpenSim.Data.SQLite cmd.CommandText = sql; cmd.Parameters.Add(":RegionID", regionID.ToString()); + return DoLoad(cmd, regionID, create); + } + + private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create) + { + EstateSettings es = new EstateSettings(); + es.OnSave += StoreEstateSettings; + IDataReader r = cmd.ExecuteReader(); if (r.Read()) @@ -120,17 +125,15 @@ namespace OpenSim.Data.SQLite } r.Close(); } - else + else if (create) { - // Migration case - // r.Close(); List names = new List(FieldList); names.Remove("EstateID"); - sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")"; + string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")"; cmd.CommandText = sql; cmd.Parameters.Clear(); @@ -176,20 +179,6 @@ namespace OpenSim.Data.SQLite { } - // Munge and transfer the ban list - // - cmd.Parameters.Clear(); - cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = :UUID"; - cmd.Parameters.Add(":UUID", regionID.ToString()); - - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception) - { - } - es.Save(); } @@ -336,5 +325,63 @@ namespace OpenSim.Data.SQLite 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 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/Tests/BasicEstateTest.cs b/OpenSim/Data/Tests/BasicEstateTest.cs index 907bb382c6..d14d405256 100644 --- a/OpenSim/Data/Tests/BasicEstateTest.cs +++ b/OpenSim/Data/Tests/BasicEstateTest.cs @@ -158,7 +158,7 @@ namespace OpenSim.Data.Tests public void T012_EstateSettingsRandomStorage() { // Letting estate store generate rows to database for us - EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); + EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); new PropertyScrambler() .DontScramble(x=>x.EstateID) .Scramble(originalSettings); @@ -167,7 +167,7 @@ namespace OpenSim.Data.Tests db.StoreEstateSettings(originalSettings); // Loading settings to another instance variable. - EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); + EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true); // Checking that loaded values are correct. Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings)); @@ -177,7 +177,7 @@ namespace OpenSim.Data.Tests public void T020_EstateSettingsManagerList() { // Letting estate store generate rows to database for us - EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); + EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 }; @@ -185,7 +185,7 @@ namespace OpenSim.Data.Tests db.StoreEstateSettings(originalSettings); // Loading settings to another instance variable. - EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); + EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true); Assert.AreEqual(2, loadedSettings.EstateManagers.Length); Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]); @@ -196,7 +196,7 @@ namespace OpenSim.Data.Tests public void T021_EstateSettingsUserList() { // Letting estate store generate rows to database for us - EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); + EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 }; @@ -204,7 +204,7 @@ namespace OpenSim.Data.Tests db.StoreEstateSettings(originalSettings); // Loading settings to another instance variable. - EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); + EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true); Assert.AreEqual(2, loadedSettings.EstateAccess.Length); Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]); @@ -215,7 +215,7 @@ namespace OpenSim.Data.Tests public void T022_EstateSettingsGroupList() { // Letting estate store generate rows to database for us - EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); + EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 }; @@ -223,7 +223,7 @@ namespace OpenSim.Data.Tests db.StoreEstateSettings(originalSettings); // Loading settings to another instance variable. - EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); + EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true); Assert.AreEqual(2, loadedSettings.EstateAccess.Length); Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]); @@ -234,7 +234,7 @@ namespace OpenSim.Data.Tests public void T022_EstateSettingsBanList() { // Letting estate store generate rows to database for us - EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); + EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); EstateBan estateBan1 = new EstateBan(); estateBan1.BannedUserID = DataTestUtil.UUID_MIN; @@ -248,7 +248,7 @@ namespace OpenSim.Data.Tests db.StoreEstateSettings(originalSettings); // Loading settings to another instance variable. - EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); + EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true); Assert.AreEqual(2, loadedSettings.EstateBans.Length); Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID); @@ -290,7 +290,7 @@ namespace OpenSim.Data.Tests { // Letting estate store generate rows to database for us - EstateSettings originalSettings = db.LoadEstateSettings(regionId); + EstateSettings originalSettings = db.LoadEstateSettings(regionId, true); SetEstateSettings( originalSettings, @@ -347,7 +347,7 @@ namespace OpenSim.Data.Tests db.StoreEstateSettings(originalSettings); // Loading settings to another instance variable. - EstateSettings loadedSettings = db.LoadEstateSettings(regionId); + EstateSettings loadedSettings = db.LoadEstateSettings(regionId, true); // Checking that loaded values are correct. ValidateEstateSettings( diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index b4b5808ad3..2a495b0e8c 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -35,7 +35,6 @@ namespace OpenSim.Framework public class EstateSettings { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private readonly ConfigurationMember configMember; public delegate void SaveDelegate(EstateSettings rs); @@ -43,7 +42,7 @@ namespace OpenSim.Framework // Only the client uses these // - private uint m_EstateID = 100; + private uint m_EstateID = 0; public uint EstateID { @@ -51,7 +50,7 @@ namespace OpenSim.Framework set { m_EstateID = value; } } - private string m_EstateName; + private string m_EstateName = "My Estate"; public string EstateName { @@ -59,7 +58,7 @@ namespace OpenSim.Framework set { m_EstateName = value; } } - private uint m_ParentEstateID = 100; + private uint m_ParentEstateID = 1; public uint ParentEstateID { @@ -67,7 +66,7 @@ namespace OpenSim.Framework set { m_ParentEstateID = value; } } - private float m_BillableFactor; + private float m_BillableFactor = 0.0f; public float BillableFactor { @@ -75,7 +74,7 @@ namespace OpenSim.Framework set { m_BillableFactor = value; } } - private int m_PricePerMeter; + private int m_PricePerMeter = 1; public int PricePerMeter { @@ -83,7 +82,7 @@ namespace OpenSim.Framework set { m_PricePerMeter = value; } } - private int m_RedirectGridX; + private int m_RedirectGridX = 0; public int RedirectGridX { @@ -91,7 +90,7 @@ namespace OpenSim.Framework set { m_RedirectGridX = value; } } - private int m_RedirectGridY; + private int m_RedirectGridY = 0; public int RedirectGridY { @@ -273,25 +272,6 @@ namespace OpenSim.Framework public EstateSettings() { - if (configMember == null) - { - try - { - // Load legacy defaults - // - configMember = - new ConfigurationMember(Path.Combine(Util.configDir(), - "estate_settings.xml"), "ESTATE SETTINGS", - loadConfigurationOptions, - handleIncomingConfiguration, true); - - l_EstateManagers.Clear(); - configMember.performConfigurationRetrieve(); - } - catch (Exception) - { - } - } } public void Save() @@ -393,165 +373,5 @@ namespace OpenSim.Framework return l_EstateAccess.Contains(user); } - - public void loadConfigurationOptions() - { - configMember.addConfigurationOption("billable_factor", - ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, - String.Empty, "0.0", true); - -// configMember.addConfigurationOption("estate_id", -// ConfigurationOption.ConfigurationTypes.TYPE_UINT32, -// String.Empty, "100", true); - -// configMember.addConfigurationOption("parent_estate_id", -// ConfigurationOption.ConfigurationTypes.TYPE_UINT32, -// String.Empty, "1", true); - - configMember.addConfigurationOption("redirect_grid_x", - ConfigurationOption.ConfigurationTypes.TYPE_INT32, - String.Empty, "0", true); - - configMember.addConfigurationOption("redirect_grid_y", - ConfigurationOption.ConfigurationTypes.TYPE_INT32, - String.Empty, "0", true); - - configMember.addConfigurationOption("price_per_meter", - ConfigurationOption.ConfigurationTypes.TYPE_UINT32, - String.Empty, "1", true); - - configMember.addConfigurationOption("estate_name", - ConfigurationOption.ConfigurationTypes.TYPE_STRING, - String.Empty, "My Estate", true); - - configMember.addConfigurationOption("estate_manager_0", - ConfigurationOption.ConfigurationTypes.TYPE_UUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - - configMember.addConfigurationOption("estate_manager_1", - ConfigurationOption.ConfigurationTypes.TYPE_UUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - - configMember.addConfigurationOption("estate_manager_2", - ConfigurationOption.ConfigurationTypes.TYPE_UUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - - configMember.addConfigurationOption("estate_manager_3", - ConfigurationOption.ConfigurationTypes.TYPE_UUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - - configMember.addConfigurationOption("estate_manager_4", - ConfigurationOption.ConfigurationTypes.TYPE_UUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - - configMember.addConfigurationOption("estate_manager_5", - ConfigurationOption.ConfigurationTypes.TYPE_UUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - - configMember.addConfigurationOption("estate_manager_6", - ConfigurationOption.ConfigurationTypes.TYPE_UUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - - configMember.addConfigurationOption("estate_manager_7", - ConfigurationOption.ConfigurationTypes.TYPE_UUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - - configMember.addConfigurationOption("estate_manager_8", - ConfigurationOption.ConfigurationTypes.TYPE_UUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - - configMember.addConfigurationOption("estate_manager_9", - ConfigurationOption.ConfigurationTypes.TYPE_UUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - - configMember.addConfigurationOption("region_flags", - ConfigurationOption.ConfigurationTypes.TYPE_UINT32, - String.Empty, "336723974", true); - } - - public bool handleIncomingConfiguration(string configuration_key, object configuration_result) - { - switch (configuration_key) - { - case "region_flags": - RegionFlags flags = (RegionFlags)(uint)configuration_result; - if ((flags & (RegionFlags)(1<<29)) != 0) - m_AllowVoice = true; - if ((flags & RegionFlags.AllowDirectTeleport) != 0) - m_AllowDirectTeleport = true; - if ((flags & RegionFlags.DenyAnonymous) != 0) - m_DenyAnonymous = true; - if ((flags & RegionFlags.DenyIdentified) != 0) - m_DenyIdentified = true; - if ((flags & RegionFlags.DenyTransacted) != 0) - m_DenyTransacted = true; - if ((flags & RegionFlags.AbuseEmailToEstateOwner) != 0) - m_AbuseEmailToEstateOwner = true; - if ((flags & RegionFlags.BlockDwell) != 0) - m_BlockDwell = true; - if ((flags & RegionFlags.EstateSkipScripts) != 0) - m_EstateSkipScripts = true; - if ((flags & RegionFlags.ResetHomeOnTeleport) != 0) - m_ResetHomeOnTeleport = true; - if ((flags & RegionFlags.TaxFree) != 0) - m_TaxFree = true; - if ((flags & RegionFlags.PublicAllowed) != 0) - m_PublicAccess = true; - break; - case "billable_factor": - m_BillableFactor = (float) configuration_result; - break; -// case "estate_id": -// m_EstateID = (uint) configuration_result; -// break; -// case "parent_estate_id": -// m_ParentEstateID = (uint) configuration_result; -// break; - case "redirect_grid_x": - m_RedirectGridX = (int) configuration_result; - break; - case "redirect_grid_y": - m_RedirectGridY = (int) configuration_result; - break; - case "price_per_meter": - m_PricePerMeter = Convert.ToInt32(configuration_result); - break; - case "estate_name": - m_EstateName = (string) configuration_result; - break; - case "estate_manager_0": - AddEstateManager((UUID)configuration_result); - break; - case "estate_manager_1": - AddEstateManager((UUID)configuration_result); - break; - case "estate_manager_2": - AddEstateManager((UUID)configuration_result); - break; - case "estate_manager_3": - AddEstateManager((UUID)configuration_result); - break; - case "estate_manager_4": - AddEstateManager((UUID)configuration_result); - break; - case "estate_manager_5": - AddEstateManager((UUID)configuration_result); - break; - case "estate_manager_6": - AddEstateManager((UUID)configuration_result); - break; - case "estate_manager_7": - AddEstateManager((UUID)configuration_result); - break; - case "estate_manager_8": - AddEstateManager((UUID)configuration_result); - break; - case "estate_manager_9": - AddEstateManager((UUID)configuration_result); - break; - } - - return true; - } } } diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index 86d63f88a8..19ab409098 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs @@ -91,7 +91,7 @@ namespace OpenSim.Framework /// bool PresenceChildStatus(UUID agentId); - bool TryGetAvatar(UUID agentID, out object scenePresence); + bool TryGetScenePresence(UUID agentID, out object scenePresence); T RequestModuleInterface(); T[] RequestModuleInterfaces(); diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 6a38278ff2..9c2a4f9ac1 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -227,8 +227,12 @@ namespace OpenSim.Framework { get { - //m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length); - return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); + //m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length); + try { return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); } + catch { } + + m_log.Warn("[SHAPE]: Failed to decode texture, length=" + ((m_textureEntry != null) ? m_textureEntry.Length : 0)); + return new Primitive.TextureEntry(null); } set { m_textureEntry = value.GetBytes(); } diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 9a6ef77437..350c041f7d 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -42,6 +42,7 @@ using Nwc.XmlRpc; using OpenMetaverse.StructuredData; using CoolHTTPListener = HttpServer.HttpListener; using HttpListener=System.Net.HttpListener; +using LogPrio=HttpServer.LogPrio; namespace OpenSim.Framework.Servers.HttpServer { @@ -294,7 +295,7 @@ namespace OpenSim.Framework.Servers.HttpServer headervals[headername] = req.Headers[headername]; } - keysvals.Add("headers",headervals); + keysvals.Add("headers", headervals); keysvals.Add("querystringkeys", querystringkeys); psEvArgs.Request(psreq.RequestID, keysvals); @@ -341,7 +342,7 @@ namespace OpenSim.Framework.Servers.HttpServer // the request can be passed through to the other handlers. This is a low // probability event; if a request is matched it is normally expected to be // handled - //m_log.Debug("[BASE HTTP SERVER]: Handling Request" + request.RawUrl); +// m_log.Debug("[BASE HTTP SERVER]: Handling request to " + request.RawUrl); IHttpAgentHandler agentHandler; @@ -496,7 +497,8 @@ namespace OpenSim.Framework.Servers.HttpServer { case null: case "text/html": - //m_log.Info("[Debug BASE HTTP SERVER]: found a text/html content type"); +// m_log.DebugFormat( +// "[BASE HTTP SERVER]: Found a text/html content type for request {0}", request.RawUrl); HandleHTTPRequest(request, response); return; @@ -524,10 +526,11 @@ namespace OpenSim.Framework.Servers.HttpServer HandleLLSDRequests(request, response); return; } - //m_log.Info("[Debug BASE HTTP SERVER]: Checking for HTTP Handler"); + +// m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl); if (DoWeHaveAHTTPHandler(request.RawUrl)) { - //m_log.Info("[Debug BASE HTTP SERVER]: found HTTP Handler"); +// m_log.DebugFormat("[BASE HTTP SERVER]: Found HTTP Handler for request {0}", request.RawUrl); HandleHTTPRequest(request, response); return; } @@ -623,7 +626,7 @@ namespace OpenSim.Framework.Servers.HttpServer private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler) { - //m_log.DebugFormat("[BASE HTTP HANDLER]: Looking for HTTP handler for {0}", handlerKey); +// m_log.DebugFormat("[BASE HTTP HANDLER]: Looking for HTTP handler for {0}", handlerKey); string bestMatch = null; @@ -943,7 +946,7 @@ namespace OpenSim.Framework.Servers.HttpServer } catch (IOException e) { - m_log.DebugFormat("[BASE HTTP SERVER]: LLSD IOException {0}.", e); + m_log.WarnFormat("[BASE HTTP SERVER]: LLSD IOException {0}.", e); } catch (SocketException e) { @@ -1218,7 +1221,11 @@ namespace OpenSim.Framework.Servers.HttpServer } public void HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) - { + { +// m_log.DebugFormat( +// "[BASE HTTP SERVER]: HandleHTTPRequest for request to {0}, method {1}", +// request.RawUrl, request.HttpMethod); + switch (request.HttpMethod) { case "OPTIONS": @@ -1233,6 +1240,8 @@ namespace OpenSim.Framework.Servers.HttpServer private void HandleContentVerbs(OSHttpRequest request, OSHttpResponse response) { +// m_log.DebugFormat("[BASE HTTP SERVER]: HandleContentVerbs for request to {0}", request.RawUrl); + // This is a test. There's a workable alternative.. as this way sucks. // We'd like to put this into a text file parhaps that's easily editable. // @@ -1273,13 +1282,15 @@ namespace OpenSim.Framework.Servers.HttpServer foreach (string queryname in querystringkeys) { +// m_log.DebugFormat( +// "[BASE HTTP SERVER]: Got query paremeter {0}={1}", queryname, request.QueryString[queryname]); keysvals.Add(queryname, request.QueryString[queryname]); requestVars.Add(queryname, keysvals[queryname]); } foreach (string headername in rHeaders) { - //m_log.Warn("[HEADER]: " + headername + "=" + request.Headers[headername]); +// m_log.Debug("[BASE HTTP SERVER]: " + headername + "=" + request.Headers[headername]); headervals[headername] = request.Headers[headername]; } @@ -1288,15 +1299,16 @@ namespace OpenSim.Framework.Servers.HttpServer host = (string)headervals["Host"]; } - keysvals.Add("headers",headervals); + keysvals.Add("headers", headervals); keysvals.Add("querystringkeys", querystringkeys); keysvals.Add("requestvars", requestVars); +// keysvals.Add("form", request.Form); if (keysvals.Contains("method")) { - //m_log.Warn("[HTTP]: Contains Method"); +// m_log.Debug("[BASE HTTP SERVER]: Contains Method"); string method = (string) keysvals["method"]; - //m_log.Warn("[HTTP]: " + requestBody); +// m_log.Debug("[BASE HTTP SERVER]: " + requestBody); GenericHTTPMethod requestprocessor; bool foundHandler = TryGetHTTPHandler(method, out requestprocessor); if (foundHandler) @@ -1308,13 +1320,12 @@ namespace OpenSim.Framework.Servers.HttpServer } else { - //m_log.Warn("[HTTP]: Handler Not Found"); +// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found"); SendHTML404(response, host); } } else { - GenericHTTPMethod requestprocessor; bool foundHandler = TryGetHTTPHandlerPathBased(request.RawUrl, out requestprocessor); if (foundHandler) @@ -1326,7 +1337,7 @@ namespace OpenSim.Framework.Servers.HttpServer } else { - //m_log.Warn("[HTTP]: Handler Not Found"); +// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found2"); SendHTML404(response, host); } } @@ -1374,8 +1385,7 @@ namespace OpenSim.Framework.Servers.HttpServer { if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) { - // You have to specifically register for '/' and to get it, you must specificaly request it - // + // You have to specifically register for '/' and to get it, you must specifically request it if (pattern == "/" && searchquery == "/" || pattern != "/") bestMatch = pattern; } @@ -1814,30 +1824,36 @@ namespace OpenSim.Framework.Servers.HttpServer /// /// Relays HttpServer log messages to our own logging mechanism. /// - /// There is also a UseTraceLogs line in this file that can be uncommented for more detailed log information + /// To use this you must uncomment the switch section + /// + /// You may also be able to get additional trace information from HttpServer if you uncomment the UseTraceLogs + /// property in StartHttp() for the HttpListener public class HttpServerLogWriter : ILogWriter { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public void Write(object source, LogPrio priority, string message) { /* switch (priority) { - case HttpServer.LogPrio.Debug: - m_log.DebugFormat("[{0}]: {1}", source.ToString(), message); + case LogPrio.Trace: + m_log.DebugFormat("[{0}]: {1}", source, message); + break; + case LogPrio.Debug: + m_log.DebugFormat("[{0}]: {1}", source, message); break; - case HttpServer.LogPrio.Error: - m_log.ErrorFormat("[{0}]: {1}", source.ToString(), message); + case LogPrio.Error: + m_log.ErrorFormat("[{0}]: {1}", source, message); break; - case HttpServer.LogPrio.Info: - m_log.InfoFormat("[{0}]: {1}", source.ToString(), message); + case LogPrio.Info: + m_log.InfoFormat("[{0}]: {1}", source, message); break; - case HttpServer.LogPrio.Warning: - m_log.WarnFormat("[{0}]: {1}", source.ToString(), message); + case LogPrio.Warning: + m_log.WarnFormat("[{0}]: {1}", source, message); break; - case HttpServer.LogPrio.Fatal: - m_log.ErrorFormat("[{0}]: FATAL! - {1}", source.ToString(), message); + case LogPrio.Fatal: + m_log.ErrorFormat("[{0}]: FATAL! - {1}", source, message); break; default: break; @@ -1847,4 +1863,4 @@ namespace OpenSim.Framework.Servers.HttpServer return; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs index bcfb0a4025..e354dfbd1a 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs @@ -127,6 +127,11 @@ namespace OpenSim.Framework.Servers.HttpServer } private Hashtable _query; + /// + /// POST request values, if applicable + /// +// public Hashtable Form { get; private set; } + public string RawUrl { get { return _request.Uri.AbsolutePath; } @@ -228,6 +233,13 @@ namespace OpenSim.Framework.Servers.HttpServer { _log.ErrorFormat("[OSHttpRequest]: Error parsing querystring"); } + +// Form = new Hashtable(); +// foreach (HttpInputItem item in req.Form) +// { +// _log.DebugFormat("[OSHttpRequest]: Got form item {0}={1}", item.Name, item.Value); +// Form.Add(item.Name, item.Value); +// } } public override string ToString() diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 7e816502a1..38b20843e0 100755 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -897,7 +897,7 @@ namespace OpenSim { connections.AppendFormat("{0}: {1} ({2}) from {3} on circuit {4}\n", scene.RegionInfo.RegionName, client.Name, client.AgentId, client.RemoteEndPoint, client.CircuitCode); - }, false + } ); } ); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index af1910dd9f..cdefecde1e 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -6001,7 +6001,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f) { ScenePresence avatar = null; - if (((Scene)m_scene).TryGetAvatar(AgentId, out avatar)) + if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar)) { if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f) { diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 36d24e8200..850474d834 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -1020,7 +1020,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Handle outgoing packets, resends, acknowledgements, and pings for each // client. m_packetSent will be set to true if a packet is sent - m_scene.ForEachClient(clientPacketHandler, false); + m_scene.ForEachClient(clientPacketHandler); // If nothing was sent, sleep for the minimum amount of time before a // token bucket could get more tokens diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index f54e41abee..23828efea5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // Save avatar attachment information ScenePresence presence; - if (m_scene.AvatarFactory != null && m_scene.TryGetAvatar(remoteClient.AgentId, out presence)) + if (m_scene.AvatarFactory != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) { m_log.Info( "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId @@ -255,7 +255,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments AttachmentPt = att.RootPart.AttachmentPoint; ScenePresence presence; - if (m_scene.TryGetAvatar(remoteClient.AgentId, out presence)) + if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) { InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = m_scene.InventoryService.GetItem(item); @@ -299,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } ScenePresence presence; - if (m_scene.TryGetAvatar(remoteClient.AgentId, out presence)) + if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) { // XXYY!! InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); @@ -314,7 +314,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient) { ScenePresence presence; - if (m_scene.TryGetAvatar(remoteClient.AgentId, out presence)) + if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) { presence.Appearance.DetachAttachment(itemID); diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 3614915c5e..9df60743ae 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs @@ -89,60 +89,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule get { return true; } } - private void KillAvatar(uint killerObjectLocalID, ScenePresence DeadAvatar) + private void KillAvatar(uint killerObjectLocalID, ScenePresence deadAvatar) { + string deadAvatarMessage; + ScenePresence killingAvatar = null; + string killingAvatarMessage; + if (killerObjectLocalID == 0) - DeadAvatar.ControllingClient.SendAgentAlertMessage("You committed suicide!", true); + deadAvatarMessage = "You committed suicide!"; else { - bool foundResult = false; - string resultstring = String.Empty; - ScenePresence[] allav = DeadAvatar.Scene.GetScenePresences(); - try + // Try to get the avatar responsible for the killing + killingAvatar = deadAvatar.Scene.GetScenePresence(killerObjectLocalID); + if (killingAvatar == null) { - for (int i = 0; i < allav.Length; i++) + // Try to get the object which was responsible for the killing + SceneObjectPart part = deadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID); + if (part == null) { - ScenePresence av = allav[i]; - - if (av.LocalId == killerObjectLocalID) - { - av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname); - resultstring = av.Firstname + " " + av.Lastname; - foundResult = true; - } - } - } catch (InvalidOperationException) - { - - } - - if (!foundResult) - { - SceneObjectPart part = DeadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID); - if (part != null) - { - ScenePresence av = DeadAvatar.Scene.GetScenePresence(part.OwnerID); - if (av != null) - { - av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname); - resultstring = av.Firstname + " " + av.Lastname; - DeadAvatar.ControllingClient.SendAgentAlertMessage("You got killed by " + resultstring + "!", true); - } - else - { - string killer = DeadAvatar.Scene.GetUserName(part.OwnerID); - DeadAvatar.ControllingClient.SendAgentAlertMessage("You impaled yourself on " + part.Name + " owned by " + killer +"!", true); - } - //DeadAvatar.Scene. part.ObjectOwner + // Cause of death: Unknown + deadAvatarMessage = "You died!"; } else { - DeadAvatar.ControllingClient.SendAgentAlertMessage("You died!", true); + // Try to find the avatar wielding the killing object + killingAvatar = deadAvatar.Scene.GetScenePresence(part.OwnerID); + if (killingAvatar == null) + deadAvatarMessage = String.Format("You impaled yourself on {0} owned by {1}!", part.Name, deadAvatar.Scene.GetUserName(part.OwnerID)); + else + { + killingAvatarMessage = String.Format("You fragged {0}!", deadAvatar.Name); + deadAvatarMessage = String.Format("You got killed by {0}!", killingAvatar.Name); + } } } + else + { + killingAvatarMessage = String.Format("You fragged {0}!", deadAvatar.Name); + deadAvatarMessage = String.Format("You got killed by {0}!", killingAvatar.Name); + } } - DeadAvatar.Health = 100; - DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient); + try + { + deadAvatar.ControllingClient.SendAgentAlertMessage(deadAvatarMessage, true); + if(killingAvatar != null) + killingAvatar.ControllingClient.SendAlertMessage("You fragged " + deadAvatar.Firstname + " " + deadAvatar.Lastname); + } + catch (InvalidOperationException) + { } + + deadAvatar.Health = 100; + deadAvatar.Scene.TeleportClientHome(deadAvatar.UUID, deadAvatar.ControllingClient); } private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index b8e013c672..c31266c0e1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -87,31 +87,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void SendAlertToUser(string firstName, string lastName, string message, bool modal) { - ScenePresence[] presenceList = m_scene.GetScenePresences(); - - for (int i = 0; i < presenceList.Length; i++) - { - ScenePresence presence = presenceList[i]; - - if (presence.Firstname == firstName && presence.Lastname == lastName) - { - presence.ControllingClient.SendAgentAlertMessage(message, modal); - break; - } - } + ScenePresence presence = m_scene.GetScenePresence(firstName, lastName); + if(presence != null) + presence.ControllingClient.SendAgentAlertMessage(message, modal); } public void SendGeneralAlert(string message) { - ScenePresence[] presenceList = m_scene.GetScenePresences(); - - for (int i = 0; i < presenceList.Length; i++) + m_scene.ForEachScenePresence(delegate(ScenePresence presence) { - ScenePresence presence = presenceList[i]; - if (!presence.IsChildAgent) presence.ControllingClient.SendAlertMessage(message); - } + }); } public void SendDialogToUser( @@ -179,14 +166,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void SendNotificationToUsersInRegion( UUID fromAvatarID, string fromAvatarName, string message) { - ScenePresence[] presences = m_scene.GetScenePresences(); - - for (int i = 0; i < presences.Length; i++) + m_scene.ForEachScenePresence(delegate(ScenePresence presence) { - ScenePresence presence = presences[i]; if (!presence.IsChildAgent) presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); - } + }); } /// diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 4f03b0e428..be897409e8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -358,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer { ScenePresence presence; - if (s.TryGetAvatar(agentID, out presence)) + if (s.TryGetScenePresence(agentID, out presence)) { // If the agent is in this scene, then we // are being called twice in a single diff --git a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs index 63a93aa026..c011776ff9 100644 --- a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs +++ b/OpenSim/Region/CoreModules/Avatar/ObjectCaps/ObjectAdd.cs @@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps responsedata["str_response_string"] = "Request wasn't what was expected"; ScenePresence avatar; - if (!m_scene.TryGetAvatar(AgentId, out avatar)) + if (!m_scene.TryGetScenePresence(AgentId, out avatar)) return responsedata; diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 25f5154389..93aeb9440f 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -190,7 +190,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (account == null) // foreign { ScenePresence sp = null; - if (m_Scene.TryGetAvatar(userID, out sp)) + if (m_Scene.TryGetScenePresence(userID, out sp)) { AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs index 8cf4619782..e95d2f8fef 100644 --- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs +++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs @@ -1206,7 +1206,7 @@ namespace OpenSim.Region.CoreModules.InterGrid { Scene homeScene = GetRootScene(); ScenePresence avatar = null; - if (homeScene.TryGetAvatar(avatarId,out avatar)) + if (homeScene.TryGetScenePresence(avatarId,out avatar)) { KillAUser ku = new KillAUser(avatar,mod); Watchdog.StartThread(ku.ShutdownNoLogout, "OGPShutdown", ThreadPriority.Normal, true); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs index bd9f387215..33e78cf384 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs @@ -427,7 +427,7 @@ namespace OpenSim.Region.Examples.RegionSyncModule private void EventManager_OnRemovePresence(UUID agentID) { ScenePresence avatar; - if (m_scene.TryGetAvatar(agentID, out avatar)) + if (m_scene.TryGetScenePresence(agentID, out avatar)) { m_log.WarnFormat("[REGION SYNC SERVER MODULE] Avatar \"{0}\" (1) {2} has left the scene", avatar.Firstname + " " + avatar.Lastname, agentID.ToString(), avatar.UUID.ToString()); } diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 643764fa12..678e7723ff 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -285,24 +285,22 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture return; } - byte[] assetData; + byte[] assetData = null; AssetBase oldAsset = null; if (BlendWithOldTexture) { - UUID lastTextureID = part.Shape.Textures.DefaultTexture.TextureID; - oldAsset = scene.AssetService.Get(lastTextureID.ToString()); - if (oldAsset != null) + Primitive.TextureEntryFace defaultFace = part.Shape.Textures.DefaultTexture; + if (defaultFace != null) { - assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha); - } - else - { - assetData = new byte[data.Length]; - Array.Copy(data, assetData, data.Length); + oldAsset = scene.AssetService.Get(defaultFace.TextureID.ToString()); + + if (oldAsset != null) + assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha); } } - else + + if (assetData == null) { assetData = new byte[data.Length]; Array.Copy(data, assetData, data.Length); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index c6312e05cd..54508ccfa8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -502,7 +502,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory private UUID GetSessionID(UUID userID) { ScenePresence sp = null; - if (m_Scene.TryGetAvatar(userID, out sp)) + if (m_Scene.TryGetScenePresence(userID, out sp)) { return sp.ControllingClient.SessionId; } @@ -521,7 +521,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (account == null) // foreign user { ScenePresence sp = null; - m_Scene.TryGetAvatar(userID, out sp); + m_Scene.TryGetScenePresence(userID, out sp); if (sp != null) { AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs index 3c3534f5dc..5e06580cce 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs @@ -100,7 +100,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory ScenePresence sp = null; foreach (Scene s in m_Scenes) { - s.TryGetAvatar(clientID, out sp); + s.TryGetScenePresence(clientID, out sp); if ((sp != null) && !sp.IsChildAgent && (s != scene)) { m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping system folders in cache", diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index e98df286fc..7a75a89f4c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -88,7 +88,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence Vector3 position = new Vector3(128, 128, 0); Vector3 lookat = new Vector3(0, 1, 0); - if (client.Scene.TryGetAvatar(client.AgentId, out sp)) + if (client.Scene.TryGetScenePresence(client.AgentId, out sp)) { if (sp is ScenePresence) { diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index e3bab2d2e7..91d40ab54a 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -468,28 +468,20 @@ namespace OpenSim.Region.CoreModules.World.Estate private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID) { - // Get a fresh list that will not change as people get teleported away - ScenePresence[] presences = m_scene.GetScenePresences(); - - for (int i = 0; i < presences.Length; i++) + m_scene.ForEachScenePresence(delegate(ScenePresence sp) { - ScenePresence p = presences[i]; - - if (p.UUID != senderID) + if (sp.UUID != senderID) { + ScenePresence p = m_scene.GetScenePresence(sp.UUID); // make sure they are still there, we could be working down a long list - ScenePresence s = m_scene.GetScenePresence(p.UUID); - if (s != null) + // Also make sure they are actually in the region + if (p != null && !p.IsChildAgent) { - // Also make sure they are actually in the region - if (!s.IsChildAgent) - { - s.ControllingClient.SendTeleportLocationStart(); - m_scene.TeleportClientHome(s.UUID, s.ControllingClient); - } + p.ControllingClient.SendTeleportLocationStart(); + m_scene.TeleportClientHome(p.UUID, p.ControllingClient); } } - } + }); } private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID) { @@ -767,12 +759,11 @@ namespace OpenSim.Region.CoreModules.World.Estate public void sendRegionInfoPacketToAll() { - List avatars = m_scene.GetAvatars(); - - for (int i = 0; i < avatars.Count; i++) + m_scene.ForEachScenePresence(delegate(ScenePresence sp) { - HandleRegionInfoRequest(avatars[i].ControllingClient); - } + if (!sp.IsChildAgent) + HandleRegionInfoRequest(sp.ControllingClient); + }); } public void sendRegionHandshake(IClientAPI remoteClient) diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 1279ac1ad5..5750aa42fc 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -191,9 +191,9 @@ namespace OpenSim.Region.CoreModules.World.Land forcedPosition = null; } //if we are far away, teleport - else if (Vector3.Distance(clientAvatar.AbsolutePosition,forcedPosition.Value) > 3) + else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition.Value) > 3) { - Debug.WriteLine(string.Format("Teleporting out because {0} is too far from avatar position {1}",forcedPosition.Value,clientAvatar.AbsolutePosition)); + Debug.WriteLine(string.Format("Teleporting out because {0} is too far from avatar position {1}", forcedPosition.Value, clientAvatar.AbsolutePosition)); clientAvatar.Teleport(forcedPosition.Value); forcedPosition = null; } @@ -374,30 +374,27 @@ namespace OpenSim.Region.CoreModules.World.Land } } - public void SendOutNearestBanLine(IClientAPI avatar) + public void SendOutNearestBanLine(IClientAPI client) { - List avatars = m_scene.GetAvatars(); - foreach (ScenePresence presence in avatars) + ScenePresence sp = m_scene.GetScenePresence(client.AgentId); + if (sp == null || sp.IsChildAgent) + return; + + List checkLandParcels = ParcelsNearPoint(sp.AbsolutePosition); + foreach (ILandObject checkBan in checkLandParcels) { - if (presence.UUID == avatar.AgentId) + if (checkBan.IsBannedFromLand(client.AgentId)) { - List checkLandParcels = ParcelsNearPoint(presence.AbsolutePosition); - foreach (ILandObject checkBan in checkLandParcels) - { - if (checkBan.IsBannedFromLand(avatar.AgentId)) - { - checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar); - return; //Only send one - } - if (checkBan.IsRestrictedFromLand(avatar.AgentId)) - { - checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar); - return; //Only send one - } - } - return; + checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, client); + return; //Only send one + } + if (checkBan.IsRestrictedFromLand(client.AgentId)) + { + checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, client); + return; //Only send one } } + return; } public void SendLandUpdate(ScenePresence avatar, bool force) diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index e85136ae17..aca551479f 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -332,36 +332,38 @@ namespace OpenSim.Region.CoreModules.World.Land public void SendLandUpdateToAvatarsOverMe(bool snap_selection) { - List avatars = m_scene.GetAvatars(); - ILandObject over = null; - for (int i = 0; i < avatars.Count; i++) + m_scene.ForEachScenePresence(delegate(ScenePresence avatar) { + if (avatar.IsChildAgent) + return; + + ILandObject over = null; try { over = - m_scene.LandChannel.GetLandObject(Util.Clamp((int)Math.Round(avatars[i].AbsolutePosition.X), 0, ((int)Constants.RegionSize - 1)), - Util.Clamp((int)Math.Round(avatars[i].AbsolutePosition.Y), 0, ((int)Constants.RegionSize - 1))); + m_scene.LandChannel.GetLandObject(Util.Clamp((int)Math.Round(avatar.AbsolutePosition.X), 0, ((int)Constants.RegionSize - 1)), + Util.Clamp((int)Math.Round(avatar.AbsolutePosition.Y), 0, ((int)Constants.RegionSize - 1))); } catch (Exception) { - m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + - Math.Round(avatars[i].AbsolutePosition.Y)); + m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " + + Math.Round(avatar.AbsolutePosition.Y)); } if (over != null) { if (over.LandData.LocalID == LandData.LocalID) { - if (((over.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) && + if (((over.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) && m_scene.RegionInfo.RegionSettings.AllowDamage) - avatars[i].Invulnerable = false; + avatar.Invulnerable = false; else - avatars[i].Invulnerable = true; + avatar.Invulnerable = true; - SendLandUpdateToClient(snap_selection, avatars[i].ControllingClient); + SendLandUpdateToClient(snap_selection, avatar.ControllingClient); } } - } + }); } #endregion @@ -892,7 +894,7 @@ namespace OpenSim.Region.CoreModules.World.Land foreach (List ol in returns.Values) { - if (m_scene.Permissions.CanUseObjectReturn(this, type, remote_client, ol)) + if (m_scene.Permissions.CanReturnObjects(this, remote_client.AgentId, ol)) m_scene.returnObjects(ol.ToArray(), remote_client.AgentId); } } diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 5c7f3b7225..0f830e12a1 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -217,7 +217,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; //FULLY IMPLEMENTED m_scene.Permissions.OnMoveObject += CanMoveObject; //MAYBE FULLY IMPLEMENTED m_scene.Permissions.OnObjectEntry += CanObjectEntry; - m_scene.Permissions.OnReturnObject += CanReturnObject; //NOT YET IMPLEMENTED + m_scene.Permissions.OnReturnObjects += CanReturnObjects; //NOT YET IMPLEMENTED m_scene.Permissions.OnRezObject += CanRezObject; //MAYBE FULLY IMPLEMENTED m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; m_scene.Permissions.OnRunScript += CanRunScript; //NOT YET IMPLEMENTED @@ -247,7 +247,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; //NOT YET IMPLEMENTED m_scene.Permissions.OnTeleport += CanTeleport; //NOT YET IMPLEMENTED - m_scene.Permissions.OnUseObjectReturn += CanUseObjectReturn; //NOT YET IMPLEMENTED m_scene.AddCommand(this, "bypass permissions", "bypass permissions ", @@ -1275,12 +1274,106 @@ namespace OpenSim.Region.CoreModules.World.Permissions return false; } - private bool CanReturnObject(UUID objectID, UUID returnerID, Scene scene) + private bool CanReturnObjects(ILandObject land, UUID user, List objects, Scene scene) { DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); if (m_bypassPermissions) return m_bypassPermissionsValue; - return GenericObjectPermission(returnerID, objectID, false); + GroupPowers powers; + ILandObject l; + + ScenePresence sp = scene.GetScenePresence(user); + if (sp == null) + return false; + + IClientAPI client = sp.ControllingClient; + + foreach (SceneObjectGroup g in new List(objects)) + { + // Any user can return their own objects at any time + // + if (GenericObjectPermission(user, g.UUID, false)) + continue; + + // This is a short cut for efficiency. If land is non-null, + // then all objects are on that parcel and we can save + // ourselves the checking for each prim. Much faster. + // + if (land != null) + { + l = land; + } + else + { + Vector3 pos = g.AbsolutePosition; + + l = scene.LandChannel.GetLandObject(pos.X, pos.Y); + } + + // If it's not over any land, then we can't do a thing + if (l == null) + { + objects.Remove(g); + continue; + } + + // If we own the land outright, then allow + // + if (l.LandData.OwnerID == user) + continue; + + // Group voodoo + // + if (l.LandData.IsGroupOwned) + { + powers = (GroupPowers)client.GetGroupPowers(l.LandData.GroupID); + // Not a group member, or no rights at all + // + if (powers == (GroupPowers)0) + { + objects.Remove(g); + continue; + } + + // Group deeded object? + // + if (g.OwnerID == l.LandData.GroupID && + (powers & GroupPowers.ReturnGroupOwned) == (GroupPowers)0) + { + objects.Remove(g); + continue; + } + + // Group set object? + // + if (g.GroupID == l.LandData.GroupID && + (powers & GroupPowers.ReturnGroupSet) == (GroupPowers)0) + { + objects.Remove(g); + continue; + } + + if ((powers & GroupPowers.ReturnNonGroup) == (GroupPowers)0) + { + objects.Remove(g); + continue; + } + + // So we can remove all objects from this group land. + // Fine. + // + continue; + } + + // By default, we can't remove + // + objects.Remove(g); + } + + if (objects.Count == 0) + return false; + + return true; } private bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene) @@ -1747,67 +1840,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions return GenericObjectPermission(agentID, prim, false); } - private bool CanUseObjectReturn(ILandObject parcel, uint type, IClientAPI client, List retlist, Scene scene) - { - DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); - if (m_bypassPermissions) return m_bypassPermissionsValue; - - long powers = 0; - if (parcel.LandData.GroupID != UUID.Zero) - client.GetGroupPowers(parcel.LandData.GroupID); - - switch (type) - { - case (uint)ObjectReturnType.Owner: - // Don't let group members return owner's objects, ever - // - if (parcel.LandData.IsGroupOwned) - { - if ((powers & (long)GroupPowers.ReturnGroupOwned) != 0) - return true; - } - else - { - if (parcel.LandData.OwnerID != client.AgentId) - return false; - } - return GenericParcelOwnerPermission(client.AgentId, parcel, (ulong)GroupPowers.ReturnGroupOwned); - case (uint)ObjectReturnType.Group: - if (parcel.LandData.OwnerID != client.AgentId) - { - // If permissionis granted through a group... - // - if ((powers & (long)GroupPowers.ReturnGroupSet) != 0) - { - foreach (SceneObjectGroup g in new List(retlist)) - { - // check for and remove group owned objects unless - // the user also has permissions to return those - // - if (g.OwnerID == g.GroupID && - ((powers & (long)GroupPowers.ReturnGroupOwned) == 0)) - { - retlist.Remove(g); - } - } - // And allow the operation - // - return true; - } - } - return GenericParcelOwnerPermission(client.AgentId, parcel, (ulong)GroupPowers.ReturnGroupSet); - case (uint)ObjectReturnType.Other: - if ((powers & (long)GroupPowers.ReturnNonGroup) != 0) - return true; - return GenericParcelOwnerPermission(client.AgentId, parcel, (ulong)GroupPowers.ReturnNonGroup); - case (uint)ObjectReturnType.List: - break; - } - - return GenericParcelOwnerPermission(client.AgentId, parcel, 0); - // Is it correct to be less restrictive for lists of objects to be returned? - } - private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) { //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType); switch (scriptType) { diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index 1f5a4ffad4..a52fea46fc 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs @@ -62,40 +62,46 @@ namespace OpenSim.Region.CoreModules.World.Sound public virtual void PlayAttachedSound( UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius) { - foreach (ScenePresence p in m_scene.GetAvatars()) + m_scene.ForEachScenePresence(delegate(ScenePresence sp) { - double dis = Util.GetDistanceTo(p.AbsolutePosition, position); + if (sp.IsChildAgent) + return; + + double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); if (dis > 100.0) // Max audio distance - continue; - + return; + // Scale by distance if (radius == 0) gain = (float)((double)gain * ((100.0 - dis) / 100.0)); else gain = (float)((double)gain * ((radius - dis) / radius)); - - p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags); - } + + sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags); + }); } public virtual void TriggerSound( UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) { - foreach (ScenePresence p in m_scene.GetAvatars()) + m_scene.ForEachScenePresence(delegate(ScenePresence sp) { - double dis = Util.GetDistanceTo(p.AbsolutePosition, position); + if (sp.IsChildAgent) + return; + + double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); if (dis > 100.0) // Max audio distance - continue; - + return; + // Scale by distance if (radius == 0) gain = (float)((double)gain * ((100.0 - dis) / 100.0)); else gain = (float)((double)gain * ((radius - dis) / radius)); - - p.ControllingClient.SendTriggeredSound( + + sp.ControllingClient.SendTriggeredSound( soundId, ownerID, objectID, parentID, handle, position, (float)gain); - } + }); } } } diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index 0712a7fabc..a6dc2ec79a 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs @@ -509,14 +509,13 @@ namespace OpenSim.Region.CoreModules private void SunUpdateToAllClients() { - List avatars = m_scene.GetAvatars(); - foreach (ScenePresence avatar in avatars) + m_scene.ForEachScenePresence(delegate(ScenePresence sp) { - if (!avatar.IsChildAgent) + if (!sp.IsChildAgent) { - SunToClient(avatar.ControllingClient); + SunToClient(sp.ControllingClient); } - } + }); } #region ISunModule Members diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index 3283c1ffa7..9736b73adf 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs @@ -425,9 +425,7 @@ namespace OpenSim.Region.CoreModules { if (m_ready) { - List avatars = m_scene.GetAvatars(); - - if (avatars.Count > 0) + if(m_scene.GetRootAgentCount() > 0) { // Ask wind plugin to generate a LL wind array to be cached locally // Try not to update this too often, as it may involve array copies @@ -437,11 +435,11 @@ namespace OpenSim.Region.CoreModules m_frameLastUpdateClientArray = m_frame; } - foreach (ScenePresence avatar in avatars) + m_scene.ForEachScenePresence(delegate(ScenePresence sp) { - if (!avatar.IsChildAgent) - avatar.ControllingClient.SendWindData(windSpeeds); - } + if (!sp.IsChildAgent) + sp.ControllingClient.SendWindData(windSpeeds); + }); } } } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs index 285d36a3d6..b71b5f61a5 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs @@ -251,13 +251,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // if you want tree blocks on the map comment the above line and uncomment the below line //mapdotspot = Color.PaleGreen; - if (part.Shape.Textures == null) + Primitive.TextureEntry textureEntry = part.Shape.Textures; + + if (textureEntry == null || textureEntry.DefaultTexture == null) continue; - if (part.Shape.Textures.DefaultTexture == null) - continue; - - Color4 texcolor = part.Shape.Textures.DefaultTexture.RGBA; + Color4 texcolor = textureEntry.DefaultTexture.RGBA; // Not sure why some of these are null, oh well. diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index b63d014923..2b0e83f52f 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // this is here because CAPS map requests work even beyond the 10,000 limit. ScenePresence avatarPresence = null; - m_scene.TryGetAvatar(agentID, out avatarPresence); + m_scene.TryGetScenePresence(agentID, out avatarPresence); if (avatarPresence != null) { @@ -304,25 +304,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap /// AgentID that logged out private void ClientLoggedOut(UUID AgentId, Scene scene) { - List presences = m_scene.GetAvatars(); - int rootcount = 0; - for (int i=0;i avatars = m_scene.GetAvatars(); int tc = Environment.TickCount; List mapitems = new List(); mapItemReply mapitem = new mapItemReply(); - if (avatars.Count == 0 || avatars.Count == 1) + if (m_scene.GetRootAgentCount() <= 1) { mapitem = new mapItemReply(); mapitem.x = (uint)(xstart + 1); @@ -392,21 +377,21 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } else { - foreach (ScenePresence av in avatars) + m_scene.ForEachScenePresence(delegate(ScenePresence sp) { // Don't send a green dot for yourself - if (av.UUID != remoteClient.AgentId) + if (!sp.IsChildAgent && sp.UUID != remoteClient.AgentId) { mapitem = new mapItemReply(); - mapitem.x = (uint)(xstart + av.AbsolutePosition.X); - mapitem.y = (uint)(ystart + av.AbsolutePosition.Y); + mapitem.x = (uint)(xstart + sp.AbsolutePosition.X); + mapitem.y = (uint)(ystart + sp.AbsolutePosition.Y); mapitem.id = UUID.Zero; mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()); mapitem.Extra = 1; mapitem.Extra2 = 0; mapitems.Add(mapitem); } - } + }); } remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); } @@ -504,7 +489,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap if (mrs.agentID != UUID.Zero) { ScenePresence av = null; - m_scene.TryGetAvatar(mrs.agentID, out av); + m_scene.TryGetScenePresence(mrs.agentID, out av); if (av != null) { if (response.ContainsKey(mrs.itemtype.ToString())) @@ -981,51 +966,35 @@ namespace OpenSim.Region.CoreModules.World.WorldMap Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart); OSDMap responsemap = new OSDMap(); - List avatars = m_scene.GetAvatars(); - OSDArray responsearr = new OSDArray(avatars.Count); - OSDMap responsemapdata = new OSDMap(); int tc = Environment.TickCount; - /* - foreach (ScenePresence av in avatars) + if (m_scene.GetRootAgentCount() == 0) { - responsemapdata = new OSDMap(); - responsemapdata["X"] = OSD.FromInteger((int)(xstart + av.AbsolutePosition.X)); - responsemapdata["Y"] = OSD.FromInteger((int)(ystart + av.AbsolutePosition.Y)); - responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); - responsemapdata["Name"] = OSD.FromString("TH"); - responsemapdata["Extra"] = OSD.FromInteger(0); - responsemapdata["Extra2"] = OSD.FromInteger(0); - responsearr.Add(responsemapdata); - } - responsemap["1"] = responsearr; - */ - if (avatars.Count == 0) - { - responsemapdata = new OSDMap(); + OSDMap responsemapdata = new OSDMap(); responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1)); responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1)); responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString())); responsemapdata["Extra"] = OSD.FromInteger(0); responsemapdata["Extra2"] = OSD.FromInteger(0); + OSDArray responsearr = new OSDArray(); responsearr.Add(responsemapdata); responsemap["6"] = responsearr; } else { - responsearr = new OSDArray(avatars.Count); - foreach (ScenePresence av in avatars) + OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); + m_scene.ForEachScenePresence(delegate(ScenePresence sp) { - responsemapdata = new OSDMap(); - responsemapdata["X"] = OSD.FromInteger((int)(xstart + av.AbsolutePosition.X)); - responsemapdata["Y"] = OSD.FromInteger((int)(ystart + av.AbsolutePosition.Y)); + OSDMap responsemapdata = new OSDMap(); + responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X)); + responsemapdata["Y"] = OSD.FromInteger((int)(ystart + sp.AbsolutePosition.Y)); responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString())); responsemapdata["Extra"] = OSD.FromInteger(1); responsemapdata["Extra2"] = OSD.FromInteger(0); responsearr.Add(responsemapdata); - } + }); responsemap["6"] = responsearr; } return responsemap; @@ -1107,25 +1076,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap private void MakeChildAgent(ScenePresence avatar) { - List presences = m_scene.GetAvatars(); - int rootcount = 0; - for (int i = 0; i < presences.Count; i++) - { - if (presences[i] != null) - { - if (!presences[i].IsChildAgent) - rootcount++; - } - } - if (rootcount <= 1) - StopThread(); - lock (m_rootAgents) { - if (m_rootAgents.Contains(avatar.UUID)) - { - m_rootAgents.Remove(avatar.UUID); - } + m_rootAgents.Remove(avatar.UUID); + if (m_rootAgents.Count == 0) + StopThread(); } } diff --git a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs index 76dac6107e..f441aa9a84 100644 --- a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs +++ b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs @@ -203,44 +203,54 @@ namespace OpenSim.Region.DataSnapshot.Providers { string bestguess = string.Empty; Dictionary counts = new Dictionary(); - if (sog.RootPart.Shape != null && sog.RootPart.Shape.ProfileShape == ProfileShape.Square && - sog.RootPart.Shape.Textures != null && sog.RootPart.Shape.Textures.FaceTextures != null) - { - if (sog.RootPart.Shape.Textures.DefaultTexture.TextureID != UUID.Zero && - sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_DefaultImage && - sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_BlankImage && - sog.RootPart.Shape.Textures.DefaultTexture.RGBA.A < 50) - { - counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = 8; - } - foreach (Primitive.TextureEntryFace tentry in sog.RootPart.Shape.Textures.FaceTextures) + PrimitiveBaseShape shape = sog.RootPart.Shape; + if (shape != null && shape.ProfileShape == ProfileShape.Square) + { + Primitive.TextureEntry textures = shape.Textures; + if (textures != null) { - if (tentry != null) + if (textures.DefaultTexture != null && + textures.DefaultTexture.TextureID != UUID.Zero && + textures.DefaultTexture.TextureID != m_DefaultImage && + textures.DefaultTexture.TextureID != m_BlankImage && + textures.DefaultTexture.RGBA.A < 50f) { - if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50) + counts[textures.DefaultTexture.TextureID] = 8; + } + + if (textures.FaceTextures != null) + { + foreach (Primitive.TextureEntryFace tentry in textures.FaceTextures) { - int c = 0; - counts.TryGetValue(tentry.TextureID, out c); - counts[tentry.TextureID] = c + 1; - // decrease the default texture count - if (counts.ContainsKey(sog.RootPart.Shape.Textures.DefaultTexture.TextureID)) - counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] - 1; + if (tentry != null) + { + if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50) + { + int c = 0; + counts.TryGetValue(tentry.TextureID, out c); + counts[tentry.TextureID] = c + 1; + // decrease the default texture count + if (counts.ContainsKey(textures.DefaultTexture.TextureID)) + counts[textures.DefaultTexture.TextureID] = counts[textures.DefaultTexture.TextureID] - 1; + } + } + } + } + + // Let's pick the most unique texture + int min = 9999; + foreach (KeyValuePair kv in counts) + { + if (kv.Value < min && kv.Value >= 1) + { + bestguess = kv.Key.ToString(); + min = kv.Value; } } } - - // Let's pick the most unique texture - int min = 9999; - foreach (KeyValuePair kv in counts) - { - if (kv.Value < min && kv.Value >= 1) - { - bestguess = kv.Key.ToString(); - min = kv.Value; - } - } } + return bestguess; } } diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs index e1d5bdc0b2..6da41db45a 100644 --- a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs +++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs @@ -88,12 +88,12 @@ namespace OpenSim.Region.Examples.SimpleModule m_scene.AgentCrossing(m_character.AgentId, Vector3.Zero, false); } - List avatars = m_scene.GetAvatars(); - foreach (ScenePresence avatar in avatars) + m_scene.ForEachScenePresence(delegate(ScenePresence sp) { - avatar.AbsolutePosition = - new Vector3((float)Util.RandomClass.Next(100, 200), (float)Util.RandomClass.Next(30, 200), 2); - } + if (!sp.IsChildAgent) + sp.AbsolutePosition = + new Vector3((float)Util.RandomClass.Next(100, 200), (float)Util.RandomClass.Next(30, 200), 2); + }); } // private void AddComplexObjects(RegionInfo regionInfo, Vector3 pos) diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs index 668ff98f7b..87c7a05f6d 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; @@ -34,7 +35,12 @@ namespace OpenSim.Region.Framework.Interfaces { void Initialise(string connectstring); - EstateSettings LoadEstateSettings(UUID regionID); + EstateSettings LoadEstateSettings(UUID regionID, bool create); + EstateSettings LoadEstateSettings(int estateID); void StoreEstateSettings(EstateSettings es); + List GetEstates(string search); + bool LinkRegion(UUID regionID, int estateID); + List GetRegions(int estateID); + bool DeleteEstate(int estateID); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 41533a1ef8..31c0be1aff 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -132,7 +132,7 @@ namespace OpenSim.Region.Framework.Scenes { ScenePresence avatar; - if (TryGetAvatar(avatarId, out avatar)) + if (TryGetScenePresence(avatarId, out avatar)) { IInventoryAccessModule invAccess = RequestModuleInterface(); if (invAccess != null) @@ -230,7 +230,7 @@ namespace OpenSim.Region.Framework.Scenes { ScenePresence avatar; - if (TryGetAvatar(avatarId, out avatar)) + if (TryGetScenePresence(avatarId, out avatar)) { return CapsUpdateTaskInventoryScriptAsset( avatar.ControllingClient, itemId, primId, isScriptRunning, data); @@ -683,7 +683,7 @@ namespace OpenSim.Region.Framework.Scenes if (transactionID == UUID.Zero) { ScenePresence presence; - if (TryGetAvatar(remoteClient.AgentId, out presence)) + if (TryGetScenePresence(remoteClient.AgentId, out presence)) { byte[] data = null; @@ -941,7 +941,7 @@ namespace OpenSim.Region.Framework.Scenes { ScenePresence avatar; - if (TryGetAvatar(avatarId, out avatar)) + if (TryGetScenePresence(avatarId, out avatar)) { return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); } @@ -1055,7 +1055,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence avatar; - if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) + if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) { destPart.GetProperties(avatar.ControllingClient); } @@ -1083,7 +1083,7 @@ namespace OpenSim.Region.Framework.Scenes } ScenePresence avatar = null; - if (TryGetAvatar(destID, out avatar)) + if (TryGetScenePresence(destID, out avatar)) { //profile.SendInventoryDecendents(avatar.ControllingClient, // profile.RootFolder.ID, true, false); @@ -1420,7 +1420,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence avatar; - if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) + if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) { destPart.GetProperties(avatar.ControllingClient); } @@ -1518,9 +1518,10 @@ namespace OpenSim.Region.Framework.Scenes if (remoteClient != null) { permissionToTake = - Permissions.CanReturnObject( - grp.UUID, - remoteClient.AgentId); + Permissions.CanReturnObjects( + null, + remoteClient.AgentId, + new List() {grp}); permissionToDelete = permissionToTake; if (permissionToDelete) @@ -1860,7 +1861,7 @@ namespace OpenSim.Region.Framework.Scenes UUID inventoryID = part.ParentGroup.GetFromItemID(); ScenePresence presence; - if (TryGetAvatar(remoteClient.AgentId, out presence)) + if (TryGetScenePresence(remoteClient.AgentId, out presence)) { if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) return; diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index d1d6b6a377..7dab04fbd2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene); public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); - public delegate bool ReturnObjectHandler(UUID objectID, UUID returnerID, Scene scene); + public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List objects, Scene scene); public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene); public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene); public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene); @@ -81,7 +81,6 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool CopyUserInventoryHandler(UUID itemID, UUID userID); public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID); public delegate bool TeleportHandler(UUID userID, Scene scene); - public delegate bool UseObjectReturnHandler(ILandObject landData, uint type, IClientAPI client, List retlist, Scene scene); #endregion public class ScenePermissions @@ -107,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes public event EditObjectInventoryHandler OnEditObjectInventory; public event MoveObjectHandler OnMoveObject; public event ObjectEntryHandler OnObjectEntry; - public event ReturnObjectHandler OnReturnObject; + public event ReturnObjectsHandler OnReturnObjects; public event InstantMessageHandler OnInstantMessage; public event InventoryTransferHandler OnInventoryTransfer; public event ViewScriptHandler OnViewScript; @@ -140,7 +139,6 @@ namespace OpenSim.Region.Framework.Scenes public event CopyUserInventoryHandler OnCopyUserInventory; public event DeleteUserInventoryHandler OnDeleteUserInventory; public event TeleportHandler OnTeleport; - public event UseObjectReturnHandler OnUseObjectReturn; #endregion #region Object Permission Checks @@ -377,15 +375,15 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region RETURN OBJECT - public bool CanReturnObject(UUID objectID, UUID returnerID) + public bool CanReturnObjects(ILandObject land, UUID user, List objects) { - ReturnObjectHandler handler = OnReturnObject; + ReturnObjectsHandler handler = OnReturnObjects; if (handler != null) { Delegate[] list = handler.GetInvocationList(); - foreach (ReturnObjectHandler h in list) + foreach (ReturnObjectsHandler h in list) { - if (h(objectID, returnerID, m_scene) == false) + if (h(land, user, objects, m_scene) == false) return false; } } @@ -949,20 +947,5 @@ namespace OpenSim.Region.Framework.Scenes } return true; } - - public bool CanUseObjectReturn(ILandObject landData, uint type , IClientAPI client, List retlist) - { - UseObjectReturnHandler handler = OnUseObjectReturn; - if (handler != null) - { - Delegate[] list = handler.GetInvocationList(); - foreach (UseObjectReturnHandler h in list) - { - if (h(landData, type, client, retlist, m_scene) == false) - return false; - } - } - return true; - } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2c33aacc94..5fbb3d8d07 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -131,7 +131,6 @@ namespace OpenSim.Region.Framework.Scenes private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing private int m_incrementsof15seconds; private volatile bool m_backingup; - private bool m_useAsyncWhenPossible; private Dictionary m_returns = new Dictionary(); private Dictionary m_groupsWithTargets = new Dictionary(); @@ -632,7 +631,44 @@ namespace OpenSim.Region.Framework.Scenes m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); if (m_storageManager.EstateDataStore != null) { - m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); + m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); + if (m_regInfo.EstateSettings.EstateID == 0) // No record at all + { + MainConsole.Instance.Output("Your region is not part of an estate."); + 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 + m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true); + + m_regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", m_regInfo.EstateSettings.EstateName); + m_regInfo.EstateSettings.Save(); + break; + } + else + { + response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); + if (response == "None") + continue; + + List estateIDs = m_storageManager.EstateDataStore.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]; + + if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID)) + break; + + MainConsole.Instance.Output("Joining the estate failed. Please try again."); + } + } + } } //Bind Storage Manager functions to some land manager functions for this scene @@ -681,9 +717,6 @@ namespace OpenSim.Region.Framework.Scenes // IConfig startupConfig = m_config.Configs["Startup"]; - // Should we try to run loops synchronously or asynchronously? - m_useAsyncWhenPossible = startupConfig.GetBoolean("use_async_when_possible", false); - //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); // TODO: Change default to true once the feature is supported @@ -1248,6 +1281,82 @@ namespace OpenSim.Region.Framework.Scenes m_teleportModule = RequestModuleInterface(); RegionSyncServerModule = RequestModuleInterface(); RegionSyncClientModule = RequestModuleInterface(); + + // Shoving this in here for now, because we have the needed + // interfaces at this point + // + // TODO: Find a better place for this + // + while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero) + { + MainConsole.Instance.Output("The current estate has no owner set."); + string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test"); + string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User"); + + UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last); + + if (account == null) + { + account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty); + if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) + { + account.ServiceURLs = new Dictionary(); + account.ServiceURLs["HomeURI"] = string.Empty; + account.ServiceURLs["GatekeeperURI"] = string.Empty; + account.ServiceURLs["InventoryServerURI"] = string.Empty; + account.ServiceURLs["AssetServerURI"] = string.Empty; + } + + if (UserAccountService.StoreUserAccount(account)) + { + string password = MainConsole.Instance.PasswdPrompt("Password"); + string email = MainConsole.Instance.CmdPrompt("Email", ""); + + account.Email = email; + UserAccountService.StoreUserAccount(account); + + bool success = false; + success = AuthenticationService.SetPassword(account.PrincipalID, password); + if (!success) + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", + first, last); + + GridRegion home = null; + if (GridService != null) + { + List defaultRegions = GridService.GetDefaultRegions(UUID.Zero); + if (defaultRegions != null && defaultRegions.Count >= 1) + home = defaultRegions[0]; + + if (PresenceService != null && home != null) + PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); + else + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", + first, last); + + } + else + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", + first, last); + + if (InventoryService != null) + success = InventoryService.CreateUserInventory(account.PrincipalID); + if (!success) + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", + first, last); + + + m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last); + + m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; + m_regInfo.EstateSettings.Save(); + } + } + else + { + MainConsole.Instance.Output("You appear to be connected to a grid and can't create users from here. Please enter the name of an existing user"); + } + } } #endregion @@ -3323,7 +3432,7 @@ namespace OpenSim.Region.Framework.Scenes } } - ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); + ScenePresence sp = GetScenePresence(agent.AgentID); if (sp != null) { m_log.DebugFormat( @@ -3615,8 +3724,7 @@ namespace OpenSim.Region.Framework.Scenes /// message to display to the user. Reason for being logged off public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) { - ScenePresence loggingOffUser = null; - loggingOffUser = GetScenePresence(AvatarID); + ScenePresence loggingOffUser = GetScenePresence(AvatarID); if (loggingOffUser != null) { UUID localRegionSecret = UUID.Zero; @@ -3652,10 +3760,8 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) { - ScenePresence presence; - m_sceneGraph.TryGetAvatar(agentID, out presence); - - if (presence != null) + ScenePresence presence = GetScenePresence(agentID); + if(presence != null) { try { @@ -3829,9 +3935,7 @@ namespace OpenSim.Region.Framework.Scenes public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) { - ScenePresence sp; - m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp); - + ScenePresence sp = GetScenePresence(remoteClient.AgentId); if (sp != null) { uint regionX = m_regInfo.RegionLocX; @@ -4010,17 +4114,17 @@ namespace OpenSim.Region.Framework.Scenes m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World"); - foreach (ScenePresence scenePresence in GetAvatars()) + ForEachScenePresence(delegate(ScenePresence sp) { m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", - scenePresence.Firstname, - scenePresence.Lastname, - scenePresence.UUID, - scenePresence.ControllingClient.AgentId, + sp.Firstname, + sp.Lastname, + sp.UUID, + sp.ControllingClient.AgentId, "Unknown", "Unknown", RegionInfo.RegionName); - } + }); break; } @@ -4186,48 +4290,45 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGraph.RemovePhysicalPrim(num); } - //The idea is to have a group of method that return a list of avatars meeting some requirement - // ie it could be all m_scenePresences within a certain range of the calling prim/avatar. - - /// - /// Return a list of all avatars in this region. - /// This list is a new object, so it can be iterated over without locking. - /// - /// - public List GetAvatars() + public int GetRootAgentCount() { - return m_sceneGraph.GetAvatars(); + return m_sceneGraph.GetRootAgentCount(); + } + + public int GetChildAgentCount() + { + return m_sceneGraph.GetChildAgentCount(); } /// - /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. - /// This list is a new object, so it can be iterated over without locking. + /// Request a scene presence by UUID. Fast, indexed lookup. /// - /// - public ScenePresence[] GetScenePresences() + /// + /// null if the presence was not found + public ScenePresence GetScenePresence(UUID agentID) { - return m_sceneGraph.GetScenePresences(); + return m_sceneGraph.GetScenePresence(agentID); } /// - /// Request a filtered list of ScenePresences in this region. - /// This list is a new object, so it can be iterated over without locking. + /// Request the scene presence by name. /// - /// - /// - public List GetScenePresences(FilterAvatarList filter) + /// + /// + /// null if the presence was not found + public ScenePresence GetScenePresence(string firstName, string lastName) { - return m_sceneGraph.GetScenePresences(filter); + return m_sceneGraph.GetScenePresence(firstName, lastName); } /// - /// Request a scene presence by UUID + /// Request the scene presence by localID. /// - /// - /// - public ScenePresence GetScenePresence(UUID avatarID) + /// + /// null if the presence was not found + public ScenePresence GetScenePresence(uint localID) { - return m_sceneGraph.GetScenePresence(avatarID); + return m_sceneGraph.GetScenePresence(localID); } public override bool PresenceChildStatus(UUID avatarID) @@ -4245,7 +4346,7 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// + /// Performs action on all scene presences. /// /// static int s_ForEachPresenceCounter = 0; @@ -4256,17 +4357,7 @@ namespace OpenSim.Region.Framework.Scenes // We don't want to try to send messages if there are no avatars. if (m_sceneGraph != null) { - try - { - ScenePresence[] presences = GetScenePresences(); - for (int i = 0; i < presences.Length; i++) - action(presences[i]); - } - catch (Exception e) - { - m_log.Info("[BUG] in " + RegionInfo.RegionName + ": " + e.ToString()); - m_log.Info("[BUG] Stack Trace: " + e.StackTrace); - } + m_sceneGraph.ForEachScenePresence(action); } } @@ -4330,9 +4421,9 @@ namespace OpenSim.Region.Framework.Scenes return m_sceneGraph.GetGroupByPrim(localID); } - public override bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) + public override bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) { - return m_sceneGraph.TryGetAvatar(avatarId, out avatar); + return m_sceneGraph.TryGetScenePresence(avatarId, out avatar); } public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) @@ -4345,24 +4436,7 @@ namespace OpenSim.Region.Framework.Scenes // REGION SYNC if (IsSyncedServer()) return; - - ForEachClient(action, m_useAsyncWhenPossible); - } - - public void ForEachClient(Action action, bool doAsynchronous) - { - // REGION SYNC - if (IsSyncedServer()) - return; - // FIXME: Asynchronous iteration is disabled until we have a threading model that - // can support calling this function from an async packet handler without - // potentially deadlocking m_clientManager.ForEachSync(action); - - //if (doAsynchronous) - // m_clientManager.ForEach(action); - //else - // m_clientManager.ForEachSync(action); } public bool TryGetClient(UUID avatarID, out IClientAPI client) diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 74476edd3e..3218dadc24 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -190,11 +190,11 @@ namespace OpenSim.Region.Framework.Scenes /// public abstract void RemoveClient(UUID agentID); - public bool TryGetAvatar(UUID agentID, out object scenePresence) + public bool TryGetScenePresence(UUID agentID, out object scenePresence) { scenePresence = null; ScenePresence sp = null; - if (TryGetAvatar(agentID, out sp)) + if (TryGetScenePresence(agentID, out sp)) { scenePresence = sp; return true; @@ -203,7 +203,7 @@ namespace OpenSim.Region.Framework.Scenes return false; } - public abstract bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence); + public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); #endregion diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index ce1d898752..53c8f05a66 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -165,9 +165,10 @@ namespace OpenSim.Region.Framework.Scenes protected internal void UpdatePresences() { - ScenePresence[] updateScenePresences = GetScenePresences(); - for (int i = 0; i < updateScenePresences.Length; i++) - updateScenePresences[i].Update(); + ForEachScenePresence(delegate(ScenePresence presence) + { + presence.Update(); + }); } protected internal float UpdatePhysics(double elapsed) @@ -196,9 +197,10 @@ namespace OpenSim.Region.Framework.Scenes protected internal void UpdateScenePresenceMovement() { - ScenePresence[] moveEntities = GetScenePresences(); - for (int i = 0; i < moveEntities.Length; i++) - moveEntities[i].UpdateMovement(); + ForEachScenePresence(delegate(ScenePresence presence) + { + presence.UpdateMovement(); + }); } #endregion @@ -616,18 +618,16 @@ namespace OpenSim.Region.Framework.Scenes public void RecalculateStats() { - ScenePresence[] presences = GetScenePresences(); int rootcount = 0; int childcount = 0; - for (int i = 0; i < presences.Length; i++) + ForEachScenePresence(delegate(ScenePresence presence) { - ScenePresence user = presences[i]; - if (user.IsChildAgent) + if (presence.IsChildAgent) ++childcount; else ++rootcount; - } + }); m_numRootAgents = rootcount; m_numChildAgents = childcount; @@ -674,25 +674,6 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region Get Methods - - /// - /// Request a List of all scene presences in this scene. This is a new list, so no - /// locking is required to iterate over it. - /// - /// - protected internal ScenePresence[] GetScenePresences() - { - return m_scenePresenceArray; - } - - protected internal List GetAvatars() - { - List result = - GetScenePresences(delegate(ScenePresence scenePresence) { return !scenePresence.IsChildAgent; }); - - return result; - } - /// /// Get the controlling client for the given avatar, if there is one. /// @@ -719,43 +700,85 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Request a filtered list of m_scenePresences in this World + /// Request a copy of m_scenePresences in this World + /// There is no guarantee that presences will remain in the scene after the list is returned. + /// This list should remain private to SceneGraph. Callers wishing to iterate should instead + /// pass a delegate to ForEachScenePresence. /// /// - protected internal List GetScenePresences(FilterAvatarList filter) + private List GetScenePresences() { - // No locking of scene presences here since we're passing back a list... - - List result = new List(); - ScenePresence[] scenePresences = GetScenePresences(); - - for (int i = 0; i < scenePresences.Length; i++) - { - ScenePresence avatar = scenePresences[i]; - if (filter(avatar)) - result.Add(avatar); - } - - return result; + lock (m_scenePresences) + return new List(m_scenePresenceArray); } /// - /// Request a scene presence by UUID + /// Request a scene presence by UUID. Fast, indexed lookup. /// - /// - /// null if the agent was not found + /// + /// null if the presence was not found protected internal ScenePresence GetScenePresence(UUID agentID) { ScenePresence sp; - lock (m_scenePresences) { m_scenePresences.TryGetValue(agentID, out sp); } - return sp; } + /// + /// Request the scene presence by name. + /// + /// + /// + /// null if the presence was not found + protected internal ScenePresence GetScenePresence(string firstName, string lastName) + { + foreach (ScenePresence presence in GetScenePresences()) + { + if (presence.Firstname == firstName && presence.Lastname == lastName) + return presence; + } + return null; + } + + /// + /// Request the scene presence by localID. + /// + /// + /// null if the presence was not found + protected internal ScenePresence GetScenePresence(uint localID) + { + foreach (ScenePresence presence in GetScenePresences()) + if (presence.LocalId == localID) + return presence; + return null; + } + + protected internal bool TryGetScenePresence(UUID agentID, out ScenePresence avatar) + { + lock (m_scenePresences) + { + m_scenePresences.TryGetValue(agentID, out avatar); + } + return (avatar != null); + } + + protected internal bool TryGetAvatarByName(string name, out ScenePresence avatar) + { + avatar = null; + foreach (ScenePresence presence in GetScenePresences()) + { + if (String.Compare(name, presence.ControllingClient.Name, true) == 0) + { + avatar = presence; + break; + } + } + return (avatar != null); + } + /// /// Get a scene object group that contains the prim with the given local id /// @@ -907,34 +930,6 @@ namespace OpenSim.Region.Framework.Scenes return group.GetChildPart(fullID); } - protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) - { - lock (m_scenePresences) - return m_scenePresences.TryGetValue(avatarId, out avatar); - } - - protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) - { - ScenePresence[] presences = GetScenePresences(); - - for (int i = 0; i < presences.Length; i++) - { - ScenePresence presence = presences[i]; - - if (!presence.IsChildAgent) - { - if (String.Compare(avatarName, presence.ControllingClient.Name, true) == 0) - { - avatar = presence; - return true; - } - } - } - - avatar = null; - return false; - } - /// /// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over /// it @@ -997,6 +992,10 @@ namespace OpenSim.Region.Framework.Scenes return UUID.Zero; } + /// + /// Performs action on all scene object groups. + /// + /// protected internal void ForEachSOG(Action action) { List objlist = new List(SceneObjectGroupsByFullID.Values); @@ -1013,6 +1012,46 @@ namespace OpenSim.Region.Framework.Scenes } } } + + + /// + /// Performs action on all scene presences. This can ultimately run the actions in parallel but + /// any delegates passed in will need to implement their own locking on data they reference and + /// modify outside of the scope of the delegate. + /// + /// + public void ForEachScenePresence(Action action) + { + // Once all callers have their delegates configured for parallelism, we can unleash this + /* + Action protectedAction = new Action(delegate(ScenePresence sp) + { + try + { + action(sp); + } + catch (Exception e) + { + m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); + m_log.Info("[BUG] Stack Trace: " + e.StackTrace); + } + }); + Parallel.ForEach(GetScenePresences(), protectedAction); + */ + // For now, perform actiona serially + foreach (ScenePresence sp in GetScenePresences()) + { + try + { + action(sp); + } + catch (Exception e) + { + m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); + m_log.Info("[BUG] Stack Trace: " + e.StackTrace); + } + } + } #endregion diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 680c39a622..3b8473469e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -414,12 +414,8 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - ScenePresence[] scenePresences = scene.GetScenePresences(); - - for (int i = 0; i < scenePresences.Length; i++) + scene.ForEachScenePresence(delegate(ScenePresence scenePresence) { - ScenePresence scenePresence = scenePresences[i]; - if (!scenePresence.IsChildAgent) { m_log.DebugFormat("Packet debug for {0} {1} set to {2}", @@ -429,7 +425,7 @@ namespace OpenSim.Region.Framework.Scenes scenePresence.ControllingClient.SetDebugPacketLevel(newDebug); } - } + }); } ); } @@ -441,14 +437,11 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - ScenePresence[] scenePresences = scene.GetScenePresences(); - - for (int i = 0; i < scenePresences.Length; i++) + scene.ForEachScenePresence(delegate(ScenePresence scenePresence) { - ScenePresence scenePresence = scenePresences[i]; if (!scenePresence.IsChildAgent) avatars.Add(scenePresence); - } + }); } ); @@ -461,8 +454,10 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene(delegate(Scene scene) { - ScenePresence[] scenePresences = scene.GetScenePresences(); - presences.AddRange(scenePresences); + scene.ForEachScenePresence(delegate(ScenePresence sp) + { + presences.Add(sp); + }); }); return presences; @@ -491,11 +486,11 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); }); } - public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) + public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) { foreach (Scene scene in m_localScenes) { - if (scene.TryGetAvatar(avatarId, out avatar)) + if (scene.TryGetScenePresence(avatarId, out avatar)) { return true; } @@ -510,7 +505,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence avatar = null; foreach (Scene mScene in m_localScenes) { - if (mScene.TryGetAvatar(avatarId, out avatar)) + if (mScene.TryGetScenePresence(avatarId, out avatar)) { scene = mScene; return true; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fcbbb0eac7..9f4f7851dc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1274,7 +1274,6 @@ namespace OpenSim.Region.Framework.Scenes Scene.RegionSyncServerModule.DeleteObject(part.RegionHandle, part.LocalId); return; } - Scene.ForEachScenePresence(delegate(ScenePresence avatar) { if (avatar.ParentID == LocalId) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 26e5f92a13..987e5e8652 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -680,7 +680,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_parentGroup != null) // TODO can there be a SOP without a SOG? { ScenePresence avatar; - if (m_parentGroup.Scene.TryGetAvatar(m_sitTargetAvatar, out avatar)) + if (m_parentGroup.Scene.TryGetScenePresence(m_sitTargetAvatar, out avatar)) { avatar.ParentPosition = GetWorldPosition(); } @@ -1197,15 +1197,14 @@ namespace OpenSim.Region.Framework.Scenes private void SendObjectPropertiesToClient(UUID AgentID) { - ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); - for (int i = 0; i < avatars.Length; i++) + m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { // Ugly reference :( - if (avatars[i].UUID == AgentID) + if (avatar.UUID == AgentID) { - m_parentGroup.GetProperties(avatars[i].ControllingClient); + m_parentGroup.GetProperties(avatar.ControllingClient); } - } + }); } // TODO: unused: @@ -1263,8 +1262,10 @@ namespace OpenSim.Region.Framework.Scenes // REGION SYNC if (m_parentGroup.Scene.IsSyncedServer()) m_parentGroup.Scene.RegionSyncServerModule.QueuePartForUpdate(this); - - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { avatar.SceneViewer.QueuePartForUpdate(this); }); + m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) + { + avatar.SceneViewer.QueuePartForUpdate(this); + }); } public void AddFullUpdateToAvatar(ScenePresence presence) @@ -1287,8 +1288,10 @@ namespace OpenSim.Region.Framework.Scenes { if (m_parentGroup.Scene.IsSyncedServer()) m_parentGroup.Scene.RegionSyncServerModule.QueuePartForUpdate(this); - - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { avatar.SceneViewer.QueuePartForUpdate(this); }); + m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) + { + avatar.SceneViewer.QueuePartForUpdate(this); + }); } public void AddTerseUpdateToAvatar(ScenePresence presence) @@ -1323,11 +1326,11 @@ namespace OpenSim.Region.Framework.Scenes if (volume < 0) volume = 0; - List avatarts = m_parentGroup.Scene.GetAvatars(); - foreach (ScenePresence p in avatarts) + m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp) { - p.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); - } + if(!sp.IsChildAgent) + sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); + }); } /// @@ -2120,17 +2123,13 @@ namespace OpenSim.Region.Framework.Scenes } else { - ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); - - for (int i = 0; i < avlist.Length; i++) + m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av) { - ScenePresence av = avlist[i]; - if (av.LocalId == localId) { if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) { - bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); + bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this avatar if (found) { @@ -2152,7 +2151,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); + bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work if (!found) { @@ -2170,7 +2169,7 @@ namespace OpenSim.Region.Framework.Scenes } } - } + }); } } if (colliding.Count > 0) @@ -2256,17 +2255,13 @@ namespace OpenSim.Region.Framework.Scenes } else { - ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); - - for (int i = 0; i < avlist.Length; i++) + m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av) { - ScenePresence av = avlist[i]; - if (av.LocalId == localId) { if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) { - bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); + bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this avatar if (found) { @@ -2288,7 +2283,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); + bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work if (!found) { @@ -2306,7 +2301,7 @@ namespace OpenSim.Region.Framework.Scenes } } - } + }); } } if (colliding.Count > 0) @@ -2387,17 +2382,13 @@ namespace OpenSim.Region.Framework.Scenes } else { - ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); - - for (int i = 0; i < avlist.Length; i++) + m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av) { - ScenePresence av = avlist[i]; - if (av.LocalId == localId) { if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) { - bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); + bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this avatar if (found) { @@ -2419,7 +2410,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); + bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work if (!found) { @@ -2437,7 +2428,7 @@ namespace OpenSim.Region.Framework.Scenes } } - } + }); } } @@ -2623,12 +2614,13 @@ namespace OpenSim.Region.Framework.Scenes } } - List avatarts = m_parentGroup.Scene.GetAvatars(); - foreach (ScenePresence p in avatarts) + m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp) { - if (!(Util.GetDistanceTo(p.AbsolutePosition, AbsolutePosition) >= 100)) - p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); - } + if (sp.IsChildAgent) + return; + if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100)) + sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); + }); } public void RemFlag(PrimFlags flag) @@ -3093,7 +3085,10 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendTerseUpdateToAllClients() { - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { SendTerseUpdateToClient(avatar.ControllingClient); }); + m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) + { + SendTerseUpdateToClient(avatar.ControllingClient); + }); } public void SetAttachmentPoint(uint AttachmentPoint) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index edfe24ddd2..3d710b42c8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2402,35 +2402,33 @@ namespace OpenSim.Region.Framework.Scenes List CoarseLocations = new List(); List AvatarUUIDs = new List(); - List avatars = m_scene.GetAvatars(); - for (int i = 0; i < avatars.Count; i++) + m_scene.ForEachScenePresence(delegate(ScenePresence sp) { - // Requested by LibOMV. Send Course Location on self. - //if (avatars[i] != this) - //{ - if (avatars[i].ParentID != 0) + if (sp.IsChildAgent) + return; + + if (sp.ParentID != 0) + { + // sitting avatar + SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID); + if (sop != null) { - // sitting avatar - SceneObjectPart sop = m_scene.GetSceneObjectPart(avatars[i].ParentID); - if (sop != null) - { - CoarseLocations.Add(sop.AbsolutePosition + avatars[i].m_pos); - AvatarUUIDs.Add(avatars[i].UUID); - } - else - { - // we can't find the parent.. ! arg! - CoarseLocations.Add(avatars[i].m_pos); - AvatarUUIDs.Add(avatars[i].UUID); - } + CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos); + AvatarUUIDs.Add(sp.UUID); } else { - CoarseLocations.Add(avatars[i].m_pos); - AvatarUUIDs.Add(avatars[i].UUID); + // we can't find the parent.. ! arg! + CoarseLocations.Add(sp.m_pos); + AvatarUUIDs.Add(sp.UUID); } - //} - } + } + else + { + CoarseLocations.Add(sp.m_pos); + AvatarUUIDs.Add(sp.UUID); + } + }); m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); @@ -2472,13 +2470,10 @@ namespace OpenSim.Region.Framework.Scenes public void SendInitialFullUpdateToAllClients() { m_perfMonMS = Util.EnvironmentTickCount(); - - ScenePresence[] avatars = m_scene.GetScenePresences(); - - for (int i = 0; i < avatars.Length; i++) + int avUpdates = 0; + m_scene.ForEachScenePresence(delegate(ScenePresence avatar) { - ScenePresence avatar = avatars[i]; - + ++avUpdates; // only send if this is the root (children are only "listening posts" in a foreign region) if (!IsChildAgent) { @@ -2494,9 +2489,9 @@ namespace OpenSim.Region.Framework.Scenes avatar.Animator.SendAnimPackToClient(ControllingClient); } } - } + }); - m_scene.StatsReporter.AddAgentUpdates(avatars.Length); + m_scene.StatsReporter.AddAgentUpdates(avUpdates); m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); //Animator.SendAnimPack(); @@ -2507,13 +2502,15 @@ namespace OpenSim.Region.Framework.Scenes m_perfMonMS = Util.EnvironmentTickCount(); // only send update from root agents to other clients; children are only "listening posts" - List avatars = m_scene.GetAvatars(); - foreach (ScenePresence avatar in avatars) + int count = 0; + m_scene.ForEachScenePresence(delegate(ScenePresence sp) { - SendFullUpdateToOtherClient(avatar); - - } - m_scene.StatsReporter.AddAgentUpdates(avatars.Count); + if (sp.IsChildAgent) + return; + SendFullUpdateToOtherClient(sp); + ++count; + }); + m_scene.StatsReporter.AddAgentUpdates(count); m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); Animator.SendAnimPack(); diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs index 840039ca2a..dd9f8f6654 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs @@ -66,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests throw new NotImplementedException(); } - public override bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence) + public override bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence) { throw new NotImplementedException(); } diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 4a1f648b16..0ec3cc3c73 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -129,19 +129,20 @@ namespace OpenSim.Region.Framework.Scenes try { Primitive.TextureEntry textureEntry = part.Shape.Textures; - - // Get the prim's default texture. This will be used for faces which don't have their own texture - assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture; - - // XXX: Not a great way to iterate through face textures, but there's no - // other method available to tell how many faces there actually are - //int i = 0; - foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) + if (textureEntry != null) { - if (texture != null) + // Get the prim's default texture. This will be used for faces which don't have their own texture + if (textureEntry.DefaultTexture != null) + assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture; + + if (textureEntry.FaceTextures != null) { - //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++); - assetUuids[texture.TextureID] = AssetType.Texture; + // Loop through the rest of the texture faces (a non-null face means the face is different from DefaultTexture) + foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) + { + if (texture != null) + assetUuids[texture.TextureID] = AssetType.Texture; + } } } diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs index c86499336c..2fcc477dc2 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs @@ -318,9 +318,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge { Scene scene = client.Scene as Scene; m_log.DebugFormat("[Concierge]: {0} logs off from {1}", client.Name, scene.RegionInfo.RegionName); - List avs = scene.GetAvatars(); - AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, client.Name, scene.RegionInfo.RegionName, avs.Count)); - UpdateBroker(scene, avs); + AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, client.Name, scene.RegionInfo.RegionName, scene.GetRootAgentCount())); + UpdateBroker(scene); } } @@ -331,11 +330,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge { Scene scene = agent.Scene; m_log.DebugFormat("[Concierge]: {0} enters {1}", agent.Name, scene.RegionInfo.RegionName); - List avs = scene.GetAvatars(); WelcomeAvatar(agent, scene); AnnounceToAgentsRegion(scene, String.Format(m_announceEntering, agent.Name, - scene.RegionInfo.RegionName, avs.Count)); - UpdateBroker(scene, avs); + scene.RegionInfo.RegionName, scene.GetRootAgentCount())); + UpdateBroker(scene); } } @@ -346,10 +344,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge { Scene scene = agent.Scene; m_log.DebugFormat("[Concierge]: {0} leaves {1}", agent.Name, scene.RegionInfo.RegionName); - List avs = scene.GetAvatars(); AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, agent.Name, - scene.RegionInfo.RegionName, avs.Count)); - UpdateBroker(scene, avs); + scene.RegionInfo.RegionName, scene.GetRootAgentCount())); + UpdateBroker(scene); } } @@ -368,7 +365,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge } } - protected void UpdateBroker(IScene scene, List avatars) + protected void UpdateBroker(Scene scene) { if (String.IsNullOrEmpty(m_brokerURI)) return; @@ -377,24 +374,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge // create XML sniplet StringBuilder list = new StringBuilder(); - if (0 == avatars.Count) - { - list.Append(String.Format("", - scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, + list.Append(String.Format("\n", + scene.GetRootAgentCount(), scene.RegionInfo.RegionName, + scene.RegionInfo.RegionID, DateTime.UtcNow.ToString("s"))); - } - else + scene.ForEachScenePresence(delegate(ScenePresence sp) { - list.Append(String.Format("\n", - avatars.Count, scene.RegionInfo.RegionName, - scene.RegionInfo.RegionID, - DateTime.UtcNow.ToString("s"))); - foreach (ScenePresence av in avatars) + if (!sp.IsChildAgent) { - list.Append(String.Format(" \n", av.Name, av.UUID)); + list.Append(String.Format(" \n", sp.Name, sp.UUID)); + list.Append(""); } - list.Append(""); - } + }); string payload = list.ToString(); // post via REST to broker @@ -529,7 +520,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge // protected void AnnounceToAgentsRegion(Scene scene, string msg) // { // ScenePresence agent = null; - // if ((client.Scene is Scene) && (client.Scene as Scene).TryGetAvatar(client.AgentId, out agent)) + // if ((client.Scene is Scene) && (client.Scene as Scene).TryGetScenePresence(client.AgentId, out agent)) // AnnounceToAgentsRegion(agent, msg); // else // m_log.DebugFormat("[Concierge]: could not find an agent for client {0}", client.Name); diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 6e742f1ece..ab0be77715 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -110,7 +110,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; - scene.TryGetAvatar(agentID, out sp); + scene.TryGetScenePresence(agentID, out sp); sp.DoAutoPilot(0, pos, m_avatars[agentID]); } } @@ -165,7 +165,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC p_scene.AddNewClient(npcAvatar); ScenePresence sp; - if (p_scene.TryGetAvatar(npcAvatar.AgentId, out sp)) + if (p_scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) { AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene); diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 1a99c833f1..9cb349a1e9 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -707,36 +707,37 @@ namespace OpenSim.Region.RegionCombinerModule return; } - List avatars = connectiondata.RegionScene.GetAvatars(); List CoarseLocations = new List(); List AvatarUUIDs = new List(); - for (int i = 0; i < avatars.Count; i++) + connectiondata.RegionScene.ForEachScenePresence(delegate(ScenePresence sp) { - if (avatars[i].UUID != presence.UUID) + if (sp.IsChildAgent) + return; + if (sp.UUID != presence.UUID) { - if (avatars[i].ParentID != 0) + if (sp.ParentID != 0) { // sitting avatar - SceneObjectPart sop = connectiondata.RegionScene.GetSceneObjectPart(avatars[i].ParentID); + SceneObjectPart sop = connectiondata.RegionScene.GetSceneObjectPart(sp.ParentID); if (sop != null) { - CoarseLocations.Add(sop.AbsolutePosition + avatars[i].AbsolutePosition); - AvatarUUIDs.Add(avatars[i].UUID); + CoarseLocations.Add(sop.AbsolutePosition + sp.AbsolutePosition); + AvatarUUIDs.Add(sp.UUID); } else { // we can't find the parent.. ! arg! - CoarseLocations.Add(avatars[i].AbsolutePosition); - AvatarUUIDs.Add(avatars[i].UUID); + CoarseLocations.Add(sp.AbsolutePosition); + AvatarUUIDs.Add(sp.UUID); } } else { - CoarseLocations.Add(avatars[i].AbsolutePosition); - AvatarUUIDs.Add(avatars[i].UUID); + CoarseLocations.Add(sp.AbsolutePosition); + AvatarUUIDs.Add(sp.UUID); } } - } + }); DistributeCourseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence); } @@ -1004,7 +1005,7 @@ namespace OpenSim.Region.RegionCombinerModule VirtualRegion.Permissions.OnIssueEstateCommand += BigRegion.PermissionModule.CanIssueEstateCommand; //FULLY IMPLEMENTED VirtualRegion.Permissions.OnMoveObject += BigRegion.PermissionModule.CanMoveObject; //MAYBE FULLY IMPLEMENTED VirtualRegion.Permissions.OnObjectEntry += BigRegion.PermissionModule.CanObjectEntry; - VirtualRegion.Permissions.OnReturnObject += BigRegion.PermissionModule.CanReturnObject; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnReturnObjects += BigRegion.PermissionModule.CanReturnObjects; //NOT YET IMPLEMENTED VirtualRegion.Permissions.OnRezObject += BigRegion.PermissionModule.CanRezObject; //MAYBE FULLY IMPLEMENTED VirtualRegion.Permissions.OnRunConsoleCommand += BigRegion.PermissionModule.CanRunConsoleCommand; VirtualRegion.Permissions.OnRunScript += BigRegion.PermissionModule.CanRunScript; //NOT YET IMPLEMENTED @@ -1030,7 +1031,6 @@ namespace OpenSim.Region.RegionCombinerModule VirtualRegion.Permissions.OnEditUserInventory += BigRegion.PermissionModule.CanEditUserInventory; //NOT YET IMPLEMENTED VirtualRegion.Permissions.OnDeleteUserInventory += BigRegion.PermissionModule.CanDeleteUserInventory; //NOT YET IMPLEMENTED VirtualRegion.Permissions.OnTeleport += BigRegion.PermissionModule.CanTeleport; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnUseObjectReturn += BigRegion.PermissionModule.CanUseObjectReturn; //NOT YET IMPLEMENTED } #region console commands diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs index 4d1af57450..393322d2d1 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs @@ -135,9 +135,9 @@ namespace OpenSim.Region.RegionCombinerModule return m_rootScene.Permissions.CanObjectEntry(objectid, enteringregion, newpoint); } - public bool CanReturnObject(UUID objectid, UUID returnerid, Scene scene) + public bool CanReturnObjects(ILandObject land, UUID user, List objects, Scene scene) { - return m_rootScene.Permissions.CanReturnObject(objectid, returnerid); + return m_rootScene.Permissions.CanReturnObjects(land, user, objects); } public bool CanRezObject(int objectcount, UUID owner, Vector3 objectposition, Scene scene) @@ -265,11 +265,6 @@ namespace OpenSim.Region.RegionCombinerModule return m_rootScene.Permissions.CanTeleport(userid); } - public bool CanUseObjectReturn(ILandObject landdata, uint type, IClientAPI client, List retlist, Scene scene) - { - return m_rootScene.Permissions.CanUseObjectReturn(landdata, type, client, retlist); - } - #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b040ca7748..3ccbb3abc6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5092,7 +5092,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetRegionAgentCount() { m_host.AddScriptLPS(1); - return new LSL_Integer(World.GetAvatars().Count); + return new LSL_Integer(World.GetRootAgentCount()); } public LSL_Vector llGetRegionCorner() @@ -8771,17 +8771,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api landObject.SetMediaUrl(url); // now send to all (non-child) agents - List agents = World.GetAvatars(); - foreach (ScenePresence agent in agents) + World.ForEachScenePresence(delegate(ScenePresence sp) { - agent.ControllingClient.SendParcelMediaUpdate(landData.MediaURL, - landData.MediaID, - landData.MediaAutoScale, - mediaType, - description, - width, height, - loop); - } + if (!sp.IsChildAgent) + { + sp.ControllingClient.SendParcelMediaUpdate(landData.MediaURL, + landData.MediaID, + landData.MediaAutoScale, + mediaType, + description, + width, height, + loop); + } + }); } else if (!presence.IsChildAgent) { @@ -8802,13 +8804,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (presence == null) { // send to all (non-child) agents - List agents = World.GetAvatars(); - foreach (ScenePresence agent in agents) + World.ForEachScenePresence(delegate(ScenePresence sp) { - agent.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this? - (ParcelMediaCommandEnum)commandToSend, - time); - } + if (!sp.IsChildAgent) + { + sp.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this? + (ParcelMediaCommandEnum)commandToSend, + time); + } + }); } else if (!presence.IsChildAgent) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 85ee29df1c..7e68cc749c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -697,10 +697,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.None, "osGetAgents"); LSL_List result = new LSL_List(); - foreach (ScenePresence avatar in World.GetAvatars()) + World.ForEachScenePresence(delegate(ScenePresence sp) { - result.Add(avatar.Name); - } + if (!sp.IsChildAgent) + result.Add(sp.Name); + }); return result; } @@ -1985,19 +1986,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) { - foreach (ScenePresence presence in World.GetAvatars()) + World.ForEachScenePresence(delegate(ScenePresence sp) { - if ((presence.Firstname == FirstName) && - presence.Lastname == SurName) + if (!sp.IsChildAgent && + sp.Firstname == FirstName && + sp.Lastname == SurName) { // kick client... if (alert != null) - presence.ControllingClient.Kick(alert); + sp.ControllingClient.Kick(alert); // ...and close on our side - presence.Scene.IncomingCloseAgent(presence.UUID); + sp.Scene.IncomingCloseAgent(sp.UUID); } - } + }); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 829fbb7fd2..2296379da7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -404,70 +404,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins private List doAgentSensor(SenseRepeatClass ts) { - List presences; List sensedEntities = new List(); - // If this is an avatar sense by key try to get them directly - // rather than getting a list to scan through - if (ts.keyID != UUID.Zero) - { - ScenePresence p = m_CmdManager.m_ScriptEngine.World.GetScenePresence(ts.keyID); - if (p == null) - return sensedEntities; - presences = new List(); - presences.Add(p); - } - else - { - presences = new List(m_CmdManager.m_ScriptEngine.World.GetScenePresences()); - } - // If nobody about quit fast - if (presences.Count == 0) + if(m_CmdManager.m_ScriptEngine.World.GetRootAgentCount() == 0) return sensedEntities; SceneObjectPart SensePoint = ts.host; - Vector3 fromRegionPos = SensePoint.AbsolutePosition; - Quaternion q = SensePoint.RotationOffset; LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); - bool attached = (SensePoint.AttachmentPoint != 0); - bool nameSearch = (ts.name != null && ts.name != ""); Vector3 toRegionPos; double dis; - for (int i = 0; i < presences.Count; i++) + Action senseEntity = new Action(delegate(ScenePresence presence) { - ScenePresence presence = presences[i]; - bool keep = true; + if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0) + return; + + // if the object the script is in is attached and the avatar is the owner + // then this one is not wanted + if (attached && presence.UUID == SensePoint.OwnerID) + return; - if (presence.IsDeleted) - continue; - - if (presence.IsChildAgent) - keep = false; toRegionPos = presence.AbsolutePosition; - dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); // are they in range - if (keep && dis <= ts.range) + if (dis <= ts.range) { - // if the object the script is in is attached and the avatar is the owner - // then this one is not wanted - if (attached && presence.UUID == SensePoint.OwnerID) - keep = false; - - // check the name if needed - if (keep && nameSearch && ts.name != presence.Name) - keep = false; - // Are they in the required angle of view - if (keep && ts.arc < Math.PI) + if (ts.arc < Math.PI) { // not omni-directional. Can you see it ? // vec forward_dir = llRot2Fwd(llGetRot()) @@ -488,26 +458,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins catch { } - if (ang_obj > ts.arc) keep = false; + if (ang_obj <= ts.arc) + { + sensedEntities.Add(new SensedEntity(dis, presence.UUID)); + } } } - else - { - keep = false; - } + }); - // Do not report gods, not even minor ones - if (keep && presence.GodLevel > 0.0) - keep = false; - - if (keep) // add to list with distance - { - sensedEntities.Add(new SensedEntity(dis, presence.UUID)); - } - - // If this is a search by name and we have just found it then no more to do - if (nameSearch && ts.name == presence.Name) + // If this is an avatar sense by key try to get them directly + // rather than getting a list to scan through + if (ts.keyID != UUID.Zero) + { + ScenePresence sp; + // Try direct lookup by UUID + if(!m_CmdManager.m_ScriptEngine.World.TryGetScenePresence(ts.keyID, out sp)) return sensedEntities; + senseEntity(sp); + } + else if (ts.name != null && ts.name != "") + { + 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); + } + else + { + m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(senseEntity); } return sensedEntities; } diff --git a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs index 704b74f67b..dcbd7173d9 100644 --- a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs +++ b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs @@ -68,17 +68,15 @@ namespace OpenSim.Region.UserStatistics HTMLUtil.OL_O(ref output, ""); foreach (Scene scene in all_scenes) { - ScenePresence[] avatarInScene = scene.GetScenePresences(); - HTMLUtil.LI_O(ref output, String.Empty); output.Append(scene.RegionInfo.RegionName); HTMLUtil.OL_O(ref output, String.Empty); - foreach (ScenePresence av in avatarInScene) + scene.ForEachScenePresence(delegate(ScenePresence av) { - Dictionary queues = new Dictionary(); + Dictionary queues = new Dictionary(); if (av.ControllingClient is IStatsCollector) { - IStatsCollector isClient = (IStatsCollector) av.ControllingClient; + IStatsCollector isClient = (IStatsCollector)av.ControllingClient; queues = decodeQueueReport(isClient.Report()); } HTMLUtil.LI_O(ref output, String.Empty); @@ -92,8 +90,8 @@ namespace OpenSim.Region.UserStatistics else { output.Append(string.Format("
Position: <{0},{1},{2}>", (int)av.AbsolutePosition.X, - (int) av.AbsolutePosition.Y, - (int) av.AbsolutePosition.Z)); + (int)av.AbsolutePosition.Y, + (int)av.AbsolutePosition.Z)); } Dictionary throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1)); @@ -124,7 +122,7 @@ namespace OpenSim.Region.UserStatistics HTMLUtil.UL_C(ref output); HTMLUtil.LI_C(ref output); - } + }); HTMLUtil.OL_C(ref output); } HTMLUtil.OL_C(ref output); diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs index cc53d6ca0f..29c9219040 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs @@ -114,7 +114,7 @@ namespace OpenSim.Services.Connectors.SimianGrid { string credential = identity["Credential"].AsString(); - if (password == credential || Utils.MD5String(password) == credential) + if (password == credential || "$1$" + Utils.MD5String(password) == credential) return Authorize(principalID); } } diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs index 0d87494693..89eb72d143 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs @@ -76,7 +76,15 @@ namespace OpenSim.Services.Connectors.SimianGrid public void Initialise(IConfigSource source) { - if (Simian.IsSimianEnabled(source, "FriendsServices", this.Name)) + bool isSimianEnabled = false; + + if (source.Configs["Friends"] != null) + { + string module = source.Configs["Friends"].GetString("Connector"); + isSimianEnabled = !String.IsNullOrEmpty(module) && module.EndsWith(this.Name); + } + + if (isSimianEnabled) { IConfig assetConfig = source.Configs["FriendsService"]; if (assetConfig == null) diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs index 5e0f7c25e6..f47bfbbce9 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs @@ -301,7 +301,7 @@ namespace OpenSim.Services.Connectors.SimianGrid private void SignificantClientMovementHandler(IClientAPI client) { ScenePresence sp; - if (client.Scene is Scene && ((Scene)client.Scene).TryGetAvatar(client.AgentId, out sp)) + if (client.Scene is Scene && ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out sp)) ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); } @@ -312,7 +312,7 @@ namespace OpenSim.Services.Connectors.SimianGrid client.OnConnectionClosed -= LogoutHandler; object obj; - if (client.Scene.TryGetAvatar(client.AgentId, out obj) && obj is ScenePresence) + if (client.Scene.TryGetScenePresence(client.AgentId, out obj) && obj is ScenePresence) { // The avatar is still in the scene, we can get the exact logout position ScenePresence sp = (ScenePresence)obj; diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs index a45bf8c79b..befd14e02a 100644 --- a/OpenSim/Services/Interfaces/IUserAccountService.cs +++ b/OpenSim/Services/Interfaces/IUserAccountService.cs @@ -150,10 +150,10 @@ namespace OpenSim.Services.Interfaces List GetUserAccounts(UUID scopeID, string query); /// - /// Store the data given, wich replaces the sotred data, therefore must be complete. + /// Store the data given, wich replaces the stored data, therefore must be complete. /// /// /// bool StoreUserAccount(UserAccount data); } -} \ No newline at end of file +} diff --git a/bin/Mono.Security.dll b/bin/Mono.Security.dll deleted file mode 100644 index c027c19f73..0000000000 Binary files a/bin/Mono.Security.dll and /dev/null differ diff --git a/bin/OpenMetaverse.Http.dll b/bin/OpenMetaverse.Http.dll deleted file mode 100644 index dbbe4d30bd..0000000000 Binary files a/bin/OpenMetaverse.Http.dll and /dev/null differ diff --git a/bin/OpenMetaverse.StructuredData.dll b/bin/OpenMetaverse.StructuredData.dll index 0e571d83f9..f4992a21ea 100644 Binary files a/bin/OpenMetaverse.StructuredData.dll and b/bin/OpenMetaverse.StructuredData.dll differ diff --git a/bin/OpenMetaverse.dll b/bin/OpenMetaverse.dll index a35b5aea3f..8751bfc71e 100644 Binary files a/bin/OpenMetaverse.dll and b/bin/OpenMetaverse.dll differ diff --git a/bin/OpenMetaverseTypes.dll b/bin/OpenMetaverseTypes.dll index c5efaf4baa..6c6440ea5b 100644 Binary files a/bin/OpenMetaverseTypes.dll and b/bin/OpenMetaverseTypes.dll differ diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 23c324115a..1a67292102 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -37,13 +37,6 @@ ; performance on .NET/Windows async_call_method = SmartThreadPool - ; There are several operations on large collections (such as - ; the current avatar list) that can be run synchronously or - ; in parallel. Running in parallel should increase performance - ; on a multi-core system, but will make debugging more - ; difficult if something deadlocks or times out - use_async_when_possible = false - ; Max threads to allocate on the FireAndForget thread pool ; when running with the SmartThreadPool option above MaxPoolThreads = 15