From 37815f34029d7fe4404b6733764892a9a2fe9086 Mon Sep 17 00:00:00 2001 From: Thomas Grimshaw Date: Tue, 16 Mar 2010 18:13:00 +0100 Subject: [PATCH 1/3] Debugger tags for VS2010 --- .../Shared/Api/Implementation/LSL_Api.cs | 387 +++++++++--------- .../Shared/Api/Runtime/LSL_Stub.cs | 2 + 2 files changed, 196 insertions(+), 193 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 8e5c203c6b..485a3b5e1d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -221,8 +221,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public List GetLinkParts(int linkType) { - List ret = new List(); - if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) + List ret = new List(); + if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) return ret; ret.Add(m_host); @@ -1115,6 +1115,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return detectedParams.TouchUV; } + [DebuggerNonUserCode] public virtual void llDie() { m_host.AddScriptLPS(1); @@ -1190,8 +1191,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } public void llSetStatus(int status, int value) - { - if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) + { + if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) return; m_host.AddScriptLPS(1); @@ -1367,7 +1368,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void SetScale(SceneObjectPart part, LSL_Vector scale) - { + { // TODO: this needs to trigger a persistance save as well if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; @@ -1426,8 +1427,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; Primitive.TextureEntry tex = part.Shape.Textures; @@ -1471,8 +1472,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } public void SetTexGen(SceneObjectPart part, int face,int style) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; Primitive.TextureEntry tex = part.Shape.Textures; @@ -1504,8 +1505,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } public void SetGlow(SceneObjectPart part, int face, float glow) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; Primitive.TextureEntry tex = part.Shape.Textures; @@ -1532,8 +1533,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; Shininess sval = new Shininess(); @@ -1584,8 +1585,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } public void SetFullBright(SceneObjectPart part, int face, bool bright) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; Primitive.TextureEntry tex = part.Shape.Textures; @@ -1654,8 +1655,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void SetAlpha(SceneObjectPart part, double alpha, int face) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; Primitive.TextureEntry tex = part.Shape.Textures; @@ -1702,8 +1703,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, float wind, float tension, LSL_Vector Force) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; if (flexi) @@ -1737,8 +1738,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// /// protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; if (light) @@ -1823,8 +1824,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void SetTexture(SceneObjectPart part, string texture, int face) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; UUID textureID=new UUID(); @@ -1871,8 +1872,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; Primitive.TextureEntry tex = part.Shape.Textures; @@ -1910,8 +1911,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; Primitive.TextureEntry tex = part.Shape.Textures; @@ -1949,8 +1950,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void RotateTexture(SceneObjectPart part, double rotation, int face) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; Primitive.TextureEntry tex = part.Shape.Textures; @@ -2022,8 +2023,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) @@ -2119,8 +2120,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void SetRot(SceneObjectPart part, Quaternion rot) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; part.UpdateRotation(rot); @@ -4016,7 +4017,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api bucket); if (m_TransferModule != null) - m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); + m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); //This delay should only occur when giving inventory to avatars. ScriptSleep(3000); @@ -6662,9 +6663,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) - { - ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return shapeBlock; if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && @@ -6735,8 +6736,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; ObjectShapePacket.ObjectDataBlock shapeBlock; @@ -6787,8 +6788,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; ObjectShapePacket.ObjectDataBlock shapeBlock; @@ -6832,8 +6833,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; ObjectShapePacket.ObjectDataBlock shapeBlock; @@ -6956,8 +6957,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); @@ -6993,13 +6994,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } public void llSetPrimitiveParams(LSL_List rules) - { + { m_host.AddScriptLPS(1); SetPrimParams(m_host, rules); } public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) - { + { m_host.AddScriptLPS(1); List parts = GetLinkParts(linknumber); @@ -7014,8 +7015,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } protected void SetPrimParams(SceneObjectPart part, LSL_List rules) - { - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + { + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; int idx = 0; @@ -7848,96 +7849,96 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } break; - case (int)ScriptBaseClass.PRIM_BUMP_SHINY: - if (remain < 1) - return res; - face = (int)rules.GetLSLIntegerItem(idx++); - - tex = part.Shape.Textures; - int shiny; - if (face == ScriptBaseClass.ALL_SIDES) - { - for (face = 0; face < GetNumberOfSides(part); face++) - { - Shininess shinyness = tex.GetFace((uint)face).Shiny; - if (shinyness == Shininess.High) - { - shiny = ScriptBaseClass.PRIM_SHINY_HIGH; - } - else if (shinyness == Shininess.Medium) - { - shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; - } - else if (shinyness == Shininess.Low) - { - shiny = ScriptBaseClass.PRIM_SHINY_LOW; - } - else - { - shiny = ScriptBaseClass.PRIM_SHINY_NONE; - } - res.Add(new LSL_Integer(shiny)); - res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); - } - } - else - { - Shininess shinyness = tex.GetFace((uint)face).Shiny; - if (shinyness == Shininess.High) - { - shiny = ScriptBaseClass.PRIM_SHINY_HIGH; - } - else if (shinyness == Shininess.Medium) - { - shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; - } - else if (shinyness == Shininess.Low) - { - shiny = ScriptBaseClass.PRIM_SHINY_LOW; - } - else - { - shiny = ScriptBaseClass.PRIM_SHINY_NONE; - } - res.Add(new LSL_Integer(shiny)); - res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); - } + case (int)ScriptBaseClass.PRIM_BUMP_SHINY: + if (remain < 1) + return res; + face = (int)rules.GetLSLIntegerItem(idx++); + + tex = part.Shape.Textures; + int shiny; + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < GetNumberOfSides(part); face++) + { + Shininess shinyness = tex.GetFace((uint)face).Shiny; + if (shinyness == Shininess.High) + { + shiny = ScriptBaseClass.PRIM_SHINY_HIGH; + } + else if (shinyness == Shininess.Medium) + { + shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; + } + else if (shinyness == Shininess.Low) + { + shiny = ScriptBaseClass.PRIM_SHINY_LOW; + } + else + { + shiny = ScriptBaseClass.PRIM_SHINY_NONE; + } + res.Add(new LSL_Integer(shiny)); + res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); + } + } + else + { + Shininess shinyness = tex.GetFace((uint)face).Shiny; + if (shinyness == Shininess.High) + { + shiny = ScriptBaseClass.PRIM_SHINY_HIGH; + } + else if (shinyness == Shininess.Medium) + { + shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; + } + else if (shinyness == Shininess.Low) + { + shiny = ScriptBaseClass.PRIM_SHINY_LOW; + } + else + { + shiny = ScriptBaseClass.PRIM_SHINY_NONE; + } + res.Add(new LSL_Integer(shiny)); + res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); + } break; - case (int)ScriptBaseClass.PRIM_FULLBRIGHT: - if (remain < 1) - return res; - face = (int)rules.GetLSLIntegerItem(idx++); - - tex = part.Shape.Textures; - int fullbright; - if (face == ScriptBaseClass.ALL_SIDES) - { - for (face = 0; face < GetNumberOfSides(part); face++) - { - if (tex.GetFace((uint)face).Fullbright == true) - { - fullbright = ScriptBaseClass.TRUE; - } - else - { - fullbright = ScriptBaseClass.FALSE; - } - res.Add(new LSL_Integer(fullbright)); - } - } - else - { - if (tex.GetFace((uint)face).Fullbright == true) - { - fullbright = ScriptBaseClass.TRUE; - } - else - { - fullbright = ScriptBaseClass.FALSE; - } - res.Add(new LSL_Integer(fullbright)); - } + case (int)ScriptBaseClass.PRIM_FULLBRIGHT: + if (remain < 1) + return res; + face = (int)rules.GetLSLIntegerItem(idx++); + + tex = part.Shape.Textures; + int fullbright; + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < GetNumberOfSides(part); face++) + { + if (tex.GetFace((uint)face).Fullbright == true) + { + fullbright = ScriptBaseClass.TRUE; + } + else + { + fullbright = ScriptBaseClass.FALSE; + } + res.Add(new LSL_Integer(fullbright)); + } + } + else + { + if (tex.GetFace((uint)face).Fullbright == true) + { + fullbright = ScriptBaseClass.TRUE; + } + else + { + fullbright = ScriptBaseClass.FALSE; + } + res.Add(new LSL_Integer(fullbright)); + } break; case (int)ScriptBaseClass.PRIM_FLEXIBLE: @@ -7958,37 +7959,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_TEXGEN: - // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) - if (remain < 1) - return res; - face = (int)rules.GetLSLIntegerItem(idx++); - - tex = part.Shape.Textures; - if (face == ScriptBaseClass.ALL_SIDES) - { - for (face = 0; face < GetNumberOfSides(part); face++) - { - if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) - { - res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); - } - else - { - res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); - } - } - } - else - { - if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) - { - res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); - } - else - { - res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); - } - } + // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) + if (remain < 1) + return res; + face = (int)rules.GetLSLIntegerItem(idx++); + + tex = part.Shape.Textures; + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < GetNumberOfSides(part); face++) + { + if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); + } + else + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); + } + } + } + else + { + if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); + } + else + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); + } + } break; case (int)ScriptBaseClass.PRIM_POINT_LIGHT: @@ -8006,26 +8007,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api res.Add(new LSL_Float(shape.LightFalloff)); // falloff break; - case (int)ScriptBaseClass.PRIM_GLOW: - if (remain < 1) + case (int)ScriptBaseClass.PRIM_GLOW: + if (remain < 1) return res; - face = (int)rules.GetLSLIntegerItem(idx++); - - tex = part.Shape.Textures; - float primglow; - if (face == ScriptBaseClass.ALL_SIDES) - { - for (face = 0; face < GetNumberOfSides(part); face++) - { - primglow = tex.GetFace((uint)face).Glow; - res.Add(new LSL_Float(primglow)); - } - } - else - { - primglow = tex.GetFace((uint)face).Glow; - res.Add(new LSL_Float(primglow)); - } + face = (int)rules.GetLSLIntegerItem(idx++); + + tex = part.Shape.Textures; + float primglow; + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < GetNumberOfSides(part); face++) + { + primglow = tex.GetFace((uint)face).Glow; + res.Add(new LSL_Float(primglow)); + } + } + else + { + primglow = tex.GetFace((uint)face).Glow; + res.Add(new LSL_Float(primglow)); + } break; case (int)ScriptBaseClass.PRIM_TEXT: Color4 textColor = part.GetTextColor(); @@ -9187,7 +9188,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (quick_pay_buttons.Data.Length < 4) - { + { int x; for (x=quick_pay_buttons.Data.Length; x<= 4; x++) { @@ -9195,12 +9196,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } int[] nPrice = new int[5]; - nPrice[0]=price; - nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; - nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; - nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; + nPrice[0]=price; + nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; + nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; + nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; - m_host.ParentGroup.RootPart.PayPrice = nPrice; + m_host.ParentGroup.RootPart.PayPrice = nPrice; m_host.ParentGroup.HasGroupChanged = true; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 3339995f66..e86d08c9aa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -26,6 +26,7 @@ */ using System; +using System.Diagnostics; //for [DebuggerNonUserCode] using System.Runtime.Remoting.Lifetime; using System.Threading; using System.Reflection; @@ -309,6 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); } + [DebuggerNonUserCode] public void llDie() { m_LSL_Functions.llDie(); From e442c2a3f9dc1823c00ddc1c81802fdabd7883dc Mon Sep 17 00:00:00 2001 From: Thomas Grimshaw Date: Wed, 17 Mar 2010 17:42:33 +0100 Subject: [PATCH 2/3] Prevent llTeleportAgentHome from affecting gods --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 485a3b5e1d..10ebf67b40 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4193,6 +4193,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScenePresence presence = World.GetScenePresence(agentId); if (presence != null) { + // agent must not be a god + if (presence.GodLevel >= 200) return; + // agent must be over the owners land if (m_host.OwnerID == World.LandChannel.GetLandObject( presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) From f35eb8819c6a872e7c4727940ffc560f7d5d68bd Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 18 Mar 2010 18:57:29 +0000 Subject: [PATCH 3/3] Unify a previous refactor of object return with the older solution. We really don't need two methods doing the same thing, but differently. --- .../CoreModules/World/Land/LandObject.cs | 2 +- .../World/Permissions/PermissionsModule.cs | 71 ++----------------- .../Framework/Scenes/Scene.Inventory.cs | 7 +- .../Framework/Scenes/Scene.Permissions.cs | 29 ++------ .../RegionCombinerModule.cs | 3 +- .../RegionCombinerPermissionModule.cs | 11 +-- 6 files changed, 21 insertions(+), 102 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 1c659650b5..b8c35f7528 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -915,7 +915,7 @@ namespace OpenSim.Region.CoreModules.World.Land foreach (List ol in returns.Values) { - if (m_scene.Permissions.CanUseObjectReturn(this, type, remote_client, ol)) + if (m_scene.Permissions.CanReturnObjects(this, remote_client.AgentId, ol)) m_scene.returnObjects(ol.ToArray(), remote_client.AgentId); } } diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 1533462b8d..7159dc6750 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -200,7 +200,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; //FULLY IMPLEMENTED m_scene.Permissions.OnMoveObject += CanMoveObject; //MAYBE FULLY IMPLEMENTED m_scene.Permissions.OnObjectEntry += CanObjectEntry; - m_scene.Permissions.OnReturnObject += CanReturnObject; //NOT YET IMPLEMENTED + m_scene.Permissions.OnReturnObjects += CanReturnObjects; //NOT YET IMPLEMENTED m_scene.Permissions.OnRezObject += CanRezObject; //MAYBE FULLY IMPLEMENTED m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; m_scene.Permissions.OnRunScript += CanRunScript; //NOT YET IMPLEMENTED @@ -230,7 +230,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; //NOT YET IMPLEMENTED m_scene.Permissions.OnTeleport += CanTeleport; //NOT YET IMPLEMENTED - m_scene.Permissions.OnUseObjectReturn += CanUseObjectReturn; //NOT YET IMPLEMENTED m_scene.AddCommand(this, "bypass permissions", "bypass permissions ", @@ -1258,12 +1257,15 @@ namespace OpenSim.Region.CoreModules.World.Permissions return false; } - private bool CanReturnObject(UUID objectID, UUID returnerID, Scene scene) + private bool CanReturnObjects(ILandObject land, UUID user, List objects, Scene scene) { + if (objects.Count == 0) + return false; + DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); if (m_bypassPermissions) return m_bypassPermissionsValue; - return GenericObjectPermission(returnerID, objectID, false); + return GenericObjectPermission(user, objects[0].UUID, false); } private bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene) @@ -1730,67 +1732,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions return GenericObjectPermission(agentID, prim, false); } - private bool CanUseObjectReturn(ILandObject parcel, uint type, IClientAPI client, List retlist, Scene scene) - { - DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); - if (m_bypassPermissions) return m_bypassPermissionsValue; - - long powers = 0; - if (parcel.LandData.GroupID != UUID.Zero) - client.GetGroupPowers(parcel.LandData.GroupID); - - switch (type) - { - case (uint)ObjectReturnType.Owner: - // Don't let group members return owner's objects, ever - // - if (parcel.LandData.IsGroupOwned) - { - if ((powers & (long)GroupPowers.ReturnGroupOwned) != 0) - return true; - } - else - { - if (parcel.LandData.OwnerID != client.AgentId) - return false; - } - return GenericParcelOwnerPermission(client.AgentId, parcel, (ulong)GroupPowers.ReturnGroupOwned); - case (uint)ObjectReturnType.Group: - if (parcel.LandData.OwnerID != client.AgentId) - { - // If permissionis granted through a group... - // - if ((powers & (long)GroupPowers.ReturnGroupSet) != 0) - { - foreach (SceneObjectGroup g in new List(retlist)) - { - // check for and remove group owned objects unless - // the user also has permissions to return those - // - if (g.OwnerID == g.GroupID && - ((powers & (long)GroupPowers.ReturnGroupOwned) == 0)) - { - retlist.Remove(g); - } - } - // And allow the operation - // - return true; - } - } - return GenericParcelOwnerPermission(client.AgentId, parcel, (ulong)GroupPowers.ReturnGroupSet); - case (uint)ObjectReturnType.Other: - if ((powers & (long)GroupPowers.ReturnNonGroup) != 0) - return true; - return GenericParcelOwnerPermission(client.AgentId, parcel, (ulong)GroupPowers.ReturnNonGroup); - case (uint)ObjectReturnType.List: - break; - } - - return GenericParcelOwnerPermission(client.AgentId, parcel, 0); - // Is it correct to be less restrictive for lists of objects to be returned? - } - private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) { //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType); switch (scriptType) { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index b2b061e272..ffbf745e90 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1581,9 +1581,10 @@ namespace OpenSim.Region.Framework.Scenes if (remoteClient != null) { permissionToTake = - Permissions.CanReturnObject( - grp.UUID, - remoteClient.AgentId); + Permissions.CanReturnObjects( + null, + remoteClient.AgentId, + new List() {grp}); permissionToDelete = permissionToTake; if (permissionToDelete) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index d1d6b6a377..7dab04fbd2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene); public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); - public delegate bool ReturnObjectHandler(UUID objectID, UUID returnerID, Scene scene); + public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List objects, Scene scene); public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene); public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene); public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene); @@ -81,7 +81,6 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool CopyUserInventoryHandler(UUID itemID, UUID userID); public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID); public delegate bool TeleportHandler(UUID userID, Scene scene); - public delegate bool UseObjectReturnHandler(ILandObject landData, uint type, IClientAPI client, List retlist, Scene scene); #endregion public class ScenePermissions @@ -107,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes public event EditObjectInventoryHandler OnEditObjectInventory; public event MoveObjectHandler OnMoveObject; public event ObjectEntryHandler OnObjectEntry; - public event ReturnObjectHandler OnReturnObject; + public event ReturnObjectsHandler OnReturnObjects; public event InstantMessageHandler OnInstantMessage; public event InventoryTransferHandler OnInventoryTransfer; public event ViewScriptHandler OnViewScript; @@ -140,7 +139,6 @@ namespace OpenSim.Region.Framework.Scenes public event CopyUserInventoryHandler OnCopyUserInventory; public event DeleteUserInventoryHandler OnDeleteUserInventory; public event TeleportHandler OnTeleport; - public event UseObjectReturnHandler OnUseObjectReturn; #endregion #region Object Permission Checks @@ -377,15 +375,15 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region RETURN OBJECT - public bool CanReturnObject(UUID objectID, UUID returnerID) + public bool CanReturnObjects(ILandObject land, UUID user, List objects) { - ReturnObjectHandler handler = OnReturnObject; + ReturnObjectsHandler handler = OnReturnObjects; if (handler != null) { Delegate[] list = handler.GetInvocationList(); - foreach (ReturnObjectHandler h in list) + foreach (ReturnObjectsHandler h in list) { - if (h(objectID, returnerID, m_scene) == false) + if (h(land, user, objects, m_scene) == false) return false; } } @@ -949,20 +947,5 @@ namespace OpenSim.Region.Framework.Scenes } return true; } - - public bool CanUseObjectReturn(ILandObject landData, uint type , IClientAPI client, List retlist) - { - UseObjectReturnHandler handler = OnUseObjectReturn; - if (handler != null) - { - Delegate[] list = handler.GetInvocationList(); - foreach (UseObjectReturnHandler h in list) - { - if (h(landData, type, client, retlist, m_scene) == false) - return false; - } - } - return true; - } } } diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 92f060b4cd..0b8771c3ad 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -922,7 +922,7 @@ namespace OpenSim.Region.RegionCombinerModule VirtualRegion.Permissions.OnIssueEstateCommand += BigRegion.PermissionModule.CanIssueEstateCommand; //FULLY IMPLEMENTED VirtualRegion.Permissions.OnMoveObject += BigRegion.PermissionModule.CanMoveObject; //MAYBE FULLY IMPLEMENTED VirtualRegion.Permissions.OnObjectEntry += BigRegion.PermissionModule.CanObjectEntry; - VirtualRegion.Permissions.OnReturnObject += BigRegion.PermissionModule.CanReturnObject; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnReturnObjects += BigRegion.PermissionModule.CanReturnObjects; //NOT YET IMPLEMENTED VirtualRegion.Permissions.OnRezObject += BigRegion.PermissionModule.CanRezObject; //MAYBE FULLY IMPLEMENTED VirtualRegion.Permissions.OnRunConsoleCommand += BigRegion.PermissionModule.CanRunConsoleCommand; VirtualRegion.Permissions.OnRunScript += BigRegion.PermissionModule.CanRunScript; //NOT YET IMPLEMENTED @@ -948,7 +948,6 @@ namespace OpenSim.Region.RegionCombinerModule VirtualRegion.Permissions.OnEditUserInventory += BigRegion.PermissionModule.CanEditUserInventory; //NOT YET IMPLEMENTED VirtualRegion.Permissions.OnDeleteUserInventory += BigRegion.PermissionModule.CanDeleteUserInventory; //NOT YET IMPLEMENTED VirtualRegion.Permissions.OnTeleport += BigRegion.PermissionModule.CanTeleport; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnUseObjectReturn += BigRegion.PermissionModule.CanUseObjectReturn; //NOT YET IMPLEMENTED } #region console commands diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs index 4d1af57450..393322d2d1 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs @@ -135,9 +135,9 @@ namespace OpenSim.Region.RegionCombinerModule return m_rootScene.Permissions.CanObjectEntry(objectid, enteringregion, newpoint); } - public bool CanReturnObject(UUID objectid, UUID returnerid, Scene scene) + public bool CanReturnObjects(ILandObject land, UUID user, List objects, Scene scene) { - return m_rootScene.Permissions.CanReturnObject(objectid, returnerid); + return m_rootScene.Permissions.CanReturnObjects(land, user, objects); } public bool CanRezObject(int objectcount, UUID owner, Vector3 objectposition, Scene scene) @@ -265,11 +265,6 @@ namespace OpenSim.Region.RegionCombinerModule return m_rootScene.Permissions.CanTeleport(userid); } - public bool CanUseObjectReturn(ILandObject landdata, uint type, IClientAPI client, List retlist, Scene scene) - { - return m_rootScene.Permissions.CanUseObjectReturn(landdata, type, client, retlist); - } - #endregion } -} \ No newline at end of file +}