From 6c6527caae77715f32c3cffe0adb7bc774fb8e97 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 7 Aug 2009 21:51:03 +0100 Subject: Thank you, Godfrey, for a patch that implements osGetLinkPrimitiveParams Fixes Mantis #3979 Applied with changes. Changed ThreatLevel to High since all discovery functions are a high threat. Overriding that is the responsibility of the grid owner. --- .../Shared/Api/Implementation/LSL_Api.cs | 47 ++++++++++++---------- .../Shared/Api/Implementation/OSSL_Api.cs | 20 +++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++ 4 files changed, 53 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5f9b09b..b855a1a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -217,7 +217,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - protected List GetLinkParts(int linkType) + public List GetLinkParts(int linkType) { List ret = new List(); ret.Add(m_host); @@ -4172,7 +4172,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // this function to understand which shape it is (taken from meshmerizer) // quite useful can be used by meshmerizer to have a centralized point of understanding the shape // except that it refers to scripting constants - protected int getScriptPrimType(PrimitiveBaseShape primShape) + public int getScriptPrimType(PrimitiveBaseShape primShape) { if (primShape.SculptEntry) return ScriptBaseClass.PRIM_TYPE_SCULPT; @@ -7246,6 +7246,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetPrimitiveParams(LSL_List rules) { m_host.AddScriptLPS(1); + return GetLinkPrimitiveParams( m_host, rules ); + } + + public LSL_List GetLinkPrimitiveParams( SceneObjectPart part, LSL_List rules ) + { LSL_List res = new LSL_List(); int idx=0; @@ -7257,40 +7262,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api switch (code) { case (int)ScriptBaseClass.PRIM_MATERIAL: - res.Add(new LSL_Integer(m_host.Material)); + res.Add(new LSL_Integer(part.Material)); break; case (int)ScriptBaseClass.PRIM_PHYSICS: - if ((m_host.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) != 0) + if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) != 0) res.Add(new LSL_Integer(1)); else res.Add(new LSL_Integer(0)); break; case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: - if ((m_host.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) != 0) + if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) != 0) res.Add(new LSL_Integer(1)); else res.Add(new LSL_Integer(0)); break; case (int)ScriptBaseClass.PRIM_PHANTOM: - if ((m_host.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0) + if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0) res.Add(new LSL_Integer(1)); else res.Add(new LSL_Integer(0)); break; case (int)ScriptBaseClass.PRIM_POSITION: - res.Add(new LSL_Vector(m_host.AbsolutePosition.X, - m_host.AbsolutePosition.Y, - m_host.AbsolutePosition.Z)); + res.Add(new LSL_Vector(part.AbsolutePosition.X, + part.AbsolutePosition.Y, + part.AbsolutePosition.Z)); break; case (int)ScriptBaseClass.PRIM_SIZE: - res.Add(new LSL_Vector(m_host.Scale.X, - m_host.Scale.Y, - m_host.Scale.Z)); + res.Add(new LSL_Vector(part.Scale.X, + part.Scale.Y, + part.Scale.Z)); break; case (int)ScriptBaseClass.PRIM_ROTATION: @@ -7299,8 +7304,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE: // implementing box - PrimitiveBaseShape Shape = m_host.Shape; - int primType = getScriptPrimType(m_host.Shape); + PrimitiveBaseShape Shape = part.Shape; + int primType = getScriptPrimType(part.Shape); res.Add(new LSL_Integer(primType)); switch (primType) { @@ -7372,10 +7377,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return res; int face = (int)rules.GetLSLIntegerItem(idx++); - Primitive.TextureEntry tex = m_host.Shape.Textures; + Primitive.TextureEntry tex = part.Shape.Textures; if (face == ScriptBaseClass.ALL_SIDES) { - for (face = 0 ; face < GetNumberOfSides(m_host) ; face++) + for (face = 0 ; face < GetNumberOfSides(part) ; face++) { Primitive.TextureEntryFace texface = tex.GetFace((uint)face); @@ -7391,7 +7396,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else { - if (face >= 0 && face < GetNumberOfSides(m_host)) + if (face >= 0 && face < GetNumberOfSides(part)) { Primitive.TextureEntryFace texface = tex.GetFace((uint)face); @@ -7413,11 +7418,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api face=(int)rules.GetLSLIntegerItem(idx++); - tex = m_host.Shape.Textures; + tex = part.Shape.Textures; Color4 texcolor; if (face == ScriptBaseClass.ALL_SIDES) { - for (face = 0 ; face < GetNumberOfSides(m_host) ; face++) + for (face = 0 ; face < GetNumberOfSides(part) ; face++) { texcolor = tex.GetFace((uint)face).RGBA; res.Add(new LSL_Vector(texcolor.R, @@ -7458,7 +7463,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_FLEXIBLE: - PrimitiveBaseShape shape = m_host.Shape; + PrimitiveBaseShape shape = part.Shape; if (shape.FlexiEntry) res.Add(new LSL_Integer(1)); // active @@ -7486,7 +7491,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_POINT_LIGHT: - shape = m_host.Shape; + shape = part.Shape; if (shape.LightEntry) res.Add(new LSL_Integer(1)); // active diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index bf86eeb..fd4ba71 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1740,6 +1740,26 @@ 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 + // to an unscrupulous third party, thus permitting unauthorized duplication of + // the object's form. + // + public LSL_List osGetLinkPrimitiveParams( int linknumber, LSL_List rules ) + { + CheckThreatLevel( ThreatLevel.High, "osGetLinkPrimitiveParams" ); + m_host.AddScriptLPS( 1 ); + InitLSL(); + LSL_List retVal = new LSL_List(); + List parts = ((LSL_Api)m_LSL_Api).GetLinkParts( linknumber ); + foreach (SceneObjectPart part in parts) + { + retVal += ((LSL_Api)m_LSL_Api).GetLinkPrimitiveParams( part, rules ); + } + return retVal; + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index debbad6..23e03e2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -146,6 +146,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osLoadedCreationDate(); string osLoadedCreationTime(); string osLoadedCreationID(); + + LSL_List osGetLinkPrimitiveParams( int linknumber, LSL_List rules ); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 193e2e0..2408129 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -386,6 +386,11 @@ 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 ); + } public OSSLPrim Prim; -- cgit v1.1