* Thanks Plugh for pointing out that the constructor that takes a ulong regionhandle and saves it to to X,Y vars in the OpenSim.Framework.Location object was inverting the X and Y resulting in X and Y confusion. The test also used 256x256 in the uint,uint constructor so it was unable to determine if the X and Y components swapped. I don't expect much upheaval from this commit, not a lot of features were using the ulong Location object constructor. The database never stores the ulong regionhandle... the prims are loaded by region Guid. LLUDPServer used it to determine regions that it handled in a service definition where there was simply a X == X test which has the same logical result un-switched as it did switched. Again, thanks LibOMV for the regionhandle code.

TeleportWork
teravus 2013-08-01 16:30:29 -05:00
parent 216e785ca9
commit 7b9a50721d
2 changed files with 15 additions and 15 deletions

View File

@ -33,10 +33,10 @@ namespace OpenSim.Framework
[Serializable]
public class Location : ICloneable
{
private readonly int m_x;
private readonly int m_y;
private readonly uint m_x;
private readonly uint m_y;
public Location(int x, int y)
public Location(uint x, uint y)
{
m_x = x;
m_y = y;
@ -44,21 +44,21 @@ namespace OpenSim.Framework
public Location(ulong regionHandle)
{
m_x = (int) regionHandle;
m_y = (int) (regionHandle >> 32);
m_x = (uint)(regionHandle >> 32);
m_y = (uint)(regionHandle & (ulong)uint.MaxValue);
}
public ulong RegionHandle
{
get { return Utils.UIntsToLong((uint)m_x, (uint)m_y); }
get { return Utils.UIntsToLong(m_x, m_y); }
}
public int X
public uint X
{
get { return m_x; }
}
public int Y
public uint Y
{
get { return m_y; }
}

View File

@ -51,21 +51,21 @@ namespace OpenSim.Framework.Tests
[Test]
public void locationXYRegionHandle()
{
Location TestLocation1 = new Location(256000,256000);
Location TestLocation2 = new Location(1099511628032000);
Location TestLocation1 = new Location(255000,256000);
Location TestLocation2 = new Location(1095216660736000);
Assert.That(TestLocation1 == TestLocation2);
Assert.That(TestLocation2.X == 256000 && TestLocation2.Y == 256000, "Test xy location doesn't match regionhandle provided");
Assert.That(TestLocation2.X == 255000 && TestLocation2.Y == 256000, "Test xy location doesn't match regionhandle provided");
Assert.That(TestLocation2.RegionHandle == 1099511628032000,
Assert.That(TestLocation2.RegionHandle == 1095216660736000,
"Location RegionHandle Property didn't match regionhandle provided in constructor");
TestLocation1 = new Location(256001, 256001);
TestLocation2 = new Location(1099511628032000);
TestLocation1 = new Location(255001, 256001);
TestLocation2 = new Location(1095216660736000);
Assert.That(TestLocation1 != TestLocation2);
Assert.That(TestLocation1.Equals(256001, 256001), "Equals(x,y) failed to match the position in the constructor");
Assert.That(TestLocation1.Equals(255001, 256001), "Equals(x,y) failed to match the position in the constructor");
Assert.That(TestLocation2.GetHashCode() == (TestLocation2.X.GetHashCode() ^ TestLocation2.Y.GetHashCode()), "GetHashCode failed to produce the expected hashcode");