From f17756712a9c1c5b8da37052e1daa7d122933f11 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 10 Sep 2012 13:15:55 +0200 Subject: [PATCH] fixed spell list handling --- apps/openmw/mwgui/spellbuyingwindow.cpp | 29 +++++++++++-------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index 481dd5dd8..48e181545 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -91,24 +91,21 @@ namespace MWGui clearSpells(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); - MWMechanics::Spells& playerSpells = stats.getSpells(); - /// \todo get spell list via MWWorld::Class interface - std::vector spellList = actor.get()->base->spells.list; - for (std::vector::const_iterator it = spellList.begin(); it != spellList.end(); ++it) + + MWMechanics::Spells& playerSpells = MWWorld::Class::get (player).getCreatureStats (player).getSpells(); + MWMechanics::Spells& merchantSpells = MWWorld::Class::get (actor).getCreatureStats (actor).getSpells(); + + for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter) { - bool alreadyHave = false; - for (std::vector::const_iterator it2 = playerSpells.begin(); it2 != playerSpells.end(); ++it2) - { - if (*it==*it2) - { - alreadyHave = true; - break; - } - } + const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter); - if (alreadyHave==false) - addSpell(*it); + if (spell->data.type!=ESM::Spell::ST_Spell) + continue; // don't try to sell diseases, curses or powers + + if (std::find (playerSpells.begin(), playerSpells.end(), *iter)!=playerSpells.end()) + continue; // we have that spell already + + addSpell (*iter); } updateLabels();