diff options
author | Adam Frisby | 2009-12-03 02:44:12 +1100 |
---|---|---|
committer | Adam Frisby | 2009-12-03 02:44:12 +1100 |
commit | 30fe88b80892e4538dc2b6f71992c3f51d35e95a (patch) | |
tree | 137c86cd0742c2f45dedfea55fe23b7353f3ad99 /OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |
parent | handle a condition where the http headers apparently have multiple remote por... (diff) | |
download | opensim-SC_OLD-30fe88b80892e4538dc2b6f71992c3f51d35e95a.zip opensim-SC_OLD-30fe88b80892e4538dc2b6f71992c3f51d35e95a.tar.gz opensim-SC_OLD-30fe88b80892e4538dc2b6f71992c3f51d35e95a.tar.bz2 opensim-SC_OLD-30fe88b80892e4538dc2b6f71992c3f51d35e95a.tar.xz |
* Terrain uploads via the Estate Tools now support a multitude of file formats. Specifically: . bmp, .raw, .r32 & .r64. (in ascending order of precision)
* It uses file length as the detection routine (as each of these formats has a distinct size in bytes for a 256x256 array.) - more formats should be possible to add.
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | 50 |
1 files changed, 31 insertions, 19 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) |