From 39a3784b43a891b307963e5545bcf731a54e01e0 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 24 Nov 2007 10:05:42 +0000 Subject: * Added some bounds checks to the sendLandUpdate packet to deal with agents coming in from foreign regions. * Updated bounds-check of getLandObject to check for >= 256 rather than > 256. --- OpenSim/Region/Environment/LandManagement/LandManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index dfeb36a..dd35a26 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -209,7 +209,7 @@ namespace OpenSim.Region.Environment.LandManagement int x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float)/Convert.ToDouble(4.0))); int y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float)/Convert.ToDouble(4.0))); - if (x > 63 || y > 63 || x < 0 || y < 0) + if (x >= 64 || y >= 64 || x < 0 || y < 0) { throw new Exception("Error: Parcel not found at point " + x + ", " + y); } @@ -222,7 +222,7 @@ namespace OpenSim.Region.Environment.LandManagement public Land getLandObject(int x, int y) { - if (x > 256 || y > 256 || x < 0 || y < 0) + if (x >= 256 || y >= 256 || x < 0 || y < 0) { throw new Exception("Error: Parcel not found at point " + x + ", " + y); } @@ -535,8 +535,8 @@ namespace OpenSim.Region.Environment.LandManagement public void sendLandUpdate(ScenePresence avatar) { - Land over = getLandObject((int) Math.Round(avatar.AbsolutePosition.X), - (int) Math.Round(avatar.AbsolutePosition.Y)); + 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)))); if (over != null) { -- cgit v1.1