Codechange: Make order load/unload flags value types. (#14861)

Order Load and Unload flags have complex logic to ensure that invalid combinations aren't used. In fact, apart from FullLoad and FullLoadAny, all mixed combinations are invalid.

Simplify logic by removing the use of bit values and treat each option as a value.
This commit is contained in:
Peter Nelson
2025-12-06 18:30:31 +00:00
committed by GitHub
parent abf8438a1b
commit 9adc4bfc0f
14 changed files with 160 additions and 117 deletions

View File

@@ -315,8 +315,8 @@ static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(Vehicle
break;
case OT_GOTO_STATION:
order_flags |= (ScriptOrderFlags)(order->GetLoadType() << 5);
order_flags |= (ScriptOrderFlags)(order->GetUnloadType() << 2);
order_flags |= static_cast<ScriptOrderFlags>(to_underlying(order->GetLoadType()) << 5);
order_flags |= static_cast<ScriptOrderFlags>(to_underlying(order->GetUnloadType()) << 2);
break;
default: break;
@@ -511,8 +511,8 @@ static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(Vehicle
case OT_GOTO_STATION:
order.MakeGoToStation(::GetStationIndex(destination));
order.SetLoadType((OrderLoadFlags)GB(order_flags, 5, 3));
order.SetUnloadType((OrderUnloadFlags)GB(order_flags, 2, 3));
order.SetLoadType(static_cast<OrderLoadType>(GB(order_flags, 5, 3)));
order.SetUnloadType(static_cast<OrderUnloadType>(GB(order_flags, 2, 3)));
order.SetStopLocation(OrderStopLocation::FarEnd);
break;