mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-20 02:42:42 +01:00
Codechange: Use enum class and EnumBitSet for various order flags. (#14783)
This commit is contained in:
@@ -265,10 +265,10 @@ int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, i
|
||||
|
||||
/* Default to the middle of the station for stations stops that are not in
|
||||
* the order list like intermediate stations when non-stop is disabled */
|
||||
OrderStopLocation osl = OSL_PLATFORM_MIDDLE;
|
||||
OrderStopLocation osl = OrderStopLocation::Middle;
|
||||
if (v->gcache.cached_total_length >= *station_length) {
|
||||
/* The train is longer than the station, make it stop at the far end of the platform */
|
||||
osl = OSL_PLATFORM_FAR_END;
|
||||
osl = OrderStopLocation::FarEnd;
|
||||
} else if (v->current_order.IsType(OT_GOTO_STATION) && v->current_order.GetDestination() == station_id) {
|
||||
osl = v->current_order.GetStopLocation();
|
||||
}
|
||||
@@ -278,15 +278,15 @@ int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, i
|
||||
switch (osl) {
|
||||
default: NOT_REACHED();
|
||||
|
||||
case OSL_PLATFORM_NEAR_END:
|
||||
case OrderStopLocation::NearEnd:
|
||||
stop = v->gcache.cached_total_length;
|
||||
break;
|
||||
|
||||
case OSL_PLATFORM_MIDDLE:
|
||||
case OrderStopLocation::Middle:
|
||||
stop = *station_length - (*station_length - v->gcache.cached_total_length) / 2;
|
||||
break;
|
||||
|
||||
case OSL_PLATFORM_FAR_END:
|
||||
case OrderStopLocation::FarEnd:
|
||||
stop = *station_length;
|
||||
break;
|
||||
}
|
||||
@@ -2675,7 +2675,7 @@ public:
|
||||
switch (order->GetType()) {
|
||||
case OT_GOTO_DEPOT:
|
||||
/* Skip service in depot orders when the train doesn't need service. */
|
||||
if ((order->GetDepotOrderType() & ODTFB_SERVICE) && !this->v->NeedsServicing()) break;
|
||||
if (order->GetDepotOrderType().Test(OrderDepotTypeFlag::Service) && !this->v->NeedsServicing()) break;
|
||||
[[fallthrough]];
|
||||
case OT_GOTO_STATION:
|
||||
case OT_GOTO_WAYPOINT:
|
||||
@@ -2859,7 +2859,7 @@ static Track ChooseTrainTrack(Train *v, TileIndex tile, DiagDirection enterdir,
|
||||
|
||||
orders.Restore();
|
||||
if (v->current_order.IsType(OT_GOTO_DEPOT) &&
|
||||
(v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) &&
|
||||
v->current_order.GetDepotActionType().Test(OrderDepotActionFlag::NearestDepot) &&
|
||||
final_dest != INVALID_TILE && IsRailDepotTile(final_dest)) {
|
||||
v->current_order.SetDestination(GetDepotIndex(final_dest));
|
||||
v->dest_tile = final_dest;
|
||||
@@ -4042,7 +4042,7 @@ static bool TrainLocoHandler(Train *v, bool mode)
|
||||
OrderType order_type = v->current_order.GetType();
|
||||
/* Do not skip waypoints (incl. 'via' stations) when passing through at full speed. */
|
||||
if ((order_type == OT_GOTO_WAYPOINT || order_type == OT_GOTO_STATION) &&
|
||||
(v->current_order.GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) &&
|
||||
v->current_order.GetNonStopType().Test(OrderNonStopFlag::NoDestination) &&
|
||||
IsTileType(v->tile, MP_STATION) &&
|
||||
v->current_order.GetDestination() == GetStationIndex(v->tile)) {
|
||||
ProcessOrders(v);
|
||||
@@ -4152,7 +4152,7 @@ static void CheckIfTrainNeedsService(Train *v)
|
||||
}
|
||||
|
||||
SetBit(v->gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS);
|
||||
v->current_order.MakeGoToDepot(depot, ODTFB_SERVICE, ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, ODATFB_NEAREST_DEPOT);
|
||||
v->current_order.MakeGoToDepot(depot, OrderDepotTypeFlag::Service, OrderNonStopFlag::NoIntermediate, OrderDepotActionFlag::NearestDepot);
|
||||
v->dest_tile = tfdd.tile;
|
||||
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user