diff options
author | Teravus Ovares | 2008-05-30 23:41:51 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-05-30 23:41:51 +0000 |
commit | f433927722f0169ca19eae05bd69fdd9f6f466e7 (patch) | |
tree | 0c678f01b39b9d6a71b2f9cfba31a2658f8f7e38 /OpenSim/Region/Environment | |
parent | * Hook up archive loading to load in prim xml data (diff) | |
download | opensim-SC_OLD-f433927722f0169ca19eae05bd69fdd9f6f466e7.zip opensim-SC_OLD-f433927722f0169ca19eae05bd69fdd9f6f466e7.tar.gz opensim-SC_OLD-f433927722f0169ca19eae05bd69fdd9f6f466e7.tar.bz2 opensim-SC_OLD-f433927722f0169ca19eae05bd69fdd9f6f466e7.tar.xz |
* You can set the sun phase via the estate tools now. It doesn't persist across reboots though.
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs index 7e4877c..e2b35c5 100644 --- a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs | |||
@@ -94,10 +94,9 @@ 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 | |
98 | private long LindenHourOffset = 0; | 98 | private long LindenHourOffset = 0; |
99 | private bool sunFixed = false; | 99 | private bool sunFixed = false; |
100 | private long estateTicksOffset = 0; | ||
101 | 100 | ||
102 | private Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>(); | 101 | private Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>(); |
103 | 102 | ||
@@ -105,7 +104,6 @@ namespace OpenSim.Region.Environment.Modules | |||
105 | private ulong CurrentTime | 104 | private ulong CurrentTime |
106 | { | 105 | { |
107 | get { | 106 | get { |
108 | //m_log.Debug("[LH]: " + LindenHourOffset.ToString()); | ||
109 | return (ulong)(((System.DateTime.Now.Ticks) - TicksToEpoch + TicksOffset + LindenHourOffset)/10000000); | 107 | return (ulong)(((System.DateTime.Now.Ticks) - TicksToEpoch + TicksOffset + LindenHourOffset)/10000000); |
110 | } | 108 | } |
111 | } | 109 | } |
@@ -113,27 +111,26 @@ namespace OpenSim.Region.Environment.Modules | |||
113 | private float GetLindenEstateHourFromCurrentTime() | 111 | private float GetLindenEstateHourFromCurrentTime() |
114 | { | 112 | { |
115 | float ticksleftover = ((float)CurrentTime) % ((float)SecondsPerSunCycle); | 113 | float ticksleftover = ((float)CurrentTime) % ((float)SecondsPerSunCycle); |
116 | //m_log.Debug("[TICKS]: " + ticksleftover.ToString()); | 114 | |
117 | float hour = (24 * (ticksleftover / SecondsPerSunCycle)) + 6; | 115 | float hour = (24 * (ticksleftover / SecondsPerSunCycle)) + 6; |
118 | //m_log.Debug("[LINDENHOUR]: " + hour.ToString()); | ||
119 | //m_log.Debug("[SunCycle]: " + (ticksleftover / 3600)); | ||
120 | //m_log.Debug("[DayLength]: " + m_day_length.ToString()); | ||
121 | 116 | ||
122 | return hour; | 117 | return hour; |
123 | } | 118 | } |
124 | 119 | ||
125 | private void SetTimeByLindenHour(float LindenHour) | 120 | private void SetTimeByLindenHour(float LindenHour) |
126 | { | 121 | { |
122 | // Linden hour is 24 hours with a 6 hour offset. 6-30 | ||
123 | |||
127 | if (LindenHour - 6 == 0) | 124 | if (LindenHour - 6 == 0) |
128 | { | 125 | { |
129 | LindenHourOffset = 0; | 126 | LindenHourOffset = 0; |
130 | return; | 127 | return; |
131 | } | 128 | } |
132 | //TimeZone local = TimeZone.CurrentTimeZone; | ||
133 | //TicksOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; | ||
134 | 129 | ||
130 | // Remove LindenHourOffset to calculate it from LocalTime | ||
135 | float ticksleftover = ((float)(((long)(CurrentTime * 10000000) - (long)LindenHourOffset)/ 10000000) % ((float)SecondsPerSunCycle)); | 131 | float ticksleftover = ((float)(((long)(CurrentTime * 10000000) - (long)LindenHourOffset)/ 10000000) % ((float)SecondsPerSunCycle)); |
136 | float hour = (24 * (ticksleftover / SecondsPerSunCycle)); | 132 | float hour = (24 * (ticksleftover / SecondsPerSunCycle)); |
133 | |||
137 | float offsethours = 0; | 134 | float offsethours = 0; |
138 | 135 | ||
139 | if (LindenHour - 6 > hour) | 136 | if (LindenHour - 6 > hour) |
@@ -145,8 +142,9 @@ namespace OpenSim.Region.Environment.Modules | |||
145 | offsethours = hour - (hour - (LindenHour - 6)); | 142 | offsethours = hour - (hour - (LindenHour - 6)); |
146 | } | 143 | } |
147 | //m_log.Debug("[OFFSET]: " + hour + " - " + LindenHour + " - " + offsethours.ToString()); | 144 | //m_log.Debug("[OFFSET]: " + hour + " - " + LindenHour + " - " + offsethours.ToString()); |
148 | //LindenHourOffset = (long)((float)offsethours * (-14400000)); | 145 | |
149 | //m_log.Debug("[SUN]: Using " + CurrentTime.ToString()); | 146 | LindenHourOffset = (long)((float)offsethours * (36000000000/m_day_length)); |
147 | m_log.Info("[SUN]: Directive from the Estate Tools to set the sun phase to LindenHour " + GetLindenEstateHourFromCurrentTime().ToString()); | ||
150 | 148 | ||
151 | } | 149 | } |
152 | // Called immediately after the module is loaded for a given region | 150 | // Called immediately after the module is loaded for a given region |
@@ -163,7 +161,6 @@ namespace OpenSim.Region.Environment.Modules | |||
163 | 161 | ||
164 | TimeZone local = TimeZone.CurrentTimeZone; | 162 | TimeZone local = TimeZone.CurrentTimeZone; |
165 | TicksOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; | 163 | TicksOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; |
166 | |||
167 | m_log.Debug("[SUN] localtime offset is " + TicksOffset); | 164 | m_log.Debug("[SUN] localtime offset is " + TicksOffset); |
168 | 165 | ||
169 | // Align ticks with Second Life | 166 | // Align ticks with Second Life |
@@ -277,7 +274,8 @@ namespace OpenSim.Region.Environment.Modules | |||
277 | { | 274 | { |
278 | if (ready) | 275 | if (ready) |
279 | { | 276 | { |
280 | GenSunPos(); // Generate shared values once | 277 | if (!sunFixed) |
278 | GenSunPos(); // Generate shared values once | ||
281 | client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); | 279 | client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); |
282 | m_log.Debug("[SUN] Initial update for new client"); | 280 | m_log.Debug("[SUN] Initial update for new client"); |
283 | } | 281 | } |
@@ -286,7 +284,7 @@ namespace OpenSim.Region.Environment.Modules | |||
286 | 284 | ||
287 | public void SunUpdate() | 285 | public void SunUpdate() |
288 | { | 286 | { |
289 | if (((m_frame++%m_frame_mod) != 0) || !ready) | 287 | if (((m_frame++%m_frame_mod) != 0) || !ready || sunFixed) |
290 | { | 288 | { |
291 | return; | 289 | return; |
292 | } | 290 | } |
@@ -426,7 +424,10 @@ namespace OpenSim.Region.Environment.Modules | |||
426 | //LindenHourOffset = 0; | 424 | //LindenHourOffset = 0; |
427 | 425 | ||
428 | //ForceSunUpdateToAllClients(); | 426 | //ForceSunUpdateToAllClients(); |
429 | //ready = true;// !FixedTime; | 427 | sunFixed = FixedTime; |
428 | if (sunFixed) | ||
429 | GenSunPos(); | ||
430 | |||
430 | 431 | ||
431 | } | 432 | } |
432 | } | 433 | } |