From b8197719196a89236a57382d6c869d9962022992 Mon Sep 17 00:00:00 2001 From: Michelle Argus Date: Fri, 21 Oct 2011 23:12:01 +0100 Subject: [PATCH] RemoteAdmin - Added optional terrain loading on region create using parameter heightmap_file to specify the terrain file to be loaded --- .../RemoteController/RemoteAdminPlugin.cs | 62 ++++++++++++------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 19914273c1..2c1568690c 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -329,28 +329,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController responseData["accepted"] = true; - Scene region = null; + LoadHeightmap(file, regionID); - if (!m_application.SceneManager.TryGetScene(regionID, out region)) - throw new Exception("1: unable to get a scene with that name"); - - ITerrainModule terrainModule = region.RequestModuleInterface(); - if (null == terrainModule) throw new Exception("terrain module not available"); - if (Uri.IsWellFormedUriString(file, UriKind.Absolute)) - { - m_log.Info("[RADMIN]: Terrain path is URL"); - Uri result; - if (Uri.TryCreate(file, UriKind.RelativeOrAbsolute, out result)) - { - // the url is valid - string fileType = file.Substring(file.LastIndexOf('/') + 1); - terrainModule.LoadFromStream(fileType, result); - } - } - else - { - terrainModule.LoadFromFile(file); - } responseData["success"] = false; response.Value = responseData; @@ -793,6 +773,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController } } + //Load Heightmap if specified to new region + if (requestData.Contains("heightmap_file")) + { + LoadHeightmap((string)requestData["heightmap_file"], region.RegionID); + } + responseData["success"] = true; responseData["region_name"] = region.RegionName; responseData["region_uuid"] = region.RegionID.ToString(); @@ -3158,5 +3144,39 @@ namespace OpenSim.ApplicationPlugins.RemoteController return false; } } + private bool LoadHeightmap(string file, UUID regionID) + { + m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); + + Scene region = null; + + if (!m_application.SceneManager.TryGetScene(regionID, out region)) + { + m_log.InfoFormat("[RADMIN]: unable to get a scene with that name: {0}", regionID.ToString()); + return false; + } + + ITerrainModule terrainModule = region.RequestModuleInterface(); + if (null == terrainModule) throw new Exception("terrain module not available"); + if (Uri.IsWellFormedUriString(file, UriKind.Absolute)) + { + m_log.Info("[RADMIN]: Terrain path is URL"); + Uri result; + if (Uri.TryCreate(file, UriKind.RelativeOrAbsolute, out result)) + { + // the url is valid + string fileType = file.Substring(file.LastIndexOf('/') + 1); + terrainModule.LoadFromStream(fileType, result); + } + } + else + { + terrainModule.LoadFromFile(file); + } + + m_log.Info("[RADMIN]: Load height maps request complete"); + + return true; + } } }