Skip to content

Commit 1a70945

Browse files
committed
fix: Move daylight offset entirely into Viewer
1 parent 0daa2d4 commit 1a70945

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

Source/Orts.Simulation/Simulation/Weather.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,5 @@ public float WindInstantaneousDirectionRad
108108
get => (float)Math.Atan2(WindInstantaneousDirection.X, -WindInstantaneousDirection.Y);
109109
set => WindInstantaneousDirection = new Vector2((float)Math.Sin(value), -(float)Math.Cos(value));
110110
}
111-
112-
// FIXME: This is not a weather simulation field
113-
// Daylight offset (-12h to +12h)
114-
public int DaylightOffset = 0;
115111
}
116112
}

Source/RunActivity/Viewer3D/SkyInterpolation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class SkyInterpolation
2929
public int Step1;
3030
public int Step2;
3131

32-
static float DaylightOffsetS => (float)Program.Simulator.Weather.DaylightOffset * 60 * 60;
32+
static float DaylightOffsetS => (float)Program.Viewer.World.WeatherControl.DaylightOffset * 60 * 60;
3333

3434
public void SetSunAndMoonDirection(ref Vector3 solarDirection, ref Vector3 lunarDirection, Vector3[] solarPosArray, Vector3[] lunarPosArray, double clockTime)
3535
{

Source/RunActivity/Viewer3D/Weather.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public class WeatherControl
6060
private readonly float[,] DesertZones = { { 30, 45, -120, -105 } }; // minlat, maxlat, minlong, maxlong
6161
public float Time;
6262

63+
// Daylight offset (-12h to +12h)
64+
public int DaylightOffset = 0;
65+
6366
// Variables used for wind calculations
6467
const int WindSpeedBeaufort = 6;
6568
const float WindInstantaneousDirectionLimitRad = (float)(45 * Math.PI / 180);
@@ -537,16 +540,16 @@ public virtual void Update(ElapsedTime elapsedTime)
537540

538541
// Daylight offset is useful for debugging night running timetables; it ranges from -12h to +12h
539542
string FormatDaylightOffsetHour(int h) => h <= 0 ? h.ToString() : $"+{h}";
540-
if (UserInput.IsPressed(UserCommand.DebugDaylightOffsetIncrease) && Weather.DaylightOffset < 12)
543+
if (UserInput.IsPressed(UserCommand.DebugDaylightOffsetIncrease) && DaylightOffset < 12)
541544
{
542-
Weather.DaylightOffset += 1;
543-
Viewer.Simulator.Confirmer.Message(ConfirmLevel.None, Viewer.Catalog.GetStringFmt("Increased daylight offset to {0} h", FormatDaylightOffsetHour(Weather.DaylightOffset)));
545+
DaylightOffset += 1;
546+
Viewer.Simulator.Confirmer.Message(ConfirmLevel.None, Viewer.Catalog.GetStringFmt("Increased daylight offset to {0} h", FormatDaylightOffsetHour(DaylightOffset)));
544547
}
545548

546-
if (UserInput.IsPressed(UserCommand.DebugDaylightOffsetDecrease) && Weather.DaylightOffset > -12)
549+
if (UserInput.IsPressed(UserCommand.DebugDaylightOffsetDecrease) && DaylightOffset > -12)
547550
{
548-
Weather.DaylightOffset -= 1;
549-
Viewer.Simulator.Confirmer.Message(ConfirmLevel.None, Viewer.Catalog.GetStringFmt("Decreased daylight offset to {0} h", FormatDaylightOffsetHour(Weather.DaylightOffset)));
551+
DaylightOffset -= 1;
552+
Viewer.Simulator.Confirmer.Message(ConfirmLevel.None, Viewer.Catalog.GetStringFmt("Decreased daylight offset to {0} h", FormatDaylightOffsetHour(DaylightOffset)));
550553
}
551554

552555
UpdateWind(elapsedTime);

0 commit comments

Comments
 (0)