From 4e2bea288ab6ff02ea3ed2232597ea0f9e6ead41 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 16 Feb 2024 17:17:59 +0000 Subject: [PATCH] add llIsFriend --- .../Shared/Api/Implementation/LSL_Api.cs | 23 +++++++++++++++++++ .../Shared/Api/Interface/ILSL_Api.cs | 2 ++ .../Shared/Api/Runtime/LSL_Stub.cs | 6 +++++ .../Region/ScriptEngine/Shared/LSL_Types.cs | 4 ++-- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 96732655bf..b835dcea3c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -18713,6 +18713,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_List(m_host.ParentGroup.LinksetData.ListKeysByPatttern(pattern.m_string, start, count)); } + + public LSL_Integer llIsFriend(LSL_Key agent_id) + { + SceneObjectGroup parentsog = m_host.ParentGroup; + if (parentsog is null || parentsog.IsDeleted) + return 0; + + if (parentsog.OwnerID.Equals(parentsog.GroupID)) + return llSameGroup(agent_id); + + IFriendsModule fm = World.RequestModuleInterface(); + if(fm is null) + return 0; + + if (World.GetScenePresence(parentsog.OwnerID) is null) + return 0; + if (!UUID.TryParse(agent_id, out UUID agent)) + return 0; + if (World.GetScenePresence(agent) is null) + return 0; + + return fm.IsFriendOnline(parentsog.OwnerID, agent) ? 1 : 0; + } } public class NotecardCache diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 252b2d25eb..dbe822a5d0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -513,5 +513,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llLinksetDataReset(); LSL_Integer llLinksetDataWrite(LSL_String name, LSL_String value); LSL_Integer llLinksetDataWriteProtected(LSL_String name, LSL_String value, LSL_String pass); + + LSL_Integer llIsFriend(LSL_Key agent_id); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 95ca92435a..d8b0079e6e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -2784,5 +2784,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_LSL_Functions.llLinksetDataFindKeys(pattern, start, count); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public LSL_Integer llIsFriend(LSL_Key agent_id) + { + return m_LSL_Functions.llIsFriend(agent_id); + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 06e804a71a..9228162796 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -2821,7 +2821,7 @@ namespace OpenSim.Region.ScriptEngine.Shared public LSLFloat(int i) { - value = (double)i; + value = i; } public LSLFloat(double d) @@ -2834,7 +2834,7 @@ namespace OpenSim.Region.ScriptEngine.Shared public LSLFloat(ReadOnlySpan s) { - if(!double.TryParse(s, System.Globalization.NumberStyles.Float, Culture.NumberFormatInfo, out value)) + if (!double.TryParse(s, NumberStyles.Float, Culture.NumberFormatInfo, out value)) value = 0; }