aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/TerrainData.cs4
-rw-r--r--OpenSim/Framework/UserProfileData.cs14
-rw-r--r--OpenSim/Framework/Util.cs37
3 files changed, 48 insertions, 7 deletions
diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs
index d5dad8f..75446d1 100644
--- a/OpenSim/Framework/TerrainData.cs
+++ b/OpenSim/Framework/TerrainData.cs
@@ -408,8 +408,8 @@ namespace OpenSim.Framework
408 } 408 }
409 ClearTaint(); 409 ClearTaint();
410 410
411 m_log.InfoFormat("{0} Read compressed 2d heightmap. Heightmap size=<{1},{2}>. Region size={<{3},{4}>. CompFact={5}", LogHeader, 411 m_log.InfoFormat("{0} Read compressed 2d heightmap. Heightmap size=<{1},{2}>. Region size=<{3},{4}>. CompFact={5}",
412 hmSizeX, hmSizeY, SizeX, SizeY, hmCompressionFactor); 412 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY, hmCompressionFactor);
413 } 413 }
414 } 414 }
415 } 415 }
diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs
index 9bac739..266ccf0 100644
--- a/OpenSim/Framework/UserProfileData.cs
+++ b/OpenSim/Framework/UserProfileData.cs
@@ -160,15 +160,19 @@ namespace OpenSim.Framework
160 public virtual ulong HomeRegion 160 public virtual ulong HomeRegion
161 { 161 {
162 get 162 get
163 { 163 {
164 return Utils.UIntsToLong( 164 return Util.RegionWorldLocToHandle(Util.RegionToWorldLoc(m_homeRegionX), Util.RegionToWorldLoc(m_homeRegionY));
165 m_homeRegionX * (uint)Constants.RegionSize, m_homeRegionY * (uint)Constants.RegionSize); 165 // return Utils.UIntsToLong( m_homeRegionX * (uint)Constants.RegionSize, m_homeRegionY * (uint)Constants.RegionSize);
166 } 166 }
167 167
168 set 168 set
169 { 169 {
170 m_homeRegionX = (uint) (value >> 40); 170 uint regionWorldLocX, regionWorldLocY;
171 m_homeRegionY = (((uint) (value)) >> 8); 171 Util.RegionHandleToWorldLoc(value, out regionWorldLocX, out regionWorldLocY);
172 m_homeRegionX = Util.WorldToRegionLoc(regionWorldLocX);
173 m_homeRegionY = Util.WorldToRegionLoc(regionWorldLocY);
174 // m_homeRegionX = (uint) (value >> 40);
175 // m_homeRegionY = (((uint) (value)) >> 8);
172 } 176 }
173 } 177 }
174 178
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index e8dfec1..105e75d 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -333,6 +333,43 @@ namespace OpenSim.Framework
333 return Utils.UIntsToLong(X, Y); 333 return Utils.UIntsToLong(X, Y);
334 } 334 }
335 335
336 // Regions are identified with a 'handle' made up of its region coordinates packed into a ulong.
337 // Several places rely on the ability to extract a region's location from its handle.
338 // Note the location is in 'world coordinates' (see below).
339 public static ulong RegionWorldLocToHandle(uint X, uint Y)
340 {
341 return Utils.UIntsToLong(X, Y);
342 }
343
344 public static void RegionHandleToWorldLoc(ulong handle, out uint X, out uint Y)
345 {
346 X = (uint)(handle >> 32);
347 Y = (uint)(handle & (ulong)uint.MaxValue);
348 }
349
350 public static void RegionHandleToRegionLoc(ulong handle, out uint X, out uint Y)
351 {
352 uint worldX, worldY;
353 RegionHandleToWorldLoc(handle, out worldX, out worldY);
354 X = WorldToRegionLoc(worldX);
355 Y = WorldToRegionLoc(worldY);
356 }
357
358 // A region location can be 'world coordinates' (meters from zero) or 'region coordinates'
359 // (number of regions from zero). This measurement of regions relies on the legacy 256 region size.
360 // These routines exist to make what is being converted explicit so the next person knows what was meant.
361 // Convert a region's 'world coordinate' to its 'region coordinate'.
362 public static uint WorldToRegionLoc(uint worldCoord)
363 {
364 return worldCoord / Constants.RegionSize;
365 }
366
367 // Convert a region's 'region coordinate' to its 'world coordinate'.
368 public static uint RegionToWorldLoc(uint regionCoord)
369 {
370 return regionCoord * Constants.RegionSize;
371 }
372
336 public static T Clamp<T>(T x, T min, T max) 373 public static T Clamp<T>(T x, T min, T max)
337 where T : IComparable<T> 374 where T : IComparable<T>
338 { 375 {