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

View File

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

View File

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

View File

@ -83,7 +83,7 @@ namespace OpenSim.Data.MSSQL
/// </summary>
/// <param name="regionID">region ID.</param>
/// <returns></returns>
public EstateSettings LoadEstateSettings(UUID regionID)
public EstateSettings LoadEstateSettings(UUID regionID, bool create)
{
EstateSettings es = new EstateSettings();
@ -127,7 +127,7 @@ namespace OpenSim.Data.MSSQL
}
if (insertEstate)
if (insertEstate && create)
{
List<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??
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
}
}

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) +
" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID";
bool migration = true;
using (MySqlCommand cmd = new MySqlCommand())
{
cmd.CommandText = sql;
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
return DoLoad(cmd, regionID, create);
}
}
private EstateSettings DoLoad(MySqlCommand cmd, UUID regionID, bool create)
{
EstateSettings es = new EstateSettings();
es.OnSave += StoreEstateSettings;
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
using (MySqlCommand cmd = dbcon.CreateCommand())
{
cmd.CommandText = sql;
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
cmd.Connection = dbcon;
bool found = false;
using (IDataReader r = cmd.ExecuteReader())
{
if (r.Read())
{
migration = false;
found = true;
foreach (string name in FieldList)
{
@ -170,62 +178,53 @@ namespace OpenSim.Data.MySQL
}
}
}
}
if (migration)
if (!found && create)
{
// Migration case
List<string> names = new List<string>(FieldList);
names.Remove("EstateID");
sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")";
string sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")";
using (MySqlCommand cmd = dbcon.CreateCommand())
using (MySqlCommand cmd2 = dbcon.CreateCommand())
{
cmd.CommandText = sql;
cmd.Parameters.Clear();
cmd2.CommandText = sql;
cmd2.Parameters.Clear();
foreach (string name in FieldList)
{
if (m_FieldMap[name].GetValue(es) is bool)
{
if ((bool)m_FieldMap[name].GetValue(es))
cmd.Parameters.AddWithValue("?" + name, "1");
cmd2.Parameters.AddWithValue("?" + name, "1");
else
cmd.Parameters.AddWithValue("?" + name, "0");
cmd2.Parameters.AddWithValue("?" + name, "0");
}
else
{
cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString());
cmd2.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString());
}
}
cmd.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
cmd.CommandText = "select LAST_INSERT_ID() as id";
cmd.Parameters.Clear();
cmd2.CommandText = "select LAST_INSERT_ID() as id";
cmd2.Parameters.Clear();
using (IDataReader r = cmd.ExecuteReader())
using (IDataReader r = cmd2.ExecuteReader())
{
r.Read();
es.EstateID = Convert.ToUInt32(r["id"]);
}
cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)";
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
cmd2.CommandText = "insert into estate_map values (?RegionID, ?EstateID)";
cmd2.Parameters.AddWithValue("?RegionID", regionID.ToString());
cmd2.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
// This will throw on dupe key
try { cmd.ExecuteNonQuery(); }
catch (Exception) { }
// Munge and transfer the ban list
cmd.Parameters.Clear();
cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID";
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
try { cmd.ExecuteNonQuery(); }
try { cmd2.ExecuteNonQuery(); }
catch (Exception) { }
es.Save();
@ -398,5 +397,83 @@ namespace OpenSim.Data.MySQL
return uuids.ToArray();
}
public EstateSettings LoadEstateSettings(int estateID)
{
using (MySqlCommand cmd = new MySqlCommand())
{
string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_settings where EstateID = ?EstateID";
cmd.CommandText = sql;
cmd.Parameters.AddWithValue("?EstateID", estateID);
return DoLoad(cmd, UUID.Zero, false);
}
}
public List<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(); }
}
public EstateSettings LoadEstateSettings(UUID regionID)
public EstateSettings LoadEstateSettings(UUID regionID, bool create)
{
EstateSettings es = new EstateSettings();
es.OnSave += StoreEstateSettings;
string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID";
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
@ -92,6 +89,14 @@ namespace OpenSim.Data.SQLite
cmd.CommandText = sql;
cmd.Parameters.Add(":RegionID", regionID.ToString());
return DoLoad(cmd, regionID, create);
}
private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create)
{
EstateSettings es = new EstateSettings();
es.OnSave += StoreEstateSettings;
IDataReader r = cmd.ExecuteReader();
if (r.Read())
@ -120,17 +125,15 @@ namespace OpenSim.Data.SQLite
}
r.Close();
}
else
else if (create)
{
// Migration case
//
r.Close();
List<string> names = new List<string>(FieldList);
names.Remove("EstateID");
sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")";
string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")";
cmd.CommandText = sql;
cmd.Parameters.Clear();
@ -176,20 +179,6 @@ namespace OpenSim.Data.SQLite
{
}
// Munge and transfer the ban list
//
cmd.Parameters.Clear();
cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = :UUID";
cmd.Parameters.Add(":UUID", regionID.ToString());
try
{
cmd.ExecuteNonQuery();
}
catch (Exception)
{
}
es.Save();
}
@ -336,5 +325,63 @@ namespace OpenSim.Data.SQLite
return uuids.ToArray();
}
public EstateSettings LoadEstateSettings(int estateID)
{
string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID :EstateID";
SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
cmd.CommandText = sql;
cmd.Parameters.Add(":EstateID", estateID.ToString());
return DoLoad(cmd, UUID.Zero, false);
}
public List<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()
{
// 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>()
.DontScramble(x=>x.EstateID)
.Scramble(originalSettings);
@ -167,7 +167,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
// Checking that loaded values are correct.
Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
@ -177,7 +177,7 @@ namespace OpenSim.Data.Tests
public void T020_EstateSettingsManagerList()
{
// Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 };
@ -185,7 +185,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
Assert.AreEqual(2, loadedSettings.EstateManagers.Length);
Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]);
@ -196,7 +196,7 @@ namespace OpenSim.Data.Tests
public void T021_EstateSettingsUserList()
{
// Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 };
@ -204,7 +204,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]);
@ -215,7 +215,7 @@ namespace OpenSim.Data.Tests
public void T022_EstateSettingsGroupList()
{
// Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 };
@ -223,7 +223,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]);
@ -234,7 +234,7 @@ namespace OpenSim.Data.Tests
public void T022_EstateSettingsBanList()
{
// Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
EstateBan estateBan1 = new EstateBan();
estateBan1.BannedUserID = DataTestUtil.UUID_MIN;
@ -248,7 +248,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
Assert.AreEqual(2, loadedSettings.EstateBans.Length);
Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID);
@ -290,7 +290,7 @@ namespace OpenSim.Data.Tests
{
// Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(regionId);
EstateSettings originalSettings = db.LoadEstateSettings(regionId, true);
SetEstateSettings(
originalSettings,
@ -347,7 +347,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
EstateSettings loadedSettings = db.LoadEstateSettings(regionId);
EstateSettings loadedSettings = db.LoadEstateSettings(regionId, true);
// Checking that loaded values are correct.
ValidateEstateSettings(

View File

@ -35,7 +35,6 @@ namespace OpenSim.Framework
public class EstateSettings
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private readonly ConfigurationMember configMember;
public delegate void SaveDelegate(EstateSettings rs);
@ -43,7 +42,7 @@ namespace OpenSim.Framework
// Only the client uses these
//
private uint m_EstateID = 100;
private uint m_EstateID = 0;
public uint EstateID
{
@ -51,7 +50,7 @@ namespace OpenSim.Framework
set { m_EstateID = value; }
}
private string m_EstateName;
private string m_EstateName = "My Estate";
public string EstateName
{
@ -59,7 +58,7 @@ namespace OpenSim.Framework
set { m_EstateName = value; }
}
private uint m_ParentEstateID = 100;
private uint m_ParentEstateID = 1;
public uint ParentEstateID
{
@ -67,7 +66,7 @@ namespace OpenSim.Framework
set { m_ParentEstateID = value; }
}
private float m_BillableFactor;
private float m_BillableFactor = 0.0f;
public float BillableFactor
{
@ -75,7 +74,7 @@ namespace OpenSim.Framework
set { m_BillableFactor = value; }
}
private int m_PricePerMeter;
private int m_PricePerMeter = 1;
public int PricePerMeter
{
@ -83,7 +82,7 @@ namespace OpenSim.Framework
set { m_PricePerMeter = value; }
}
private int m_RedirectGridX;
private int m_RedirectGridX = 0;
public int RedirectGridX
{
@ -91,7 +90,7 @@ namespace OpenSim.Framework
set { m_RedirectGridX = value; }
}
private int m_RedirectGridY;
private int m_RedirectGridY = 0;
public int RedirectGridY
{
@ -273,25 +272,6 @@ namespace OpenSim.Framework
public EstateSettings()
{
if (configMember == null)
{
try
{
// Load legacy defaults
//
configMember =
new ConfigurationMember(Path.Combine(Util.configDir(),
"estate_settings.xml"), "ESTATE SETTINGS",
loadConfigurationOptions,
handleIncomingConfiguration, true);
l_EstateManagers.Clear();
configMember.performConfigurationRetrieve();
}
catch (Exception)
{
}
}
}
public void Save()
@ -393,165 +373,5 @@ namespace OpenSim.Framework
return l_EstateAccess.Contains(user);
}
public void loadConfigurationOptions()
{
configMember.addConfigurationOption("billable_factor",
ConfigurationOption.ConfigurationTypes.TYPE_FLOAT,
String.Empty, "0.0", true);
// configMember.addConfigurationOption("estate_id",
// ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
// String.Empty, "100", true);
// configMember.addConfigurationOption("parent_estate_id",
// ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
// String.Empty, "1", true);
configMember.addConfigurationOption("redirect_grid_x",
ConfigurationOption.ConfigurationTypes.TYPE_INT32,
String.Empty, "0", true);
configMember.addConfigurationOption("redirect_grid_y",
ConfigurationOption.ConfigurationTypes.TYPE_INT32,
String.Empty, "0", true);
configMember.addConfigurationOption("price_per_meter",
ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
String.Empty, "1", true);
configMember.addConfigurationOption("estate_name",
ConfigurationOption.ConfigurationTypes.TYPE_STRING,
String.Empty, "My Estate", true);
configMember.addConfigurationOption("estate_manager_0",
ConfigurationOption.ConfigurationTypes.TYPE_UUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_1",
ConfigurationOption.ConfigurationTypes.TYPE_UUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_2",
ConfigurationOption.ConfigurationTypes.TYPE_UUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_3",
ConfigurationOption.ConfigurationTypes.TYPE_UUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_4",
ConfigurationOption.ConfigurationTypes.TYPE_UUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_5",
ConfigurationOption.ConfigurationTypes.TYPE_UUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_6",
ConfigurationOption.ConfigurationTypes.TYPE_UUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_7",
ConfigurationOption.ConfigurationTypes.TYPE_UUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_8",
ConfigurationOption.ConfigurationTypes.TYPE_UUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("estate_manager_9",
ConfigurationOption.ConfigurationTypes.TYPE_UUID,
String.Empty, "00000000-0000-0000-0000-000000000000", true);
configMember.addConfigurationOption("region_flags",
ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
String.Empty, "336723974", true);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
{
switch (configuration_key)
{
case "region_flags":
RegionFlags flags = (RegionFlags)(uint)configuration_result;
if ((flags & (RegionFlags)(1<<29)) != 0)
m_AllowVoice = true;
if ((flags & RegionFlags.AllowDirectTeleport) != 0)
m_AllowDirectTeleport = true;
if ((flags & RegionFlags.DenyAnonymous) != 0)
m_DenyAnonymous = true;
if ((flags & RegionFlags.DenyIdentified) != 0)
m_DenyIdentified = true;
if ((flags & RegionFlags.DenyTransacted) != 0)
m_DenyTransacted = true;
if ((flags & RegionFlags.AbuseEmailToEstateOwner) != 0)
m_AbuseEmailToEstateOwner = true;
if ((flags & RegionFlags.BlockDwell) != 0)
m_BlockDwell = true;
if ((flags & RegionFlags.EstateSkipScripts) != 0)
m_EstateSkipScripts = true;
if ((flags & RegionFlags.ResetHomeOnTeleport) != 0)
m_ResetHomeOnTeleport = true;
if ((flags & RegionFlags.TaxFree) != 0)
m_TaxFree = true;
if ((flags & RegionFlags.PublicAllowed) != 0)
m_PublicAccess = true;
break;
case "billable_factor":
m_BillableFactor = (float) configuration_result;
break;
// case "estate_id":
// m_EstateID = (uint) configuration_result;
// break;
// case "parent_estate_id":
// m_ParentEstateID = (uint) configuration_result;
// break;
case "redirect_grid_x":
m_RedirectGridX = (int) configuration_result;
break;
case "redirect_grid_y":
m_RedirectGridY = (int) configuration_result;
break;
case "price_per_meter":
m_PricePerMeter = Convert.ToInt32(configuration_result);
break;
case "estate_name":
m_EstateName = (string) configuration_result;
break;
case "estate_manager_0":
AddEstateManager((UUID)configuration_result);
break;
case "estate_manager_1":
AddEstateManager((UUID)configuration_result);
break;
case "estate_manager_2":
AddEstateManager((UUID)configuration_result);
break;
case "estate_manager_3":
AddEstateManager((UUID)configuration_result);
break;
case "estate_manager_4":
AddEstateManager((UUID)configuration_result);
break;
case "estate_manager_5":
AddEstateManager((UUID)configuration_result);
break;
case "estate_manager_6":
AddEstateManager((UUID)configuration_result);
break;
case "estate_manager_7":
AddEstateManager((UUID)configuration_result);
break;
case "estate_manager_8":
AddEstateManager((UUID)configuration_result);
break;
case "estate_manager_9":
AddEstateManager((UUID)configuration_result);
break;
}
return true;
}
}
}

View File

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

View File

@ -227,8 +227,12 @@ namespace OpenSim.Framework
{
get
{
//m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length);
return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length);
//m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length);
try { return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); }
catch { }
m_log.Warn("[SHAPE]: Failed to decode texture, length=" + ((m_textureEntry != null) ? m_textureEntry.Length : 0));
return new Primitive.TextureEntry(null);
}
set { m_textureEntry = value.GetBytes(); }

View File

@ -42,6 +42,7 @@ using Nwc.XmlRpc;
using OpenMetaverse.StructuredData;
using CoolHTTPListener = HttpServer.HttpListener;
using HttpListener=System.Net.HttpListener;
using LogPrio=HttpServer.LogPrio;
namespace OpenSim.Framework.Servers.HttpServer
{
@ -341,7 +342,7 @@ namespace OpenSim.Framework.Servers.HttpServer
// the request can be passed through to the other handlers. This is a low
// probability event; if a request is matched it is normally expected to be
// handled
//m_log.Debug("[BASE HTTP SERVER]: Handling Request" + request.RawUrl);
// m_log.Debug("[BASE HTTP SERVER]: Handling request to " + request.RawUrl);
IHttpAgentHandler agentHandler;
@ -496,7 +497,8 @@ namespace OpenSim.Framework.Servers.HttpServer
{
case null:
case "text/html":
//m_log.Info("[Debug BASE HTTP SERVER]: found a text/html content type");
// m_log.DebugFormat(
// "[BASE HTTP SERVER]: Found a text/html content type for request {0}", request.RawUrl);
HandleHTTPRequest(request, response);
return;
@ -524,10 +526,11 @@ namespace OpenSim.Framework.Servers.HttpServer
HandleLLSDRequests(request, response);
return;
}
//m_log.Info("[Debug BASE HTTP SERVER]: Checking for HTTP Handler");
// m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl);
if (DoWeHaveAHTTPHandler(request.RawUrl))
{
//m_log.Info("[Debug BASE HTTP SERVER]: found HTTP Handler");
// m_log.DebugFormat("[BASE HTTP SERVER]: Found HTTP Handler for request {0}", request.RawUrl);
HandleHTTPRequest(request, response);
return;
}
@ -943,7 +946,7 @@ namespace OpenSim.Framework.Servers.HttpServer
}
catch (IOException e)
{
m_log.DebugFormat("[BASE HTTP SERVER]: LLSD IOException {0}.", e);
m_log.WarnFormat("[BASE HTTP SERVER]: LLSD IOException {0}.", e);
}
catch (SocketException e)
{
@ -1219,6 +1222,10 @@ namespace OpenSim.Framework.Servers.HttpServer
public void HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response)
{
// m_log.DebugFormat(
// "[BASE HTTP SERVER]: HandleHTTPRequest for request to {0}, method {1}",
// request.RawUrl, request.HttpMethod);
switch (request.HttpMethod)
{
case "OPTIONS":
@ -1233,6 +1240,8 @@ namespace OpenSim.Framework.Servers.HttpServer
private void HandleContentVerbs(OSHttpRequest request, OSHttpResponse response)
{
// m_log.DebugFormat("[BASE HTTP SERVER]: HandleContentVerbs for request to {0}", request.RawUrl);
// This is a test. There's a workable alternative.. as this way sucks.
// We'd like to put this into a text file parhaps that's easily editable.
//
@ -1273,13 +1282,15 @@ namespace OpenSim.Framework.Servers.HttpServer
foreach (string queryname in querystringkeys)
{
// m_log.DebugFormat(
// "[BASE HTTP SERVER]: Got query paremeter {0}={1}", queryname, request.QueryString[queryname]);
keysvals.Add(queryname, request.QueryString[queryname]);
requestVars.Add(queryname, keysvals[queryname]);
}
foreach (string headername in rHeaders)
{
//m_log.Warn("[HEADER]: " + headername + "=" + request.Headers[headername]);
// m_log.Debug("[BASE HTTP SERVER]: " + headername + "=" + request.Headers[headername]);
headervals[headername] = request.Headers[headername];
}
@ -1291,12 +1302,13 @@ namespace OpenSim.Framework.Servers.HttpServer
keysvals.Add("headers", headervals);
keysvals.Add("querystringkeys", querystringkeys);
keysvals.Add("requestvars", requestVars);
// keysvals.Add("form", request.Form);
if (keysvals.Contains("method"))
{
//m_log.Warn("[HTTP]: Contains Method");
// m_log.Debug("[BASE HTTP SERVER]: Contains Method");
string method = (string) keysvals["method"];
//m_log.Warn("[HTTP]: " + requestBody);
// m_log.Debug("[BASE HTTP SERVER]: " + requestBody);
GenericHTTPMethod requestprocessor;
bool foundHandler = TryGetHTTPHandler(method, out requestprocessor);
if (foundHandler)
@ -1308,13 +1320,12 @@ namespace OpenSim.Framework.Servers.HttpServer
}
else
{
//m_log.Warn("[HTTP]: Handler Not Found");
// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found");
SendHTML404(response, host);
}
}
else
{
GenericHTTPMethod requestprocessor;
bool foundHandler = TryGetHTTPHandlerPathBased(request.RawUrl, out requestprocessor);
if (foundHandler)
@ -1326,7 +1337,7 @@ namespace OpenSim.Framework.Servers.HttpServer
}
else
{
//m_log.Warn("[HTTP]: Handler Not Found");
// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found2");
SendHTML404(response, host);
}
}
@ -1374,8 +1385,7 @@ namespace OpenSim.Framework.Servers.HttpServer
{
if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length)
{
// You have to specifically register for '/' and to get it, you must specificaly request it
//
// You have to specifically register for '/' and to get it, you must specifically request it
if (pattern == "/" && searchquery == "/" || pattern != "/")
bestMatch = pattern;
}
@ -1814,30 +1824,36 @@ namespace OpenSim.Framework.Servers.HttpServer
/// <summary>
/// Relays HttpServer log messages to our own logging mechanism.
/// </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
{
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public void Write(object source, LogPrio priority, string message)
{
/*
switch (priority)
{
case HttpServer.LogPrio.Debug:
m_log.DebugFormat("[{0}]: {1}", source.ToString(), message);
case LogPrio.Trace:
m_log.DebugFormat("[{0}]: {1}", source, message);
break;
case HttpServer.LogPrio.Error:
m_log.ErrorFormat("[{0}]: {1}", source.ToString(), message);
case LogPrio.Debug:
m_log.DebugFormat("[{0}]: {1}", source, message);
break;
case HttpServer.LogPrio.Info:
m_log.InfoFormat("[{0}]: {1}", source.ToString(), message);
case LogPrio.Error:
m_log.ErrorFormat("[{0}]: {1}", source, message);
break;
case HttpServer.LogPrio.Warning:
m_log.WarnFormat("[{0}]: {1}", source.ToString(), message);
case LogPrio.Info:
m_log.InfoFormat("[{0}]: {1}", source, message);
break;
case HttpServer.LogPrio.Fatal:
m_log.ErrorFormat("[{0}]: FATAL! - {1}", source.ToString(), message);
case LogPrio.Warning:
m_log.WarnFormat("[{0}]: {1}", source, message);
break;
case LogPrio.Fatal:
m_log.ErrorFormat("[{0}]: FATAL! - {1}", source, message);
break;
default:
break;

View File

@ -127,6 +127,11 @@ namespace OpenSim.Framework.Servers.HttpServer
}
private Hashtable _query;
/// <value>
/// POST request values, if applicable
/// </value>
// public Hashtable Form { get; private set; }
public string RawUrl
{
get { return _request.Uri.AbsolutePath; }
@ -228,6 +233,13 @@ namespace OpenSim.Framework.Servers.HttpServer
{
_log.ErrorFormat("[OSHttpRequest]: Error parsing querystring");
}
// Form = new Hashtable();
// foreach (HttpInputItem item in req.Form)
// {
// _log.DebugFormat("[OSHttpRequest]: Got form item {0}={1}", item.Name, item.Value);
// Form.Add(item.Name, item.Value);
// }
}
public override string ToString()

View File

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

View File

@ -6001,7 +6001,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|| avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
{
ScenePresence avatar = null;
if (((Scene)m_scene).TryGetAvatar(AgentId, out avatar))
if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
{
if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
{

View File

@ -1020,7 +1020,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Handle outgoing packets, resends, acknowledgements, and pings for each
// client. m_packetSent will be set to true if a packet is sent
m_scene.ForEachClient(clientPacketHandler, false);
m_scene.ForEachClient(clientPacketHandler);
// If nothing was sent, sleep for the minimum amount of time before a
// token bucket could get more tokens

View File

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

View File

@ -89,60 +89,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
get { return true; }
}
private void KillAvatar(uint killerObjectLocalID, ScenePresence DeadAvatar)
private void KillAvatar(uint killerObjectLocalID, ScenePresence deadAvatar)
{
string deadAvatarMessage;
ScenePresence killingAvatar = null;
string killingAvatarMessage;
if (killerObjectLocalID == 0)
DeadAvatar.ControllingClient.SendAgentAlertMessage("You committed suicide!", true);
deadAvatarMessage = "You committed suicide!";
else
{
bool foundResult = false;
string resultstring = String.Empty;
ScenePresence[] allav = DeadAvatar.Scene.GetScenePresences();
// Try to get the avatar responsible for the killing
killingAvatar = deadAvatar.Scene.GetScenePresence(killerObjectLocalID);
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
{
for (int i = 0; i < allav.Length; i++)
{
ScenePresence av = allav[i];
deadAvatar.ControllingClient.SendAgentAlertMessage(deadAvatarMessage, true);
if(killingAvatar != null)
killingAvatar.ControllingClient.SendAlertMessage("You fragged " + deadAvatar.Firstname + " " + deadAvatar.Lastname);
}
catch (InvalidOperationException)
{ }
if (av.LocalId == killerObjectLocalID)
{
av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname);
resultstring = av.Firstname + " " + av.Lastname;
foundResult = true;
}
}
} catch (InvalidOperationException)
{
}
if (!foundResult)
{
SceneObjectPart part = DeadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID);
if (part != null)
{
ScenePresence av = DeadAvatar.Scene.GetScenePresence(part.OwnerID);
if (av != null)
{
av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname);
resultstring = av.Firstname + " " + av.Lastname;
DeadAvatar.ControllingClient.SendAgentAlertMessage("You got killed by " + resultstring + "!", true);
}
else
{
string killer = DeadAvatar.Scene.GetUserName(part.OwnerID);
DeadAvatar.ControllingClient.SendAgentAlertMessage("You impaled yourself on " + part.Name + " owned by " + killer +"!", true);
}
//DeadAvatar.Scene. part.ObjectOwner
}
else
{
DeadAvatar.ControllingClient.SendAgentAlertMessage("You died!", true);
}
}
}
DeadAvatar.Health = 100;
DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient);
deadAvatar.Health = 100;
deadAvatar.Scene.TeleportClientHome(deadAvatar.UUID, deadAvatar.ControllingClient);
}
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)
{
ScenePresence[] presenceList = m_scene.GetScenePresences();
for (int i = 0; i < presenceList.Length; i++)
{
ScenePresence presence = presenceList[i];
if (presence.Firstname == firstName && presence.Lastname == lastName)
{
ScenePresence presence = m_scene.GetScenePresence(firstName, lastName);
if(presence != null)
presence.ControllingClient.SendAgentAlertMessage(message, modal);
break;
}
}
}
public void SendGeneralAlert(string message)
{
ScenePresence[] presenceList = m_scene.GetScenePresences();
for (int i = 0; i < presenceList.Length; i++)
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
{
ScenePresence presence = presenceList[i];
if (!presence.IsChildAgent)
presence.ControllingClient.SendAlertMessage(message);
}
});
}
public void SendDialogToUser(
@ -179,14 +166,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
public void SendNotificationToUsersInRegion(
UUID fromAvatarID, string fromAvatarName, string message)
{
ScenePresence[] presences = m_scene.GetScenePresences();
for (int i = 0; i < presences.Length; i++)
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
{
ScenePresence presence = presences[i];
if (!presence.IsChildAgent)
presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
}
});
}
/// <summary>

View File

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

View File

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

View File

@ -190,7 +190,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
if (account == null) // foreign
{
ScenePresence sp = null;
if (m_Scene.TryGetAvatar(userID, out sp))
if (m_Scene.TryGetScenePresence(userID, out sp))
{
AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))

View File

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

View File

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

View File

@ -285,24 +285,22 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
return;
}
byte[] assetData;
byte[] assetData = null;
AssetBase oldAsset = null;
if (BlendWithOldTexture)
{
UUID lastTextureID = part.Shape.Textures.DefaultTexture.TextureID;
oldAsset = scene.AssetService.Get(lastTextureID.ToString());
if (oldAsset != null)
Primitive.TextureEntryFace defaultFace = part.Shape.Textures.DefaultTexture;
if (defaultFace != null)
{
oldAsset = scene.AssetService.Get(defaultFace.TextureID.ToString());
if (oldAsset != null)
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];
Array.Copy(data, assetData, data.Length);

View File

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

View File

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

View File

@ -88,7 +88,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
Vector3 position = new Vector3(128, 128, 0);
Vector3 lookat = new Vector3(0, 1, 0);
if (client.Scene.TryGetAvatar(client.AgentId, out sp))
if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
{
if (sp is ScenePresence)
{

View File

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

View File

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

View File

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

View File

@ -62,11 +62,14 @@ namespace OpenSim.Region.CoreModules.World.Sound
public virtual void PlayAttachedSound(
UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius)
{
foreach (ScenePresence p in m_scene.GetAvatars())
m_scene.ForEachScenePresence(delegate(ScenePresence sp)
{
double dis = Util.GetDistanceTo(p.AbsolutePosition, position);
if (sp.IsChildAgent)
return;
double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
if (dis > 100.0) // Max audio distance
continue;
return;
// Scale by distance
if (radius == 0)
@ -74,18 +77,21 @@ namespace OpenSim.Region.CoreModules.World.Sound
else
gain = (float)((double)gain * ((radius - dis) / radius));
p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags);
}
sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags);
});
}
public virtual void TriggerSound(
UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius)
{
foreach (ScenePresence p in m_scene.GetAvatars())
m_scene.ForEachScenePresence(delegate(ScenePresence sp)
{
double dis = Util.GetDistanceTo(p.AbsolutePosition, position);
if (sp.IsChildAgent)
return;
double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
if (dis > 100.0) // Max audio distance
continue;
return;
// Scale by distance
if (radius == 0)
@ -93,9 +99,9 @@ namespace OpenSim.Region.CoreModules.World.Sound
else
gain = (float)((double)gain * ((radius - dis) / radius));
p.ControllingClient.SendTriggeredSound(
sp.ControllingClient.SendTriggeredSound(
soundId, ownerID, objectID, parentID, handle, position, (float)gain);
}
});
}
}
}

View File

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

View File

@ -425,9 +425,7 @@ namespace OpenSim.Region.CoreModules
{
if (m_ready)
{
List<ScenePresence> avatars = m_scene.GetAvatars();
if (avatars.Count > 0)
if(m_scene.GetRootAgentCount() > 0)
{
// Ask wind plugin to generate a LL wind array to be cached locally
// Try not to update this too often, as it may involve array copies
@ -437,11 +435,11 @@ namespace OpenSim.Region.CoreModules
m_frameLastUpdateClientArray = m_frame;
}
foreach (ScenePresence avatar in avatars)
m_scene.ForEachScenePresence(delegate(ScenePresence sp)
{
if (!avatar.IsChildAgent)
avatar.ControllingClient.SendWindData(windSpeeds);
}
if (!sp.IsChildAgent)
sp.ControllingClient.SendWindData(windSpeeds);
});
}
}
}

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
//mapdotspot = Color.PaleGreen;
if (part.Shape.Textures == null)
Primitive.TextureEntry textureEntry = part.Shape.Textures;
if (textureEntry == null || textureEntry.DefaultTexture == null)
continue;
if (part.Shape.Textures.DefaultTexture == null)
continue;
Color4 texcolor = part.Shape.Textures.DefaultTexture.RGBA;
Color4 texcolor = textureEntry.DefaultTexture.RGBA;
// Not sure why some of these are null, oh well.

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.
ScenePresence avatarPresence = null;
m_scene.TryGetAvatar(agentID, out avatarPresence);
m_scene.TryGetScenePresence(agentID, out avatarPresence);
if (avatarPresence != null)
{
@ -304,25 +304,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
/// <param name="AgentId">AgentID that logged out</param>
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)
{
if (m_rootAgents.Contains(AgentId))
{
m_rootAgents.Remove(AgentId);
}
if(m_rootAgents.Count == 0)
StopThread();
}
}
#endregion
@ -375,11 +361,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
{
// Local Map Item Request
List<ScenePresence> avatars = m_scene.GetAvatars();
int tc = Environment.TickCount;
List<mapItemReply> mapitems = new List<mapItemReply>();
mapItemReply mapitem = new mapItemReply();
if (avatars.Count == 0 || avatars.Count == 1)
if (m_scene.GetRootAgentCount() <= 1)
{
mapitem = new mapItemReply();
mapitem.x = (uint)(xstart + 1);
@ -392,21 +377,21 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
}
else
{
foreach (ScenePresence av in avatars)
m_scene.ForEachScenePresence(delegate(ScenePresence sp)
{
// Don't send a green dot for yourself
if (av.UUID != remoteClient.AgentId)
if (!sp.IsChildAgent && sp.UUID != remoteClient.AgentId)
{
mapitem = new mapItemReply();
mapitem.x = (uint)(xstart + av.AbsolutePosition.X);
mapitem.y = (uint)(ystart + av.AbsolutePosition.Y);
mapitem.x = (uint)(xstart + sp.AbsolutePosition.X);
mapitem.y = (uint)(ystart + sp.AbsolutePosition.Y);
mapitem.id = UUID.Zero;
mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString());
mapitem.Extra = 1;
mapitem.Extra2 = 0;
mapitems.Add(mapitem);
}
}
});
}
remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
}
@ -504,7 +489,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
if (mrs.agentID != UUID.Zero)
{
ScenePresence av = null;
m_scene.TryGetAvatar(mrs.agentID, out av);
m_scene.TryGetScenePresence(mrs.agentID, out av);
if (av != null)
{
if (response.ContainsKey(mrs.itemtype.ToString()))
@ -981,51 +966,35 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart);
OSDMap responsemap = new OSDMap();
List<ScenePresence> avatars = m_scene.GetAvatars();
OSDArray responsearr = new OSDArray(avatars.Count);
OSDMap responsemapdata = new OSDMap();
int tc = Environment.TickCount;
/*
foreach (ScenePresence av in avatars)
if (m_scene.GetRootAgentCount() == 0)
{
responsemapdata = new OSDMap();
responsemapdata["X"] = OSD.FromInteger((int)(xstart + av.AbsolutePosition.X));
responsemapdata["Y"] = OSD.FromInteger((int)(ystart + av.AbsolutePosition.Y));
responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
responsemapdata["Name"] = OSD.FromString("TH");
responsemapdata["Extra"] = OSD.FromInteger(0);
responsemapdata["Extra2"] = OSD.FromInteger(0);
responsearr.Add(responsemapdata);
}
responsemap["1"] = responsearr;
*/
if (avatars.Count == 0)
{
responsemapdata = new OSDMap();
OSDMap responsemapdata = new OSDMap();
responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1));
responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1));
responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
responsemapdata["Extra"] = OSD.FromInteger(0);
responsemapdata["Extra2"] = OSD.FromInteger(0);
OSDArray responsearr = new OSDArray();
responsearr.Add(responsemapdata);
responsemap["6"] = responsearr;
}
else
{
responsearr = new OSDArray(avatars.Count);
foreach (ScenePresence av in avatars)
OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount());
m_scene.ForEachScenePresence(delegate(ScenePresence sp)
{
responsemapdata = new OSDMap();
responsemapdata["X"] = OSD.FromInteger((int)(xstart + av.AbsolutePosition.X));
responsemapdata["Y"] = OSD.FromInteger((int)(ystart + av.AbsolutePosition.Y));
OSDMap responsemapdata = new OSDMap();
responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X));
responsemapdata["Y"] = OSD.FromInteger((int)(ystart + sp.AbsolutePosition.Y));
responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
responsemapdata["Extra"] = OSD.FromInteger(1);
responsemapdata["Extra2"] = OSD.FromInteger(0);
responsearr.Add(responsemapdata);
}
});
responsemap["6"] = responsearr;
}
return responsemap;
@ -1107,25 +1076,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
private void MakeChildAgent(ScenePresence avatar)
{
List<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)
{
if (m_rootAgents.Contains(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;
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 &&
sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_DefaultImage &&
sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_BlankImage &&
sog.RootPart.Shape.Textures.DefaultTexture.RGBA.A < 50)
Primitive.TextureEntry textures = shape.Textures;
if (textures != null)
{
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)
{
@ -224,8 +231,9 @@ namespace OpenSim.Region.DataSnapshot.Providers
counts.TryGetValue(tentry.TextureID, out c);
counts[tentry.TextureID] = c + 1;
// decrease the default texture count
if (counts.ContainsKey(sog.RootPart.Shape.Textures.DefaultTexture.TextureID))
counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] - 1;
if (counts.ContainsKey(textures.DefaultTexture.TextureID))
counts[textures.DefaultTexture.TextureID] = counts[textures.DefaultTexture.TextureID] - 1;
}
}
}
}
@ -241,6 +249,8 @@ namespace OpenSim.Region.DataSnapshot.Providers
}
}
}
}
return bestguess;
}
}

View File

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

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
using OpenMetaverse;
using OpenSim.Framework;
@ -34,7 +35,12 @@ namespace OpenSim.Region.Framework.Interfaces
{
void Initialise(string connectstring);
EstateSettings LoadEstateSettings(UUID regionID);
EstateSettings LoadEstateSettings(UUID regionID, bool create);
EstateSettings LoadEstateSettings(int estateID);
void StoreEstateSettings(EstateSettings es);
List<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;
if (TryGetAvatar(avatarId, out avatar))
if (TryGetScenePresence(avatarId, out avatar))
{
IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
if (invAccess != null)
@ -230,7 +230,7 @@ namespace OpenSim.Region.Framework.Scenes
{
ScenePresence avatar;
if (TryGetAvatar(avatarId, out avatar))
if (TryGetScenePresence(avatarId, out avatar))
{
return CapsUpdateTaskInventoryScriptAsset(
avatar.ControllingClient, itemId, primId, isScriptRunning, data);
@ -683,7 +683,7 @@ namespace OpenSim.Region.Framework.Scenes
if (transactionID == UUID.Zero)
{
ScenePresence presence;
if (TryGetAvatar(remoteClient.AgentId, out presence))
if (TryGetScenePresence(remoteClient.AgentId, out presence))
{
byte[] data = null;
@ -941,7 +941,7 @@ namespace OpenSim.Region.Framework.Scenes
{
ScenePresence avatar;
if (TryGetAvatar(avatarId, out avatar))
if (TryGetScenePresence(avatarId, out avatar))
{
return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId);
}
@ -1055,7 +1055,7 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence avatar;
if (TryGetAvatar(srcTaskItem.OwnerID, out avatar))
if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
{
destPart.GetProperties(avatar.ControllingClient);
}
@ -1083,7 +1083,7 @@ namespace OpenSim.Region.Framework.Scenes
}
ScenePresence avatar = null;
if (TryGetAvatar(destID, out avatar))
if (TryGetScenePresence(destID, out avatar))
{
//profile.SendInventoryDecendents(avatar.ControllingClient,
// profile.RootFolder.ID, true, false);
@ -1420,7 +1420,7 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence avatar;
if (TryGetAvatar(srcTaskItem.OwnerID, out avatar))
if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
{
destPart.GetProperties(avatar.ControllingClient);
}
@ -1518,9 +1518,10 @@ namespace OpenSim.Region.Framework.Scenes
if (remoteClient != null)
{
permissionToTake =
Permissions.CanReturnObject(
grp.UUID,
remoteClient.AgentId);
Permissions.CanReturnObjects(
null,
remoteClient.AgentId,
new List<SceneObjectGroup>() {grp});
permissionToDelete = permissionToTake;
if (permissionToDelete)
@ -1860,7 +1861,7 @@ namespace OpenSim.Region.Framework.Scenes
UUID inventoryID = part.ParentGroup.GetFromItemID();
ScenePresence presence;
if (TryGetAvatar(remoteClient.AgentId, out presence))
if (TryGetScenePresence(remoteClient.AgentId, out presence))
{
if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition))
return;

View File

@ -48,7 +48,7 @@ namespace OpenSim.Region.Framework.Scenes
public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene);
public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene);
public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene);
public delegate bool ReturnObjectHandler(UUID objectID, UUID returnerID, Scene scene);
public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene);
public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene);
public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene);
public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
@ -81,7 +81,6 @@ namespace OpenSim.Region.Framework.Scenes
public delegate bool CopyUserInventoryHandler(UUID itemID, UUID userID);
public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID);
public delegate bool TeleportHandler(UUID userID, Scene scene);
public delegate bool UseObjectReturnHandler(ILandObject landData, uint type, IClientAPI client, List<SceneObjectGroup> retlist, Scene scene);
#endregion
public class ScenePermissions
@ -107,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes
public event EditObjectInventoryHandler OnEditObjectInventory;
public event MoveObjectHandler OnMoveObject;
public event ObjectEntryHandler OnObjectEntry;
public event ReturnObjectHandler OnReturnObject;
public event ReturnObjectsHandler OnReturnObjects;
public event InstantMessageHandler OnInstantMessage;
public event InventoryTransferHandler OnInventoryTransfer;
public event ViewScriptHandler OnViewScript;
@ -140,7 +139,6 @@ namespace OpenSim.Region.Framework.Scenes
public event CopyUserInventoryHandler OnCopyUserInventory;
public event DeleteUserInventoryHandler OnDeleteUserInventory;
public event TeleportHandler OnTeleport;
public event UseObjectReturnHandler OnUseObjectReturn;
#endregion
#region Object Permission Checks
@ -377,15 +375,15 @@ namespace OpenSim.Region.Framework.Scenes
#endregion
#region RETURN OBJECT
public bool CanReturnObject(UUID objectID, UUID returnerID)
public bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects)
{
ReturnObjectHandler handler = OnReturnObject;
ReturnObjectsHandler handler = OnReturnObjects;
if (handler != null)
{
Delegate[] list = handler.GetInvocationList();
foreach (ReturnObjectHandler h in list)
foreach (ReturnObjectsHandler h in list)
{
if (h(objectID, returnerID, m_scene) == false)
if (h(land, user, objects, m_scene) == false)
return false;
}
}
@ -949,20 +947,5 @@ namespace OpenSim.Region.Framework.Scenes
}
return true;
}
public bool CanUseObjectReturn(ILandObject landData, uint type , IClientAPI client, List<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 int m_incrementsof15seconds;
private volatile bool m_backingup;
private bool m_useAsyncWhenPossible;
private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
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);
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
@ -681,9 +717,6 @@ namespace OpenSim.Region.Framework.Scenes
//
IConfig startupConfig = m_config.Configs["Startup"];
// Should we try to run loops synchronously or asynchronously?
m_useAsyncWhenPossible = startupConfig.GetBoolean("use_async_when_possible", false);
//Animation states
m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
// TODO: Change default to true once the feature is supported
@ -1248,6 +1281,82 @@ namespace OpenSim.Region.Framework.Scenes
m_teleportModule = RequestModuleInterface<IEntityTransferModule>();
RegionSyncServerModule = RequestModuleInterface<IRegionSyncServerModule>();
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
@ -3323,7 +3432,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID);
ScenePresence sp = GetScenePresence(agent.AgentID);
if (sp != null)
{
m_log.DebugFormat(
@ -3615,8 +3724,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="message">message to display to the user. Reason for being logged off</param>
public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
{
ScenePresence loggingOffUser = null;
loggingOffUser = GetScenePresence(AvatarID);
ScenePresence loggingOffUser = GetScenePresence(AvatarID);
if (loggingOffUser != null)
{
UUID localRegionSecret = UUID.Zero;
@ -3652,9 +3760,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="isFlying"></param>
public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
{
ScenePresence presence;
m_sceneGraph.TryGetAvatar(agentID, out presence);
ScenePresence presence = GetScenePresence(agentID);
if(presence != null)
{
try
@ -3829,9 +3935,7 @@ namespace OpenSim.Region.Framework.Scenes
public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position,
Vector3 lookAt, uint teleportFlags)
{
ScenePresence sp;
m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp);
ScenePresence sp = GetScenePresence(remoteClient.AgentId);
if (sp != null)
{
uint regionX = m_regInfo.RegionLocX;
@ -4010,17 +4114,17 @@ namespace OpenSim.Region.Framework.Scenes
m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname",
"Agent ID", "Session ID", "Circuit", "IP", "World");
foreach (ScenePresence scenePresence in GetAvatars())
ForEachScenePresence(delegate(ScenePresence sp)
{
m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}",
scenePresence.Firstname,
scenePresence.Lastname,
scenePresence.UUID,
scenePresence.ControllingClient.AgentId,
sp.Firstname,
sp.Lastname,
sp.UUID,
sp.ControllingClient.AgentId,
"Unknown",
"Unknown",
RegionInfo.RegionName);
}
});
break;
}
@ -4186,48 +4290,45 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.RemovePhysicalPrim(num);
}
//The idea is to have a group of method that return a list of avatars meeting some requirement
// ie it could be all m_scenePresences within a certain range of the calling prim/avatar.
/// <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()
public int GetRootAgentCount()
{
return m_sceneGraph.GetAvatars();
return m_sceneGraph.GetRootAgentCount();
}
public int GetChildAgentCount()
{
return m_sceneGraph.GetChildAgentCount();
}
/// <summary>
/// Return a list of all ScenePresences in this region. This returns child agents as well as root agents.
/// This list is a new object, so it can be iterated over without locking.
/// Request a scene presence by UUID. Fast, indexed lookup.
/// </summary>
/// <returns></returns>
public ScenePresence[] GetScenePresences()
/// <param name="agentID"></param>
/// <returns>null if the presence was not found</returns>
public ScenePresence GetScenePresence(UUID agentID)
{
return m_sceneGraph.GetScenePresences();
return m_sceneGraph.GetScenePresence(agentID);
}
/// <summary>
/// Request a filtered list of ScenePresences in this region.
/// This list is a new object, so it can be iterated over without locking.
/// Request the scene presence by name.
/// </summary>
/// <param name="filter"></param>
/// <returns></returns>
public List<ScenePresence> GetScenePresences(FilterAvatarList filter)
/// <param name="firstName"></param>
/// <param name="lastName"></param>
/// <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>
/// Request a scene presence by UUID
/// Request the scene presence by localID.
/// </summary>
/// <param name="avatarID"></param>
/// <returns></returns>
public ScenePresence GetScenePresence(UUID avatarID)
/// <param name="localID"></param>
/// <returns>null if the presence was not found</returns>
public ScenePresence GetScenePresence(uint localID)
{
return m_sceneGraph.GetScenePresence(avatarID);
return m_sceneGraph.GetScenePresence(localID);
}
public override bool PresenceChildStatus(UUID avatarID)
@ -4245,7 +4346,7 @@ namespace OpenSim.Region.Framework.Scenes
}
/// <summary>
///
/// Performs action on all scene presences.
/// </summary>
/// <param name="action"></param>
static int s_ForEachPresenceCounter = 0;
@ -4256,17 +4357,7 @@ namespace OpenSim.Region.Framework.Scenes
// We don't want to try to send messages if there are no avatars.
if (m_sceneGraph != null)
{
try
{
ScenePresence[] presences = GetScenePresences();
for (int i = 0; i < presences.Length; i++)
action(presences[i]);
}
catch (Exception e)
{
m_log.Info("[BUG] in " + RegionInfo.RegionName + ": " + e.ToString());
m_log.Info("[BUG] Stack Trace: " + e.StackTrace);
}
m_sceneGraph.ForEachScenePresence(action);
}
}
@ -4330,9 +4421,9 @@ namespace OpenSim.Region.Framework.Scenes
return m_sceneGraph.GetGroupByPrim(localID);
}
public override bool TryGetAvatar(UUID avatarId, out ScenePresence avatar)
public override bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
{
return m_sceneGraph.TryGetAvatar(avatarId, out avatar);
return m_sceneGraph.TryGetScenePresence(avatarId, out avatar);
}
public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
@ -4345,24 +4436,7 @@ namespace OpenSim.Region.Framework.Scenes
// REGION SYNC
if (IsSyncedServer())
return;
ForEachClient(action, m_useAsyncWhenPossible);
}
public void ForEachClient(Action<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);
//if (doAsynchronous)
// m_clientManager.ForEach(action);
//else
// m_clientManager.ForEachSync(action);
}
public bool TryGetClient(UUID avatarID, out IClientAPI client)

View File

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

View File

@ -165,9 +165,10 @@ namespace OpenSim.Region.Framework.Scenes
protected internal void UpdatePresences()
{
ScenePresence[] updateScenePresences = GetScenePresences();
for (int i = 0; i < updateScenePresences.Length; i++)
updateScenePresences[i].Update();
ForEachScenePresence(delegate(ScenePresence presence)
{
presence.Update();
});
}
protected internal float UpdatePhysics(double elapsed)
@ -196,9 +197,10 @@ namespace OpenSim.Region.Framework.Scenes
protected internal void UpdateScenePresenceMovement()
{
ScenePresence[] moveEntities = GetScenePresences();
for (int i = 0; i < moveEntities.Length; i++)
moveEntities[i].UpdateMovement();
ForEachScenePresence(delegate(ScenePresence presence)
{
presence.UpdateMovement();
});
}
#endregion
@ -616,18 +618,16 @@ namespace OpenSim.Region.Framework.Scenes
public void RecalculateStats()
{
ScenePresence[] presences = GetScenePresences();
int rootcount = 0;
int childcount = 0;
for (int i = 0; i < presences.Length; i++)
ForEachScenePresence(delegate(ScenePresence presence)
{
ScenePresence user = presences[i];
if (user.IsChildAgent)
if (presence.IsChildAgent)
++childcount;
else
++rootcount;
}
});
m_numRootAgents = rootcount;
m_numChildAgents = childcount;
@ -674,25 +674,6 @@ namespace OpenSim.Region.Framework.Scenes
#endregion
#region Get Methods
/// <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>
/// Get the controlling client for the given avatar, if there is one.
///
@ -719,43 +700,85 @@ namespace OpenSim.Region.Framework.Scenes
}
/// <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>
/// <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...
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;
lock (m_scenePresences)
return new List<ScenePresence>(m_scenePresenceArray);
}
/// <summary>
/// Request a scene presence by UUID
/// Request a scene presence by UUID. Fast, indexed lookup.
/// </summary>
/// <param name="avatarID"></param>
/// <returns>null if the agent was not found</returns>
/// <param name="agentID"></param>
/// <returns>null if the presence was not found</returns>
protected internal ScenePresence GetScenePresence(UUID agentID)
{
ScenePresence sp;
lock (m_scenePresences)
{
m_scenePresences.TryGetValue(agentID, out 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>
/// Get a scene object group that contains the prim with the given local id
/// </summary>
@ -907,34 +930,6 @@ namespace OpenSim.Region.Framework.Scenes
return group.GetChildPart(fullID);
}
protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar)
{
lock (m_scenePresences)
return m_scenePresences.TryGetValue(avatarId, out avatar);
}
protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
{
ScenePresence[] presences = GetScenePresences();
for (int i = 0; i < presences.Length; i++)
{
ScenePresence presence = presences[i];
if (!presence.IsChildAgent)
{
if (String.Compare(avatarName, presence.ControllingClient.Name, true) == 0)
{
avatar = presence;
return true;
}
}
}
avatar = null;
return false;
}
/// <summary>
/// Returns a list of the entities in the scene. This is a new list so no locking is required to iterate over
/// it
@ -997,6 +992,10 @@ namespace OpenSim.Region.Framework.Scenes
return UUID.Zero;
}
/// <summary>
/// Performs action on all scene object groups.
/// </summary>
/// <param name="action"></param>
protected internal void ForEachSOG(Action<SceneObjectGroup> action)
{
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
#region Client Event handlers

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -318,9 +318,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
{
Scene scene = client.Scene as Scene;
m_log.DebugFormat("[Concierge]: {0} logs off from {1}", client.Name, scene.RegionInfo.RegionName);
List<ScenePresence> avs = scene.GetAvatars();
AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, client.Name, scene.RegionInfo.RegionName, avs.Count));
UpdateBroker(scene, avs);
AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, client.Name, scene.RegionInfo.RegionName, scene.GetRootAgentCount()));
UpdateBroker(scene);
}
}
@ -331,11 +330,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
{
Scene scene = agent.Scene;
m_log.DebugFormat("[Concierge]: {0} enters {1}", agent.Name, scene.RegionInfo.RegionName);
List<ScenePresence> avs = scene.GetAvatars();
WelcomeAvatar(agent, scene);
AnnounceToAgentsRegion(scene, String.Format(m_announceEntering, agent.Name,
scene.RegionInfo.RegionName, avs.Count));
UpdateBroker(scene, avs);
scene.RegionInfo.RegionName, scene.GetRootAgentCount()));
UpdateBroker(scene);
}
}
@ -346,10 +344,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
{
Scene scene = agent.Scene;
m_log.DebugFormat("[Concierge]: {0} leaves {1}", agent.Name, scene.RegionInfo.RegionName);
List<ScenePresence> avs = scene.GetAvatars();
AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, agent.Name,
scene.RegionInfo.RegionName, avs.Count));
UpdateBroker(scene, avs);
scene.RegionInfo.RegionName, scene.GetRootAgentCount()));
UpdateBroker(scene);
}
}
@ -368,7 +365,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
}
}
protected void UpdateBroker(IScene scene, List<ScenePresence> avatars)
protected void UpdateBroker(Scene scene)
{
if (String.IsNullOrEmpty(m_brokerURI))
return;
@ -377,24 +374,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
// create XML sniplet
StringBuilder list = new StringBuilder();
if (0 == avatars.Count)
{
list.Append(String.Format("<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",
avatars.Count, scene.RegionInfo.RegionName,
scene.GetRootAgentCount(), scene.RegionInfo.RegionName,
scene.RegionInfo.RegionID,
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>");
}
});
string payload = list.ToString();
// post via REST to broker
@ -529,7 +520,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
// protected void AnnounceToAgentsRegion(Scene scene, string msg)
// {
// ScenePresence agent = null;
// if ((client.Scene is Scene) && (client.Scene as Scene).TryGetAvatar(client.AgentId, out agent))
// if ((client.Scene is Scene) && (client.Scene as Scene).TryGetScenePresence(client.AgentId, out agent))
// AnnounceToAgentsRegion(agent, msg);
// else
// m_log.DebugFormat("[Concierge]: could not find an agent for client {0}", client.Name);

View File

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

View File

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

View File

@ -135,9 +135,9 @@ namespace OpenSim.Region.RegionCombinerModule
return m_rootScene.Permissions.CanObjectEntry(objectid, enteringregion, newpoint);
}
public bool CanReturnObject(UUID objectid, UUID returnerid, Scene scene)
public bool CanReturnObjects(ILandObject land, UUID user, List<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)
@ -265,11 +265,6 @@ namespace OpenSim.Region.RegionCombinerModule
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
}
}

View File

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

View File

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

View File

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

View File

@ -68,12 +68,10 @@ namespace OpenSim.Region.UserStatistics
HTMLUtil.OL_O(ref output, "");
foreach (Scene scene in all_scenes)
{
ScenePresence[] avatarInScene = scene.GetScenePresences();
HTMLUtil.LI_O(ref output, String.Empty);
output.Append(scene.RegionInfo.RegionName);
HTMLUtil.OL_O(ref output, String.Empty);
foreach (ScenePresence av in avatarInScene)
scene.ForEachScenePresence(delegate(ScenePresence av)
{
Dictionary<string, string> queues = new Dictionary<string, string>();
if (av.ControllingClient is IStatsCollector)
@ -124,7 +122,7 @@ namespace OpenSim.Region.UserStatistics
HTMLUtil.UL_C(ref output);
HTMLUtil.LI_C(ref output);
}
});
HTMLUtil.OL_C(ref output);
}
HTMLUtil.OL_C(ref output);

View File

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

View File

@ -76,7 +76,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
public void Initialise(IConfigSource source)
{
if (Simian.IsSimianEnabled(source, "FriendsServices", this.Name))
bool isSimianEnabled = false;
if (source.Configs["Friends"] != null)
{
string module = source.Configs["Friends"].GetString("Connector");
isSimianEnabled = !String.IsNullOrEmpty(module) && module.EndsWith(this.Name);
}
if (isSimianEnabled)
{
IConfig assetConfig = source.Configs["FriendsService"];
if (assetConfig == null)

View File

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

View File

@ -150,7 +150,7 @@ namespace OpenSim.Services.Interfaces
List<UserAccount> GetUserAccounts(UUID scopeID, string query);
/// <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>
/// <param name="data"></param>
/// <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
async_call_method = SmartThreadPool
; There are several operations on large collections (such as
; the current avatar list) that can be run synchronously or
; in parallel. Running in parallel should increase performance
; on a multi-core system, but will make debugging more
; difficult if something deadlocks or times out
use_async_when_possible = false
; Max threads to allocate on the FireAndForget thread pool
; when running with the SmartThreadPool option above
MaxPoolThreads = 15