Codechange: Add to_underlying() to convert enum to underlying type. (#12958)
This simplifies and replaces static_cast and C-style casts doing the same. `std::to_underlying()` exists in C++23 but not C++20.
This commit is contained in:
@@ -1200,7 +1200,7 @@ int GetEngineProperty(EngineID engine, PropertyID property, int orig_value, cons
|
||||
*/
|
||||
bool TestVehicleBuildProbability(Vehicle *v, EngineID engine, BuildProbabilityType type)
|
||||
{
|
||||
uint16_t p = GetVehicleCallback(CBID_VEHICLE_BUILD_PROBABILITY, std::underlying_type<BuildProbabilityType>::type(type), 0, engine, v);
|
||||
uint16_t p = GetVehicleCallback(CBID_VEHICLE_BUILD_PROBABILITY, to_underlying(type), 0, engine, v);
|
||||
if (p == CALLBACK_FAILED) return false;
|
||||
|
||||
const uint16_t PROBABILITY_RANGE = 100;
|
||||
|
||||
Reference in New Issue
Block a user