diff options
author | Justin Clark-Casey (justincc) | 2009-12-04 18:26:58 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2009-12-04 18:26:58 +0000 |
commit | c0f3a4c8332f235e998714214011c5412bdcacf0 (patch) | |
tree | 78838e69a71b5a3d76d320161ba89111d156665a | |
parent | * Clarifies that the PrimMaxPhys in OpenSim.ini.example does nothing. Tells ... (diff) | |
download | opensim-SC_OLD-c0f3a4c8332f235e998714214011c5412bdcacf0.zip opensim-SC_OLD-c0f3a4c8332f235e998714214011c5412bdcacf0.tar.gz opensim-SC_OLD-c0f3a4c8332f235e998714214011c5412bdcacf0.tar.bz2 opensim-SC_OLD-c0f3a4c8332f235e998714214011c5412bdcacf0.tar.xz |
Allow terrain heightmaps to be loaded directly from URIs via the remote admin plugin
See http://opensimulator.org/mantis/view.php?id=4418
Thanks StrawberryFride
See
4 files changed, 53 insertions, 4 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 3149eaa..adf7967 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -315,8 +315,21 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
315 | 315 | ||
316 | ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>(); | 316 | ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>(); |
317 | if (null == terrainModule) throw new Exception("terrain module not available"); | 317 | if (null == terrainModule) throw new Exception("terrain module not available"); |
318 | terrainModule.LoadFromFile(file); | 318 | if (Uri.IsWellFormedUriString(file, UriKind.Absolute)) |
319 | 319 | { | |
320 | m_log.Info("[RADMIN]: Terrain path is URL"); | ||
321 | Uri result; | ||
322 | if (Uri.TryCreate(file, UriKind.RelativeOrAbsolute, out result)) | ||
323 | { | ||
324 | // the url is valid | ||
325 | string fileType = file.Substring(file.LastIndexOf('/') + 1); | ||
326 | terrainModule.LoadFromStream(fileType, result); | ||
327 | } | ||
328 | } | ||
329 | else | ||
330 | { | ||
331 | terrainModule.LoadFromFile(file); | ||
332 | } | ||
320 | responseData["success"] = false; | 333 | responseData["success"] = false; |
321 | 334 | ||
322 | response.Value = responseData; | 335 | response.Value = responseData; |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index ba271fd..a40828b 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Net; | ||
32 | using log4net; | 33 | using log4net; |
33 | using Nini.Config; | 34 | using Nini.Config; |
34 | using OpenMetaverse; | 35 | using OpenMetaverse; |
@@ -259,6 +260,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
259 | } | 260 | } |
260 | 261 | ||
261 | /// <summary> | 262 | /// <summary> |
263 | /// Loads a terrain file from the specified URI | ||
264 | /// </summary> | ||
265 | /// <param name="filename">The name of the terrain to load</param> | ||
266 | /// <param name="pathToTerrainHeightmap">The URI to the terrain height map</param> | ||
267 | public void LoadFromStream(string filename, Uri pathToTerrainHeightmap) | ||
268 | { | ||
269 | LoadFromStream(filename, URIFetch(pathToTerrainHeightmap)); | ||
270 | } | ||
271 | |||
272 | /// <summary> | ||
262 | /// Loads a terrain file from a stream and installs it in the scene. | 273 | /// Loads a terrain file from a stream and installs it in the scene. |
263 | /// </summary> | 274 | /// </summary> |
264 | /// <param name="filename">Filename to terrain file. Type is determined by extension.</param> | 275 | /// <param name="filename">Filename to terrain file. Type is determined by extension.</param> |
@@ -267,7 +278,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
267 | { | 278 | { |
268 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | 279 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) |
269 | { | 280 | { |
270 | if (@filename.EndsWith(loader.Key)) | 281 | if (filename.EndsWith(loader.Key)) |
271 | { | 282 | { |
272 | lock (m_scene) | 283 | lock (m_scene) |
273 | { | 284 | { |
@@ -295,6 +306,25 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
295 | throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); | 306 | throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename)); |
296 | } | 307 | } |
297 | 308 | ||
309 | private static Stream URIFetch(Uri uri) | ||
310 | { | ||
311 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | ||
312 | |||
313 | // request.Credentials = credentials; | ||
314 | |||
315 | request.ContentLength = 0; | ||
316 | request.KeepAlive = false; | ||
317 | |||
318 | WebResponse response = request.GetResponse(); | ||
319 | Stream file = response.GetResponseStream(); | ||
320 | |||
321 | if (response.ContentLength == 0) | ||
322 | throw new Exception(String.Format("{0} returned an empty file", uri.ToString())); | ||
323 | |||
324 | // return new BufferedStream(file, (int) response.ContentLength); | ||
325 | return new BufferedStream(file, 1000000); | ||
326 | } | ||
327 | |||
298 | /// <summary> | 328 | /// <summary> |
299 | /// Modify Land | 329 | /// Modify Land |
300 | /// </summary> | 330 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs index 2dcba0c..7caac55 100644 --- a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
51 | /// </param> | 51 | /// </param> |
52 | /// <param name="stream"></param> | 52 | /// <param name="stream"></param> |
53 | void LoadFromStream(string filename, Stream stream); | 53 | void LoadFromStream(string filename, Stream stream); |
54 | 54 | void LoadFromStream(string filename, System.Uri pathToTerrainHeightmap); | |
55 | /// <summary> | 55 | /// <summary> |
56 | /// Save a terrain to a stream. | 56 | /// Save a terrain to a stream. |
57 | /// </summary> | 57 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 09d02f4..0b0c205 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -2393,6 +2393,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2393 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 2393 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); |
2394 | item = InventoryService.GetItem(item); | 2394 | item = InventoryService.GetItem(item); |
2395 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); | 2395 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); |
2396 | |||
2397 | if (m_AvatarFactory != null) | ||
2398 | { | ||
2399 | m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
2400 | } | ||
2401 | |||
2396 | } | 2402 | } |
2397 | } | 2403 | } |
2398 | 2404 | ||