From 3ebb0061fd1c573b909d1708f034c4024fbb1c34 Mon Sep 17 00:00:00 2001 From: Williham Totland Date: Wed, 2 Jul 2014 09:05:24 +0000 Subject: [PATCH] further calendar extensions --- src/calendar.h | 6 +++--- src/weather_gen.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/calendar.h b/src/calendar.h index a35c3742ceff9..92072bd088998 100644 --- a/src/calendar.h +++ b/src/calendar.h @@ -112,12 +112,12 @@ class calendar // Season and year lenght stuff + static int year_turns() { return DAYS(year_length()); } static int year_length() { return season_length() * 4; } static int season_length(); - int day_of_year() { - return day + season_length() * season; - } + int turn_of_year() { return turn_number % year_turns(); } + int day_of_year() { return day + season_length() * season; } // Print-friendly stuff std::string print_time(bool just_hour = false) const; diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index 30822ad243a85..d43d34f11ed7f 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -27,7 +27,7 @@ w_point weather_generator::get_weather(double x, double y, calendar t) { double P(Pressure.noise(x, y, z / 3) * 70); // temperature variation - const double now((t.day_of_year() + dayFraction) / (double)calendar::year_length()); // Add the minutes to the day and return the current time as a decimal [0-1] + const double now((double)t.turn_of_year() / (double)calendar::year_turns()); // [0,1) const double ctn(cos(tau * now)); const double mod_t = 0; // TODO: make this depend on latitude and altitude? const double current_t = this->base_t + mod_t; // Current baseline temperature. Degrees Celsius.