From fe82471c2b5ad15ff95aabb1ac18ffa4e5f83b72 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 12 Nov 2009 19:42:35 +0000 Subject: [PATCH] Apply patch http://opensimulator.org/mantis/view.php?id=4369 Adds osGetMapTexture() and osGetRegionMapTexture() methods to retrieve region map texture uuids --- .../Shared/Api/Implementation/OSSL_Api.cs | 75 ++++++++++++++----- .../Shared/Api/Interface/IOSSL_Api.cs | 10 ++- .../Shared/Api/Runtime/OSSL_Stub.cs | 28 ++++--- 3 files changed, 81 insertions(+), 32 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index f7ee3d99ab..3ffcff0806 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -199,7 +199,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //Dumps an error message on the debug console. // - internal void OSSLShoutError(string message) + internal void OSSLShoutError(string message) { if (message.Length > 1023) message = message.Substring(0, 1023); @@ -1176,7 +1176,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api land.SetMediaUrl(url); } - + public void osSetParcelSIPAddress(string SIPAddress) { // What actually is the difference to the LL function? @@ -1184,7 +1184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL"); m_host.AddScriptLPS(1); - + ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); @@ -1194,16 +1194,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api OSSLError("osSetParcelSIPAddress: Sorry, you need to own the land to use this function"); return; } - + // get the voice module IVoiceModule voiceModule = World.RequestModuleInterface(); - - if (voiceModule != null) + + if (voiceModule != null) voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); else OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); - - + + } public string osGetScriptEngineName() @@ -1525,10 +1525,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } - /*Instead of using the LSL Dataserver event to pull notecard data, + /*Instead of using the LSL Dataserver event to pull notecard data, this will simply read the requested line and return its data as a string. - - Warning - due to the synchronous method this function uses to fetch assets, its use + + Warning - due to the synchronous method this function uses to fetch assets, its use may be dangerous and unreliable while running in grid mode. */ public string osGetNotecardLine(string name, int line) @@ -1576,10 +1576,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } - /*Instead of using the LSL Dataserver event to pull notecard data line by line, + /*Instead of using the LSL Dataserver event to pull notecard data line by line, this will simply read the entire notecard and return its data as a string. - - Warning - due to the synchronous method this function uses to fetch assets, its use + + Warning - due to the synchronous method this function uses to fetch assets, its use may be dangerous and unreliable while running in grid mode. */ @@ -1634,10 +1634,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } - /*Instead of using the LSL Dataserver event to pull notecard data, + /*Instead of using the LSL Dataserver event to pull notecard data, this will simply read the number of note card lines and return this data as an integer. - - Warning - due to the synchronous method this function uses to fetch assets, its use + + Warning - due to the synchronous method this function uses to fetch assets, its use may be dangerous and unreliable while running in grid mode. */ @@ -1837,7 +1837,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return World.RegionInfo.RegionSettings.LoadedCreationID; } - + // Threat level is 'Low' because certain users could possibly be tricked into // dropping an unverified script into one of their own objects, which could // then gather the physical construction details of the object and transmit it @@ -1861,7 +1861,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); - //QueueUserWorkItem + //QueueUserWorkItem INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -1910,5 +1910,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api module.DeleteNPC(new UUID(npc.m_string), World); } } + + /// + /// Get current region's map texture UUID + /// + /// + public LSL_Key osGetMapTexture() + { + CheckThreatLevel(ThreatLevel.None, "osGetMapTexture"); + return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString(); + } + + /// + /// Get a region's map texture UUID by region UUID or name. + /// + /// + /// + public LSL_Key osGetRegionMapTexture(string regionName) + { + CheckThreatLevel(ThreatLevel.High, "osGetRegionMapTexture"); + Scene scene = m_ScriptEngine.World; + UUID key = UUID.Zero; + GridRegion region; + + //If string is a key, use it. Otherwise, try to locate region by name. + if (UUID.TryParse(regionName, out key)) + region = scene.GridService.GetRegionByUUID(UUID.Zero, key); + else + region = scene.GridService.GetRegionByName(UUID.Zero, regionName); + + // If region was found, return the regions map texture key. + if (region != null) + key = region.TerrainImage; + + ScriptSleep(1000); + + return key.ToString(); + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index d8d3c31dd4..2a403bf0fe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -79,7 +79,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces // Avatar Info Commands string osGetAgentIP(string agent); - LSL_List osGetAgents(); + LSL_List osGetAgents(); // Teleport commands void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); @@ -127,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osGetScriptEngineName(); string osGetSimulatorVersion(); Hashtable osParseJSON(string JSON); - + void osMessageObject(key objectUUID,string message); void osMakeNotecard(string notecardName, LSL_Types.list contents); @@ -138,7 +138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osAvatarName2Key(string firstname, string lastname); string osKey2Name(string id); - + // Grid Info Functions string osGetGridNick(); string osGetGridName(); @@ -151,7 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osLoadedCreationDate(); string osLoadedCreationTime(); string osLoadedCreationID(); - + LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); @@ -160,5 +160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osNpcSay(key npc, string message); void osNpcRemove(key npc); + key osGetMapTexture(); + key osGetRegionMapTexture(string regionName); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 8dcb1f5c02..4928e904b3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -94,7 +94,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osWindActiveModelPluginName(); } - + // Not yet plugged in as available OSSL functions, so commented out // void osWindParamSet(string plugin, string param, float value) // { @@ -138,14 +138,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, bool blend, int disp, int timer, int alpha, int face) { - return m_OSSL_Functions.osSetDynamicTextureURLBlendFace(dynamicID, contentType, url, extraParams, + return m_OSSL_Functions.osSetDynamicTextureURLBlendFace(dynamicID, contentType, url, extraParams, blend, disp, timer, alpha, face); } public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, bool blend, int disp, int timer, int alpha, int face) { - return m_OSSL_Functions.osSetDynamicTextureDataBlendFace(dynamicID, contentType, data, extraParams, + return m_OSSL_Functions.osSetDynamicTextureDataBlendFace(dynamicID, contentType, data, extraParams, blend, disp, timer, alpha, face); } @@ -183,7 +183,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { m_OSSL_Functions.osSetParcelMediaURL(url); } - + public void osSetParcelSIPAddress(string SIPAddress) { m_OSSL_Functions.osSetParcelSIPAddress(SIPAddress); @@ -211,7 +211,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osTeleportAgent(agent, position, lookat); } - // Avatar info functions + // Avatar info functions public string osGetAgentIP(string agent) { return m_OSSL_Functions.osGetAgentIP(agent); @@ -326,17 +326,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osGetScriptEngineName(); } - + public string osGetSimulatorVersion() { return m_OSSL_Functions.osGetSimulatorVersion(); } - + public Hashtable osParseJSON(string JSON) { return m_OSSL_Functions.osParseJSON(JSON); } - + public void osMessageObject(key objectUUID,string message) { m_OSSL_Functions.osMessageObject(objectUUID,message); @@ -412,7 +412,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osLoadedCreationID(); } - + public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) { return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules); @@ -622,5 +622,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase } } } + + public key osGetMapTexture() + { + return m_OSSL_Functions.osGetMapTexture(); + } + + public key osGetRegionMapTexture(string regionName) + { + return m_OSSL_Functions.osGetRegionMapTexture(regionName); + } } }