Codechange: make TimerGameCalendar Date and Year types strongly typed (#10761)
This commit is contained in:
@@ -6512,18 +6512,18 @@ bool GetGlobalVariable(byte param, uint32_t *value, const GRFFile *grffile)
|
||||
{
|
||||
switch (param) {
|
||||
case 0x00: // current date
|
||||
*value = std::max(TimerGameCalendar::date - DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameCalendar::Date(0));
|
||||
*value = static_cast<int32_t>(std::max(TimerGameCalendar::date - DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameCalendar::Date(0)));
|
||||
return true;
|
||||
|
||||
case 0x01: // current year
|
||||
*value = Clamp(TimerGameCalendar::year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
|
||||
*value = static_cast<int32_t>(Clamp(TimerGameCalendar::year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR);
|
||||
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)
|
||||
TimerGameCalendar::YearMonthDay ymd;
|
||||
TimerGameCalendar::ConvertDateToYMD(TimerGameCalendar::date, &ymd);
|
||||
TimerGameCalendar::Date start_of_year = TimerGameCalendar::ConvertYMDToDate(ymd.year, 0, 1);
|
||||
*value = ymd.month | (ymd.day - 1) << 8 | (TimerGameCalendar::IsLeapYear(ymd.year) ? 1 << 15 : 0) | (TimerGameCalendar::date - start_of_year) << 16;
|
||||
*value = ymd.month | (ymd.day - 1) << 8 | (TimerGameCalendar::IsLeapYear(ymd.year) ? 1 << 15 : 0) | static_cast<int32_t>(TimerGameCalendar::date - start_of_year) << 16;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6629,11 +6629,11 @@ bool GetGlobalVariable(byte param, uint32_t *value, const GRFFile *grffile)
|
||||
return true;
|
||||
|
||||
case 0x23: // long format date
|
||||
*value = TimerGameCalendar::date;
|
||||
*value = static_cast<int32_t>(TimerGameCalendar::date);
|
||||
return true;
|
||||
|
||||
case 0x24: // long format year
|
||||
*value = TimerGameCalendar::year;
|
||||
*value = static_cast<int32_t>(TimerGameCalendar::year);
|
||||
return true;
|
||||
|
||||
default: return false;
|
||||
@@ -7228,7 +7228,7 @@ static uint32_t GetPatchVariable(uint8_t param)
|
||||
{
|
||||
switch (param) {
|
||||
/* start year - 1920 */
|
||||
case 0x0B: return std::max(_settings_game.game_creation.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR;
|
||||
case 0x0B: return static_cast<int32_t>(std::max(_settings_game.game_creation.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR);
|
||||
|
||||
/* freight trains weight factor */
|
||||
case 0x0E: return _settings_game.vehicle.freight_trains;
|
||||
|
Reference in New Issue
Block a user