From d63dd881130d87ef11463b72796eacbad7dd5c63 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 12 Jul 2014 17:35:38 +0200 Subject: [PATCH] Apply autocalc corrections to player starting spells --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 073cb5f74..d7c3e2f56 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -186,7 +186,7 @@ namespace MWMechanics const ESM::Spell* weakestSpell = NULL; int minCost = INT_MAX; - std::set selectedSpells; + std::vector selectedSpells; const ESM::Race* race = NULL; if (mRaceSelected) @@ -212,8 +212,6 @@ namespace MWMechanics continue; if (reachedLimit && spell->mData.mCost <= minCost) continue; - if (selectedSpells.find(spell->mId) != selectedSpells.end()) - continue; if (race && std::find(race->mPowers.mList.begin(), race->mPowers.mList.end(), spell->mId) != race->mPowers.mList.end()) continue; if (baseMagicka < spell->mData.mCost) @@ -226,18 +224,19 @@ namespace MWMechanics if (!attrSkillCheck(spell, skills, attributes)) continue; - selectedSpells.insert(spell->mId); + selectedSpells.push_back(spell->mId); if (reachedLimit) { - selectedSpells.erase(weakestSpell->mId); + std::vector::iterator it = std::find(selectedSpells.begin(), selectedSpells.end(), weakestSpell->mId); + if (it != selectedSpells.end()) + selectedSpells.erase(it); minCost = INT_MAX; - for (std::set::iterator weakIt = selectedSpells.begin(); weakIt != selectedSpells.end(); ++weakIt) + for (std::vector::iterator weakIt = selectedSpells.begin(); weakIt != selectedSpells.end(); ++weakIt) { const ESM::Spell* testSpell = esmStore.get().find(*weakIt); - if (testSpell->mData.mCost < minCost) // XXX what if 2 candidates have the same cost? - // Note iAutoPCSpellMax is 100 by default, so reachedLimit is very unlikely to happen + if (testSpell->mData.mCost < minCost) { minCost = testSpell->mData.mCost; weakestSpell = testSpell; @@ -257,7 +256,7 @@ namespace MWMechanics } } - for (std::set::iterator it = selectedSpells.begin(); it != selectedSpells.end(); ++it) + for (std::vector::iterator it = selectedSpells.begin(); it != selectedSpells.end(); ++it) creatureStats.getSpells().add(*it); // forced update and current value adjustments