mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-04 16:49:41 +00:00
Use algorithms to add/remove listener to SpellList
This commit is contained in:
parent
a34151d890
commit
46e34c500c
1 changed files with 5 additions and 13 deletions
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue