From 9ed0a8dbad121b64ca8baca78f28ca58602c47ca Mon Sep 17 00:00:00 2001
From: MW
Date: Wed, 25 Apr 2007 18:12:06 +0000
Subject: 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.
---
OpenSim.Framework/AgentInventory.cs | 5 +-
OpenSim.Framework/OpenSim.Framework.csproj | 6 ++
OpenSim.Framework/OpenSim.Framework.dll.build | 1 +
OpenSim.Framework/Util.cs | 89 +++++++++++++++++++++++++++
4 files changed, 99 insertions(+), 2 deletions(-)
(limited to 'OpenSim.Framework')
diff --git a/OpenSim.Framework/AgentInventory.cs b/OpenSim.Framework/AgentInventory.cs
index cabefc9..35c27d9 100644
--- a/OpenSim.Framework/AgentInventory.cs
+++ b/OpenSim.Framework/AgentInventory.cs
@@ -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
}
diff --git a/OpenSim.Framework/OpenSim.Framework.csproj b/OpenSim.Framework/OpenSim.Framework.csproj
index ea4817e..0061140 100644
--- a/OpenSim.Framework/OpenSim.Framework.csproj
+++ b/OpenSim.Framework/OpenSim.Framework.csproj
@@ -76,6 +76,12 @@
+
+ XMLRPC
+ {8E81D43C-0000-0000-0000-000000000000}
+ {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ False
+
diff --git a/OpenSim.Framework/OpenSim.Framework.dll.build b/OpenSim.Framework/OpenSim.Framework.dll.build
index 8048de5..2ed5643 100644
--- a/OpenSim.Framework/OpenSim.Framework.dll.build
+++ b/OpenSim.Framework/OpenSim.Framework.dll.build
@@ -50,6 +50,7 @@
+
diff --git a/OpenSim.Framework/Util.cs b/OpenSim.Framework/Util.cs
index 695cac9..17ca611 100644
--- a/OpenSim.Framework/Util.cs
+++ b/OpenSim.Framework/Util.cs
@@ -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);
+ }
+
+ ///
+ /// Convert a variable length field (byte array) to a string, with a
+ /// field name prepended to each line of the output
+ ///
+ /// If the byte array has unprintable characters in it, a
+ /// hex dump will be put in the string instead
+ /// The byte array to convert to a string
+ /// A field name to prepend to each line of output
+ /// An ASCII string or a string containing a hex dump, minus
+ /// the null terminator
+ 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()
{
--
cgit v1.1