diff options
author | Melanie | 2012-03-25 20:07:43 +0100 |
---|---|---|
committer | Melanie | 2012-03-25 20:07:43 +0100 |
commit | 44f1f876562dd41c0c619462a57d6a33731729ac (patch) | |
tree | 96c7a583dcb483f2fe8d19787a381fae1985b1b1 /OpenSim/Region/CoreModules | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Simplify the module invocation registration. The types and method name (diff) | |
download | opensim-SC-44f1f876562dd41c0c619462a57d6a33731729ac.zip opensim-SC-44f1f876562dd41c0c619462a57d6a33731729ac.tar.gz opensim-SC-44f1f876562dd41c0c619462a57d6a33731729ac.tar.bz2 opensim-SC-44f1f876562dd41c0c619462a57d6a33731729ac.tar.xz |
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region/CoreModules')
3 files changed, 61 insertions, 33 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index 21a9999..58925fd 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | |||
@@ -132,13 +132,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
132 | { | 132 | { |
133 | // We need to do this because: | 133 | // We need to do this because: |
134 | // "Saving the image to the same file it was constructed from is not allowed and throws an exception." | 134 | // "Saving the image to the same file it was constructed from is not allowed and throws an exception." |
135 | string tempName = offsetX + "_ " + offsetY + "_" + filename; | 135 | string tempName = Path.GetTempFileName(); |
136 | 136 | ||
137 | Bitmap entireBitmap = null; | 137 | Bitmap entireBitmap = null; |
138 | Bitmap thisBitmap = null; | 138 | Bitmap thisBitmap = null; |
139 | if (File.Exists(filename)) | 139 | if (File.Exists(filename)) |
140 | { | 140 | { |
141 | File.Copy(filename, tempName); | 141 | File.Copy(filename, tempName, true); |
142 | entireBitmap = new Bitmap(tempName); | 142 | entireBitmap = new Bitmap(tempName); |
143 | if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY) | 143 | if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY) |
144 | { | 144 | { |
@@ -152,7 +152,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
152 | } | 152 | } |
153 | 153 | ||
154 | thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); | 154 | thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); |
155 | Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); | 155 | // Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); |
156 | for (int x = 0; x < regionSizeX; x++) | 156 | for (int x = 0; x < regionSizeX; x++) |
157 | for (int y = 0; y < regionSizeY; y++) | 157 | for (int y = 0; y < regionSizeY; y++) |
158 | entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); | 158 | entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs index 7237f90..d407617 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs | |||
@@ -38,6 +38,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
38 | ITerrainChannel LoadStream(Stream stream); | 38 | ITerrainChannel LoadStream(Stream stream); |
39 | void SaveFile(string filename, ITerrainChannel map); | 39 | void SaveFile(string filename, ITerrainChannel map); |
40 | void SaveStream(Stream stream, ITerrainChannel map); | 40 | void SaveStream(Stream stream, ITerrainChannel map); |
41 | |||
42 | /// <summary> | ||
43 | /// Save a number of map tiles to a single big image file. | ||
44 | /// </summary> | ||
45 | /// <remarks> | ||
46 | /// If the image file already exists then the tiles saved will replace those already in the file - other tiles | ||
47 | /// will be untouched. | ||
48 | /// </remarks> | ||
49 | /// <param name="filename">The terrain file to save</param> | ||
50 | /// <param name="offsetX">The map x co-ordinate at which to begin the save.</param> | ||
51 | /// <param name="offsetY">The may y co-ordinate at which to begin the save.</param> | ||
52 | /// <param name="fileWidth">The number of tiles to save along the X axis.</param> | ||
53 | /// <param name="fileHeight">The number of tiles to save along the Y axis.</param> | ||
54 | /// <param name="regionSizeX">The width of a map tile.</param> | ||
55 | /// <param name="regionSizeY">The height of a map tile.</param> | ||
41 | void SaveFile(ITerrainChannel map, string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int regionSizeX, int regionSizeY); | 56 | void SaveFile(ITerrainChannel map, string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int regionSizeX, int regionSizeY); |
42 | } | 57 | } |
43 | } \ No newline at end of file | 58 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 7c6df03..9159f0c 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -561,49 +561,56 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
561 | } | 561 | } |
562 | 562 | ||
563 | /// <summary> | 563 | /// <summary> |
564 | /// Saves the terrain to a larger terrain file. | 564 | /// Save a number of map tiles to a single big image file. |
565 | /// </summary> | 565 | /// </summary> |
566 | /// <remarks> | ||
567 | /// If the image file already exists then the tiles saved will replace those already in the file - other tiles | ||
568 | /// will be untouched. | ||
569 | /// </remarks> | ||
566 | /// <param name="filename">The terrain file to save</param> | 570 | /// <param name="filename">The terrain file to save</param> |
567 | /// <param name="fileWidth">The width of the file in units</param> | 571 | /// <param name="fileWidth">The number of tiles to save along the X axis.</param> |
568 | /// <param name="fileHeight">The height of the file in units</param> | 572 | /// <param name="fileHeight">The number of tiles to save along the Y axis.</param> |
569 | /// <param name="fileStartX">Where to begin our slice</param> | 573 | /// <param name="fileStartX">The map x co-ordinate at which to begin the save.</param> |
570 | /// <param name="fileStartY">Where to begin our slice</param> | 574 | /// <param name="fileStartY">The may y co-ordinate at which to begin the save.</param> |
571 | public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) | 575 | public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) |
572 | { | 576 | { |
573 | int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX; | 577 | int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX; |
574 | int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY; | 578 | int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY; |
575 | 579 | ||
576 | if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) | 580 | if (offsetX < 0 || offsetX >= fileWidth || offsetY < 0 || offsetY >= fileHeight) |
577 | { | 581 | { |
578 | // this region is included in the tile request | 582 | MainConsole.Instance.OutputFormat( |
579 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | 583 | "ERROR: file width + minimum X tile and file height + minimum Y tile must incorporate the current region at ({0},{1}). File width {2} from {3} and file height {4} from {5} does not.", |
584 | m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, fileWidth, fileStartX, fileHeight, fileStartY); | ||
585 | |||
586 | return; | ||
587 | } | ||
588 | |||
589 | // this region is included in the tile request | ||
590 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | ||
591 | { | ||
592 | if (filename.EndsWith(loader.Key)) | ||
580 | { | 593 | { |
581 | if (filename.EndsWith(loader.Key)) | 594 | lock (m_scene) |
582 | { | 595 | { |
583 | lock (m_scene) | 596 | loader.Value.SaveFile(m_channel, filename, offsetX, offsetY, |
584 | { | 597 | fileWidth, fileHeight, |
585 | loader.Value.SaveFile(m_channel, filename, offsetX, offsetY, | 598 | (int)Constants.RegionSize, |
586 | fileWidth, fileHeight, | 599 | (int)Constants.RegionSize); |
587 | (int)Constants.RegionSize, | 600 | |
588 | (int)Constants.RegionSize); | 601 | MainConsole.Instance.OutputFormat( |
589 | 602 | "Saved terrain from ({0},{1}) to ({2},{3}) from {4} to {5}", | |
590 | m_log.InfoFormat("[TERRAIN]: Saved terrain from {0} to {1}", m_scene.RegionInfo.RegionName, filename); | 603 | fileStartX, fileStartY, fileStartX + fileWidth - 1, fileStartY + fileHeight - 1, |
591 | } | 604 | m_scene.RegionInfo.RegionName, filename); |
592 | |||
593 | return; | ||
594 | } | 605 | } |
606 | |||
607 | return; | ||
595 | } | 608 | } |
596 | |||
597 | m_log.ErrorFormat( | ||
598 | "[TERRAIN]: Could not save terrain from {0} to {1}. Valid file extensions are {2}", | ||
599 | m_scene.RegionInfo.RegionName, filename, m_supportedFileExtensions); | ||
600 | } | 609 | } |
601 | // else | 610 | |
602 | // { | 611 | MainConsole.Instance.OutputFormat( |
603 | // m_log.ErrorFormat( | 612 | "ERROR: Could not save terrain from {0} to {1}. Valid file extensions are {2}", |
604 | // "[TERRAIN]: Could not save terrain from {0} to {1}. {2} {3} {4} {5} {6} {7}", | 613 | m_scene.RegionInfo.RegionName, filename, m_supportedFileExtensions); |
605 | // m_scene.RegionInfo.RegionName, filename, fileWidth, fileHeight, fileStartX, fileStartY, offsetX, offsetY); | ||
606 | // } | ||
607 | } | 614 | } |
608 | 615 | ||
609 | /// <summary> | 616 | /// <summary> |
@@ -1194,6 +1201,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1194 | "Integer"); | 1201 | "Integer"); |
1195 | saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", | 1202 | saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", |
1196 | "Integer"); | 1203 | "Integer"); |
1204 | saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first tile on the file\n" | ||
1205 | + "= Example =\n" | ||
1206 | + "To save a PNG file for a set of map tiles 2 regions wide and 3 regions high from map co-ordinate (9910,10234)\n" | ||
1207 | + " # terrain save-tile ST06.png 2 3 9910 10234\n", | ||
1208 | "Integer"); | ||
1209 | |||
1197 | // Terrain adjustments | 1210 | // Terrain adjustments |
1198 | Command fillRegionCommand = | 1211 | Command fillRegionCommand = |
1199 | new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); | 1212 | new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); |