mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-28 08:37:12 +00:00
Use algorithms to add/remove listener to SpellList
This commit is contained in:
parent
a34151d890
commit
46e34c500c
@ -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…
x
Reference in New Issue
Block a user