aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs76
1 files changed, 49 insertions, 27 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index cf000a4..b3c2969 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -86,6 +86,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
86 private volatile bool m_tainted; 86 private volatile bool m_tainted;
87 private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5); 87 private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5);
88 88
89 private String m_InitialTerrain = "pinhead-island";
90
89 /// <summary> 91 /// <summary>
90 /// Human readable list of terrain file extensions that are supported. 92 /// Human readable list of terrain file extensions that are supported.
91 /// </summary> 93 /// </summary>
@@ -109,6 +111,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain
109 /// <param name="config">Config for the region</param> 111 /// <param name="config">Config for the region</param>
110 public void Initialise(IConfigSource config) 112 public void Initialise(IConfigSource config)
111 { 113 {
114 IConfig terrainConfig = config.Configs["Terrain"];
115 if (terrainConfig != null)
116 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
112 } 117 }
113 118
114 public void AddRegion(Scene scene) 119 public void AddRegion(Scene scene)
@@ -120,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
120 { 125 {
121 if (m_scene.Heightmap == null) 126 if (m_scene.Heightmap == null)
122 { 127 {
123 m_channel = new TerrainChannel(); 128 m_channel = new TerrainChannel(m_InitialTerrain);
124 m_scene.Heightmap = m_channel; 129 m_scene.Heightmap = m_channel;
125 m_revert = new TerrainChannel(); 130 m_revert = new TerrainChannel();
126 UpdateRevertMap(); 131 UpdateRevertMap();
@@ -556,43 +561,56 @@ namespace OpenSim.Region.CoreModules.World.Terrain
556 } 561 }
557 562
558 /// <summary> 563 /// <summary>
559 /// Saves the terrain to a larger terrain file. 564 /// Save a number of map tiles to a single big image file.
560 /// </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>
561 /// <param name="filename">The terrain file to save</param> 570 /// <param name="filename">The terrain file to save</param>
562 /// <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>
563 /// <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>
564 /// <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>
565 /// <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>
566 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)
567 { 576 {
568 int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX; 577 int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX;
569 int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY; 578 int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY;
570 579
571 if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) 580 if (offsetX < 0 || offsetX >= fileWidth || offsetY < 0 || offsetY >= fileHeight)
572 { 581 {
573 // this region is included in the tile request 582 MainConsole.Instance.OutputFormat(
574 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))
575 { 593 {
576 if (filename.EndsWith(loader.Key)) 594 lock (m_scene)
577 { 595 {
578 lock (m_scene) 596 loader.Value.SaveFile(m_channel, filename, offsetX, offsetY,
579 { 597 fileWidth, fileHeight,
580 loader.Value.SaveFile(m_channel, filename, offsetX, offsetY, 598 (int)Constants.RegionSize,
581 fileWidth, fileHeight, 599 (int)Constants.RegionSize);
582 (int)Constants.RegionSize, 600
583 (int)Constants.RegionSize); 601 MainConsole.Instance.OutputFormat(
584 602 "Saved terrain from ({0},{1}) to ({2},{3}) from {4} to {5}",
585 m_log.InfoFormat("[TERRAIN]: Saved terrain from {0} to {1}", m_scene.RegionInfo.RegionName, filename); 603 fileStartX, fileStartY, fileStartX + fileWidth - 1, fileStartY + fileHeight - 1,
586 } 604 m_scene.RegionInfo.RegionName, filename);
587
588 return;
589 } 605 }
606
607 return;
590 } 608 }
591
592 m_log.ErrorFormat(
593 "[TERRAIN]: Could not save terrain from {0} to {1}. Valid file extensions are {2}",
594 m_scene.RegionInfo.RegionName, filename, m_supportedFileExtensions);
595 } 609 }
610
611 MainConsole.Instance.OutputFormat(
612 "ERROR: Could not save terrain from {0} to {1}. Valid file extensions are {2}",
613 m_scene.RegionInfo.RegionName, filename, m_supportedFileExtensions);
596 } 614 }
597 615
598 /// <summary> 616 /// <summary>
@@ -1179,8 +1197,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1179 saveToTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer"); 1197 saveToTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer");
1180 saveToTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file", 1198 saveToTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file",
1181 "Integer"); 1199 "Integer");
1182 saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", 1200 saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first tile on the file\n"
1183 "Integer"); 1201 + "= Example =\n"
1202 + "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"
1203 + " # terrain save-tile ST06.png 2 3 9910 10234\n",
1204 "Integer");
1205
1184 // Terrain adjustments 1206 // Terrain adjustments
1185 Command fillRegionCommand = 1207 Command fillRegionCommand =
1186 new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); 1208 new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value.");