diff options
author | Justin Clarke Casey | 2009-02-13 16:43:20 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-02-13 16:43:20 +0000 |
commit | 88b273bc719b5d462069bdfce5782c5dcaf97596 (patch) | |
tree | 6272d4413e1645b52ef8250245186fe88cbb2394 /OpenSim | |
parent | fixing crash due to make-child and make-root stepping on each other's toes (diff) | |
download | opensim-SC_OLD-88b273bc719b5d462069bdfce5782c5dcaf97596.zip opensim-SC_OLD-88b273bc719b5d462069bdfce5782c5dcaf97596.tar.gz opensim-SC_OLD-88b273bc719b5d462069bdfce5782c5dcaf97596.tar.bz2 opensim-SC_OLD-88b273bc719b5d462069bdfce5782c5dcaf97596.tar.xz |
* refactor: Move export map function to world map module from scene
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Console/ConsoleBase.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/Application/OpenSim.cs | 15 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 93 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 54 |
6 files changed, 94 insertions, 76 deletions
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 0e7326f..0f0b3a6 100644 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs | |||
@@ -361,6 +361,7 @@ namespace OpenSim.Framework.Console | |||
361 | fn(ci.module, result); | 361 | fn(ci.module, result); |
362 | return result; | 362 | return result; |
363 | } | 363 | } |
364 | |||
364 | return new string[0]; | 365 | return new string[0]; |
365 | } | 366 | } |
366 | } | 367 | } |
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index fdc55c7..17ced08 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -225,10 +225,6 @@ namespace OpenSim | |||
225 | "command-script <script>", | 225 | "command-script <script>", |
226 | "Run a command script from file", RunCommand); | 226 | "Run a command script from file", RunCommand); |
227 | 227 | ||
228 | m_console.Commands.AddCommand("region", false, "export-map", | ||
229 | "export-map <file>", | ||
230 | "Save an image of the world map", RunCommand); | ||
231 | |||
232 | m_console.Commands.AddCommand("region", false, "remove-region", | 228 | m_console.Commands.AddCommand("region", false, "remove-region", |
233 | "remove-region <name>", | 229 | "remove-region <name>", |
234 | "Remove a region from this simulator", RunCommand); | 230 | "Remove a region from this simulator", RunCommand); |
@@ -609,17 +605,6 @@ namespace OpenSim | |||
609 | m_sceneManager.RestartCurrentScene(); | 605 | m_sceneManager.RestartCurrentScene(); |
610 | break; | 606 | break; |
611 | 607 | ||
612 | case "export-map": | ||
613 | if (cmdparams.Length > 0) | ||
614 | { | ||
615 | m_sceneManager.CurrentOrFirstScene.ExportWorldMap(cmdparams[0]); | ||
616 | } | ||
617 | else | ||
618 | { | ||
619 | m_sceneManager.CurrentOrFirstScene.ExportWorldMap("exportmap.jpg"); | ||
620 | } | ||
621 | break; | ||
622 | |||
623 | case "Add-InventoryHost": | 608 | case "Add-InventoryHost": |
624 | if (cmdparams.Length > 0) | 609 | if (cmdparams.Length > 0) |
625 | { | 610 | { |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs index 6f9e5d3..75b5644 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs | |||
@@ -266,10 +266,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
266 | } | 266 | } |
267 | } | 267 | } |
268 | } | 268 | } |
269 | |||
270 | } | 269 | } |
271 | 270 | ||
272 | |||
273 | /// <summary> | 271 | /// <summary> |
274 | /// Callback for when the image has been decoded | 272 | /// Callback for when the image has been decoded |
275 | /// </summary> | 273 | /// </summary> |
@@ -281,7 +279,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
281 | if (m_shuttingdown) | 279 | if (m_shuttingdown) |
282 | return; | 280 | return; |
283 | 281 | ||
284 | |||
285 | lock (PQHandles) | 282 | lock (PQHandles) |
286 | { | 283 | { |
287 | // Update our asset data | 284 | // Update our asset data |
@@ -299,7 +296,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
299 | } | 296 | } |
300 | } | 297 | } |
301 | 298 | ||
302 | |||
303 | /// <summary> | 299 | /// <summary> |
304 | /// This image has had a good life. It's now expired. Remove it off the queue | 300 | /// This image has had a good life. It's now expired. Remove it off the queue |
305 | /// </summary> | 301 | /// </summary> |
@@ -531,7 +527,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
531 | DiscardLevel = 0; | 527 | DiscardLevel = 0; |
532 | StopPacket = TexturePacketCount() - 1; | 528 | StopPacket = TexturePacketCount() - 1; |
533 | CurrentPacket = Util.Clamp<int>(packet, 1, TexturePacketCount() - 1); | 529 | CurrentPacket = Util.Clamp<int>(packet, 1, TexturePacketCount() - 1); |
534 | |||
535 | } | 530 | } |
536 | } | 531 | } |
537 | 532 | ||
@@ -562,7 +557,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
562 | } | 557 | } |
563 | else | 558 | else |
564 | { | 559 | { |
565 | |||
566 | // Send first packet | 560 | // Send first packet |
567 | byte[] firstImageData = new byte[FIRST_IMAGE_PACKET_SIZE]; | 561 | byte[] firstImageData = new byte[FIRST_IMAGE_PACKET_SIZE]; |
568 | try { Buffer.BlockCopy(m_asset_ref.Data, 0, firstImageData, 0, FIRST_IMAGE_PACKET_SIZE); } | 562 | try { Buffer.BlockCopy(m_asset_ref.Data, 0, firstImageData, 0, FIRST_IMAGE_PACKET_SIZE); } |
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 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ffe0b81..7cce3b6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -851,15 +851,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
851 | UpdateEvents(); | 851 | UpdateEvents(); |
852 | 852 | ||
853 | if (m_frame % m_update_backup == 0) | 853 | if (m_frame % m_update_backup == 0) |
854 | { | ||
855 | UpdateStorageBackup(); | 854 | UpdateStorageBackup(); |
856 | } | ||
857 | 855 | ||
858 | if (m_frame % m_update_terrain == 0) | 856 | if (m_frame % m_update_terrain == 0) |
859 | UpdateTerrain(); | 857 | UpdateTerrain(); |
860 | 858 | ||
861 | if (m_frame % m_update_land == 0) | 859 | if (m_frame % m_update_land == 0) |
862 | UpdateLand(); | 860 | UpdateLand(); |
861 | |||
863 | otherMS = Environment.TickCount - otherMS; | 862 | otherMS = Environment.TickCount - otherMS; |
864 | // if (m_frame%m_update_avatars == 0) | 863 | // if (m_frame%m_update_avatars == 0) |
865 | // UpdateInWorldTime(); | 864 | // UpdateInWorldTime(); |
@@ -1052,57 +1051,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1052 | 1051 | ||
1053 | #region Load Terrain | 1052 | #region Load Terrain |
1054 | 1053 | ||
1055 | public void ExportWorldMap(string fileName) | ||
1056 | { | ||
1057 | List<MapBlockData> mapBlocks = | ||
1058 | m_sceneGridService.RequestNeighbourMapBlocks((int)(RegionInfo.RegionLocX - 9), | ||
1059 | (int)(RegionInfo.RegionLocY - 9), | ||
1060 | (int)(RegionInfo.RegionLocX + 9), | ||
1061 | (int)(RegionInfo.RegionLocY + 9)); | ||
1062 | List<AssetBase> textures = new List<AssetBase>(); | ||
1063 | List<Image> bitImages = new List<Image>(); | ||
1064 | |||
1065 | foreach (MapBlockData mapBlock in mapBlocks) | ||
1066 | { | ||
1067 | AssetBase texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true); | ||
1068 | |||
1069 | if (texAsset != null) | ||
1070 | { | ||
1071 | textures.Add(texAsset); | ||
1072 | } | ||
1073 | else | ||
1074 | { | ||
1075 | texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true); | ||
1076 | if (texAsset != null) | ||
1077 | { | ||
1078 | textures.Add(texAsset); | ||
1079 | } | ||
1080 | } | ||
1081 | } | ||
1082 | |||
1083 | foreach (AssetBase asset in textures) | ||
1084 | { | ||
1085 | ManagedImage managedImage; | ||
1086 | Image image; | ||
1087 | |||
1088 | if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image)) | ||
1089 | bitImages.Add(image); | ||
1090 | } | ||
1091 | |||
1092 | Bitmap mapTexture = new Bitmap(2560, 2560); | ||
1093 | Graphics g = Graphics.FromImage(mapTexture); | ||
1094 | SolidBrush sea = new SolidBrush(Color.DarkBlue); | ||
1095 | g.FillRectangle(sea, 0, 0, 2560, 2560); | ||
1096 | |||
1097 | for (int i = 0; i < mapBlocks.Count; i++) | ||
1098 | { | ||
1099 | ushort x = (ushort)((mapBlocks[i].X - RegionInfo.RegionLocX) + 10); | ||
1100 | ushort y = (ushort)((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10); | ||
1101 | g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128); | ||
1102 | } | ||
1103 | mapTexture.Save(fileName, ImageFormat.Jpeg); | ||
1104 | } | ||
1105 | |||
1106 | public void SaveTerrain() | 1054 | public void SaveTerrain() |
1107 | { | 1055 | { |
1108 | m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); | 1056 | m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); |