Codechange: Add base() method to StrongType to allow access to the base type without casting. (#11445)

This removes the ability to explicitly cast to the base type, but the requirement
to use .base() means the conversion is still explicit.
This commit is contained in:
Peter Nelson
2023-11-06 20:29:35 +00:00
committed by GitHub
parent 737775f834
commit ab535c0a86
73 changed files with 174 additions and 173 deletions

View File

@@ -75,8 +75,8 @@ static const uint16_t _accum_days_for_month[] = {
*/
/* There are 97 leap years in 400 years */
TimerGameCalendar::Year yr = 400 * (static_cast<int32_t>(date) / (CalendarTime::DAYS_IN_YEAR * 400 + 97));
int rem = static_cast<int32_t>(date) % (CalendarTime::DAYS_IN_YEAR * 400 + 97);
TimerGameCalendar::Year yr = 400 * (date.base() / (CalendarTime::DAYS_IN_YEAR * 400 + 97));
int rem = date.base() % (CalendarTime::DAYS_IN_YEAR * 400 + 97);
uint16_t x;
if (rem >= CalendarTime::DAYS_IN_YEAR * 100 + 25) {
@@ -141,7 +141,7 @@ static const uint16_t _accum_days_for_month[] = {
*/
/* static */ bool TimerGameCalendar::IsLeapYear(TimerGameCalendar::Year yr)
{
return static_cast<int32_t>(yr) % 4 == 0 && (static_cast<int32_t>(yr) % 100 != 0 || static_cast<int32_t>(yr) % 400 == 0);
return yr.base() % 4 == 0 && (yr.base() % 100 != 0 || yr.base() % 400 == 0);
}
/**
@@ -215,7 +215,7 @@ void TimerManager<TimerGameCalendar>::Elapsed([[maybe_unused]] TimerGameCalendar
timer->Elapsed(TimerGameCalendar::DAY);
}
if ((static_cast<int32_t>(TimerGameCalendar::date) % 7) == 3) {
if ((TimerGameCalendar::date.base() % 7) == 3) {
for (auto timer : timers) {
timer->Elapsed(TimerGameCalendar::WEEK);
}