aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorMelanie2009-12-05 19:53:54 +0000
committerMelanie2009-12-05 19:53:54 +0000
commit43a6fa1d01707fda74b8ba7c2d9fb95210463b6a (patch)
tree77c5897901544e82467b1cdfafdc63644ee821ef /OpenSim/Region/CoreModules
parentMerge branch 'master' into careminster (diff)
parent* Fix line endings in BaseHttpServer.cs (diff)
downloadopensim-SC-43a6fa1d01707fda74b8ba7c2d9fb95210463b6a.zip
opensim-SC-43a6fa1d01707fda74b8ba7c2d9fb95210463b6a.tar.gz
opensim-SC-43a6fa1d01707fda74b8ba7c2d9fb95210463b6a.tar.bz2
opensim-SC-43a6fa1d01707fda74b8ba7c2d9fb95210463b6a.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs50
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs32
2 files changed, 62 insertions, 20 deletions
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index e3a395e..b1dcb14 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -471,20 +471,45 @@ namespace OpenSim.Region.CoreModules.World.Estate
471 if (terr != null) 471 if (terr != null)
472 { 472 {
473 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName); 473 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName);
474 if (File.Exists(Util.dataDir() + "/terrain.raw")) 474
475 {
476 File.Delete(Util.dataDir() + "/terrain.raw");
477 }
478 try 475 try
479 { 476 {
480 FileStream input = new FileStream(Util.dataDir() + "/terrain.raw", FileMode.CreateNew); 477
478 string localfilename = "terrain.raw";
479
480 if (terrainData.Length == 851968)
481 {
482 localfilename = Path.Combine(Util.dataDir(),"terrain.raw"); // It's a .LLRAW
483 }
484
485 if (terrainData.Length == 196662) // 24-bit 256x256 Bitmap
486 localfilename = Path.Combine(Util.dataDir(), "terrain.bmp");
487
488 if (terrainData.Length == 256 * 256 * 4) // It's a .R32
489 localfilename = Path.Combine(Util.dataDir(), "terrain.r32");
490
491 if (terrainData.Length == 256 * 256 * 8) // It's a .R64
492 localfilename = Path.Combine(Util.dataDir(), "terrain.r64");
493
494 if (File.Exists(localfilename))
495 {
496 File.Delete(localfilename);
497 }
498
499 FileStream input = new FileStream(localfilename, FileMode.CreateNew);
481 input.Write(terrainData, 0, terrainData.Length); 500 input.Write(terrainData, 0, terrainData.Length);
482 input.Close(); 501 input.Close();
502
503 FileInfo x = new FileInfo(localfilename);
504
505 terr.LoadFromFile(localfilename);
506 remoteClient.SendAlertMessage("Your terrain was loaded as a ." + x.Extension + " file. It may take a few moments to appear.");
507
483 } 508 }
484 catch (IOException e) 509 catch (IOException e)
485 { 510 {
486 m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString()); 511 m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
487 remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space"); 512 remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space.");
488 513
489 return; 514 return;
490 } 515 }
@@ -502,29 +527,16 @@ namespace OpenSim.Region.CoreModules.World.Estate
502 527
503 return; 528 return;
504 } 529 }
505
506
507
508
509 try
510 {
511 terr.LoadFromFile(Util.dataDir() + "/terrain.raw");
512 remoteClient.SendAlertMessage("Your terrain was loaded. Give it a minute or two to apply");
513 }
514 catch (Exception e) 530 catch (Exception e)
515 { 531 {
516 m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString()); 532 m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
517 remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again"); 533 remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again");
518 } 534 }
519
520 } 535 }
521 else 536 else
522 { 537 {
523 remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module"); 538 remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module");
524 } 539 }
525
526
527
528 } 540 }
529 541
530 private void handleUploadTerrain(IClientAPI remote_client, string clientFileName) 542 private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
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>