diff options
author | Teravus Ovares (Dan Olivares) | 2009-08-07 20:31:48 -0400 |
---|---|---|
committer | Teravus Ovares (Dan Olivares) | 2009-08-07 20:31:48 -0400 |
commit | 2b990a61bfa88e13d5ad19602e6acef751ea473c (patch) | |
tree | d7cf9705923c940646e2db3af67bdb98944d9392 /OpenSim/Region/CoreModules/World | |
parent | * Remove hard coded 256 limitations from various places. There's no more 2... (diff) | |
download | opensim-SC_OLD-2b990a61bfa88e13d5ad19602e6acef751ea473c.zip opensim-SC_OLD-2b990a61bfa88e13d5ad19602e6acef751ea473c.tar.gz opensim-SC_OLD-2b990a61bfa88e13d5ad19602e6acef751ea473c.tar.bz2 opensim-SC_OLD-2b990a61bfa88e13d5ad19602e6acef751ea473c.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
6 files changed, 26 insertions, 24 deletions
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 | |||
317 | 317 | ||
318 | public void SendLandUpdate(ScenePresence avatar, bool force) | 318 | public void SendLandUpdate(ScenePresence avatar, bool force) |
319 | { | 319 | { |
320 | ILandObject over = GetLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), | 320 | ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), |
321 | (int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); | 321 | (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); |
322 | 322 | ||
323 | if (over != null) | 323 | if (over != null) |
324 | { | 324 | { |
@@ -849,10 +849,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
849 | byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET]; | 849 | byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET]; |
850 | int byteArrayCount = 0; | 850 | int byteArrayCount = 0; |
851 | int sequenceID = 0; | 851 | int sequenceID = 0; |
852 | int blockmeters = 4 * (int) Constants.RegionSize/(int)Constants.TerrainPatchSize; | ||
852 | 853 | ||
853 | for (int y = 0; y < 64; y++) | 854 | |
855 | for (int y = 0; y < blockmeters; y++) | ||
854 | { | 856 | { |
855 | for (int x = 0; x < 64; x++) | 857 | for (int x = 0; x < blockmeters; x++) |
856 | { | 858 | { |
857 | byte tempByte = 0; //This represents the byte for the current 4x4 | 859 | byte tempByte = 0; //This represents the byte for the current 4x4 |
858 | 860 | ||
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 | |||
305 | try | 305 | try |
306 | { | 306 | { |
307 | over = | 307 | over = |
308 | m_scene.LandChannel.GetLandObject(Util.Clamp<int>((int)Math.Round(avatars[i].AbsolutePosition.X), 0, 255), | 308 | m_scene.LandChannel.GetLandObject(Util.Clamp<int>((int)Math.Round(avatars[i].AbsolutePosition.X), 0, ((int)Constants.RegionSize - 1)), |
309 | Util.Clamp<int>((int)Math.Round(avatars[i].AbsolutePosition.Y), 0, 255)); | 309 | Util.Clamp<int>((int)Math.Round(avatars[i].AbsolutePosition.Y), 0, ((int)Constants.RegionSize - 1))); |
310 | } | 310 | } |
311 | catch (Exception) | 311 | catch (Exception) |
312 | { | 312 | { |
@@ -455,21 +455,21 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
455 | } | 455 | } |
456 | } | 456 | } |
457 | int tx = min_x * 4; | 457 | int tx = min_x * 4; |
458 | if (tx > 255) | 458 | if (tx > ((int)Constants.RegionSize - 1)) |
459 | tx = 255; | 459 | tx = ((int)Constants.RegionSize - 1); |
460 | int ty = min_y * 4; | 460 | int ty = min_y * 4; |
461 | if (ty > 255) | 461 | if (ty > ((int)Constants.RegionSize - 1)) |
462 | ty = 255; | 462 | ty = ((int)Constants.RegionSize - 1); |
463 | landData.AABBMin = | 463 | landData.AABBMin = |
464 | new Vector3((float) (min_x * 4), (float) (min_y * 4), | 464 | new Vector3((float) (min_x * 4), (float) (min_y * 4), |
465 | (float) m_scene.Heightmap[tx, ty]); | 465 | (float) m_scene.Heightmap[tx, ty]); |
466 | 466 | ||
467 | tx = max_x * 4; | 467 | tx = max_x * 4; |
468 | if (tx > 255) | 468 | if (tx > ((int)Constants.RegionSize - 1)) |
469 | tx = 255; | 469 | tx = ((int)Constants.RegionSize - 1); |
470 | ty = max_y * 4; | 470 | ty = max_y * 4; |
471 | if (ty > 255) | 471 | if (ty > ((int)Constants.RegionSize - 1)) |
472 | ty = 255; | 472 | ty = ((int)Constants.RegionSize - 1); |
473 | landData.AABBMax = | 473 | landData.AABBMax = |
474 | new Vector3((float) (max_x * 4), (float) (max_y * 4), | 474 | new Vector3((float) (max_x * 4), (float) (max_y * 4), |
475 | (float) m_scene.Heightmap[tx, ty]); | 475 | (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 | |||
1355 | float X = position.X; | 1355 | float X = position.X; |
1356 | float Y = position.Y; | 1356 | float Y = position.Y; |
1357 | 1357 | ||
1358 | if (X > 255) | 1358 | if (X > ((int)Constants.RegionSize - 1)) |
1359 | X = 255; | 1359 | X = ((int)Constants.RegionSize - 1); |
1360 | if (Y > 255) | 1360 | if (Y > ((int)Constants.RegionSize - 1)) |
1361 | Y = 255; | 1361 | Y = ((int)Constants.RegionSize - 1); |
1362 | if (X < 0) | 1362 | if (X < 0) |
1363 | X = 0; | 1363 | X = 0; |
1364 | if (Y < 0) | 1364 | 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 | |||
331 | int mapdrawendY = (int)(pos.Y + scale.Y); | 331 | int mapdrawendY = (int)(pos.Y + scale.Y); |
332 | 332 | ||
333 | // If object is beyond the edge of the map, don't draw it to avoid errors | 333 | // If object is beyond the edge of the map, don't draw it to avoid errors |
334 | if (mapdrawstartX < 0 || mapdrawstartX > 255 || mapdrawendX < 0 || mapdrawendX > 255 | 334 | if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1) |
335 | || mapdrawstartY < 0 || mapdrawstartY > 255 || mapdrawendY < 0 | 335 | || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0 |
336 | || mapdrawendY > 255) | 336 | || mapdrawendY > ((int)Constants.RegionSize - 1)) |
337 | continue; | 337 | continue; |
338 | 338 | ||
339 | #region obb face reconstruction part duex | 339 | #region obb face reconstruction part duex |
@@ -537,7 +537,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
537 | // float z = -point3d.z - topos.z; | 537 | // float z = -point3d.z - topos.z; |
538 | 538 | ||
539 | returnpt.X = (int)point3d.X;//(int)((topos.x - point3d.x) / z * d); | 539 | returnpt.X = (int)point3d.X;//(int)((topos.x - point3d.x) / z * d); |
540 | returnpt.Y = (int)(255 - point3d.Y);//(int)(255 - (((topos.y - point3d.y) / z * d))); | 540 | returnpt.Y = (int)(((int)Constants.RegionSize - 1) - point3d.Y);//(int)(255 - (((topos.y - point3d.y) / z * d))); |
541 | 541 | ||
542 | return returnpt; | 542 | return returnpt; |
543 | } | 543 | } |
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 | |||
107 | // . | 107 | // . |
108 | // | 108 | // |
109 | // Shade the terrain for shadows | 109 | // Shade the terrain for shadows |
110 | if (x < 255 && yr < 255) | 110 | if (x < ((int)Constants.RegionSize - 1) && yr < ((int)Constants.RegionSize - 1)) |
111 | { | 111 | { |
112 | float hfvalue = (float)hm[x, y]; | 112 | float hfvalue = (float)hm[x, y]; |
113 | float hfvaluecompare = 0f; | 113 | 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 | |||
266 | // the heigthfield might have some jumps in values. Rendered land is smooth, though, | 266 | // the heigthfield might have some jumps in values. Rendered land is smooth, though, |
267 | // as a slope is rendered at that place. So average 4 neighbour values to emulate that. | 267 | // as a slope is rendered at that place. So average 4 neighbour values to emulate that. |
268 | private float getHeight(double[,] hm, int x, int y) { | 268 | private float getHeight(double[,] hm, int x, int y) { |
269 | if (x < 255 && y < 255) | 269 | if (x < ((int)Constants.RegionSize - 1) && y < ((int)Constants.RegionSize - 1)) |
270 | return (float)(hm[x, y] * .444 + (hm[x + 1, y] + hm[x, y + 1]) * .222 + hm[x + 1, y +1] * .112); | 270 | return (float)(hm[x, y] * .444 + (hm[x + 1, y] + hm[x, y + 1]) * .222 + hm[x + 1, y +1] * .112); |
271 | else | 271 | else |
272 | return (float)hm[x, y]; | 272 | return (float)hm[x, y]; |