* Added experimental RegionHandle class to Framework.Types - see email posted to mailing list for technical details. Not actually enabled anywhere and could be helpful for ordinary RegionHandles as well.
parent
93eaddd583
commit
62c6c9fe8b
|
@ -1,4 +1,4 @@
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ProjectType>Local</ProjectType>
|
<ProjectType>Local</ProjectType>
|
||||||
<ProductVersion>8.0.50727</ProductVersion>
|
<ProductVersion>8.0.50727</ProductVersion>
|
||||||
|
@ -6,7 +6,8 @@
|
||||||
<ProjectGuid>{8ACA2445-0000-0000-0000-000000000000}</ProjectGuid>
|
<ProjectGuid>{8ACA2445-0000-0000-0000-000000000000}</ProjectGuid>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ApplicationIcon></ApplicationIcon>
|
<ApplicationIcon>
|
||||||
|
</ApplicationIcon>
|
||||||
<AssemblyKeyContainerName>
|
<AssemblyKeyContainerName>
|
||||||
</AssemblyKeyContainerName>
|
</AssemblyKeyContainerName>
|
||||||
<AssemblyName>OpenSim.Framework</AssemblyName>
|
<AssemblyName>OpenSim.Framework</AssemblyName>
|
||||||
|
@ -15,9 +16,11 @@
|
||||||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder></AppDesignerFolder>
|
<AppDesignerFolder>
|
||||||
|
</AppDesignerFolder>
|
||||||
<RootNamespace>OpenSim.Framework</RootNamespace>
|
<RootNamespace>OpenSim.Framework</RootNamespace>
|
||||||
<StartupObject></StartupObject>
|
<StartupObject>
|
||||||
|
</StartupObject>
|
||||||
<FileUpgradeFlags>
|
<FileUpgradeFlags>
|
||||||
</FileUpgradeFlags>
|
</FileUpgradeFlags>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -28,7 +31,8 @@
|
||||||
<ConfigurationOverrideFile>
|
<ConfigurationOverrideFile>
|
||||||
</ConfigurationOverrideFile>
|
</ConfigurationOverrideFile>
|
||||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||||
<DocumentationFile></DocumentationFile>
|
<DocumentationFile>
|
||||||
|
</DocumentationFile>
|
||||||
<DebugSymbols>True</DebugSymbols>
|
<DebugSymbols>True</DebugSymbols>
|
||||||
<FileAlignment>4096</FileAlignment>
|
<FileAlignment>4096</FileAlignment>
|
||||||
<Optimize>False</Optimize>
|
<Optimize>False</Optimize>
|
||||||
|
@ -37,7 +41,8 @@
|
||||||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<NoWarn></NoWarn>
|
<NoWarn>
|
||||||
|
</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||||
|
@ -46,7 +51,8 @@
|
||||||
<ConfigurationOverrideFile>
|
<ConfigurationOverrideFile>
|
||||||
</ConfigurationOverrideFile>
|
</ConfigurationOverrideFile>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<DocumentationFile></DocumentationFile>
|
<DocumentationFile>
|
||||||
|
</DocumentationFile>
|
||||||
<DebugSymbols>False</DebugSymbols>
|
<DebugSymbols>False</DebugSymbols>
|
||||||
<FileAlignment>4096</FileAlignment>
|
<FileAlignment>4096</FileAlignment>
|
||||||
<Optimize>True</Optimize>
|
<Optimize>True</Optimize>
|
||||||
|
@ -55,7 +61,8 @@
|
||||||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<NoWarn></NoWarn>
|
<NoWarn>
|
||||||
|
</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System">
|
<Reference Include="System">
|
||||||
|
@ -114,6 +121,7 @@
|
||||||
<Compile Include="SimProfile.cs">
|
<Compile Include="SimProfile.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Types\RegionHandle.cs" />
|
||||||
<Compile Include="UserProfile.cs">
|
<Compile Include="UserProfile.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -0,0 +1,120 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Types
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A class for manipulating RegionHandle coordinates
|
||||||
|
/// </summary>
|
||||||
|
class RegionHandle
|
||||||
|
{
|
||||||
|
private UInt64 handle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises a new grid-aware RegionHandle
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ip">IP Address of the Grid Server for this region</param>
|
||||||
|
/// <param name="x">Grid X Coordinate</param>
|
||||||
|
/// <param name="y">Grid Y Coordinate</param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises a new RegionHandle that is not inter-grid aware
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">Grid X Coordinate</param>
|
||||||
|
/// <param name="y">Grid Y Coordinate</param>
|
||||||
|
public RegionHandle(uint x, uint y)
|
||||||
|
{
|
||||||
|
handle = ((x * 256) << 32) | (y * 256);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialises a new RegionHandle from an existing value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Region">A U64 RegionHandle</param>
|
||||||
|
public RegionHandle(UInt64 Region)
|
||||||
|
{
|
||||||
|
handle = Region;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Grid Masked RegionHandle - For use in Teleport packets and other packets where sending the grid IP address may be handy.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Do not use for SimulatorEnable packets. The client will choke.</remarks>
|
||||||
|
/// <returns>Region Handle including IP Address encoding</returns>
|
||||||
|
public UInt64 getTeleportHandle()
|
||||||
|
{
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a RegionHandle which may be used for SimulatorEnable packets. Removes the IP address encoding and returns the lower bounds.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A U64 RegionHandle for use in SimulatorEnable packets.</returns>
|
||||||
|
public UInt64 getNeighbourHandle()
|
||||||
|
{
|
||||||
|
UInt64 mask = 0x0000FFFF0000FFFF;
|
||||||
|
|
||||||
|
return handle | mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the IP Address of the GridServer from a Grid-Encoded RegionHandle
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Grid Server IP Address</returns>
|
||||||
|
public IPAddress getGridIP()
|
||||||
|
{
|
||||||
|
uint a = (uint)((handle >> 16) & 0xFFFF);
|
||||||
|
uint b = (uint)((handle >> 48) & 0xFFFF);
|
||||||
|
|
||||||
|
return new IPAddress((long)(a << 16) | (long)b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the X Coordinate from a Grid-Encoded RegionHandle
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>X Coordinate</returns>
|
||||||
|
public uint getGridX()
|
||||||
|
{
|
||||||
|
uint x = (uint)((handle >> 32) & 0xFFFF);
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Y Coordinate from a Grid-Encoded RegionHandle
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Y Coordinate</returns>
|
||||||
|
public uint getGridY()
|
||||||
|
{
|
||||||
|
uint y = (uint)((handle >> 0) & 0xFFFF);
|
||||||
|
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue