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.
arthursv
Melanie 2009-08-07 21:51:03 +01:00
parent ad0d2fea20
commit 6c6527caae
4 changed files with 53 additions and 21 deletions

View File

@ -217,7 +217,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
protected List<SceneObjectPart> GetLinkParts(int linkType) public List<SceneObjectPart> GetLinkParts(int linkType)
{ {
List<SceneObjectPart> ret = new List<SceneObjectPart>(); List<SceneObjectPart> ret = new List<SceneObjectPart>();
ret.Add(m_host); 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) // 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 // quite useful can be used by meshmerizer to have a centralized point of understanding the shape
// except that it refers to scripting constants // except that it refers to scripting constants
protected int getScriptPrimType(PrimitiveBaseShape primShape) public int getScriptPrimType(PrimitiveBaseShape primShape)
{ {
if (primShape.SculptEntry) if (primShape.SculptEntry)
return ScriptBaseClass.PRIM_TYPE_SCULPT; return ScriptBaseClass.PRIM_TYPE_SCULPT;
@ -7246,6 +7246,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_List llGetPrimitiveParams(LSL_List rules) public LSL_List llGetPrimitiveParams(LSL_List rules)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
return GetLinkPrimitiveParams( m_host, rules );
}
public LSL_List GetLinkPrimitiveParams( SceneObjectPart part, LSL_List rules )
{
LSL_List res = new LSL_List(); LSL_List res = new LSL_List();
int idx=0; int idx=0;
@ -7257,40 +7262,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
switch (code) switch (code)
{ {
case (int)ScriptBaseClass.PRIM_MATERIAL: case (int)ScriptBaseClass.PRIM_MATERIAL:
res.Add(new LSL_Integer(m_host.Material)); res.Add(new LSL_Integer(part.Material));
break; break;
case (int)ScriptBaseClass.PRIM_PHYSICS: 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)); res.Add(new LSL_Integer(1));
else else
res.Add(new LSL_Integer(0)); res.Add(new LSL_Integer(0));
break; break;
case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: 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)); res.Add(new LSL_Integer(1));
else else
res.Add(new LSL_Integer(0)); res.Add(new LSL_Integer(0));
break; break;
case (int)ScriptBaseClass.PRIM_PHANTOM: 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)); res.Add(new LSL_Integer(1));
else else
res.Add(new LSL_Integer(0)); res.Add(new LSL_Integer(0));
break; break;
case (int)ScriptBaseClass.PRIM_POSITION: case (int)ScriptBaseClass.PRIM_POSITION:
res.Add(new LSL_Vector(m_host.AbsolutePosition.X, res.Add(new LSL_Vector(part.AbsolutePosition.X,
m_host.AbsolutePosition.Y, part.AbsolutePosition.Y,
m_host.AbsolutePosition.Z)); part.AbsolutePosition.Z));
break; break;
case (int)ScriptBaseClass.PRIM_SIZE: case (int)ScriptBaseClass.PRIM_SIZE:
res.Add(new LSL_Vector(m_host.Scale.X, res.Add(new LSL_Vector(part.Scale.X,
m_host.Scale.Y, part.Scale.Y,
m_host.Scale.Z)); part.Scale.Z));
break; break;
case (int)ScriptBaseClass.PRIM_ROTATION: case (int)ScriptBaseClass.PRIM_ROTATION:
@ -7299,8 +7304,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TYPE: case (int)ScriptBaseClass.PRIM_TYPE:
// implementing box // implementing box
PrimitiveBaseShape Shape = m_host.Shape; PrimitiveBaseShape Shape = part.Shape;
int primType = getScriptPrimType(m_host.Shape); int primType = getScriptPrimType(part.Shape);
res.Add(new LSL_Integer(primType)); res.Add(new LSL_Integer(primType));
switch (primType) switch (primType)
{ {
@ -7372,10 +7377,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return res; return res;
int face = (int)rules.GetLSLIntegerItem(idx++); int face = (int)rules.GetLSLIntegerItem(idx++);
Primitive.TextureEntry tex = m_host.Shape.Textures; Primitive.TextureEntry tex = part.Shape.Textures;
if (face == ScriptBaseClass.ALL_SIDES) 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); Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
@ -7391,7 +7396,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
else else
{ {
if (face >= 0 && face < GetNumberOfSides(m_host)) if (face >= 0 && face < GetNumberOfSides(part))
{ {
Primitive.TextureEntryFace texface = tex.GetFace((uint)face); Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
@ -7413,11 +7418,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
face=(int)rules.GetLSLIntegerItem(idx++); face=(int)rules.GetLSLIntegerItem(idx++);
tex = m_host.Shape.Textures; tex = part.Shape.Textures;
Color4 texcolor; Color4 texcolor;
if (face == ScriptBaseClass.ALL_SIDES) 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; texcolor = tex.GetFace((uint)face).RGBA;
res.Add(new LSL_Vector(texcolor.R, res.Add(new LSL_Vector(texcolor.R,
@ -7458,7 +7463,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break; break;
case (int)ScriptBaseClass.PRIM_FLEXIBLE: case (int)ScriptBaseClass.PRIM_FLEXIBLE:
PrimitiveBaseShape shape = m_host.Shape; PrimitiveBaseShape shape = part.Shape;
if (shape.FlexiEntry) if (shape.FlexiEntry)
res.Add(new LSL_Integer(1)); // active res.Add(new LSL_Integer(1)); // active
@ -7486,7 +7491,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break; break;
case (int)ScriptBaseClass.PRIM_POINT_LIGHT: case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
shape = m_host.Shape; shape = part.Shape;
if (shape.LightEntry) if (shape.LightEntry)
res.Add(new LSL_Integer(1)); // active res.Add(new LSL_Integer(1)); // active

View File

@ -1741,5 +1741,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return World.RegionInfo.RegionSettings.LoadedCreationID; 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<SceneObjectPart> parts = ((LSL_Api)m_LSL_Api).GetLinkParts( linknumber );
foreach (SceneObjectPart part in parts)
{
retVal += ((LSL_Api)m_LSL_Api).GetLinkPrimitiveParams( part, rules );
}
return retVal;
}
} }
} }

View File

@ -147,5 +147,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
string osLoadedCreationTime(); string osLoadedCreationTime();
string osLoadedCreationID(); string osLoadedCreationID();
LSL_List osGetLinkPrimitiveParams( int linknumber, LSL_List rules );
} }
} }

View File

@ -387,6 +387,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_OSSL_Functions.osLoadedCreationID(); return m_OSSL_Functions.osLoadedCreationID();
} }
public LSL_List osGetLinkPrimitiveParams( int linknumber, LSL_List rules )
{
return m_OSSL_Functions.osGetLinkPrimitiveParams( linknumber, rules );
}
public OSSLPrim Prim; public OSSLPrim Prim;