Codechange: Use DateAtStartOfYear() instead of multiplying by DAYS_IN_LEAP_YEAR (#11174)

This commit is contained in:
Tyler Trahan
2023-08-11 08:18:59 -04:00
committed by GitHub
parent 93069066f9
commit e4fd99a33a
4 changed files with 40 additions and 39 deletions

View File

@@ -1377,9 +1377,11 @@ void AgeVehicle(Vehicle *v)
if (!v->IsPrimaryVehicle() && (v->type != VEH_TRAIN || !Train::From(v)->IsEngine())) return;
int age = v->age - v->max_age;
if (age == DAYS_IN_LEAP_YEAR * 0 || age == DAYS_IN_LEAP_YEAR * 1 ||
age == DAYS_IN_LEAP_YEAR * 2 || age == DAYS_IN_LEAP_YEAR * 3 || age == DAYS_IN_LEAP_YEAR * 4) {
v->reliability_spd_dec <<= 1;
for (int32_t i = 0; i <= 4; i++) {
if (age == DateAtStartOfYear(i)) {
v->reliability_spd_dec <<= 1;
break;
}
}
SetWindowDirty(WC_VEHICLE_DETAILS, v->index);