From c6da0fda58ec2c0ff200cb0167c0cbcc76a8985e Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Fri, 20 Mar 2009 22:42:21 +0000
Subject: Thank you, mcortez, for patch to add functionality to the sun module.
Fixes Mantis #3313
---
.../Shared/Api/Implementation/OSSL_Api.cs | 88 ++++++++++++++++++++++
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 5 ++
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 21 ++++++
3 files changed, 114 insertions(+)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index f4be267..8776524 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -807,6 +807,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//World.Permissions.GenericEstatePermission(
if (World.Permissions.IsGod(m_host.OwnerID))
{
+ while (sunHour > 24.0)
+ sunHour -= 24.0;
+
+ while (sunHour < 0)
+ sunHour += 24.0;
+
+
World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun;
World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30
World.RegionInfo.RegionSettings.FixedSun = sunFixed;
@@ -816,6 +823,87 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
+ ///
+ /// Changes the Estate Sun Settings, then Triggers a Sun Update
+ ///
+ /// True to keep the sun stationary, false to use global time
+ /// The "Sun Hour" that is desired, 0...24, with 0 just after SunRise
+ public void osSetEstateSunSettings(bool sunFixed, double sunHour)
+ {
+ CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings");
+
+ m_host.AddScriptLPS(1);
+ //Check to make sure that the script's owner is the estate manager/master
+ //World.Permissions.GenericEstatePermission(
+ if (World.Permissions.IsGod(m_host.OwnerID))
+ {
+ while (sunHour > 24.0)
+ sunHour -= 24.0;
+
+ while (sunHour < 0)
+ sunHour += 24.0;
+
+ World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed;
+ World.RegionInfo.EstateSettings.SunPosition = sunHour;
+ World.RegionInfo.EstateSettings.FixedSun = sunFixed;
+ World.RegionInfo.EstateSettings.Save();
+
+ World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour);
+ }
+ }
+
+ ///
+ /// Return the current Sun Hour 0...24, with 0 being roughly sun-rise
+ ///
+ ///
+ public double osGetCurrentSunHour()
+ {
+ CheckThreatLevel(ThreatLevel.None, "osGetCurrentSunHour");
+
+ m_host.AddScriptLPS(1);
+
+ // Must adjust for the fact that Region Sun Settings are still LL offset
+ double sunHour = World.RegionInfo.RegionSettings.SunPosition - 6;
+
+ // See if the sun module has registered itself, if so it's authoritative
+ ISunModule module = World.RequestModuleInterface();
+ if (module != null)
+ {
+ sunHour = module.GetCurrentSunHour();
+ }
+
+ return sunHour;
+ }
+
+ public double osSunGetParam(string param)
+ {
+ CheckThreatLevel(ThreatLevel.None, "osSunGetParam");
+ m_host.AddScriptLPS(1);
+
+ double value = 0.0;
+
+ ISunModule module = World.RequestModuleInterface();
+ if (module != null)
+ {
+ value = module.GetSunParameter(param);
+ }
+
+ return value;
+ }
+
+ public void osSunSetParam(string param, double value)
+ {
+ CheckThreatLevel(ThreatLevel.None, "osSunSetParam");
+ m_host.AddScriptLPS(1);
+
+ ISunModule module = World.RequestModuleInterface();
+ if (module != null)
+ {
+ module.SetSunParameter(param, value);
+ }
+
+ }
+
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 3656f92..7a7b922 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -98,6 +98,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void osSetRegionWaterHeight(double height);
void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour);
+ void osSetEstateSunSettings(bool sunFixed, double sunHour);
+ double osGetCurrentSunHour();
+ double osSunGetParam(string param);
+ void osSunSetParam(string param, double value);
+
string osGetScriptEngineName();
string osGetSimulatorVersion();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index d316ac9..a50b6f2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -67,6 +67,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osSetRegionSunSettings(useEstateSun, sunFixed, sunHour);
}
+ public void osSetEstateSunSettings(bool sunFixed, double sunHour)
+ {
+ m_OSSL_Functions.osSetEstateSunSettings(sunFixed, sunHour);
+ }
+
+ public double osGetCurrentSunHour()
+ {
+ return m_OSSL_Functions.osGetCurrentSunHour();
+ }
+
+ public double osSunGetParam(string param)
+ {
+ return m_OSSL_Functions.osSunGetParam(param);
+ }
+
+ public void osSunSetParam(string param, double value)
+ {
+ m_OSSL_Functions.osSunSetParam(param, value);
+ }
+
+
public double osList2Double(LSL_Types.list src, int index)
{
return m_OSSL_Functions.osList2Double(src, index);
--
cgit v1.1