Remove costly recalculation of a date format we already have.

(cherry picked from commit 6aca18d18252f1c2f6d4a215999b7d7afb7df813)

See #36
This commit is contained in:
keldorkatarn
2018-04-10 04:51:24 +02:00
committed by Jonathan G Rennison
parent 9ab2b8fa3e
commit 4955996b35
8 changed files with 12 additions and 19 deletions

View File

@@ -5780,10 +5780,8 @@ bool GetGlobalVariable(byte param, uint32 *value, const GRFFile *grffile)
return true;
case 0x02: { // detailed date information: month of year (bit 0-7), day of month (bit 8-12), leap year (bit 15), day of year (bit 16-24)
YearMonthDay ymd;
ConvertDateToYMD(_date, &ymd);
Date start_of_year = ConvertYMDToDate(ymd.year, 0, 1);
*value = ymd.month | (ymd.day - 1) << 8 | (IsLeapYear(ymd.year) ? 1 << 15 : 0) | (_date - start_of_year) << 16;
Date start_of_year = ConvertYMDToDate(_cur_date_ymd.year, 0, 1);
*value = _cur_date_ymd.month | (_cur_date_ymd.day - 1) << 8 | (IsLeapYear(_cur_date_ymd.year) ? 1 << 15 : 0) | (_date - start_of_year) << 16;
return true;
}