diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index eb06fcc4af..d05abc59d3 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -118,7 +118,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
uint sun = 0;
- if (!Scene.RegionInfo.EstateSettings.UseGlobalTime)
+ if (Scene.RegionInfo.EstateSettings.FixedSun)
sun = (uint)(Scene.RegionInfo.EstateSettings.SunPosition * 1024.0) + 0x1800;
UUID estateOwner;
estateOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
@@ -1091,6 +1091,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
Scene.RegionInfo.EstateSettings.UseGlobalTime = false;
Scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
+ // Warning: FixedSun should be set to True, otherwise this sun position won't be used.
}
if ((parms1 & 0x00000010) != 0)
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
index a321c0926e..6f344c8625 100644
--- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
@@ -252,12 +252,11 @@ namespace OpenSim.Region.CoreModules
}
// TODO: Decouple this, so we can get rid of Linden Hour info
- // Update Region infor with new Sun Position and Hour
+ // Update Region with new Sun Vector
// set estate settings for region access to sun position
if (receivedEstateToolsSunUpdate)
{
m_scene.RegionInfo.RegionSettings.SunVector = Position;
- m_scene.RegionInfo.RegionSettings.SunPosition = GetCurrentTimeAsLindenSunHour();
}
}
@@ -395,7 +394,7 @@ namespace OpenSim.Region.CoreModules
ready = false;
// Remove our hooks
- m_scene.EventManager.OnFrame -= SunUpdate;
+ m_scene.EventManager.OnFrame -= SunUpdate;
m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
m_scene.EventManager.OnEstateToolsSunUpdate -= EstateToolsSunUpdate;
m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour;
@@ -459,26 +458,33 @@ namespace OpenSim.Region.CoreModules
SunToClient(avatar.ControllingClient);
}
- ///
- ///
- ///
- ///
- /// Is the sun's position fixed?
- /// Use the Region or Estate Sun hour?
- /// What hour of the day is the Sun Fixed at?
- public void EstateToolsSunUpdate(ulong regionHandle, bool FixedSun, bool useEstateTime, float FixedSunHour)
+ public void EstateToolsSunUpdate(ulong regionHandle)
{
if (m_scene.RegionInfo.RegionHandle == regionHandle)
{
+ float sunFixedHour;
+ bool fixedSun;
+
+ if (m_scene.RegionInfo.RegionSettings.UseEstateSun)
+ {
+ sunFixedHour = (float)m_scene.RegionInfo.EstateSettings.SunPosition;
+ fixedSun = m_scene.RegionInfo.EstateSettings.FixedSun;
+ }
+ else
+ {
+ sunFixedHour = (float)m_scene.RegionInfo.RegionSettings.SunPosition - 6.0f;
+ fixedSun = m_scene.RegionInfo.RegionSettings.FixedSun;
+ }
+
// Must limit the Sun Hour to 0 ... 24
- while (FixedSunHour > 24.0f)
- FixedSunHour -= 24;
+ while (sunFixedHour > 24.0f)
+ sunFixedHour -= 24;
- while (FixedSunHour < 0)
- FixedSunHour += 24;
-
- m_SunFixedHour = FixedSunHour;
- m_SunFixed = FixedSun;
+ while (sunFixedHour < 0)
+ sunFixedHour += 24;
+
+ m_SunFixedHour = sunFixedHour;
+ m_SunFixed = fixedSun;
// m_log.DebugFormat("[SUN]: Sun Settings Update: Fixed Sun? : {0}", m_SunFixed.ToString());
// m_log.DebugFormat("[SUN]: Sun Settings Update: Sun Hour : {0}", m_SunFixedHour.ToString());
@@ -501,7 +507,7 @@ namespace OpenSim.Region.CoreModules
{
m_scene.ForEachRootClient(delegate(IClientAPI client)
{
- SunToClient(client);
+ SunToClient(client);
});
}
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 4c49b7168d..6b08e0f8fe 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -751,7 +751,7 @@ namespace OpenSim.Region.Framework.Scenes
public event ScriptTimerEvent OnScriptTimerEvent;
*/
- public delegate void EstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour);
+ public delegate void EstateToolsSunUpdate(ulong regionHandle);
public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID);
public event EstateToolsSunUpdate OnEstateToolsSunUpdate;
@@ -2507,13 +2507,10 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Updates the system as to how the position of the sun should be handled.
+ /// Called when the sun's position parameters have changed in the Region and/or Estate
///
- ///
- /// True if the Sun Position is fixed
- /// True if the Estate Settings should be used instead of region
- /// The hour 0.0 <= FixedSunHour <= 24.0 at which the sun is fixed at. Sun Hour 0 is sun-rise, when Day/Night ratio is 1:1
- public void TriggerEstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool useEstateTime, float FixedSunHour)
+ /// The region that changed
+ public void TriggerEstateToolsSunUpdate(ulong regionHandle)
{
EstateToolsSunUpdate handlerEstateToolsSunUpdate = OnEstateToolsSunUpdate;
if (handlerEstateToolsSunUpdate != null)
@@ -2522,7 +2519,7 @@ namespace OpenSim.Region.Framework.Scenes
{
try
{
- d(regionHandle, FixedTime, useEstateTime, FixedSunHour);
+ d(regionHandle);
}
catch (Exception e)
{
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index cca295cf7d..11b63b7c35 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -5345,33 +5345,7 @@ namespace OpenSim.Region.Framework.Scenes
public void TriggerEstateSunUpdate()
{
- float sun;
- if (RegionInfo.RegionSettings.UseEstateSun)
- {
- sun = (float)RegionInfo.EstateSettings.SunPosition;
- if (RegionInfo.EstateSettings.UseGlobalTime)
- {
- sun = EventManager.GetCurrentTimeAsSunLindenHour() - 6.0f;
- }
-
- //
- EventManager.TriggerEstateToolsSunUpdate(
- RegionInfo.RegionHandle,
- RegionInfo.EstateSettings.FixedSun,
- RegionInfo.RegionSettings.UseEstateSun,
- sun);
- }
- else
- {
- // Use the Sun Position from the Region Settings
- sun = (float)RegionInfo.RegionSettings.SunPosition - 6.0f;
-
- EventManager.TriggerEstateToolsSunUpdate(
- RegionInfo.RegionHandle,
- RegionInfo.RegionSettings.FixedSun,
- RegionInfo.RegionSettings.UseEstateSun,
- sun);
- }
+ EventManager.TriggerEstateToolsSunUpdate(RegionInfo.RegionHandle);
}
private void HandleReloadEstate(string module, string[] cmd)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 828288d02e..33c02ef68e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1205,12 +1205,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
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;
+ World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30
+ World.RegionInfo.RegionSettings.FixedSun = sunFixed;
World.RegionInfo.RegionSettings.Save();
- World.EventManager.TriggerEstateToolsSunUpdate(
- World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour);
+ World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle);
}
///
@@ -1235,8 +1234,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
World.RegionInfo.EstateSettings.FixedSun = sunFixed;
World.RegionInfo.EstateSettings.Save();
- World.EventManager.TriggerEstateToolsSunUpdate(
- World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour);
+ World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle);
}
///