1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-04 13:49:41 +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)
{
for(const auto ptr : mListeners)
{
if(ptr == spells)
return;
}
if (std::find(mListeners.begin(), mListeners.end(), spells) != mListeners.end())
return;
mListeners.push_back(spells);
}
void SpellList::removeListener(Spells* spells)
{
for(auto it = mListeners.begin(); it != mListeners.end(); it++)
{
if(*it == spells)
{
mListeners.erase(it);
break;
}
}
const auto it = std::find(mListeners.begin(), mListeners.end(), spells);
if (it != mListeners.end())
mListeners.erase(it);
}
}