mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-23 19:20:56 +00:00
Add move constructor to MWMechanics::Spells
This commit is contained in:
parent
46e34c500c
commit
ca7add0624
@ -164,4 +164,12 @@ namespace MWMechanics
|
||||
if (it != mListeners.end())
|
||||
mListeners.erase(it);
|
||||
}
|
||||
|
||||
void SpellList::updateListener(Spells* before, Spells* after)
|
||||
{
|
||||
const auto it = std::find(mListeners.begin(), mListeners.end(), before);
|
||||
if (it == mListeners.end())
|
||||
return mListeners.push_back(after);
|
||||
*it = after;
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ namespace MWMechanics
|
||||
|
||||
void removeListener(Spells* spells);
|
||||
|
||||
void updateListener(Spells* before, Spells* after);
|
||||
|
||||
const std::vector<std::string> getSpells() const;
|
||||
};
|
||||
}
|
||||
|
@ -32,6 +32,15 @@ namespace MWMechanics
|
||||
mSpellList->addListener(this);
|
||||
}
|
||||
|
||||
Spells::Spells(Spells&& spells) : mSpellList(std::move(spells.mSpellList)), mSpells(std::move(spells.mSpells)),
|
||||
mSelectedSpell(std::move(spells.mSelectedSpell)), mUsedPowers(std::move(spells.mUsedPowers)),
|
||||
mSpellsChanged(std::move(spells.mSpellsChanged)), mEffects(std::move(spells.mEffects)),
|
||||
mSourcedEffects(std::move(spells.mSourcedEffects))
|
||||
{
|
||||
if (mSpellList)
|
||||
mSpellList->updateListener(&spells, this);
|
||||
}
|
||||
|
||||
std::map<const ESM::Spell*, SpellParams>::const_iterator Spells::begin() const
|
||||
{
|
||||
return mSpells.begin();
|
||||
|
@ -59,7 +59,7 @@ namespace MWMechanics
|
||||
|
||||
Spells(const Spells&);
|
||||
|
||||
Spells(const Spells&&) = delete;
|
||||
Spells(Spells&& spells);
|
||||
|
||||
~Spells();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user