From 514fedc92afaf166a630d56a65f02dc88f816250 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sun, 29 Dec 2019 21:05:35 -0500 Subject: [PATCH] Use a slightly more accurate lunar month Previously the in-game lunar month was exactly one third of a season (30.333 days, by default). This meant that the lunar cycle matched perfectly with the seasons / years, unlike the real-world lunar cycle which is inconveniently mismatched with other calendar units. Switch it so that, for the default season length, the lunar cycle matches the real-world synodic month of about 29.5 days. Also tidy up the code so that it's clearer how this value is arrived at. --- src/calendar.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calendar.cpp b/src/calendar.cpp index 587f5bb6fa587..d61aa0d11f5b4 100644 --- a/src/calendar.cpp +++ b/src/calendar.cpp @@ -59,9 +59,10 @@ double default_daylight_level() moon_phase get_moon_phase( const time_point &p ) { - //One full phase every 1 rl months = 1/3 season length - const time_duration moon_phase_duration = calendar::season_length() / 3.0; - //Switch moon phase at noon so it stays the same all night + static constexpr time_duration synodic_month = 29.530588853 * 1_days; + const time_duration moon_phase_duration = + calendar::season_from_default_ratio() * synodic_month; + // Switch moon phase at noon so it stays the same all night const time_duration current_day = ( p - calendar::turn_zero ) + 1_days / 2; const double phase_change = current_day / moon_phase_duration; const int current_phase = static_cast( round( phase_change * MOON_PHASE_MAX ) ) %