From c12e68e34d6f9340bbd17a2f183fe9859483cc6f Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 10 Nov 2013 19:52:31 -0800 Subject: 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. --- .../CoreModules/World/Land/LandManagementModule.cs | 26 +++++++++++++++------- .../Region/CoreModules/World/Land/LandObject.cs | 17 ++++++++++++-- 2 files changed, 33 insertions(+), 10 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 3f21f85..5b98d97 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,18 +823,28 @@ 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; if (x >= m_scene.RegionInfo.RegionSizeX || y >= m_scene.RegionInfo.RegionSizeY || x < 0 || y < 0) { // 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 0bde877..2a4d8d8 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++) -- cgit v1.1