mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 23:08:05 -05:00
refactor: use std::extent_v instead of std::extent
This commit is contained in:
@ -63,7 +63,7 @@ bool AssetLoaderPhysPreset::LoadFromInfoString(
|
||||
const auto presetInfo = std::make_unique<PhysPresetInfo>();
|
||||
memset(presetInfo.get(), 0, sizeof(PhysPresetInfo));
|
||||
InfoStringToPhysPresetConverter converter(
|
||||
infoString, presetInfo.get(), zone->m_script_strings, memory, manager, phys_preset_fields, std::extent<decltype(phys_preset_fields)>::value);
|
||||
infoString, presetInfo.get(), zone->m_script_strings, memory, manager, phys_preset_fields, std::extent_v<decltype(phys_preset_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse phys preset: \"" << assetName << "\"" << std::endl;
|
||||
|
@ -23,7 +23,7 @@ namespace T6
|
||||
switch (static_cast<constraintsFieldType_t>(field.iFieldType))
|
||||
{
|
||||
case CFT_TYPE:
|
||||
return ConvertEnumInt(value, field.iOffset, s_constraintTypeNames, std::extent<decltype(s_constraintTypeNames)>::value);
|
||||
return ConvertEnumInt(value, field.iOffset, s_constraintTypeNames, std::extent_v<decltype(s_constraintTypeNames)>);
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
@ -61,7 +61,7 @@ void AssetLoaderPhysConstraints::CalculatePhysConstraintsFields(PhysConstraints*
|
||||
// count
|
||||
{
|
||||
auto foundEnd = false;
|
||||
for (auto i = 0u; i < std::extent<decltype(PhysConstraints::data)>::value; i++)
|
||||
for (auto i = 0u; i < std::extent_v<decltype(PhysConstraints::data)>; i++)
|
||||
{
|
||||
if (physConstraints->data[i].type == CONSTRAINT_NONE)
|
||||
{
|
||||
@ -72,7 +72,7 @@ void AssetLoaderPhysConstraints::CalculatePhysConstraintsFields(PhysConstraints*
|
||||
}
|
||||
|
||||
if (!foundEnd)
|
||||
physConstraints->count = std::extent<decltype(PhysConstraints::data)>::value;
|
||||
physConstraints->count = std::extent_v<decltype(PhysConstraints::data)>;
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ bool AssetLoaderPhysConstraints::LoadFromInfoString(
|
||||
memset(physConstraints, 0, sizeof(PhysConstraints));
|
||||
|
||||
InfoStringToPhysConstraintsConverter converter(
|
||||
infoString, physConstraints, zone->m_script_strings, memory, manager, phys_constraints_fields, std::extent<decltype(phys_constraints_fields)>::value);
|
||||
infoString, physConstraints, zone->m_script_strings, memory, manager, phys_constraints_fields, std::extent_v<decltype(phys_constraints_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse phys constraints: \"" << assetName << "\"" << std::endl;
|
||||
|
@ -66,7 +66,7 @@ bool AssetLoaderPhysPreset::LoadFromInfoString(
|
||||
const auto presetInfo = std::make_unique<PhysPresetInfo>();
|
||||
memset(presetInfo.get(), 0, sizeof(PhysPresetInfo));
|
||||
InfoStringToPhysPresetConverter converter(
|
||||
infoString, presetInfo.get(), zone->m_script_strings, memory, manager, phys_preset_fields, std::extent<decltype(phys_preset_fields)>::value);
|
||||
infoString, presetInfo.get(), zone->m_script_strings, memory, manager, phys_preset_fields, std::extent_v<decltype(phys_preset_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse phys preset: \"" << assetName << "\"" << std::endl;
|
||||
|
@ -23,7 +23,7 @@ namespace T6
|
||||
switch (static_cast<tracerFieldType_t>(field.iFieldType))
|
||||
{
|
||||
case TFT_TRACERTYPE:
|
||||
return ConvertEnumInt(value, field.iOffset, tracerTypeNames, std::extent<decltype(tracerTypeNames)>::value);
|
||||
return ConvertEnumInt(value, field.iOffset, tracerTypeNames, std::extent_v<decltype(tracerTypeNames)>);
|
||||
|
||||
case TFT_NUM_FIELD_TYPES:
|
||||
default:
|
||||
@ -52,8 +52,7 @@ bool AssetLoaderTracer::LoadFromInfoString(
|
||||
auto* tracer = memory->Create<TracerDef>();
|
||||
memset(tracer, 0, sizeof(TracerDef));
|
||||
|
||||
InfoStringToTracerConverter converter(
|
||||
infoString, tracer, zone->m_script_strings, memory, manager, tracer_fields, std::extent<decltype(tracer_fields)>::value);
|
||||
InfoStringToTracerConverter converter(infoString, tracer, zone->m_script_strings, memory, manager, tracer_fields, std::extent_v<decltype(tracer_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse tracer: \"" << assetName << "\"" << std::endl;
|
||||
|
@ -23,13 +23,13 @@ namespace T6
|
||||
switch (static_cast<VehicleFieldType>(field.iFieldType))
|
||||
{
|
||||
case VFT_TYPE:
|
||||
return ConvertEnumInt(value, field.iOffset, s_vehicleClassNames, std::extent<decltype(s_vehicleClassNames)>::value);
|
||||
return ConvertEnumInt(value, field.iOffset, s_vehicleClassNames, std::extent_v<decltype(s_vehicleClassNames)>);
|
||||
|
||||
case VFT_CAMERAMODE:
|
||||
return ConvertEnumInt(value, field.iOffset, s_vehicleCameraModes, std::extent<decltype(s_vehicleCameraModes)>::value);
|
||||
return ConvertEnumInt(value, field.iOffset, s_vehicleCameraModes, std::extent_v<decltype(s_vehicleCameraModes)>);
|
||||
|
||||
case VFT_TRACTION_TYPE:
|
||||
return ConvertEnumInt(value, field.iOffset, s_tractionTypeNames, std::extent<decltype(s_tractionTypeNames)>::value);
|
||||
return ConvertEnumInt(value, field.iOffset, s_tractionTypeNames, std::extent_v<decltype(s_tractionTypeNames)>);
|
||||
|
||||
case VFT_MPH_TO_INCHES_PER_SECOND:
|
||||
{
|
||||
@ -115,7 +115,7 @@ bool AssetLoaderVehicle::LoadFromInfoString(
|
||||
memset(vehicleDef, 0, sizeof(VehicleDef));
|
||||
|
||||
InfoStringToVehicleConverter converter(
|
||||
infoString, vehicleDef, zone->m_script_strings, memory, manager, vehicle_fields, std::extent<decltype(vehicle_fields)>::value);
|
||||
infoString, vehicleDef, zone->m_script_strings, memory, manager, vehicle_fields, std::extent_v<decltype(vehicle_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse vehicle: \"" << assetName << "\"" << std::endl;
|
||||
|
@ -68,7 +68,7 @@ namespace T6
|
||||
return true;
|
||||
}
|
||||
|
||||
assert(std::extent<decltype(bounceSoundSuffixes)>::value == SURF_TYPE_NUM);
|
||||
assert(std::extent_v<decltype(bounceSoundSuffixes)> == SURF_TYPE_NUM);
|
||||
*bounceSound = static_cast<const char**>(m_memory->Alloc(sizeof(const char*) * SURF_TYPE_NUM));
|
||||
for (auto i = 0u; i < SURF_TYPE_NUM; i++)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ void AssetLoaderZBarrier::CalculateZBarrierFields(ZBarrierDef* zbarrier)
|
||||
// numBoardsInBarrier
|
||||
{
|
||||
auto foundEnd = false;
|
||||
for (auto i = 0u; i < std::extent<decltype(ZBarrierDef::boards)>::value; i++)
|
||||
for (auto i = 0u; i < std::extent_v<decltype(ZBarrierDef::boards)>; i++)
|
||||
{
|
||||
if (zbarrier->boards[i].pBoardModel == nullptr)
|
||||
{
|
||||
@ -53,7 +53,7 @@ void AssetLoaderZBarrier::CalculateZBarrierFields(ZBarrierDef* zbarrier)
|
||||
}
|
||||
|
||||
if (!foundEnd)
|
||||
zbarrier->numBoardsInBarrier = std::extent<decltype(ZBarrierDef::boards)>::value;
|
||||
zbarrier->numBoardsInBarrier = std::extent_v<decltype(ZBarrierDef::boards)>;
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ bool AssetLoaderZBarrier::LoadFromInfoString(
|
||||
memset(zbarrier, 0, sizeof(ZBarrierDef));
|
||||
|
||||
InfoStringToZBarrierConverter converter(
|
||||
infoString, zbarrier, zone->m_script_strings, memory, manager, zbarrier_fields, std::extent<decltype(zbarrier_fields)>::value);
|
||||
infoString, zbarrier, zone->m_script_strings, memory, manager, zbarrier_fields, std::extent_v<decltype(zbarrier_fields)>);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse zbarrier: \"" << assetName << "\"" << std::endl;
|
||||
|
@ -88,7 +88,7 @@ Texture* IwiLoader::LoadIwi6(std::istream& stream) const
|
||||
const auto sizeOfMipLevel = texture->GetSizeOfMipLevel(currentMipLevel) * texture->GetFaceCount();
|
||||
currentFileSize += sizeOfMipLevel;
|
||||
|
||||
if (currentMipLevel < static_cast<int>(std::extent<decltype(iwi6::IwiHeader::fileSizeForPicmip)>::value)
|
||||
if (currentMipLevel < static_cast<int>(std::extent_v<decltype(iwi6::IwiHeader::fileSizeForPicmip)>)
|
||||
&& currentFileSize != header.fileSizeForPicmip[currentMipLevel])
|
||||
{
|
||||
printf("Iwi has invalid file size for picmip %i\n", currentMipLevel);
|
||||
@ -206,7 +206,7 @@ Texture* IwiLoader::LoadIwi8(std::istream& stream) const
|
||||
const auto sizeOfMipLevel = texture->GetSizeOfMipLevel(currentMipLevel) * texture->GetFaceCount();
|
||||
currentFileSize += sizeOfMipLevel;
|
||||
|
||||
if (currentMipLevel < static_cast<int>(std::extent<decltype(iwi8::IwiHeader::fileSizeForPicmip)>::value)
|
||||
if (currentMipLevel < static_cast<int>(std::extent_v<decltype(iwi8::IwiHeader::fileSizeForPicmip)>)
|
||||
&& currentFileSize != header.fileSizeForPicmip[currentMipLevel])
|
||||
{
|
||||
printf("Iwi has invalid file size for picmip %i\n", currentMipLevel);
|
||||
@ -311,7 +311,7 @@ Texture* IwiLoader::LoadIwi13(std::istream& stream) const
|
||||
const auto sizeOfMipLevel = texture->GetSizeOfMipLevel(currentMipLevel) * texture->GetFaceCount();
|
||||
currentFileSize += sizeOfMipLevel;
|
||||
|
||||
if (currentMipLevel < static_cast<int>(std::extent<decltype(iwi13::IwiHeader::fileSizeForPicmip)>::value)
|
||||
if (currentMipLevel < static_cast<int>(std::extent_v<decltype(iwi13::IwiHeader::fileSizeForPicmip)>)
|
||||
&& currentFileSize != header.fileSizeForPicmip[currentMipLevel])
|
||||
{
|
||||
printf("Iwi has invalid file size for picmip %i\n", currentMipLevel);
|
||||
@ -418,7 +418,7 @@ Texture* IwiLoader::LoadIwi27(std::istream& stream) const
|
||||
const auto sizeOfMipLevel = texture->GetSizeOfMipLevel(currentMipLevel) * texture->GetFaceCount();
|
||||
currentFileSize += sizeOfMipLevel;
|
||||
|
||||
if (currentMipLevel < static_cast<int>(std::extent<decltype(iwi27::IwiHeader::fileSizeForPicmip)>::value)
|
||||
if (currentMipLevel < static_cast<int>(std::extent_v<decltype(iwi27::IwiHeader::fileSizeForPicmip)>)
|
||||
&& currentFileSize != header.fileSizeForPicmip[currentMipLevel])
|
||||
{
|
||||
printf("Iwi has invalid file size for picmip %i\n", currentMipLevel);
|
||||
|
Reference in New Issue
Block a user