1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-20 19:02:41 +01:00

Codechange: Use EnumBitSet for VehicleFlags. (#13793)

This commit is contained in:
Peter Nelson
2025-03-13 08:38:54 +00:00
committed by GitHub
parent dc343ca141
commit 8b39b23d2b
14 changed files with 83 additions and 81 deletions

View File

@@ -223,7 +223,7 @@ struct TimetableWindow : Window {
*/
static bool BuildArrivalDepartureList(const Vehicle *v, std::vector<TimetableArrivalDeparture> &table)
{
assert(HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED));
assert(v->vehicle_flags.Test(VehicleFlag::TimetableStarted));
bool travelling = (!v->current_order.IsType(OT_LOADING) || v->current_order.GetNonStopType() == ONSF_STOP_EVERYWHERE);
TimerGameTick::Ticks start_time = -v->current_order_time;
@@ -391,7 +391,7 @@ struct TimetableWindow : Window {
this->DisableWidget(WID_VT_SHARED_ORDER_LIST);
}
this->SetWidgetLoweredState(WID_VT_AUTOFILL, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE));
this->SetWidgetLoweredState(WID_VT_AUTOFILL, v->vehicle_flags.Test(VehicleFlag::AutofillTimetable));
this->DrawWidgets();
}
@@ -496,7 +496,7 @@ struct TimetableWindow : Window {
* i.e. are only shown if we can calculate all times.
* Excluding order lists with only one order makes some things easier. */
TimerGameTick::Ticks total_time = v->orders != nullptr ? v->orders->GetTimetableDurationIncomplete() : 0;
if (total_time <= 0 || v->GetNumOrders() <= 1 || !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) return;
if (total_time <= 0 || v->GetNumOrders() <= 1 || !v->vehicle_flags.Test(VehicleFlag::TimetableStarted)) return;
std::vector<TimetableArrivalDeparture> arr_dep(v->GetNumOrders());
const VehicleOrderID cur_order = v->cur_real_order_index % v->GetNumOrders();
@@ -595,7 +595,7 @@ struct TimetableWindow : Window {
/* Other units use dates. */
DrawString(tr, GetString(STR_TIMETABLE_STATUS_START_AT_DATE, STR_JUST_DATE_TINY, GetDateFromStartTick(v->timetable_start)));
}
} else if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) {
} else if (!v->vehicle_flags.Test(VehicleFlag::TimetableStarted)) {
/* We aren't running on a timetable yet. */
DrawString(tr, STR_TIMETABLE_STATUS_NOT_STARTED);
} else if (!VehicleIsAboveLatenessThreshold(abs(v->lateness_counter), false)) {
@@ -734,7 +734,7 @@ struct TimetableWindow : Window {
break;
case WID_VT_AUTOFILL: { // Autofill the timetable.
Command<CMD_AUTOFILL_TIMETABLE>::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, !HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE), _ctrl_pressed);
Command<CMD_AUTOFILL_TIMETABLE>::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, !v->vehicle_flags.Test(VehicleFlag::AutofillTimetable), _ctrl_pressed);
break;
}