forked from teamnwah/openmw-tes3coop
[Client] Fix crash and memory leak when erasing spellbook
This commit is contained in:
parent
88e648aaa9
commit
c5035cd174
1 changed files with 11 additions and 5 deletions
|
@ -914,15 +914,21 @@ void LocalPlayer::setSpellbook()
|
||||||
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
||||||
|
|
||||||
// Clear spells in spellbook, while ignoring abilities, powers, etc.
|
// Clear spells in spellbook, while ignoring abilities, powers, etc.
|
||||||
for (MWMechanics::Spells::TIterator iter = ptrSpells.begin(); iter != ptrSpells.end(); ++iter)
|
while(true)
|
||||||
|
{
|
||||||
|
MWMechanics::Spells::TIterator iter = ptrSpells.begin();
|
||||||
|
for (; iter != ptrSpells.end(); iter++)
|
||||||
{
|
{
|
||||||
const ESM::Spell *spell = iter->first;
|
const ESM::Spell *spell = iter->first;
|
||||||
|
|
||||||
if (spell->mData.mType == ESM::Spell::ST_Spell)
|
if (spell->mData.mType == ESM::Spell::ST_Spell)
|
||||||
{
|
{
|
||||||
ptrSpells.remove(spell->mId);
|
ptrSpells.remove(spell->mId);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(iter == ptrSpells.end())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Proceed by adding spells
|
// Proceed by adding spells
|
||||||
addSpells();
|
addSpells();
|
||||||
|
|
Loading…
Reference in a new issue