diff options
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | 73 |
1 files changed, 43 insertions, 30 deletions
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."); |