diff options
author | UbitUmarov | 2016-12-23 14:23:07 +0000 |
---|---|---|
committer | UbitUmarov | 2016-12-23 14:23:07 +0000 |
commit | b6266c6a1de9d78904aa01eb39f1da2979db06ca (patch) | |
tree | af5d733262930dd07d57ceeed2f030dafec7652e | |
parent | replace the (hidden) GRID_GOD by a more usefull GOD so includes all types. Th... (diff) | |
download | opensim-SC_OLD-b6266c6a1de9d78904aa01eb39f1da2979db06ca.zip opensim-SC_OLD-b6266c6a1de9d78904aa01eb39f1da2979db06ca.tar.gz opensim-SC_OLD-b6266c6a1de9d78904aa01eb39f1da2979db06ca.tar.bz2 opensim-SC_OLD-b6266c6a1de9d78904aa01eb39f1da2979db06ca.tar.xz |
check if a parcelID is a encoded position data or a true UUID. This may fail, just reducing the odds.
-rw-r--r-- | OpenSim/Framework/Util.cs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index b622523..89cf045 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1725,12 +1725,16 @@ namespace OpenSim.Framework | |||
1725 | return new UUID(bytes, 0); | 1725 | return new UUID(bytes, 0); |
1726 | } | 1726 | } |
1727 | 1727 | ||
1728 | public static void ParseFakeParcelID(UUID parcelID, out ulong regionHandle, out uint x, out uint y) | 1728 | public static bool ParseFakeParcelID(UUID parcelID, out ulong regionHandle, out uint x, out uint y) |
1729 | { | 1729 | { |
1730 | byte[] bytes = parcelID.GetBytes(); | 1730 | byte[] bytes = parcelID.GetBytes(); |
1731 | regionHandle = Utils.BytesToUInt64(bytes); | 1731 | regionHandle = Utils.BytesToUInt64(bytes); |
1732 | x = Utils.BytesToUInt(bytes, 8) & 0xffff; | 1732 | x = Utils.BytesToUInt(bytes, 8) & 0xffff; |
1733 | y = Utils.BytesToUInt(bytes, 12) & 0xffff; | 1733 | y = Utils.BytesToUInt(bytes, 12) & 0xffff; |
1734 | // validation may fail, just reducing the odds of using a real UUID as encoded parcel | ||
1735 | return ( bytes[0] == 0 && bytes[4] == 0 && // handler x,y multiples of 256 | ||
1736 | bytes[9] < 64 && bytes[13] < 64 && // positions < 16km | ||
1737 | bytes[14] == 0 && bytes[15] == 0); | ||
1734 | } | 1738 | } |
1735 | 1739 | ||
1736 | public static void ParseFakeParcelID(UUID parcelID, out ulong regionHandle, out uint x, out uint y, out uint z) | 1740 | public static void ParseFakeParcelID(UUID parcelID, out ulong regionHandle, out uint x, out uint y, out uint z) |