From 0a5d6671cec0eaea00127e29d4237cc4614d111d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 21 Jan 2017 06:37:29 +0000 Subject: [PATCH] fix llScriptDanger(); don't call old ScriptDamage on ossl health functions --- OpenSim/Region/Framework/Scenes/Scene.cs | 90 +++++++++---------- .../Shared/Api/Implementation/LSL_Api.cs | 2 +- .../Shared/Api/Implementation/OSSL_Api.cs | 9 +- 3 files changed, 48 insertions(+), 53 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d9b0327911..ca298be5be 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5083,65 +5083,59 @@ Label_GroupsDone: #endregion #region Script Engine + public bool LSLScriptDanger(SceneObjectPart part, Vector3 pos) + { + + ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); + if (parcel == null) + return true; + + LandData ldata = parcel.LandData; + if (ldata == null) + return true; + + uint landflags = ldata.Flags; + + uint mask = (uint)(ParcelFlags.CreateObjects | ParcelFlags.AllowAPrimitiveEntry); + if((landflags & mask) != mask) + return true; + + if((landflags & (uint)ParcelFlags.AllowOtherScripts) != 0) + return false; + + if(part == null) + return true; + if(part.GroupID == ldata.GroupID && (landflags & (uint)ParcelFlags.AllowGroupScripts) != 0) + return false; + + return true; + } private bool ScriptDanger(SceneObjectPart part, Vector3 pos) { + if (part == null) + return false; + ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); - if (part != null) + if (parcel != null) { - if (parcel != null) - { - if ((parcel.LandData.Flags & (uint)ParcelFlags.AllowOtherScripts) != 0) - { - return true; - } - else if ((part.OwnerID == parcel.LandData.OwnerID) || Permissions.IsGod(part.OwnerID)) - { - return true; - } - else if (((parcel.LandData.Flags & (uint)ParcelFlags.AllowGroupScripts) != 0) - && (parcel.LandData.GroupID != UUID.Zero) && (parcel.LandData.GroupID == part.GroupID)) - { - return true; - } - else - { - return false; - } - } - else - { + if ((parcel.LandData.Flags & (uint)ParcelFlags.AllowOtherScripts) != 0) + return true; - if (pos.X > 0f && pos.X < RegionInfo.RegionSizeX && pos.Y > 0f && pos.Y < RegionInfo.RegionSizeY) - { - // The only time parcel != null when an object is inside a region is when - // there is nothing behind the landchannel. IE, no land plugin loaded. - return true; - } - else - { - // The object is outside of this region. Stop piping events to it. - return false; - } - } + if ((part.OwnerID == parcel.LandData.OwnerID) || Permissions.IsGod(part.OwnerID)) + return true; + + if (((parcel.LandData.Flags & (uint)ParcelFlags.AllowGroupScripts) != 0) + && (parcel.LandData.GroupID != UUID.Zero) && (parcel.LandData.GroupID == part.GroupID)) + return true; } else { - return false; + if (pos.X > 0f && pos.X < RegionInfo.RegionSizeX && pos.Y > 0f && pos.Y < RegionInfo.RegionSizeY) + return true; } - } - public bool ScriptDanger(uint localID, Vector3 pos) - { - SceneObjectPart part = GetSceneObjectPart(localID); - if (part != null) - { - return ScriptDanger(part, pos); - } - else - { - return false; - } + return false; } public bool PipeEventsForScript(uint localID) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3cdf49ca51..226ad6c412 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7963,7 +7963,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llScriptDanger(LSL_Vector pos) { m_host.AddScriptLPS(1); - bool result = World.ScriptDanger(m_host.LocalId, pos); + bool result = World.LSLScriptDanger(m_host, pos); if (result) { return 1; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index a17eb033bf..4c3f7eeec5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -3538,7 +3538,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Float health = new LSL_Float(-1); ScenePresence presence = World.GetScenePresence(new UUID(avatar)); - if (presence != null) health = presence.Health; + if (presence != null) + health = presence.Health; return health; } @@ -3578,7 +3579,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID avatarId = new UUID(avatar); ScenePresence presence = World.GetScenePresence(avatarId); - if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) + if (presence != null) { float health = presence.Health; health += (float)healing; @@ -3598,7 +3599,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID avatarId = new UUID(avatar); ScenePresence presence = World.GetScenePresence(avatarId); - if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) + if (presence != null) { if (health > 100.0) health = 100.0; @@ -3617,7 +3618,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID avatarId = new UUID(avatar); ScenePresence presence = World.GetScenePresence(avatarId); - if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) + if (presence != null) presence.HealRate = (float)healrate; }