mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
refactor: use std ranges functions where applicable
This commit is contained in:
parent
132cccb971
commit
239001e6f2
@ -25,7 +25,7 @@ void GameIW3::AddZone(Zone* zone)
|
||||
|
||||
void GameIW3::RemoveZone(Zone* zone)
|
||||
{
|
||||
const auto foundEntry = std::find(m_zones.begin(), m_zones.end(), zone);
|
||||
const auto foundEntry = std::ranges::find(m_zones, zone);
|
||||
|
||||
if (foundEntry != m_zones.end())
|
||||
m_zones.erase(foundEntry);
|
||||
|
@ -25,7 +25,7 @@ void GameIW4::AddZone(Zone* zone)
|
||||
|
||||
void GameIW4::RemoveZone(Zone* zone)
|
||||
{
|
||||
const auto foundEntry = std::find(m_zones.begin(), m_zones.end(), zone);
|
||||
const auto foundEntry = std::ranges::find(m_zones, zone);
|
||||
|
||||
if (foundEntry != m_zones.end())
|
||||
m_zones.erase(foundEntry);
|
||||
|
@ -25,7 +25,7 @@ void GameIW5::AddZone(Zone* zone)
|
||||
|
||||
void GameIW5::RemoveZone(Zone* zone)
|
||||
{
|
||||
const auto foundEntry = std::find(m_zones.begin(), m_zones.end(), zone);
|
||||
const auto foundEntry = std::ranges::find(m_zones, zone);
|
||||
|
||||
if (foundEntry != m_zones.end())
|
||||
m_zones.erase(foundEntry);
|
||||
|
@ -25,7 +25,7 @@ void GameT5::AddZone(Zone* zone)
|
||||
|
||||
void GameT5::RemoveZone(Zone* zone)
|
||||
{
|
||||
const auto foundEntry = std::find(m_zones.begin(), m_zones.end(), zone);
|
||||
const auto foundEntry = std::ranges::find(m_zones, zone);
|
||||
|
||||
if (foundEntry != m_zones.end())
|
||||
m_zones.erase(foundEntry);
|
||||
|
@ -25,7 +25,7 @@ void GameT6::AddZone(Zone* zone)
|
||||
|
||||
void GameT6::RemoveZone(Zone* zone)
|
||||
{
|
||||
const auto foundEntry = std::find(m_zones.begin(), m_zones.end(), zone);
|
||||
const auto foundEntry = std::ranges::find(m_zones, zone);
|
||||
|
||||
if (foundEntry != m_zones.end())
|
||||
m_zones.erase(foundEntry);
|
||||
|
@ -37,12 +37,11 @@ namespace state_map
|
||||
|
||||
for (auto& resultVar : entry.m_result_vars)
|
||||
{
|
||||
const auto correspondingVar = std::find_if(layout.m_var_layout.m_vars.begin(),
|
||||
layout.m_var_layout.m_vars.end(),
|
||||
[&resultVar](const StateMapLayoutVar& var)
|
||||
{
|
||||
return var.m_name == resultVar;
|
||||
});
|
||||
const auto correspondingVar = std::ranges::find_if(layout.m_var_layout.m_vars,
|
||||
[&resultVar](const StateMapLayoutVar& var)
|
||||
{
|
||||
return var.m_name == resultVar;
|
||||
});
|
||||
|
||||
// Has to have a corresponding var
|
||||
assert(correspondingVar != layout.m_var_layout.m_vars.end());
|
||||
|
@ -467,19 +467,18 @@ class LinkerImpl final : public Linker
|
||||
|
||||
bool BuildReferencedTargets(const std::string& projectName, const std::string& targetName, const ZoneDefinition& zoneDefinition)
|
||||
{
|
||||
return std::all_of(zoneDefinition.m_targets_to_build.begin(),
|
||||
zoneDefinition.m_targets_to_build.end(),
|
||||
[this, &projectName, &targetName](const std::string& buildTargetName)
|
||||
{
|
||||
if (buildTargetName == targetName)
|
||||
{
|
||||
std::cerr << "Cannot build target with same name: \"" << targetName << "\"\n";
|
||||
return false;
|
||||
}
|
||||
return std::ranges::all_of(zoneDefinition.m_targets_to_build,
|
||||
[this, &projectName, &targetName](const std::string& buildTargetName)
|
||||
{
|
||||
if (buildTargetName == targetName)
|
||||
{
|
||||
std::cerr << "Cannot build target with same name: \"" << targetName << "\"\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "Building referenced target \"" << buildTargetName << "\"\n";
|
||||
return BuildProject(projectName, buildTargetName);
|
||||
});
|
||||
std::cout << "Building referenced target \"" << buildTargetName << "\"\n";
|
||||
return BuildProject(projectName, buildTargetName);
|
||||
});
|
||||
}
|
||||
|
||||
bool BuildProject(const std::string& projectName, const std::string& targetName)
|
||||
|
@ -60,20 +60,18 @@ uint32_t CommonStructuredDataEnum::CalculateChecksum(const uint32_t initialValue
|
||||
|
||||
void CommonStructuredDataEnum::SortEntriesByOffset()
|
||||
{
|
||||
std::sort(m_entries.begin(),
|
||||
m_entries.end(),
|
||||
[](const CommonStructuredDataEnumEntry& e1, const CommonStructuredDataEnumEntry& e2)
|
||||
{
|
||||
return e1.m_value < e2.m_value;
|
||||
});
|
||||
std::ranges::sort(m_entries,
|
||||
[](const CommonStructuredDataEnumEntry& e1, const CommonStructuredDataEnumEntry& e2)
|
||||
{
|
||||
return e1.m_value < e2.m_value;
|
||||
});
|
||||
}
|
||||
|
||||
void CommonStructuredDataEnum::SortEntriesByName()
|
||||
{
|
||||
std::sort(m_entries.begin(),
|
||||
m_entries.end(),
|
||||
[](const CommonStructuredDataEnumEntry& e1, const CommonStructuredDataEnumEntry& e2)
|
||||
{
|
||||
return e1.m_name < e2.m_name;
|
||||
});
|
||||
std::ranges::sort(m_entries,
|
||||
[](const CommonStructuredDataEnumEntry& e1, const CommonStructuredDataEnumEntry& e2)
|
||||
{
|
||||
return e1.m_name < e2.m_name;
|
||||
});
|
||||
}
|
||||
|
@ -118,20 +118,18 @@ uint32_t CommonStructuredDataStruct::CalculateChecksum(const CommonStructuredDat
|
||||
|
||||
void CommonStructuredDataStruct::SortPropertiesByOffset()
|
||||
{
|
||||
std::sort(m_properties.begin(),
|
||||
m_properties.end(),
|
||||
[](const CommonStructuredDataStructProperty& e1, const CommonStructuredDataStructProperty& e2)
|
||||
{
|
||||
return e1.m_offset_in_bits < e2.m_offset_in_bits;
|
||||
});
|
||||
std::ranges::sort(m_properties,
|
||||
[](const CommonStructuredDataStructProperty& e1, const CommonStructuredDataStructProperty& e2)
|
||||
{
|
||||
return e1.m_offset_in_bits < e2.m_offset_in_bits;
|
||||
});
|
||||
}
|
||||
|
||||
void CommonStructuredDataStruct::SortPropertiesByName()
|
||||
{
|
||||
std::sort(m_properties.begin(),
|
||||
m_properties.end(),
|
||||
[](const CommonStructuredDataStructProperty& e1, const CommonStructuredDataStructProperty& e2)
|
||||
{
|
||||
return e1.m_name < e2.m_name;
|
||||
});
|
||||
std::ranges::sort(m_properties,
|
||||
[](const CommonStructuredDataStructProperty& e1, const CommonStructuredDataStructProperty& e2)
|
||||
{
|
||||
return e1.m_name < e2.m_name;
|
||||
});
|
||||
}
|
||||
|
@ -844,13 +844,12 @@ namespace IW4
|
||||
if (techsetDefinition->GetTechniqueByIndex(i, techniqueName))
|
||||
{
|
||||
const auto stateBitsForTechnique = GetStateBitsForTechnique(techniqueName);
|
||||
const auto foundStateBits =
|
||||
std::find_if(m_state_bits.begin(),
|
||||
m_state_bits.end(),
|
||||
[stateBitsForTechnique](const GfxStateBits& s1)
|
||||
{
|
||||
return s1.loadBits[0] == stateBitsForTechnique.loadBits[0] && s1.loadBits[1] == stateBitsForTechnique.loadBits[1];
|
||||
});
|
||||
const auto foundStateBits = std::ranges::find_if(m_state_bits,
|
||||
[stateBitsForTechnique](const GfxStateBits& s1)
|
||||
{
|
||||
return s1.loadBits[0] == stateBitsForTechnique.loadBits[0]
|
||||
&& s1.loadBits[1] == stateBitsForTechnique.loadBits[1];
|
||||
});
|
||||
|
||||
if (foundStateBits != m_state_bits.end())
|
||||
{
|
||||
|
@ -403,22 +403,21 @@ namespace IW4
|
||||
return false;
|
||||
|
||||
// Sort args by their update frequency
|
||||
std::sort(pass.m_arguments.begin(),
|
||||
pass.m_arguments.end(),
|
||||
[](const PassShaderArgument& arg1, const PassShaderArgument& arg2)
|
||||
{
|
||||
if (arg1.m_update_frequency != arg2.m_update_frequency)
|
||||
return arg1.m_update_frequency < arg2.m_update_frequency;
|
||||
std::ranges::sort(pass.m_arguments,
|
||||
[](const PassShaderArgument& arg1, const PassShaderArgument& arg2)
|
||||
{
|
||||
if (arg1.m_update_frequency != arg2.m_update_frequency)
|
||||
return arg1.m_update_frequency < arg2.m_update_frequency;
|
||||
|
||||
if (arg1.m_arg.type != arg2.m_arg.type)
|
||||
return arg1.m_arg.type < arg2.m_arg.type;
|
||||
if (arg1.m_arg.type != arg2.m_arg.type)
|
||||
return arg1.m_arg.type < arg2.m_arg.type;
|
||||
|
||||
if (arg1.m_arg.type == MTL_ARG_MATERIAL_VERTEX_CONST || arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_CONST
|
||||
|| arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_SAMPLER)
|
||||
return arg1.m_arg.u.codeSampler < arg2.m_arg.u.codeSampler;
|
||||
if (arg1.m_arg.type == MTL_ARG_MATERIAL_VERTEX_CONST || arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_CONST
|
||||
|| arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_SAMPLER)
|
||||
return arg1.m_arg.u.codeSampler < arg2.m_arg.u.codeSampler;
|
||||
|
||||
return arg1.m_arg.dest < arg2.m_arg.dest;
|
||||
});
|
||||
return arg1.m_arg.dest < arg2.m_arg.dest;
|
||||
});
|
||||
|
||||
AllocateVertexDecl();
|
||||
|
||||
@ -600,12 +599,11 @@ namespace IW4
|
||||
size_t& registerOffset,
|
||||
std::string& errorMessage) const
|
||||
{
|
||||
const auto matchingShaderConstant = std::find_if(shaderInfo.m_constants.begin(),
|
||||
shaderInfo.m_constants.end(),
|
||||
[argument](const d3d9::ShaderConstant& constant)
|
||||
{
|
||||
return constant.m_name == argument.m_argument_name;
|
||||
});
|
||||
const auto matchingShaderConstant = std::ranges::find_if(shaderInfo.m_constants,
|
||||
[argument](const d3d9::ShaderConstant& constant)
|
||||
{
|
||||
return constant.m_name == argument.m_argument_name;
|
||||
});
|
||||
|
||||
if (matchingShaderConstant == shaderInfo.m_constants.end())
|
||||
{
|
||||
@ -1013,14 +1011,14 @@ namespace IW4
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto foundDestination = std::find(std::begin(materialStreamDestinationNames), std::end(materialStreamDestinationNames), destination);
|
||||
const auto foundDestination = std::ranges::find(materialStreamDestinationNames, destination);
|
||||
if (foundDestination == std::end(materialStreamDestinationNames))
|
||||
{
|
||||
errorMessage = "Unknown stream destination";
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto foundSource = std::find(std::begin(materialStreamSourceNames), std::end(materialStreamSourceNames), source);
|
||||
const auto foundSource = std::ranges::find(materialStreamSourceNames, source);
|
||||
if (foundSource == std::end(materialStreamSourceNames))
|
||||
{
|
||||
errorMessage = "Unknown stream source";
|
||||
@ -1187,7 +1185,7 @@ namespace IW4
|
||||
assert(arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER);
|
||||
if (arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER)
|
||||
{
|
||||
const auto customSampler = std::find(std::begin(g_customSamplerSrc), std::end(g_customSamplerSrc), arg.m_arg.u.codeSampler);
|
||||
const auto customSampler = std::ranges::find(g_customSamplerSrc, arg.m_arg.u.codeSampler);
|
||||
assert(customSampler != std::end(g_customSamplerSrc));
|
||||
if (customSampler != std::end(g_customSamplerSrc))
|
||||
{
|
||||
|
@ -64,16 +64,14 @@ bool AssetLoaderVertexDecl::LoadFromRaw(
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto foundSourceAbbreviation =
|
||||
std::find(std::begin(materialStreamSourceAbbreviation), std::end(materialStreamSourceAbbreviation), sourceAbbreviation);
|
||||
const auto foundSourceAbbreviation = std::ranges::find(materialStreamSourceAbbreviation, sourceAbbreviation);
|
||||
if (foundSourceAbbreviation == std::end(materialStreamSourceAbbreviation))
|
||||
{
|
||||
std::cout << "Unknown vertex decl source abbreviation: " << sourceAbbreviation << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto foundDestinationAbbreviation =
|
||||
std::find(std::begin(materialStreamDestinationAbbreviation), std::end(materialStreamDestinationAbbreviation), destinationAbbreviation);
|
||||
const auto foundDestinationAbbreviation = std::ranges::find(materialStreamDestinationAbbreviation, destinationAbbreviation);
|
||||
if (foundDestinationAbbreviation == std::end(materialStreamDestinationAbbreviation))
|
||||
{
|
||||
std::cout << "Unknown vertex decl destination abbreviation: " << destinationAbbreviation << "\n";
|
||||
|
@ -48,12 +48,11 @@ void AssetLoaderFontIcon::PreprocessRow(std::vector<std::string>& row)
|
||||
|
||||
bool AssetLoaderFontIcon::RowIsEmpty(const std::vector<std::string>& row)
|
||||
{
|
||||
return std::all_of(row.begin(),
|
||||
row.end(),
|
||||
[](const std::string& cell)
|
||||
{
|
||||
return cell.empty();
|
||||
});
|
||||
return std::ranges::all_of(row,
|
||||
[](const std::string& cell)
|
||||
{
|
||||
return cell.empty();
|
||||
});
|
||||
}
|
||||
|
||||
bool AssetLoaderFontIcon::ParseInt(int& value, const std::string& str)
|
||||
|
@ -27,7 +27,7 @@ namespace
|
||||
{
|
||||
std::string soundFilePath(sndAlias->assetFileName);
|
||||
|
||||
std::replace(soundFilePath.begin(), soundFilePath.end(), '\\', '/');
|
||||
std::ranges::replace(soundFilePath, '\\', '/');
|
||||
for (const auto& droppedPrefix : PREFIXES_TO_DROP)
|
||||
{
|
||||
if (soundFilePath.rfind(droppedPrefix, 0) != std::string::npos)
|
||||
|
@ -56,12 +56,11 @@ class IPak::Impl : public ObjContainerReferenceable
|
||||
m_index_entries.push_back(indexEntry);
|
||||
}
|
||||
|
||||
std::sort(m_index_entries.begin(),
|
||||
m_index_entries.end(),
|
||||
[](const IPakIndexEntry& entry1, const IPakIndexEntry& entry2)
|
||||
{
|
||||
return entry1.key.combinedKey < entry2.key.combinedKey;
|
||||
});
|
||||
std::ranges::sort(m_index_entries,
|
||||
[](const IPakIndexEntry& entry1, const IPakIndexEntry& entry2)
|
||||
{
|
||||
return entry1.key.combinedKey < entry2.key.combinedKey;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -71,12 +71,11 @@ public:
|
||||
m_stream_mutex.lock();
|
||||
|
||||
ChunkBuffer* reservedChunkBuffer;
|
||||
const auto freeChunkBuffer = std::find_if(m_chunk_buffers.begin(),
|
||||
m_chunk_buffers.end(),
|
||||
[](ChunkBuffer* chunkBuffer)
|
||||
{
|
||||
return chunkBuffer->m_using_stream == nullptr;
|
||||
});
|
||||
const auto freeChunkBuffer = std::ranges::find_if(m_chunk_buffers,
|
||||
[](ChunkBuffer* chunkBuffer)
|
||||
{
|
||||
return chunkBuffer->m_using_stream == nullptr;
|
||||
});
|
||||
|
||||
if (freeChunkBuffer == m_chunk_buffers.end())
|
||||
{
|
||||
@ -111,12 +110,11 @@ public:
|
||||
{
|
||||
m_stream_mutex.lock();
|
||||
|
||||
const auto openStreamEntry = std::find_if(m_open_streams.begin(),
|
||||
m_open_streams.end(),
|
||||
[stream](const ManagedStream& managedStream)
|
||||
{
|
||||
return managedStream.m_stream == stream;
|
||||
});
|
||||
const auto openStreamEntry = std::ranges::find_if(m_open_streams,
|
||||
[stream](const ManagedStream& managedStream)
|
||||
{
|
||||
return managedStream.m_stream == stream;
|
||||
});
|
||||
|
||||
if (openStreamEntry != m_open_streams.end())
|
||||
{
|
||||
@ -127,7 +125,7 @@ public:
|
||||
// Only keep previously allocated chunk buffer if we did not get over the limit of idle chunk buffers
|
||||
if (m_chunk_buffers.size() > CHUNK_BUFFER_COUNT_IDLE_LIMIT)
|
||||
{
|
||||
const auto chunkBufferEntry = std::find(m_chunk_buffers.begin(), m_chunk_buffers.end(), chunkBuffer);
|
||||
const auto chunkBufferEntry = std::ranges::find(m_chunk_buffers, chunkBuffer);
|
||||
|
||||
if (chunkBufferEntry != m_chunk_buffers.end())
|
||||
{
|
||||
|
@ -248,7 +248,7 @@ public:
|
||||
}
|
||||
|
||||
auto iwdFilename = fileName;
|
||||
std::replace(iwdFilename.begin(), iwdFilename.end(), '\\', '/');
|
||||
std::ranges::replace(iwdFilename, '\\', '/');
|
||||
|
||||
const auto iwdEntry = m_entry_map.find(iwdFilename);
|
||||
|
||||
|
@ -46,12 +46,11 @@ public:
|
||||
|
||||
void AddSound(const std::string& soundFilePath, unsigned int soundId, bool looping, bool streamed) override
|
||||
{
|
||||
auto itr = std::find_if(this->m_sounds.begin(),
|
||||
this->m_sounds.end(),
|
||||
[soundId](SoundBankEntryInfo& entry)
|
||||
{
|
||||
return entry.m_sound_id == soundId;
|
||||
});
|
||||
auto itr = std::ranges::find_if(this->m_sounds,
|
||||
[soundId](SoundBankEntryInfo& entry)
|
||||
{
|
||||
return entry.m_sound_id == soundId;
|
||||
});
|
||||
|
||||
if (itr == this->m_sounds.end())
|
||||
{
|
||||
|
@ -179,12 +179,11 @@ namespace state_map
|
||||
const auto tokenValue =
|
||||
valueToken.m_type == SimpleParserValueType::IDENTIFIER ? valueToken.IdentifierValue() : std::to_string(valueToken.IntegerValue());
|
||||
|
||||
const auto referencedValue = std::find_if(var.m_values.begin(),
|
||||
var.m_values.end(),
|
||||
[&tokenValue](const StateMapLayoutVarValue& value)
|
||||
{
|
||||
return value.m_name == tokenValue;
|
||||
});
|
||||
const auto referencedValue = std::ranges::find_if(var.m_values,
|
||||
[&tokenValue](const StateMapLayoutVarValue& value)
|
||||
{
|
||||
return value.m_name == tokenValue;
|
||||
});
|
||||
|
||||
if (referencedValue == var.m_values.end())
|
||||
throw ParsingException(valueToken.GetPos(), "Not part of the valid values for this var");
|
||||
|
@ -40,19 +40,18 @@ void StateMapHandler::ApplyStateMap(const uint32_t* baseStateBits, uint32_t* out
|
||||
for (auto entryIndex = 0u; entryIndex < m_state_map.m_state_map_entries.size(); entryIndex++)
|
||||
{
|
||||
const auto& entry = m_state_map.m_state_map_entries[entryIndex];
|
||||
const auto matchingRule = std::find_if(entry.m_rules.begin(),
|
||||
entry.m_rules.end(),
|
||||
[&vars](const std::unique_ptr<StateMapRule>& rule)
|
||||
{
|
||||
const auto matchingCondition = std::find_if(rule->m_conditions.begin(),
|
||||
rule->m_conditions.end(),
|
||||
[&vars](std::unique_ptr<ISimpleExpression>& condition)
|
||||
{
|
||||
return condition->EvaluateNonStatic(&vars).IsTruthy();
|
||||
});
|
||||
const auto matchingRule = std::ranges::find_if(entry.m_rules,
|
||||
[&vars](const std::unique_ptr<StateMapRule>& rule)
|
||||
{
|
||||
const auto matchingCondition =
|
||||
std::ranges::find_if(rule->m_conditions,
|
||||
[&vars](std::unique_ptr<ISimpleExpression>& condition)
|
||||
{
|
||||
return condition->EvaluateNonStatic(&vars).IsTruthy();
|
||||
});
|
||||
|
||||
return matchingCondition != rule->m_conditions.end();
|
||||
});
|
||||
return matchingCondition != rule->m_conditions.end();
|
||||
});
|
||||
|
||||
if (matchingRule != entry.m_rules.end())
|
||||
ApplyRule(m_state_map_layout.m_entry_layout.m_entries[entryIndex], **matchingRule, outStateBits);
|
||||
@ -68,12 +67,11 @@ StateMapVars StateMapHandler::BuildVars(const uint32_t* baseStateBits) const
|
||||
for (const auto& var : m_state_map_layout.m_var_layout.m_vars)
|
||||
{
|
||||
const auto baseStateBitField = baseStateBits[var.m_state_bits_index];
|
||||
const auto matchingValue = std::find_if(var.m_values.begin(),
|
||||
var.m_values.end(),
|
||||
[&baseStateBitField](const StateMapLayoutVarValue& value)
|
||||
{
|
||||
return (baseStateBitField & value.m_state_bits_mask) == value.m_state_bits_mask;
|
||||
});
|
||||
const auto matchingValue = std::ranges::find_if(var.m_values,
|
||||
[&baseStateBitField](const StateMapLayoutVarValue& value)
|
||||
{
|
||||
return (baseStateBitField & value.m_state_bits_mask) == value.m_state_bits_mask;
|
||||
});
|
||||
|
||||
if (matchingValue != var.m_values.end())
|
||||
result.AddValue(var.m_name, matchingValue->m_name);
|
||||
|
@ -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()
|
||||
|
@ -981,7 +981,7 @@ void DefinesStreamProxy::ProcessNestedMacros(ParserLine& line, unsigned& linePos
|
||||
const Define* nestedMacro = nullptr;
|
||||
while (FindNextMacro(input, pos, defineStart, nestedMacro))
|
||||
{
|
||||
if (std::find(callstack.cbegin(), callstack.cend(), nestedMacro) != callstack.cend())
|
||||
if (std::ranges::find(std::as_const(callstack), nestedMacro) != callstack.cend())
|
||||
{
|
||||
// Do not expand recursively
|
||||
continue;
|
||||
|
@ -283,18 +283,16 @@ std::unique_ptr<SimpleExpressionMatchers::matcher_t> SimpleExpressionMatchers::P
|
||||
}
|
||||
}
|
||||
|
||||
const auto hasAddOperation = std::any_of(enabledBinaryOperations.begin(),
|
||||
enabledBinaryOperations.end(),
|
||||
[](const SimpleExpressionBinaryOperationType* type)
|
||||
{
|
||||
return type == &SimpleExpressionBinaryOperationType::OPERATION_ADD;
|
||||
});
|
||||
const auto hasSubtractOperation = std::any_of(enabledBinaryOperations.begin(),
|
||||
enabledBinaryOperations.end(),
|
||||
[](const SimpleExpressionBinaryOperationType* type)
|
||||
{
|
||||
return type == &SimpleExpressionBinaryOperationType::OPERATION_SUBTRACT;
|
||||
});
|
||||
const auto hasAddOperation = std::ranges::any_of(enabledBinaryOperations,
|
||||
[](const SimpleExpressionBinaryOperationType* type)
|
||||
{
|
||||
return type == &SimpleExpressionBinaryOperationType::OPERATION_ADD;
|
||||
});
|
||||
const auto hasSubtractOperation = std::ranges::any_of(enabledBinaryOperations,
|
||||
[](const SimpleExpressionBinaryOperationType* type)
|
||||
{
|
||||
return type == &SimpleExpressionBinaryOperationType::OPERATION_SUBTRACT;
|
||||
});
|
||||
|
||||
if (hasAddOperation && hasSubtractOperation)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ SimpleMatcherAnyCharacterBesides::SimpleMatcherAnyCharacterBesides(std::vector<c
|
||||
MatcherResult<SimpleParserValue> SimpleMatcherAnyCharacterBesides::CanMatch(ILexer<SimpleParserValue>* lexer, const unsigned tokenOffset)
|
||||
{
|
||||
const auto& token = lexer->GetToken(tokenOffset);
|
||||
return token.m_type == SimpleParserValueType::CHARACTER && std::find(m_chars.begin(), m_chars.end(), token.CharacterValue()) == m_chars.end()
|
||||
return token.m_type == SimpleParserValueType::CHARACTER && std::ranges::find(m_chars, token.CharacterValue()) == m_chars.end()
|
||||
? MatcherResult<SimpleParserValue>::Match(1)
|
||||
: MatcherResult<SimpleParserValue>::NoMatch();
|
||||
}
|
||||
|
@ -17,14 +17,12 @@ MatcherResult<SimpleParserValue> SimpleMatcherKeywordIgnoreCase::CanMatch(ILexer
|
||||
return MatcherResult<SimpleParserValue>::NoMatch();
|
||||
|
||||
const auto& identifierValue = token.IdentifierValue();
|
||||
const auto isEqual = std::equal(identifierValue.begin(),
|
||||
identifierValue.end(),
|
||||
m_value.begin(),
|
||||
m_value.end(),
|
||||
[](const char a, const char b)
|
||||
{
|
||||
return tolower(a) == b;
|
||||
});
|
||||
const auto isEqual = std::ranges::equal(identifierValue,
|
||||
m_value,
|
||||
[](const char a, const char b)
|
||||
{
|
||||
return tolower(a) == b;
|
||||
});
|
||||
|
||||
if (isEqual)
|
||||
return MatcherResult<SimpleParserValue>::Match(1);
|
||||
|
@ -21,12 +21,11 @@ bool MemberComputations::ShouldIgnore() const
|
||||
bool MemberComputations::ContainsNonEmbeddedReference() const
|
||||
{
|
||||
const auto& declarationModifiers = m_info->m_member->m_type_declaration->m_declaration_modifiers;
|
||||
return std::any_of(declarationModifiers.begin(),
|
||||
declarationModifiers.end(),
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
return std::ranges::any_of(declarationModifiers,
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
}
|
||||
|
||||
bool MemberComputations::ContainsSinglePointerReference() const
|
||||
@ -136,12 +135,11 @@ bool MemberComputations::IsPointerToArray() const
|
||||
if (lastModifier->GetType() != DeclarationModifierType::ARRAY)
|
||||
return false;
|
||||
|
||||
return std::any_of(declarationModifiers.begin(),
|
||||
declarationModifiers.end(),
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
return std::ranges::any_of(declarationModifiers,
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<int> MemberComputations::GetPointerToArraySizes() const
|
||||
@ -207,13 +205,12 @@ bool MemberComputations::HasDynamicArraySize() const
|
||||
{
|
||||
const auto& declarationModifiers = m_info->m_member->m_type_declaration->m_declaration_modifiers;
|
||||
|
||||
return std::any_of(declarationModifiers.begin(),
|
||||
declarationModifiers.end(),
|
||||
[](const std::unique_ptr<DeclarationModifier>& declarationModifier)
|
||||
{
|
||||
return declarationModifier->GetType() == DeclarationModifierType::ARRAY
|
||||
&& dynamic_cast<ArrayDeclarationModifier*>(declarationModifier.get())->m_dynamic_size_evaluation;
|
||||
});
|
||||
return std::ranges::any_of(declarationModifiers,
|
||||
[](const std::unique_ptr<DeclarationModifier>& declarationModifier)
|
||||
{
|
||||
return declarationModifier->GetType() == DeclarationModifierType::ARRAY
|
||||
&& dynamic_cast<ArrayDeclarationModifier*>(declarationModifier.get())->m_dynamic_size_evaluation;
|
||||
});
|
||||
}
|
||||
|
||||
bool MemberComputations::IsDynamicMember() const
|
||||
|
@ -123,7 +123,7 @@ std::vector<DeclarationModifierComputations> DeclarationModifierComputations::Ge
|
||||
for (auto i = 0; i < arraySize; i++)
|
||||
{
|
||||
std::vector<int> childModifierIndices(m_modifier_indices.size() + 1);
|
||||
std::copy(m_modifier_indices.begin(), m_modifier_indices.end(), childModifierIndices.begin());
|
||||
std::ranges::copy(m_modifier_indices, childModifierIndices.begin());
|
||||
childModifierIndices[childModifierIndices.size() - 1] = i;
|
||||
arrayEntries.push_back(DeclarationModifierComputations(m_information, std::move(childModifierIndices)));
|
||||
}
|
||||
@ -140,12 +140,11 @@ bool DeclarationModifierComputations::IsSinglePointer() const
|
||||
{
|
||||
const auto following = GetFollowingDeclarationModifiers();
|
||||
|
||||
return !std::any_of(following.begin(),
|
||||
following.end(),
|
||||
[](const DeclarationModifier* modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
return !std::ranges::any_of(following,
|
||||
[](const DeclarationModifier* modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -160,12 +159,11 @@ bool DeclarationModifierComputations::IsArrayPointer() const
|
||||
{
|
||||
const auto following = GetFollowingDeclarationModifiers();
|
||||
|
||||
return !std::any_of(following.begin(),
|
||||
following.end(),
|
||||
[](const DeclarationModifier* modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
return !std::ranges::any_of(following,
|
||||
[](const DeclarationModifier* modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -247,12 +245,11 @@ unsigned DeclarationModifierComputations::GetAlignment() const
|
||||
{
|
||||
const auto following = GetFollowingDeclarationModifiers();
|
||||
|
||||
return std::any_of(following.begin(),
|
||||
following.end(),
|
||||
[](const DeclarationModifier* modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
})
|
||||
return std::ranges::any_of(following,
|
||||
[](const DeclarationModifier* modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
})
|
||||
? m_information->m_member->GetAlignment()
|
||||
: m_information->m_member->m_type_declaration->m_type->GetAlignment();
|
||||
}
|
||||
|
@ -91,10 +91,9 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
return std::all_of(m_post_processors.begin(),
|
||||
m_post_processors.end(),
|
||||
[repository](const std::unique_ptr<IPostProcessor>& postProcessor)
|
||||
{
|
||||
return postProcessor->PostProcess(repository);
|
||||
});
|
||||
return std::ranges::all_of(m_post_processors,
|
||||
[repository](const std::unique_ptr<IPostProcessor>& postProcessor)
|
||||
{
|
||||
return postProcessor->PostProcess(repository);
|
||||
});
|
||||
}
|
||||
|
@ -45,12 +45,11 @@ void SequenceAssetRef::ProcessMatch(CommandsParserState* state, SequenceResult<C
|
||||
if (!hasPointerRef)
|
||||
{
|
||||
const auto& modifiers = typeDecl->m_declaration_modifiers;
|
||||
hasPointerRef = std::any_of(modifiers.begin(),
|
||||
modifiers.end(),
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
hasPointerRef = std::ranges::any_of(modifiers,
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
}
|
||||
|
||||
if (typeDecl->m_type->GetType() == DataDefinitionType::TYPEDEF)
|
||||
|
@ -39,12 +39,11 @@ void SequenceString::ProcessMatch(CommandsParserState* state, SequenceResult<Com
|
||||
if (!hasPointerRef)
|
||||
{
|
||||
const auto& modifiers = typeDecl->m_declaration_modifiers;
|
||||
hasPointerRef = std::any_of(modifiers.begin(),
|
||||
modifiers.end(),
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
hasPointerRef = std::ranges::any_of(modifiers,
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::POINTER;
|
||||
});
|
||||
}
|
||||
|
||||
if (typeDecl->m_type->GetType() == DataDefinitionType::TYPEDEF)
|
||||
|
@ -91,10 +91,9 @@ bool HeaderFileReader::ReadHeaderFile(IDataRepository* repository)
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
return std::all_of(m_post_processors.begin(),
|
||||
m_post_processors.end(),
|
||||
[repository](const std::unique_ptr<IPostProcessor>& postProcessor)
|
||||
{
|
||||
return postProcessor->PostProcess(repository);
|
||||
});
|
||||
return std::ranges::all_of(m_post_processors,
|
||||
[repository](const std::unique_ptr<IPostProcessor>& postProcessor)
|
||||
{
|
||||
return postProcessor->PostProcess(repository);
|
||||
});
|
||||
}
|
||||
|
@ -29,10 +29,9 @@ bool CreateMemberInformationPostProcessor::PostProcess(IDataRepository* reposito
|
||||
{
|
||||
const auto& allStructureInformation = repository->GetAllStructureInformation();
|
||||
|
||||
return std::all_of(allStructureInformation.begin(),
|
||||
allStructureInformation.end(),
|
||||
[this, repository](StructureInformation* structure)
|
||||
{
|
||||
return CreateMemberInformationForStructure(repository, structure);
|
||||
});
|
||||
return std::ranges::all_of(allStructureInformation,
|
||||
[this, repository](StructureInformation* structure)
|
||||
{
|
||||
return CreateMemberInformationForStructure(repository, structure);
|
||||
});
|
||||
}
|
||||
|
@ -40,13 +40,12 @@ bool UnionsPostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
const auto& allInfos = repository->GetAllStructureInformation();
|
||||
|
||||
return std::all_of(allInfos.begin(),
|
||||
allInfos.end(),
|
||||
[](StructureInformation* info)
|
||||
{
|
||||
if (info->m_definition->GetType() != DataDefinitionType::UNION)
|
||||
return true;
|
||||
return std::ranges::all_of(allInfos,
|
||||
[](StructureInformation* info)
|
||||
{
|
||||
if (info->m_definition->GetType() != DataDefinitionType::UNION)
|
||||
return true;
|
||||
|
||||
return ProcessUnion(info);
|
||||
});
|
||||
return ProcessUnion(info);
|
||||
});
|
||||
}
|
||||
|
@ -63,11 +63,10 @@ bool UsagesPostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
const auto& allInfos = repository->GetAllStructureInformation();
|
||||
|
||||
return std::all_of(allInfos.begin(),
|
||||
allInfos.end(),
|
||||
[](StructureInformation* info)
|
||||
{
|
||||
const StructureComputations computations(info);
|
||||
return !computations.IsAsset() || ProcessAsset(info);
|
||||
});
|
||||
return std::ranges::all_of(allInfos,
|
||||
[](StructureInformation* info)
|
||||
{
|
||||
const StructureComputations computations(info);
|
||||
return !computations.IsAsset() || ProcessAsset(info);
|
||||
});
|
||||
}
|
||||
|
@ -97,12 +97,11 @@ void PrettyPrinter::PrintVariable(Variable* variable) const
|
||||
else
|
||||
{
|
||||
if (declarationModifiers[0]->GetType() == DeclarationModifierType::POINTER
|
||||
&& std::any_of(declarationModifiers.begin(),
|
||||
declarationModifiers.end(),
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::ARRAY;
|
||||
}))
|
||||
&& std::ranges::any_of(declarationModifiers,
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::ARRAY;
|
||||
}))
|
||||
{
|
||||
PrintVariablePointerToArray(variable);
|
||||
}
|
||||
@ -262,12 +261,11 @@ void PrettyPrinter::PrintTypedefs() const
|
||||
else
|
||||
{
|
||||
if (declarationModifiers[0]->GetType() == DeclarationModifierType::POINTER
|
||||
&& std::any_of(declarationModifiers.begin(),
|
||||
declarationModifiers.end(),
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::ARRAY;
|
||||
}))
|
||||
&& std::ranges::any_of(declarationModifiers,
|
||||
[](const std::unique_ptr<DeclarationModifier>& modifier)
|
||||
{
|
||||
return modifier->GetType() == DeclarationModifierType::ARRAY;
|
||||
}))
|
||||
{
|
||||
PrintTypedefPointerToArray(typedefDefinition);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ std::vector<scr_string_t> AssetMarker::GetUsedScriptStrings() const
|
||||
for (auto scrString : m_used_script_strings)
|
||||
usedScriptStrings.push_back(scrString);
|
||||
|
||||
std::sort(usedScriptStrings.begin(), usedScriptStrings.end());
|
||||
std::ranges::sort(usedScriptStrings);
|
||||
}
|
||||
|
||||
return usedScriptStrings;
|
||||
|
@ -30,12 +30,11 @@ void ZoneLoader::AddXBlock(std::unique_ptr<XBlock> block)
|
||||
{
|
||||
m_blocks.push_back(block.get());
|
||||
|
||||
std::sort(m_blocks.begin(),
|
||||
m_blocks.end(),
|
||||
[](XBlock* b1, XBlock* b2) -> bool
|
||||
{
|
||||
return b1->m_index < b2->m_index;
|
||||
});
|
||||
std::ranges::sort(m_blocks,
|
||||
[](XBlock* b1, XBlock* b2) -> bool
|
||||
{
|
||||
return b1->m_index < b2->m_index;
|
||||
});
|
||||
|
||||
m_zone->GetMemory()->AddBlock(std::move(block));
|
||||
}
|
||||
|
@ -61,10 +61,9 @@ bool MockParserLineStream::IsOpen() const
|
||||
|
||||
bool MockParserLineStream::Eof() const
|
||||
{
|
||||
return !std::any_of(m_include_positions.begin(),
|
||||
m_include_positions.end(),
|
||||
[](const IncludePos& pos)
|
||||
{
|
||||
return pos.m_pos < pos.m_lines.size();
|
||||
});
|
||||
return !std::ranges::any_of(m_include_positions,
|
||||
[](const IncludePos& pos)
|
||||
{
|
||||
return pos.m_pos < pos.m_lines.size();
|
||||
});
|
||||
}
|
||||
|
@ -973,7 +973,7 @@ namespace test::parsing::matcher
|
||||
[](HeaderMatcherFactory::token_list_t& tokens)
|
||||
{
|
||||
auto str = tokens[0].get().IdentifierValue();
|
||||
std::transform(str.begin(), str.end(), str.begin(), toupper);
|
||||
std::ranges::transform(str, str.begin(), toupper);
|
||||
return HeaderParserValue::Identifier(tokens[0].get().GetPos(), new std::string(std::move(str)));
|
||||
}),
|
||||
create.Char('{'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user