CAnimSourceReader: Make use of std::find_if where applicable

This commit is contained in:
Lioncash 2020-03-15 18:47:52 -04:00
parent 9541ed1919
commit 15db1b2647
1 changed files with 26 additions and 12 deletions

View File

@ -1,5 +1,7 @@
#include "Runtime/Character/CAnimSourceReader.hpp" #include "Runtime/Character/CAnimSourceReader.hpp"
#include <algorithm>
#include "Runtime/Character/CBoolPOINode.hpp" #include "Runtime/Character/CBoolPOINode.hpp"
#include "Runtime/Character/CFBStreamedAnimReader.hpp" #include "Runtime/Character/CFBStreamedAnimReader.hpp"
#include "Runtime/Character/CInt32POINode.hpp" #include "Runtime/Character/CInt32POINode.hpp"
@ -171,24 +173,36 @@ u32 CAnimSourceReaderBase::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOI
} }
bool CAnimSourceReaderBase::VGetBoolPOIState(const char* name) const { bool CAnimSourceReaderBase::VGetBoolPOIState(const char* name) const {
for (const auto& node : x24_boolStates) const auto iter = std::find_if(x24_boolStates.cbegin(), x24_boolStates.cend(),
if (node.first == name) [name](const auto& entry) { return entry.first == name; });
return node.second;
return false; if (iter == x24_boolStates.cend()) {
return false;
}
return iter->second;
} }
s32 CAnimSourceReaderBase::VGetInt32POIState(const char* name) const { s32 CAnimSourceReaderBase::VGetInt32POIState(const char* name) const {
for (const auto& node : x34_int32States) const auto iter = std::find_if(x34_int32States.cbegin(), x34_int32States.cend(),
if (node.first == name) [name](const auto& entry) { return entry.first == name; });
return node.second;
return 0; if (iter == x34_int32States.cend()) {
return 0;
}
return iter->second;
} }
CParticleData::EParentedMode CAnimSourceReaderBase::VGetParticlePOIState(const char* name) const { CParticleData::EParentedMode CAnimSourceReaderBase::VGetParticlePOIState(const char* name) const {
for (const auto& node : x44_particleStates) const auto iter = std::find_if(x44_particleStates.cbegin(), x44_particleStates.cend(),
if (node.first == name) [name](const auto& entry) { return entry.first == name; });
return node.second;
return CParticleData::EParentedMode::Initial; if (iter == x44_particleStates.cend()) {
return CParticleData::EParentedMode::Initial;
}
return iter->second;
} }
CAnimSourceReaderBase::CAnimSourceReaderBase(std::unique_ptr<IAnimSourceInfo>&& sourceInfo, const CCharAnimTime& time) CAnimSourceReaderBase::CAnimSourceReaderBase(std::unique_ptr<IAnimSourceInfo>&& sourceInfo, const CCharAnimTime& time)