aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2009-12-04 18:26:58 +0000
committerJustin Clark-Casey (justincc)2009-12-04 18:26:58 +0000
commitc0f3a4c8332f235e998714214011c5412bdcacf0 (patch)
tree78838e69a71b5a3d76d320161ba89111d156665a /OpenSim/Region/CoreModules
parent* Clarifies that the PrimMaxPhys in OpenSim.ini.example does nothing. Tells ... (diff)
downloadopensim-SC-c0f3a4c8332f235e998714214011c5412bdcacf0.zip
opensim-SC-c0f3a4c8332f235e998714214011c5412bdcacf0.tar.gz
opensim-SC-c0f3a4c8332f235e998714214011c5412bdcacf0.tar.bz2
opensim-SC-c0f3a4c8332f235e998714214011c5412bdcacf0.tar.xz
Allow terrain heightmaps to be loaded directly from URIs via the remote admin plugin
See http://opensimulator.org/mantis/view.php?id=4418 Thanks StrawberryFride See
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs32
1 files changed, 31 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index ba271fd..a40828b 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Net;
32using log4net; 33using log4net;
33using Nini.Config; 34using Nini.Config;
34using OpenMetaverse; 35using OpenMetaverse;
@@ -259,6 +260,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain
259 } 260 }
260 261
261 /// <summary> 262 /// <summary>
263 /// Loads a terrain file from the specified URI
264 /// </summary>
265 /// <param name="filename">The name of the terrain to load</param>
266 /// <param name="pathToTerrainHeightmap">The URI to the terrain height map</param>
267 public void LoadFromStream(string filename, Uri pathToTerrainHeightmap)
268 {
269 LoadFromStream(filename, URIFetch(pathToTerrainHeightmap));
270 }
271
272 /// <summary>
262 /// Loads a terrain file from a stream and installs it in the scene. 273 /// Loads a terrain file from a stream and installs it in the scene.
263 /// </summary> 274 /// </summary>
264 /// <param name="filename">Filename to terrain file. Type is determined by extension.</param> 275 /// <param name="filename">Filename to terrain file. Type is determined by extension.</param>
@@ -267,7 +278,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
267 { 278 {
268 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) 279 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
269 { 280 {
270 if (@filename.EndsWith(loader.Key)) 281 if (filename.EndsWith(loader.Key))
271 { 282 {
272 lock (m_scene) 283 lock (m_scene)
273 { 284 {
@@ -295,6 +306,25 @@ namespace OpenSim.Region.CoreModules.World.Terrain
295 throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); 306 throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename));
296 } 307 }
297 308
309 private static Stream URIFetch(Uri uri)
310 {
311 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
312
313 // request.Credentials = credentials;
314
315 request.ContentLength = 0;
316 request.KeepAlive = false;
317
318 WebResponse response = request.GetResponse();
319 Stream file = response.GetResponseStream();
320
321 if (response.ContentLength == 0)
322 throw new Exception(String.Format("{0} returned an empty file", uri.ToString()));
323
324 // return new BufferedStream(file, (int) response.ContentLength);
325 return new BufferedStream(file, 1000000);
326 }
327
298 /// <summary> 328 /// <summary>
299 /// Modify Land 329 /// Modify Land
300 /// </summary> 330 /// </summary>