diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index 165ea6ea91..81d1a4a280 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/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 z_sort = new Dictionary(); - //SortedList z_sort = new SortedList(); List z_sortheights = new List(); List z_localIDs = new List(); + Dictionary z_sort = new Dictionary(); - 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; } diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs index 9b939c9e1f..708286c906 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs +++ b/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"); } } } diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs index 413ac6462f..9f23141315 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs +++ b/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"); } } } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index e925f0d531..b4720380ff 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -114,6 +114,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap "export-map []", "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; - - List parcels = m_scene.LandChannel.AllParcels(); - - 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); - - SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); - - 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) + bool[,] saleBitmap = new bool[64, 64]; + for (int x = 0 ; x < 64 ; x++) { - landForSale = true; + for (int y = 0 ; y < 64 ; y++) + saleBitmap[x, y] = false; + } - saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap()); + bool landForSale = false; + + List parcels = m_scene.LandChannel.AllParcels(); + + Color background = Color.FromArgb(0, 0, 0, 0); + + using (Graphics g = Graphics.FromImage(overlay)) + { + using (SolidBrush transparent = new SolidBrush(background)) + g.FillRectangle(transparent, 0, 0, 256, 256); + + + 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); + + 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 + { + return OpenJPEG.EncodeFromImage(overlay, true); + } + catch (Exception e) + { + m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString()); } } - 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); - - 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 - { - return OpenJPEG.EncodeFromImage(overlay, true); - } - catch (Exception e) - { - m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString()); - } return null; } } diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 1eb0a6bc5f..ec18db0aa8 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/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 [full]"; + return "Usage: show image queues [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()); } });