mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-17 09:22:42 +01:00
Codechange: move all date-related variables inside the timer (#10706)
This commit is contained in:
22
src/date.cpp
22
src/date.cpp
@@ -25,30 +25,8 @@
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
Year _cur_year; ///< Current year, starting at 0
|
||||
Month _cur_month; ///< Current month (0..11)
|
||||
Date _date; ///< Current date in days (day counter)
|
||||
DateFract _date_fract; ///< Fractional part of the day.
|
||||
uint64 _tick_counter; ///< Ever incrementing tick counter for setting off various events
|
||||
|
||||
/**
|
||||
* Set the date.
|
||||
* @param date New date
|
||||
* @param fract The number of ticks that have passed on this date.
|
||||
*/
|
||||
void SetDate(Date date, DateFract fract)
|
||||
{
|
||||
assert(fract < DAY_TICKS);
|
||||
|
||||
YearMonthDay ymd;
|
||||
|
||||
_date = date;
|
||||
_date_fract = fract;
|
||||
ConvertDateToYMD(date, &ymd);
|
||||
_cur_year = ymd.year;
|
||||
_cur_month = ymd.month;
|
||||
}
|
||||
|
||||
#define M(a, b) ((a << 5) | b)
|
||||
static const uint16 _month_date_from_year_day[] = {
|
||||
M( 0, 1), M( 0, 2), M( 0, 3), M( 0, 4), M( 0, 5), M( 0, 6), M( 0, 7), M( 0, 8), M( 0, 9), M( 0, 10), M( 0, 11), M( 0, 12), M( 0, 13), M( 0, 14), M( 0, 15), M( 0, 16), M( 0, 17), M( 0, 18), M( 0, 19), M( 0, 20), M( 0, 21), M( 0, 22), M( 0, 23), M( 0, 24), M( 0, 25), M( 0, 26), M( 0, 27), M( 0, 28), M( 0, 29), M( 0, 30), M( 0, 31),
|
||||
|
||||
Reference in New Issue
Block a user