From d834a2c3da1aa97887e087e5a265e73a914c5f7b Mon Sep 17 00:00:00 2001
From: Thomas Grimshaw
Date: Wed, 7 Apr 2010 23:53:08 +0200
Subject: Implement cmGetAvatarList(). This returns a strided list of all
avatars in the region, including their UUID, position and name. The radar is
often the most taxing scripts on a sim, this function can help radars reduce
their impact by 66% by eliminating the need for sensors.
---
.../Shared/Api/Implementation/CM_Api.cs | 130 ++++++++++++---------
.../ScriptEngine/Shared/Api/Interface/ICM_Api.cs | 3 +-
.../ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | 14 ++-
3 files changed, 87 insertions(+), 60 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
index 99973b4..9f829da 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -86,6 +86,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
///
+ /// Like osGetAgents but returns enough info for a radar
+ ///
+ /// Strided list of the UUID, position and name of each avatar in the region
+ public LSL_List cmGetAvatarList()
+ {
+ LSL_List result = new LSL_List();
+ foreach (ScenePresence avatar in World.GetAvatars())
+ {
+ if (avatar.UUID != m_host.OwnerID)
+ {
+ if (avatar.IsChildAgent == false)
+ {
+ result.Add(avatar.UUID);
+ result.Add(avatar.PhysicsActor.Position);
+ result.Add(avatar.Name);
+ }
+ }
+ }
+ return result;
+ }
+
+ ///
/// Get the current Windlight scene
///
/// List of windlight parameters
@@ -229,10 +251,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return values;
- }
-
+ }
+
private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules)
- {
+ {
RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();
LSL_List values = new LSL_List();
@@ -244,9 +266,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Types.Vector3 iV;
switch (rule)
{
- case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
- idx++;
- wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx);
+ case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
+ idx++;
+ wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_AMBIENT:
idx++;
@@ -419,58 +441,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
CMShoutError("Careminster functions are not enabled.");
return 0;
- }
- if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
- {
- CMShoutError("cmSetWindlightScene can only be used by estate managers or owners.");
- return 0;
+ }
+ if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
+ {
+ CMShoutError("cmSetWindlightScene can only be used by estate managers or owners.");
+ return 0;
+ }
+ int success = 0;
+ m_host.AddScriptLPS(1);
+ if (Meta7WindlightModule.EnableWindlight)
+ {
+ RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
+ m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
+ success = 1;
+ }
+ else
+ {
+ CMShoutError("Windlight module is disabled");
+ return 0;
+ }
+ return success;
+ }
+ ///
+ /// Set the current Windlight scene to a target avatar
+ ///
+ ///
+ /// success: true or false
+ public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
+ {
+ if (!m_CMFunctionsEnabled)
+ {
+ CMShoutError("Careminster functions are not enabled.");
+ return 0;
+ }
+ if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
+ {
+ CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners.");
+ return 0;
}
int success = 0;
- m_host.AddScriptLPS(1);
- if (Meta7WindlightModule.EnableWindlight)
- {
- RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
- m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
- success = 1;
- }
- else
- {
- CMShoutError("Windlight module is disabled");
- return 0;
+ m_host.AddScriptLPS(1);
+ if (Meta7WindlightModule.EnableWindlight)
+ {
+ RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
+ World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
+ success = 1;
+ }
+ else
+ {
+ CMShoutError("Windlight module is disabled");
+ return 0;
}
return success;
- }
- ///
- /// Set the current Windlight scene to a target avatar
- ///
- ///
- /// success: true or false
- public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
- {
- if (!m_CMFunctionsEnabled)
- {
- CMShoutError("Careminster functions are not enabled.");
- return 0;
- }
- if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
- {
- CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners.");
- return 0;
- }
- int success = 0;
- m_host.AddScriptLPS(1);
- if (Meta7WindlightModule.EnableWindlight)
- {
- RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
- World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
- success = 1;
- }
- else
- {
- CMShoutError("Windlight module is disabled");
- return 0;
- }
- return success;
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
index ef990a1..6239726 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
@@ -15,7 +15,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
{
// Windlight Functions
LSL_List cmGetWindlightScene(LSL_List rules);
- int cmSetWindlightScene(LSL_List rules);
+ int cmSetWindlightScene(LSL_List rules);
int cmSetWindlightSceneTargeted(LSL_List rules, key target);
+ LSL_List cmGetAvatarList();
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
index 5bc3a88..aaffbe4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
@@ -66,11 +66,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public int cmSetWindlightScene(LSL_List rules)
{
return m_CM_Functions.cmSetWindlightScene(rules);
- }
-
- public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
- {
- return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
+ }
+
+ public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
+ {
+ return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
+ }
+ public LSL_List cmGetAvatarList()
+ {
+ return m_CM_Functions.cmGetAvatarList();
}
}
}
--
cgit v1.1