From d1457001150d7af6faf2a11e59b895320c6e3e9b Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 10 Nov 2008 23:56:58 +0000 Subject: * Commit allows downloading of the .raw terrain from the estate tools. * Implements the SendInitiateDownload method in IClientAPI * Uses the ITerrainModule Interface to write a terrain file to disk then uses a FileStream to read the binary file from the disk and put it in a byte array. and save to the xFer list. * It then tells the client to download the file and the client initiates an Xfer request. --- .../Environment/Modules/Agent/Xfer/XferModule.cs | 1 + .../Modules/World/Estate/EstateManagementModule.cs | 26 ++++++++++++++++++++++ .../Environment/Modules/World/NPC/NPCAvatar.cs | 6 ++++- 3 files changed, 32 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs index 3c69621..2f9a691 100644 --- a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs @@ -105,6 +105,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer /// public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) { + lock (NewFiles) { if (NewFiles.ContainsKey(fileName)) diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs index 041bba5..c38d502 100644 --- a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs @@ -421,6 +421,31 @@ namespace OpenSim.Region.Environment.Modules.World.Estate } } + private void handleTerrainRequest(IClientAPI remote_client, string clientFileName) + { + // Save terrain here + OpenSim.Region.Environment.Modules.World.Terrain.ITerrainModule terr = m_scene.RequestModuleInterface(); + + if (terr != null) + { + m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName); + if (System.IO.File.Exists(Util.dataDir() + "/terrain.raw")) + { + System.IO.File.Delete(Util.dataDir() + "/terrain.raw"); + } + terr.SaveToFile(Util.dataDir() + "/terrain.raw"); + + System.IO.FileStream input = new System.IO.FileStream(Util.dataDir() + "/terrain.raw", System.IO.FileMode.Open); + byte[] bdata = new byte[input.Length]; + input.Read(bdata, 0, (int)input.Length); + remote_client.SendAlertMessage("Terrain file written, starting download..."); + m_scene.XferManager.AddNewFile("terrain.raw", bdata); + // Tell client about it + m_log.Warn("[CLIENT]: Sending Terrain to " + remote_client.Name); + remote_client.SendInitiateDownload("terrain.raw", clientFileName); + } + } + private void HandleRegionInfoRequest(IClientAPI remote_client) { @@ -767,6 +792,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate client.OnEstateDebugRegionRequest += handleEstateDebugRegionRequest; client.OnEstateTeleportOneUserHomeRequest += handleEstateTeleportOneUserHomeRequest; client.OnEstateTeleportAllUsersHomeRequest += handleEstateTeleportAllUsersHomeRequest; + client.OnRequestTerrain += handleTerrainRequest; client.OnRegionInfoRequest += HandleRegionInfoRequest; client.OnEstateCovenantRequest += HandleEstateCovenantRequest; diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index cf8ba94..7b077ec 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs @@ -268,7 +268,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC public event ObjectDeselect OnObjectDeselect; public event RegionInfoRequest OnRegionInfoRequest; public event EstateCovenantRequest OnEstateCovenantRequest; - + public event RequestTerrain OnRequestTerrain; public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; public event FriendActionDelegate OnApproveFriendRequest; @@ -698,6 +698,10 @@ namespace OpenSim.Region.Environment.Modules.World.NPC { } + public void SendInitiateDownload(string simFileName, string clientFileName) + { + } + public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec) { } -- cgit v1.1