Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non synchronous moon phases #36549

Merged

Conversation

jbytheway
Copy link
Contributor

@jbytheway jbytheway commented Dec 30, 2019

Summary

SUMMARY: Features "Make lunar cycle not exactly match season changes"

Purpose of change

Previously (since #35246) 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.

Describe the solution

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.

Add some tests for the lunar cycle code.

Describe alternatives you've considered

Having a fixed lunar month regardless of season length setting.

Testing

Unit tests, including the newly added test.

Additional context

I'm using Catch2 generators for this test. That's a relatively new feature which I believe we should be using in more places. This is a simple test case for that.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment will not be necessarily true with non synchronous moon cycles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that this was broken, but I think it was already broken before my changes. In any case, I've now fixed it, and added a test.

@ZhilkinSerg ZhilkinSerg added <Enhancement / Feature> New features, or enhancements on existing [C++] Changes (can be) made in C++. Previously named `Code` Time / Turns / Duration / Date Issues concerning any activities being too fast or too slow. Also issues about time and date ingame labels Dec 30, 2019
@jbytheway jbytheway force-pushed the non_synchronous_moon_phases branch from 010156f to 77e7e5b Compare December 31, 2019 03:06
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.
Pull these values out as global statics to make it clearer that the
default season length is the real-world season length.
This was failing on Mingw, probably due to -ffast-math optimizations.
This was already theoretically implemented, but it didn't work.  Fix it
and add a test.
@jbytheway jbytheway force-pushed the non_synchronous_moon_phases branch from 77e7e5b to 31bae0e Compare December 31, 2019 20:19
This one is in Catch2 internals and triggered by using generators.
@kevingranade kevingranade merged commit 0918b4e into CleverRaven:master Jan 2, 2020
@jbytheway jbytheway deleted the non_synchronous_moon_phases branch January 7, 2020 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Time / Turns / Duration / Date Issues concerning any activities being too fast or too slow. Also issues about time and date ingame
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants