diff options
-rw-r--r-- | OpenSim/Region/CoreModules/World/Sun/SunModule.cs | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index e04cb29..561552a 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs | |||
@@ -261,10 +261,8 @@ namespace OpenSim.Region.CoreModules | |||
261 | 261 | ||
262 | private float GetCurrentTimeAsLindenSunHour() | 262 | private float GetCurrentTimeAsLindenSunHour() |
263 | { | 263 | { |
264 | if (m_SunFixed) | 264 | float curtime = m_SunFixed ? m_SunFixedHour : GetCurrentSunHour(); |
265 | return m_SunFixedHour + 6; | 265 | return (curtime + 6.0f) % 24.0f; |
266 | |||
267 | return GetCurrentSunHour() + 6.0f; | ||
268 | } | 266 | } |
269 | 267 | ||
270 | #region INonSharedRegion Methods | 268 | #region INonSharedRegion Methods |
@@ -517,7 +515,7 @@ namespace OpenSim.Region.CoreModules | |||
517 | return m_UpdateInterval; | 515 | return m_UpdateInterval; |
518 | 516 | ||
519 | case "current_time": | 517 | case "current_time": |
520 | return CurrentTime; | 518 | return GetCurrentTimeAsLindenSunHour(); |
521 | 519 | ||
522 | default: | 520 | default: |
523 | throw new Exception("Unknown sun parameter."); | 521 | throw new Exception("Unknown sun parameter."); |
@@ -526,7 +524,51 @@ namespace OpenSim.Region.CoreModules | |||
526 | 524 | ||
527 | public void SetSunParameter(string param, double value) | 525 | public void SetSunParameter(string param, double value) |
528 | { | 526 | { |
529 | HandleSunConsoleCommand("sun", new string[] {param, value.ToString() }); | 527 | switch (param) |
528 | { | ||
529 | case "year_length": | ||
530 | m_YearLengthDays = (int)value; | ||
531 | SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays); | ||
532 | SeasonSpeed = m_SeasonalCycle/SecondsPerYear; | ||
533 | break; | ||
534 | |||
535 | case "day_length": | ||
536 | m_DayLengthHours = value; | ||
537 | SecondsPerSunCycle = (uint) (m_DayLengthHours * 60 * 60); | ||
538 | SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays); | ||
539 | SunSpeed = m_SunCycle/SecondsPerSunCycle; | ||
540 | SeasonSpeed = m_SeasonalCycle/SecondsPerYear; | ||
541 | break; | ||
542 | |||
543 | case "day_night_offset": | ||
544 | m_HorizonShift = value; | ||
545 | HorizonShift = m_HorizonShift; | ||
546 | break; | ||
547 | |||
548 | case "day_time_sun_hour_scale": | ||
549 | m_DayTimeSunHourScale = value; | ||
550 | break; | ||
551 | |||
552 | case "update_interval": | ||
553 | m_UpdateInterval = (int)value; | ||
554 | break; | ||
555 | |||
556 | case "current_time": | ||
557 | value = (value + 18.0) % 24.0; | ||
558 | // set the current offset so that the effective sun time is the parameter | ||
559 | m_CurrentTimeOffset = 0; // clear this first so we use raw time | ||
560 | m_CurrentTimeOffset = (ulong)(SecondsPerSunCycle * value/ 24.0) - (CurrentTime % SecondsPerSunCycle); | ||
561 | break; | ||
562 | |||
563 | default: | ||
564 | throw new Exception("Unknown sun parameter."); | ||
565 | |||
566 | // Generate shared values | ||
567 | GenSunPos(); | ||
568 | |||
569 | // When sun settings are updated, we should update all clients with new settings. | ||
570 | SunUpdateToAllClients(); | ||
571 | } | ||
530 | } | 572 | } |
531 | 573 | ||
532 | public float GetCurrentSunHour() | 574 | public float GetCurrentSunHour() |
@@ -606,57 +648,15 @@ namespace OpenSim.Region.CoreModules | |||
606 | } | 648 | } |
607 | else if (args.Length == 3) | 649 | else if (args.Length == 3) |
608 | { | 650 | { |
609 | float value = 0.0f; | 651 | double value = 0.0; |
610 | if (!float.TryParse(args[2], out value)) | 652 | if (! double.TryParse(args[2], out value)) |
611 | { | 653 | { |
612 | Output.Add(String.Format("The parameter value {0} is not a valid number.", args[2])); | 654 | Output.Add(String.Format("The parameter value {0} is not a valid number.", args[2])); |
655 | return Output; | ||
613 | } | 656 | } |
614 | 657 | ||
615 | switch (args[1].ToLower()) | 658 | SetSunParameter(args[1].ToLower(), value); |
616 | { | ||
617 | case "year_length": | ||
618 | m_YearLengthDays = (int)value; | ||
619 | SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays); | ||
620 | break; | ||
621 | |||
622 | case "day_length": | ||
623 | m_DayLengthHours = value; | ||
624 | SecondsPerSunCycle = (uint) (m_DayLengthHours * 60 * 60); | ||
625 | SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays); | ||
626 | break; | ||
627 | |||
628 | case "day_night_offset": | ||
629 | m_HorizonShift = value; | ||
630 | HorizonShift = m_HorizonShift; | ||
631 | break; | ||
632 | |||
633 | case "day_time_sun_hour_scale": | ||
634 | m_DayTimeSunHourScale = value; | ||
635 | break; | ||
636 | |||
637 | case "update_interval": | ||
638 | m_UpdateInterval = (int)value; | ||
639 | break; | ||
640 | |||
641 | case "current_time": | ||
642 | // best to get the current time offset out of the currenttime equation then | ||
643 | // reset it | ||
644 | m_CurrentTimeOffset = 0; | ||
645 | m_CurrentTimeOffset = CurrentTime - (ulong)value; | ||
646 | break; | ||
647 | |||
648 | default: | ||
649 | Output.Add(String.Format("Unknown parameter {0}.", args[1])); | ||
650 | return Output; | ||
651 | } | ||
652 | |||
653 | Output.Add(String.Format("Parameter {0} set to {1}.", args[1], value.ToString())); | 659 | Output.Add(String.Format("Parameter {0} set to {1}.", args[1], value.ToString())); |
654 | |||
655 | // Generate shared values | ||
656 | GenSunPos(); | ||
657 | |||
658 | // When sun settings are updated, we should update all clients with new settings. | ||
659 | SunUpdateToAllClients(); | ||
660 | } | 660 | } |
661 | 661 | ||
662 | return Output; | 662 | return Output; |