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:
parent
a34151d890
commit
46e34c500c
1 changed files with 5 additions and 13 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue