Browse Source

Merge branch 'master' into varregion

Conflicts:
	OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
	OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
	OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
Robert Adams 10 years ago
parent
commit
13a9d5409c

+ 39 - 38
OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs

@@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
     public struct DrawStruct
     {
         public DrawRoutine dr;
-        public Rectangle rect;
+//        public Rectangle rect;
         public SolidBrush brush;
         public face[] trns;
     }
@@ -120,6 +120,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
             {
                 mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID);
             }
+
             return mapbmp;
         }
 
@@ -128,7 +129,10 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
             try
             {
                 using (Bitmap mapbmp = CreateMapTile())
-                    return OpenJPEG.EncodeFromImage(mapbmp, true);
+                {
+                    if (mapbmp != null)
+                        return OpenJPEG.EncodeFromImage(mapbmp, true);
+                }
             }
             catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
             {
@@ -278,12 +282,11 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
             tc = Environment.TickCount;
             m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile");
             EntityBase[] objs = whichScene.GetEntities();
-            Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
-            //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>();
             List<float> z_sortheights = new List<float>();
             List<uint> z_localIDs = new List<uint>();
+            Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
 
-            try
+            try 
             {
                 lock (objs)
                 {
@@ -294,7 +297,6 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
                         {
                             SceneObjectGroup mapdot = (SceneObjectGroup)obj;
                             Color mapdotspot = Color.Gray; // Default color when prim color is white
-
                             // Loop over prim in group
                             foreach (SceneObjectPart part in mapdot.Parts)
                             {
@@ -547,27 +549,25 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
                                         z_localIDs.Add(part.LocalId);
                                         z_sortheights.Add(pos.Z);
 
-                                        //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
-                                        //{
-                                        //for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
-                                        //{
-                                        //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy);
-                                        //try
-                                        //{
-                                        // Remember, flip the y!
-                                        //    mapbmp.SetPixel(wx, (255 - wy), mapdotspot);
-                                        //}
-                                        //catch (ArgumentException)
-                                        //{
-                                        //    breakYN = true;
-                                        //}
-
-                                        //if (breakYN)
-                                        //    break;
-                                        //}
-
-                                        //if (breakYN)
-                                        //    break;
+                                        for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
+                                        // {
+                                        //     for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
+                                        //     {
+                                        //         m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy);
+                                        //         try
+                                        //         {
+                                        //             // Remember, flip the y!
+                                        //             mapbmp.SetPixel(wx, (255 - wy), mapdotspot);
+                                        //         }
+                                        //         catch (ArgumentException)
+                                        //         {
+                                        //             breakYN = true;
+                                        //         }
+                                        //     }
+                                        //     if (breakYN)
+                                        //         break;
+                                        //     }
+                                        // }
                                         //}
                                     } // Object is within 256m Z of terrain
                                 } // object is at least a meter wide
@@ -581,21 +581,23 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
                     // Sort prim by Z position
                     Array.Sort(sortedZHeights, sortedlocalIds);
 
-                    Graphics g = Graphics.FromImage(mapbmp);
-
-                    for (int s = 0; s < sortedZHeights.Length; s++)
+                    using (Graphics g = Graphics.FromImage(mapbmp))
                     {
-                        if (z_sort.ContainsKey(sortedlocalIds[s]))
+                        for (int s = 0; s < sortedZHeights.Length; s++)
                         {
-                            DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]];
-                            for (int r = 0; r < rectDrawStruct.trns.Length; r++)
+                            if (z_sort.ContainsKey(sortedlocalIds[s]))
                             {
-                                g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts);
+                                DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]];
+                                for (int r = 0; r < rectDrawStruct.trns.Length; r++)
+                                {
+                                    g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts);
+                                }
+                                //g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect);
                             }
-                            //g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect);
                         }
                     }
-                }   // lock(objs)
+                } // lock entities objs
+
             }
             finally
             {
@@ -603,9 +605,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
                     ds.brush.Dispose();
             }
 
-            g.Dispose();
-
             m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms");
+
             return mapbmp;
         }
 

+ 4 - 3
OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs

@@ -207,7 +207,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
                         {
                             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", m_scene.RegionInfo.RegionName);
+                                m_log.WarnFormat("[SHADED MAP TILE RENDERER]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName);
                                 terraincorruptedwarningsaid = true;
                             }
                             color = Color.Black;
@@ -237,7 +237,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
                         {
                             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", m_scene.RegionInfo.RegionName);
+                                m_log.WarnFormat("[SHADED MAP TILE RENDERER]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName);
                                 terraincorruptedwarningsaid = true;
                             }
                             Color black = Color.Black;
@@ -246,7 +246,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
                     }
                 }
             }
-            m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
+
+            m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
         }
     }
 }

+ 10 - 5
OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs

@@ -232,10 +232,14 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
             if (textureID == UUID.Zero) return defaultColor; // not set
             if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures
 
-            Bitmap bmp = fetchTexture(textureID);
-            Color color = bmp == null ? defaultColor : computeAverageColor(bmp);
-            // store it for future reference
-            m_mapping[textureID] = color;
+            Color color;
+
+            using (Bitmap bmp = fetchTexture(textureID))
+            {
+                color = bmp == null ? defaultColor : computeAverageColor(bmp);
+                // store it for future reference
+                m_mapping[textureID] = color;
+            }
 
             return color;
         }
@@ -417,7 +421,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
                     }
                 }
             }
-            m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
+
+            m_log.Debug("[TEXTURED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
         }
     }
 }

+ 64 - 42
OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs

@@ -114,6 +114,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
                     "export-map [<path>]",
                     "Save an image of the world map", HandleExportWorldMapConsoleCommand);
 
+                m_scene.AddCommand(
+                    "Regions", this, "generate map",
+                    "generate map",
+                    "Generates and stores a new maptile.", HandleGenerateMapConsoleCommand);
+
                 AddHandlers();
             }
         }
@@ -1271,6 +1276,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
                 m_scene.RegionInfo.RegionName, exportPath);
         }
 
+        public void HandleGenerateMapConsoleCommand(string module, string[] cmdparams)
+        {
+            Scene consoleScene = m_scene.ConsoleScene();
+
+            if (consoleScene != null && consoleScene != m_scene)
+                return;
+
+            GenerateMaptile();
+        }
+
         public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
         {
             uint xstart = 0;
@@ -1502,62 +1517,69 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
 
         private Byte[] GenerateOverlay()
         {
-            Bitmap overlay = new Bitmap(256, 256);
-
-            bool[,] saleBitmap = new bool[64, 64];
-            for (int x = 0 ; x < 64 ; x++)
+            using (Bitmap overlay = new Bitmap(256, 256))
             {
-                for (int y = 0 ; y < 64 ; y++)
-                    saleBitmap[x, y] = false;
-            }
-
-            bool landForSale = false;
+                bool[,] saleBitmap = new bool[64, 64];
+                for (int x = 0 ; x < 64 ; x++)
+                {
+                    for (int y = 0 ; y < 64 ; y++)
+                        saleBitmap[x, y] = false;
+                }
 
-            List<ILandObject> parcels = m_scene.LandChannel.AllParcels();
+                bool landForSale = false;
 
-            Color background = Color.FromArgb(0, 0, 0, 0);
-            SolidBrush transparent = new SolidBrush(background);
-            Graphics g = Graphics.FromImage(overlay);
-            g.FillRectangle(transparent, 0, 0, 256, 256);
+                List<ILandObject> parcels = m_scene.LandChannel.AllParcels();
 
-            SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9));
+                Color background = Color.FromArgb(0, 0, 0, 0);
 
-            foreach (ILandObject land in parcels)
-            {
-                // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
-                if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
+                using (Graphics g = Graphics.FromImage(overlay))
                 {
-                    landForSale = true;
+                    using (SolidBrush transparent = new SolidBrush(background))
+                        g.FillRectangle(transparent, 0, 0, 256, 256);
 
-                    saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap());
-                }
-            }
 
-            if (!landForSale)
-            {
-                m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName);
-                return null;
-            }
+                    foreach (ILandObject land in parcels)
+                    {
+                        // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
+                        if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
+                        {
+                            landForSale = true;
+
+                            saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap());
+                        }
+                    }
+
+                    if (!landForSale)
+                    {
+                        m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName);
+                        return null;
+                    }
 
-            m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
+                    m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
 
-            for (int x = 0 ; x < 64 ; x++)
-            {
-                for (int y = 0 ; y < 64 ; y++)
+                    using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)))
+                    {
+                        for (int x = 0 ; x < 64 ; x++)
+                        {
+                            for (int y = 0 ; y < 64 ; y++)
+                            {
+                                if (saleBitmap[x, y])
+                                    g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4);
+                            }
+                        }
+                    }
+                }
+
+                try
                 {
-                    if (saleBitmap[x, y])
-                        g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4);
+                    return OpenJPEG.EncodeFromImage(overlay, true);
+                }
+                catch (Exception e)
+                {
+                    m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
                 }
             }
 
-            try
-            {
-                return OpenJPEG.EncodeFromImage(overlay, true);
-            }
-            catch (Exception e)
-            {
-                m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
-            }
             return null;
         }
     }

+ 19 - 21
OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs

@@ -304,7 +304,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
         private string GetImageQueuesReport(string[] showParams)
         {
             if (showParams.Length < 5 || showParams.Length > 6)
-                return "Usage: image queues show <first-name> <last-name> [full]";
+                return "Usage: show image queues <first-name> <last-name> [full]";
 
             string firstName = showParams[3];
             string lastName = showParams[4];
@@ -395,7 +395,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
             report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding));
             
             report.AppendFormat(
-                "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7} {12,7}\n",
+                "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n",
                 "Since",
                 "Pkts",
                 "Pkts",
@@ -407,12 +407,11 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
                 "Q Pkts",
                 "Q Pkts",
                 "Q Pkts",
-                "Q Pkts",
                 "Q Pkts");
     
             report.AppendFormat("{0,-" + totalInfoFieldsLength +  "}", "");
             report.AppendFormat(
-                "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7} {12,7}\n",
+                "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n",
                 "Last In",
                 "In",
                 "Out",
@@ -424,8 +423,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
                 "Cloud",
                 "Task",
                 "Texture",
-                "Asset",
-                "State");            
+                "Asset");            
             
             lock (m_scenes)
             {
@@ -434,24 +432,24 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
                     scene.ForEachClient(
                         delegate(IClientAPI client)
                         {
-                            bool isChild = client.SceneAgent.IsChildAgent;
-                            if (isChild && !showChildren)
-                                return;
-                    
-                            string name = client.Name;
-                            if (pname != "" && name != pname)
-                                return;
-
-                            string regionName = scene.RegionInfo.RegionName;
-
-                            report.Append(GetColumnEntry(name, maxNameLength, columnPadding));
-                            report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding));
-                            report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding));
-
                             if (client is IStatsCollector)
                             {
-                                IStatsCollector stats = (IStatsCollector)client;
+
+                                bool isChild = client.SceneAgent.IsChildAgent;
+                                if (isChild && !showChildren)
+                                    return;
                         
+                                string name = client.Name;
+                                if (pname != "" && name != pname)
+                                    return;
+
+                                string regionName = scene.RegionInfo.RegionName;
+
+                                report.Append(GetColumnEntry(name, maxNameLength, columnPadding));
+                                report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding));
+                                report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding));
+
+                                IStatsCollector stats = (IStatsCollector)client;                            
                                 report.AppendLine(stats.Report());
                             }
                         });