Merged from master

dsg
Dan Lake 2010-03-24 10:50:42 -07:00
commit 8027b7c1a5
69 changed files with 1165 additions and 1156 deletions

View File

@ -123,10 +123,15 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
private void DoMove(RequestData rdata) 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); string[] names = rdata.Parameters[PARM_MOVE_AVATAR].Split(Rest.CA_SPACE);
ScenePresence avatar = null; ScenePresence presence = null;
Scene scene = null; Scene scene = null;
if (names.Length != 2) 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 // The first parameter should be an avatar name, look for the
// avatar in the known regions first. // 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] && if (sp.Firstname == names[0] && sp.Lastname == names[1])
presence.Lastname == names[1])
{ {
scene = cs; scene = s;
avatar = presence; presence = sp;
break;
}
}
} }
});
});
if (avatar != null) if (presence != null)
{ {
Rest.Log.DebugFormat("{0} Move : Avatar {1} located in region {2}", Rest.Log.DebugFormat("{0} Move : Avatar {1} located in region {2}",
MsgId, rdata.Parameters[PARM_MOVE_AVATAR], scene.RegionInfo.RegionName); 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 y = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Y]);
float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]); float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]);
Vector3 vector = new Vector3(x,y,z); Vector3 vector = new Vector3(x,y,z);
avatar.DoAutoPilot(0,vector,avatar.ControllingClient); presence.DoAutoPilot(0,vector,presence.ControllingClient);
} }
catch (Exception e) catch (Exception e)
{ {
rdata.Fail(Rest.HttpStatusCodeBadRequest, rdata.Fail(Rest.HttpStatusCodeBadRequest,
String.Format("invalid parameters: {0}", e.Message)); String.Format("invalid parameters: {0}", e.Message));
} }
} }
else else
{ {
@ -183,12 +185,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
rdata.Complete(); rdata.Complete();
rdata.Respond("OK"); rdata.Respond("OK");
}
else
{
Rest.Log.WarnFormat("{0} Move: No movement information provided", MsgId);
rdata.Fail(Rest.HttpStatusCodeBadRequest, "no movement information provided");
} }
} }

View File

@ -192,7 +192,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
protected string RegionStats(OSHttpResponse httpResponse, Scene scene) protected string RegionStats(OSHttpResponse httpResponse, Scene scene)
{ {
int users = scene.GetAvatars().Count; int users = scene.GetRootAgentCount();
int objects = scene.Entities.Count - users; int objects = scene.Entities.Count - users;
RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); RestXmlWriter rxw = new RestXmlWriter(new StringWriter());

View File

@ -117,7 +117,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString()); rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString());
rxw.WriteEndAttribute(); rxw.WriteEndAttribute();
int users = s.GetAvatars().Count; int users = s.GetRootAgentCount();
rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty); rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty);
rxw.WriteValue(users); rxw.WriteValue(users);
rxw.WriteEndAttribute(); rxw.WriteEndAttribute();

View File

@ -83,7 +83,7 @@ namespace OpenSim.Data.MSSQL
/// </summary> /// </summary>
/// <param name="regionID">region ID.</param> /// <param name="regionID">region ID.</param>
/// <returns></returns> /// <returns></returns>
public EstateSettings LoadEstateSettings(UUID regionID) public EstateSettings LoadEstateSettings(UUID regionID, bool create)
{ {
EstateSettings es = new EstateSettings(); EstateSettings es = new EstateSettings();
@ -127,7 +127,7 @@ namespace OpenSim.Data.MSSQL
} }
if (insertEstate) if (insertEstate && create)
{ {
List<string> names = new List<string>(FieldList); List<string> names = new List<string>(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?? //TODO check if this is needed??
es.Save(); es.Save();
} }
@ -365,6 +346,31 @@ namespace OpenSim.Data.MSSQL
} }
} }
} }
public EstateSettings LoadEstateSettings(int estateID)
{
return new EstateSettings();
}
public List<int> GetEstates(string search)
{
return new List<int>();
}
public bool LinkRegion(UUID regionID, int estateID)
{
return false;
}
public List<UUID> GetRegions(int estateID)
{
return new List<UUID>();
}
public bool DeleteEstate(int estateID)
{
return false;
}
#endregion #endregion
} }
} }

View File

@ -121,30 +121,38 @@ 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) + 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"; " 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)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
using (MySqlCommand cmd = dbcon.CreateCommand()) cmd.Connection = dbcon;
{
cmd.CommandText = sql; bool found = false;
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
using (IDataReader r = cmd.ExecuteReader()) using (IDataReader r = cmd.ExecuteReader())
{ {
if (r.Read()) if (r.Read())
{ {
migration = false; found = true;
foreach (string name in FieldList) foreach (string name in FieldList)
{ {
@ -170,62 +178,53 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
}
if (migration) if (!found && create)
{ {
// Migration case // Migration case
List<string> names = new List<string>(FieldList); List<string> names = new List<string>(FieldList);
names.Remove("EstateID"); 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; cmd2.CommandText = sql;
cmd.Parameters.Clear(); cmd2.Parameters.Clear();
foreach (string name in FieldList) foreach (string name in FieldList)
{ {
if (m_FieldMap[name].GetValue(es) is bool) if (m_FieldMap[name].GetValue(es) is bool)
{ {
if ((bool)m_FieldMap[name].GetValue(es)) if ((bool)m_FieldMap[name].GetValue(es))
cmd.Parameters.AddWithValue("?" + name, "1"); cmd2.Parameters.AddWithValue("?" + name, "1");
else else
cmd.Parameters.AddWithValue("?" + name, "0"); cmd2.Parameters.AddWithValue("?" + name, "0");
} }
else 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"; cmd2.CommandText = "select LAST_INSERT_ID() as id";
cmd.Parameters.Clear(); cmd2.Parameters.Clear();
using (IDataReader r = cmd.ExecuteReader()) using (IDataReader r = cmd2.ExecuteReader())
{ {
r.Read(); r.Read();
es.EstateID = Convert.ToUInt32(r["id"]); es.EstateID = Convert.ToUInt32(r["id"]);
} }
cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; cmd2.CommandText = "insert into estate_map values (?RegionID, ?EstateID)";
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); cmd2.Parameters.AddWithValue("?RegionID", regionID.ToString());
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); cmd2.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
// This will throw on dupe key // This will throw on dupe key
try { cmd.ExecuteNonQuery(); } try { cmd2.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(); }
catch (Exception) { } catch (Exception) { }
es.Save(); es.Save();
@ -398,5 +397,83 @@ namespace OpenSim.Data.MySQL
return uuids.ToArray(); 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<int> GetEstates(string search)
{
List<int> result = new List<int>();
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<UUID> GetRegions(int estateID)
{
return new List<UUID>();
}
public bool DeleteEstate(int estateID)
{
return false;
}
} }
} }

View File

@ -0,0 +1,3 @@
BEGIN;
ALTER TABLE estate_settings AUTO_INCREMENT = 100;
COMMIT;

View File

@ -80,11 +80,8 @@ namespace OpenSim.Data.SQLite
get { return new List<string>(m_FieldMap.Keys).ToArray(); } get { return new List<string>(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"; 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(); SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
@ -92,6 +89,14 @@ namespace OpenSim.Data.SQLite
cmd.CommandText = sql; cmd.CommandText = sql;
cmd.Parameters.Add(":RegionID", regionID.ToString()); 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(); IDataReader r = cmd.ExecuteReader();
if (r.Read()) if (r.Read())
@ -120,17 +125,15 @@ namespace OpenSim.Data.SQLite
} }
r.Close(); r.Close();
} }
else else if (create)
{ {
// Migration case
//
r.Close(); r.Close();
List<string> names = new List<string>(FieldList); List<string> names = new List<string>(FieldList);
names.Remove("EstateID"); 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.CommandText = sql;
cmd.Parameters.Clear(); 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(); es.Save();
} }
@ -336,5 +325,63 @@ namespace OpenSim.Data.SQLite
return uuids.ToArray(); 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<int> GetEstates(string search)
{
List<int> result = new List<int>();
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<UUID> GetRegions(int estateID)
{
return new List<UUID>();
}
public bool DeleteEstate(int estateID)
{
return false;
}
} }
} }

View File

@ -158,7 +158,7 @@ namespace OpenSim.Data.Tests
public void T012_EstateSettingsRandomStorage() public void T012_EstateSettingsRandomStorage()
{ {
// Letting estate store generate rows to database for us // Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
new PropertyScrambler<EstateSettings>() new PropertyScrambler<EstateSettings>()
.DontScramble(x=>x.EstateID) .DontScramble(x=>x.EstateID)
.Scramble(originalSettings); .Scramble(originalSettings);
@ -167,7 +167,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings); db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable. // 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. // Checking that loaded values are correct.
Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings)); Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
@ -177,7 +177,7 @@ namespace OpenSim.Data.Tests
public void T020_EstateSettingsManagerList() public void T020_EstateSettingsManagerList()
{ {
// Letting estate store generate rows to database for us // 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 }; originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 };
@ -185,7 +185,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings); db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable. // 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(2, loadedSettings.EstateManagers.Length);
Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]); Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]);
@ -196,7 +196,7 @@ namespace OpenSim.Data.Tests
public void T021_EstateSettingsUserList() public void T021_EstateSettingsUserList()
{ {
// Letting estate store generate rows to database for us // 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 }; originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 };
@ -204,7 +204,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings); db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable. // 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(2, loadedSettings.EstateAccess.Length);
Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]); Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]);
@ -215,7 +215,7 @@ namespace OpenSim.Data.Tests
public void T022_EstateSettingsGroupList() public void T022_EstateSettingsGroupList()
{ {
// Letting estate store generate rows to database for us // 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 }; originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 };
@ -223,7 +223,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings); db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable. // 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(2, loadedSettings.EstateAccess.Length);
Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]); Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]);
@ -234,7 +234,7 @@ namespace OpenSim.Data.Tests
public void T022_EstateSettingsBanList() public void T022_EstateSettingsBanList()
{ {
// Letting estate store generate rows to database for us // 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(); EstateBan estateBan1 = new EstateBan();
estateBan1.BannedUserID = DataTestUtil.UUID_MIN; estateBan1.BannedUserID = DataTestUtil.UUID_MIN;
@ -248,7 +248,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings); db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable. // 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(2, loadedSettings.EstateBans.Length);
Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID); 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 // Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(regionId); EstateSettings originalSettings = db.LoadEstateSettings(regionId, true);
SetEstateSettings( SetEstateSettings(
originalSettings, originalSettings,
@ -347,7 +347,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings); db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable. // Loading settings to another instance variable.
EstateSettings loadedSettings = db.LoadEstateSettings(regionId); EstateSettings loadedSettings = db.LoadEstateSettings(regionId, true);
// Checking that loaded values are correct. // Checking that loaded values are correct.
ValidateEstateSettings( ValidateEstateSettings(

View File

@ -35,7 +35,6 @@ namespace OpenSim.Framework
public class EstateSettings public class EstateSettings
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private readonly ConfigurationMember configMember;
public delegate void SaveDelegate(EstateSettings rs); public delegate void SaveDelegate(EstateSettings rs);
@ -43,7 +42,7 @@ namespace OpenSim.Framework
// Only the client uses these // Only the client uses these
// //
private uint m_EstateID = 100; private uint m_EstateID = 0;
public uint EstateID public uint EstateID
{ {
@ -51,7 +50,7 @@ namespace OpenSim.Framework
set { m_EstateID = value; } set { m_EstateID = value; }
} }
private string m_EstateName; private string m_EstateName = "My Estate";
public string EstateName public string EstateName
{ {
@ -59,7 +58,7 @@ namespace OpenSim.Framework
set { m_EstateName = value; } set { m_EstateName = value; }
} }
private uint m_ParentEstateID = 100; private uint m_ParentEstateID = 1;
public uint ParentEstateID public uint ParentEstateID
{ {
@ -67,7 +66,7 @@ namespace OpenSim.Framework
set { m_ParentEstateID = value; } set { m_ParentEstateID = value; }
} }
private float m_BillableFactor; private float m_BillableFactor = 0.0f;
public float BillableFactor public float BillableFactor
{ {
@ -75,7 +74,7 @@ namespace OpenSim.Framework
set { m_BillableFactor = value; } set { m_BillableFactor = value; }
} }
private int m_PricePerMeter; private int m_PricePerMeter = 1;
public int PricePerMeter public int PricePerMeter
{ {
@ -83,7 +82,7 @@ namespace OpenSim.Framework
set { m_PricePerMeter = value; } set { m_PricePerMeter = value; }
} }
private int m_RedirectGridX; private int m_RedirectGridX = 0;
public int RedirectGridX public int RedirectGridX
{ {
@ -91,7 +90,7 @@ namespace OpenSim.Framework
set { m_RedirectGridX = value; } set { m_RedirectGridX = value; }
} }
private int m_RedirectGridY; private int m_RedirectGridY = 0;
public int RedirectGridY public int RedirectGridY
{ {
@ -273,25 +272,6 @@ namespace OpenSim.Framework
public EstateSettings() 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() public void Save()
@ -393,165 +373,5 @@ namespace OpenSim.Framework
return l_EstateAccess.Contains(user); 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;
}
} }
} }

View File

@ -91,7 +91,7 @@ namespace OpenSim.Framework
/// </exception> /// </exception>
bool PresenceChildStatus(UUID agentId); bool PresenceChildStatus(UUID agentId);
bool TryGetAvatar(UUID agentID, out object scenePresence); bool TryGetScenePresence(UUID agentID, out object scenePresence);
T RequestModuleInterface<T>(); T RequestModuleInterface<T>();
T[] RequestModuleInterfaces<T>(); T[] RequestModuleInterfaces<T>();

View File

@ -227,8 +227,12 @@ namespace OpenSim.Framework
{ {
get get
{ {
//m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length); //m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length);
return new Primitive.TextureEntry(m_textureEntry, 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(); } set { m_textureEntry = value.GetBytes(); }

View File

@ -42,6 +42,7 @@ using Nwc.XmlRpc;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using CoolHTTPListener = HttpServer.HttpListener; using CoolHTTPListener = HttpServer.HttpListener;
using HttpListener=System.Net.HttpListener; using HttpListener=System.Net.HttpListener;
using LogPrio=HttpServer.LogPrio;
namespace OpenSim.Framework.Servers.HttpServer namespace OpenSim.Framework.Servers.HttpServer
{ {
@ -294,7 +295,7 @@ namespace OpenSim.Framework.Servers.HttpServer
headervals[headername] = req.Headers[headername]; headervals[headername] = req.Headers[headername];
} }
keysvals.Add("headers",headervals); keysvals.Add("headers", headervals);
keysvals.Add("querystringkeys", querystringkeys); keysvals.Add("querystringkeys", querystringkeys);
psEvArgs.Request(psreq.RequestID, keysvals); 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 // 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 // probability event; if a request is matched it is normally expected to be
// handled // handled
//m_log.Debug("[BASE HTTP SERVER]: Handling Request" + request.RawUrl); // m_log.Debug("[BASE HTTP SERVER]: Handling request to " + request.RawUrl);
IHttpAgentHandler agentHandler; IHttpAgentHandler agentHandler;
@ -496,7 +497,8 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
case null: case null:
case "text/html": 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); HandleHTTPRequest(request, response);
return; return;
@ -524,10 +526,11 @@ namespace OpenSim.Framework.Servers.HttpServer
HandleLLSDRequests(request, response); HandleLLSDRequests(request, response);
return; 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)) 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); HandleHTTPRequest(request, response);
return; return;
} }
@ -623,7 +626,7 @@ namespace OpenSim.Framework.Servers.HttpServer
private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler) 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; string bestMatch = null;
@ -943,7 +946,7 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
catch (IOException e) 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) catch (SocketException e)
{ {
@ -1219,6 +1222,10 @@ namespace OpenSim.Framework.Servers.HttpServer
public void HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) 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) switch (request.HttpMethod)
{ {
case "OPTIONS": case "OPTIONS":
@ -1233,6 +1240,8 @@ namespace OpenSim.Framework.Servers.HttpServer
private void HandleContentVerbs(OSHttpRequest request, OSHttpResponse response) 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. // 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. // 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) 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]); keysvals.Add(queryname, request.QueryString[queryname]);
requestVars.Add(queryname, keysvals[queryname]); requestVars.Add(queryname, keysvals[queryname]);
} }
foreach (string headername in rHeaders) 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]; headervals[headername] = request.Headers[headername];
} }
@ -1288,15 +1299,16 @@ namespace OpenSim.Framework.Servers.HttpServer
host = (string)headervals["Host"]; host = (string)headervals["Host"];
} }
keysvals.Add("headers",headervals); keysvals.Add("headers", headervals);
keysvals.Add("querystringkeys", querystringkeys); keysvals.Add("querystringkeys", querystringkeys);
keysvals.Add("requestvars", requestVars); keysvals.Add("requestvars", requestVars);
// keysvals.Add("form", request.Form);
if (keysvals.Contains("method")) if (keysvals.Contains("method"))
{ {
//m_log.Warn("[HTTP]: Contains Method"); // m_log.Debug("[BASE HTTP SERVER]: Contains Method");
string method = (string) keysvals["method"]; string method = (string) keysvals["method"];
//m_log.Warn("[HTTP]: " + requestBody); // m_log.Debug("[BASE HTTP SERVER]: " + requestBody);
GenericHTTPMethod requestprocessor; GenericHTTPMethod requestprocessor;
bool foundHandler = TryGetHTTPHandler(method, out requestprocessor); bool foundHandler = TryGetHTTPHandler(method, out requestprocessor);
if (foundHandler) if (foundHandler)
@ -1308,13 +1320,12 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
else else
{ {
//m_log.Warn("[HTTP]: Handler Not Found"); // m_log.Warn("[BASE HTTP SERVER]: Handler Not Found");
SendHTML404(response, host); SendHTML404(response, host);
} }
} }
else else
{ {
GenericHTTPMethod requestprocessor; GenericHTTPMethod requestprocessor;
bool foundHandler = TryGetHTTPHandlerPathBased(request.RawUrl, out requestprocessor); bool foundHandler = TryGetHTTPHandlerPathBased(request.RawUrl, out requestprocessor);
if (foundHandler) if (foundHandler)
@ -1326,7 +1337,7 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
else else
{ {
//m_log.Warn("[HTTP]: Handler Not Found"); // m_log.Warn("[BASE HTTP SERVER]: Handler Not Found2");
SendHTML404(response, host); SendHTML404(response, host);
} }
} }
@ -1374,8 +1385,7 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) 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 != "/") if (pattern == "/" && searchquery == "/" || pattern != "/")
bestMatch = pattern; bestMatch = pattern;
} }
@ -1814,30 +1824,36 @@ namespace OpenSim.Framework.Servers.HttpServer
/// <summary> /// <summary>
/// Relays HttpServer log messages to our own logging mechanism. /// Relays HttpServer log messages to our own logging mechanism.
/// </summary> /// </summary>
/// 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 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) public void Write(object source, LogPrio priority, string message)
{ {
/* /*
switch (priority) switch (priority)
{ {
case HttpServer.LogPrio.Debug: case LogPrio.Trace:
m_log.DebugFormat("[{0}]: {1}", source.ToString(), message); m_log.DebugFormat("[{0}]: {1}", source, message);
break; break;
case HttpServer.LogPrio.Error: case LogPrio.Debug:
m_log.ErrorFormat("[{0}]: {1}", source.ToString(), message); m_log.DebugFormat("[{0}]: {1}", source, message);
break; break;
case HttpServer.LogPrio.Info: case LogPrio.Error:
m_log.InfoFormat("[{0}]: {1}", source.ToString(), message); m_log.ErrorFormat("[{0}]: {1}", source, message);
break; break;
case HttpServer.LogPrio.Warning: case LogPrio.Info:
m_log.WarnFormat("[{0}]: {1}", source.ToString(), message); m_log.InfoFormat("[{0}]: {1}", source, message);
break; break;
case HttpServer.LogPrio.Fatal: case LogPrio.Warning:
m_log.ErrorFormat("[{0}]: FATAL! - {1}", source.ToString(), message); m_log.WarnFormat("[{0}]: {1}", source, message);
break;
case LogPrio.Fatal:
m_log.ErrorFormat("[{0}]: FATAL! - {1}", source, message);
break; break;
default: default:
break; break;

View File

@ -127,6 +127,11 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
private Hashtable _query; private Hashtable _query;
/// <value>
/// POST request values, if applicable
/// </value>
// public Hashtable Form { get; private set; }
public string RawUrl public string RawUrl
{ {
get { return _request.Uri.AbsolutePath; } get { return _request.Uri.AbsolutePath; }
@ -228,6 +233,13 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
_log.ErrorFormat("[OSHttpRequest]: Error parsing querystring"); _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() public override string ToString()

View File

@ -897,7 +897,7 @@ namespace OpenSim
{ {
connections.AppendFormat("{0}: {1} ({2}) from {3} on circuit {4}\n", connections.AppendFormat("{0}: {1} ({2}) from {3} on circuit {4}\n",
scene.RegionInfo.RegionName, client.Name, client.AgentId, client.RemoteEndPoint, client.CircuitCode); scene.RegionInfo.RegionName, client.Name, client.AgentId, client.RemoteEndPoint, client.CircuitCode);
}, false }
); );
} }
); );

View File

@ -6001,7 +6001,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|| avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f) || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
{ {
ScenePresence avatar = null; 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) if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
{ {

View File

@ -1020,7 +1020,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Handle outgoing packets, resends, acknowledgements, and pings for each // Handle outgoing packets, resends, acknowledgements, and pings for each
// client. m_packetSent will be set to true if a packet is sent // 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 // If nothing was sent, sleep for the minimum amount of time before a
// token bucket could get more tokens // token bucket could get more tokens

View File

@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// Save avatar attachment information // Save avatar attachment information
ScenePresence presence; 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( m_log.Info(
"[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
@ -255,7 +255,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
AttachmentPt = att.RootPart.AttachmentPoint; AttachmentPt = att.RootPart.AttachmentPoint;
ScenePresence presence; 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); InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
item = m_scene.InventoryService.GetItem(item); item = m_scene.InventoryService.GetItem(item);
@ -299,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
} }
ScenePresence presence; ScenePresence presence;
if (m_scene.TryGetAvatar(remoteClient.AgentId, out presence)) if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
{ {
// XXYY!! // XXYY!!
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
@ -314,7 +314,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient) public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient)
{ {
ScenePresence presence; ScenePresence presence;
if (m_scene.TryGetAvatar(remoteClient.AgentId, out presence)) if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
{ {
presence.Appearance.DetachAttachment(itemID); presence.Appearance.DetachAttachment(itemID);

View File

@ -89,60 +89,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
get { return true; } 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) if (killerObjectLocalID == 0)
DeadAvatar.ControllingClient.SendAgentAlertMessage("You committed suicide!", true); deadAvatarMessage = "You committed suicide!";
else else
{ {
bool foundResult = false; // Try to get the avatar responsible for the killing
string resultstring = String.Empty; killingAvatar = deadAvatar.Scene.GetScenePresence(killerObjectLocalID);
ScenePresence[] allav = DeadAvatar.Scene.GetScenePresences(); if (killingAvatar == null)
{
// Try to get the object which was responsible for the killing
SceneObjectPart part = deadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID);
if (part == null)
{
// Cause of death: Unknown
deadAvatarMessage = "You died!";
}
else
{
// 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);
}
}
try try
{ {
for (int i = 0; i < allav.Length; i++) deadAvatar.ControllingClient.SendAgentAlertMessage(deadAvatarMessage, true);
{ if(killingAvatar != null)
ScenePresence av = allav[i]; killingAvatar.ControllingClient.SendAlertMessage("You fragged " + deadAvatar.Firstname + " " + deadAvatar.Lastname);
}
catch (InvalidOperationException)
{ }
if (av.LocalId == killerObjectLocalID) deadAvatar.Health = 100;
{ deadAvatar.Scene.TeleportClientHome(deadAvatar.UUID, deadAvatar.ControllingClient);
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
}
else
{
DeadAvatar.ControllingClient.SendAgentAlertMessage("You died!", true);
}
}
}
DeadAvatar.Health = 100;
DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient);
} }
private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID)

View File

@ -87,31 +87,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
public void SendAlertToUser(string firstName, string lastName, string message, bool modal) public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
{ {
ScenePresence[] presenceList = m_scene.GetScenePresences(); ScenePresence presence = m_scene.GetScenePresence(firstName, lastName);
if(presence != null)
for (int i = 0; i < presenceList.Length; i++)
{
ScenePresence presence = presenceList[i];
if (presence.Firstname == firstName && presence.Lastname == lastName)
{
presence.ControllingClient.SendAgentAlertMessage(message, modal); presence.ControllingClient.SendAgentAlertMessage(message, modal);
break;
}
}
} }
public void SendGeneralAlert(string message) public void SendGeneralAlert(string message)
{ {
ScenePresence[] presenceList = m_scene.GetScenePresences(); m_scene.ForEachScenePresence(delegate(ScenePresence presence)
for (int i = 0; i < presenceList.Length; i++)
{ {
ScenePresence presence = presenceList[i];
if (!presence.IsChildAgent) if (!presence.IsChildAgent)
presence.ControllingClient.SendAlertMessage(message); presence.ControllingClient.SendAlertMessage(message);
} });
} }
public void SendDialogToUser( public void SendDialogToUser(
@ -179,14 +166,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
public void SendNotificationToUsersInRegion( public void SendNotificationToUsersInRegion(
UUID fromAvatarID, string fromAvatarName, string message) UUID fromAvatarID, string fromAvatarName, string message)
{ {
ScenePresence[] presences = m_scene.GetScenePresences(); m_scene.ForEachScenePresence(delegate(ScenePresence presence)
for (int i = 0; i < presences.Length; i++)
{ {
ScenePresence presence = presences[i];
if (!presence.IsChildAgent) if (!presence.IsChildAgent)
presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
} });
} }
/// <summary> /// <summary>

View File

@ -358,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{ {
ScenePresence presence; ScenePresence presence;
if (s.TryGetAvatar(agentID, out presence)) if (s.TryGetScenePresence(agentID, out presence))
{ {
// If the agent is in this scene, then we // If the agent is in this scene, then we
// are being called twice in a single // are being called twice in a single

View File

@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
responsedata["str_response_string"] = "Request wasn't what was expected"; responsedata["str_response_string"] = "Request wasn't what was expected";
ScenePresence avatar; ScenePresence avatar;
if (!m_scene.TryGetAvatar(AgentId, out avatar)) if (!m_scene.TryGetScenePresence(AgentId, out avatar))
return responsedata; return responsedata;

View File

@ -190,7 +190,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
if (account == null) // foreign if (account == null) // foreign
{ {
ScenePresence sp = null; 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); AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))

View File

@ -1206,7 +1206,7 @@ namespace OpenSim.Region.CoreModules.InterGrid
{ {
Scene homeScene = GetRootScene(); Scene homeScene = GetRootScene();
ScenePresence avatar = null; ScenePresence avatar = null;
if (homeScene.TryGetAvatar(avatarId,out avatar)) if (homeScene.TryGetScenePresence(avatarId,out avatar))
{ {
KillAUser ku = new KillAUser(avatar,mod); KillAUser ku = new KillAUser(avatar,mod);
Watchdog.StartThread(ku.ShutdownNoLogout, "OGPShutdown", ThreadPriority.Normal, true); Watchdog.StartThread(ku.ShutdownNoLogout, "OGPShutdown", ThreadPriority.Normal, true);

View File

@ -427,7 +427,7 @@ namespace OpenSim.Region.Examples.RegionSyncModule
private void EventManager_OnRemovePresence(UUID agentID) private void EventManager_OnRemovePresence(UUID agentID)
{ {
ScenePresence avatar; 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()); m_log.WarnFormat("[REGION SYNC SERVER MODULE] Avatar \"{0}\" (1) {2} has left the scene", avatar.Firstname + " " + avatar.Lastname, agentID.ToString(), avatar.UUID.ToString());
} }

View File

@ -285,24 +285,22 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
return; return;
} }
byte[] assetData; byte[] assetData = null;
AssetBase oldAsset = null; AssetBase oldAsset = null;
if (BlendWithOldTexture) if (BlendWithOldTexture)
{ {
UUID lastTextureID = part.Shape.Textures.DefaultTexture.TextureID; Primitive.TextureEntryFace defaultFace = part.Shape.Textures.DefaultTexture;
oldAsset = scene.AssetService.Get(lastTextureID.ToString()); if (defaultFace != null)
if (oldAsset != null)
{ {
oldAsset = scene.AssetService.Get(defaultFace.TextureID.ToString());
if (oldAsset != null)
assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha); assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha);
} }
else
{
assetData = new byte[data.Length];
Array.Copy(data, assetData, data.Length);
} }
}
else if (assetData == null)
{ {
assetData = new byte[data.Length]; assetData = new byte[data.Length];
Array.Copy(data, assetData, data.Length); Array.Copy(data, assetData, data.Length);

View File

@ -502,7 +502,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
private UUID GetSessionID(UUID userID) private UUID GetSessionID(UUID userID)
{ {
ScenePresence sp = null; ScenePresence sp = null;
if (m_Scene.TryGetAvatar(userID, out sp)) if (m_Scene.TryGetScenePresence(userID, out sp))
{ {
return sp.ControllingClient.SessionId; return sp.ControllingClient.SessionId;
} }
@ -521,7 +521,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if (account == null) // foreign user if (account == null) // foreign user
{ {
ScenePresence sp = null; ScenePresence sp = null;
m_Scene.TryGetAvatar(userID, out sp); m_Scene.TryGetScenePresence(userID, out sp);
if (sp != null) if (sp != null)
{ {
AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);

View File

@ -100,7 +100,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
ScenePresence sp = null; ScenePresence sp = null;
foreach (Scene s in m_Scenes) foreach (Scene s in m_Scenes)
{ {
s.TryGetAvatar(clientID, out sp); s.TryGetScenePresence(clientID, out sp);
if ((sp != null) && !sp.IsChildAgent && (s != scene)) 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", m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping system folders in cache",

View File

@ -88,7 +88,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
Vector3 position = new Vector3(128, 128, 0); Vector3 position = new Vector3(128, 128, 0);
Vector3 lookat = new Vector3(0, 1, 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) if (sp is ScenePresence)
{ {

View File

@ -468,28 +468,20 @@ namespace OpenSim.Region.CoreModules.World.Estate
private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID) private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
{ {
// Get a fresh list that will not change as people get teleported away m_scene.ForEachScenePresence(delegate(ScenePresence sp)
ScenePresence[] presences = m_scene.GetScenePresences();
for (int i = 0; i < presences.Length; i++)
{ {
ScenePresence p = presences[i]; if (sp.UUID != senderID)
if (p.UUID != senderID)
{ {
ScenePresence p = m_scene.GetScenePresence(sp.UUID);
// make sure they are still there, we could be working down a long list // 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 // Also make sure they are actually in the region
if (!s.IsChildAgent) if (p != null && !p.IsChildAgent)
{ {
s.ControllingClient.SendTeleportLocationStart(); p.ControllingClient.SendTeleportLocationStart();
m_scene.TeleportClientHome(s.UUID, s.ControllingClient); m_scene.TeleportClientHome(p.UUID, p.ControllingClient);
}
}
} }
} }
});
} }
private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID) private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
{ {
@ -767,12 +759,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
public void sendRegionInfoPacketToAll() public void sendRegionInfoPacketToAll()
{ {
List<ScenePresence> avatars = m_scene.GetAvatars(); m_scene.ForEachScenePresence(delegate(ScenePresence sp)
for (int i = 0; i < avatars.Count; i++)
{ {
HandleRegionInfoRequest(avatars[i].ControllingClient); if (!sp.IsChildAgent)
} HandleRegionInfoRequest(sp.ControllingClient);
});
} }
public void sendRegionHandshake(IClientAPI remoteClient) public void sendRegionHandshake(IClientAPI remoteClient)

View File

@ -191,9 +191,9 @@ namespace OpenSim.Region.CoreModules.World.Land
forcedPosition = null; forcedPosition = null;
} }
//if we are far away, teleport //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); clientAvatar.Teleport(forcedPosition.Value);
forcedPosition = null; forcedPosition = null;
} }
@ -374,31 +374,28 @@ namespace OpenSim.Region.CoreModules.World.Land
} }
} }
public void SendOutNearestBanLine(IClientAPI avatar) public void SendOutNearestBanLine(IClientAPI client)
{ {
List<ScenePresence> avatars = m_scene.GetAvatars(); ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
foreach (ScenePresence presence in avatars) if (sp == null || sp.IsChildAgent)
{ return;
if (presence.UUID == avatar.AgentId)
{ List<ILandObject> checkLandParcels = ParcelsNearPoint(sp.AbsolutePosition);
List<ILandObject> checkLandParcels = ParcelsNearPoint(presence.AbsolutePosition);
foreach (ILandObject checkBan in checkLandParcels) foreach (ILandObject checkBan in checkLandParcels)
{ {
if (checkBan.IsBannedFromLand(avatar.AgentId)) if (checkBan.IsBannedFromLand(client.AgentId))
{ {
checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar); checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, client);
return; //Only send one return; //Only send one
} }
if (checkBan.IsRestrictedFromLand(avatar.AgentId)) if (checkBan.IsRestrictedFromLand(client.AgentId))
{ {
checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar); checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, client);
return; //Only send one return; //Only send one
} }
} }
return; return;
} }
}
}
public void SendLandUpdate(ScenePresence avatar, bool force) public void SendLandUpdate(ScenePresence avatar, bool force)
{ {

View File

@ -332,20 +332,22 @@ namespace OpenSim.Region.CoreModules.World.Land
public void SendLandUpdateToAvatarsOverMe(bool snap_selection) public void SendLandUpdateToAvatarsOverMe(bool snap_selection)
{ {
List<ScenePresence> avatars = m_scene.GetAvatars(); m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
ILandObject over = null;
for (int i = 0; i < avatars.Count; i++)
{ {
if (avatar.IsChildAgent)
return;
ILandObject over = null;
try try
{ {
over = over =
m_scene.LandChannel.GetLandObject(Util.Clamp<int>((int)Math.Round(avatars[i].AbsolutePosition.X), 0, ((int)Constants.RegionSize - 1)), m_scene.LandChannel.GetLandObject(Util.Clamp<int>((int)Math.Round(avatar.AbsolutePosition.X), 0, ((int)Constants.RegionSize - 1)),
Util.Clamp<int>((int)Math.Round(avatars[i].AbsolutePosition.Y), 0, ((int)Constants.RegionSize - 1))); Util.Clamp<int>((int)Math.Round(avatar.AbsolutePosition.Y), 0, ((int)Constants.RegionSize - 1)));
} }
catch (Exception) catch (Exception)
{ {
m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " +
Math.Round(avatars[i].AbsolutePosition.Y)); Math.Round(avatar.AbsolutePosition.Y));
} }
if (over != null) if (over != null)
@ -354,14 +356,14 @@ namespace OpenSim.Region.CoreModules.World.Land
{ {
if (((over.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) && if (((over.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) &&
m_scene.RegionInfo.RegionSettings.AllowDamage) m_scene.RegionInfo.RegionSettings.AllowDamage)
avatars[i].Invulnerable = false; avatar.Invulnerable = false;
else else
avatars[i].Invulnerable = true; avatar.Invulnerable = true;
SendLandUpdateToClient(snap_selection, avatars[i].ControllingClient); SendLandUpdateToClient(snap_selection, avatar.ControllingClient);
}
} }
} }
});
} }
#endregion #endregion
@ -892,7 +894,7 @@ namespace OpenSim.Region.CoreModules.World.Land
foreach (List<SceneObjectGroup> ol in returns.Values) foreach (List<SceneObjectGroup> 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); m_scene.returnObjects(ol.ToArray(), remote_client.AgentId);
} }
} }

View File

@ -217,7 +217,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; //FULLY IMPLEMENTED m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; //FULLY IMPLEMENTED
m_scene.Permissions.OnMoveObject += CanMoveObject; //MAYBE FULLY IMPLEMENTED m_scene.Permissions.OnMoveObject += CanMoveObject; //MAYBE FULLY IMPLEMENTED
m_scene.Permissions.OnObjectEntry += CanObjectEntry; 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.OnRezObject += CanRezObject; //MAYBE FULLY IMPLEMENTED
m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand;
m_scene.Permissions.OnRunScript += CanRunScript; //NOT YET IMPLEMENTED 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.OnDeleteUserInventory += CanDeleteUserInventory; //NOT YET IMPLEMENTED
m_scene.Permissions.OnTeleport += CanTeleport; //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", m_scene.AddCommand(this, "bypass permissions",
"bypass permissions <true / false>", "bypass permissions <true / false>",
@ -1275,12 +1274,106 @@ namespace OpenSim.Region.CoreModules.World.Permissions
return false; return false;
} }
private bool CanReturnObject(UUID objectID, UUID returnerID, Scene scene) private bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene)
{ {
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
if (m_bypassPermissions) return m_bypassPermissionsValue; 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<SceneObjectGroup>(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) 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); return GenericObjectPermission(agentID, prim, false);
} }
private bool CanUseObjectReturn(ILandObject parcel, uint type, IClientAPI client, List<SceneObjectGroup> 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<SceneObjectGroup>(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) { private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) {
//m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType); //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType);
switch (scriptType) { switch (scriptType) {

View File

@ -62,11 +62,14 @@ namespace OpenSim.Region.CoreModules.World.Sound
public virtual void PlayAttachedSound( public virtual void PlayAttachedSound(
UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius) 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 if (dis > 100.0) // Max audio distance
continue; return;
// Scale by distance // Scale by distance
if (radius == 0) if (radius == 0)
@ -74,18 +77,21 @@ namespace OpenSim.Region.CoreModules.World.Sound
else else
gain = (float)((double)gain * ((radius - dis) / radius)); 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( public virtual void TriggerSound(
UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) 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 if (dis > 100.0) // Max audio distance
continue; return;
// Scale by distance // Scale by distance
if (radius == 0) if (radius == 0)
@ -93,9 +99,9 @@ namespace OpenSim.Region.CoreModules.World.Sound
else else
gain = (float)((double)gain * ((radius - dis) / radius)); gain = (float)((double)gain * ((radius - dis) / radius));
p.ControllingClient.SendTriggeredSound( sp.ControllingClient.SendTriggeredSound(
soundId, ownerID, objectID, parentID, handle, position, (float)gain); soundId, ownerID, objectID, parentID, handle, position, (float)gain);
} });
} }
} }
} }

View File

@ -509,14 +509,13 @@ namespace OpenSim.Region.CoreModules
private void SunUpdateToAllClients() private void SunUpdateToAllClients()
{ {
List<ScenePresence> avatars = m_scene.GetAvatars(); m_scene.ForEachScenePresence(delegate(ScenePresence sp)
foreach (ScenePresence avatar in avatars)
{ {
if (!avatar.IsChildAgent) if (!sp.IsChildAgent)
{ {
SunToClient(avatar.ControllingClient); SunToClient(sp.ControllingClient);
}
} }
});
} }
#region ISunModule Members #region ISunModule Members

View File

@ -425,9 +425,7 @@ namespace OpenSim.Region.CoreModules
{ {
if (m_ready) if (m_ready)
{ {
List<ScenePresence> avatars = m_scene.GetAvatars(); if(m_scene.GetRootAgentCount() > 0)
if (avatars.Count > 0)
{ {
// Ask wind plugin to generate a LL wind array to be cached locally // 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 // 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; m_frameLastUpdateClientArray = m_frame;
} }
foreach (ScenePresence avatar in avatars) m_scene.ForEachScenePresence(delegate(ScenePresence sp)
{ {
if (!avatar.IsChildAgent) if (!sp.IsChildAgent)
avatar.ControllingClient.SendWindData(windSpeeds); sp.ControllingClient.SendWindData(windSpeeds);
} });
} }
} }
} }

View File

@ -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 // if you want tree blocks on the map comment the above line and uncomment the below line
//mapdotspot = Color.PaleGreen; //mapdotspot = Color.PaleGreen;
if (part.Shape.Textures == null) Primitive.TextureEntry textureEntry = part.Shape.Textures;
if (textureEntry == null || textureEntry.DefaultTexture == null)
continue; continue;
if (part.Shape.Textures.DefaultTexture == null) Color4 texcolor = textureEntry.DefaultTexture.RGBA;
continue;
Color4 texcolor = part.Shape.Textures.DefaultTexture.RGBA;
// Not sure why some of these are null, oh well. // Not sure why some of these are null, oh well.

View File

@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
// this is here because CAPS map requests work even beyond the 10,000 limit. // this is here because CAPS map requests work even beyond the 10,000 limit.
ScenePresence avatarPresence = null; ScenePresence avatarPresence = null;
m_scene.TryGetAvatar(agentID, out avatarPresence); m_scene.TryGetScenePresence(agentID, out avatarPresence);
if (avatarPresence != null) if (avatarPresence != null)
{ {
@ -304,25 +304,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
/// <param name="AgentId">AgentID that logged out</param> /// <param name="AgentId">AgentID that logged out</param>
private void ClientLoggedOut(UUID AgentId, Scene scene) private void ClientLoggedOut(UUID AgentId, Scene scene)
{ {
List<ScenePresence> 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) lock (m_rootAgents)
{
if (m_rootAgents.Contains(AgentId))
{ {
m_rootAgents.Remove(AgentId); m_rootAgents.Remove(AgentId);
} if(m_rootAgents.Count == 0)
StopThread();
} }
} }
#endregion #endregion
@ -375,11 +361,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
{ {
// Local Map Item Request // Local Map Item Request
List<ScenePresence> avatars = m_scene.GetAvatars();
int tc = Environment.TickCount; int tc = Environment.TickCount;
List<mapItemReply> mapitems = new List<mapItemReply>(); List<mapItemReply> mapitems = new List<mapItemReply>();
mapItemReply mapitem = new mapItemReply(); mapItemReply mapitem = new mapItemReply();
if (avatars.Count == 0 || avatars.Count == 1) if (m_scene.GetRootAgentCount() <= 1)
{ {
mapitem = new mapItemReply(); mapitem = new mapItemReply();
mapitem.x = (uint)(xstart + 1); mapitem.x = (uint)(xstart + 1);
@ -392,21 +377,21 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
} }
else else
{ {
foreach (ScenePresence av in avatars) m_scene.ForEachScenePresence(delegate(ScenePresence sp)
{ {
// Don't send a green dot for yourself // Don't send a green dot for yourself
if (av.UUID != remoteClient.AgentId) if (!sp.IsChildAgent && sp.UUID != remoteClient.AgentId)
{ {
mapitem = new mapItemReply(); mapitem = new mapItemReply();
mapitem.x = (uint)(xstart + av.AbsolutePosition.X); mapitem.x = (uint)(xstart + sp.AbsolutePosition.X);
mapitem.y = (uint)(ystart + av.AbsolutePosition.Y); mapitem.y = (uint)(ystart + sp.AbsolutePosition.Y);
mapitem.id = UUID.Zero; mapitem.id = UUID.Zero;
mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()); mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString());
mapitem.Extra = 1; mapitem.Extra = 1;
mapitem.Extra2 = 0; mapitem.Extra2 = 0;
mapitems.Add(mapitem); mapitems.Add(mapitem);
} }
} });
} }
remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
} }
@ -504,7 +489,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
if (mrs.agentID != UUID.Zero) if (mrs.agentID != UUID.Zero)
{ {
ScenePresence av = null; ScenePresence av = null;
m_scene.TryGetAvatar(mrs.agentID, out av); m_scene.TryGetScenePresence(mrs.agentID, out av);
if (av != null) if (av != null)
{ {
if (response.ContainsKey(mrs.itemtype.ToString())) 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); Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart);
OSDMap responsemap = new OSDMap(); OSDMap responsemap = new OSDMap();
List<ScenePresence> avatars = m_scene.GetAvatars();
OSDArray responsearr = new OSDArray(avatars.Count);
OSDMap responsemapdata = new OSDMap();
int tc = Environment.TickCount; int tc = Environment.TickCount;
/* if (m_scene.GetRootAgentCount() == 0)
foreach (ScenePresence av in avatars)
{ {
responsemapdata = new OSDMap(); OSDMap 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();
responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1)); responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1));
responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1)); responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1));
responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString())); responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
responsemapdata["Extra"] = OSD.FromInteger(0); responsemapdata["Extra"] = OSD.FromInteger(0);
responsemapdata["Extra2"] = OSD.FromInteger(0); responsemapdata["Extra2"] = OSD.FromInteger(0);
OSDArray responsearr = new OSDArray();
responsearr.Add(responsemapdata); responsearr.Add(responsemapdata);
responsemap["6"] = responsearr; responsemap["6"] = responsearr;
} }
else else
{ {
responsearr = new OSDArray(avatars.Count); OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount());
foreach (ScenePresence av in avatars) m_scene.ForEachScenePresence(delegate(ScenePresence sp)
{ {
responsemapdata = new OSDMap(); OSDMap responsemapdata = new OSDMap();
responsemapdata["X"] = OSD.FromInteger((int)(xstart + av.AbsolutePosition.X)); responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X));
responsemapdata["Y"] = OSD.FromInteger((int)(ystart + av.AbsolutePosition.Y)); responsemapdata["Y"] = OSD.FromInteger((int)(ystart + sp.AbsolutePosition.Y));
responsemapdata["ID"] = OSD.FromUUID(UUID.Zero); responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString())); responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
responsemapdata["Extra"] = OSD.FromInteger(1); responsemapdata["Extra"] = OSD.FromInteger(1);
responsemapdata["Extra2"] = OSD.FromInteger(0); responsemapdata["Extra2"] = OSD.FromInteger(0);
responsearr.Add(responsemapdata); responsearr.Add(responsemapdata);
} });
responsemap["6"] = responsearr; responsemap["6"] = responsearr;
} }
return responsemap; return responsemap;
@ -1107,25 +1076,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
private void MakeChildAgent(ScenePresence avatar) private void MakeChildAgent(ScenePresence avatar)
{ {
List<ScenePresence> 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) 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();
} }
} }

View File

@ -203,18 +203,25 @@ namespace OpenSim.Region.DataSnapshot.Providers
{ {
string bestguess = string.Empty; string bestguess = string.Empty;
Dictionary<UUID, int> counts = new Dictionary<UUID, int>(); Dictionary<UUID, int> counts = new Dictionary<UUID, int>();
if (sog.RootPart.Shape != null && sog.RootPart.Shape.ProfileShape == ProfileShape.Square &&
sog.RootPart.Shape.Textures != null && sog.RootPart.Shape.Textures.FaceTextures != null) PrimitiveBaseShape shape = sog.RootPart.Shape;
if (shape != null && shape.ProfileShape == ProfileShape.Square)
{ {
if (sog.RootPart.Shape.Textures.DefaultTexture.TextureID != UUID.Zero && Primitive.TextureEntry textures = shape.Textures;
sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_DefaultImage && if (textures != null)
sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_BlankImage &&
sog.RootPart.Shape.Textures.DefaultTexture.RGBA.A < 50)
{ {
counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = 8; if (textures.DefaultTexture != null &&
textures.DefaultTexture.TextureID != UUID.Zero &&
textures.DefaultTexture.TextureID != m_DefaultImage &&
textures.DefaultTexture.TextureID != m_BlankImage &&
textures.DefaultTexture.RGBA.A < 50f)
{
counts[textures.DefaultTexture.TextureID] = 8;
} }
foreach (Primitive.TextureEntryFace tentry in sog.RootPart.Shape.Textures.FaceTextures) if (textures.FaceTextures != null)
{
foreach (Primitive.TextureEntryFace tentry in textures.FaceTextures)
{ {
if (tentry != null) if (tentry != null)
{ {
@ -224,8 +231,9 @@ namespace OpenSim.Region.DataSnapshot.Providers
counts.TryGetValue(tentry.TextureID, out c); counts.TryGetValue(tentry.TextureID, out c);
counts[tentry.TextureID] = c + 1; counts[tentry.TextureID] = c + 1;
// decrease the default texture count // decrease the default texture count
if (counts.ContainsKey(sog.RootPart.Shape.Textures.DefaultTexture.TextureID)) if (counts.ContainsKey(textures.DefaultTexture.TextureID))
counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] - 1; counts[textures.DefaultTexture.TextureID] = counts[textures.DefaultTexture.TextureID] - 1;
}
} }
} }
} }
@ -241,6 +249,8 @@ namespace OpenSim.Region.DataSnapshot.Providers
} }
} }
} }
}
return bestguess; return bestguess;
} }
} }

View File

@ -88,12 +88,12 @@ namespace OpenSim.Region.Examples.SimpleModule
m_scene.AgentCrossing(m_character.AgentId, Vector3.Zero, false); m_scene.AgentCrossing(m_character.AgentId, Vector3.Zero, false);
} }
List<ScenePresence> avatars = m_scene.GetAvatars(); m_scene.ForEachScenePresence(delegate(ScenePresence sp)
foreach (ScenePresence avatar in avatars)
{ {
avatar.AbsolutePosition = if (!sp.IsChildAgent)
sp.AbsolutePosition =
new Vector3((float)Util.RandomClass.Next(100, 200), (float)Util.RandomClass.Next(30, 200), 2); new Vector3((float)Util.RandomClass.Next(100, 200), (float)Util.RandomClass.Next(30, 200), 2);
} });
} }
// private void AddComplexObjects(RegionInfo regionInfo, Vector3 pos) // private void AddComplexObjects(RegionInfo regionInfo, Vector3 pos)

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System.Collections.Generic;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
@ -34,7 +35,12 @@ namespace OpenSim.Region.Framework.Interfaces
{ {
void Initialise(string connectstring); void Initialise(string connectstring);
EstateSettings LoadEstateSettings(UUID regionID); EstateSettings LoadEstateSettings(UUID regionID, bool create);
EstateSettings LoadEstateSettings(int estateID);
void StoreEstateSettings(EstateSettings es); void StoreEstateSettings(EstateSettings es);
List<int> GetEstates(string search);
bool LinkRegion(UUID regionID, int estateID);
List<UUID> GetRegions(int estateID);
bool DeleteEstate(int estateID);
} }
} }

View File

@ -132,7 +132,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
ScenePresence avatar; ScenePresence avatar;
if (TryGetAvatar(avatarId, out avatar)) if (TryGetScenePresence(avatarId, out avatar))
{ {
IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
if (invAccess != null) if (invAccess != null)
@ -230,7 +230,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
ScenePresence avatar; ScenePresence avatar;
if (TryGetAvatar(avatarId, out avatar)) if (TryGetScenePresence(avatarId, out avatar))
{ {
return CapsUpdateTaskInventoryScriptAsset( return CapsUpdateTaskInventoryScriptAsset(
avatar.ControllingClient, itemId, primId, isScriptRunning, data); avatar.ControllingClient, itemId, primId, isScriptRunning, data);
@ -683,7 +683,7 @@ namespace OpenSim.Region.Framework.Scenes
if (transactionID == UUID.Zero) if (transactionID == UUID.Zero)
{ {
ScenePresence presence; ScenePresence presence;
if (TryGetAvatar(remoteClient.AgentId, out presence)) if (TryGetScenePresence(remoteClient.AgentId, out presence))
{ {
byte[] data = null; byte[] data = null;
@ -941,7 +941,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
ScenePresence avatar; ScenePresence avatar;
if (TryGetAvatar(avatarId, out avatar)) if (TryGetScenePresence(avatarId, out avatar))
{ {
return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId);
} }
@ -1055,7 +1055,7 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence avatar; ScenePresence avatar;
if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
{ {
destPart.GetProperties(avatar.ControllingClient); destPart.GetProperties(avatar.ControllingClient);
} }
@ -1083,7 +1083,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
ScenePresence avatar = null; ScenePresence avatar = null;
if (TryGetAvatar(destID, out avatar)) if (TryGetScenePresence(destID, out avatar))
{ {
//profile.SendInventoryDecendents(avatar.ControllingClient, //profile.SendInventoryDecendents(avatar.ControllingClient,
// profile.RootFolder.ID, true, false); // profile.RootFolder.ID, true, false);
@ -1420,7 +1420,7 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence avatar; ScenePresence avatar;
if (TryGetAvatar(srcTaskItem.OwnerID, out avatar)) if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
{ {
destPart.GetProperties(avatar.ControllingClient); destPart.GetProperties(avatar.ControllingClient);
} }
@ -1518,9 +1518,10 @@ namespace OpenSim.Region.Framework.Scenes
if (remoteClient != null) if (remoteClient != null)
{ {
permissionToTake = permissionToTake =
Permissions.CanReturnObject( Permissions.CanReturnObjects(
grp.UUID, null,
remoteClient.AgentId); remoteClient.AgentId,
new List<SceneObjectGroup>() {grp});
permissionToDelete = permissionToTake; permissionToDelete = permissionToTake;
if (permissionToDelete) if (permissionToDelete)
@ -1860,7 +1861,7 @@ namespace OpenSim.Region.Framework.Scenes
UUID inventoryID = part.ParentGroup.GetFromItemID(); UUID inventoryID = part.ParentGroup.GetFromItemID();
ScenePresence presence; 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)) if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition))
return; return;

View File

@ -48,7 +48,7 @@ namespace OpenSim.Region.Framework.Scenes
public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene);
public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, 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 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<SceneObjectGroup> objects, Scene scene);
public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene); public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene);
public delegate bool InventoryTransferHandler(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); 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 CopyUserInventoryHandler(UUID itemID, UUID userID);
public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID); public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID);
public delegate bool TeleportHandler(UUID userID, Scene scene); public delegate bool TeleportHandler(UUID userID, Scene scene);
public delegate bool UseObjectReturnHandler(ILandObject landData, uint type, IClientAPI client, List<SceneObjectGroup> retlist, Scene scene);
#endregion #endregion
public class ScenePermissions public class ScenePermissions
@ -107,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes
public event EditObjectInventoryHandler OnEditObjectInventory; public event EditObjectInventoryHandler OnEditObjectInventory;
public event MoveObjectHandler OnMoveObject; public event MoveObjectHandler OnMoveObject;
public event ObjectEntryHandler OnObjectEntry; public event ObjectEntryHandler OnObjectEntry;
public event ReturnObjectHandler OnReturnObject; public event ReturnObjectsHandler OnReturnObjects;
public event InstantMessageHandler OnInstantMessage; public event InstantMessageHandler OnInstantMessage;
public event InventoryTransferHandler OnInventoryTransfer; public event InventoryTransferHandler OnInventoryTransfer;
public event ViewScriptHandler OnViewScript; public event ViewScriptHandler OnViewScript;
@ -140,7 +139,6 @@ namespace OpenSim.Region.Framework.Scenes
public event CopyUserInventoryHandler OnCopyUserInventory; public event CopyUserInventoryHandler OnCopyUserInventory;
public event DeleteUserInventoryHandler OnDeleteUserInventory; public event DeleteUserInventoryHandler OnDeleteUserInventory;
public event TeleportHandler OnTeleport; public event TeleportHandler OnTeleport;
public event UseObjectReturnHandler OnUseObjectReturn;
#endregion #endregion
#region Object Permission Checks #region Object Permission Checks
@ -377,15 +375,15 @@ namespace OpenSim.Region.Framework.Scenes
#endregion #endregion
#region RETURN OBJECT #region RETURN OBJECT
public bool CanReturnObject(UUID objectID, UUID returnerID) public bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects)
{ {
ReturnObjectHandler handler = OnReturnObject; ReturnObjectsHandler handler = OnReturnObjects;
if (handler != null) if (handler != null)
{ {
Delegate[] list = handler.GetInvocationList(); 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; return false;
} }
} }
@ -949,20 +947,5 @@ namespace OpenSim.Region.Framework.Scenes
} }
return true; return true;
} }
public bool CanUseObjectReturn(ILandObject landData, uint type , IClientAPI client, List<SceneObjectGroup> 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;
}
} }
} }

View File

@ -131,7 +131,6 @@ namespace OpenSim.Region.Framework.Scenes
private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
private int m_incrementsof15seconds; private int m_incrementsof15seconds;
private volatile bool m_backingup; private volatile bool m_backingup;
private bool m_useAsyncWhenPossible;
private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>();
@ -632,7 +631,44 @@ namespace OpenSim.Region.Framework.Scenes
m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID);
if (m_storageManager.EstateDataStore != null) 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<string>() {"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<int> 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 //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"]; 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 //Animation states
m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
// TODO: Change default to true once the feature is supported // TODO: Change default to true once the feature is supported
@ -1248,6 +1281,82 @@ namespace OpenSim.Region.Framework.Scenes
m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); m_teleportModule = RequestModuleInterface<IEntityTransferModule>();
RegionSyncServerModule = RequestModuleInterface<IRegionSyncServerModule>(); RegionSyncServerModule = RequestModuleInterface<IRegionSyncServerModule>();
RegionSyncClientModule = RequestModuleInterface<IRegionSyncClientModule>(); RegionSyncClientModule = RequestModuleInterface<IRegionSyncClientModule>();
// 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<string, object>();
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<GridRegion> 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 #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) if (sp != null)
{ {
m_log.DebugFormat( m_log.DebugFormat(
@ -3615,8 +3724,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="message">message to display to the user. Reason for being logged off</param> /// <param name="message">message to display to the user. Reason for being logged off</param>
public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
{ {
ScenePresence loggingOffUser = null; ScenePresence loggingOffUser = GetScenePresence(AvatarID);
loggingOffUser = GetScenePresence(AvatarID);
if (loggingOffUser != null) if (loggingOffUser != null)
{ {
UUID localRegionSecret = UUID.Zero; UUID localRegionSecret = UUID.Zero;
@ -3652,10 +3760,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="isFlying"></param> /// <param name="isFlying"></param>
public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
{ {
ScenePresence presence; ScenePresence presence = GetScenePresence(agentID);
m_sceneGraph.TryGetAvatar(agentID, out presence); if(presence != null)
if (presence != null)
{ {
try try
{ {
@ -3829,9 +3935,7 @@ namespace OpenSim.Region.Framework.Scenes
public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position,
Vector3 lookAt, uint teleportFlags) Vector3 lookAt, uint teleportFlags)
{ {
ScenePresence sp; ScenePresence sp = GetScenePresence(remoteClient.AgentId);
m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp);
if (sp != null) if (sp != null)
{ {
uint regionX = m_regInfo.RegionLocX; 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", 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"); "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}", m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}",
scenePresence.Firstname, sp.Firstname,
scenePresence.Lastname, sp.Lastname,
scenePresence.UUID, sp.UUID,
scenePresence.ControllingClient.AgentId, sp.ControllingClient.AgentId,
"Unknown", "Unknown",
"Unknown", "Unknown",
RegionInfo.RegionName); RegionInfo.RegionName);
} });
break; break;
} }
@ -4186,48 +4290,45 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.RemovePhysicalPrim(num); m_sceneGraph.RemovePhysicalPrim(num);
} }
//The idea is to have a group of method that return a list of avatars meeting some requirement public int GetRootAgentCount()
// ie it could be all m_scenePresences within a certain range of the calling prim/avatar.
/// <summary>
/// Return a list of all avatars in this region.
/// This list is a new object, so it can be iterated over without locking.
/// </summary>
/// <returns></returns>
public List<ScenePresence> GetAvatars()
{ {
return m_sceneGraph.GetAvatars(); return m_sceneGraph.GetRootAgentCount();
}
public int GetChildAgentCount()
{
return m_sceneGraph.GetChildAgentCount();
} }
/// <summary> /// <summary>
/// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. /// Request a scene presence by UUID. Fast, indexed lookup.
/// This list is a new object, so it can be iterated over without locking.
/// </summary> /// </summary>
/// <returns></returns> /// <param name="agentID"></param>
public ScenePresence[] GetScenePresences() /// <returns>null if the presence was not found</returns>
public ScenePresence GetScenePresence(UUID agentID)
{ {
return m_sceneGraph.GetScenePresences(); return m_sceneGraph.GetScenePresence(agentID);
} }
/// <summary> /// <summary>
/// Request a filtered list of ScenePresences in this region. /// Request the scene presence by name.
/// This list is a new object, so it can be iterated over without locking.
/// </summary> /// </summary>
/// <param name="filter"></param> /// <param name="firstName"></param>
/// <returns></returns> /// <param name="lastName"></param>
public List<ScenePresence> GetScenePresences(FilterAvatarList filter) /// <returns>null if the presence was not found</returns>
public ScenePresence GetScenePresence(string firstName, string lastName)
{ {
return m_sceneGraph.GetScenePresences(filter); return m_sceneGraph.GetScenePresence(firstName, lastName);
} }
/// <summary> /// <summary>
/// Request a scene presence by UUID /// Request the scene presence by localID.
/// </summary> /// </summary>
/// <param name="avatarID"></param> /// <param name="localID"></param>
/// <returns></returns> /// <returns>null if the presence was not found</returns>
public ScenePresence GetScenePresence(UUID avatarID) public ScenePresence GetScenePresence(uint localID)
{ {
return m_sceneGraph.GetScenePresence(avatarID); return m_sceneGraph.GetScenePresence(localID);
} }
public override bool PresenceChildStatus(UUID avatarID) public override bool PresenceChildStatus(UUID avatarID)
@ -4245,7 +4346,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
/// <summary> /// <summary>
/// /// Performs action on all scene presences.
/// </summary> /// </summary>
/// <param name="action"></param> /// <param name="action"></param>
static int s_ForEachPresenceCounter = 0; 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. // We don't want to try to send messages if there are no avatars.
if (m_sceneGraph != null) if (m_sceneGraph != null)
{ {
try m_sceneGraph.ForEachScenePresence(action);
{
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);
}
} }
} }
@ -4330,9 +4421,9 @@ namespace OpenSim.Region.Framework.Scenes
return m_sceneGraph.GetGroupByPrim(localID); 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) public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
@ -4345,24 +4436,7 @@ namespace OpenSim.Region.Framework.Scenes
// REGION SYNC // REGION SYNC
if (IsSyncedServer()) if (IsSyncedServer())
return; return;
ForEachClient(action, m_useAsyncWhenPossible);
}
public void ForEachClient(Action<IClientAPI> 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); m_clientManager.ForEachSync(action);
//if (doAsynchronous)
// m_clientManager.ForEach(action);
//else
// m_clientManager.ForEachSync(action);
} }
public bool TryGetClient(UUID avatarID, out IClientAPI client) public bool TryGetClient(UUID avatarID, out IClientAPI client)

View File

@ -190,11 +190,11 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="agentID"></param> /// <param name="agentID"></param>
public abstract void RemoveClient(UUID agentID); 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 = null;
ScenePresence sp = null; ScenePresence sp = null;
if (TryGetAvatar(agentID, out sp)) if (TryGetScenePresence(agentID, out sp))
{ {
scenePresence = sp; scenePresence = sp;
return true; return true;
@ -203,7 +203,7 @@ namespace OpenSim.Region.Framework.Scenes
return false; return false;
} }
public abstract bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence); public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence);
#endregion #endregion

View File

@ -165,9 +165,10 @@ namespace OpenSim.Region.Framework.Scenes
protected internal void UpdatePresences() protected internal void UpdatePresences()
{ {
ScenePresence[] updateScenePresences = GetScenePresences(); ForEachScenePresence(delegate(ScenePresence presence)
for (int i = 0; i < updateScenePresences.Length; i++) {
updateScenePresences[i].Update(); presence.Update();
});
} }
protected internal float UpdatePhysics(double elapsed) protected internal float UpdatePhysics(double elapsed)
@ -196,9 +197,10 @@ namespace OpenSim.Region.Framework.Scenes
protected internal void UpdateScenePresenceMovement() protected internal void UpdateScenePresenceMovement()
{ {
ScenePresence[] moveEntities = GetScenePresences(); ForEachScenePresence(delegate(ScenePresence presence)
for (int i = 0; i < moveEntities.Length; i++) {
moveEntities[i].UpdateMovement(); presence.UpdateMovement();
});
} }
#endregion #endregion
@ -616,18 +618,16 @@ namespace OpenSim.Region.Framework.Scenes
public void RecalculateStats() public void RecalculateStats()
{ {
ScenePresence[] presences = GetScenePresences();
int rootcount = 0; int rootcount = 0;
int childcount = 0; int childcount = 0;
for (int i = 0; i < presences.Length; i++) ForEachScenePresence(delegate(ScenePresence presence)
{ {
ScenePresence user = presences[i]; if (presence.IsChildAgent)
if (user.IsChildAgent)
++childcount; ++childcount;
else else
++rootcount; ++rootcount;
} });
m_numRootAgents = rootcount; m_numRootAgents = rootcount;
m_numChildAgents = childcount; m_numChildAgents = childcount;
@ -674,25 +674,6 @@ namespace OpenSim.Region.Framework.Scenes
#endregion #endregion
#region Get Methods #region Get Methods
/// <summary>
/// Request a List of all scene presences in this scene. This is a new list, so no
/// locking is required to iterate over it.
/// </summary>
/// <returns></returns>
protected internal ScenePresence[] GetScenePresences()
{
return m_scenePresenceArray;
}
protected internal List<ScenePresence> GetAvatars()
{
List<ScenePresence> result =
GetScenePresences(delegate(ScenePresence scenePresence) { return !scenePresence.IsChildAgent; });
return result;
}
/// <summary> /// <summary>
/// Get the controlling client for the given avatar, if there is one. /// Get the controlling client for the given avatar, if there is one.
/// ///
@ -719,43 +700,85 @@ namespace OpenSim.Region.Framework.Scenes
} }
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
protected internal List<ScenePresence> GetScenePresences(FilterAvatarList filter) private List<ScenePresence> GetScenePresences()
{ {
// No locking of scene presences here since we're passing back a list... lock (m_scenePresences)
return new List<ScenePresence>(m_scenePresenceArray);
List<ScenePresence> result = new List<ScenePresence>();
ScenePresence[] scenePresences = GetScenePresences();
for (int i = 0; i < scenePresences.Length; i++)
{
ScenePresence avatar = scenePresences[i];
if (filter(avatar))
result.Add(avatar);
}
return result;
} }
/// <summary> /// <summary>
/// Request a scene presence by UUID /// Request a scene presence by UUID. Fast, indexed lookup.
/// </summary> /// </summary>
/// <param name="avatarID"></param> /// <param name="agentID"></param>
/// <returns>null if the agent was not found</returns> /// <returns>null if the presence was not found</returns>
protected internal ScenePresence GetScenePresence(UUID agentID) protected internal ScenePresence GetScenePresence(UUID agentID)
{ {
ScenePresence sp; ScenePresence sp;
lock (m_scenePresences) lock (m_scenePresences)
{ {
m_scenePresences.TryGetValue(agentID, out sp); m_scenePresences.TryGetValue(agentID, out sp);
} }
return sp; return sp;
} }
/// <summary>
/// Request the scene presence by name.
/// </summary>
/// <param name="firstName"></param>
/// <param name="lastName"></param>
/// <returns>null if the presence was not found</returns>
protected internal ScenePresence GetScenePresence(string firstName, string lastName)
{
foreach (ScenePresence presence in GetScenePresences())
{
if (presence.Firstname == firstName && presence.Lastname == lastName)
return presence;
}
return null;
}
/// <summary>
/// Request the scene presence by localID.
/// </summary>
/// <param name="localID"></param>
/// <returns>null if the presence was not found</returns>
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);
}
/// <summary> /// <summary>
/// Get a scene object group that contains the prim with the given local id /// Get a scene object group that contains the prim with the given local id
/// </summary> /// </summary>
@ -907,34 +930,6 @@ namespace OpenSim.Region.Framework.Scenes
return group.GetChildPart(fullID); 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;
}
/// <summary> /// <summary>
/// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over /// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over
/// it /// it
@ -997,6 +992,10 @@ namespace OpenSim.Region.Framework.Scenes
return UUID.Zero; return UUID.Zero;
} }
/// <summary>
/// Performs action on all scene object groups.
/// </summary>
/// <param name="action"></param>
protected internal void ForEachSOG(Action<SceneObjectGroup> action) protected internal void ForEachSOG(Action<SceneObjectGroup> action)
{ {
List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
@ -1014,6 +1013,46 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/// <summary>
/// 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.
/// </summary>
/// <param name="action"></param>
public void ForEachScenePresence(Action<ScenePresence> action)
{
// Once all callers have their delegates configured for parallelism, we can unleash this
/*
Action<ScenePresence> protectedAction = new Action<ScenePresence>(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<ScenePresence>(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 #endregion
#region Client Event handlers #region Client Event handlers

View File

@ -414,12 +414,8 @@ namespace OpenSim.Region.Framework.Scenes
ForEachCurrentScene( ForEachCurrentScene(
delegate(Scene scene) delegate(Scene scene)
{ {
ScenePresence[] scenePresences = scene.GetScenePresences(); scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
for (int i = 0; i < scenePresences.Length; i++)
{ {
ScenePresence scenePresence = scenePresences[i];
if (!scenePresence.IsChildAgent) if (!scenePresence.IsChildAgent)
{ {
m_log.DebugFormat("Packet debug for {0} {1} set to {2}", m_log.DebugFormat("Packet debug for {0} {1} set to {2}",
@ -429,7 +425,7 @@ namespace OpenSim.Region.Framework.Scenes
scenePresence.ControllingClient.SetDebugPacketLevel(newDebug); scenePresence.ControllingClient.SetDebugPacketLevel(newDebug);
} }
} });
} }
); );
} }
@ -441,14 +437,11 @@ namespace OpenSim.Region.Framework.Scenes
ForEachCurrentScene( ForEachCurrentScene(
delegate(Scene scene) delegate(Scene scene)
{ {
ScenePresence[] scenePresences = scene.GetScenePresences(); scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
for (int i = 0; i < scenePresences.Length; i++)
{ {
ScenePresence scenePresence = scenePresences[i];
if (!scenePresence.IsChildAgent) if (!scenePresence.IsChildAgent)
avatars.Add(scenePresence); avatars.Add(scenePresence);
} });
} }
); );
@ -461,8 +454,10 @@ namespace OpenSim.Region.Framework.Scenes
ForEachCurrentScene(delegate(Scene scene) ForEachCurrentScene(delegate(Scene scene)
{ {
ScenePresence[] scenePresences = scene.GetScenePresences(); scene.ForEachScenePresence(delegate(ScenePresence sp)
presences.AddRange(scenePresences); {
presences.Add(sp);
});
}); });
return presences; return presences;
@ -491,11 +486,11 @@ namespace OpenSim.Region.Framework.Scenes
ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); }); 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) foreach (Scene scene in m_localScenes)
{ {
if (scene.TryGetAvatar(avatarId, out avatar)) if (scene.TryGetScenePresence(avatarId, out avatar))
{ {
return true; return true;
} }
@ -510,7 +505,7 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence avatar = null; ScenePresence avatar = null;
foreach (Scene mScene in m_localScenes) foreach (Scene mScene in m_localScenes)
{ {
if (mScene.TryGetAvatar(avatarId, out avatar)) if (mScene.TryGetScenePresence(avatarId, out avatar))
{ {
scene = mScene; scene = mScene;
return true; return true;

View File

@ -1274,7 +1274,6 @@ namespace OpenSim.Region.Framework.Scenes
Scene.RegionSyncServerModule.DeleteObject(part.RegionHandle, part.LocalId); Scene.RegionSyncServerModule.DeleteObject(part.RegionHandle, part.LocalId);
return; return;
} }
Scene.ForEachScenePresence(delegate(ScenePresence avatar) Scene.ForEachScenePresence(delegate(ScenePresence avatar)
{ {
if (avatar.ParentID == LocalId) if (avatar.ParentID == LocalId)

View File

@ -680,7 +680,7 @@ namespace OpenSim.Region.Framework.Scenes
if (m_parentGroup != null) // TODO can there be a SOP without a SOG? if (m_parentGroup != null) // TODO can there be a SOP without a SOG?
{ {
ScenePresence avatar; ScenePresence avatar;
if (m_parentGroup.Scene.TryGetAvatar(m_sitTargetAvatar, out avatar)) if (m_parentGroup.Scene.TryGetScenePresence(m_sitTargetAvatar, out avatar))
{ {
avatar.ParentPosition = GetWorldPosition(); avatar.ParentPosition = GetWorldPosition();
} }
@ -1197,15 +1197,14 @@ namespace OpenSim.Region.Framework.Scenes
private void SendObjectPropertiesToClient(UUID AgentID) private void SendObjectPropertiesToClient(UUID AgentID)
{ {
ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
for (int i = 0; i < avatars.Length; i++)
{ {
// Ugly reference :( // Ugly reference :(
if (avatars[i].UUID == AgentID) if (avatar.UUID == AgentID)
{ {
m_parentGroup.GetProperties(avatars[i].ControllingClient); m_parentGroup.GetProperties(avatar.ControllingClient);
}
} }
});
} }
// TODO: unused: // TODO: unused:
@ -1263,8 +1262,10 @@ namespace OpenSim.Region.Framework.Scenes
// REGION SYNC // REGION SYNC
if (m_parentGroup.Scene.IsSyncedServer()) if (m_parentGroup.Scene.IsSyncedServer())
m_parentGroup.Scene.RegionSyncServerModule.QueuePartForUpdate(this); m_parentGroup.Scene.RegionSyncServerModule.QueuePartForUpdate(this);
m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { avatar.SceneViewer.QueuePartForUpdate(this); }); {
avatar.SceneViewer.QueuePartForUpdate(this);
});
} }
public void AddFullUpdateToAvatar(ScenePresence presence) public void AddFullUpdateToAvatar(ScenePresence presence)
@ -1287,8 +1288,10 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (m_parentGroup.Scene.IsSyncedServer()) if (m_parentGroup.Scene.IsSyncedServer())
m_parentGroup.Scene.RegionSyncServerModule.QueuePartForUpdate(this); m_parentGroup.Scene.RegionSyncServerModule.QueuePartForUpdate(this);
m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { avatar.SceneViewer.QueuePartForUpdate(this); }); {
avatar.SceneViewer.QueuePartForUpdate(this);
});
} }
public void AddTerseUpdateToAvatar(ScenePresence presence) public void AddTerseUpdateToAvatar(ScenePresence presence)
@ -1323,11 +1326,11 @@ namespace OpenSim.Region.Framework.Scenes
if (volume < 0) if (volume < 0)
volume = 0; volume = 0;
List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp)
foreach (ScenePresence p in avatarts)
{ {
p.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); if(!sp.IsChildAgent)
} sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume);
});
} }
/// <summary> /// <summary>
@ -2120,17 +2123,13 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
for (int i = 0; i < avlist.Length; i++)
{ {
ScenePresence av = avlist[i];
if (av.LocalId == localId) if (av.LocalId == localId)
{ {
if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) 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 it is 1, it is to accept ONLY collisions from this avatar
if (found) if (found)
{ {
@ -2152,7 +2151,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
else 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 it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work
if (!found) if (!found)
{ {
@ -2170,7 +2169,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
} });
} }
} }
if (colliding.Count > 0) if (colliding.Count > 0)
@ -2256,17 +2255,13 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
for (int i = 0; i < avlist.Length; i++)
{ {
ScenePresence av = avlist[i];
if (av.LocalId == localId) if (av.LocalId == localId)
{ {
if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) 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 it is 1, it is to accept ONLY collisions from this avatar
if (found) if (found)
{ {
@ -2288,7 +2283,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
else 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 it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work
if (!found) if (!found)
{ {
@ -2306,7 +2301,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
} });
} }
} }
if (colliding.Count > 0) if (colliding.Count > 0)
@ -2387,17 +2382,13 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
for (int i = 0; i < avlist.Length; i++)
{ {
ScenePresence av = avlist[i];
if (av.LocalId == localId) if (av.LocalId == localId)
{ {
if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) 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 it is 1, it is to accept ONLY collisions from this avatar
if (found) if (found)
{ {
@ -2419,7 +2410,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
else 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 it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work
if (!found) if (!found)
{ {
@ -2437,7 +2428,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
} });
} }
} }
@ -2623,12 +2614,13 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp)
foreach (ScenePresence p in avatarts)
{ {
if (!(Util.GetDistanceTo(p.AbsolutePosition, AbsolutePosition) >= 100)) if (sp.IsChildAgent)
p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); return;
} if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100))
sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
});
} }
public void RemFlag(PrimFlags flag) public void RemFlag(PrimFlags flag)
@ -3093,7 +3085,10 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
public void SendTerseUpdateToAllClients() 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) public void SetAttachmentPoint(uint AttachmentPoint)

View File

@ -2402,35 +2402,33 @@ namespace OpenSim.Region.Framework.Scenes
List<Vector3> CoarseLocations = new List<Vector3>(); List<Vector3> CoarseLocations = new List<Vector3>();
List<UUID> AvatarUUIDs = new List<UUID>(); List<UUID> AvatarUUIDs = new List<UUID>();
List<ScenePresence> avatars = m_scene.GetAvatars(); m_scene.ForEachScenePresence(delegate(ScenePresence sp)
for (int i = 0; i < avatars.Count; i++)
{ {
// Requested by LibOMV. Send Course Location on self. if (sp.IsChildAgent)
//if (avatars[i] != this) return;
//{
if (avatars[i].ParentID != 0) if (sp.ParentID != 0)
{ {
// sitting avatar // sitting avatar
SceneObjectPart sop = m_scene.GetSceneObjectPart(avatars[i].ParentID); SceneObjectPart sop = m_scene.GetSceneObjectPart(sp.ParentID);
if (sop != null) if (sop != null)
{ {
CoarseLocations.Add(sop.AbsolutePosition + avatars[i].m_pos); CoarseLocations.Add(sop.AbsolutePosition + sp.m_pos);
AvatarUUIDs.Add(avatars[i].UUID); AvatarUUIDs.Add(sp.UUID);
} }
else else
{ {
// we can't find the parent.. ! arg! // we can't find the parent.. ! arg!
CoarseLocations.Add(avatars[i].m_pos); CoarseLocations.Add(sp.m_pos);
AvatarUUIDs.Add(avatars[i].UUID); AvatarUUIDs.Add(sp.UUID);
} }
} }
else else
{ {
CoarseLocations.Add(avatars[i].m_pos); CoarseLocations.Add(sp.m_pos);
AvatarUUIDs.Add(avatars[i].UUID); AvatarUUIDs.Add(sp.UUID);
}
//}
} }
});
m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations);
@ -2472,13 +2470,10 @@ namespace OpenSim.Region.Framework.Scenes
public void SendInitialFullUpdateToAllClients() public void SendInitialFullUpdateToAllClients()
{ {
m_perfMonMS = Util.EnvironmentTickCount(); m_perfMonMS = Util.EnvironmentTickCount();
int avUpdates = 0;
ScenePresence[] avatars = m_scene.GetScenePresences(); m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
for (int i = 0; i < avatars.Length; i++)
{ {
ScenePresence avatar = avatars[i]; ++avUpdates;
// only send if this is the root (children are only "listening posts" in a foreign region) // only send if this is the root (children are only "listening posts" in a foreign region)
if (!IsChildAgent) if (!IsChildAgent)
{ {
@ -2494,9 +2489,9 @@ namespace OpenSim.Region.Framework.Scenes
avatar.Animator.SendAnimPackToClient(ControllingClient); avatar.Animator.SendAnimPackToClient(ControllingClient);
} }
} }
} });
m_scene.StatsReporter.AddAgentUpdates(avatars.Length); m_scene.StatsReporter.AddAgentUpdates(avUpdates);
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
//Animator.SendAnimPack(); //Animator.SendAnimPack();
@ -2507,13 +2502,15 @@ namespace OpenSim.Region.Framework.Scenes
m_perfMonMS = Util.EnvironmentTickCount(); m_perfMonMS = Util.EnvironmentTickCount();
// only send update from root agents to other clients; children are only "listening posts" // only send update from root agents to other clients; children are only "listening posts"
List<ScenePresence> avatars = m_scene.GetAvatars(); int count = 0;
foreach (ScenePresence avatar in avatars) m_scene.ForEachScenePresence(delegate(ScenePresence sp)
{ {
SendFullUpdateToOtherClient(avatar); if (sp.IsChildAgent)
return;
} SendFullUpdateToOtherClient(sp);
m_scene.StatsReporter.AddAgentUpdates(avatars.Count); ++count;
});
m_scene.StatsReporter.AddAgentUpdates(count);
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
Animator.SendAnimPack(); Animator.SendAnimPack();

View File

@ -66,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence) public override bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -129,21 +129,22 @@ namespace OpenSim.Region.Framework.Scenes
try try
{ {
Primitive.TextureEntry textureEntry = part.Shape.Textures; Primitive.TextureEntry textureEntry = part.Shape.Textures;
if (textureEntry != null)
{
// Get the prim's default texture. This will be used for faces which don't have their own texture // 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; assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture;
// XXX: Not a great way to iterate through face textures, but there's no if (textureEntry.FaceTextures != null)
// other method available to tell how many faces there actually are {
//int i = 0; // 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) foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
{ {
if (texture != null) if (texture != null)
{
//m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++);
assetUuids[texture.TextureID] = AssetType.Texture; assetUuids[texture.TextureID] = AssetType.Texture;
} }
} }
}
// If the prim is a sculpt then preserve this information too // If the prim is a sculpt then preserve this information too
if (part.Shape.SculptTexture != UUID.Zero) if (part.Shape.SculptTexture != UUID.Zero)

View File

@ -318,9 +318,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
{ {
Scene scene = client.Scene as Scene; Scene scene = client.Scene as Scene;
m_log.DebugFormat("[Concierge]: {0} logs off from {1}", client.Name, scene.RegionInfo.RegionName); m_log.DebugFormat("[Concierge]: {0} logs off from {1}", client.Name, scene.RegionInfo.RegionName);
List<ScenePresence> avs = scene.GetAvatars(); AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, client.Name, scene.RegionInfo.RegionName, scene.GetRootAgentCount()));
AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, client.Name, scene.RegionInfo.RegionName, avs.Count)); UpdateBroker(scene);
UpdateBroker(scene, avs);
} }
} }
@ -331,11 +330,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
{ {
Scene scene = agent.Scene; Scene scene = agent.Scene;
m_log.DebugFormat("[Concierge]: {0} enters {1}", agent.Name, scene.RegionInfo.RegionName); m_log.DebugFormat("[Concierge]: {0} enters {1}", agent.Name, scene.RegionInfo.RegionName);
List<ScenePresence> avs = scene.GetAvatars();
WelcomeAvatar(agent, scene); WelcomeAvatar(agent, scene);
AnnounceToAgentsRegion(scene, String.Format(m_announceEntering, agent.Name, AnnounceToAgentsRegion(scene, String.Format(m_announceEntering, agent.Name,
scene.RegionInfo.RegionName, avs.Count)); scene.RegionInfo.RegionName, scene.GetRootAgentCount()));
UpdateBroker(scene, avs); UpdateBroker(scene);
} }
} }
@ -346,10 +344,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
{ {
Scene scene = agent.Scene; Scene scene = agent.Scene;
m_log.DebugFormat("[Concierge]: {0} leaves {1}", agent.Name, scene.RegionInfo.RegionName); m_log.DebugFormat("[Concierge]: {0} leaves {1}", agent.Name, scene.RegionInfo.RegionName);
List<ScenePresence> avs = scene.GetAvatars();
AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, agent.Name, AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, agent.Name,
scene.RegionInfo.RegionName, avs.Count)); scene.RegionInfo.RegionName, scene.GetRootAgentCount()));
UpdateBroker(scene, avs); UpdateBroker(scene);
} }
} }
@ -368,7 +365,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
} }
} }
protected void UpdateBroker(IScene scene, List<ScenePresence> avatars) protected void UpdateBroker(Scene scene)
{ {
if (String.IsNullOrEmpty(m_brokerURI)) if (String.IsNullOrEmpty(m_brokerURI))
return; return;
@ -377,24 +374,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
// create XML sniplet // create XML sniplet
StringBuilder list = new StringBuilder(); StringBuilder list = new StringBuilder();
if (0 == avatars.Count)
{
list.Append(String.Format("<avatars count=\"0\" region_name=\"{0}\" region_uuid=\"{1}\" timestamp=\"{2}\" />",
scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
DateTime.UtcNow.ToString("s")));
}
else
{
list.Append(String.Format("<avatars count=\"{0}\" region_name=\"{1}\" region_uuid=\"{2}\" timestamp=\"{3}\">\n", list.Append(String.Format("<avatars count=\"{0}\" region_name=\"{1}\" region_uuid=\"{2}\" timestamp=\"{3}\">\n",
avatars.Count, scene.RegionInfo.RegionName, scene.GetRootAgentCount(), scene.RegionInfo.RegionName,
scene.RegionInfo.RegionID, scene.RegionInfo.RegionID,
DateTime.UtcNow.ToString("s"))); DateTime.UtcNow.ToString("s")));
foreach (ScenePresence av in avatars) scene.ForEachScenePresence(delegate(ScenePresence sp)
{ {
list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", av.Name, av.UUID)); if (!sp.IsChildAgent)
} {
list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID));
list.Append("</avatars>"); list.Append("</avatars>");
} }
});
string payload = list.ToString(); string payload = list.ToString();
// post via REST to broker // post via REST to broker
@ -529,7 +520,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
// protected void AnnounceToAgentsRegion(Scene scene, string msg) // protected void AnnounceToAgentsRegion(Scene scene, string msg)
// { // {
// ScenePresence agent = null; // 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); // AnnounceToAgentsRegion(agent, msg);
// else // else
// m_log.DebugFormat("[Concierge]: could not find an agent for client {0}", client.Name); // m_log.DebugFormat("[Concierge]: could not find an agent for client {0}", client.Name);

View File

@ -110,7 +110,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
if (m_avatars.ContainsKey(agentID)) if (m_avatars.ContainsKey(agentID))
{ {
ScenePresence sp; ScenePresence sp;
scene.TryGetAvatar(agentID, out sp); scene.TryGetScenePresence(agentID, out sp);
sp.DoAutoPilot(0, pos, m_avatars[agentID]); sp.DoAutoPilot(0, pos, m_avatars[agentID]);
} }
} }
@ -165,7 +165,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
p_scene.AddNewClient(npcAvatar); p_scene.AddNewClient(npcAvatar);
ScenePresence sp; 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); AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene);

View File

@ -707,36 +707,37 @@ namespace OpenSim.Region.RegionCombinerModule
return; return;
} }
List<ScenePresence> avatars = connectiondata.RegionScene.GetAvatars();
List<Vector3> CoarseLocations = new List<Vector3>(); List<Vector3> CoarseLocations = new List<Vector3>();
List<UUID> AvatarUUIDs = new List<UUID>(); List<UUID> AvatarUUIDs = new List<UUID>();
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 // sitting avatar
SceneObjectPart sop = connectiondata.RegionScene.GetSceneObjectPart(avatars[i].ParentID); SceneObjectPart sop = connectiondata.RegionScene.GetSceneObjectPart(sp.ParentID);
if (sop != null) if (sop != null)
{ {
CoarseLocations.Add(sop.AbsolutePosition + avatars[i].AbsolutePosition); CoarseLocations.Add(sop.AbsolutePosition + sp.AbsolutePosition);
AvatarUUIDs.Add(avatars[i].UUID); AvatarUUIDs.Add(sp.UUID);
} }
else else
{ {
// we can't find the parent.. ! arg! // we can't find the parent.. ! arg!
CoarseLocations.Add(avatars[i].AbsolutePosition); CoarseLocations.Add(sp.AbsolutePosition);
AvatarUUIDs.Add(avatars[i].UUID); AvatarUUIDs.Add(sp.UUID);
} }
} }
else else
{ {
CoarseLocations.Add(avatars[i].AbsolutePosition); CoarseLocations.Add(sp.AbsolutePosition);
AvatarUUIDs.Add(avatars[i].UUID); AvatarUUIDs.Add(sp.UUID);
}
} }
} }
});
DistributeCourseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence); DistributeCourseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence);
} }
@ -1004,7 +1005,7 @@ namespace OpenSim.Region.RegionCombinerModule
VirtualRegion.Permissions.OnIssueEstateCommand += BigRegion.PermissionModule.CanIssueEstateCommand; //FULLY IMPLEMENTED VirtualRegion.Permissions.OnIssueEstateCommand += BigRegion.PermissionModule.CanIssueEstateCommand; //FULLY IMPLEMENTED
VirtualRegion.Permissions.OnMoveObject += BigRegion.PermissionModule.CanMoveObject; //MAYBE FULLY IMPLEMENTED VirtualRegion.Permissions.OnMoveObject += BigRegion.PermissionModule.CanMoveObject; //MAYBE FULLY IMPLEMENTED
VirtualRegion.Permissions.OnObjectEntry += BigRegion.PermissionModule.CanObjectEntry; 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.OnRezObject += BigRegion.PermissionModule.CanRezObject; //MAYBE FULLY IMPLEMENTED
VirtualRegion.Permissions.OnRunConsoleCommand += BigRegion.PermissionModule.CanRunConsoleCommand; VirtualRegion.Permissions.OnRunConsoleCommand += BigRegion.PermissionModule.CanRunConsoleCommand;
VirtualRegion.Permissions.OnRunScript += BigRegion.PermissionModule.CanRunScript; //NOT YET IMPLEMENTED 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.OnEditUserInventory += BigRegion.PermissionModule.CanEditUserInventory; //NOT YET IMPLEMENTED
VirtualRegion.Permissions.OnDeleteUserInventory += BigRegion.PermissionModule.CanDeleteUserInventory; //NOT YET IMPLEMENTED VirtualRegion.Permissions.OnDeleteUserInventory += BigRegion.PermissionModule.CanDeleteUserInventory; //NOT YET IMPLEMENTED
VirtualRegion.Permissions.OnTeleport += BigRegion.PermissionModule.CanTeleport; //NOT YET IMPLEMENTED VirtualRegion.Permissions.OnTeleport += BigRegion.PermissionModule.CanTeleport; //NOT YET IMPLEMENTED
VirtualRegion.Permissions.OnUseObjectReturn += BigRegion.PermissionModule.CanUseObjectReturn; //NOT YET IMPLEMENTED
} }
#region console commands #region console commands

View File

@ -135,9 +135,9 @@ namespace OpenSim.Region.RegionCombinerModule
return m_rootScene.Permissions.CanObjectEntry(objectid, enteringregion, newpoint); 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<SceneObjectGroup> 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) 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); return m_rootScene.Permissions.CanTeleport(userid);
} }
public bool CanUseObjectReturn(ILandObject landdata, uint type, IClientAPI client, List<SceneObjectGroup> retlist, Scene scene)
{
return m_rootScene.Permissions.CanUseObjectReturn(landdata, type, client, retlist);
}
#endregion #endregion
} }
} }

View File

@ -5092,7 +5092,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llGetRegionAgentCount() public LSL_Integer llGetRegionAgentCount()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
return new LSL_Integer(World.GetAvatars().Count); return new LSL_Integer(World.GetRootAgentCount());
} }
public LSL_Vector llGetRegionCorner() public LSL_Vector llGetRegionCorner()
@ -8771,10 +8771,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
landObject.SetMediaUrl(url); landObject.SetMediaUrl(url);
// now send to all (non-child) agents // now send to all (non-child) agents
List<ScenePresence> agents = World.GetAvatars(); World.ForEachScenePresence(delegate(ScenePresence sp)
foreach (ScenePresence agent in agents)
{ {
agent.ControllingClient.SendParcelMediaUpdate(landData.MediaURL, if (!sp.IsChildAgent)
{
sp.ControllingClient.SendParcelMediaUpdate(landData.MediaURL,
landData.MediaID, landData.MediaID,
landData.MediaAutoScale, landData.MediaAutoScale,
mediaType, mediaType,
@ -8782,6 +8783,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
width, height, width, height,
loop); loop);
} }
});
} }
else if (!presence.IsChildAgent) else if (!presence.IsChildAgent)
{ {
@ -8802,13 +8804,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (presence == null) if (presence == null)
{ {
// send to all (non-child) agents // send to all (non-child) agents
List<ScenePresence> agents = World.GetAvatars(); World.ForEachScenePresence(delegate(ScenePresence sp)
foreach (ScenePresence agent in agents)
{ {
agent.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this? if (!sp.IsChildAgent)
{
sp.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this?
(ParcelMediaCommandEnum)commandToSend, (ParcelMediaCommandEnum)commandToSend,
time); time);
} }
});
} }
else if (!presence.IsChildAgent) else if (!presence.IsChildAgent)
{ {

View File

@ -697,10 +697,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.None, "osGetAgents"); CheckThreatLevel(ThreatLevel.None, "osGetAgents");
LSL_List result = new LSL_List(); 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; return result;
} }
@ -1985,19 +1986,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar");
if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
{ {
foreach (ScenePresence presence in World.GetAvatars()) World.ForEachScenePresence(delegate(ScenePresence sp)
{ {
if ((presence.Firstname == FirstName) && if (!sp.IsChildAgent &&
presence.Lastname == SurName) sp.Firstname == FirstName &&
sp.Lastname == SurName)
{ {
// kick client... // kick client...
if (alert != null) if (alert != null)
presence.ControllingClient.Kick(alert); sp.ControllingClient.Kick(alert);
// ...and close on our side // ...and close on our side
presence.Scene.IncomingCloseAgent(presence.UUID); sp.Scene.IncomingCloseAgent(sp.UUID);
}
} }
});
} }
} }

View File

@ -404,70 +404,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) private List<SensedEntity> doAgentSensor(SenseRepeatClass ts)
{ {
List<ScenePresence> presences;
List<SensedEntity> sensedEntities = new List<SensedEntity>(); List<SensedEntity> sensedEntities = new List<SensedEntity>();
// 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<ScenePresence>();
presences.Add(p);
}
else
{
presences = new List<ScenePresence>(m_CmdManager.m_ScriptEngine.World.GetScenePresences());
}
// If nobody about quit fast // If nobody about quit fast
if (presences.Count == 0) if(m_CmdManager.m_ScriptEngine.World.GetRootAgentCount() == 0)
return sensedEntities; return sensedEntities;
SceneObjectPart SensePoint = ts.host; SceneObjectPart SensePoint = ts.host;
Vector3 fromRegionPos = SensePoint.AbsolutePosition; Vector3 fromRegionPos = SensePoint.AbsolutePosition;
Quaternion q = SensePoint.RotationOffset; Quaternion q = SensePoint.RotationOffset;
LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 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); LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
bool attached = (SensePoint.AttachmentPoint != 0); bool attached = (SensePoint.AttachmentPoint != 0);
bool nameSearch = (ts.name != null && ts.name != "");
Vector3 toRegionPos; Vector3 toRegionPos;
double dis; double dis;
for (int i = 0; i < presences.Count; i++) Action<ScenePresence> senseEntity = new Action<ScenePresence>(delegate(ScenePresence presence)
{ {
ScenePresence presence = presences[i]; if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0)
bool keep = true; 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 the object the script is in is attached and the avatar is the owner // if the object the script is in is attached and the avatar is the owner
// then this one is not wanted // then this one is not wanted
if (attached && presence.UUID == SensePoint.OwnerID) if (attached && presence.UUID == SensePoint.OwnerID)
keep = false; return;
// check the name if needed toRegionPos = presence.AbsolutePosition;
if (keep && nameSearch && ts.name != presence.Name) dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos));
keep = false;
// are they in range
if (dis <= ts.range)
{
// Are they in the required angle of view // 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 ? // not omni-directional. Can you see it ?
// vec forward_dir = llRot2Fwd(llGetRot()) // vec forward_dir = llRot2Fwd(llGetRot())
@ -488,26 +458,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
catch catch
{ {
} }
if (ang_obj > ts.arc) keep = false; if (ang_obj <= ts.arc)
}
}
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)); 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 this is an avatar sense by key try to get them directly
if (nameSearch && ts.name == presence.Name) // 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; 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; return sensedEntities;
} }

View File

@ -68,17 +68,15 @@ namespace OpenSim.Region.UserStatistics
HTMLUtil.OL_O(ref output, ""); HTMLUtil.OL_O(ref output, "");
foreach (Scene scene in all_scenes) foreach (Scene scene in all_scenes)
{ {
ScenePresence[] avatarInScene = scene.GetScenePresences();
HTMLUtil.LI_O(ref output, String.Empty); HTMLUtil.LI_O(ref output, String.Empty);
output.Append(scene.RegionInfo.RegionName); output.Append(scene.RegionInfo.RegionName);
HTMLUtil.OL_O(ref output, String.Empty); HTMLUtil.OL_O(ref output, String.Empty);
foreach (ScenePresence av in avatarInScene) scene.ForEachScenePresence(delegate(ScenePresence av)
{ {
Dictionary<string,string> queues = new Dictionary<string, string>(); Dictionary<string, string> queues = new Dictionary<string, string>();
if (av.ControllingClient is IStatsCollector) if (av.ControllingClient is IStatsCollector)
{ {
IStatsCollector isClient = (IStatsCollector) av.ControllingClient; IStatsCollector isClient = (IStatsCollector)av.ControllingClient;
queues = decodeQueueReport(isClient.Report()); queues = decodeQueueReport(isClient.Report());
} }
HTMLUtil.LI_O(ref output, String.Empty); HTMLUtil.LI_O(ref output, String.Empty);
@ -92,8 +90,8 @@ namespace OpenSim.Region.UserStatistics
else else
{ {
output.Append(string.Format("<br /><NOBR>Position: <{0},{1},{2}></NOBR>", (int)av.AbsolutePosition.X, output.Append(string.Format("<br /><NOBR>Position: <{0},{1},{2}></NOBR>", (int)av.AbsolutePosition.X,
(int) av.AbsolutePosition.Y, (int)av.AbsolutePosition.Y,
(int) av.AbsolutePosition.Z)); (int)av.AbsolutePosition.Z));
} }
Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1)); Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
@ -124,7 +122,7 @@ namespace OpenSim.Region.UserStatistics
HTMLUtil.UL_C(ref output); HTMLUtil.UL_C(ref output);
HTMLUtil.LI_C(ref output); HTMLUtil.LI_C(ref output);
} });
HTMLUtil.OL_C(ref output); HTMLUtil.OL_C(ref output);
} }
HTMLUtil.OL_C(ref output); HTMLUtil.OL_C(ref output);

View File

@ -114,7 +114,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
{ {
string credential = identity["Credential"].AsString(); string credential = identity["Credential"].AsString();
if (password == credential || Utils.MD5String(password) == credential) if (password == credential || "$1$" + Utils.MD5String(password) == credential)
return Authorize(principalID); return Authorize(principalID);
} }
} }

View File

@ -76,7 +76,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
public void Initialise(IConfigSource source) 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"]; IConfig assetConfig = source.Configs["FriendsService"];
if (assetConfig == null) if (assetConfig == null)

View File

@ -301,7 +301,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
private void SignificantClientMovementHandler(IClientAPI client) private void SignificantClientMovementHandler(IClientAPI client)
{ {
ScenePresence sp; 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); ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
} }
@ -312,7 +312,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
client.OnConnectionClosed -= LogoutHandler; client.OnConnectionClosed -= LogoutHandler;
object obj; 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 // The avatar is still in the scene, we can get the exact logout position
ScenePresence sp = (ScenePresence)obj; ScenePresence sp = (ScenePresence)obj;

View File

@ -150,7 +150,7 @@ namespace OpenSim.Services.Interfaces
List<UserAccount> GetUserAccounts(UUID scopeID, string query); List<UserAccount> GetUserAccounts(UUID scopeID, string query);
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
/// <param name="data"></param> /// <param name="data"></param>
/// <returns></returns> /// <returns></returns>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -37,13 +37,6 @@
; performance on .NET/Windows ; performance on .NET/Windows
async_call_method = SmartThreadPool 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 ; Max threads to allocate on the FireAndForget thread pool
; when running with the SmartThreadPool option above ; when running with the SmartThreadPool option above
MaxPoolThreads = 15 MaxPoolThreads = 15