aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs1
-rw-r--r--OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs72
2 files changed, 67 insertions, 6 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs
index ff179da..6476a4b 100644
--- a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs
@@ -183,6 +183,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate
183 // Time of day / fixed sun 183 // Time of day / fixed sun
184 m_scene.RegionInfo.EstateSettings.useFixedSun = UseFixedSun; 184 m_scene.RegionInfo.EstateSettings.useFixedSun = UseFixedSun;
185 m_scene.RegionInfo.EstateSettings.sunHour = SunHour; 185 m_scene.RegionInfo.EstateSettings.sunHour = SunHour;
186 m_scene.EventManager.TriggerEstateToolsTimeUpdate(m_scene.RegionInfo.RegionHandle, UseFixedSun, UseFixedSun, SunHour);
186 //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString()); 187 //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString());
187 //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString()); 188 //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString());
188 sendRegionInfoPacketToAll(); 189 sendRegionInfoPacketToAll();
diff --git a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs
index e1358db..7e4877c 100644
--- a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs
@@ -94,7 +94,8 @@ namespace OpenSim.Region.Environment.Modules
94 private LLVector3 Position = new LLVector3(0,0,0); 94 private LLVector3 Position = new LLVector3(0,0,0);
95 private LLVector3 Velocity = new LLVector3(0,0,0); 95 private LLVector3 Velocity = new LLVector3(0,0,0);
96 private LLQuaternion Tilt = new LLQuaternion(1,0,0,0); 96 private LLQuaternion Tilt = new LLQuaternion(1,0,0,0);
97 private float LindenEstateHour = 6f; 97 //private float LindenEstateHour = 6f;
98 private long LindenHourOffset = 0;
98 private bool sunFixed = false; 99 private bool sunFixed = false;
99 private long estateTicksOffset = 0; 100 private long estateTicksOffset = 0;
100 101
@@ -104,13 +105,14 @@ namespace OpenSim.Region.Environment.Modules
104 private ulong CurrentTime 105 private ulong CurrentTime
105 { 106 {
106 get { 107 get {
107 108 //m_log.Debug("[LH]: " + LindenHourOffset.ToString());
108 return (ulong)(((System.DateTime.Now.Ticks) - TicksToEpoch + TicksOffset)/10000000); 109 return (ulong)(((System.DateTime.Now.Ticks) - TicksToEpoch + TicksOffset + LindenHourOffset)/10000000);
109 } 110 }
110 } 111 }
112
111 private float GetLindenEstateHourFromCurrentTime() 113 private float GetLindenEstateHourFromCurrentTime()
112 { 114 {
113 float ticksleftover = ((float)((ulong)(((System.DateTime.Now.Ticks) - TicksToEpoch + TicksOffset) / 10000000))) % ((float)SecondsPerSunCycle); 115 float ticksleftover = ((float)CurrentTime) % ((float)SecondsPerSunCycle);
114 //m_log.Debug("[TICKS]: " + ticksleftover.ToString()); 116 //m_log.Debug("[TICKS]: " + ticksleftover.ToString());
115 float hour = (24 * (ticksleftover / SecondsPerSunCycle)) + 6; 117 float hour = (24 * (ticksleftover / SecondsPerSunCycle)) + 6;
116 //m_log.Debug("[LINDENHOUR]: " + hour.ToString()); 118 //m_log.Debug("[LINDENHOUR]: " + hour.ToString());
@@ -120,6 +122,33 @@ namespace OpenSim.Region.Environment.Modules
120 return hour; 122 return hour;
121 } 123 }
122 124
125 private void SetTimeByLindenHour(float LindenHour)
126 {
127 if (LindenHour - 6 == 0)
128 {
129 LindenHourOffset = 0;
130 return;
131 }
132 //TimeZone local = TimeZone.CurrentTimeZone;
133 //TicksOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks;
134
135 float ticksleftover = ((float)(((long)(CurrentTime * 10000000) - (long)LindenHourOffset)/ 10000000) % ((float)SecondsPerSunCycle));
136 float hour = (24 * (ticksleftover / SecondsPerSunCycle));
137 float offsethours = 0;
138
139 if (LindenHour - 6 > hour)
140 {
141 offsethours = hour + ((LindenHour-6) - hour);
142 }
143 else
144 {
145 offsethours = hour - (hour - (LindenHour - 6));
146 }
147 //m_log.Debug("[OFFSET]: " + hour + " - " + LindenHour + " - " + offsethours.ToString());
148 //LindenHourOffset = (long)((float)offsethours * (-14400000));
149 //m_log.Debug("[SUN]: Using " + CurrentTime.ToString());
150
151 }
123 // Called immediately after the module is loaded for a given region 152 // Called immediately after the module is loaded for a given region
124 // i.e. Immediately after instance creation. 153 // i.e. Immediately after instance creation.
125 154
@@ -203,6 +232,7 @@ namespace OpenSim.Region.Environment.Modules
203 scene.EventManager.OnMakeChildAgent += MakeChildAgent; 232 scene.EventManager.OnMakeChildAgent += MakeChildAgent;
204 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; 233 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
205 scene.EventManager.OnClientClosed += ClientLoggedOut; 234 scene.EventManager.OnClientClosed += ClientLoggedOut;
235 scene.EventManager.OnEstateToolsTimeUpdate += EstateToolsTimeUpdate;
206 236
207 ready = true; 237 ready = true;
208 238
@@ -226,8 +256,9 @@ namespace OpenSim.Region.Environment.Modules
226 m_scene.EventManager.OnFrame -= SunUpdate; 256 m_scene.EventManager.OnFrame -= SunUpdate;
227 // m_scene.EventManager.OnNewClient -= SunToClient; 257 // m_scene.EventManager.OnNewClient -= SunToClient;
228 m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent; 258 m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
229 m_scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; 259 m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
230 m_scene.EventManager.OnClientClosed += ClientLoggedOut; 260 m_scene.EventManager.OnClientClosed -= ClientLoggedOut;
261 m_scene.EventManager.OnEstateToolsTimeUpdate -= EstateToolsTimeUpdate;
231 } 262 }
232 263
233 public string Name 264 public string Name
@@ -273,7 +304,21 @@ namespace OpenSim.Region.Environment.Modules
273 m_scene.RegionInfo.EstateSettings.sunPosition = Position; 304 m_scene.RegionInfo.EstateSettings.sunPosition = Position;
274 m_scene.RegionInfo.EstateSettings.sunHour = GetLindenEstateHourFromCurrentTime(); 305 m_scene.RegionInfo.EstateSettings.sunHour = GetLindenEstateHourFromCurrentTime();
275 } 306 }
307 public void ForceSunUpdateToAllClients()
308 {
309 GenSunPos(); // Generate shared values once
310
311 List<ScenePresence> avatars = m_scene.GetAvatars();
312 foreach (ScenePresence avatar in avatars)
313 {
314 if (!avatar.IsChildAgent)
315 avatar.ControllingClient.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition);
316 }
276 317
318 // set estate settings for region access to sun position
319 m_scene.RegionInfo.EstateSettings.sunPosition = Position;
320 m_scene.RegionInfo.EstateSettings.sunHour = GetLindenEstateHourFromCurrentTime();
321 }
277 /// <summary> 322 /// <summary>
278 /// Calculate the sun's orbital position and its velocity. 323 /// Calculate the sun's orbital position and its velocity.
279 /// </summary> 324 /// </summary>
@@ -370,5 +415,20 @@ namespace OpenSim.Region.Environment.Modules
370 } 415 }
371 } 416 }
372 } 417 }
418
419 public void EstateToolsTimeUpdate(ulong regionHandle, bool FixedTime, bool useEstateTime, float LindenHour)
420 {
421 if (m_scene.RegionInfo.RegionHandle == regionHandle)
422 {
423 SetTimeByLindenHour(LindenHour);
424
425 //if (useEstateTime)
426 //LindenHourOffset = 0;
427
428 //ForceSunUpdateToAllClients();
429 //ready = true;// !FixedTime;
430
431 }
432 }
373 } 433 }
374} 434}