1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-05-04 19:41:24 +00:00

Rename hasDisease to hasSpellType and refactor function

This commit is contained in:
ζeh Matt 2022-03-25 20:47:43 +02:00
parent dcdba227f7
commit edca5ac0b8
No known key found for this signature in database
GPG key ID: 18CE582C71A225B0
2 changed files with 9 additions and 11 deletions

View file

@ -112,25 +112,23 @@ namespace MWMechanics
return mSelectedSpell; return mSelectedSpell;
} }
bool Spells::hasDisease(const ESM::Spell::SpellType type) const bool Spells::hasSpellType(const ESM::Spell::SpellType type) const
{ {
for (const auto spell : mSpells) auto it = std::find_if(std::begin(mSpells), std::end(mSpells), [=](const ESM::Spell* spell)
{ {
if (spell->mData.mType == type) return spell->mData.mType == type;
return true; });
} return it != std::end(mSpells);
return false;
} }
bool Spells::hasCommonDisease() const bool Spells::hasCommonDisease() const
{ {
return hasDisease(ESM::Spell::ST_Disease); return hasSpellType(ESM::Spell::ST_Disease);
} }
bool Spells::hasBlightDisease() const bool Spells::hasBlightDisease() const
{ {
return hasDisease(ESM::Spell::ST_Blight); return hasSpellType(ESM::Spell::ST_Blight);
} }
void Spells::purge(const SpellFilter& filter) void Spells::purge(const SpellFilter& filter)

View file

@ -36,7 +36,7 @@ namespace MWMechanics
std::vector<std::pair<const ESM::Spell*, MWWorld::TimeStamp>> mUsedPowers; std::vector<std::pair<const ESM::Spell*, MWWorld::TimeStamp>> mUsedPowers;
bool hasDisease(const ESM::Spell::SpellType type) const; bool hasSpellType(const ESM::Spell::SpellType type) const;
using SpellFilter = bool (*)(const ESM::Spell*); using SpellFilter = bool (*)(const ESM::Spell*);
void purge(const SpellFilter& filter); void purge(const SpellFilter& filter);