diff --git a/Common/OpenSim.Framework/OpenSim.Framework.csproj b/Common/OpenSim.Framework/OpenSim.Framework.csproj
index 5a993f5b97..038e537a68 100644
--- a/Common/OpenSim.Framework/OpenSim.Framework.csproj
+++ b/Common/OpenSim.Framework/OpenSim.Framework.csproj
@@ -1,4 +1,4 @@
-
+
Local
8.0.50727
@@ -6,7 +6,8 @@
{8ACA2445-0000-0000-0000-000000000000}
Debug
AnyCPU
-
+
+
OpenSim.Framework
@@ -15,9 +16,11 @@
IE50
false
Library
-
+
+
OpenSim.Framework
-
+
+
@@ -28,7 +31,8 @@
TRACE;DEBUG
-
+
+
True
4096
False
@@ -37,7 +41,8 @@
False
False
4
-
+
+
False
@@ -46,7 +51,8 @@
TRACE
-
+
+
False
4096
True
@@ -55,22 +61,23 @@
False
False
4
-
+
+
-
+
System.dll
False
-
+
System.Xml.dll
False
-
+
..\..\bin\libsecondlife.dll
False
-
+
..\..\bin\Db4objects.Db4o.dll
False
@@ -80,13 +87,13 @@
XMLRPC
{8E81D43C-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Framework.Console
{A7CD0630-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
@@ -114,6 +121,7 @@
Code
+
Code
@@ -212,4 +220,4 @@
-
+
\ No newline at end of file
diff --git a/Common/OpenSim.Framework/Types/RegionHandle.cs b/Common/OpenSim.Framework/Types/RegionHandle.cs
new file mode 100644
index 0000000000..1271d0445a
--- /dev/null
+++ b/Common/OpenSim.Framework/Types/RegionHandle.cs
@@ -0,0 +1,120 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Net;
+
+namespace OpenSim.Framework.Types
+{
+ ///
+ /// A class for manipulating RegionHandle coordinates
+ ///
+ class RegionHandle
+ {
+ private UInt64 handle;
+
+ ///
+ /// Initialises a new grid-aware RegionHandle
+ ///
+ /// IP Address of the Grid Server for this region
+ /// Grid X Coordinate
+ /// Grid Y Coordinate
+ public RegionHandle(string ip, short x, short y)
+ {
+ IPAddress addr = IPAddress.Parse(ip);
+
+ long baseHandle = addr.Address;
+
+ // Split the IP address in half
+ short a = (short)((baseHandle << 16) & 0xFFFF);
+ short b = (short)((baseHandle << 0) & 0xFFFF);
+
+ // Raise the bounds a little
+ uint nx = (uint)x;
+ uint ny = (uint)y;
+
+ // Multiply grid coords to get region coords
+ nx *= 256;
+ ny *= 256;
+
+ // Stuff the IP address in too
+ nx = (uint)a << 16;
+ ny = (uint)b << 16;
+
+ handle = ((UInt64)nx << 32) | (uint)ny;
+ }
+
+ ///
+ /// Initialises a new RegionHandle that is not inter-grid aware
+ ///
+ /// Grid X Coordinate
+ /// Grid Y Coordinate
+ public RegionHandle(uint x, uint y)
+ {
+ handle = ((x * 256) << 32) | (y * 256);
+ }
+
+ ///
+ /// Initialises a new RegionHandle from an existing value
+ ///
+ /// A U64 RegionHandle
+ public RegionHandle(UInt64 Region)
+ {
+ handle = Region;
+ }
+
+ ///
+ /// Returns the Grid Masked RegionHandle - For use in Teleport packets and other packets where sending the grid IP address may be handy.
+ ///
+ /// Do not use for SimulatorEnable packets. The client will choke.
+ /// Region Handle including IP Address encoding
+ public UInt64 getTeleportHandle()
+ {
+ return handle;
+ }
+
+ ///
+ /// Returns a RegionHandle which may be used for SimulatorEnable packets. Removes the IP address encoding and returns the lower bounds.
+ ///
+ /// A U64 RegionHandle for use in SimulatorEnable packets.
+ public UInt64 getNeighbourHandle()
+ {
+ UInt64 mask = 0x0000FFFF0000FFFF;
+
+ return handle | mask;
+ }
+
+ ///
+ /// Returns the IP Address of the GridServer from a Grid-Encoded RegionHandle
+ ///
+ /// Grid Server IP Address
+ public IPAddress getGridIP()
+ {
+ uint a = (uint)((handle >> 16) & 0xFFFF);
+ uint b = (uint)((handle >> 48) & 0xFFFF);
+
+ return new IPAddress((long)(a << 16) | (long)b);
+ }
+
+ ///
+ /// Returns the X Coordinate from a Grid-Encoded RegionHandle
+ ///
+ /// X Coordinate
+ public uint getGridX()
+ {
+ uint x = (uint)((handle >> 32) & 0xFFFF);
+
+ return x;
+ }
+
+ ///
+ /// Returns the Y Coordinate from a Grid-Encoded RegionHandle
+ ///
+ /// Y Coordinate
+ public uint getGridY()
+ {
+ uint y = (uint)((handle >> 0) & 0xFFFF);
+
+ return y;
+ }
+ }
+}