Don't clear known spells when reading from the savegame

This is needed because the .ess format doesn't include the racial spells in the player's spell list.
openmw-35
scrawl 10 years ago
parent c7d15e6f74
commit 69676906ae

@ -23,6 +23,10 @@ namespace ESSImport
mKnownDialogueTopics.push_back(esm.getHString()); mKnownDialogueTopics.push_back(esm.getHString());
} }
if (esm.isNextSub("MNAM"))
esm.skipHSub(); // If this field is here it seems to specify the interior cell the player is in,
// but it's not always here, so it's kinda useless
esm.getHNT(mPNAM, "PNAM"); esm.getHNT(mPNAM, "PNAM");
if (esm.isNextSub("SNAM")) if (esm.isNextSub("SNAM"))

@ -312,21 +312,17 @@ namespace MWMechanics
void Spells::readState(const ESM::SpellState &state) void Spells::readState(const ESM::SpellState &state)
{ {
mSpells = state.mSpells; for (TContainer::const_iterator it = state.mSpells.begin(); it != state.mSpells.end(); ++it)
mSelectedSpell = state.mSelectedSpell;
// Discard spells that are no longer available due to changed content files
for (TContainer::iterator iter = mSpells.begin(); iter!=mSpells.end();)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(iter->first); // Discard spells that are no longer available due to changed content files
if (!spell) const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(it->first);
if (spell)
{ {
if (iter->first == mSelectedSpell) mSpells[it->first] = it->second;
mSelectedSpell = "";
mSpells.erase(iter++); if (it->first == state.mSelectedSpell)
mSelectedSpell = it->first;
} }
else
++iter;
} }
// No need to discard spells here (doesn't really matter if non existent ids are kept) // No need to discard spells here (doesn't really matter if non existent ids are kept)

@ -12,6 +12,7 @@ namespace ESM
class ESMReader; class ESMReader;
class ESMWriter; class ESMWriter;
// NOTE: spell ids must be lower case
struct SpellState struct SpellState
{ {
struct CorprusStats struct CorprusStats

Loading…
Cancel
Save