aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs61
1 files changed, 61 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
index 1bda2a0..fb81abc 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
@@ -221,6 +221,67 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
221 throw new TerrainException(String.Format("Unable to save heightmap: saving of this file format not implemented")); 221 throw new TerrainException(String.Format("Unable to save heightmap: saving of this file format not implemented"));
222 } 222 }
223 } 223 }
224
225 /// <summary>
226 /// Loads a terrain file from a stream and installs it in the scene.
227 /// </summary>
228 /// <param name="filename">Filename to terrain file. Type is determined by extension.</param>
229 /// <param name="stream"></param>
230 public void LoadFromStream(string filename, Stream stream)
231 {
232 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
233 {
234 if (filename.EndsWith(loader.Key))
235 {
236 lock (m_scene)
237 {
238 try
239 {
240 ITerrainChannel channel = loader.Value.LoadStream(stream);
241 m_scene.Heightmap = channel;
242 m_channel = channel;
243 UpdateRevertMap();
244 }
245 catch (NotImplementedException)
246 {
247 m_log.Error("[TERRAIN]: Unable to load heightmap, the " + loader.Value +
248 " parser does not support file loading. (May be save only)");
249 throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value));
250 }
251 }
252 CheckForTerrainUpdates();
253 m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully");
254 return;
255 }
256 }
257 m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader availible for that format.");
258 throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename));
259 }
260
261 /// <summary>
262 /// Saves the current heightmap to a specified stream.
263 /// </summary>
264 /// <param name="filename">The destination filename. Used here only to identify the image type</param>
265 /// <param name="stream"></param>
266 public void SaveToStream(string filename, Stream stream)
267 {
268 try
269 {
270 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
271 {
272 if (filename.EndsWith(loader.Key))
273 {
274 loader.Value.SaveStream(stream, m_channel);
275 return;
276 }
277 }
278 }
279 catch (NotImplementedException)
280 {
281 m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented.");
282 throw new TerrainException(String.Format("Unable to save heightmap: saving of this file format not implemented"));
283 }
284 }
224 285
225 #region Plugin Loading Methods 286 #region Plugin Loading Methods
226 287