cosmetics (or not)

httptests
UbitUmarov 2018-01-21 16:40:58 +00:00
parent 56535cdb47
commit cb5a7246a2
3 changed files with 42 additions and 43 deletions

View File

@ -29,11 +29,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Reflection; using System.Reflection;
using log4net; using System.Text;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
namespace OpenSim.Data.MySQL namespace OpenSim.Data.MySQL
{ {
@ -129,25 +127,27 @@ namespace OpenSim.Data.MySQL
public virtual T[] Get(string[] fields, string[] keys, string options) public virtual T[] Get(string[] fields, string[] keys, string options)
{ {
if (fields.Length != keys.Length) int flen = fields.Length;
if (flen == 0 || flen != keys.Length)
return new T[0]; return new T[0];
List<string> terms = new List<string>(); int flast = flen - 1;
StringBuilder sb = new StringBuilder(1024);
sb.AppendFormat("select * from {0} where ", m_Realm);
using (MySqlCommand cmd = new MySqlCommand()) using (MySqlCommand cmd = new MySqlCommand())
{ {
for (int i = 0 ; i < fields.Length ; i++) for (int i = 0 ; i < flen ; i++)
{ {
cmd.Parameters.AddWithValue(fields[i], keys[i]); cmd.Parameters.AddWithValue(fields[i], keys[i]);
terms.Add("`" + fields[i] + "` = ?" + fields[i]); if(i< flast)
sb.AppendFormat("`{0}` = ?{0} and ", fields[i]);
else
sb.AppendFormat("`{0}` = ?{0} ", fields[i]);
} }
string where = String.Join(" and ", terms.ToArray()); sb.Append(options);
cmd.CommandText = sb.ToString();
string query = String.Format("select * from {0} where {1} {2}",
m_Realm, where, options);
cmd.CommandText = query;
return DoQuery(cmd); return DoQuery(cmd);
} }
@ -204,7 +204,7 @@ namespace OpenSim.Data.MySQL
if (m_Fields[name].FieldType == typeof(bool)) if (m_Fields[name].FieldType == typeof(bool))
{ {
int v = Convert.ToInt32(reader[name]); int v = Convert.ToInt32(reader[name]);
m_Fields[name].SetValue(row, v != 0 ? true : false); m_Fields[name].SetValue(row, v != 0);
} }
else if (m_Fields[name].FieldType == typeof(UUID)) else if (m_Fields[name].FieldType == typeof(UUID))
{ {

View File

@ -43,16 +43,16 @@ namespace OpenSim.Region.ClientStack.Linden
private static byte[] ulongToByteArray(ulong uLongValue) private static byte[] ulongToByteArray(ulong uLongValue)
{ {
// Reverse endianness of RegionHandle // Reverse endianness of RegionHandle
return new byte[] return new byte[8]
{ {
(byte)((uLongValue >> 56) % 256), (byte)((uLongValue >> 56) & 0xff),
(byte)((uLongValue >> 48) % 256), (byte)((uLongValue >> 48) & 0xff),
(byte)((uLongValue >> 40) % 256), (byte)((uLongValue >> 40) & 0xff),
(byte)((uLongValue >> 32) % 256), (byte)((uLongValue >> 32) & 0xff),
(byte)((uLongValue >> 24) % 256), (byte)((uLongValue >> 24) & 0xff),
(byte)((uLongValue >> 16) % 256), (byte)((uLongValue >> 16) & 0xff),
(byte)((uLongValue >> 8) % 256), (byte)((uLongValue >> 8) & 0xff),
(byte)(uLongValue % 256) (byte)(uLongValue & 0xff)
}; };
} }

View File

@ -86,12 +86,15 @@ namespace OpenSim.Services.UserAccountService
m_CreateDefaultAvatarEntries = userConfig.GetBoolean("CreateDefaultAvatarEntries", false); m_CreateDefaultAvatarEntries = userConfig.GetBoolean("CreateDefaultAvatarEntries", false);
if (m_RootInstance == null)
{
m_RootInstance = this;
// create a system grid god account // create a system grid god account
UserAccount ggod = GetUserAccount(UUID.Zero, UUID_GRID_GOD); UserAccount ggod = GetUserAccount(UUID.Zero, UUID_GRID_GOD);
if(ggod == null) if(ggod == null)
{ {
UserAccountData d = new UserAccountData(); UserAccountData d = new UserAccountData();
d.FirstName = "GRID"; d.FirstName = "GRID";
d.LastName = "SERVICES"; d.LastName = "SERVICES";
d.PrincipalID = UUID_GRID_GOD; d.PrincipalID = UUID_GRID_GOD;
@ -106,10 +109,6 @@ namespace OpenSim.Services.UserAccountService
m_Database.Store(d); m_Database.Store(d);
} }
if (m_RootInstance == null)
{
m_RootInstance = this;
// In case there are several instances of this class in the same process, // In case there are several instances of this class in the same process,
// the console commands are only registered for the root instance // the console commands are only registered for the root instance
if (MainConsole.Instance != null) if (MainConsole.Instance != null)