From a1f05a289dd845edb7e3d163b84ceecc85374427 Mon Sep 17 00:00:00 2001 From: Michelle Argus Date: Fri, 21 Oct 2011 23:12:01 +0100 Subject: 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(-) (limited to 'OpenSim/ApplicationPlugins/RemoteController') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 4319fa0..a634f1c 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; + } } } \ No newline at end of file -- cgit v1.1