mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 01:35:46 +08:00
updated to use lastest version of libsl but is currently broke when using SL viewer 1.15.02, due to big changes in the message templates.
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Text;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
using OpenSim.Framework.Types;
|
||||
using OpenSim.Framework.Utilities;
|
||||
|
||||
namespace OpenSim.Framework.Inventory
|
||||
{
|
||||
@@ -114,9 +115,9 @@ namespace OpenSim.Framework.Inventory
|
||||
Console.WriteLine("updating inventory item details");
|
||||
if (this.InventoryItems.ContainsKey(itemID))
|
||||
{
|
||||
Console.WriteLine("changing name to "+ Helpers.FieldToString(packet.Name));
|
||||
Console.WriteLine("changing name to "+ Util.FieldToString(packet.Name));
|
||||
InventoryItem Item = this.InventoryItems[itemID];
|
||||
Item.Name = Helpers.FieldToString(packet.Name);
|
||||
Item.Name = Util.FieldToString(packet.Name);
|
||||
Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated());
|
||||
//TODO need to update the rest of the info
|
||||
}
|
||||
|
||||
@@ -76,6 +76,12 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj">
|
||||
<Name>XMLRPC</Name>
|
||||
<Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
|
||||
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AgentInventory.cs">
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
<include name="System.Xml.dll" />
|
||||
<include name="../bin/libsecondlife.dll" />
|
||||
<include name="../bin/Db4objects.Db4o.dll" />
|
||||
<include name="../bin/XMLRPC.dll" />
|
||||
</references>
|
||||
</csc>
|
||||
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../bin/" />
|
||||
|
||||
@@ -36,6 +36,95 @@ namespace OpenSim.Framework.Utilities
|
||||
return id;
|
||||
}
|
||||
|
||||
public static int fast_distance2d(int x, int y)
|
||||
{
|
||||
x = System.Math.Abs(x);
|
||||
y = System.Math.Abs(y);
|
||||
|
||||
int min = System.Math.Min(x, y);
|
||||
|
||||
return (x + y - (min >> 1) - (min >> 2) + (min >> 4));
|
||||
}
|
||||
|
||||
public static string FieldToString(byte[] bytes)
|
||||
{
|
||||
return FieldToString(bytes, String.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a variable length field (byte array) to a string, with a
|
||||
/// field name prepended to each line of the output
|
||||
/// </summary>
|
||||
/// <remarks>If the byte array has unprintable characters in it, a
|
||||
/// hex dump will be put in the string instead</remarks>
|
||||
/// <param name="bytes">The byte array to convert to a string</param>
|
||||
/// <param name="fieldName">A field name to prepend to each line of output</param>
|
||||
/// <returns>An ASCII string or a string containing a hex dump, minus
|
||||
/// the null terminator</returns>
|
||||
public static string FieldToString(byte[] bytes, string fieldName)
|
||||
{
|
||||
// Check for a common case
|
||||
if (bytes.Length == 0) return String.Empty;
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
bool printable = true;
|
||||
|
||||
for (int i = 0; i < bytes.Length; ++i)
|
||||
{
|
||||
// Check if there are any unprintable characters in the array
|
||||
if ((bytes[i] < 0x20 || bytes[i] > 0x7E) && bytes[i] != 0x09
|
||||
&& bytes[i] != 0x0D && bytes[i] != 0x0A && bytes[i] != 0x00)
|
||||
{
|
||||
printable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (printable)
|
||||
{
|
||||
if (fieldName.Length > 0)
|
||||
{
|
||||
output.Append(fieldName);
|
||||
output.Append(": ");
|
||||
}
|
||||
|
||||
if (bytes[bytes.Length - 1] == 0x00)
|
||||
output.Append(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1));
|
||||
else
|
||||
output.Append(UTF8Encoding.UTF8.GetString(bytes));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < bytes.Length; i += 16)
|
||||
{
|
||||
if (i != 0)
|
||||
output.Append(Environment.NewLine);
|
||||
if (fieldName.Length > 0)
|
||||
{
|
||||
output.Append(fieldName);
|
||||
output.Append(": ");
|
||||
}
|
||||
|
||||
for (int j = 0; j < 16; j++)
|
||||
{
|
||||
if ((i + j) < bytes.Length)
|
||||
output.Append(String.Format("{0:X2} ", bytes[i + j]));
|
||||
else
|
||||
output.Append(" ");
|
||||
}
|
||||
|
||||
for (int j = 0; j < 16 && (i + j) < bytes.Length; j++)
|
||||
{
|
||||
if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E)
|
||||
output.Append((char)bytes[i + j]);
|
||||
else
|
||||
output.Append(".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output.ToString();
|
||||
}
|
||||
public Util()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user