diff options
author | Teravus Ovares | 2008-11-14 14:42:00 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-11-14 14:42:00 +0000 |
commit | 3e4b094921dddfe10f6ee5f73eb1b917381c2c30 (patch) | |
tree | 7cdce613258028725b555e43ad0125081a2fc305 /OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs | |
parent | reverting #7295, as it still fails a test case (as pointed out very (diff) | |
download | opensim-SC_OLD-3e4b094921dddfe10f6ee5f73eb1b917381c2c30.zip opensim-SC_OLD-3e4b094921dddfe10f6ee5f73eb1b917381c2c30.tar.gz opensim-SC_OLD-3e4b094921dddfe10f6ee5f73eb1b917381c2c30.tar.bz2 opensim-SC_OLD-3e4b094921dddfe10f6ee5f73eb1b917381c2c30.tar.xz |
* Implements terrain raw upload. You can now upload your .raw terrain files using the Estate Tools.
* Could this be extended in the future to support .oar uploads too? Only time will tell!
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs index 52175f4..4aad3b1 100644 --- a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs | |||
@@ -45,6 +45,8 @@ namespace OpenSim.Region.Environment.Modules.World.Estate | |||
45 | 45 | ||
46 | private Scene m_scene; | 46 | private Scene m_scene; |
47 | 47 | ||
48 | private EstateTerrainXferHandler TerrainUploader = null; | ||
49 | |||
48 | #region Packet Data Responders | 50 | #region Packet Data Responders |
49 | 51 | ||
50 | private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) | 52 | private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) |
@@ -420,7 +422,119 @@ namespace OpenSim.Region.Environment.Modules.World.Estate | |||
420 | } | 422 | } |
421 | } | 423 | } |
422 | } | 424 | } |
425 | private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID) | ||
426 | { | ||
427 | if (TerrainUploader != null) | ||
428 | { | ||
429 | lock (TerrainUploader) | ||
430 | { | ||
431 | if (XferID == TerrainUploader.XferID) | ||
432 | { | ||
433 | remoteClient.OnXferReceive -= TerrainUploader.XferReceive; | ||
434 | remoteClient.OnAbortXfer -= AbortTerrainXferHandler; | ||
435 | TerrainUploader.TerrainUploadDone -= HandleTerrainApplication; | ||
436 | |||
437 | TerrainUploader = null; | ||
438 | remoteClient.SendAlertMessage("Terrain Upload aborted by the client"); | ||
439 | } | ||
440 | } | ||
441 | } | ||
442 | |||
443 | } | ||
444 | private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient) | ||
445 | { | ||
446 | lock (TerrainUploader) | ||
447 | { | ||
448 | remoteClient.OnXferReceive -= TerrainUploader.XferReceive; | ||
449 | remoteClient.OnAbortXfer -= AbortTerrainXferHandler; | ||
450 | TerrainUploader.TerrainUploadDone -= HandleTerrainApplication; | ||
451 | |||
452 | TerrainUploader = null; | ||
453 | } | ||
454 | remoteClient.SendAlertMessage("Terrain Upload Complete. Loading...."); | ||
455 | OpenSim.Region.Environment.Modules.World.Terrain.ITerrainModule terr = m_scene.RequestModuleInterface<OpenSim.Region.Environment.Modules.World.Terrain.ITerrainModule>(); | ||
456 | |||
457 | if (terr != null) | ||
458 | { | ||
459 | m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName); | ||
460 | if (System.IO.File.Exists(Util.dataDir() + "/terrain.raw")) | ||
461 | { | ||
462 | System.IO.File.Delete(Util.dataDir() + "/terrain.raw"); | ||
463 | } | ||
464 | try | ||
465 | { | ||
466 | System.IO.FileStream input = new System.IO.FileStream(Util.dataDir() + "/terrain.raw", System.IO.FileMode.CreateNew); | ||
467 | input.Write(terrainData, 0, terrainData.Length); | ||
468 | input.Close(); | ||
469 | } | ||
470 | catch (System.IO.IOException e) | ||
471 | { | ||
472 | m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString()); | ||
473 | remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space"); | ||
474 | |||
475 | return; | ||
476 | } | ||
477 | catch (System.Security.SecurityException e) | ||
478 | { | ||
479 | m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString()); | ||
480 | remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive"); | ||
481 | |||
482 | return; | ||
483 | } | ||
484 | catch (System.UnauthorizedAccessException e) | ||
485 | { | ||
486 | 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 a security Exception loading your terrain. Please check the security on the simulator drive"); | ||
423 | 488 | ||
489 | return; | ||
490 | } | ||
491 | |||
492 | |||
493 | |||
494 | |||
495 | try | ||
496 | { | ||
497 | terr.LoadFromFile(Util.dataDir() + "/terrain.raw"); | ||
498 | remoteClient.SendAlertMessage("Your terrain was loaded. Give it a minute or two to apply"); | ||
499 | } | ||
500 | catch (Exception e) | ||
501 | { | ||
502 | m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString()); | ||
503 | remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again"); | ||
504 | } | ||
505 | |||
506 | } | ||
507 | else | ||
508 | { | ||
509 | remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module"); | ||
510 | } | ||
511 | |||
512 | |||
513 | |||
514 | } | ||
515 | |||
516 | private void handleUploadTerrain(IClientAPI remote_client, string clientFileName) | ||
517 | { | ||
518 | |||
519 | if (TerrainUploader == null) | ||
520 | { | ||
521 | |||
522 | TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName); | ||
523 | lock (TerrainUploader) | ||
524 | { | ||
525 | remote_client.OnXferReceive += TerrainUploader.XferReceive; | ||
526 | remote_client.OnAbortXfer += AbortTerrainXferHandler; | ||
527 | TerrainUploader.TerrainUploadDone += HandleTerrainApplication; | ||
528 | } | ||
529 | TerrainUploader.RequestStartXfer(remote_client); | ||
530 | |||
531 | } | ||
532 | else | ||
533 | { | ||
534 | remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!"); | ||
535 | } | ||
536 | |||
537 | } | ||
424 | private void handleTerrainRequest(IClientAPI remote_client, string clientFileName) | 538 | private void handleTerrainRequest(IClientAPI remote_client, string clientFileName) |
425 | { | 539 | { |
426 | // Save terrain here | 540 | // Save terrain here |
@@ -793,6 +907,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate | |||
793 | client.OnEstateTeleportOneUserHomeRequest += handleEstateTeleportOneUserHomeRequest; | 907 | client.OnEstateTeleportOneUserHomeRequest += handleEstateTeleportOneUserHomeRequest; |
794 | client.OnEstateTeleportAllUsersHomeRequest += handleEstateTeleportAllUsersHomeRequest; | 908 | client.OnEstateTeleportAllUsersHomeRequest += handleEstateTeleportAllUsersHomeRequest; |
795 | client.OnRequestTerrain += handleTerrainRequest; | 909 | client.OnRequestTerrain += handleTerrainRequest; |
910 | client.OnUploadTerrain += handleUploadTerrain; | ||
796 | 911 | ||
797 | client.OnRegionInfoRequest += HandleRegionInfoRequest; | 912 | client.OnRegionInfoRequest += HandleRegionInfoRequest; |
798 | client.OnEstateCovenantRequest += HandleEstateCovenantRequest; | 913 | client.OnEstateCovenantRequest += HandleEstateCovenantRequest; |