Skip to content

Commit d00c6d9

Browse files
committed
Reimplemented daylight offset as debug commands
1 parent bfba8f0 commit d00c6d9

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

Source/ORTS.Common/Input/UserCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public enum UserCommand
6161
[GetString("Debug Precipitation Decrease")] DebugPrecipitationDecrease,
6262
[GetString("Debug Precipitation Liquidity Increase")] DebugPrecipitationLiquidityIncrease,
6363
[GetString("Debug Precipitation Liquidity Decrease")] DebugPrecipitationLiquidityDecrease,
64+
[GetString("Debug Daylight Offset Increase")] DebugDaylightOffsetIncrease,
65+
[GetString("Debug Daylight Offset Decrease")] DebugDaylightOffsetDecrease,
6466
[GetString("Debug Weather Change")] DebugWeatherChange,
6567
[GetString("Debug Clock Forwards")] DebugClockForwards,
6668
[GetString("Debug Clock Backwards")] DebugClockBackwards,

Source/ORTS.Settings/InputSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ static void InitializeCommands(UserCommandInput[] Commands)
474474
Commands[(int)UserCommand.DebugLockShadows] = new UserCommandKeyInput(0x1F, KeyModifiers.Control | KeyModifiers.Alt);
475475
Commands[(int)UserCommand.DebugLogger] = new UserCommandKeyInput(0x58);
476476
Commands[(int)UserCommand.DebugLogRenderFrame] = new UserCommandKeyInput(0x58, KeyModifiers.Alt);
477+
Commands[(int)UserCommand.DebugDaylightOffsetDecrease] = new UserCommandKeyInput(0x0C, KeyModifiers.Shift | KeyModifiers.Alt);
478+
Commands[(int)UserCommand.DebugDaylightOffsetIncrease] = new UserCommandKeyInput(0x0D, KeyModifiers.Shift | KeyModifiers.Alt);
477479
Commands[(int)UserCommand.DebugOvercastDecrease] = new UserCommandKeyInput(0x0C, KeyModifiers.Control);
478480
Commands[(int)UserCommand.DebugOvercastIncrease] = new UserCommandKeyInput(0x0D, KeyModifiers.Control);
479481
Commands[(int)UserCommand.DebugPhysicsForm] = new UserCommandKeyInput(0x3D, KeyModifiers.Alt);

Source/Orts.Simulation/Simulation/Weather.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public class Weather
4444

4545
// Fog/visibility distance. Ranges from 10m (can't see anything), 5km (medium), 20km (clear) to 100km (clear arctic).
4646
public float FogDistance;
47+
48+
// Daylight offset (-12h to +12h)
49+
public int DaylightOffset = 0;
4750

4851
// Precipitation liquidity; =1 for rain, =0 for snow; intermediate values possible with dynamic weather;
4952
public float PrecipitationLiquidity;

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 => (Program.DebugViewer == null) ? 0f : (float)Program.DebugViewer.DaylightOffsetHrs * 60 * 60;
32+
static float DaylightOffsetS => (float)Program.Simulator.Weather.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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// COPYRIGHT 2010, 2011, 2014 by the Open Rails project.
1+
// COPYRIGHT 2010, 2011, 2014 by the Open Rails project.
22
//
33
// This file is part of Open Rails.
44
//
@@ -487,6 +487,15 @@ public virtual void Update(ElapsedTime elapsedTime)
487487
weatherChangeOn = false;
488488
}
489489

490+
// Daylight offset is useful for debugging night running timetables; it ranges from -12h to +12h
491+
if (UserInput.IsPressed(UserCommand.DebugDaylightOffsetIncrease) && Weather.DaylightOffset < 12) {
492+
Weather.DaylightOffset += 1;
493+
}
494+
if (UserInput.IsPressed(UserCommand.DebugDaylightOffsetDecrease) && Weather.DaylightOffset > -12)
495+
{
496+
Weather.DaylightOffset -= 1;
497+
}
498+
490499
UpdateWind(elapsedTime);
491500
}
492501

0 commit comments

Comments
 (0)