diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 8b53edcb96..55567d1826 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -243,33 +243,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } public List GetLinkParts(int linkType) + { + return GetLinkParts(m_host, linkType); + } + + private List GetLinkParts(SceneObjectPart part, int linkType) { List ret = new List(); - ret.Add(m_host); + ret.Add(part); switch (linkType) { case ScriptBaseClass.LINK_SET: - return new List(m_host.ParentGroup.Parts); + return new List(part.ParentGroup.Parts); case ScriptBaseClass.LINK_ROOT: ret = new List(); - ret.Add(m_host.ParentGroup.RootPart); + ret.Add(part.ParentGroup.RootPart); return ret; case ScriptBaseClass.LINK_ALL_OTHERS: - ret = new List(m_host.ParentGroup.Parts); + ret = new List(part.ParentGroup.Parts); - if (ret.Contains(m_host)) - ret.Remove(m_host); + if (ret.Contains(part)) + ret.Remove(part); return ret; case ScriptBaseClass.LINK_ALL_CHILDREN: - ret = new List(m_host.ParentGroup.Parts); + ret = new List(part.ParentGroup.Parts); - if (ret.Contains(m_host.ParentGroup.RootPart)) - ret.Remove(m_host.ParentGroup.RootPart); + if (ret.Contains(part.ParentGroup.RootPart)) + ret.Remove(part.ParentGroup.RootPart); return ret; case ScriptBaseClass.LINK_THIS: @@ -279,7 +284,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (linkType < 0) return new List(); - SceneObjectPart target = m_host.ParentGroup.GetLinkNumPart(linkType); + SceneObjectPart target = part.ParentGroup.GetLinkNumPart(linkType); if (target == null) return new List(); ret = new List(); @@ -7254,7 +7259,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetPrimitiveParams(LSL_List rules) { m_host.AddScriptLPS(1); - SetPrimParams(m_host, rules); + + setLinkPrimParams(ScriptBaseClass.LINK_THIS, rules); ScriptSleep(200); } @@ -7279,11 +7285,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { List parts = GetLinkParts(linknumber); + LSL_List remaining = null; + 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; @@ -7306,7 +7324,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POSITION: case (int)ScriptBaseClass.PRIM_POS_LOCAL: if (remain < 1) - return; + return null; v=rules.GetVector3Item(idx++); positionChanged = true; @@ -7315,7 +7333,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_SIZE: if (remain < 1) - return; + return null; v=rules.GetVector3Item(idx++); SetScale(part, v); @@ -7323,7 +7341,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_ROTATION: if (remain < 1) - return; + return null; LSL_Rotation q = rules.GetQuaternionItem(idx++); // try to let this work as in SL... @@ -7343,7 +7361,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE: if (remain < 3) - return; + return null; code = (int)rules.GetLSLIntegerItem(idx++); @@ -7362,7 +7380,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { case (int)ScriptBaseClass.PRIM_TYPE_BOX: if (remain < 6) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); v = rules.GetVector3Item(idx++); // cut @@ -7377,7 +7395,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: if (remain < 6) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); // cut @@ -7391,7 +7409,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_PRISM: if (remain < 6) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut @@ -7405,7 +7423,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: if (remain < 5) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); // cut @@ -7418,7 +7436,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_TORUS: if (remain < 11) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut @@ -7437,7 +7455,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_TUBE: if (remain < 11) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut @@ -7456,7 +7474,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_RING: if (remain < 11) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut @@ -7475,7 +7493,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: if (remain < 2) - return; + return null; string map = rules.Data[idx++].ToString(); face = (int)rules.GetLSLIntegerItem(idx++); // type @@ -7487,7 +7505,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TEXTURE: if (remain < 5) - return; + return null; face=(int)rules.GetLSLIntegerItem(idx++); string tex=rules.Data[idx++].ToString(); @@ -7504,7 +7522,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_COLOR: if (remain < 3) - return; + return null; face=(int)rules.GetLSLIntegerItem(idx++); LSL_Vector color=rules.GetVector3Item(idx++); @@ -7517,7 +7535,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_FLEXIBLE: if (remain < 7) - return; + return null; bool flexi = rules.GetLSLIntegerItem(idx++); int softness = rules.GetLSLIntegerItem(idx++); @@ -7533,7 +7551,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POINT_LIGHT: if (remain < 5) - return; + return null; bool light = rules.GetLSLIntegerItem(idx++); LSL_Vector lightcolor = rules.GetVector3Item(idx++); float intensity = (float)rules.GetLSLFloatItem(idx++); @@ -7546,7 +7564,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_GLOW: if (remain < 2) - return; + return null; face = rules.GetLSLIntegerItem(idx++); float glow = (float)rules.GetLSLFloatItem(idx++); @@ -7556,7 +7574,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_BUMP_SHINY: if (remain < 3) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); int shiny = (int)rules.GetLSLIntegerItem(idx++); Bumpiness bump = (Bumpiness)(int)rules.GetLSLIntegerItem(idx++); @@ -7567,7 +7585,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_FULLBRIGHT: if (remain < 2) - return; + return null; face = rules.GetLSLIntegerItem(idx++); bool st = rules.GetLSLIntegerItem(idx++); SetFullBright(part, face , st); @@ -7575,17 +7593,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_MATERIAL: if (remain < 1) - return; + return null; int mat = rules.GetLSLIntegerItem(idx++); if (mat < 0 || mat > 7) - return; + return null; part.Material = Convert.ToByte(mat); break; case (int)ScriptBaseClass.PRIM_PHANTOM: if (remain < 1) - return; + return null; string ph = rules.Data[idx++].ToString(); m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); @@ -7594,7 +7612,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_PHYSICS: if (remain < 1) - return; + return null; string phy = rules.Data[idx++].ToString(); bool physics; @@ -7608,7 +7626,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: if (remain < 1) - return; + return null; string temp = rules.Data[idx++].ToString(); m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); @@ -7617,7 +7635,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TEXGEN: if (remain < 2) - return; + return null; //face,type face = rules.GetLSLIntegerItem(idx++); int style = rules.GetLSLIntegerItem(idx++); @@ -7625,7 +7643,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_TEXT: if (remain < 3) - return; + return null; string primText = rules.GetLSLStringItem(idx++); LSL_Vector primTextColor = rules.GetVector3Item(idx++); LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); @@ -7637,25 +7655,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_NAME: if (remain < 1) - return; + return null; string primName = rules.GetLSLStringItem(idx++); part.Name = primName; break; case (int)ScriptBaseClass.PRIM_DESC: if (remain < 1) - return; + return null; string primDesc = rules.GetLSLStringItem(idx++); part.Description = primDesc; break; case (int)ScriptBaseClass.PRIM_ROT_LOCAL: if (remain < 1) - return; + return null; LSL_Rotation lr = rules.GetQuaternionItem(idx++); SetRot(part, Rot2Quaternion(lr)); break; case (int)ScriptBaseClass.PRIM_OMEGA: if (remain < 3) - return; + return null; LSL_Vector axis = rules.GetVector3Item(idx++); LSL_Float spinrate = rules.GetLSLFloatItem(idx++); LSL_Float gain = rules.GetLSLFloatItem(idx++); @@ -7663,12 +7681,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; 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. - return; - LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); - LSL_List new_rules = rules.GetSublist(idx, -1); - setLinkPrimParams((int)new_linknumber, new_rules); + return null; - return; + return rules.GetSublist(idx, -1); } } } @@ -7690,6 +7705,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } + return null; } public LSL_String llStringToBase64(string str) @@ -10762,7 +10778,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (obj.OwnerID != m_host.OwnerID) 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)