From 2b990a61bfa88e13d5ad19602e6acef751ea473c Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 7 Aug 2009 20:31:48 -0400 Subject: This is the second part of the 'not crash on regionsize changes'. This lets you configure region sizes to be smaller without crashing the region. I remind you that regions are still square, must be a multiple of 4, and the Linden client doesn't like anything other then 256. If you set it bigger or smaller, the terrain doesn't load in the client, the map has issues, and god forbid you connect it to a grid that expects 256m regions. --- .../CoreModules/World/Land/LandManagementModule.cs | 10 ++++++---- OpenSim/Region/CoreModules/World/Land/LandObject.cs | 20 ++++++++++---------- .../World/Permissions/PermissionsModule.cs | 8 ++++---- .../CoreModules/World/WorldMap/MapImageModule.cs | 8 ++++---- .../World/WorldMap/ShadedMapTileRenderer.cs | 2 +- .../World/WorldMap/TexturedMapTileRenderer.cs | 2 +- 6 files changed, 26 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 4deb36e..097a62d 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -317,8 +317,8 @@ namespace OpenSim.Region.CoreModules.World.Land public void SendLandUpdate(ScenePresence avatar, bool force) { - ILandObject over = GetLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), - (int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); + ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), + (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); if (over != null) { @@ -849,10 +849,12 @@ namespace OpenSim.Region.CoreModules.World.Land byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET]; int byteArrayCount = 0; int sequenceID = 0; + int blockmeters = 4 * (int) Constants.RegionSize/(int)Constants.TerrainPatchSize; - for (int y = 0; y < 64; y++) + + for (int y = 0; y < blockmeters; y++) { - for (int x = 0; x < 64; x++) + for (int x = 0; x < blockmeters; x++) { byte tempByte = 0; //This represents the byte for the current 4x4 diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 715b48d..f41bdac 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -305,8 +305,8 @@ namespace OpenSim.Region.CoreModules.World.Land try { over = - m_scene.LandChannel.GetLandObject(Util.Clamp((int)Math.Round(avatars[i].AbsolutePosition.X), 0, 255), - Util.Clamp((int)Math.Round(avatars[i].AbsolutePosition.Y), 0, 255)); + m_scene.LandChannel.GetLandObject(Util.Clamp((int)Math.Round(avatars[i].AbsolutePosition.X), 0, ((int)Constants.RegionSize - 1)), + Util.Clamp((int)Math.Round(avatars[i].AbsolutePosition.Y), 0, ((int)Constants.RegionSize - 1))); } catch (Exception) { @@ -455,21 +455,21 @@ namespace OpenSim.Region.CoreModules.World.Land } } int tx = min_x * 4; - if (tx > 255) - tx = 255; + if (tx > ((int)Constants.RegionSize - 1)) + tx = ((int)Constants.RegionSize - 1); int ty = min_y * 4; - if (ty > 255) - ty = 255; + if (ty > ((int)Constants.RegionSize - 1)) + ty = ((int)Constants.RegionSize - 1); landData.AABBMin = new Vector3((float) (min_x * 4), (float) (min_y * 4), (float) m_scene.Heightmap[tx, ty]); tx = max_x * 4; - if (tx > 255) - tx = 255; + if (tx > ((int)Constants.RegionSize - 1)) + tx = ((int)Constants.RegionSize - 1); ty = max_y * 4; - if (ty > 255) - ty = 255; + if (ty > ((int)Constants.RegionSize - 1)) + ty = ((int)Constants.RegionSize - 1); landData.AABBMax = new Vector3((float) (max_x * 4), (float) (max_y * 4), (float) m_scene.Heightmap[tx, ty]); diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index a4793e6..6db9cbf 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -1355,10 +1355,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions float X = position.X; float Y = position.Y; - if (X > 255) - X = 255; - if (Y > 255) - Y = 255; + if (X > ((int)Constants.RegionSize - 1)) + X = ((int)Constants.RegionSize - 1); + if (Y > ((int)Constants.RegionSize - 1)) + Y = ((int)Constants.RegionSize - 1); if (X < 0) X = 0; if (Y < 0) diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs index d1d3045..5fd8369 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs @@ -331,9 +331,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap int mapdrawendY = (int)(pos.Y + scale.Y); // If object is beyond the edge of the map, don't draw it to avoid errors - if (mapdrawstartX < 0 || mapdrawstartX > 255 || mapdrawendX < 0 || mapdrawendX > 255 - || mapdrawstartY < 0 || mapdrawstartY > 255 || mapdrawendY < 0 - || mapdrawendY > 255) + if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1) + || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0 + || mapdrawendY > ((int)Constants.RegionSize - 1)) continue; #region obb face reconstruction part duex @@ -537,7 +537,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // float z = -point3d.z - topos.z; returnpt.X = (int)point3d.X;//(int)((topos.x - point3d.x) / z * d); - returnpt.Y = (int)(255 - point3d.Y);//(int)(255 - (((topos.y - point3d.y) / z * d))); + returnpt.Y = (int)(((int)Constants.RegionSize - 1) - point3d.Y);//(int)(255 - (((topos.y - point3d.y) / z * d))); return returnpt; } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs index f39cf68..a297cf3 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs @@ -107,7 +107,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // . // // Shade the terrain for shadows - if (x < 255 && yr < 255) + if (x < ((int)Constants.RegionSize - 1) && yr < ((int)Constants.RegionSize - 1)) { float hfvalue = (float)hm[x, y]; float hfvaluecompare = 0f; diff --git a/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs index 97ee451..4ecad74 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs @@ -266,7 +266,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // the heigthfield might have some jumps in values. Rendered land is smooth, though, // as a slope is rendered at that place. So average 4 neighbour values to emulate that. private float getHeight(double[,] hm, int x, int y) { - if (x < 255 && y < 255) + if (x < ((int)Constants.RegionSize - 1) && y < ((int)Constants.RegionSize - 1)) return (float)(hm[x, y] * .444 + (hm[x + 1, y] + hm[x, y + 1]) * .222 + hm[x + 1, y +1] * .112); else return (float)hm[x, y]; -- cgit v1.1