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