aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2015-03-29 14:25:12 -0700
committerRobert Adams2015-03-29 14:25:12 -0700
commit07dead7dcb8b0f2a27a50748e4a460d9669903fc (patch)
treeb61c3d892e83d36fece40e7735c5d97e64b9020f /OpenSim/Region
parentvarregion: add varregion and TerrainData use in LLClientView. (diff)
downloadopensim-SC_OLD-07dead7dcb8b0f2a27a50748e4a460d9669903fc.zip
opensim-SC_OLD-07dead7dcb8b0f2a27a50748e4a460d9669903fc.tar.gz
opensim-SC_OLD-07dead7dcb8b0f2a27a50748e4a460d9669903fc.tar.bz2
opensim-SC_OLD-07dead7dcb8b0f2a27a50748e4a460d9669903fc.tar.xz
varregion: any conversions of use of Constants.RegionSize converted into
Util.cs routines to convert region coords to and from world coords or handles.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs9
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs35
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs32
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs33
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs25
-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
-rw-r--r--OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs5
-rw-r--r--OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs4
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs17
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs14
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs9
-rw-r--r--OpenSim/Region/RegionCombinerModule/RegionConnections.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs17
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs10
35 files changed, 186 insertions, 139 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index dcfc630..9d70063 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -213,8 +213,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
213 IScene scene = c.Scene; 213 IScene scene = c.Scene;
214 UUID destination = c.Destination; 214 UUID destination = c.Destination;
215 Vector3 fromPos = c.Position; 215 Vector3 fromPos = c.Position;
216 Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, 216 Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);
217 scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
218 217
219 bool checkParcelHide = false; 218 bool checkParcelHide = false;
220 UUID sourceParcelID = UUID.Zero; 219 UUID sourceParcelID = UUID.Zero;
@@ -424,8 +423,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
424 { 423 {
425 Vector3 fromRegionPos = fromPos + regionPos; 424 Vector3 fromRegionPos = fromPos + regionPos;
426 Vector3 toRegionPos = presence.AbsolutePosition + 425 Vector3 toRegionPos = presence.AbsolutePosition +
427 new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize, 426 new Vector3(presence.Scene.RegionInfo.WorldLocX, presence.Scene.RegionInfo.WorldLocY, 0);
428 presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
429 427
430 int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); 428 int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);
431 429
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index db8405b..7177d9b 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -663,8 +663,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
663 663
664 Vector3 avaPos = p.AbsolutePosition; 664 Vector3 avaPos = p.AbsolutePosition;
665 // Getting the global position for the Avatar 665 // Getting the global position for the Avatar
666 Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.RegionLocX*Constants.RegionSize + avaPos.X, 666 Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.WorldLocX + avaPos.X,
667 remoteClient.Scene.RegionInfo.RegionLocY*Constants.RegionSize + avaPos.Y, 667 remoteClient.Scene.RegionInfo.WorldLocY + avaPos.Y,
668 avaPos.Z); 668 avaPos.Z);
669 669
670 string landOwnerName = string.Empty; 670 string landOwnerName = string.Empty;
@@ -1353,4 +1353,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
1353 } 1353 }
1354 #endregion Web Util 1354 #endregion Web Util
1355 } 1355 }
1356} \ No newline at end of file 1356}
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
index 6e0fd03..f615c6b 100644
--- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
@@ -317,9 +317,7 @@ namespace OpenSim.Region.CoreModules.Framework
317 foreach (KeyValuePair<ulong, string> kvp in m_childrenSeeds[agentID]) 317 foreach (KeyValuePair<ulong, string> kvp in m_childrenSeeds[agentID])
318 { 318 {
319 uint x, y; 319 uint x, y;
320 Utils.LongToUInts(kvp.Key, out x, out y); 320 Util.RegionHandleToRegionLoc(kvp.Key, out x, out y);
321 x = x / Constants.RegionSize;
322 y = y / Constants.RegionSize;
323 m_log.Info(" >> "+x+", "+y+": "+kvp.Value); 321 m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
324 } 322 }
325 } 323 }
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 809027f..c81e5aa 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -587,8 +587,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
587 Util.RegionHandleToRegionLoc(regionHandle, out regX, out regY); 587 Util.RegionHandleToRegionLoc(regionHandle, out regX, out regY);
588 588
589 MapBlockData block = new MapBlockData(); 589 MapBlockData block = new MapBlockData();
590 block.X = (ushort)(regX / Constants.RegionSize); 590 block.X = (ushort)(regX);
591 block.Y = (ushort)(regY / Constants.RegionSize); 591 block.Y = (ushort)(regY);
592 block.Access = (byte)SimAccess.Down; // == not there 592 block.Access = (byte)SimAccess.Down; // == not there
593 593
594 List<MapBlockData> blocks = new List<MapBlockData>(); 594 List<MapBlockData> blocks = new List<MapBlockData>();
diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
index d943b20..4e7ad75 100644
--- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
@@ -213,8 +213,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
213 if (part != null) 213 if (part != null)
214 { 214 {
215 ObjectRegionName = s.RegionInfo.RegionName; 215 ObjectRegionName = s.RegionInfo.RegionName;
216 uint localX = (s.RegionInfo.RegionLocX * (int)Constants.RegionSize); 216 uint localX = s.RegionInfo.WorldLocX;
217 uint localY = (s.RegionInfo.RegionLocY * (int)Constants.RegionSize); 217 uint localY = s.RegionInfo.WorldLocY;
218 ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")"; 218 ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")";
219 return part; 219 return part;
220 } 220 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index 31ef79b..8ccad39 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -268,11 +268,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
268 caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key); 268 caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key);
269 List<GridRegion> regions = kvp.Value.GetNeighbours(); 269 List<GridRegion> regions = kvp.Value.GetNeighbours();
270 foreach (GridRegion r in regions) 270 foreach (GridRegion r in regions)
271 caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); 271 caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY));
272 } 272 }
273 } 273 }
274 274
275 MainConsole.Instance.Output(caps.ToString()); 275 MainConsole.Instance.Output(caps.ToString());
276 } 276 }
277 } 277 }
278} \ No newline at end of file 278}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
index 9172536..ae76288 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
66 return; 66 return;
67 67
68 m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", 68 m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}",
69 m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX / Constants.RegionSize, otherRegion.RegionLocY / Constants.RegionSize); 69 m_scene.RegionInfo.RegionName, otherRegion.RegionName, Util.WorldToRegionLoc((uint)otherRegion.RegionLocX), Util.WorldToRegionLoc((uint)otherRegion.RegionLocY));
70 70
71 m_neighbours[otherRegion.RegionHandle] = otherRegion; 71 m_neighbours[otherRegion.RegionHandle] = otherRegion;
72 } 72 }
@@ -82,11 +82,16 @@ 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 (in meters).
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.
88 // The snapping is technically unnecessary but is harmless because regions are always
89 // multiples of the legacy region size (256).
85 public GridRegion GetRegionByPosition(int x, int y) 90 public GridRegion GetRegionByPosition(int x, int y)
86 { 91 {
87 uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize; 92 uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize;
88 uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize; 93 uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize;
89 ulong handle = Utils.UIntsToLong(xsnap, ysnap); 94 ulong handle = Util.RegionWorldLocToHandle(xsnap, ysnap);
90 95
91 if (m_neighbours.ContainsKey(handle)) 96 if (m_neighbours.ContainsKey(handle))
92 return m_neighbours[handle]; 97 return m_neighbours[handle];
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
index 4338133..6a49ca7 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -141,7 +141,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
141 Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null"); 141 Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null");
142 Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match"); 142 Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match");
143 143
144 result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize); 144 result = m_LocalConnector.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000));
145 Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null"); 145 Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null");
146 Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match"); 146 Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match");
147 147
@@ -197,4 +197,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
197 Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected"); 197 Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected");
198 } 198 }
199 } 199 }
200} \ No newline at end of file 200}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
index fd89428..bda354f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
@@ -125,14 +125,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
125 public OpenSim.Services.Interfaces.GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) 125 public OpenSim.Services.Interfaces.GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
126 { 126 {
127 uint x, y; 127 uint x, y;
128 Utils.LongToUInts(regionHandle, out x, out y); 128 Util.RegionHandleToRegionLoc(regionHandle, out x, out y);
129 129
130 foreach (Scene s in m_Scenes) 130 foreach (Scene s in m_Scenes)
131 { 131 {
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, x, 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 7a844f4..cd95ee9 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/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index d4e4c25..014c845 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/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 616fe98..928755d 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -1571,10 +1571,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1571 float X = position.X; 1571 float X = position.X;
1572 float Y = position.Y; 1572 float Y = position.Y;
1573 1573
1574 if (X > ((int)Constants.RegionSize - 1)) 1574 if (X > ((int)m_scene.RegionInfo.RegionSizeX - 1))
1575 X = ((int)Constants.RegionSize - 1); 1575 X = ((int)m_scene.RegionInfo.RegionSizeX - 1);
1576 if (Y > ((int)Constants.RegionSize - 1)) 1576 if (Y > ((int)m_scene.RegionInfo.RegionSizeY - 1))
1577 Y = ((int)Constants.RegionSize - 1); 1577 Y = ((int)m_scene.RegionInfo.RegionSizeY - 1);
1578 if (X < 0) 1578 if (X < 0)
1579 X = 0; 1579 X = 0;
1580 if (Y < 0) 1580 if (Y < 0)
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs
index 7186dd7..80396c4 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
42 for (y = 0; y < map.Height; y++) 42 for (y = 0; y < map.Height; y++)
43 { 43 {
44 map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; 44 map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10;
45 double spherFac = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2, Constants.RegionSize / 2, 50) * 0.01; 45 double spherFac = TerrainUtil.SphericalFactor(x, y, map.Width / 2, map.Height / 2, 50) * 0.01;
46 if (map[x, y] < spherFac) 46 if (map[x, y] < spherFac)
47 { 47 {
48 map[x, y] = spherFac; 48 map[x, y] = spherFac;
@@ -53,4 +53,4 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
53 53
54 #endregion 54 #endregion
55 } 55 }
56} \ No newline at end of file 56}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs
index b5c7d33..a7e4d9f 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs
@@ -154,10 +154,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
154 154
155 public ITerrainChannel LoadStream(Stream s) 155 public ITerrainChannel LoadStream(Stream s)
156 { 156 {
157 157 // Set to default size
158 int w = (int)Constants.RegionSize; 158 int w = (int)Constants.RegionSize;
159 int h = (int)Constants.RegionSize; 159 int h = (int)Constants.RegionSize;
160 160
161 // create a dummy channel (in case data is bad)
161 TerrainChannel retval = new TerrainChannel(w, h); 162 TerrainChannel retval = new TerrainChannel(w, h);
162 163
163 BinaryReader bs = new BinaryReader(s); 164 BinaryReader bs = new BinaryReader(s);
@@ -165,8 +166,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
165 bool eof = false; 166 bool eof = false;
166 if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") 167 if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ")
167 { 168 {
168// int fileWidth = w;
169// int fileHeight = h;
170 169
171 // Terragen file 170 // Terragen file
172 while (eof == false) 171 while (eof == false)
@@ -175,31 +174,29 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
175 switch (tmp) 174 switch (tmp)
176 { 175 {
177 case "SIZE": 176 case "SIZE":
178// int sztmp = bs.ReadInt16() + 1; 177 w = bs.ReadInt16() + 1;
179// fileWidth = sztmp; 178 h = w;
180// fileHeight = sztmp;
181 bs.ReadInt16();
182 bs.ReadInt16(); 179 bs.ReadInt16();
183 break; 180 break;
184 case "XPTS": 181 case "XPTS":
185// fileWidth = bs.ReadInt16(); 182 w = bs.ReadInt16();
186 bs.ReadInt16();
187 bs.ReadInt16(); 183 bs.ReadInt16();
188 break; 184 break;
189 case "YPTS": 185 case "YPTS":
190// fileHeight = bs.ReadInt16(); 186 h = bs.ReadInt16();
191 bs.ReadInt16();
192 bs.ReadInt16(); 187 bs.ReadInt16();
193 break; 188 break;
194 case "ALTW": 189 case "ALTW":
195 eof = true; 190 eof = true;
196 Int16 heightScale = bs.ReadInt16(); 191 // create new channel of proper size (now that we know it)
197 Int16 baseHeight = bs.ReadInt16(); 192 retval = new TerrainChannel(w, h);
193 double heightScale = (double)bs.ReadInt16() / 65536.0;
194 double baseHeight = (double)bs.ReadInt16();
198 for (int y = 0; y < h; y++) 195 for (int y = 0; y < h; y++)
199 { 196 {
200 for (int x = 0; x < w; x++) 197 for (int x = 0; x < w; x++)
201 { 198 {
202 retval[x, y] = baseHeight + bs.ReadInt16() * (double)heightScale / 65536.0; 199 retval[x, y] = baseHeight + (double)bs.ReadInt16() * heightScale;
203 } 200 }
204 } 201 }
205 break; 202 break;
@@ -257,17 +254,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
257 bs.Write(enc.GetBytes("TERRAGENTERRAIN ")); 254 bs.Write(enc.GetBytes("TERRAGENTERRAIN "));
258 255
259 bs.Write(enc.GetBytes("SIZE")); 256 bs.Write(enc.GetBytes("SIZE"));
260 bs.Write(Convert.ToInt16(Constants.RegionSize)); 257 bs.Write(Convert.ToInt16(map.Width));
261 bs.Write(Convert.ToInt16(0)); // necessary padding 258 bs.Write(Convert.ToInt16(0)); // necessary padding
262 259
263 //The XPTS and YPTS chunks are not needed for square regions 260 //The XPTS and YPTS chunks are not needed for square regions
264 //but L3DT won't load the terrain file properly without them. 261 //but L3DT won't load the terrain file properly without them.
265 bs.Write(enc.GetBytes("XPTS")); 262 bs.Write(enc.GetBytes("XPTS"));
266 bs.Write(Convert.ToInt16(Constants.RegionSize)); 263 bs.Write(Convert.ToInt16(map.Width));
267 bs.Write(Convert.ToInt16(0)); // necessary padding 264 bs.Write(Convert.ToInt16(0)); // necessary padding
268 265
269 bs.Write(enc.GetBytes("YPTS")); 266 bs.Write(enc.GetBytes("YPTS"));
270 bs.Write(Convert.ToInt16(Constants.RegionSize)); 267 bs.Write(Convert.ToInt16(map.Height));
271 bs.Write(Convert.ToInt16(0)); // necessary padding 268 bs.Write(Convert.ToInt16(0)); // necessary padding
272 269
273 bs.Write(enc.GetBytes("SCAL")); 270 bs.Write(enc.GetBytes("SCAL"));
@@ -283,11 +280,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
283 bs.Write(Convert.ToInt16(horizontalScale)); // range between max and min 280 bs.Write(Convert.ToInt16(horizontalScale)); // range between max and min
284 bs.Write(Convert.ToInt16(baseHeight)); // base height or mid point 281 bs.Write(Convert.ToInt16(baseHeight)); // base height or mid point
285 282
283 double factor = 65536.0 / horizontalScale; // avoid computing this on each iteration
284
286 for (int y = 0; y < map.Height; y++) 285 for (int y = 0; y < map.Height; y++)
287 { 286 {
288 for (int x = 0; x < map.Width; x++) 287 for (int x = 0; x < map.Width; x++)
289 { 288 {
290 float elevation = (float)((map[x,y] - baseHeight) * 65536 ) / (float)horizontalScale; // see LoadStream for inverse 289 float elevation = (float)((map[x,y] - baseHeight) * factor); // see LoadStream for inverse
291 290
292 // clamp rounding issues 291 // clamp rounding issues
293 if (elevation > Int16.MaxValue) 292 if (elevation > Int16.MaxValue)
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
index 630473e..d3e2533 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 }
@@ -55,4 +55,4 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
55 55
56 #endregion 56 #endregion
57 } 57 }
58} \ No newline at end of file 58}
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/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
index be719ea..062d7ff 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
@@ -40,10 +40,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
40 [Test] 40 [Test]
41 public void BrushTest() 41 public void BrushTest()
42 { 42 {
43 int midRegion = (int)Constants.RegionSize / 2;
44
45 // Create a mask that covers only the left half of the region
43 bool[,] allowMask = new bool[(int)Constants.RegionSize, 256]; 46 bool[,] allowMask = new bool[(int)Constants.RegionSize, 256];
44 int x; 47 int x;
45 int y; 48 int y;
46 for (x = 0; x < (int)((int)Constants.RegionSize * 0.5f); x++) 49 for (x = 0; x < midRegion; x++)
47 { 50 {
48 for (y = 0; y < (int)Constants.RegionSize; y++) 51 for (y = 0; y < (int)Constants.RegionSize; y++)
49 { 52 {
@@ -57,13 +60,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
57 TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); 60 TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
58 ITerrainPaintableEffect effect = new RaiseSphere(); 61 ITerrainPaintableEffect effect = new RaiseSphere();
59 62
60 effect.PaintEffect(map, allowMask, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, -1.0, 2, 0.1); 63 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
61 Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (127,128)."); 64 Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128).");
62 Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (124,128)."); 65 Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128).");
63 Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (123,128)."); 66 Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128).");
64 Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (128,128)."); 67 Assert.That(map[128, midRegion] == 0.0, "Raise brush should not change value at this point (128,128).");
65 Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (0,128)."); 68 Assert.That(map[0, midRegion] == 0.0, "Raise brush should not change value at this point (0,128).");
66
67 // 69 //
68 // Test LowerSphere 70 // Test LowerSphere
69 // 71 //
@@ -77,13 +79,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
77 } 79 }
78 effect = new LowerSphere(); 80 effect = new LowerSphere();
79 81
80 effect.PaintEffect(map, allowMask, ((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), -1.0, 2, 6.0); 82 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
81 Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128)."); 83 Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
82 Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128)."); 84 Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
83 Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] < 1.0, "Lower brush should lowering value at this point (124,128)."); 85 Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128).");
84 Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (123,128)."); 86 Assert.That(map[120, midRegion] == 1.0, "Lower brush should not change value at this point (120,128).");
85 Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (128,128)."); 87 Assert.That(map[128, midRegion] == 1.0, "Lower brush should not change value at this point (128,128).");
86 Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (0,128)."); 88 Assert.That(map[0, midRegion] == 1.0, "Lower brush should not change value at this point (0,128).");
87 } 89 }
88 90
89 [Test] 91 [Test]
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index b45cc4d..4ab5a4a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -2221,14 +2221,9 @@ namespace OpenSim.Region.Framework.Scenes
2221 itemID = UUID.Zero; 2221 itemID = UUID.Zero;
2222 if (grp != null) 2222 if (grp != null)
2223 { 2223 {
2224 Vector3 inventoryStoredPosition = new Vector3 2224 Vector3 inventoryStoredPosition = new Vector3(
2225 (((grp.AbsolutePosition.X > (int)Constants.RegionSize) 2225 Math.Min(grp.AbsolutePosition.X, RegionInfo.RegionSizeX - 6),
2226 ? 250 2226 Math.Min(grp.AbsolutePosition.Y, RegionInfo.RegionSizeY - 6),
2227 : grp.AbsolutePosition.X)
2228 ,
2229 (grp.AbsolutePosition.X > (int)Constants.RegionSize)
2230 ? 250
2231 : grp.AbsolutePosition.X,
2232 grp.AbsolutePosition.Z); 2227 grp.AbsolutePosition.Z);
2233 2228
2234 Vector3 originalPosition = grp.AbsolutePosition; 2229 Vector3 originalPosition = grp.AbsolutePosition;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index f5458c1..46c9048 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -6,7 +6,7 @@
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyrightD 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
@@ -103,7 +103,29 @@ namespace OpenSim.Region.Framework.Scenes
103 /// <summary> 103 /// <summary>
104 /// If false then physical objects are disabled, though collisions will continue as normal. 104 /// If false then physical objects are disabled, though collisions will continue as normal.
105 /// </summary> 105 /// </summary>
106 public bool PhysicsEnabled { get; set; } 106 public bool PhysicsEnabled
107 {
108 get
109 {
110 return m_physicsEnabled;
111 }
112
113 set
114 {
115 m_physicsEnabled = value;
116
117 if (PhysicsScene != null)
118 {
119 IPhysicsParameters physScene = PhysicsScene as IPhysicsParameters;
120
121 if (physScene != null)
122 physScene.SetPhysicsParameter(
123 "Active", m_physicsEnabled.ToString(), PhysParameterEntry.APPLY_TO_NONE);
124 }
125 }
126 }
127
128 private bool m_physicsEnabled;
107 129
108 /// <summary> 130 /// <summary>
109 /// If false then scripts are not enabled on the smiulator 131 /// If false then scripts are not enabled on the smiulator
@@ -199,15 +221,16 @@ namespace OpenSim.Region.Framework.Scenes
199 /// </summary> 221 /// </summary>
200 public int m_linksetCapacity = 0; 222 public int m_linksetCapacity = 0;
201 223
224 public bool m_clampPrimSize;
225 public bool m_trustBinaries;
226 public bool m_allowScriptCrossings = true;
227
202 /// <summary> 228 /// <summary>
203 /// Max prims an Physical object will hold 229 /// Max prims an Physical object will hold
204 /// </summary> 230 /// </summary>
205 /// 231 ///
206 public int m_linksetPhysCapacity = 0; 232 public int m_linksetPhysCapacity = 0;
207 233
208 public bool m_clampPrimSize;
209 public bool m_trustBinaries;
210 public bool m_allowScriptCrossings;
211 public bool m_useFlySlow; 234 public bool m_useFlySlow;
212 public bool m_useTrashOnDelete = true; 235 public bool m_useTrashOnDelete = true;
213 236
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 52f46f2..a2625c4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -52,6 +52,7 @@ namespace OpenSim.Region.Framework.Scenes
52 public class SceneCommunicationService //one instance per region 52 public class SceneCommunicationService //one instance per region
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 private static string LogHeader = "[SCENE COMMUNICATION SERVICE]";
55 56
56 protected RegionInfo m_regionInfo; 57 protected RegionInfo m_regionInfo;
57 protected Scene m_scene; 58 protected Scene m_scene;
@@ -100,7 +101,7 @@ namespace OpenSim.Region.Framework.Scenes
100 { 101 {
101 m_log.WarnFormat( 102 m_log.WarnFormat(
102 "[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.", 103 "[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.",
103 m_scene.Name, x / Constants.RegionSize, y / Constants.RegionSize); 104 m_scene.Name, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
104 } 105 }
105 } 106 }
106 107
@@ -166,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes
166 // we only want to send one update to each simulator; the simulator will 167 // we only want to send one update to each simulator; the simulator will
167 // hand it off to the regions where a child agent exists, this does assume 168 // hand it off to the regions where a child agent exists, this does assume
168 // that the region position is cached or performance will degrade 169 // that the region position is cached or performance will degrade
169 Utils.LongToUInts(regionHandle, out x, out y); 170 Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
170 GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); 171 GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
171 if (dest == null) 172 if (dest == null)
172 continue; 173 continue;
@@ -206,7 +207,7 @@ namespace OpenSim.Region.Framework.Scenes
206 207
207 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); 208 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
208 uint x = 0, y = 0; 209 uint x = 0, y = 0;
209 Utils.LongToUInts(regionHandle, out x, out y); 210 Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
210 211
211 GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); 212 GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y);
212 213
@@ -226,6 +227,8 @@ namespace OpenSim.Region.Framework.Scenes
226 { 227 {
227 foreach (ulong handle in regionslst) 228 foreach (ulong handle in regionslst)
228 { 229 {
230 // We must take a copy here since handle acts like a reference when used in an iterator.
231 // This leads to race conditions if directly passed to SendCloseChildAgent with more than one neighbour region.
229 ulong handleCopy = handle; 232 ulong handleCopy = handle;
230 Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy, auth_code); }); 233 Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy, auth_code); });
231 } 234 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index a99e469..cb2f377 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -412,7 +412,7 @@ namespace OpenSim.Region.Framework.Scenes
412 { 412 {
413 get 413 get
414 { 414 {
415 Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); 415 Vector3 minScale = new Vector3(Constants.MaximumRegionSize, Constants.MaximumRegionSize, Constants.MaximumRegionSize);
416 Vector3 maxScale = Vector3.Zero; 416 Vector3 maxScale = Vector3.Zero;
417 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); 417 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
418 418
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 2965903..82508ad 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -842,9 +842,8 @@ namespace OpenSim.Region.Framework.Scenes
842 foreach (ulong handle in seeds.Keys) 842 foreach (ulong handle in seeds.Keys)
843 { 843 {
844 uint x, y; 844 uint x, y;
845 Utils.LongToUInts(handle, out x, out y); 845 Util.RegionHandleToRegionLoc(handle, out x, out y);
846 x = x / Constants.RegionSize; 846
847 y = y / Constants.RegionSize;
848 if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) 847 if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY))
849 { 848 {
850 old.Add(handle); 849 old.Add(handle);
@@ -866,9 +865,7 @@ namespace OpenSim.Region.Framework.Scenes
866 foreach (KeyValuePair<ulong, string> kvp in KnownRegions) 865 foreach (KeyValuePair<ulong, string> kvp in KnownRegions)
867 { 866 {
868 uint x, y; 867 uint x, y;
869 Utils.LongToUInts(kvp.Key, out x, out y); 868 Util.RegionHandleToRegionLoc(kvp.Key, out x, out y);
870 x = x / Constants.RegionSize;
871 y = y / Constants.RegionSize;
872 m_log.Info(" >> "+x+", "+y+": "+kvp.Value); 869 m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
873 } 870 }
874 } 871 }
@@ -1189,7 +1186,7 @@ namespace OpenSim.Region.Framework.Scenes
1189 1186
1190 float posZLimit = 0; 1187 float posZLimit = 0;
1191 1188
1192 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) 1189 if (pos.X < m_scene.RegionInfo.RegionSizeX && pos.Y < m_scene.RegionInfo.RegionSizeY)
1193 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 1190 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
1194 1191
1195 float newPosZ = posZLimit + localAVHeight / 2; 1192 float newPosZ = posZLimit + localAVHeight / 2;
@@ -2595,7 +2592,7 @@ namespace OpenSim.Region.Framework.Scenes
2595 if (regionCombinerModule != null) 2592 if (regionCombinerModule != null)
2596 regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); 2593 regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID);
2597 else 2594 else
2598 regionSize = new Vector2(Constants.RegionSize); 2595 regionSize = new Vector2(m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY);
2599 2596
2600 if (pos.X < 0 || pos.X >= regionSize.X 2597 if (pos.X < 0 || pos.X >= regionSize.X
2601 || pos.Y < 0 || pos.Y >= regionSize.Y 2598 || pos.Y < 0 || pos.Y >= regionSize.Y
@@ -2613,8 +2610,8 @@ namespace OpenSim.Region.Framework.Scenes
2613// } 2610// }
2614 2611
2615 // Get terrain height for sub-region in a megaregion if necessary 2612 // Get terrain height for sub-region in a megaregion if necessary
2616 int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); 2613 int X = (int)((m_scene.RegionInfo.WorldLocX) + pos.X);
2617 int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); 2614 int Y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y);
2618 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); 2615 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y);
2619 // If X and Y is NaN, target_region will be null 2616 // If X and Y is NaN, target_region will be null
2620 if (target_region == null) 2617 if (target_region == null)
@@ -2625,7 +2622,7 @@ namespace OpenSim.Region.Framework.Scenes
2625 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) 2622 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene))
2626 targetScene = m_scene; 2623 targetScene = m_scene;
2627 2624
2628 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % Constants.RegionSize), (int)(pos.Y % Constants.RegionSize)]; 2625 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)];
2629 // dont try to land underground 2626 // dont try to land underground
2630 terrainHeight += Appearance.AvatarHeight / 2; 2627 terrainHeight += Appearance.AvatarHeight / 2;
2631 pos.Z = Math.Max(terrainHeight, pos.Z); 2628 pos.Z = Math.Max(terrainHeight, pos.Z);
@@ -3941,7 +3938,7 @@ namespace OpenSim.Region.Framework.Scenes
3941 3938
3942 // Put the child agent back at the center 3939 // Put the child agent back at the center
3943 AbsolutePosition 3940 AbsolutePosition
3944 = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); 3941 = new Vector3(((float)m_scene.RegionInfo.RegionSizeX * 0.5f), ((float)m_scene.RegionInfo.RegionSizeY * 0.5f), 70);
3945 3942
3946 Animator.ResetAnimations(); 3943 Animator.ResetAnimations();
3947 } 3944 }
@@ -3968,9 +3965,7 @@ namespace OpenSim.Region.Framework.Scenes
3968 if (handle != Scene.RegionInfo.RegionHandle) 3965 if (handle != Scene.RegionInfo.RegionHandle)
3969 { 3966 {
3970 uint x, y; 3967 uint x, y;
3971 Utils.LongToUInts(handle, out x, out y); 3968 Util.RegionHandleToRegionLoc(handle, out x, out y);
3972 x = x / Constants.RegionSize;
3973 y = y / Constants.RegionSize;
3974 3969
3975// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); 3970// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
3976// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); 3971// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index ed1503c..3750494 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -518,7 +518,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
518 518
519 public Vector3 StartPos 519 public Vector3 StartPos
520 { 520 {
521 get { return new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 50); } 521 get { return new Vector3(m_scene.RegionInfo.RegionSizeX * 0.5f, m_scene.RegionInfo.RegionSizeY * 0.5f, 50f); }
522 set { } 522 set { }
523 } 523 }
524 524
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/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
index a375da9..0bf23f1 100644
--- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
+++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
@@ -122,8 +122,8 @@ namespace OpenSim.Region.OptionalModules
122 122
123 private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) 123 private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene)
124 { 124 {
125 if (newPoint.X < -1f || newPoint.X > (float)(Constants.RegionSize + 1) || 125 if (newPoint.X < -1f || newPoint.X > (scene.RegionInfo.RegionSizeX + 1) ||
126 newPoint.Y < -1f || newPoint.Y > (float)(Constants.RegionSize + 1)) 126 newPoint.Y < -1f || newPoint.Y > (scene.RegionInfo.RegionSizeY) )
127 return true; 127 return true;
128 128
129 SceneObjectPart obj = scene.GetSceneObjectPart(objectID); 129 SceneObjectPart obj = scene.GetSceneObjectPart(objectID);
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index eb386fe..296ab87 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -170,7 +170,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
170 c.Channel = m_channelNotify; 170 c.Channel = m_channelNotify;
171 c.Message += numScriptsFailed.ToString() + "," + message; 171 c.Message += numScriptsFailed.ToString() + "," + message;
172 c.Type = ChatTypeEnum.Region; 172 c.Type = ChatTypeEnum.Region;
173 c.Position = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 30); 173 if (m_scene != null)
174 c.Position = new Vector3((m_scene.RegionInfo.RegionSizeX * 0.5f), (m_scene.RegionInfo.RegionSizeY * 0.5f), 30);
175 else
176 c.Position = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 30);
174 c.Sender = null; 177 c.Sender = null;
175 c.SenderUUID = UUID.Zero; 178 c.SenderUUID = UUID.Zero;
176 c.Scene = m_scene; 179 c.Scene = m_scene;
diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
index 8144870..e4a3382 100644
--- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
+++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
@@ -748,8 +748,8 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
748 position.X = s_tree.AbsolutePosition.X + (float)randX; 748 position.X = s_tree.AbsolutePosition.X + (float)randX;
749 position.Y = s_tree.AbsolutePosition.Y + (float)randY; 749 position.Y = s_tree.AbsolutePosition.Y + (float)randY;
750 750
751 if (position.X <= ((int)Constants.RegionSize - 1) && position.X >= 0 && 751 if (position.X <= (m_scene.RegionInfo.RegionSizeX - 1) && position.X >= 0 &&
752 position.Y <= ((int)Constants.RegionSize - 1) && position.Y >= 0 && 752 position.Y <= (m_scene.RegionInfo.RegionSizeY - 1) && position.Y >= 0 &&
753 Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range) 753 Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range)
754 { 754 {
755 UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner; 755 UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
index 0816b7b..8e40561 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
@@ -46,6 +46,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
46 private List<BasicActor> _actors = new List<BasicActor>(); 46 private List<BasicActor> _actors = new List<BasicActor>();
47 private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>(); 47 private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>();
48 private float[] _heightMap; 48 private float[] _heightMap;
49 private Vector3 m_regionExtent;
49 50
50 //protected internal string sceneIdentifier; 51 //protected internal string sceneIdentifier;
51 52
@@ -58,6 +59,12 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
58 59
59 public override void Initialise(IMesher meshmerizer, IConfigSource config) 60 public override void Initialise(IMesher meshmerizer, IConfigSource config)
60 { 61 {
62 throw new Exception("Should not be called.");
63 }
64
65 public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent)
66 {
67 m_regionExtent = regionExtent;
61 } 68 }
62 69
63 public override void Dispose() {} 70 public override void Dispose() {}
@@ -121,23 +128,23 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
121 { 128 {
122 actorPosition.Y = 0.1F; 129 actorPosition.Y = 0.1F;
123 } 130 }
124 else if (actor.Position.Y >= Constants.RegionSize) 131 else if (actor.Position.Y >= m_regionExtent.Y)
125 { 132 {
126 actorPosition.Y = ((int)Constants.RegionSize - 0.1f); 133 actorPosition.Y = (m_regionExtent.Y - 0.1f);
127 } 134 }
128 135
129 if (actor.Position.X < 0) 136 if (actor.Position.X < 0)
130 { 137 {
131 actorPosition.X = 0.1F; 138 actorPosition.X = 0.1F;
132 } 139 }
133 else if (actor.Position.X >= Constants.RegionSize) 140 else if (actor.Position.X >= m_regionExtent.X)
134 { 141 {
135 actorPosition.X = ((int)Constants.RegionSize - 0.1f); 142 actorPosition.X = (m_regionExtent.X - 0.1f);
136 } 143 }
137 144
138 float terrainHeight = 0; 145 float terrainHeight = 0;
139 if (_heightMap != null) 146 if (_heightMap != null)
140 terrainHeight = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X]; 147 terrainHeight = _heightMap[(int)actor.Position.Y * (int)m_regionExtent.Y + (int)actor.Position.X];
141 148
142 float height = terrainHeight + actor.Size.Z; 149 float height = terrainHeight + actor.Size.Z;
143 150
diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
index 8ccfda5..d14edfd 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
@@ -32,6 +32,7 @@ using System.Reflection;
32using Nini.Config; 32using Nini.Config;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenMetaverse;
35 36
36namespace OpenSim.Region.Physics.Manager 37namespace OpenSim.Region.Physics.Manager
37{ 38{
@@ -59,6 +60,14 @@ namespace OpenSim.Region.Physics.Manager
59 m_log.Info("[PHYSICS]: Added meshing engine: " + plugHard.GetName()); 60 m_log.Info("[PHYSICS]: Added meshing engine: " + plugHard.GetName());
60 } 61 }
61 62
63 // Legacy method for simulators before extent was passed
64 public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName,
65 IConfigSource config, string regionName)
66 {
67 Vector3 extent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
68 return GetPhysicsScene(physEngineName, meshEngineName, config, regionName, extent);
69 }
70
62 /// <summary> 71 /// <summary>
63 /// Get a physics scene for the given physics engine and mesher. 72 /// Get a physics scene for the given physics engine and mesher.
64 /// </summary> 73 /// </summary>
@@ -66,7 +75,8 @@ namespace OpenSim.Region.Physics.Manager
66 /// <param name="meshEngineName"></param> 75 /// <param name="meshEngineName"></param>
67 /// <param name="config"></param> 76 /// <param name="config"></param>
68 /// <returns></returns> 77 /// <returns></returns>
69 public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName, IConfigSource config, string regionName) 78 public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName,
79 IConfigSource config, string regionName, Vector3 regionExtent)
70 { 80 {
71 if (String.IsNullOrEmpty(physEngineName)) 81 if (String.IsNullOrEmpty(physEngineName))
72 { 82 {
@@ -94,7 +104,7 @@ namespace OpenSim.Region.Physics.Manager
94 { 104 {
95 m_log.Info("[PHYSICS]: creating " + physEngineName); 105 m_log.Info("[PHYSICS]: creating " + physEngineName);
96 PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName); 106 PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName);
97 result.Initialise(meshEngine, config); 107 result.Initialise(meshEngine, config, regionExtent);
98 return result; 108 return result;
99 } 109 }
100 else 110 else
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index dd9bbc1..4f4ff07 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -132,8 +132,17 @@ namespace OpenSim.Region.Physics.Manager
132 } 132 }
133 } 133 }
134 134
135 // Deprecated. Do not use this for new physics engines.
135 public abstract void Initialise(IMesher meshmerizer, IConfigSource config); 136 public abstract void Initialise(IMesher meshmerizer, IConfigSource config);
136 137
138 // For older physics engines that do not implement non-legacy region sizes.
139 // If the physics engine handles the region extent feature, it overrides this function.
140 public virtual void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent)
141 {
142 // If not overridden, call the old initialization entry.
143 Initialise(meshmerizer, config);
144 }
145
137 /// <summary> 146 /// <summary>
138 /// Add an avatar 147 /// Add an avatar
139 /// </summary> 148 /// </summary>
diff --git a/OpenSim/Region/RegionCombinerModule/RegionConnections.cs b/OpenSim/Region/RegionCombinerModule/RegionConnections.cs
index fba51d2..6bf1c4a 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionConnections.cs
+++ b/OpenSim/Region/RegionCombinerModule/RegionConnections.cs
@@ -64,12 +64,12 @@ namespace OpenSim.Region.RegionCombinerModule
64 /// <summary> 64 /// <summary>
65 /// The X meters position of this connection. 65 /// The X meters position of this connection.
66 /// </summary> 66 /// </summary>
67 public uint PosX { get { return X * Constants.RegionSize; } } 67 public uint PosX { get { return Util.RegionToWorldLoc(X); } }
68 68
69 /// <summary> 69 /// <summary>
70 /// The Y meters co-ordinate of this connection. 70 /// The Y meters co-ordinate of this connection.
71 /// </summary> 71 /// </summary>
72 public uint PosY { get { return Y * Constants.RegionSize; } } 72 public uint PosY { get { return Util.RegionToWorldLoc(Y); } }
73 73
74 /// <summary> 74 /// <summary>
75 /// The size of the megaregion in meters. 75 /// The size of the megaregion in meters.
@@ -91,4 +91,4 @@ namespace OpenSim.Region.RegionCombinerModule
91 YEnd = (uint)extents.Y; 91 YEnd = (uint)extents.Y;
92 } 92 }
93 } 93 }
94} \ No newline at end of file 94}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index a5d8292..7d5c750 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2351,7 +2351,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2351 // 2351 //
2352 // This workaround is to prevent silent failure of this function. 2352 // This workaround is to prevent silent failure of this function.
2353 // According to the specification on the SL Wiki, providing a position outside of the 2353 // According to the specification on the SL Wiki, providing a position outside of the
2354 if (pos.x < 0 || pos.x > Constants.RegionSize || pos.y < 0 || pos.y > Constants.RegionSize) 2354 if (pos.x < 0 || pos.x > World.RegionInfo.RegionSizeX || pos.y < 0 || pos.y > World.RegionInfo.RegionSizeY)
2355 { 2355 {
2356 return 0; 2356 return 0;
2357 } 2357 }
@@ -2361,9 +2361,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2361 m_host.ParentGroup.IsAttachment || // return FALSE if attachment 2361 m_host.ParentGroup.IsAttachment || // return FALSE if attachment
2362 ( 2362 (
2363 pos.x < -10.0 || // return FALSE if more than 10 meters into a west-adjacent region. 2363 pos.x < -10.0 || // return FALSE if more than 10 meters into a west-adjacent region.
2364 pos.x > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a east-adjacent region. 2364 pos.x > (World.RegionInfo.RegionSizeX + 10) || // return FALSE if more than 10 meters into a east-adjacent region.
2365 pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region. 2365 pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region.
2366 pos.y > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a north-adjacent region. 2366 pos.y > (World.RegionInfo.RegionSizeY + 10) || // return FALSE if more than 10 meters into a north-adjacent region.
2367 pos.z > Constants.RegionHeight // return FALSE if altitude than 4096m 2367 pos.z > Constants.RegionHeight // return FALSE if altitude than 4096m
2368 ) 2368 )
2369 ) 2369 )
@@ -4654,10 +4654,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4654 DataserverPlugin.RegisterRequest(m_host.LocalId, 4654 DataserverPlugin.RegisterRequest(m_host.LocalId,
4655 m_item.ItemID, item.AssetID.ToString()); 4655 m_item.ItemID, item.AssetID.ToString());
4656 4656
4657 Vector3 region = new Vector3( 4657 Vector3 region = new Vector3(World.RegionInfo.WorldLocX, World.RegionInfo.WorldLocY, 0);
4658 World.RegionInfo.RegionLocX * Constants.RegionSize,
4659 World.RegionInfo.RegionLocY * Constants.RegionSize,
4660 0);
4661 4658
4662 World.AssetService.Get(item.AssetID.ToString(), this, 4659 World.AssetService.Get(item.AssetID.ToString(), this,
4663 delegate(string i, object sender, AssetBase a) 4660 delegate(string i, object sender, AssetBase a)
@@ -5948,7 +5945,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5948 public LSL_Vector llGetRegionCorner() 5945 public LSL_Vector llGetRegionCorner()
5949 { 5946 {
5950 m_host.AddScriptLPS(1); 5947 m_host.AddScriptLPS(1);
5951 return new LSL_Vector(World.RegionInfo.RegionLocX * Constants.RegionSize, World.RegionInfo.RegionLocY * Constants.RegionSize, 0); 5948 return new LSL_Vector(World.RegionInfo.WorldLocX, World.RegionInfo.WorldLocY, 0);
5952 } 5949 }
5953 5950
5954 /// <summary> 5951 /// <summary>
@@ -6103,7 +6100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6103 LSL_Float mag; 6100 LSL_Float mag;
6104 if (dir.x > 0) 6101 if (dir.x > 0)
6105 { 6102 {
6106 mag = (Constants.RegionSize - pos.x) / dir.x; 6103 mag = (World.RegionInfo.RegionSizeX - pos.x) / dir.x;
6107 } 6104 }
6108 else 6105 else
6109 { 6106 {
@@ -6114,7 +6111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6114 6111
6115 edge.y = pos.y + (dir.y * mag); 6112 edge.y = pos.y + (dir.y * mag);
6116 6113
6117 if (edge.y > Constants.RegionSize || edge.y < 0) 6114 if (edge.y > World.RegionInfo.RegionSizeY || edge.y < 0)
6118 { 6115 {
6119 // Y goes out of bounds first 6116 // Y goes out of bounds first
6120 edge.y = dir.y / Math.Abs(dir.y); 6117 edge.y = dir.y / Math.Abs(dir.y);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index d2a5980..01d90e7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -459,7 +459,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
459 { 459 {
460 m_host.AddScriptLPS(1); 460 m_host.AddScriptLPS(1);
461 461
462 if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0) 462 if (x > (World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0)
463 OSSLError("osSetTerrainHeight: Coordinate out of bounds"); 463 OSSLError("osSetTerrainHeight: Coordinate out of bounds");
464 464
465 if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0))) 465 if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0)))
@@ -489,7 +489,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
489 private LSL_Float GetTerrainHeight(int x, int y) 489 private LSL_Float GetTerrainHeight(int x, int y)
490 { 490 {
491 m_host.AddScriptLPS(1); 491 m_host.AddScriptLPS(1);
492 if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0) 492 if (x > (World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0)
493 OSSLError("osGetTerrainHeight: Coordinate out of bounds"); 493 OSSLError("osGetTerrainHeight: Coordinate out of bounds");
494 494
495 return World.Heightmap[x, y]; 495 return World.Heightmap[x, y];
@@ -823,7 +823,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
823 private void TeleportAgent(string agent, int regionX, int regionY, 823 private void TeleportAgent(string agent, int regionX, int regionY,
824 LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) 824 LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions)
825 { 825 {
826 ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); 826 ulong regionHandle = Util.RegionLocToHandle((uint)regionX, (uint)regionY);
827 827
828 m_host.AddScriptLPS(1); 828 m_host.AddScriptLPS(1);
829 UUID agentId = new UUID(); 829 UUID agentId = new UUID();
@@ -3024,7 +3024,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3024 } 3024 }
3025 else 3025 else
3026 { 3026 {
3027 return new LSL_Vector((float)Constants.RegionSize, (float)Constants.RegionSize, Constants.RegionHeight); 3027 return new LSL_Vector((float)World.RegionInfo.RegionSizeX,
3028 (float)World.RegionInfo.RegionSizeY,
3029 (float)World.RegionInfo.RegionSizeZ );
3028 } 3030 }
3029 } 3031 }
3030 3032
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 9cf7b35..8666421 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -708,18 +708,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
708 } 708 }
709 private void Save() 709 private void Save()
710 { 710 {
711 /* Remove temporarily until we have a handle to the region size
711 if (Position.x > ((int)Constants.RegionSize - 1)) 712 if (Position.x > ((int)Constants.RegionSize - 1))
712 Position.x = ((int)Constants.RegionSize - 1); 713 Position.x = ((int)Constants.RegionSize - 1);
713 if (Position.x < 0)
714 Position.x = 0;
715 if (Position.y > ((int)Constants.RegionSize - 1)) 714 if (Position.y > ((int)Constants.RegionSize - 1))
716 Position.y = ((int)Constants.RegionSize - 1); 715 Position.y = ((int)Constants.RegionSize - 1);
716 */
717 if (Position.x < 0)
718 Position.x = 0;
717 if (Position.y < 0) 719 if (Position.y < 0)
718 Position.y = 0; 720 Position.y = 0;
719 if (Position.z > 768)
720 Position.z = 768;
721 if (Position.z < 0) 721 if (Position.z < 0)
722 Position.z = 0; 722 Position.z = 0;
723 if (Position.z > Constants.RegionHeight)
724 Position.z = Constants.RegionHeight;
723 prim.OSSL.llSetPos(Position); 725 prim.OSSL.llSetPos(Position);
724 } 726 }
725 727