1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-04 20:49:42 +00:00

Use algorithms to add/remove listener to SpellList

This commit is contained in:
elsid 2021-04-23 23:57:58 +02:00
parent a34151d890
commit 46e34c500c
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40

View file

@ -153,23 +153,15 @@ namespace MWMechanics
void SpellList::addListener(Spells* spells) void SpellList::addListener(Spells* spells)
{ {
for(const auto ptr : mListeners) if (std::find(mListeners.begin(), mListeners.end(), spells) != mListeners.end())
{ return;
if(ptr == spells)
return;
}
mListeners.push_back(spells); mListeners.push_back(spells);
} }
void SpellList::removeListener(Spells* spells) void SpellList::removeListener(Spells* spells)
{ {
for(auto it = mListeners.begin(); it != mListeners.end(); it++) const auto it = std::find(mListeners.begin(), mListeners.end(), spells);
{ if (it != mListeners.end())
if(*it == spells) mListeners.erase(it);
{
mListeners.erase(it);
break;
}
}
} }
} }