diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 93 |
2 files changed, 92 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 73eceb7..ff57953 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -121,6 +121,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
121 | client.OnParcelReclaim += new ParcelReclaim(handleParcelReclaim); | 121 | client.OnParcelReclaim += new ParcelReclaim(handleParcelReclaim); |
122 | client.OnParcelInfoRequest += new ParcelInfoRequest(handleParcelInfo); | 122 | client.OnParcelInfoRequest += new ParcelInfoRequest(handleParcelInfo); |
123 | client.OnParcelDwellRequest += new ParcelDwellRequest(handleParcelDwell); | 123 | client.OnParcelDwellRequest += new ParcelDwellRequest(handleParcelDwell); |
124 | |||
124 | if (m_scene.Entities.ContainsKey(client.AgentId)) | 125 | if (m_scene.Entities.ContainsKey(client.AgentId)) |
125 | { | 126 | { |
126 | SendLandUpdate((ScenePresence)m_scene.Entities[client.AgentId], true); | 127 | SendLandUpdate((ScenePresence)m_scene.Entities[client.AgentId], true); |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 5ce2a2b..9f5277b 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -54,6 +54,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
54 | { | 54 | { |
55 | private static readonly ILog m_log = | 55 | private static readonly ILog m_log = |
56 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 56 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
57 | |||
58 | private static readonly string DEFAULT_WORLD_MAP_EXPORT_PATH = "exportmap.jpg"; | ||
57 | 59 | ||
58 | private static readonly string m_mapLayerPath = "0001/"; | 60 | private static readonly string m_mapLayerPath = "0001/"; |
59 | 61 | ||
@@ -80,14 +82,18 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
80 | public virtual void Initialise(Scene scene, IConfigSource config) | 82 | public virtual void Initialise(Scene scene, IConfigSource config) |
81 | { | 83 | { |
82 | IConfig startupConfig = config.Configs["Startup"]; | 84 | IConfig startupConfig = config.Configs["Startup"]; |
83 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == | 85 | if (startupConfig.GetString("WorldMapModule", "WorldMap") == "WorldMap") |
84 | "WorldMap") | ||
85 | m_Enabled = true; | 86 | m_Enabled = true; |
86 | 87 | ||
87 | if (!m_Enabled) | 88 | if (!m_Enabled) |
88 | return; | 89 | return; |
89 | 90 | ||
90 | m_scene = scene; | 91 | m_scene = scene; |
92 | |||
93 | m_scene.AddCommand( | ||
94 | this, "export-map", | ||
95 | "export-map [<path>]", | ||
96 | "Save an image of the world map", HandleExportWorldMapConsoleCommand); | ||
91 | } | 97 | } |
92 | 98 | ||
93 | public virtual void PostInitialise() | 99 | public virtual void PostInitialise() |
@@ -788,6 +794,89 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
788 | } | 794 | } |
789 | return null; | 795 | return null; |
790 | } | 796 | } |
797 | |||
798 | /// <summary> | ||
799 | /// Export the world map | ||
800 | /// </summary> | ||
801 | /// <param name="fileName"></param> | ||
802 | public void HandleExportWorldMapConsoleCommand(string module, string[] cmdparams) | ||
803 | { | ||
804 | if (m_scene.ConsoleScene() == null) | ||
805 | { | ||
806 | // FIXME: If console region is root then this will be printed by every module. Currently, there is no | ||
807 | // way to prevent this, short of making the entire module shared (which is complete overkill). | ||
808 | // One possibility is to return a bool to signal whether the module has completely handled the command | ||
809 | m_log.InfoFormat("[WORLD MAP]: Please change to a specific region in order to export its world map"); | ||
810 | return; | ||
811 | } | ||
812 | |||
813 | if (m_scene.ConsoleScene() != m_scene) | ||
814 | return; | ||
815 | |||
816 | string exportPath; | ||
817 | |||
818 | if (cmdparams.Length > 1) | ||
819 | exportPath = cmdparams[1]; | ||
820 | else | ||
821 | exportPath = DEFAULT_WORLD_MAP_EXPORT_PATH; | ||
822 | |||
823 | m_log.InfoFormat( | ||
824 | "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath); | ||
825 | |||
826 | List<MapBlockData> mapBlocks = | ||
827 | m_scene.CommsManager.GridService.RequestNeighbourMapBlocks( | ||
828 | (int)(m_scene.RegionInfo.RegionLocX - 9), | ||
829 | (int)(m_scene.RegionInfo.RegionLocY - 9), | ||
830 | (int)(m_scene.RegionInfo.RegionLocX + 9), | ||
831 | (int)(m_scene.RegionInfo.RegionLocY + 9)); | ||
832 | List<AssetBase> textures = new List<AssetBase>(); | ||
833 | List<Image> bitImages = new List<Image>(); | ||
834 | |||
835 | foreach (MapBlockData mapBlock in mapBlocks) | ||
836 | { | ||
837 | AssetBase texAsset = m_scene.CommsManager.AssetCache.GetAsset(mapBlock.MapImageId, true); | ||
838 | |||
839 | if (texAsset != null) | ||
840 | { | ||
841 | textures.Add(texAsset); | ||
842 | } | ||
843 | else | ||
844 | { | ||
845 | texAsset = m_scene.CommsManager.AssetCache.GetAsset(mapBlock.MapImageId, true); | ||
846 | if (texAsset != null) | ||
847 | { | ||
848 | textures.Add(texAsset); | ||
849 | } | ||
850 | } | ||
851 | } | ||
852 | |||
853 | foreach (AssetBase asset in textures) | ||
854 | { | ||
855 | ManagedImage managedImage; | ||
856 | Image image; | ||
857 | |||
858 | if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image)) | ||
859 | bitImages.Add(image); | ||
860 | } | ||
861 | |||
862 | Bitmap mapTexture = new Bitmap(2560, 2560); | ||
863 | Graphics g = Graphics.FromImage(mapTexture); | ||
864 | SolidBrush sea = new SolidBrush(Color.DarkBlue); | ||
865 | g.FillRectangle(sea, 0, 0, 2560, 2560); | ||
866 | |||
867 | for (int i = 0; i < mapBlocks.Count; i++) | ||
868 | { | ||
869 | ushort x = (ushort)((mapBlocks[i].X - m_scene.RegionInfo.RegionLocX) + 10); | ||
870 | ushort y = (ushort)((mapBlocks[i].Y - m_scene.RegionInfo.RegionLocY) + 10); | ||
871 | g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128); | ||
872 | } | ||
873 | |||
874 | mapTexture.Save(exportPath, ImageFormat.Jpeg); | ||
875 | |||
876 | m_log.InfoFormat( | ||
877 | "[WORLD MAP]: Successfully exported world map for {0} to {1}", | ||
878 | m_scene.RegionInfo.RegionName, exportPath); | ||
879 | } | ||
791 | 880 | ||
792 | public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) | 881 | public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) |
793 | { | 882 | { |