From 2883656bbc9f16e19466403aef7735f907f6e1af Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 11 Jun 2008 19:45:17 +0000 Subject: For people receiving: Exception: System.ArgumentException: Value of -2147483648 is not valid for red, I've added the following message; [MAPIMAGE]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level And, I've also kept it from crashing... --- OpenSim/Region/Environment/Scenes/Scene.cs | 49 +++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index d5d8629..3c9f91b 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1012,6 +1012,7 @@ namespace OpenSim.Region.Environment.Scenes //Vector3 AXdirection = new Vector3(); //Ray testRay = new Ray(); //EntityIntersection rt = new EntityIntersection(); + bool terraincorruptedwarningsaid = false; float low = 255; float high = 0; @@ -1063,11 +1064,25 @@ namespace OpenSim.Region.Environment.Scenes if (heightvalue < 0) heightvalue = 0; + if (Single.IsInfinity(heightvalue) || Single.IsNaN(heightvalue)) + heightvalue = 0; + try + { + Color green = Color.FromArgb((int)heightvalue, 100, (int)heightvalue); - Color green = Color.FromArgb((int)heightvalue, 100, (int)heightvalue); - - // Y flip the cordinates - mapbmp.SetPixel(x, (256 - y) - 1, green); + // Y flip the cordinates + mapbmp.SetPixel(x, (256 - y) - 1, green); + } + catch (System.ArgumentException) + { + if (!terraincorruptedwarningsaid) + { + m_log.WarnFormat("[MAPIMAGE]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level",RegionInfo.RegionName); + terraincorruptedwarningsaid = true; + } + Color black = Color.Black; + mapbmp.SetPixel(x, (256 - y) - 1, black); + } } else { @@ -1086,13 +1101,31 @@ namespace OpenSim.Region.Environment.Scenes if (heightvalue < 0) heightvalue = 0; - Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255); - mapbmp.SetPixel(x, (256 - y) - 1, water); + if (Single.IsInfinity(heightvalue) || Single.IsNaN(heightvalue)) + heightvalue = 0; + + try + { + Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255); + mapbmp.SetPixel(x, (256 - y) - 1, water); + } + catch (System.ArgumentException) + { + if (!terraincorruptedwarningsaid) + { + m_log.WarnFormat("[MAPIMAGE]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", RegionInfo.RegionName); + terraincorruptedwarningsaid = true; + } + Color black = Color.Black; + mapbmp.SetPixel(x, (256 - y) - 1, black); + } } - //} + + } + //} - } + //tc = System.Environment.TickCount - tc; //m_log.Info("[MAPTILE]: Completed One row in " + tc + " ms"); } -- cgit v1.1