mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-04 02:01:51 +00:00
refactor: use std ranges functions where applicable
This commit is contained in:
@ -126,13 +126,12 @@ namespace IW4
|
||||
{
|
||||
const auto expectedRegisterSet =
|
||||
arg.type == MTL_ARG_CODE_PIXEL_SAMPLER || arg.type == MTL_ARG_MATERIAL_PIXEL_SAMPLER ? d3d9::RegisterSet::SAMPLER : d3d9::RegisterSet::FLOAT_4;
|
||||
const auto targetShaderArg = std::find_if(shaderInfo.m_constants.begin(),
|
||||
shaderInfo.m_constants.end(),
|
||||
[arg, expectedRegisterSet](const d3d9::ShaderConstant& constant)
|
||||
{
|
||||
return constant.m_register_set == expectedRegisterSet && constant.m_register_index <= arg.dest
|
||||
&& constant.m_register_index + constant.m_register_count > arg.dest;
|
||||
});
|
||||
const auto targetShaderArg = std::ranges::find_if(shaderInfo.m_constants,
|
||||
[arg, expectedRegisterSet](const d3d9::ShaderConstant& constant)
|
||||
{
|
||||
return constant.m_register_set == expectedRegisterSet && constant.m_register_index <= arg.dest
|
||||
&& constant.m_register_index + constant.m_register_count > arg.dest;
|
||||
});
|
||||
|
||||
assert(targetShaderArg != shaderInfo.m_constants.end());
|
||||
if (targetShaderArg == shaderInfo.m_constants.end())
|
||||
|
@ -139,7 +139,7 @@ class AssetDumperSndBank::Internal
|
||||
{
|
||||
fs::path assetPath(m_context.m_base_path);
|
||||
|
||||
std::replace(outputFileName.begin(), outputFileName.end(), '\\', '/');
|
||||
std::ranges::replace(outputFileName, '\\', '/');
|
||||
for (const auto& droppedPrefix : PREFIXES_TO_DROP)
|
||||
{
|
||||
if (outputFileName.rfind(droppedPrefix, 0) != std::string::npos)
|
||||
|
@ -115,22 +115,20 @@ bool AbstractMenuDumper::DoesTokenNeedQuotationMarks(const std::string& token)
|
||||
if (token.empty())
|
||||
return true;
|
||||
|
||||
const auto hasAlNumCharacter = std::any_of(token.begin(),
|
||||
token.end(),
|
||||
[](const char& c)
|
||||
{
|
||||
return isalnum(c);
|
||||
});
|
||||
const auto hasAlNumCharacter = std::ranges::any_of(token,
|
||||
[](const char& c)
|
||||
{
|
||||
return isalnum(c);
|
||||
});
|
||||
|
||||
if (!hasAlNumCharacter)
|
||||
return false;
|
||||
|
||||
const auto hasNonIdentifierCharacter = std::any_of(token.begin(),
|
||||
token.end(),
|
||||
[](const char& c)
|
||||
{
|
||||
return !isalnum(c) && c != '_';
|
||||
});
|
||||
const auto hasNonIdentifierCharacter = std::ranges::any_of(token,
|
||||
[](const char& c)
|
||||
{
|
||||
return !isalnum(c) && c != '_';
|
||||
});
|
||||
|
||||
return hasNonIdentifierCharacter;
|
||||
}
|
||||
|
@ -291,12 +291,11 @@ public:
|
||||
|
||||
m_index_entries.reserve(m_images.size());
|
||||
|
||||
const auto result = std::all_of(m_images.begin(),
|
||||
m_images.end(),
|
||||
[this](const std::string& imageName)
|
||||
{
|
||||
return WriteImageData(imageName);
|
||||
});
|
||||
const auto result = std::ranges::all_of(m_images,
|
||||
[this](const std::string& imageName)
|
||||
{
|
||||
return WriteImageData(imageName);
|
||||
});
|
||||
|
||||
FlushBlock();
|
||||
m_data_section_size = static_cast<size_t>(m_current_offset - m_data_section_offset);
|
||||
@ -311,7 +310,7 @@ public:
|
||||
|
||||
void SortIndexSectionEntries()
|
||||
{
|
||||
std::sort(m_index_entries.begin(), m_index_entries.end(), CompareIndices);
|
||||
std::ranges::sort(m_index_entries, CompareIndices);
|
||||
}
|
||||
|
||||
void WriteIndexSection()
|
||||
|
Reference in New Issue
Block a user