From 5944d5e7f65a05596ca2b6005e59eea85e09e838 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 18 Feb 2008 18:22:50 +0000 Subject: * Fixed a land manager exception or two with Math.Max(255,Math.Min(0,val)) * Trapped a few more into little self contained boxes with padlocks on them. --- OpenSim/Region/Environment/LandManagement/Land.cs | 17 +++++-- .../Environment/LandManagement/LandManager.cs | 57 +++++++++++++++++++--- 2 files changed, 65 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index fec8899..58e40c2 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -47,6 +47,8 @@ namespace OpenSim.Region.Environment.LandManagement { #region Member Variables + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public LandData landData = new LandData(); public List primsOverMe = new List(); public Scene m_scene; @@ -282,11 +284,20 @@ namespace OpenSim.Region.Environment.LandManagement public void sendLandUpdateToAvatarsOverMe() { List avatars = m_scene.GetAvatars(); + Land over = null; for (int i = 0; i < avatars.Count; i++) { - Land over = - m_scene.LandManager.getLandObject((int) Math.Round(avatars[i].AbsolutePosition.X), - (int) Math.Round(avatars[i].AbsolutePosition.Y)); + try + { + over = + m_scene.LandManager.getLandObject((int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.X))), + (int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.Y)))); + } + catch (Exception) + { + m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + Math.Round(avatars[i].AbsolutePosition.Y)); + } + if (over != null) { if (over.landData.localID == landData.localID) diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index 47201f3..017fce8 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -310,7 +310,15 @@ namespace OpenSim.Region.Environment.LandManagement { //First, lets loop through the points and make sure they are all in the same peice of land //Get the land object at start - Land startLandObject = getLandObject(start_x, start_y); + Land startLandObject = null; + try + { + startLandObject = getLandObject(start_x, start_y); + } + catch (Exception) + { + m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + start_x + " y:" + start_y); + } if (startLandObject == null) return false; //No such land object at the beginning //Loop through the points @@ -386,7 +394,15 @@ namespace OpenSim.Region.Environment.LandManagement { for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4) { - Land p = getLandObject(stepXSelected, stepYSelected); + Land p = null; + try + { + p = getLandObject(stepXSelected, stepYSelected); + } + catch (Exception) + { + m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + stepXSelected + " y:" + stepYSelected); + } if (p != null) { if (!selectedLandObjects.Contains(p)) @@ -452,7 +468,18 @@ namespace OpenSim.Region.Environment.LandManagement for (x = 0; x < 64; x++) { byte tempByte = (byte) 0; //This represents the byte for the current 4x4 - Land currentParcelBlock = getLandObject(x*4, y*4); + Land currentParcelBlock = null; + + try + { + currentParcelBlock = getLandObject(x * 4, y * 4); + } + catch (Exception) + { + m_log.Warn("[LAND]: " + "unable to get land at x: " + (x * 4) + " y: " + (y * 4)); + } + + if (currentParcelBlock != null) { if (currentParcelBlock.landData.ownerID == remote_client.AgentId) @@ -545,7 +572,16 @@ namespace OpenSim.Region.Environment.LandManagement { for (y = 0; y < inc_y; y++) { - Land currentParcel = getLandObject(start_x + x, start_y + y); + + Land currentParcel = null; + try + { + getLandObject(start_x + x, start_y + y); + } + catch (Exception) + { + m_log.Warn("[LAND]: " + "unable to get land at x: " + (start_x + x) + " y: " + (start_y + y)); + } if (currentParcel != null) { if (!temp.Contains(currentParcel)) @@ -699,6 +735,7 @@ namespace OpenSim.Region.Environment.LandManagement { if (presence.UUID == avatar.AgentId) { + List checkLandParcels = parcelsNearPoint(presence.AbsolutePosition); foreach (Land checkBan in checkLandParcels) { @@ -720,8 +757,16 @@ namespace OpenSim.Region.Environment.LandManagement public void sendLandUpdate(ScenePresence avatar, bool force) { - Land 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)))); + Land over = null; + try + { + 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)))); + } + catch (Exception) + { + m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " + Math.Round(avatar.AbsolutePosition.Y)); + } if (over != null) { -- cgit v1.1