mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 17:05:55 +08:00
a few more useless changes
This commit is contained in:
@@ -47,9 +47,6 @@ namespace OpenSim.Data.Null
|
||||
|
||||
public NullUserAccountData(string connectionString, string realm)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[NULL USER ACCOUNT DATA]: Initializing new NullUserAccountData with connectionString [{0}], realm [{1}]",
|
||||
// connectionString, realm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -62,51 +59,38 @@ namespace OpenSim.Data.Null
|
||||
/// <returns></returns>
|
||||
public UserAccountData[] Get(string[] fields, string[] values)
|
||||
{
|
||||
// if (m_log.IsDebugEnabled)
|
||||
// {
|
||||
// m_log.DebugFormat(
|
||||
// "[NULL USER ACCOUNT DATA]: Called Get with fields [{0}], values [{1}]",
|
||||
// string.Join(", ", fields), string.Join(", ", values));
|
||||
// }
|
||||
//if (m_log.IsDebugEnabled)
|
||||
//{
|
||||
// m_log.DebugFormat(
|
||||
// "[NULL USER ACCOUNT DATA]: Called Get with fields [{0}], values [{1}]",
|
||||
// string.Join(", ", fields), string.Join(", ", values));
|
||||
//}
|
||||
|
||||
UserAccountData[] userAccounts = new UserAccountData[0];
|
||||
|
||||
List<string> fieldsLst = new List<string>(fields);
|
||||
if (fieldsLst.Contains("PrincipalID"))
|
||||
try
|
||||
{
|
||||
int i = fieldsLst.IndexOf("PrincipalID");
|
||||
UUID id = UUID.Zero;
|
||||
if (UUID.TryParse(values[i], out id))
|
||||
if (m_DataByUUID.ContainsKey(id))
|
||||
userAccounts = new UserAccountData[] { m_DataByUUID[id] };
|
||||
}
|
||||
else if (fieldsLst.Contains("FirstName") && fieldsLst.Contains("LastName"))
|
||||
{
|
||||
int findex = fieldsLst.IndexOf("FirstName");
|
||||
int lindex = fieldsLst.IndexOf("LastName");
|
||||
if (m_DataByName.ContainsKey(values[findex] + " " + values[lindex]))
|
||||
UserAccountData uad;
|
||||
int i = Array.FindIndex(fields, (fn) => fn == "PrincipalID");
|
||||
if (i >= 0)
|
||||
{
|
||||
userAccounts = new UserAccountData[] { m_DataByName[values[findex] + " " + values[lindex]] };
|
||||
if (UUID.TryParse(values[i], out UUID id) && m_DataByUUID.TryGetValue(id, out uad))
|
||||
return new UserAccountData[] { uad };
|
||||
}
|
||||
}
|
||||
else if (fieldsLst.Contains("Email"))
|
||||
{
|
||||
int i = fieldsLst.IndexOf("Email");
|
||||
if (m_DataByEmail.ContainsKey(values[i]))
|
||||
userAccounts = new UserAccountData[] { m_DataByEmail[values[i]] };
|
||||
}
|
||||
|
||||
// if (m_log.IsDebugEnabled)
|
||||
// {
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// foreach (UserAccountData uad in userAccounts)
|
||||
// sb.AppendFormat("({0} {1} {2}) ", uad.FirstName, uad.LastName, uad.PrincipalID);
|
||||
//
|
||||
// m_log.DebugFormat(
|
||||
// "[NULL USER ACCOUNT DATA]: Returning {0} user accounts out of {1}: [{2}]", userAccounts.Length, m_DataByName.Count, sb);
|
||||
// }
|
||||
i = Array.FindIndex(fields, (fn) => fn == "FirstName");
|
||||
if (i >= 0)
|
||||
{
|
||||
int lindex = Array.FindIndex(fields, i + 1, (fn) => fn == "LastName");
|
||||
if(lindex >= 0 && m_DataByName.TryGetValue(values[i] + " " + values[lindex], out uad))
|
||||
return new UserAccountData[] { uad };
|
||||
}
|
||||
|
||||
return userAccounts;
|
||||
i = Array.FindIndex(fields, (fn) => fn == "Email");
|
||||
if (i >= 0 && m_DataByEmail.TryGetValue(values[i], out uad))
|
||||
return new UserAccountData[] { uad };
|
||||
}
|
||||
catch { }
|
||||
|
||||
return Array.Empty<UserAccountData>();
|
||||
}
|
||||
|
||||
public bool Store(UserAccountData data)
|
||||
@@ -120,18 +104,18 @@ namespace OpenSim.Data.Null
|
||||
|
||||
m_DataByUUID[data.PrincipalID] = data;
|
||||
m_DataByName[data.FirstName + " " + data.LastName] = data;
|
||||
if (data.Data.ContainsKey("Email") && data.Data["Email"] != null && data.Data["Email"] != string.Empty)
|
||||
m_DataByEmail[data.Data["Email"]] = data;
|
||||
if (data.Data.TryGetValue("Email", out string semail) && !string.IsNullOrEmpty(semail))
|
||||
m_DataByEmail[semail] = data;
|
||||
|
||||
// m_log.DebugFormat("m_DataByUUID count is {0}, m_DataByName count is {1}", m_DataByUUID.Count, m_DataByName.Count);
|
||||
// m_log.DebugFormat("m_DataByUUID count is {0}, m_DataByName count is {1}", m_DataByUUID.Count, m_DataByName.Count);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public UserAccountData[] GetUsers(UUID scopeID, string query)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[NULL USER ACCOUNT DATA]: Called GetUsers with scope [{0}], query [{1}]", scopeID, query);
|
||||
//m_log.DebugFormat(
|
||||
// "[NULL USER ACCOUNT DATA]: Called GetUsers with scope [{0}], query [{1}]", scopeID, query);
|
||||
|
||||
string[] words = query.Split();
|
||||
|
||||
@@ -177,15 +161,12 @@ namespace OpenSim.Data.Null
|
||||
// Only delete by PrincipalID
|
||||
if (field.Equals("PrincipalID"))
|
||||
{
|
||||
UUID uuid = UUID.Zero;
|
||||
if (UUID.TryParse(val, out uuid) && m_DataByUUID.ContainsKey(uuid))
|
||||
if (UUID.TryParse(val, out UUID uuid) && m_DataByUUID.TryGetValue(uuid, out UserAccountData account))
|
||||
{
|
||||
UserAccountData account = m_DataByUUID[uuid];
|
||||
m_DataByUUID.Remove(uuid);
|
||||
if (m_DataByName.ContainsKey(account.FirstName + " " + account.LastName))
|
||||
m_DataByName.Remove(account.FirstName + " " + account.LastName);
|
||||
if (account.Data.ContainsKey("Email") && account.Data["Email"] != string.Empty && m_DataByEmail.ContainsKey(account.Data["Email"]))
|
||||
m_DataByEmail.Remove(account.Data["Email"]);
|
||||
m_DataByName.Remove(account.FirstName + " " + account.LastName);
|
||||
if (account.Data.TryGetValue("Email", out string semail) && !string.IsNullOrEmpty(semail))
|
||||
m_DataByEmail.Remove(semail);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -107,10 +107,8 @@ namespace OpenSim.Data.PGSQL
|
||||
|
||||
public bool Store(AuthenticationData data)
|
||||
{
|
||||
if (data.Data.ContainsKey("UUID"))
|
||||
data.Data.Remove("UUID");
|
||||
if (data.Data.ContainsKey("uuid"))
|
||||
data.Data.Remove("uuid");
|
||||
data.Data.Remove("UUID");
|
||||
data.Data.Remove("uuid");
|
||||
|
||||
/*
|
||||
Dictionary<string, object> oAuth = new Dictionary<string, object>();
|
||||
|
||||
@@ -183,12 +183,12 @@ namespace OpenSim.Data.PGSQL
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
if ( m_FieldTypes.ContainsKey(field) )
|
||||
cmd.Parameters.Add(m_database.CreateParameter(field, key, m_FieldTypes[field]));
|
||||
if ( m_FieldTypes.TryGetValue(field, out string ftype) )
|
||||
cmd.Parameters.Add(m_database.CreateParameter(field, key, ftype));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter(field, key));
|
||||
|
||||
string query = String.Format("SELECT * FROM {0} WHERE \"{1}\" = :{1}", m_Realm, field, field);
|
||||
string query = $"SELECT * FROM {m_Realm} WHERE \"{field}\" = :{field}";
|
||||
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query;
|
||||
@@ -243,8 +243,8 @@ namespace OpenSim.Data.PGSQL
|
||||
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
if ( m_FieldTypes.ContainsKey(fields[i]) )
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i], m_FieldTypes[fields[i]]));
|
||||
if ( m_FieldTypes.TryGetValue(fields[i], out string ftype) )
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i], ftype));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
|
||||
|
||||
@@ -398,8 +398,9 @@ namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
constraints.Add(new KeyValuePair<string, string>(fi.Name, fi.GetValue(row).ToString() ));
|
||||
}
|
||||
if (m_FieldTypes.ContainsKey(fi.Name))
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fi.Name, fi.GetValue(row), m_FieldTypes[fi.Name]));
|
||||
|
||||
if (m_FieldTypes.TryGetValue(fi.Name, out string ftype))
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fi.Name, fi.GetValue(row), ftype));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fi.Name, fi.GetValue(row)));
|
||||
}
|
||||
@@ -418,8 +419,8 @@ namespace OpenSim.Data.PGSQL
|
||||
names.Add(kvp.Key);
|
||||
values.Add(":" + kvp.Key);
|
||||
|
||||
if (m_FieldTypes.ContainsKey(kvp.Key))
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + kvp.Key, kvp.Value, m_FieldTypes[kvp.Key]));
|
||||
if (m_FieldTypes.TryGetValue(kvp.Key, out string ftype))
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + kvp.Key, kvp.Value, ftype));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + kvp.Key, kvp.Value));
|
||||
}
|
||||
@@ -493,8 +494,8 @@ namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
if (m_FieldTypes.ContainsKey(fields[i]))
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i], m_FieldTypes[fields[i]]));
|
||||
if (m_FieldTypes.TryGetValue(fields[i], out string ftype))
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i], ftype));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
|
||||
|
||||
|
||||
@@ -196,12 +196,12 @@ namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
while (itemReader.Read())
|
||||
{
|
||||
if (!(itemReader["primID"] is DBNull))
|
||||
if (itemReader["primID"] is not DBNull)
|
||||
{
|
||||
UUID primID = new UUID(itemReader["primID"].ToString());
|
||||
if (prims.ContainsKey(primID))
|
||||
if(UUID.TryParse(itemReader["primID"].ToString(), out UUID primID) &&
|
||||
prims.TryGetValue(primID, out SceneObjectPart sop))
|
||||
{
|
||||
primsWithInventory.Add(prims[primID]);
|
||||
primsWithInventory.Add(sop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,8 +129,7 @@ namespace OpenSim.Data.SQLite
|
||||
|
||||
public bool Store(AuthenticationData data)
|
||||
{
|
||||
if (data.Data.ContainsKey("UUID"))
|
||||
data.Data.Remove("UUID");
|
||||
data.Data.Remove("UUID");
|
||||
|
||||
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||
string[] values = new string[data.Data.Count];
|
||||
|
||||
@@ -32,6 +32,7 @@ using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using log4net;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
@@ -541,16 +542,20 @@ namespace OpenSim.Framework
|
||||
|
||||
lock (m_attachments)
|
||||
{
|
||||
if (!m_attachments.ContainsKey(attach.AttachPoint))
|
||||
m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
|
||||
ref List<AvatarAttachment> atlst = ref CollectionsMarshal.GetValueRefOrAddDefault(m_attachments, attach.AttachPoint, out bool ex);
|
||||
if(!ex)
|
||||
{
|
||||
atlst = new List<AvatarAttachment>() { attach };
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (AvatarAttachment prev in m_attachments[attach.AttachPoint])
|
||||
foreach (AvatarAttachment prev in atlst)
|
||||
{
|
||||
if (prev.ItemID.Equals(attach.ItemID))
|
||||
return;
|
||||
}
|
||||
|
||||
m_attachments[attach.AttachPoint].Add(attach);
|
||||
atlst.Add(attach);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -562,8 +567,7 @@ namespace OpenSim.Framework
|
||||
|
||||
lock (m_attachments)
|
||||
{
|
||||
m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
|
||||
m_attachments[attach.AttachPoint].Add(attach);
|
||||
m_attachments[attach.AttachPoint] = new List<AvatarAttachment>() { attach };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user