aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs43
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs34
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs34
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs49
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs37
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs53
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs20
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs2
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs10
25 files changed, 149 insertions, 179 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 2aa43bc..eb08257 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -337,6 +337,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
337 "[ENTITY TRANSFER MODULE]: Received teleport cancel request from {0} in {1}", client.Name, Scene.Name); 337 "[ENTITY TRANSFER MODULE]: Received teleport cancel request from {0} in {1}", client.Name, Scene.Name);
338 } 338 }
339 339
340 // Attempt to teleport the ScenePresence to the specified position in the specified region (spec'ed by its handle).
340 public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) 341 public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags)
341 { 342 {
342 if (sp.Scene.Permissions.IsGridGod(sp.UUID)) 343 if (sp.Scene.Permissions.IsGridGod(sp.UUID))
@@ -478,7 +479,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
478 Vector3 lookAt, uint teleportFlags, out GridRegion finalDestination) 479 Vector3 lookAt, uint teleportFlags, out GridRegion finalDestination)
479 { 480 {
480 uint x = 0, y = 0; 481 uint x = 0, y = 0;
481 Utils.LongToUInts(regionHandle, out x, out y); 482 Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
482 GridRegion reg = Scene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y); 483 GridRegion reg = Scene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y);
483 484
484 if (reg != null) 485 if (reg != null)
@@ -532,8 +533,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
532 Util.RegionHandleToRegionLoc(regionHandle, out regX, out regY); 533 Util.RegionHandleToRegionLoc(regionHandle, out regX, out regY);
533 534
534 MapBlockData block = new MapBlockData(); 535 MapBlockData block = new MapBlockData();
535 block.X = (ushort)Util.WorldToRegionLoc(regX); 536 block.X = (ushort)regX;
536 block.Y = (ushort)Util.WorldToRegionLoc(regY); 537 block.Y = (ushort)regY;
537 block.Access = 254; // == not there 538 block.Access = 254; // == not there
538 539
539 List<MapBlockData> blocks = new List<MapBlockData>(); 540 List<MapBlockData> blocks = new List<MapBlockData>();
@@ -1505,7 +1506,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1505 1506
1506 agent.Scene.RequestTeleportLocation( 1507 agent.Scene.RequestTeleportLocation(
1507 agent.ControllingClient, 1508 agent.ControllingClient,
1508 Utils.UIntsToLong(regionX * (uint)Constants.RegionSize, regionY * (uint)Constants.RegionSize), 1509 Util.RegionLocToHandle(regionX, regionY),
1509 position, 1510 position,
1510 agent.Lookat, 1511 agent.Lookat,
1511 (uint)Constants.TeleportFlags.ViaLocation); 1512 (uint)Constants.TeleportFlags.ViaLocation);
@@ -1515,11 +1516,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1515 if (im != null) 1516 if (im != null)
1516 { 1517 {
1517 UUID gotoLocation = Util.BuildFakeParcelID( 1518 UUID gotoLocation = Util.BuildFakeParcelID(
1518 Util.UIntsToLong( 1519 Util.RegionLocToHandle(regionX, regionY),
1519 (regionX *
1520 (uint)Constants.RegionSize),
1521 (regionY *
1522 (uint)Constants.RegionSize)),
1523 (uint)(int)position.X, 1520 (uint)(int)position.X,
1524 (uint)(int)position.Y, 1521 (uint)(int)position.Y,
1525 (uint)(int)position.Z); 1522 (uint)(int)position.Z);
@@ -1991,8 +1988,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1991 int shifty = (rRegionY - tRegionY) * (int)Constants.RegionSize; 1988 int shifty = (rRegionY - tRegionY) * (int)Constants.RegionSize;
1992 return new Vector3(shiftx, shifty, 0f); 1989 return new Vector3(shiftx, shifty, 0f);
1993 */ 1990 */
1994 return new Vector3(sp.Scene.RegionInfo.RegionLocX - neighbour.RegionLocX, 1991 return new Vector3( sp.Scene.RegionInfo.WorldLocX - neighbour.RegionLocX,
1995 sp.Scene.RegionInfo.RegionLocY - neighbour.RegionLocY, 1992 sp.Scene.RegionInfo.WorldLocY - neighbour.RegionLocY,
1996 0f); 1993 0f);
1997 } 1994 }
1998 1995
@@ -2172,16 +2169,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2172 // view to include everything in the megaregion 2169 // view to include everything in the megaregion
2173 if (m_regionCombinerModule == null || !m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID)) 2170 if (m_regionCombinerModule == null || !m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID))
2174 { 2171 {
2175 int dd = avatar.DrawDistance < Constants.RegionSize ? (int)Constants.RegionSize : (int)avatar.DrawDistance; 2172 // The area to check is as big as the current region.
2173 // We presume all adjacent regions are the same size as this region.
2174 uint dd = Math.Max((uint)avatar.DrawDistance,
2175 Math.Max(Scene.RegionInfo.RegionSizeX, Scene.RegionInfo.RegionSizeY));
2176 2176
2177 int startX = (int)pRegionLocX * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2); 2177 uint startX = Util.RegionToWorldLoc(pRegionLocX) - dd + Constants.RegionSize/2;
2178 int startY = (int)pRegionLocY * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2); 2178 uint startY = Util.RegionToWorldLoc(pRegionLocY) - dd + Constants.RegionSize/2;
2179 2179
2180 int endX = (int)pRegionLocX * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2); 2180 uint endX = Util.RegionToWorldLoc(pRegionLocX) + dd + Constants.RegionSize/2;
2181 int endY = (int)pRegionLocY * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2); 2181 uint endY = Util.RegionToWorldLoc(pRegionLocY) + dd + Constants.RegionSize/2;
2182 2182
2183 List<GridRegion> neighbours = 2183 List<GridRegion> neighbours =
2184 avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY); 2184 avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, (int)startX, (int)endX, (int)startY, (int)endY);
2185 2185
2186 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; }); 2186 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
2187 return neighbours; 2187 return neighbours;
@@ -2194,10 +2194,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2194 List<GridRegion> neighbours 2194 List<GridRegion> neighbours
2195 = pScene.GridService.GetRegionRange( 2195 = pScene.GridService.GetRegionRange(
2196 m_regionInfo.ScopeID, 2196 m_regionInfo.ScopeID,
2197 (int)swCorner.X * (int)Constants.RegionSize, 2197 (int)Util.RegionToWorldLoc((uint)swCorner.X), (int)Util.RegionToWorldLoc((uint)neCorner.X),
2198 (int)neCorner.X * (int)Constants.RegionSize, 2198 (int)Util.RegionToWorldLoc((uint)swCorner.Y), (int)Util.RegionToWorldLoc((uint)neCorner.Y) );
2199 (int)swCorner.Y * (int)Constants.RegionSize,
2200 (int)neCorner.Y * (int)Constants.RegionSize);
2201 2199
2202 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; }); 2200 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
2203 2201
@@ -2300,7 +2298,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2300 double objectWorldLocY = (double)scene.RegionInfo.WorldLocY + attemptedPosition.Y; 2298 double objectWorldLocY = (double)scene.RegionInfo.WorldLocY + attemptedPosition.Y;
2301 2299
2302 // Ask the grid service for the region that contains the passed address 2300 // Ask the grid service for the region that contains the passed address
2303 GridRegion destination = GetRegionContainingWorldLocation(scene.GridService, scene.RegionInfo.ScopeID, objectWorldLocX, objectWorldLocY); 2301 GridRegion destination = GetRegionContainingWorldLocation(scene.GridService, scene.RegionInfo.ScopeID,
2302 objectWorldLocX, objectWorldLocY);
2304 2303
2305 Vector3 pos = Vector3.Zero; 2304 Vector3 pos = Vector3.Zero;
2306 if (destination != null) 2305 if (destination != null)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
index 33ff7ea..ae76288 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
@@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
82 return new List<GridRegion>(m_neighbours.Values); 82 return new List<GridRegion>(m_neighbours.Values);
83 } 83 }
84 84
85 // Get a region given its base coordinates. 85 // Get a region given its base coordinates (in meters).
86 // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST 86 // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST
87 // be the base coordinate of the region. 87 // be the base coordinate of the region.
88 // The snapping is technically unnecessary but is harmless because regions are always 88 // The snapping is technically unnecessary but is harmless because regions are always
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index ac81337..ae5081c 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -186,7 +186,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
186 return rinfo; 186 return rinfo;
187 } 187 }
188 188
189 // Get a region given its base coordinates. 189 // Get a region given its base world coordinates (in meters).
190 // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST 190 // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST
191 // be the base coordinate of the region. 191 // be the base coordinate of the region.
192 // The coordinates are world coords (meters), NOT region units. 192 // The coordinates are world coords (meters), NOT region units.
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
index fd89428..56d9937 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
@@ -132,7 +132,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
132 if (s.RegionInfo.RegionHandle == regionHandle) 132 if (s.RegionInfo.RegionHandle == regionHandle)
133 { 133 {
134 m_log.DebugFormat("[LOCAL NEIGHBOUR SERVICE CONNECTOR]: HelloNeighbour from region {0} to neighbour {1} at {2}-{3}", 134 m_log.DebugFormat("[LOCAL NEIGHBOUR SERVICE CONNECTOR]: HelloNeighbour from region {0} to neighbour {1} at {2}-{3}",
135 thisRegion.RegionName, s.Name, x / Constants.RegionSize, y / Constants.RegionSize); 135 thisRegion.RegionName, s.Name, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y) );
136 136
137 //m_log.Debug("[NEIGHBOUR CONNECTOR]: Found region to SendHelloNeighbour"); 137 //m_log.Debug("[NEIGHBOUR CONNECTOR]: Found region to SendHelloNeighbour");
138 return s.IncomingHelloNeighbour(thisRegion); 138 return s.IncomingHelloNeighbour(thisRegion);
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
index a990898..9f39aa2 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
@@ -533,7 +533,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
533 if (isMegaregion) 533 if (isMegaregion)
534 size = rcMod.GetSizeOfMegaregion(scene.RegionInfo.RegionID); 534 size = rcMod.GetSizeOfMegaregion(scene.RegionInfo.RegionID);
535 else 535 else
536 size = new Vector2((float)Constants.RegionSize, (float)Constants.RegionSize); 536 size = new Vector2((float)scene.RegionInfo.RegionSizeX, (float)scene.RegionInfo.RegionSizeY);
537 537
538 xtw.WriteElementString("is_megaregion", isMegaregion.ToString()); 538 xtw.WriteElementString("is_megaregion", isMegaregion.ToString());
539 xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y)); 539 xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y));
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
index 40638f8..1007e0b 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
@@ -102,7 +102,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
102 102
103 terrainRenderer.Initialise(m_scene, m_config); 103 terrainRenderer.Initialise(m_scene, m_config);
104 104
105 mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize, System.Drawing.Imaging.PixelFormat.Format24bppRgb); 105 mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height,
106 System.Drawing.Imaging.PixelFormat.Format24bppRgb);
106 //long t = System.Environment.TickCount; 107 //long t = System.Environment.TickCount;
107 //for (int i = 0; i < 10; ++i) { 108 //for (int i = 0; i < 10; ++i) {
108 terrainRenderer.TerrainToBitmap(mapbmp); 109 terrainRenderer.TerrainToBitmap(mapbmp);
@@ -273,7 +274,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
273 private Bitmap DrawObjectVolume(Scene whichScene, Bitmap mapbmp) 274 private Bitmap DrawObjectVolume(Scene whichScene, Bitmap mapbmp)
274 { 275 {
275 int tc = 0; 276 int tc = 0;
276 double[,] hm = whichScene.Heightmap.GetDoubles(); 277 ITerrainChannel hm = whichScene.Heightmap;
277 tc = Environment.TickCount; 278 tc = Environment.TickCount;
278 m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); 279 m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile");
279 EntityBase[] objs = whichScene.GetEntities(); 280 EntityBase[] objs = whichScene.GetEntities();
@@ -356,7 +357,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
356 Vector3 pos = part.GetWorldPosition(); 357 Vector3 pos = part.GetWorldPosition();
357 358
358 // skip prim outside of retion 359 // skip prim outside of retion
359 if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f) 360 if (!m_scene.PositionIsInCurrentRegion(pos))
360 continue; 361 continue;
361 362
362 // skip prim in non-finite position 363 // skip prim in non-finite position
@@ -399,9 +400,14 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
399 int mapdrawendY = (int)(pos.Y + scale.Y); 400 int mapdrawendY = (int)(pos.Y + scale.Y);
400 401
401 // If object is beyond the edge of the map, don't draw it to avoid errors 402 // If object is beyond the edge of the map, don't draw it to avoid errors
402 if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1) 403 if (mapdrawstartX < 0
403 || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0 404 || mapdrawstartX > (hm.Width - 1)
404 || mapdrawendY > ((int)Constants.RegionSize - 1)) 405 || mapdrawendX < 0
406 || mapdrawendX > (hm.Width - 1)
407 || mapdrawstartY < 0
408 || mapdrawstartY > (hm.Height - 1)
409 || mapdrawendY < 0
410 || mapdrawendY > (hm.Height - 1))
405 continue; 411 continue;
406 412
407#region obb face reconstruction part duex 413#region obb face reconstruction part duex
@@ -523,11 +529,11 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
523 for (int i = 0; i < FaceA.Length; i++) 529 for (int i = 0; i < FaceA.Length; i++)
524 { 530 {
525 Point[] working = new Point[5]; 531 Point[] working = new Point[5];
526 working[0] = project(FaceA[i], axPos); 532 working[0] = project(hm, FaceA[i], axPos);
527 working[1] = project(FaceB[i], axPos); 533 working[1] = project(hm, FaceB[i], axPos);
528 working[2] = project(FaceD[i], axPos); 534 working[2] = project(hm, FaceD[i], axPos);
529 working[3] = project(FaceC[i], axPos); 535 working[3] = project(hm, FaceC[i], axPos);
530 working[4] = project(FaceA[i], axPos); 536 working[4] = project(hm, FaceA[i], axPos);
531 537
532 face workingface = new face(); 538 face workingface = new face();
533 workingface.pts = working; 539 workingface.pts = working;
@@ -595,17 +601,17 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
595 return mapbmp; 601 return mapbmp;
596 } 602 }
597 603
598 private Point project(Vector3 point3d, Vector3 originpos) 604 private Point project(ITerrainChannel hm, Vector3 point3d, Vector3 originpos)
599 { 605 {
600 Point returnpt = new Point(); 606 Point returnpt = new Point();
601 //originpos = point3d; 607 //originpos = point3d;
602 //int d = (int)(256f / 1.5f); 608 //int d = (int)(256f / 1.5f);
603 609
604 //Vector3 topos = new Vector3(0, 0, 0); 610 //Vector3 topos = new Vector3(0, 0, 0);
605 // float z = -point3d.z - topos.z; 611 // float z = -point3d.z - topos.z;
606 612
607 returnpt.X = (int)point3d.X;//(int)((topos.x - point3d.x) / z * d); 613 returnpt.X = (int)point3d.X;//(int)((topos.x - point3d.x) / z * d);
608 returnpt.Y = (int)(((int)Constants.RegionSize - 1) - point3d.Y);//(int)(255 - (((topos.y - point3d.y) / z * d))); 614 returnpt.Y = (int)((hm.Width - 1) - point3d.Y);//(int)(255 - (((topos.y - point3d.y) / z * d)));
609 615
610 return returnpt; 616 return returnpt;
611 } 617 }
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
index 992bff3..9b939c9 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
@@ -31,6 +31,7 @@ using System.Reflection;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
35 36
36namespace OpenSim.Region.CoreModules.World.LegacyMap 37namespace OpenSim.Region.CoreModules.World.LegacyMap
@@ -39,8 +40,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
39 { 40 {
40 private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95); 41 private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95);
41 42
42 private static readonly ILog m_log = 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly string LogHeader = "[SHADED MAPTILE RENDERER]";
44 45
45 private Scene m_scene; 46 private Scene m_scene;
46 //private IConfigSource m_config; // not used currently 47 //private IConfigSource m_config; // not used currently
@@ -53,19 +54,26 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
53 54
54 public void TerrainToBitmap(Bitmap mapbmp) 55 public void TerrainToBitmap(Bitmap mapbmp)
55 { 56 {
57 m_log.DebugFormat("{0} Generating Maptile Step 1: Terrain", LogHeader);
56 int tc = Environment.TickCount; 58 int tc = Environment.TickCount;
57 m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain");
58 59
59 double[,] hm = m_scene.Heightmap.GetDoubles(); 60 ITerrainChannel hm = m_scene.Heightmap;
61
62 if (mapbmp.Width != hm.Width || mapbmp.Height != hm.Height)
63 {
64 m_log.ErrorFormat("{0} TerrainToBitmap. Passed bitmap wrong dimensions. passed=<{1},{2}>, size=<{3},{4}>",
65 LogHeader, mapbmp.Width, mapbmp.Height, hm.Width, hm.Height);
66 }
67
60 bool ShadowDebugContinue = true; 68 bool ShadowDebugContinue = true;
61 69
62 bool terraincorruptedwarningsaid = false; 70 bool terraincorruptedwarningsaid = false;
63 71
64 float low = 255; 72 float low = 255;
65 float high = 0; 73 float high = 0;
66 for (int x = 0; x < (int)Constants.RegionSize; x++) 74 for (int x = 0; x < hm.Width; x++)
67 { 75 {
68 for (int y = 0; y < (int)Constants.RegionSize; y++) 76 for (int y = 0; y < hm.Height; y++)
69 { 77 {
70 float hmval = (float)hm[x, y]; 78 float hmval = (float)hm[x, y];
71 if (hmval < low) 79 if (hmval < low)
@@ -77,12 +85,12 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
77 85
78 float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; 86 float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight;
79 87
80 for (int x = 0; x < (int)Constants.RegionSize; x++) 88 for (int x = 0; x < hm.Width; x++)
81 { 89 {
82 for (int y = 0; y < (int)Constants.RegionSize; y++) 90 for (int y = 0; y < hm.Height; y++)
83 { 91 {
84 // Y flip the cordinates for the bitmap: hf origin is lower left, bm origin is upper left 92 // Y flip the cordinates for the bitmap: hf origin is lower left, bm origin is upper left
85 int yr = ((int)Constants.RegionSize - 1) - y; 93 int yr = ((int)hm.Height - 1) - y;
86 94
87 float heightvalue = (float)hm[x, y]; 95 float heightvalue = (float)hm[x, y];
88 96
@@ -109,12 +117,12 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
109 // . 117 // .
110 // 118 //
111 // Shade the terrain for shadows 119 // Shade the terrain for shadows
112 if (x < ((int)Constants.RegionSize - 1) && yr < ((int)Constants.RegionSize - 1)) 120 if (x < (hm.Width - 1) && yr < (hm.Height - 1))
113 { 121 {
114 float hfvalue = (float)hm[x, y]; 122 float hfvalue = (float)hm[x, y];
115 float hfvaluecompare = 0f; 123 float hfvaluecompare = 0f;
116 124
117 if ((x + 1 < (int)Constants.RegionSize) && (y + 1 < (int)Constants.RegionSize)) 125 if ((x + 1 < hm.Width) && (y + 1 < hm.Height))
118 { 126 {
119 hfvaluecompare = (float)hm[x + 1, y + 1]; // light from north-east => look at land height there 127 hfvaluecompare = (float)hm[x + 1, y + 1]; // light from north-east => look at land height there
120 } 128 }
@@ -179,7 +187,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
179 187
180 if (ShadowDebugContinue) 188 if (ShadowDebugContinue)
181 { 189 {
182 if ((x - 1 > 0) && (yr + 1 < (int)Constants.RegionSize)) 190 if ((x - 1 > 0) && (yr + 1 < hm.Height))
183 { 191 {
184 color = mapbmp.GetPixel(x - 1, yr + 1); 192 color = mapbmp.GetPixel(x - 1, yr + 1);
185 int r = color.R; 193 int r = color.R;
@@ -233,7 +241,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
233 terraincorruptedwarningsaid = true; 241 terraincorruptedwarningsaid = true;
234 } 242 }
235 Color black = Color.Black; 243 Color black = Color.Black;
236 mapbmp.SetPixel(x, ((int)Constants.RegionSize - y) - 1, black); 244 mapbmp.SetPixel(x, (hm.Width - y) - 1, black);
237 } 245 }
238 } 246 }
239 } 247 }
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
index d13c2ef..413ac64 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
@@ -34,6 +34,8 @@ using Nini.Config;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenMetaverse.Imaging; 35using OpenMetaverse.Imaging;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Region.Framework;
38using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
38 40
39namespace OpenSim.Region.CoreModules.World.LegacyMap 41namespace OpenSim.Region.CoreModules.World.LegacyMap
@@ -122,8 +124,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
122 { 124 {
123 #region Constants 125 #region Constants
124 126
125 private static readonly ILog m_log = 127 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
126 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 128 private static readonly string LogHeader = "[TEXTURED MAPTILE RENDERER]";
127 129
128 // some hardcoded terrain UUIDs that work with SL 1.20 (the four default textures and "Blank"). 130 // some hardcoded terrain UUIDs that work with SL 1.20 (the four default textures and "Blank").
129 // The color-values were choosen because they "look right" (at least to me) ;-) 131 // The color-values were choosen because they "look right" (at least to me) ;-)
@@ -173,7 +175,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
173 private Bitmap fetchTexture(UUID id) 175 private Bitmap fetchTexture(UUID id)
174 { 176 {
175 AssetBase asset = m_scene.AssetService.Get(id.ToString()); 177 AssetBase asset = m_scene.AssetService.Get(id.ToString());
176 m_log.DebugFormat("[TexturedMapTileRenderer]: Fetched texture {0}, found: {1}", id, asset != null); 178 m_log.DebugFormat("{0} Fetched texture {1}, found: {2}", LogHeader, id, asset != null);
177 if (asset == null) return null; 179 if (asset == null) return null;
178 180
179 ManagedImage managedImage; 181 ManagedImage managedImage;
@@ -188,18 +190,15 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
188 } 190 }
189 catch (DllNotFoundException) 191 catch (DllNotFoundException)
190 { 192 {
191 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id); 193 m_log.ErrorFormat("{0} OpenJpeg is not installed correctly on this system. Asset Data is empty for {1}", LogHeader, id);
192
193 } 194 }
194 catch (IndexOutOfRangeException) 195 catch (IndexOutOfRangeException)
195 { 196 {
196 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); 197 m_log.ErrorFormat("{0} OpenJpeg was unable to encode this. Asset Data is empty for {1}", LogHeader, id);
197
198 } 198 }
199 catch (Exception) 199 catch (Exception)
200 { 200 {
201 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); 201 m_log.ErrorFormat("{0} OpenJpeg was unable to encode this. Asset Data is empty for {1}", LogHeader, id);
202
203 } 202 }
204 return null; 203 return null;
205 204
@@ -267,8 +266,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
267 266
268 // the heigthfield might have some jumps in values. Rendered land is smooth, though, 267 // the heigthfield might have some jumps in values. Rendered land is smooth, though,
269 // as a slope is rendered at that place. So average 4 neighbour values to emulate that. 268 // as a slope is rendered at that place. So average 4 neighbour values to emulate that.
270 private float getHeight(double[,] hm, int x, int y) { 269 private float getHeight(ITerrainChannel hm, int x, int y) {
271 if (x < ((int)Constants.RegionSize - 1) && y < ((int)Constants.RegionSize - 1)) 270 if (x < (hm.Width - 1) && y < (hm.Height - 1))
272 return (float)(hm[x, y] * .444 + (hm[x + 1, y] + hm[x, y + 1]) * .222 + hm[x + 1, y +1] * .112); 271 return (float)(hm[x, y] * .444 + (hm[x + 1, y] + hm[x, y + 1]) * .222 + hm[x + 1, y +1] * .112);
273 else 272 else
274 return (float)hm[x, y]; 273 return (float)hm[x, y];
@@ -278,7 +277,15 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
278 public void TerrainToBitmap(Bitmap mapbmp) 277 public void TerrainToBitmap(Bitmap mapbmp)
279 { 278 {
280 int tc = Environment.TickCount; 279 int tc = Environment.TickCount;
281 m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); 280 m_log.DebugFormat("{0} Generating Maptile Step 1: Terrain", LogHeader);
281
282 ITerrainChannel hm = m_scene.Heightmap;
283
284 if (mapbmp.Width != hm.Width || mapbmp.Height != hm.Height)
285 {
286 m_log.ErrorFormat("{0} TerrainToBitmap. Passed bitmap wrong dimensions. passed=<{1},{2}>, size=<{3},{4}>",
287 LogHeader, mapbmp.Width, mapbmp.Height, hm.Width, hm.Height);
288 }
282 289
283 // These textures should be in the AssetCache anyway, as every client conneting to this 290 // These textures should be in the AssetCache anyway, as every client conneting to this
284 // region needs them. Except on start, when the map is recreated (before anyone connected), 291 // region needs them. Except on start, when the map is recreated (before anyone connected),
@@ -306,19 +313,17 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
306 313
307 float waterHeight = (float)settings.WaterHeight; 314 float waterHeight = (float)settings.WaterHeight;
308 315
309 double[,] hm = m_scene.Heightmap.GetDoubles(); 316 for (int x = 0; x < hm.Width; x++)
310
311 for (int x = 0; x < (int)Constants.RegionSize; x++)
312 { 317 {
313 float columnRatio = x / ((float)Constants.RegionSize - 1); // 0 - 1, for interpolation 318 float columnRatio = x / (hm.Width - 1); // 0 - 1, for interpolation
314 for (int y = 0; y < (int)Constants.RegionSize; y++) 319 for (int y = 0; y < hm.Height; y++)
315 { 320 {
316 float rowRatio = y / ((float)Constants.RegionSize - 1); // 0 - 1, for interpolation 321 float rowRatio = y / (hm.Height - 1); // 0 - 1, for interpolation
317 322
318 // Y flip the cordinates for the bitmap: hf origin is lower left, bm origin is upper left 323 // Y flip the cordinates for the bitmap: hf origin is lower left, bm origin is upper left
319 int yr = ((int)Constants.RegionSize - 1) - y; 324 int yr = (hm.Height - 1) - y;
320 325
321 float heightvalue = getHeight(hm, x, y); 326 float heightvalue = getHeight(m_scene.Heightmap, x, y);
322 if (Single.IsInfinity(heightvalue) || Single.IsNaN(heightvalue)) 327 if (Single.IsInfinity(heightvalue) || Single.IsNaN(heightvalue))
323 heightvalue = 0; 328 heightvalue = 0;
324 329
@@ -368,9 +373,9 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
368 } 373 }
369 374
370 // Shade the terrain for shadows 375 // Shade the terrain for shadows
371 if (x < ((int)Constants.RegionSize - 1) && y < ((int)Constants.RegionSize - 1)) 376 if (x < (hm.Width - 1) && y < (hm.Height - 1))
372 { 377 {
373 float hfvaluecompare = getHeight(hm, x + 1, y + 1); // light from north-east => look at land height there 378 float hfvaluecompare = getHeight(m_scene.Heightmap, x + 1, y + 1); // light from north-east => look at land height there
374 if (Single.IsInfinity(hfvaluecompare) || Single.IsNaN(hfvaluecompare)) 379 if (Single.IsInfinity(hfvaluecompare) || Single.IsNaN(hfvaluecompare))
375 hfvaluecompare = 0f; 380 hfvaluecompare = 0f;
376 381
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 22a53a8..e8eaeb7 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -151,14 +151,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
151 break; 151 break;
152 152
153 case 2: // Sell a copy 153 case 2: // Sell a copy
154 Vector3 inventoryStoredPosition = new Vector3 154 Vector3 inventoryStoredPosition = new Vector3(
155 (((group.AbsolutePosition.X > (int)Constants.RegionSize) 155 Math.Min(group.AbsolutePosition.X, m_scene.RegionInfo.RegionSizeX - 6),
156 ? 250 156 Math.Min(group.AbsolutePosition.Y, m_scene.RegionInfo.RegionSizeY - 6),
157 : group.AbsolutePosition.X)
158 ,
159 (group.AbsolutePosition.X > (int)Constants.RegionSize)
160 ? 250
161 : group.AbsolutePosition.X,
162 group.AbsolutePosition.Z); 157 group.AbsolutePosition.Z);
163 158
164 Vector3 originalPosition = group.AbsolutePosition; 159 Vector3 originalPosition = group.AbsolutePosition;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
index 630473e..b6c635c 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
45 { 45 {
46 if (fillArea[x, y]) 46 if (fillArea[x, y])
47 { 47 {
48 double noise = TerrainUtil.PerlinNoise2D((double) x / Constants.RegionSize, (double) y / Constants.RegionSize, 8, 1.0); 48 double noise = TerrainUtil.PerlinNoise2D((double) x / map.Width, (double) y / map.Height, 8, 1.0);
49 49
50 map[x, y] += noise * strength; 50 map[x, y] += noise * strength;
51 } 51 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs
index 989b7d8..e7df3f8 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs
@@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
53 z *= z; 53 z *= z;
54 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); 54 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
55 55
56 double noise = TerrainUtil.PerlinNoise2D(x / (double) Constants.RegionSize, y / (double) Constants.RegionSize, 8, 1.0); 56 double noise = TerrainUtil.PerlinNoise2D(x / (double) map.Width, y / (double) map.Height, 8, 1.0);
57 57
58 if (z > 0.0) 58 if (z > 0.0)
59 map[x, y] += noise * z * duration; 59 map[x, y] += noise * z * duration;
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
index ed2b06a..6d9e31b 100644
--- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
@@ -128,7 +128,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
128 public Bitmap CreateMapTile() 128 public Bitmap CreateMapTile()
129 { 129 {
130 Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); 130 Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f);
131 Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, (int)Constants.RegionSize, (int)Constants.RegionSize, (float)Constants.RegionSize, (float)Constants.RegionSize); 131 Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f,
132 (int)Constants.RegionSize, (int)Constants.RegionSize,
133 (float)Constants.RegionSize, (float)Constants.RegionSize);
132 return CreateMapTile(viewport, false); 134 return CreateMapTile(viewport, false);
133 } 135 }
134 136
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 708a9a2..1fb1aba 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -184,8 +184,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
184 data.Name = info.RegionName; 184 data.Name = info.RegionName;
185 data.RegionFlags = 0; // TODO not used? 185 data.RegionFlags = 0; // TODO not used?
186 data.WaterHeight = 0; // not used 186 data.WaterHeight = 0; // not used
187 data.X = (ushort)(info.RegionLocX / Constants.RegionSize); 187 data.X = (ushort)Util.WorldToRegionLoc((uint)info.RegionLocX);
188 data.Y = (ushort)(info.RegionLocY / Constants.RegionSize); 188 data.Y = (ushort)Util.WorldToRegionLoc((uint)info.RegionLocY);
189 blocks.Add(data); 189 blocks.Add(data);
190 } 190 }
191 } 191 }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index cd315b1..4badb12 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -277,11 +277,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
277 { 277 {
278 List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; 278 List<MapBlockData> mapBlocks = new List<MapBlockData>(); ;
279 279
280 // Get regions that are within 8 regions of here
280 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, 281 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
281 (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, 282 (int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocX - 8),
282 (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, 283 (int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocX + 8),
283 (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, 284 (int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocY - 8),
284 (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); 285 (int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocY + 8) );
285 foreach (GridRegion r in regions) 286 foreach (GridRegion r in regions)
286 { 287 {
287 MapBlockData block = new MapBlockData(); 288 MapBlockData block = new MapBlockData();
@@ -1011,17 +1012,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1011 // on an unloaded square. 1012 // on an unloaded square.
1012 // But make sure: Look whether the one we requested is in there 1013 // But make sure: Look whether the one we requested is in there
1013 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, 1014 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
1014 minX * (int)Constants.RegionSize, 1015 (int)Util.RegionToWorldLoc((uint)minX), (int)Util.RegionToWorldLoc((uint)maxX),
1015 maxX * (int)Constants.RegionSize, 1016 (int)Util.RegionToWorldLoc((uint)minY), (int)Util.RegionToWorldLoc((uint)maxY) );
1016 minY * (int)Constants.RegionSize,
1017 maxY * (int)Constants.RegionSize);
1018 1017
1019 if (regions != null) 1018 if (regions != null)
1020 { 1019 {
1021 foreach (GridRegion r in regions) 1020 foreach (GridRegion r in regions)
1022 { 1021 {
1023 if ((r.RegionLocX == minX * (int)Constants.RegionSize) && 1022 if (r.RegionLocX == Util.RegionToWorldLoc((uint)minX)
1024 (r.RegionLocY == minY * (int)Constants.RegionSize)) 1023 && r.RegionLocY == Util.RegionToWorldLoc((uint)minY) )
1025 { 1024 {
1026 // found it => add it to response 1025 // found it => add it to response
1027 MapBlockData block = new MapBlockData(); 1026 MapBlockData block = new MapBlockData();
@@ -1055,10 +1054,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1055 { 1054 {
1056 List<MapBlockData> mapBlocks = new List<MapBlockData>(); 1055 List<MapBlockData> mapBlocks = new List<MapBlockData>();
1057 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, 1056 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
1058 (minX - 4) * (int)Constants.RegionSize, 1057 (int)Util.RegionToWorldLoc((uint)(minX - 4)), (int)Util.RegionToWorldLoc((uint)(maxX + 4)),
1059 (maxX + 4) * (int)Constants.RegionSize, 1058 (int)Util.RegionToWorldLoc((uint)(minY - 4)), (int)Util.RegionToWorldLoc((uint)(maxY + 4)) );
1060 (minY - 4) * (int)Constants.RegionSize,
1061 (maxY + 4) * (int)Constants.RegionSize);
1062 foreach (GridRegion r in regions) 1059 foreach (GridRegion r in regions)
1063 { 1060 {
1064 MapBlockData block = new MapBlockData(); 1061 MapBlockData block = new MapBlockData();
@@ -1086,8 +1083,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1086 break; 1083 break;
1087 } 1084 }
1088 block.Name = r.RegionName; 1085 block.Name = r.RegionName;
1089 block.X = (ushort)(r.RegionLocX / Constants.RegionSize); 1086 block.X = (ushort)Util.WorldToRegionLoc((uint)r.RegionLocX);
1090 block.Y = (ushort)(r.RegionLocY / Constants.RegionSize); 1087 block.Y = (ushort)Util.WorldToRegionLoc((uint)r.RegionLocY);
1091 } 1088 }
1092 1089
1093 public Hashtable OnHTTPThrottled(Hashtable keysvals) 1090 public Hashtable OnHTTPThrottled(Hashtable keysvals)
@@ -1218,10 +1215,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1218 1215
1219 List<MapBlockData> mapBlocks = new List<MapBlockData>(); 1216 List<MapBlockData> mapBlocks = new List<MapBlockData>();
1220 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, 1217 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
1221 (int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize, 1218 (int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocX - 9),
1222 (int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize, 1219 (int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocX + 9),
1223 (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize, 1220 (int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocY - 9),
1224 (int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize); 1221 (int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocY + 9));
1225 List<AssetBase> textures = new List<AssetBase>(); 1222 List<AssetBase> textures = new List<AssetBase>();
1226 List<Image> bitImages = new List<Image>(); 1223 List<Image> bitImages = new List<Image>();
1227 1224
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 10421ff..5a7e2dd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1099,8 +1099,6 @@ namespace OpenSim.Region.Framework.Scenes
1099 /// <returns>True after all operations complete, throws exceptions otherwise.</returns> 1099 /// <returns>True after all operations complete, throws exceptions otherwise.</returns>
1100 public override void OtherRegionUp(GridRegion otherRegion) 1100 public override void OtherRegionUp(GridRegion otherRegion)
1101 { 1101 {
1102 // uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
1103 // uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
1104 uint xcell = Util.WorldToRegionLoc((uint)otherRegion.RegionLocX); 1102 uint xcell = Util.WorldToRegionLoc((uint)otherRegion.RegionLocX);
1105 uint ycell = Util.WorldToRegionLoc((uint)otherRegion.RegionLocY); 1103 uint ycell = Util.WorldToRegionLoc((uint)otherRegion.RegionLocY);
1106 1104
@@ -2450,9 +2448,9 @@ namespace OpenSim.Region.Framework.Scenes
2450 int xx = (int)Math.Floor(pos.X); 2448 int xx = (int)Math.Floor(pos.X);
2451 int yy = (int)Math.Floor(pos.Y); 2449 int yy = (int)Math.Floor(pos.Y);
2452 if (xx < 0 2450 if (xx < 0
2453 || xx > RegionInfo.RegionSizeX 2451 || xx >= RegionInfo.RegionSizeX
2454 || yy < 0 2452 || yy < 0
2455 || yy > RegionInfo.RegionSizeY) 2453 || yy >= RegionInfo.RegionSizeY)
2456 ret = false; 2454 ret = false;
2457 return ret; 2455 return ret;
2458 2456
@@ -4581,53 +4579,6 @@ namespace OpenSim.Region.Framework.Scenes
4581 ScenePresence sp = GetScenePresence(remoteClient.AgentId); 4579 ScenePresence sp = GetScenePresence(remoteClient.AgentId);
4582 if (sp != null) 4580 if (sp != null)
4583 { 4581 {
4584 /*
4585 uint regionX = RegionInfo.LegacyRegionLocX;
4586 uint regionY = RegionInfo.LegacyRegionLocY;
4587
4588 Util.RegionHandleToWorldLoc(regionHandle, out regionX, out regionY);
4589 Utils.LongToUInts(regionHandle, out regionX, out regionY);
4590
4591 int shiftx = (int) regionX - (int) RegionInfo.LegacyRegionLocX * (int)Constants.RegionSize;
4592 int shifty = (int) regionY - (int) RegionInfo.LegacyRegionLocY * (int)Constants.RegionSize;
4593 */
4594
4595 uint regionX, regionY;
4596 Util.RegionHandleToWorldLoc(regionHandle, out regionX, out regionY);
4597
4598 int shiftx = (int) regionX - (int)RegionInfo.WorldLocX;
4599 int shifty = (int) regionY - (int)RegionInfo.WorldLocY;
4600
4601 position.X += shiftx;
4602 position.Y += shifty;
4603
4604 bool result = false;
4605
4606 if (TestBorderCross(position,Cardinals.N))
4607 result = true;
4608
4609 if (TestBorderCross(position, Cardinals.S))
4610 result = true;
4611
4612 if (TestBorderCross(position, Cardinals.E))
4613 result = true;
4614
4615 if (TestBorderCross(position, Cardinals.W))
4616 result = true;
4617
4618 // bordercross if position is outside of region
4619
4620 if (!result)
4621 {
4622 regionHandle = RegionInfo.RegionHandle;
4623 }
4624 else
4625 {
4626 // not in this region, undo the shift!
4627 position.X -= shiftx;
4628 position.Y -= shifty;
4629 }
4630
4631 if (EntityTransferModule != null) 4582 if (EntityTransferModule != null)
4632 { 4583 {
4633 EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); 4584 EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index f95220d..b059ecf 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Region.Framework.Scenes
42{ 42{
43 public abstract class SceneBase : IScene 43 public abstract class SceneBase : IScene
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private static readonly string LogHeader = "[SCENE]"; 46 private static readonly string LogHeader = "[SCENE]";
47 47
48 #region Events 48 #region Events
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index d4cbf7d..44c476c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -331,7 +331,7 @@ namespace OpenSim.Region.Framework.Scenes
331 { 331 {
332 get 332 get
333 { 333 {
334 Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); 334 Vector3 minScale = new Vector3(Constants.MaximumRegionSize, Constants.MaximumRegionSize, Constants.MaximumRegionSize);
335 Vector3 maxScale = Vector3.Zero; 335 Vector3 maxScale = Vector3.Zero;
336 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); 336 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
337 337
@@ -517,14 +517,14 @@ namespace OpenSim.Region.Framework.Scenes
517 m_scene.CrossPrimGroupIntoNewRegion(val, this, true); 517 m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
518 518
519 // Normalize 519 // Normalize
520 if (val.X >= Constants.RegionSize) 520 if (val.X >= m_scene.RegionInfo.RegionSizeX)
521 val.X -= Constants.RegionSize; 521 val.X -= m_scene.RegionInfo.RegionSizeX;
522 if (val.Y >= Constants.RegionSize) 522 if (val.Y >= m_scene.RegionInfo.RegionSizeY)
523 val.Y -= Constants.RegionSize; 523 val.Y -= m_scene.RegionInfo.RegionSizeY;
524 if (val.X < 0) 524 if (val.X < 0)
525 val.X += Constants.RegionSize; 525 val.X += m_scene.RegionInfo.RegionSizeX;
526 if (val.Y < 0) 526 if (val.Y < 0)
527 val.Y += Constants.RegionSize; 527 val.Y += m_scene.RegionInfo.RegionSizeY;
528 528
529 // If it's deleted, crossing was successful 529 // If it's deleted, crossing was successful
530 if (IsDeleted) 530 if (IsDeleted)
@@ -572,9 +572,9 @@ namespace OpenSim.Region.Framework.Scenes
572 } 572 }
573 } 573 }
574 Vector3 oldp = AbsolutePosition; 574 Vector3 oldp = AbsolutePosition;
575 val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); 575 val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)m_scene.RegionInfo.RegionSizeX - 0.5f);
576 val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); 576 val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)m_scene.RegionInfo.RegionSizeY - 0.5f);
577 val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f); 577 val.Z = Util.Clamp<float>(oldp.Z, 0.5f, Constants.RegionHeight);
578 } 578 }
579 } 579 }
580 580
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index b3fdd22..c8320d0 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -516,7 +516,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
516 516
517 public Vector3 StartPos 517 public Vector3 StartPos
518 { 518 {
519 get { return new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 50); } 519 get { return new Vector3(m_scene.RegionInfo.RegionSizeX * 0.5f, m_scene.RegionInfo.RegionSizeY * 0.5f, 50f); }
520 set { } 520 set { }
521 } 521 }
522 522
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
index c5cba8e..f5bd44d 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
@@ -52,6 +52,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
52 52
53 // Local constants 53 // Local constants
54 54
55 // This computation is not the real region center if the region is larger than 256.
56 // This computation isn't fixed because there is not a handle back to the region.
55 private static readonly Vector3 CenterOfRegion = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 20); 57 private static readonly Vector3 CenterOfRegion = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 20);
56 private static readonly char[] CS_SPACE = { ' ' }; 58 private static readonly char[] CS_SPACE = { ' ' };
57 59
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs
index d4fe5e0..5505001 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs
@@ -44,6 +44,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
44 private static readonly ILog m_log = 44 private static readonly ILog m_log =
45 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 // This computation is not the real region center if the region is larger than 256.
48 // This computation isn't fixed because there is not a handle back to the region.
47 private static readonly OpenMetaverse.Vector3 CenterOfRegion = new OpenMetaverse.Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 20); 49 private static readonly OpenMetaverse.Vector3 CenterOfRegion = new OpenMetaverse.Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 20);
48 private const int DEBUG_CHANNEL = 2147483647; 50 private const int DEBUG_CHANNEL = 2147483647;
49 51
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
index 17ebed2..aca1ed4 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs
@@ -1311,7 +1311,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
1311 /* TODO */ 1311 /* TODO */
1312 ConfigurationParameters[] configparms = new ConfigurationParameters[1]; 1312 ConfigurationParameters[] configparms = new ConfigurationParameters[1];
1313 configparms[0] = parms; 1313 configparms[0] = parms;
1314 Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); 1314 Vector3 worldExtent = maxPosition;
1315 m_maxCollisions = maxCollisions; 1315 m_maxCollisions = maxCollisions;
1316 m_maxUpdatesPerFrame = maxUpdates; 1316 m_maxUpdatesPerFrame = maxUpdates;
1317 specialCollisionObjects = new Dictionary<uint, GhostObject>(); 1317 specialCollisionObjects = new Dictionary<uint, GhostObject>();
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 83ef1f6..fe014fc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -208,6 +208,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
208 Name = EngineType + "/" + RegionName; 208 Name = EngineType + "/" + RegionName;
209 } 209 }
210 210
211 // Old version of initialization that assumes legacy sized regions (256x256)
211 public override void Initialise(IMesher meshmerizer, IConfigSource config) 212 public override void Initialise(IMesher meshmerizer, IConfigSource config)
212 { 213 {
213 m_log.ErrorFormat("{0} WARNING WARNING WARNING! BulletSim initialized without region extent specification. Terrain will be messed up."); 214 m_log.ErrorFormat("{0} WARNING WARNING WARNING! BulletSim initialized without region extent specification. Terrain will be messed up.");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 6861865..674885c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -4333,7 +4333,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4333 m_host.AddScriptLPS(1); 4333 m_host.AddScriptLPS(1);
4334 UUID agentId = new UUID(); 4334 UUID agentId = new UUID();
4335 4335
4336 ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y); 4336 ulong regionHandle = Util.RegionWorldLocToHandle((uint)global_coords.x, (uint)global_coords.y);
4337 4337
4338 if (UUID.TryParse(agent, out agentId)) 4338 if (UUID.TryParse(agent, out agentId))
4339 { 4339 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 4fb0856..31ea067 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -814,8 +814,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
814 private void TeleportAgent(string agent, int regionX, int regionY, 814 private void TeleportAgent(string agent, int regionX, int regionY,
815 LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) 815 LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions)
816 { 816 {
817 // ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); 817 // ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize));
818 ulong regionHandle = Util.RegionWorldLocToHandle(Util.RegionToWorldLoc((uint)regionX), Util.RegionToWorldLoc((uint)regionY)); 818 ulong regionHandle = Util.RegionLocToHandle((uint)regionX, (uint)regionY);
819 819
820 m_host.AddScriptLPS(1); 820 m_host.AddScriptLPS(1);
821 UUID agentId = new UUID(); 821 UUID agentId = new UUID();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index e3f3fc7..d81cddc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -713,16 +713,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
713 } 713 }
714 private void Save() 714 private void Save()
715 { 715 {
716 /* Remove temporarily until we have a handle to the region size
716 if (Position.x > ((int)Constants.RegionSize - 1)) 717 if (Position.x > ((int)Constants.RegionSize - 1))
717 Position.x = ((int)Constants.RegionSize - 1); 718 Position.x = ((int)Constants.RegionSize - 1);
718 if (Position.x < 0)
719 Position.x = 0;
720 if (Position.y > ((int)Constants.RegionSize - 1)) 719 if (Position.y > ((int)Constants.RegionSize - 1))
721 Position.y = ((int)Constants.RegionSize - 1); 720 Position.y = ((int)Constants.RegionSize - 1);
722 if (Position.y < 0) 721 */
723 Position.y = 0;
724 if (Position.z > Constants.RegionHeight) 722 if (Position.z > Constants.RegionHeight)
725 Position.z = Constants.RegionHeight; 723 Position.z = Constants.RegionHeight;
724 if (Position.x < 0)
725 Position.x = 0;
726 if (Position.y < 0)
727 Position.y = 0;
726 if (Position.z < 0) 728 if (Position.z < 0)
727 Position.z = 0; 729 Position.z = 0;
728 prim.OSSL.llSetPos(Position); 730 prim.OSSL.llSetPos(Position);