Implementing PRIM_LINK_TARGET in a non-recursive fashion

0.7.4.1
SignpostMarv 2012-08-15 21:14:39 +01:00 committed by Justin Clark-Casey (justincc)
parent f37038013d
commit b714fb0c39
1 changed files with 74 additions and 49 deletions

View File

@ -243,33 +243,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
public List<SceneObjectPart> GetLinkParts(int linkType) public List<SceneObjectPart> GetLinkParts(int linkType)
{
return GetLinkParts(m_host, linkType);
}
private List<SceneObjectPart> GetLinkParts(SceneObjectPart part, int linkType)
{ {
List<SceneObjectPart> ret = new List<SceneObjectPart>(); List<SceneObjectPart> ret = new List<SceneObjectPart>();
ret.Add(m_host); ret.Add(part);
switch (linkType) switch (linkType)
{ {
case ScriptBaseClass.LINK_SET: case ScriptBaseClass.LINK_SET:
return new List<SceneObjectPart>(m_host.ParentGroup.Parts); return new List<SceneObjectPart>(part.ParentGroup.Parts);
case ScriptBaseClass.LINK_ROOT: case ScriptBaseClass.LINK_ROOT:
ret = new List<SceneObjectPart>(); ret = new List<SceneObjectPart>();
ret.Add(m_host.ParentGroup.RootPart); ret.Add(part.ParentGroup.RootPart);
return ret; return ret;
case ScriptBaseClass.LINK_ALL_OTHERS: case ScriptBaseClass.LINK_ALL_OTHERS:
ret = new List<SceneObjectPart>(m_host.ParentGroup.Parts); ret = new List<SceneObjectPart>(part.ParentGroup.Parts);
if (ret.Contains(m_host)) if (ret.Contains(part))
ret.Remove(m_host); ret.Remove(part);
return ret; return ret;
case ScriptBaseClass.LINK_ALL_CHILDREN: case ScriptBaseClass.LINK_ALL_CHILDREN:
ret = new List<SceneObjectPart>(m_host.ParentGroup.Parts); ret = new List<SceneObjectPart>(part.ParentGroup.Parts);
if (ret.Contains(m_host.ParentGroup.RootPart)) if (ret.Contains(part.ParentGroup.RootPart))
ret.Remove(m_host.ParentGroup.RootPart); ret.Remove(part.ParentGroup.RootPart);
return ret; return ret;
case ScriptBaseClass.LINK_THIS: case ScriptBaseClass.LINK_THIS:
@ -279,7 +284,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (linkType < 0) if (linkType < 0)
return new List<SceneObjectPart>(); return new List<SceneObjectPart>();
SceneObjectPart target = m_host.ParentGroup.GetLinkNumPart(linkType); SceneObjectPart target = part.ParentGroup.GetLinkNumPart(linkType);
if (target == null) if (target == null)
return new List<SceneObjectPart>(); return new List<SceneObjectPart>();
ret = new List<SceneObjectPart>(); ret = new List<SceneObjectPart>();
@ -7184,7 +7189,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetPrimitiveParams(LSL_List rules) public void llSetPrimitiveParams(LSL_List rules)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
SetPrimParams(m_host, rules);
setLinkPrimParams(ScriptBaseClass.LINK_THIS, rules);
ScriptSleep(200); ScriptSleep(200);
} }
@ -7209,11 +7215,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
List<SceneObjectPart> parts = GetLinkParts(linknumber); List<SceneObjectPart> parts = GetLinkParts(linknumber);
LSL_List remaining = null;
foreach (SceneObjectPart part in parts) foreach (SceneObjectPart part in parts)
SetPrimParams(part, rules); remaining = SetPrimParams(part, rules);
while(remaining != null && remaining.Length > 2)
{
linknumber = remaining.GetLSLIntegerItem(0);
rules = remaining.GetSublist(1,-1);
parts = GetLinkParts(linknumber);
foreach (SceneObjectPart part in parts)
remaining = SetPrimParams(part, rules);
}
} }
protected void SetPrimParams(SceneObjectPart part, LSL_List rules) protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules)
{ {
int idx = 0; int idx = 0;
@ -7236,7 +7254,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_POSITION: case (int)ScriptBaseClass.PRIM_POSITION:
case (int)ScriptBaseClass.PRIM_POS_LOCAL: case (int)ScriptBaseClass.PRIM_POS_LOCAL:
if (remain < 1) if (remain < 1)
return; return null;
v=rules.GetVector3Item(idx++); v=rules.GetVector3Item(idx++);
positionChanged = true; positionChanged = true;
@ -7245,7 +7263,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break; break;
case (int)ScriptBaseClass.PRIM_SIZE: case (int)ScriptBaseClass.PRIM_SIZE:
if (remain < 1) if (remain < 1)
return; return null;
v=rules.GetVector3Item(idx++); v=rules.GetVector3Item(idx++);
SetScale(part, v); SetScale(part, v);
@ -7253,7 +7271,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break; break;
case (int)ScriptBaseClass.PRIM_ROTATION: case (int)ScriptBaseClass.PRIM_ROTATION:
if (remain < 1) if (remain < 1)
return; return null;
LSL_Rotation q = rules.GetQuaternionItem(idx++); LSL_Rotation q = rules.GetQuaternionItem(idx++);
// try to let this work as in SL... // try to let this work as in SL...
@ -7273,7 +7291,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TYPE: case (int)ScriptBaseClass.PRIM_TYPE:
if (remain < 3) if (remain < 3)
return; return null;
code = (int)rules.GetLSLIntegerItem(idx++); code = (int)rules.GetLSLIntegerItem(idx++);
@ -7292,7 +7310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
case (int)ScriptBaseClass.PRIM_TYPE_BOX: case (int)ScriptBaseClass.PRIM_TYPE_BOX:
if (remain < 6) if (remain < 6)
return; return null;
face = (int)rules.GetLSLIntegerItem(idx++); face = (int)rules.GetLSLIntegerItem(idx++);
v = rules.GetVector3Item(idx++); // cut v = rules.GetVector3Item(idx++); // cut
@ -7307,7 +7325,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER:
if (remain < 6) if (remain < 6)
return; return null;
face = (int)rules.GetLSLIntegerItem(idx++); // holeshape face = (int)rules.GetLSLIntegerItem(idx++); // holeshape
v = rules.GetVector3Item(idx++); // cut v = rules.GetVector3Item(idx++); // cut
@ -7321,7 +7339,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TYPE_PRISM: case (int)ScriptBaseClass.PRIM_TYPE_PRISM:
if (remain < 6) if (remain < 6)
return; return null;
face = (int)rules.GetLSLIntegerItem(idx++); // holeshape face = (int)rules.GetLSLIntegerItem(idx++); // holeshape
v = rules.GetVector3Item(idx++); //cut v = rules.GetVector3Item(idx++); //cut
@ -7335,7 +7353,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: case (int)ScriptBaseClass.PRIM_TYPE_SPHERE:
if (remain < 5) if (remain < 5)
return; return null;
face = (int)rules.GetLSLIntegerItem(idx++); // holeshape face = (int)rules.GetLSLIntegerItem(idx++); // holeshape
v = rules.GetVector3Item(idx++); // cut v = rules.GetVector3Item(idx++); // cut
@ -7348,7 +7366,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TYPE_TORUS: case (int)ScriptBaseClass.PRIM_TYPE_TORUS:
if (remain < 11) if (remain < 11)
return; return null;
face = (int)rules.GetLSLIntegerItem(idx++); // holeshape face = (int)rules.GetLSLIntegerItem(idx++); // holeshape
v = rules.GetVector3Item(idx++); //cut v = rules.GetVector3Item(idx++); //cut
@ -7367,7 +7385,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TYPE_TUBE: case (int)ScriptBaseClass.PRIM_TYPE_TUBE:
if (remain < 11) if (remain < 11)
return; return null;
face = (int)rules.GetLSLIntegerItem(idx++); // holeshape face = (int)rules.GetLSLIntegerItem(idx++); // holeshape
v = rules.GetVector3Item(idx++); //cut v = rules.GetVector3Item(idx++); //cut
@ -7386,7 +7404,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TYPE_RING: case (int)ScriptBaseClass.PRIM_TYPE_RING:
if (remain < 11) if (remain < 11)
return; return null;
face = (int)rules.GetLSLIntegerItem(idx++); // holeshape face = (int)rules.GetLSLIntegerItem(idx++); // holeshape
v = rules.GetVector3Item(idx++); //cut v = rules.GetVector3Item(idx++); //cut
@ -7405,7 +7423,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: case (int)ScriptBaseClass.PRIM_TYPE_SCULPT:
if (remain < 2) if (remain < 2)
return; return null;
string map = rules.Data[idx++].ToString(); string map = rules.Data[idx++].ToString();
face = (int)rules.GetLSLIntegerItem(idx++); // type face = (int)rules.GetLSLIntegerItem(idx++); // type
@ -7417,7 +7435,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TEXTURE: case (int)ScriptBaseClass.PRIM_TEXTURE:
if (remain < 5) if (remain < 5)
return; return null;
face=(int)rules.GetLSLIntegerItem(idx++); face=(int)rules.GetLSLIntegerItem(idx++);
string tex=rules.Data[idx++].ToString(); string tex=rules.Data[idx++].ToString();
@ -7434,7 +7452,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_COLOR: case (int)ScriptBaseClass.PRIM_COLOR:
if (remain < 3) if (remain < 3)
return; return null;
face=(int)rules.GetLSLIntegerItem(idx++); face=(int)rules.GetLSLIntegerItem(idx++);
LSL_Vector color=rules.GetVector3Item(idx++); LSL_Vector color=rules.GetVector3Item(idx++);
@ -7447,7 +7465,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_FLEXIBLE: case (int)ScriptBaseClass.PRIM_FLEXIBLE:
if (remain < 7) if (remain < 7)
return; return null;
bool flexi = rules.GetLSLIntegerItem(idx++); bool flexi = rules.GetLSLIntegerItem(idx++);
int softness = rules.GetLSLIntegerItem(idx++); int softness = rules.GetLSLIntegerItem(idx++);
@ -7463,7 +7481,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_POINT_LIGHT: case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
if (remain < 5) if (remain < 5)
return; return null;
bool light = rules.GetLSLIntegerItem(idx++); bool light = rules.GetLSLIntegerItem(idx++);
LSL_Vector lightcolor = rules.GetVector3Item(idx++); LSL_Vector lightcolor = rules.GetVector3Item(idx++);
float intensity = (float)rules.GetLSLFloatItem(idx++); float intensity = (float)rules.GetLSLFloatItem(idx++);
@ -7476,7 +7494,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_GLOW: case (int)ScriptBaseClass.PRIM_GLOW:
if (remain < 2) if (remain < 2)
return; return null;
face = rules.GetLSLIntegerItem(idx++); face = rules.GetLSLIntegerItem(idx++);
float glow = (float)rules.GetLSLFloatItem(idx++); float glow = (float)rules.GetLSLFloatItem(idx++);
@ -7486,7 +7504,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_BUMP_SHINY: case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
if (remain < 3) if (remain < 3)
return; return null;
face = (int)rules.GetLSLIntegerItem(idx++); face = (int)rules.GetLSLIntegerItem(idx++);
int shiny = (int)rules.GetLSLIntegerItem(idx++); int shiny = (int)rules.GetLSLIntegerItem(idx++);
Bumpiness bump = (Bumpiness)(int)rules.GetLSLIntegerItem(idx++); Bumpiness bump = (Bumpiness)(int)rules.GetLSLIntegerItem(idx++);
@ -7497,7 +7515,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_FULLBRIGHT: case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
if (remain < 2) if (remain < 2)
return; return null;
face = rules.GetLSLIntegerItem(idx++); face = rules.GetLSLIntegerItem(idx++);
bool st = rules.GetLSLIntegerItem(idx++); bool st = rules.GetLSLIntegerItem(idx++);
SetFullBright(part, face , st); SetFullBright(part, face , st);
@ -7505,17 +7523,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_MATERIAL: case (int)ScriptBaseClass.PRIM_MATERIAL:
if (remain < 1) if (remain < 1)
return; return null;
int mat = rules.GetLSLIntegerItem(idx++); int mat = rules.GetLSLIntegerItem(idx++);
if (mat < 0 || mat > 7) if (mat < 0 || mat > 7)
return; return null;
part.Material = Convert.ToByte(mat); part.Material = Convert.ToByte(mat);
break; break;
case (int)ScriptBaseClass.PRIM_PHANTOM: case (int)ScriptBaseClass.PRIM_PHANTOM:
if (remain < 1) if (remain < 1)
return; return null;
string ph = rules.Data[idx++].ToString(); string ph = rules.Data[idx++].ToString();
m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1"));
@ -7524,7 +7542,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_PHYSICS: case (int)ScriptBaseClass.PRIM_PHYSICS:
if (remain < 1) if (remain < 1)
return; return null;
string phy = rules.Data[idx++].ToString(); string phy = rules.Data[idx++].ToString();
bool physics; bool physics;
@ -7538,7 +7556,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
if (remain < 1) if (remain < 1)
return; return null;
string temp = rules.Data[idx++].ToString(); string temp = rules.Data[idx++].ToString();
m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1"));
@ -7547,7 +7565,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TEXGEN: case (int)ScriptBaseClass.PRIM_TEXGEN:
if (remain < 2) if (remain < 2)
return; return null;
//face,type //face,type
face = rules.GetLSLIntegerItem(idx++); face = rules.GetLSLIntegerItem(idx++);
int style = rules.GetLSLIntegerItem(idx++); int style = rules.GetLSLIntegerItem(idx++);
@ -7555,7 +7573,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break; break;
case (int)ScriptBaseClass.PRIM_TEXT: case (int)ScriptBaseClass.PRIM_TEXT:
if (remain < 3) if (remain < 3)
return; return null;
string primText = rules.GetLSLStringItem(idx++); string primText = rules.GetLSLStringItem(idx++);
LSL_Vector primTextColor = rules.GetVector3Item(idx++); LSL_Vector primTextColor = rules.GetVector3Item(idx++);
LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++);
@ -7567,25 +7585,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break; break;
case (int)ScriptBaseClass.PRIM_NAME: case (int)ScriptBaseClass.PRIM_NAME:
if (remain < 1) if (remain < 1)
return; return null;
string primName = rules.GetLSLStringItem(idx++); string primName = rules.GetLSLStringItem(idx++);
part.Name = primName; part.Name = primName;
break; break;
case (int)ScriptBaseClass.PRIM_DESC: case (int)ScriptBaseClass.PRIM_DESC:
if (remain < 1) if (remain < 1)
return; return null;
string primDesc = rules.GetLSLStringItem(idx++); string primDesc = rules.GetLSLStringItem(idx++);
part.Description = primDesc; part.Description = primDesc;
break; break;
case (int)ScriptBaseClass.PRIM_ROT_LOCAL: case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
if (remain < 1) if (remain < 1)
return; return null;
LSL_Rotation lr = rules.GetQuaternionItem(idx++); LSL_Rotation lr = rules.GetQuaternionItem(idx++);
SetRot(part, Rot2Quaternion(lr)); SetRot(part, Rot2Quaternion(lr));
break; break;
case (int)ScriptBaseClass.PRIM_OMEGA: case (int)ScriptBaseClass.PRIM_OMEGA:
if (remain < 3) if (remain < 3)
return; return null;
LSL_Vector axis = rules.GetVector3Item(idx++); LSL_Vector axis = rules.GetVector3Item(idx++);
LSL_Float spinrate = rules.GetLSLFloatItem(idx++); LSL_Float spinrate = rules.GetLSLFloatItem(idx++);
LSL_Float gain = rules.GetLSLFloatItem(idx++); LSL_Float gain = rules.GetLSLFloatItem(idx++);
@ -7593,12 +7611,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break; break;
case (int)ScriptBaseClass.PRIM_LINK_TARGET: case (int)ScriptBaseClass.PRIM_LINK_TARGET:
if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
return; return null;
LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
LSL_List new_rules = rules.GetSublist(idx, -1);
setLinkPrimParams((int)new_linknumber, new_rules);
return; return rules.GetSublist(idx, -1);
} }
} }
} }
@ -7620,6 +7635,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
} }
return null;
} }
public LSL_String llStringToBase64(string str) public LSL_String llStringToBase64(string str)
@ -10692,7 +10708,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (obj.OwnerID != m_host.OwnerID) if (obj.OwnerID != m_host.OwnerID)
return; return;
SetPrimParams(obj, rules); LSL_List remaining = SetPrimParams(obj, rules);
while (remaining != null && remaining.Length > 2)
{
LSL_Integer newLink = remaining.GetLSLIntegerItem(0);
LSL_List newrules = remaining.GetSublist(1, -1);
foreach(SceneObjectPart part in GetLinkParts(obj, newLink)){
remaining = SetPrimParams(part, newrules);
}
}
} }
public LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules) public LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules)