aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/Util.cs24
1 files changed, 20 insertions, 4 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index ec03d25..57c1601 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -739,15 +739,18 @@ namespace OpenSim.Framework
739 /// <returns> 739 /// <returns>
740 /// The extracted ulong 740 /// The extracted ulong
741 /// </returns> 741 /// </returns>
742 public static ulong BytesToUInt64Big(byte[] bytes) { 742 public static ulong BytesToUInt64Big(byte[] bytes)
743 {
743 if (bytes.Length < 8) return 0; 744 if (bytes.Length < 8) return 0;
744 return ((ulong)bytes[0] << 56) | ((ulong)bytes[1] << 48) | ((ulong)bytes[2] << 40) | ((ulong)bytes[3] << 32) | 745 return ((ulong)bytes[0] << 56) | ((ulong)bytes[1] << 48) | ((ulong)bytes[2] << 40) | ((ulong)bytes[3] << 32) |
745 ((ulong)bytes[4] << 24) | ((ulong)bytes[5] << 16) | ((ulong)bytes[6] << 8) | (ulong)bytes[7]; 746 ((ulong)bytes[4] << 24) | ((ulong)bytes[5] << 16) | ((ulong)bytes[6] << 8) | (ulong)bytes[7];
746 } 747 }
747 748
748 // used for RemoteParcelRequest (for "About Landmark") 749 // used for RemoteParcelRequest (for "About Landmark")
749 public static UUID BuildFakeParcelID(ulong regionHandle, uint x, uint y) { 750 public static UUID BuildFakeParcelID(ulong regionHandle, uint x, uint y)
750 byte[] bytes = { 751 {
752 byte[] bytes =
753 {
751 (byte)regionHandle, (byte)(regionHandle >> 8), (byte)(regionHandle >> 16), (byte)(regionHandle >> 24), 754 (byte)regionHandle, (byte)(regionHandle >> 8), (byte)(regionHandle >> 16), (byte)(regionHandle >> 24),
752 (byte)(regionHandle >> 32), (byte)(regionHandle >> 40), (byte)(regionHandle >> 48), (byte)(regionHandle << 56), 755 (byte)(regionHandle >> 32), (byte)(regionHandle >> 40), (byte)(regionHandle >> 48), (byte)(regionHandle << 56),
753 (byte)x, (byte)(x >> 8), (byte)(x >> 16), (byte)(x >> 24), 756 (byte)x, (byte)(x >> 8), (byte)(x >> 16), (byte)(x >> 24),
@@ -755,11 +758,24 @@ namespace OpenSim.Framework
755 return new UUID(bytes, 0); 758 return new UUID(bytes, 0);
756 } 759 }
757 760
758 public static void ParseFakeParcelID(UUID parcelID, out ulong regionHandle, out uint x, out uint y) { 761 public static void ParseFakeParcelID(UUID parcelID, out ulong regionHandle, out uint x, out uint y)
762 {
759 byte[] bytes = parcelID.GetBytes(); 763 byte[] bytes = parcelID.GetBytes();
760 regionHandle = Helpers.BytesToUInt64(bytes); 764 regionHandle = Helpers.BytesToUInt64(bytes);
761 x = Helpers.BytesToUInt(bytes, 8); 765 x = Helpers.BytesToUInt(bytes, 8);
762 y = Helpers.BytesToUInt(bytes, 12); 766 y = Helpers.BytesToUInt(bytes, 12);
763 } 767 }
768
769 public static void FakeParcelIDToGlobalPosition(UUID parcelID, out uint x, out uint y)
770 {
771 ulong regionHandle;
772 uint rx, ry;
773
774 ParseFakeParcelID(parcelID, out regionHandle, out x, out y);
775 Helpers.LongToUInts(regionHandle, out rx, out ry);
776
777 x += rx;
778 y += ry;
779 }
764 } 780 }
765} 781}