From b9e700b60d2782b9ccd5790c89920fcc912672ed Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 2 Nov 2011 11:43:16 +0000 Subject: Streamline PRIM_LINK_TARGET, eliminating a recursion and a failure scenario --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 83c3b78..6c690e8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7411,12 +7411,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api TargetOmega(part, axis, (double)spinrate, (double)gain); 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. + if (remain < 1) return; LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); - LSL_List new_rules = rules.GetSublist(idx, -1); - setLinkPrimParams((int)new_linknumber, new_rules); - return; + part = part.ParentGroup.GetLinkNumPart((int)new_linknumber); + break; } } } -- cgit v1.1 From 1b9ae3fb512c692ec36d43aefaaf11fe035cd54f Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 2 Nov 2011 12:02:44 +0000 Subject: Some positioning fixes from AVN trunk --- .../Shared/Api/Implementation/LSL_Api.cs | 43 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6c690e8..20fe6c6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1958,6 +1958,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return end; } + protected LSL_Vector GetSetPosTarget(SceneObjectPart part, LSL_Vector targetPos, LSL_Vector fromPos) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + return fromPos; + + // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) + + + float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y); + bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true); + + if (part.ParentGroup.RootPart == part) + { + if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) + targetPos.z = ground; + } + LSL_Vector real_vec = SetPosAdjust(fromPos, targetPos); + + return real_vec; + } + protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) { // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) @@ -7043,6 +7064,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { int idx = 0; + bool positionChanged = false; + LSL_Vector currentPosition = GetPartLocalPos(part); + while (idx < rules.Length) { int code = rules.GetLSLIntegerItem(idx++); @@ -7059,7 +7083,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; v=rules.GetVector3Item(idx++); - SetPos(part, v); + positionChanged = true; + currentPosition = GetSetPosTarget(part, v, currentPosition); break; case (int)ScriptBaseClass.PRIM_SIZE: @@ -7418,6 +7443,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; } } + + if (positionChanged) + { + if (part.ParentGroup.RootPart == part) + { + SceneObjectGroup parent = part.ParentGroup; + parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); + } + else + { + part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); + SceneObjectGroup parent = part.ParentGroup; + parent.HasGroupChanged = true; + parent.ScheduleGroupForTerseUpdate(); + } + } } public LSL_String llStringToBase64(string str) -- cgit v1.1 From c5fb39e21f41baf85f392ac916c1b59789235c8c Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 2 Nov 2011 12:09:18 +0000 Subject: Restore the recursive calling of PRIM_LINK_TARGET because the version I made breaks LINK_SET et al. --- .../Shared/Api/Implementation/LSL_Api.cs | 661 +++++++++++---------- 1 file changed, 334 insertions(+), 327 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 20fe6c6..a51a88b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7067,396 +7067,403 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api bool positionChanged = false; LSL_Vector currentPosition = GetPartLocalPos(part); - while (idx < rules.Length) + try { - int code = rules.GetLSLIntegerItem(idx++); + while (idx < rules.Length) + { + int code = rules.GetLSLIntegerItem(idx++); - int remain = rules.Length - idx; + int remain = rules.Length - idx; - int face; - LSL_Vector v; + int face; + LSL_Vector v; - switch (code) - { - case (int)ScriptBaseClass.PRIM_POSITION: - if (remain < 1) - return; + switch (code) + { + case (int)ScriptBaseClass.PRIM_POSITION: + if (remain < 1) + return; - v=rules.GetVector3Item(idx++); - positionChanged = true; - currentPosition = GetSetPosTarget(part, v, currentPosition); + v=rules.GetVector3Item(idx++); + positionChanged = true; + currentPosition = GetSetPosTarget(part, v, currentPosition); - break; - case (int)ScriptBaseClass.PRIM_SIZE: - if (remain < 1) - return; + break; + case (int)ScriptBaseClass.PRIM_SIZE: + if (remain < 1) + return; - v=rules.GetVector3Item(idx++); - SetScale(part, v); + v=rules.GetVector3Item(idx++); + SetScale(part, v); - break; - case (int)ScriptBaseClass.PRIM_ROTATION: - if (remain < 1) - return; + break; + case (int)ScriptBaseClass.PRIM_ROTATION: + if (remain < 1) + return; - LSL_Rotation q = rules.GetQuaternionItem(idx++); - // try to let this work as in SL... - if (part.ParentID == 0) - { - // special case: If we are root, rotate complete SOG to new rotation - SetRot(part, Rot2Quaternion(q)); - } - else - { - // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. - SceneObjectPart rootPart = part.ParentGroup.RootPart; - SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); - } + LSL_Rotation q = rules.GetQuaternionItem(idx++); + // try to let this work as in SL... + if (part.ParentID == 0) + { + // special case: If we are root, rotate complete SOG to new rotation + SetRot(part, Rot2Quaternion(q)); + } + else + { + // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. + SceneObjectPart rootPart = part.ParentGroup.RootPart; + SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); + } - break; + break; - case (int)ScriptBaseClass.PRIM_TYPE: - if (remain < 3) - return; + case (int)ScriptBaseClass.PRIM_TYPE: + if (remain < 3) + return; - code = (int)rules.GetLSLIntegerItem(idx++); + code = (int)rules.GetLSLIntegerItem(idx++); - remain = rules.Length - idx; - float hollow; - LSL_Vector twist; - LSL_Vector taper_b; - LSL_Vector topshear; - float revolutions; - float radiusoffset; - float skew; - LSL_Vector holesize; - LSL_Vector profilecut; + remain = rules.Length - idx; + float hollow; + LSL_Vector twist; + LSL_Vector taper_b; + LSL_Vector topshear; + float revolutions; + float radiusoffset; + float skew; + LSL_Vector holesize; + LSL_Vector profilecut; - switch (code) - { - case (int)ScriptBaseClass.PRIM_TYPE_BOX: - if (remain < 6) - return; - - face = (int)rules.GetLSLIntegerItem(idx++); - v = rules.GetVector3Item(idx++); // cut - hollow = (float)rules.GetLSLFloatItem(idx++); - twist = rules.GetVector3Item(idx++); - taper_b = rules.GetVector3Item(idx++); - topshear = rules.GetVector3Item(idx++); - - SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, - (byte)ProfileShape.Square, (byte)Extrusion.Straight); - break; + switch (code) + { + case (int)ScriptBaseClass.PRIM_TYPE_BOX: + if (remain < 6) + return; + + face = (int)rules.GetLSLIntegerItem(idx++); + v = rules.GetVector3Item(idx++); // cut + hollow = (float)rules.GetLSLFloatItem(idx++); + twist = rules.GetVector3Item(idx++); + taper_b = rules.GetVector3Item(idx++); + topshear = rules.GetVector3Item(idx++); + + SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, + (byte)ProfileShape.Square, (byte)Extrusion.Straight); + break; - case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: - if (remain < 6) - return; - - face = (int)rules.GetLSLIntegerItem(idx++); // holeshape - v = rules.GetVector3Item(idx++); // cut - hollow = (float)rules.GetLSLFloatItem(idx++); - twist = rules.GetVector3Item(idx++); - taper_b = rules.GetVector3Item(idx++); - topshear = rules.GetVector3Item(idx++); - SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, - (byte)ProfileShape.Circle, (byte)Extrusion.Straight); - break; + case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: + if (remain < 6) + return; + + face = (int)rules.GetLSLIntegerItem(idx++); // holeshape + v = rules.GetVector3Item(idx++); // cut + hollow = (float)rules.GetLSLFloatItem(idx++); + twist = rules.GetVector3Item(idx++); + taper_b = rules.GetVector3Item(idx++); + topshear = rules.GetVector3Item(idx++); + SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, + (byte)ProfileShape.Circle, (byte)Extrusion.Straight); + break; - case (int)ScriptBaseClass.PRIM_TYPE_PRISM: - if (remain < 6) - return; - - face = (int)rules.GetLSLIntegerItem(idx++); // holeshape - v = rules.GetVector3Item(idx++); //cut - hollow = (float)rules.GetLSLFloatItem(idx++); - twist = rules.GetVector3Item(idx++); - taper_b = rules.GetVector3Item(idx++); - topshear = rules.GetVector3Item(idx++); - SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, - (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Straight); - break; + case (int)ScriptBaseClass.PRIM_TYPE_PRISM: + if (remain < 6) + return; + + face = (int)rules.GetLSLIntegerItem(idx++); // holeshape + v = rules.GetVector3Item(idx++); //cut + hollow = (float)rules.GetLSLFloatItem(idx++); + twist = rules.GetVector3Item(idx++); + taper_b = rules.GetVector3Item(idx++); + topshear = rules.GetVector3Item(idx++); + SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, + (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Straight); + break; - case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: - if (remain < 5) - return; - - face = (int)rules.GetLSLIntegerItem(idx++); // holeshape - v = rules.GetVector3Item(idx++); // cut - hollow = (float)rules.GetLSLFloatItem(idx++); - twist = rules.GetVector3Item(idx++); - taper_b = rules.GetVector3Item(idx++); // dimple - SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, - (byte)ProfileShape.HalfCircle, (byte)Extrusion.Curve1); - break; + case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: + if (remain < 5) + return; + + face = (int)rules.GetLSLIntegerItem(idx++); // holeshape + v = rules.GetVector3Item(idx++); // cut + hollow = (float)rules.GetLSLFloatItem(idx++); + twist = rules.GetVector3Item(idx++); + taper_b = rules.GetVector3Item(idx++); // dimple + SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, + (byte)ProfileShape.HalfCircle, (byte)Extrusion.Curve1); + break; - case (int)ScriptBaseClass.PRIM_TYPE_TORUS: - if (remain < 11) - return; - - face = (int)rules.GetLSLIntegerItem(idx++); // holeshape - v = rules.GetVector3Item(idx++); //cut - hollow = (float)rules.GetLSLFloatItem(idx++); - twist = rules.GetVector3Item(idx++); - holesize = rules.GetVector3Item(idx++); - topshear = rules.GetVector3Item(idx++); - profilecut = rules.GetVector3Item(idx++); - taper_b = rules.GetVector3Item(idx++); // taper_a - revolutions = (float)rules.GetLSLFloatItem(idx++); - radiusoffset = (float)rules.GetLSLFloatItem(idx++); - skew = (float)rules.GetLSLFloatItem(idx++); - SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, - revolutions, radiusoffset, skew, (byte)ProfileShape.Circle, (byte)Extrusion.Curve1); - break; + case (int)ScriptBaseClass.PRIM_TYPE_TORUS: + if (remain < 11) + return; + + face = (int)rules.GetLSLIntegerItem(idx++); // holeshape + v = rules.GetVector3Item(idx++); //cut + hollow = (float)rules.GetLSLFloatItem(idx++); + twist = rules.GetVector3Item(idx++); + holesize = rules.GetVector3Item(idx++); + topshear = rules.GetVector3Item(idx++); + profilecut = rules.GetVector3Item(idx++); + taper_b = rules.GetVector3Item(idx++); // taper_a + revolutions = (float)rules.GetLSLFloatItem(idx++); + radiusoffset = (float)rules.GetLSLFloatItem(idx++); + skew = (float)rules.GetLSLFloatItem(idx++); + SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, + revolutions, radiusoffset, skew, (byte)ProfileShape.Circle, (byte)Extrusion.Curve1); + break; - case (int)ScriptBaseClass.PRIM_TYPE_TUBE: - if (remain < 11) - return; - - face = (int)rules.GetLSLIntegerItem(idx++); // holeshape - v = rules.GetVector3Item(idx++); //cut - hollow = (float)rules.GetLSLFloatItem(idx++); - twist = rules.GetVector3Item(idx++); - holesize = rules.GetVector3Item(idx++); - topshear = rules.GetVector3Item(idx++); - profilecut = rules.GetVector3Item(idx++); - taper_b = rules.GetVector3Item(idx++); // taper_a - revolutions = (float)rules.GetLSLFloatItem(idx++); - radiusoffset = (float)rules.GetLSLFloatItem(idx++); - skew = (float)rules.GetLSLFloatItem(idx++); - SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, - revolutions, radiusoffset, skew, (byte)ProfileShape.Square, (byte)Extrusion.Curve1); - break; + case (int)ScriptBaseClass.PRIM_TYPE_TUBE: + if (remain < 11) + return; + + face = (int)rules.GetLSLIntegerItem(idx++); // holeshape + v = rules.GetVector3Item(idx++); //cut + hollow = (float)rules.GetLSLFloatItem(idx++); + twist = rules.GetVector3Item(idx++); + holesize = rules.GetVector3Item(idx++); + topshear = rules.GetVector3Item(idx++); + profilecut = rules.GetVector3Item(idx++); + taper_b = rules.GetVector3Item(idx++); // taper_a + revolutions = (float)rules.GetLSLFloatItem(idx++); + radiusoffset = (float)rules.GetLSLFloatItem(idx++); + skew = (float)rules.GetLSLFloatItem(idx++); + SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, + revolutions, radiusoffset, skew, (byte)ProfileShape.Square, (byte)Extrusion.Curve1); + break; - case (int)ScriptBaseClass.PRIM_TYPE_RING: - if (remain < 11) - return; - - face = (int)rules.GetLSLIntegerItem(idx++); // holeshape - v = rules.GetVector3Item(idx++); //cut - hollow = (float)rules.GetLSLFloatItem(idx++); - twist = rules.GetVector3Item(idx++); - holesize = rules.GetVector3Item(idx++); - topshear = rules.GetVector3Item(idx++); - profilecut = rules.GetVector3Item(idx++); - taper_b = rules.GetVector3Item(idx++); // taper_a - revolutions = (float)rules.GetLSLFloatItem(idx++); - radiusoffset = (float)rules.GetLSLFloatItem(idx++); - skew = (float)rules.GetLSLFloatItem(idx++); - SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, - revolutions, radiusoffset, skew, (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Curve1); - break; + case (int)ScriptBaseClass.PRIM_TYPE_RING: + if (remain < 11) + return; + + face = (int)rules.GetLSLIntegerItem(idx++); // holeshape + v = rules.GetVector3Item(idx++); //cut + hollow = (float)rules.GetLSLFloatItem(idx++); + twist = rules.GetVector3Item(idx++); + holesize = rules.GetVector3Item(idx++); + topshear = rules.GetVector3Item(idx++); + profilecut = rules.GetVector3Item(idx++); + taper_b = rules.GetVector3Item(idx++); // taper_a + revolutions = (float)rules.GetLSLFloatItem(idx++); + radiusoffset = (float)rules.GetLSLFloatItem(idx++); + skew = (float)rules.GetLSLFloatItem(idx++); + SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, + revolutions, radiusoffset, skew, (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Curve1); + break; - case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: - if (remain < 2) - return; + case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: + if (remain < 2) + return; - string map = rules.Data[idx++].ToString(); - face = (int)rules.GetLSLIntegerItem(idx++); // type - SetPrimitiveShapeParams(part, map, face, (byte)Extrusion.Curve1); - break; - } + string map = rules.Data[idx++].ToString(); + face = (int)rules.GetLSLIntegerItem(idx++); // type + SetPrimitiveShapeParams(part, map, face, (byte)Extrusion.Curve1); + break; + } - break; + break; - case (int)ScriptBaseClass.PRIM_TEXTURE: - if (remain < 5) - return; + case (int)ScriptBaseClass.PRIM_TEXTURE: + if (remain < 5) + return; - face=(int)rules.GetLSLIntegerItem(idx++); - string tex=rules.Data[idx++].ToString(); - LSL_Vector repeats=rules.GetVector3Item(idx++); - LSL_Vector offsets=rules.GetVector3Item(idx++); - double rotation=(double)rules.GetLSLFloatItem(idx++); + face=(int)rules.GetLSLIntegerItem(idx++); + string tex=rules.Data[idx++].ToString(); + LSL_Vector repeats=rules.GetVector3Item(idx++); + LSL_Vector offsets=rules.GetVector3Item(idx++); + double rotation=(double)rules.GetLSLFloatItem(idx++); - SetTexture(part, tex, face); - ScaleTexture(part, repeats.x, repeats.y, face); - OffsetTexture(part, offsets.x, offsets.y, face); - RotateTexture(part, rotation, face); + SetTexture(part, tex, face); + ScaleTexture(part, repeats.x, repeats.y, face); + OffsetTexture(part, offsets.x, offsets.y, face); + RotateTexture(part, rotation, face); - break; + break; - case (int)ScriptBaseClass.PRIM_COLOR: - if (remain < 3) - return; + case (int)ScriptBaseClass.PRIM_COLOR: + if (remain < 3) + return; - face=(int)rules.GetLSLIntegerItem(idx++); - LSL_Vector color=rules.GetVector3Item(idx++); - double alpha=(double)rules.GetLSLFloatItem(idx++); + face=(int)rules.GetLSLIntegerItem(idx++); + LSL_Vector color=rules.GetVector3Item(idx++); + double alpha=(double)rules.GetLSLFloatItem(idx++); - part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); - SetAlpha(part, alpha, face); + part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); + SetAlpha(part, alpha, face); - break; + break; - case (int)ScriptBaseClass.PRIM_FLEXIBLE: - if (remain < 7) - return; + case (int)ScriptBaseClass.PRIM_FLEXIBLE: + if (remain < 7) + return; - bool flexi = rules.GetLSLIntegerItem(idx++); - int softness = rules.GetLSLIntegerItem(idx++); - float gravity = (float)rules.GetLSLFloatItem(idx++); - float friction = (float)rules.GetLSLFloatItem(idx++); - float wind = (float)rules.GetLSLFloatItem(idx++); - float tension = (float)rules.GetLSLFloatItem(idx++); - LSL_Vector force = rules.GetVector3Item(idx++); + bool flexi = rules.GetLSLIntegerItem(idx++); + int softness = rules.GetLSLIntegerItem(idx++); + float gravity = (float)rules.GetLSLFloatItem(idx++); + float friction = (float)rules.GetLSLFloatItem(idx++); + float wind = (float)rules.GetLSLFloatItem(idx++); + float tension = (float)rules.GetLSLFloatItem(idx++); + LSL_Vector force = rules.GetVector3Item(idx++); - SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force); + SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force); - break; + break; - case (int)ScriptBaseClass.PRIM_POINT_LIGHT: - if (remain < 5) - return; - bool light = rules.GetLSLIntegerItem(idx++); - LSL_Vector lightcolor = rules.GetVector3Item(idx++); - float intensity = (float)rules.GetLSLFloatItem(idx++); - float radius = (float)rules.GetLSLFloatItem(idx++); - float falloff = (float)rules.GetLSLFloatItem(idx++); + case (int)ScriptBaseClass.PRIM_POINT_LIGHT: + if (remain < 5) + return; + bool light = rules.GetLSLIntegerItem(idx++); + LSL_Vector lightcolor = rules.GetVector3Item(idx++); + float intensity = (float)rules.GetLSLFloatItem(idx++); + float radius = (float)rules.GetLSLFloatItem(idx++); + float falloff = (float)rules.GetLSLFloatItem(idx++); - SetPointLight(part, light, lightcolor, intensity, radius, falloff); + SetPointLight(part, light, lightcolor, intensity, radius, falloff); - break; + break; - case (int)ScriptBaseClass.PRIM_GLOW: - if (remain < 2) - return; - face = rules.GetLSLIntegerItem(idx++); - float glow = (float)rules.GetLSLFloatItem(idx++); + case (int)ScriptBaseClass.PRIM_GLOW: + if (remain < 2) + return; + face = rules.GetLSLIntegerItem(idx++); + float glow = (float)rules.GetLSLFloatItem(idx++); - SetGlow(part, face, glow); + SetGlow(part, face, glow); - break; + break; - case (int)ScriptBaseClass.PRIM_BUMP_SHINY: - if (remain < 3) - return; - face = (int)rules.GetLSLIntegerItem(idx++); - int shiny = (int)rules.GetLSLIntegerItem(idx++); - Bumpiness bump = (Bumpiness)Convert.ToByte((int)rules.GetLSLIntegerItem(idx++)); + case (int)ScriptBaseClass.PRIM_BUMP_SHINY: + if (remain < 3) + return; + face = (int)rules.GetLSLIntegerItem(idx++); + int shiny = (int)rules.GetLSLIntegerItem(idx++); + Bumpiness bump = (Bumpiness)Convert.ToByte((int)rules.GetLSLIntegerItem(idx++)); - SetShiny(part, face, shiny, bump); + SetShiny(part, face, shiny, bump); - break; + break; - case (int)ScriptBaseClass.PRIM_FULLBRIGHT: - if (remain < 2) - return; - face = rules.GetLSLIntegerItem(idx++); - bool st = rules.GetLSLIntegerItem(idx++); - SetFullBright(part, face , st); - break; + case (int)ScriptBaseClass.PRIM_FULLBRIGHT: + if (remain < 2) + return; + face = rules.GetLSLIntegerItem(idx++); + bool st = rules.GetLSLIntegerItem(idx++); + SetFullBright(part, face , st); + break; - case (int)ScriptBaseClass.PRIM_MATERIAL: - if (remain < 1) - return; - int mat = rules.GetLSLIntegerItem(idx++); - if (mat < 0 || mat > 7) - return; + case (int)ScriptBaseClass.PRIM_MATERIAL: + if (remain < 1) + return; + int mat = rules.GetLSLIntegerItem(idx++); + if (mat < 0 || mat > 7) + return; - part.Material = Convert.ToByte(mat); - break; + part.Material = Convert.ToByte(mat); + break; - case (int)ScriptBaseClass.PRIM_PHANTOM: - if (remain < 1) - return; + case (int)ScriptBaseClass.PRIM_PHANTOM: + if (remain < 1) + return; - string ph = rules.Data[idx++].ToString(); - m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); + string ph = rules.Data[idx++].ToString(); + m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); - break; + break; - case (int)ScriptBaseClass.PRIM_PHYSICS: - if (remain < 1) - return; - string phy = rules.Data[idx++].ToString(); - bool physics; + case (int)ScriptBaseClass.PRIM_PHYSICS: + if (remain < 1) + return; + string phy = rules.Data[idx++].ToString(); + bool physics; - if (phy.Equals("1")) - physics = true; - else - physics = false; + if (phy.Equals("1")) + physics = true; + else + physics = false; - part.ScriptSetPhysicsStatus(physics); - break; + part.ScriptSetPhysicsStatus(physics); + break; - case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: - if (remain < 1) - return; - string temp = rules.Data[idx++].ToString(); + case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: + if (remain < 1) + return; + string temp = rules.Data[idx++].ToString(); - m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); + m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); - break; + break; - case (int)ScriptBaseClass.PRIM_TEXGEN: - if (remain < 2) - return; - //face,type - face = rules.GetLSLIntegerItem(idx++); - int style = rules.GetLSLIntegerItem(idx++); - SetTexGen(part, face, style); - break; - case (int)ScriptBaseClass.PRIM_TEXT: - if (remain < 3) - return; - string primText = rules.GetLSLStringItem(idx++); - LSL_Vector primTextColor = rules.GetVector3Item(idx++); - LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); - Vector3 av3 = new Vector3(Util.Clip((float)primTextColor.x, 0.0f, 1.0f), - Util.Clip((float)primTextColor.y, 0.0f, 1.0f), - Util.Clip((float)primTextColor.z, 0.0f, 1.0f)); - part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); + case (int)ScriptBaseClass.PRIM_TEXGEN: + if (remain < 2) + return; + //face,type + face = rules.GetLSLIntegerItem(idx++); + int style = rules.GetLSLIntegerItem(idx++); + SetTexGen(part, face, style); + break; + case (int)ScriptBaseClass.PRIM_TEXT: + if (remain < 3) + return; + string primText = rules.GetLSLStringItem(idx++); + LSL_Vector primTextColor = rules.GetVector3Item(idx++); + LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); + Vector3 av3 = new Vector3(Util.Clip((float)primTextColor.x, 0.0f, 1.0f), + Util.Clip((float)primTextColor.y, 0.0f, 1.0f), + Util.Clip((float)primTextColor.z, 0.0f, 1.0f)); + part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); + + break; + case (int)ScriptBaseClass.PRIM_NAME: + if (remain < 1) + return; + string primName = rules.GetLSLStringItem(idx++); + part.Name = primName; + break; + case (int)ScriptBaseClass.PRIM_DESC: + if (remain < 1) + return; + string primDesc = rules.GetLSLStringItem(idx++); + part.Description = primDesc; + break; + case (int)ScriptBaseClass.PRIM_ROT_LOCAL: + if (remain < 1) + return; + LSL_Rotation lr = rules.GetQuaternionItem(idx++); + SetRot(part, Rot2Quaternion(lr)); + break; + case (int)ScriptBaseClass.PRIM_OMEGA: + if (remain < 3) + return; + LSL_Vector axis = rules.GetVector3Item(idx++); + LSL_Float spinrate = rules.GetLSLFloatItem(idx++); + LSL_Float gain = rules.GetLSLFloatItem(idx++); + TargetOmega(part, axis, (double)spinrate, (double)gain); + 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); - break; - case (int)ScriptBaseClass.PRIM_NAME: - if (remain < 1) - return; - string primName = rules.GetLSLStringItem(idx++); - part.Name = primName; - break; - case (int)ScriptBaseClass.PRIM_DESC: - if (remain < 1) - return; - string primDesc = rules.GetLSLStringItem(idx++); - part.Description = primDesc; - break; - case (int)ScriptBaseClass.PRIM_ROT_LOCAL: - if (remain < 1) - return; - LSL_Rotation lr = rules.GetQuaternionItem(idx++); - SetRot(part, Rot2Quaternion(lr)); - break; - case (int)ScriptBaseClass.PRIM_OMEGA: - if (remain < 3) - return; - LSL_Vector axis = rules.GetVector3Item(idx++); - LSL_Float spinrate = rules.GetLSLFloatItem(idx++); - LSL_Float gain = rules.GetLSLFloatItem(idx++); - TargetOmega(part, axis, (double)spinrate, (double)gain); - break; - case (int)ScriptBaseClass.PRIM_LINK_TARGET: - if (remain < 1) return; - LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); - part = part.ParentGroup.GetLinkNumPart((int)new_linknumber); - break; + } } } - - if (positionChanged) + finally { - if (part.ParentGroup.RootPart == part) + if (positionChanged) { - SceneObjectGroup parent = part.ParentGroup; - parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); - } - else - { - part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); - SceneObjectGroup parent = part.ParentGroup; - parent.HasGroupChanged = true; - parent.ScheduleGroupForTerseUpdate(); + if (part.ParentGroup.RootPart == part) + { + SceneObjectGroup parent = part.ParentGroup; + parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); + } + else + { + part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); + SceneObjectGroup parent = part.ParentGroup; + parent.HasGroupChanged = true; + parent.ScheduleGroupForTerseUpdate(); + } } } } -- cgit v1.1 From b6873a7b5d8bbb4936550b38b0fbc9b0a8463b63 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 2 Nov 2011 13:16:02 +0000 Subject: Catch any exceptions exiting the top of the robust console, as we already do for the main simulator. This prevents issues such as transient mono console problems from crashing the server. --- OpenSim/Server/Base/ServicesServerBase.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index 36e6665..aeba35f 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -266,7 +266,14 @@ namespace OpenSim.Server.Base { while (m_Running) { - MainConsole.Instance.Prompt(); + try + { + MainConsole.Instance.Prompt(); + } + catch (Exception e) + { + m_log.ErrorFormat("Command error: {0}", e); + } } if (m_pidFile != String.Empty) -- cgit v1.1 From 03993d0b14599358ac30a001cebd5b2145881c65 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 2 Nov 2011 18:12:12 +0000 Subject: Fix race condition that would sometimes send or save appearance for the wrong avatar. In AvatarFactoryModule.HandleAppearanceUpdateTimer(), we loop through appearance save and send requests and dispatch via a FireAndForget thread. If there was more than one request in the save or send queue, then this led to a subtle race condition where the foreach loop would load in the next KeyValuePair before the thread was dispatched. This gave the thread the wrong avatar ID, leaving some avatar appearance cloudy since appearance data was never sent. This change loads the fields into local references so that this doesn't happen. --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 28 ++++++++++++++++------ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 ++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 236a47c..07d1cb3 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -169,6 +169,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public bool SendAppearance(UUID agentId) { +// m_log.DebugFormat("[AVFACTORY]: Sending appearance for {0}", agentId); + ScenePresence sp = m_scene.GetScenePresence(agentId); if (sp == null) { @@ -257,7 +259,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory /// public void QueueAppearanceSend(UUID agentid) { - // m_log.WarnFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); +// m_log.DebugFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); // 10000 ticks per millisecond, 1000 milliseconds per second long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 1000 * 10000); @@ -393,10 +395,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory Dictionary sends = new Dictionary(m_sendqueue); foreach (KeyValuePair kvp in sends) { - if (kvp.Value < now) + // We have to load the key and value into local parameters to avoid a race condition if we loop + // around and load kvp with a different value before FireAndForget has launched its thread. + UUID avatarID = kvp.Key; + long sendTime = kvp.Value; + +// m_log.DebugFormat("[AVFACTORY]: Handling queued appearance updates for {0}, update delta to now is {1}", avatarID, sendTime - now); + + if (sendTime < now) { - Util.FireAndForget(delegate(object o) { SendAppearance(kvp.Key); }); - m_sendqueue.Remove(kvp.Key); + Util.FireAndForget(o => SendAppearance(avatarID)); + m_sendqueue.Remove(avatarID); } } } @@ -406,10 +415,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory Dictionary saves = new Dictionary(m_savequeue); foreach (KeyValuePair kvp in saves) { - if (kvp.Value < now) + // We have to load the key and value into local parameters to avoid a race condition if we loop + // around and load kvp with a different value before FireAndForget has launched its thread. + UUID avatarID = kvp.Key; + long sendTime = kvp.Value; + + if (sendTime < now) { - Util.FireAndForget(delegate(object o) { SaveAppearance(kvp.Key); }); - m_savequeue.Remove(kvp.Key); + Util.FireAndForget(o => SaveAppearance(avatarID)); + m_savequeue.Remove(avatarID); } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 29966f9..3e3fb0f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2628,7 +2628,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendAppearanceToAllOtherAgents() { - //m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} ({1})", Name, UUID); +// m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} {1}", Name, UUID); + // only send update from root agents to other clients; children are only "listening posts" if (IsChildAgent) { @@ -2656,7 +2657,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendOtherAgentsAppearanceToMe() { - //m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} ({1})", Name, UUID); +// m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} {1}", Name, UUID); int count = 0; m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) -- cgit v1.1 From 72923134e9ab9ab946253c883d40536af389ab18 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 2 Nov 2011 18:40:49 +0000 Subject: Get some hopefully more useful exception information when OpenJPEG.EncodeFromImage() fails in VectorRender and DynamicTexture modules --- .../CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | 6 ++++-- .../CoreModules/Scripting/VectorRender/VectorRenderModule.cs | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 6075e19..f2c8b3d 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -395,9 +395,11 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture { result = OpenJPEG.EncodeFromImage(joint, true); } - catch (Exception) + catch (Exception e) { - m_log.Error("[DYNAMICTEXTUREMODULE]: OpenJpeg Encode Failed. Empty byte data returned!"); + m_log.ErrorFormat( + "[DYNAMICTEXTUREMODULE]: OpenJpeg Encode Failed. Exception {0}{1}", + e.Message, e.StackTrace); } return result; diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index 7316e5b..c061868 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -338,10 +338,11 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender { imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true); } - catch (Exception) + catch (Exception e) { - m_log.Error( - "[VECTORRENDERMODULE]: OpenJpeg Encode Failed. Empty byte data returned!"); + m_log.ErrorFormat( + "[VECTORRENDERMODULE]: OpenJpeg Encode Failed. Exception {0}{1}", + e.Message, e.StackTrace); } m_textureManager.ReturnData(id, imageJ2000); -- cgit v1.1