From 61e99bcdcba5480aa8a2a8b8e2f2b0a66c08e6b4 Mon Sep 17 00:00:00 2001 From: Talun Date: Tue, 8 May 2012 15:52:25 +0100 Subject: Mantis 6015 new LSL function llGetAgentList. Details in the lsl wiki --- .../Shared/Api/Implementation/LSL_Api.cs | 85 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 1 + .../Shared/Api/Runtime/LSL_Constants.cs | 5 ++ .../ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 ++ 4 files changed, 96 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index afd943b..5b5cab8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5529,6 +5529,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); return "en-us"; } + /// + /// http://wiki.secondlife.com/wiki/LlGetAgentList + /// The list of options is currently not used in SL + /// scope is one of:- + /// AGENT_LIST_REGION - all in the region + /// AGENT_LIST_PARCEL - all in the same parcel as the scripted object + /// AGENT_LIST_PARCEL_OWNER - all in any parcel owned by the owner of the + /// current parcel. + /// + public LSL_List llGetAgentList(LSL_Integer scope, LSL_List options) + { + m_host.AddScriptLPS(1); + + // the constants are 1, 2 and 4 so bits are being set, but you + // get an error "INVALID_SCOPE" if it is anything but 1, 2 and 4 + bool regionWide = scope == ScriptBaseClass.AGENT_LIST_REGION; + bool parcelOwned = scope == ScriptBaseClass.AGENT_LIST_PARCEL_OWNER; + bool parcel = scope == ScriptBaseClass.AGENT_LIST_PARCEL; + + LSL_List result = new LSL_List(); + + if (!regionWide && !parcelOwned && !parcel) + { + result.Add("INVALID_SCOPE"); + return result; + } + + ILandObject land; + Vector3 pos; + UUID id = UUID.Zero; + if (parcel || parcelOwned) + { + pos = m_host.ParentGroup.RootPart.GetWorldPosition(); + land = World.LandChannel.GetLandObject(pos.X, pos.Y); + if (land == null) + { + id = UUID.Zero; + } + else + { + if (parcelOwned) + { + id = land.LandData.OwnerID; + } + else + { + id = land.LandData.GlobalID; + } + } + } + List presenceIds = new List(); + + World.ForEachRootScenePresence( + delegate (ScenePresence ssp) + { + // Gods are not listed in SL + if (!ssp.IsDeleted && ssp.GodLevel == 0.0 && !ssp.IsChildAgent) + { + if (!regionWide) + { + pos = ssp.AbsolutePosition; + land = World.LandChannel.GetLandObject(pos.X, pos.Y); + if (land != null) + { + if (parcelOwned && land.LandData.OwnerID == id || + parcel && land.LandData.GlobalID == id) + { + result.Add(ssp.UUID.ToString()); + } + } + } + else + { + result.Add(ssp.UUID.ToString()); + } + } + // Maximum of 100 results + if (result.Length > 99) + { + return; + } + } + ); + return result; + } public void llAdjustSoundVolume(double volume) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 7a797ac..7f5d1fe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -109,6 +109,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Vector llGetAccel(); LSL_Integer llGetAgentInfo(string id); LSL_String llGetAgentLanguage(string id); + LSL_List llGetAgentList(LSL_Integer scope, LSL_List options); LSL_Vector llGetAgentSize(string id); LSL_Float llGetAlpha(int face); LSL_Float llGetAndResetTime(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 2a28542..b6c21e6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -501,6 +501,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int OBJECT_STREAMING_COST = 15; public const int OBJECT_PHYSICS_COST = 16; + // for llGetAgentList + public const int AGENT_LIST_PARCEL = 1; + public const int AGENT_LIST_PARCEL_OWNER = 2; + public const int AGENT_LIST_REGION = 4; + // Can not be public const? public static readonly vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0); public static readonly rotation ZERO_ROTATION = new rotation(0.0, 0.0, 0.0, 1.0); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 80fa530..c0bf29c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -389,6 +389,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetAgentLanguage(id); } + public LSL_List llGetAgentList(LSL_Integer scope, LSL_List options) + { + return m_LSL_Functions.llGetAgentList(scope, options); + } + public LSL_Vector llGetAgentSize(string id) { return m_LSL_Functions.llGetAgentSize(id); -- cgit v1.1