From c12e68e34d6f9340bbd17a2f183fe9859483cc6f Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 10 Nov 2013 19:52:31 -0800 Subject: [PATCH] varregion: fix GetLandObject error return and initialization of square land object bitmaps. This fixes creation of child presences and the editing of parcels. Also lots of commented out debugging messages. --- OpenSim/Framework/TerrainData.cs | 6 +++-- .../World/Land/LandManagementModule.cs | 26 +++++++++++++------ .../CoreModules/World/Land/LandObject.cs | 17 ++++++++++-- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs index 75446d137c..1c52a6962e 100644 --- a/OpenSim/Framework/TerrainData.cs +++ b/OpenSim/Framework/TerrainData.cs @@ -112,7 +112,7 @@ namespace OpenSim.Framework public class HeightmapTerrainData : TerrainData { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static string LogHeader = "[TERRAIN DATA]"; + private static string LogHeader = "[HEIGHTMAP TERRAIN DATA]"; // TerrainData.this[x, y] public override float this[int x, int y] @@ -124,7 +124,6 @@ namespace OpenSim.Framework { m_heightmap[x, y] = newVal; m_taint[x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize] = true; - // m_log.DebugFormat("{0} set[{1},{2}] to {3} ({4})", LogHeader, x, y, value, newVal); } } } @@ -258,6 +257,7 @@ namespace OpenSim.Framework } } + // m_log.DebugFormat("{0} new by doubles. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ); m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize]; ClearTaint(); @@ -272,6 +272,7 @@ namespace OpenSim.Framework m_compressionFactor = 100.0f; m_heightmap = new short[SizeX, SizeY]; m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize]; + // m_log.DebugFormat("{0} new by dimensions. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ); ClearTaint(); } @@ -282,6 +283,7 @@ namespace OpenSim.Framework for (int xx = 0; xx < SizeX; xx++) for (int yy = 0; yy < SizeY; yy++) m_heightmap[xx, yy] = cmap[ind++]; + // m_log.DebugFormat("{0} new by compressed map. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ); } // Create a heighmap from a database blob diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 3f21f85ddd..5b98d97c58 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -635,14 +635,14 @@ namespace OpenSim.Region.CoreModules.World.Land new_land.LandData.LocalID = newLandLocalID; bool[,] landBitmap = new_land.GetLandBitmap(); - m_log.DebugFormat("{0} AddLandObject. new_land.bitmapSize=({1},{2}). bitmap[600/4,600/4]={3}, newLocalID={4}", - LogHeader, landBitmap.GetLength(0), landBitmap.GetLength(1), landBitmap[600/4, 600/4], newLandLocalID); + // m_log.DebugFormat("{0} AddLandObject. new_land.bitmapSize=({1},{2}). newLocalID={3}", + // LogHeader, landBitmap.GetLength(0), landBitmap.GetLength(1), newLandLocalID); if (landBitmap.GetLength(0) != m_landIDList.GetLength(0) || landBitmap.GetLength(1) != m_landIDList.GetLength(1)) { // Going to variable sized regions can cause mismatches m_log.ErrorFormat("{0} AddLandObject. Added land bitmap different size than region ID map. bitmapSize=({1},{2}), landIDSize=({3},{4})", - LogHeader, landBitmap.GetLength(0), m_landIDList.GetLength(1), landBitmap.GetLength(0), m_landIDList.GetLength(1) ); + LogHeader, landBitmap.GetLength(0), landBitmap.GetLength(1), m_landIDList.GetLength(0), m_landIDList.GetLength(1) ); } else { @@ -769,7 +769,7 @@ namespace OpenSim.Region.CoreModules.World.Land /// Land object at the point supplied public ILandObject GetLandObject(float x_float, float y_float) { - return GetLandObject((int)x_float, (int)y_float); + return GetLandObject((int)x_float, (int)y_float, true /* returnNullIfLandObjectNotFound */); /* int x; int y; @@ -823,8 +823,15 @@ namespace OpenSim.Region.CoreModules.World.Land */ } - // Given a region position, return the parcel land object for that location + // Public entry. + // Throws exception if land object is not found public ILandObject GetLandObject(int x, int y) + { + return GetLandObject(x, y, false /* returnNullIfLandObjectNotFound */); + } + + // Given a region position, return the parcel land object for that location + private ILandObject GetLandObject(int x, int y, bool returnNullIfLandObjectNotFound) { ILandObject ret = null; @@ -832,9 +839,12 @@ namespace OpenSim.Region.CoreModules.World.Land { // These exceptions here will cause a lot of complaints from the users specifically because // they happen every time at border crossings - throw new Exception( - String.Format("{0} GetLandObject for non-existant position. Region={1}, pos=<{2},{3}", - LogHeader, m_scene.RegionInfo.RegionName, x, y) + if (returnNullIfLandObjectNotFound) + return null; + else + throw new Exception( + String.Format("{0} GetLandObject for non-existant position. Region={1}, pos=<{2},{3}", + LogHeader, m_scene.RegionInfo.RegionName, x, y) ); } diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 0bde877ea1..2a4d8d8fd7 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -102,6 +102,8 @@ namespace OpenSim.Region.CoreModules.World.Land } } + m_log.ErrorFormat("{0} StartPoint. No start point found. bitmapSize=<{1},{2}>", + LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1)); return new Vector3(-1, -1, -1); } } @@ -121,6 +123,8 @@ namespace OpenSim.Region.CoreModules.World.Land } } + m_log.ErrorFormat("{0} EndPoint. No end point found. bitmapSize=<{1},{2}>", + LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1)); return new Vector3(-1, -1, -1); } } @@ -757,6 +761,7 @@ namespace OpenSim.Region.CoreModules.World.Land public void SetLandBitmap(bool[,] bitmap) { LandBitmap = bitmap; + // m_log.DebugFormat("{0} SetLandBitmap. BitmapSize=<{1},{2}>", LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1)); ForceUpdateLandInfo(); } @@ -776,10 +781,14 @@ namespace OpenSim.Region.CoreModules.World.Land public bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y) { - bool[,] tempBitmap = new bool[(end_x-start_x)/landUnit,(end_y-start_y)/landUnit]; + // Empty bitmap for the whole region + bool[,] tempBitmap = new bool[m_scene.RegionInfo.RegionSizeX / landUnit, m_scene.RegionInfo.RegionSizeY / landUnit]; tempBitmap.Initialize(); + // Fill the bitmap square area specified by state and end tempBitmap = ModifyLandBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true); + // m_log.DebugFormat("{0} GetSquareLandBitmap. tempBitmapSize=<{1},{2}>", + // LogHeader, tempBitmap.GetLength(0), tempBitmap.GetLength(1)); return tempBitmap; } @@ -808,6 +817,8 @@ namespace OpenSim.Region.CoreModules.World.Land } } } + // m_log.DebugFormat("{0} ModifyLandBitmapSquare. startXY=<{1},{2}>, endXY=<{3},{4}>, val={5}, landBitmapSize=<{6},{7}>", + // LogHeader, start_x, start_y, end_x, end_y, set_value, land_bitmap.GetLength(0), land_bitmap.GetLength(1)); return land_bitmap; } @@ -868,6 +879,8 @@ namespace OpenSim.Region.CoreModules.World.Land } } } + // m_log.DebugFormat("{0} ConvertLandBitmapToBytes. BitmapSize=<{1},{2}>", + // LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1)); return tempConvertArr; } @@ -886,7 +899,7 @@ namespace OpenSim.Region.CoreModules.World.Land // and only set the lower area of the larger region. xLen = (int)(Constants.RegionSize / landUnit); } - m_log.DebugFormat("{0} ConvertBytesToLandBitmap: bitmapLen={1}, xLen={2}", LogHeader, bitmapLen, xLen); + // m_log.DebugFormat("{0} ConvertBytesToLandBitmap: bitmapLen={1}, xLen={2}", LogHeader, bitmapLen, xLen); int x = 0, y = 0; for (int i = 0; i < bitmapLen; i++)