Use algorithm for IsResponsibleForIndex check.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2020-06-02 12:14:49 +02:00
parent 69f6a89c0d
commit 18203138d1
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 7 additions and 7 deletions

View File

@ -19,3 +19,9 @@ export uint8_t CreatureLib_BattleParty_IsResponsibleForIndex(bool& out, const Ba
} }
export bool CreatureLib_BattleParty_HasCreaturesNotInField(const BattleParty* p) { return p->HasCreaturesNotInField(); } export bool CreatureLib_BattleParty_HasCreaturesNotInField(const BattleParty* p) { return p->HasCreaturesNotInField(); }
inline bool BattleParty::IsResponsibleForIndex(uint8_t side, uint8_t index) const {
return std::any_of(_responsibleIndices.begin(), _responsibleIndices.end(), [side, index](const CreatureIndex& ci) {
return ci.GetSideIndex() == side && ci.GetCreatureIndex() == index;
});
}

View File

@ -24,13 +24,7 @@ namespace CreatureLib::Battling {
return _responsibleIndices.Contains(index); return _responsibleIndices.Contains(index);
} }
inline bool IsResponsibleForIndex(uint8_t side, uint8_t index) const { bool IsResponsibleForIndex(uint8_t side, uint8_t index) const;
for (const auto& i : _responsibleIndices) {
if (i.GetSideIndex() == side && i.GetCreatureIndex() == index)
return true;
}
return false;
}
inline bool HasCreaturesNotInField() const { inline bool HasCreaturesNotInField() const {
auto& p = _party->GetParty(); auto& p = _party->GetParty();