diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index a2cb34741e..6c1cb21b75 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1299,7 +1299,7 @@ static int32_t cc_for_date([[maybe_unused]] InteractiveConsole& console, [[maybe if (argv.size() <= 2) { day = std::clamp( - gDateMonthTicks / (0x10000 / days_in_month[month - 1]) + 1, 1, static_cast(days_in_month[month - 1])); + gDateMonthTicks / (TICKS_PER_MONTH / days_in_month[month - 1]) + 1, 1, static_cast(days_in_month[month - 1])); } // YYYY MM DD (year, month, and day provided) diff --git a/src/openrct2/localisation/Date.h b/src/openrct2/localisation/Date.h index 4f96c1a52a..f8de349382 100644 --- a/src/openrct2/localisation/Date.h +++ b/src/openrct2/localisation/Date.h @@ -13,6 +13,7 @@ #include "../common.h" constexpr int32_t MAX_YEAR = 8192; +constexpr int32_t TICKS_PER_MONTH = 0x10000; enum { diff --git a/src/openrct2/localisation/Localisation.Date.cpp b/src/openrct2/localisation/Localisation.Date.cpp index a896ab4b1a..7d7dd6f7ec 100644 --- a/src/openrct2/localisation/Localisation.Date.cpp +++ b/src/openrct2/localisation/Localisation.Date.cpp @@ -71,13 +71,13 @@ void date_set(int32_t year, int32_t month, int32_t day) month = std::clamp(month, 1, static_cast(MONTH_COUNT)); day = std::clamp(day, 1, static_cast(days_in_month[month - 1])); gDateMonthsElapsed = (year - 1) * MONTH_COUNT + month - 1; - gDateMonthTicks = 0x10000 / days_in_month[month - 1] * (day - 1) + 4; + gDateMonthTicks = TICKS_PER_MONTH / days_in_month[month - 1] * (day - 1) + 4; } void date_update() { int32_t monthTicks = gDateMonthTicks + 4; - if (monthTicks >= 0x10000) + if (monthTicks >= TICKS_PER_MONTH) { gDateMonthTicks = 0; gDateMonthsElapsed++; diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index 2ec796e1c1..7ff2e593e8 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -356,7 +356,7 @@ static void scenario_update_daynight_cycle() if (gScreenFlags == SCREEN_FLAGS_PLAYING && gConfigGeneral.day_night_cycle) { - float monthFraction = gDateMonthTicks / static_cast(0x10000); + float monthFraction = gDateMonthTicks / static_cast(TICKS_PER_MONTH); if (monthFraction < (1 / 8.0f)) { gDayNightCycle = 0.0f;