From 86ad7a96f4288de26335558ceac2d210e45e1c42 Mon Sep 17 00:00:00 2001 From: greye Date: Mon, 5 Nov 2012 21:19:22 +0400 Subject: [PATCH] applying new interface vol.2, inconsistent --- apps/openmw/mwmechanics/activespells.cpp | 10 ++--- apps/openmw/mwmechanics/actors.cpp | 8 ++-- apps/openmw/mwmechanics/creaturestats.cpp | 7 +-- .../mwmechanics/mechanicsmanagerimp.cpp | 44 +++++++++++-------- apps/openmw/mwmechanics/npcstats.cpp | 21 ++++----- apps/openmw/mwmechanics/spellsuccess.hpp | 9 ++-- 6 files changed, 56 insertions(+), 43 deletions(-) diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 7deab426d..989bdedd7 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -86,7 +86,7 @@ namespace MWMechanics if (effects.second) { const ESM::MagicEffect *magicEffect = - MWBase::Environment::get().getWorld()->getStore().magicEffects.find ( + MWBase::Environment::get().getWorld()->getStore().get().find ( iter->mEffectID); if (iter->mDuration==0) @@ -114,18 +114,18 @@ namespace MWMechanics std::pair ActiveSpells::getEffectList (const std::string& id) const { if (const ESM::Spell *spell = - MWBase::Environment::get().getWorld()->getStore().spells.search (id)) + MWBase::Environment::get().getWorld()->getStore().get().search (id)) return std::make_pair (spell->mEffects, false); if (const ESM::Potion *potion = - MWBase::Environment::get().getWorld()->getStore().potions.search (id)) + MWBase::Environment::get().getWorld()->getStore().get().search (id)) return std::make_pair (potion->mEffects, false); if (const ESM::Ingredient *ingredient = - MWBase::Environment::get().getWorld()->getStore().ingreds.search (id)) + MWBase::Environment::get().getWorld()->getStore().get().search (id)) { const ESM::MagicEffect *magicEffect = - MWBase::Environment::get().getWorld()->getStore().magicEffects.find ( + MWBase::Environment::get().getWorld()->getStore().get().find ( ingredient->mData.mEffectID[0]); ESM::ENAMstruct effect; diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index b5933a646..d541baea9 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -103,9 +103,9 @@ namespace MWMechanics const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); - float fFatigueReturnBase = store.gameSettings.find("fFatigueReturnBase")->getFloat (); - float fFatigueReturnMult = store.gameSettings.find("fFatigueReturnMult")->getFloat (); - float fEndFatigueMult = store.gameSettings.find("fEndFatigueMult")->getFloat (); + float fFatigueReturnBase = store.get().find("fFatigueReturnBase")->getFloat (); + float fFatigueReturnMult = store.get().find("fFatigueReturnMult")->getFloat (); + float fEndFatigueMult = store.get().find("fEndFatigueMult")->getFloat (); float capacity = MWWorld::Class::get(ptr).getCapacity(ptr); float encumbrance = MWWorld::Class::get(ptr).getEncumbrance(ptr); @@ -122,7 +122,7 @@ namespace MWMechanics if (!stunted) { - float fRestMagicMult = store.gameSettings.find("fRestMagicMult")->getFloat (); + float fRestMagicMult = store.get().find("fRestMagicMult")->getFloat (); DynamicStat magicka = stats.getMagicka(); magicka.setCurrent (magicka.getCurrent() diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 9a6a5c0f2..95e721c01 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -41,10 +41,11 @@ namespace MWMechanics float normalised = max==0 ? 1 : std::max (0.0f, static_cast (current)/max); - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::Store &gmst = + MWBase::Environment::get().getWorld()->getStore().get(); - return store.gameSettings.find ("fFatigueBase")->getFloat() - - store.gameSettings.find ("fFatigueMult")->getFloat() * (1-normalised); + return gmst.find ("fFatigueBase")->getFloat() + - gmst.find ("fFatigueMult")->getFloat() * (1-normalised); } const Stat &CreatureStats::getAttribute(int index) const diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index a9b6e82e8..94418c522 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -42,8 +42,9 @@ namespace MWMechanics if (mRaceSelected) { const ESM::Race *race = - MWBase::Environment::get().getWorld()->getStore().races.find ( - MWBase::Environment::get().getWorld()->getPlayer().getRace()); + MWBase::Environment::get().getWorld()->getStore().get().find ( + MWBase::Environment::get().getWorld()->getPlayer().getRace() + ); bool male = MWBase::Environment::get().getWorld()->getPlayer().isMale(); @@ -91,7 +92,7 @@ namespace MWMechanics if (!MWBase::Environment::get().getWorld()->getPlayer().getBirthsign().empty()) { const ESM::BirthSign *sign = - MWBase::Environment::get().getWorld()->getStore().birthSigns.find ( + MWBase::Environment::get().getWorld()->getStore().get().find ( MWBase::Environment::get().getWorld()->getPlayer().getBirthsign()); for (std::vector::const_iterator iter (sign->mPowers.mList.begin()); @@ -132,14 +133,15 @@ namespace MWMechanics } } - typedef MWWorld::IndexListT::MapType ContainerType; - const ContainerType& skills = MWBase::Environment::get().getWorld()->getStore().skills.list; + const MWWorld::Store &skills = + MWBase::Environment::get().getWorld()->getStore().get(); - for (ContainerType::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter) + MWWorld::Store::iterator iter = skills.begin(); + for (; iter != skills.end(); ++iter) { - if (iter->second.mData.mSpecialization==class_.mData.mSpecialization) + if (iter->mData.mSpecialization==class_.mData.mSpecialization) { - int index = iter->first; + int index = iter->mIndex; if (index>=0 && index<27) { @@ -261,12 +263,16 @@ namespace MWMechanics if (mUpdatePlayer) { // basic player profile; should not change anymore after the creation phase is finished. - MWBase::Environment::get().getWindowManager()->setValue ("name", MWBase::Environment::get().getWorld()->getPlayer().getName()); - MWBase::Environment::get().getWindowManager()->setValue ("race", - MWBase::Environment::get().getWorld()->getStore().races.find (MWBase::Environment::get().getWorld()->getPlayer(). - getRace())->mName); - MWBase::Environment::get().getWindowManager()->setValue ("class", - MWBase::Environment::get().getWorld()->getPlayer().getClass().mName); + MWBase::WindowManager *winMgr = + MWBase::Environment::get().getWindowManager(); + + MWBase::World *world = MWBase::Environment::get().getWorld(); + MWWorld::Player &player = world->getPlayer(); + + winMgr->setValue ("name", player.getName()); + winMgr->setValue ("race", world->getStore().get().find (player.getRace())->mName); + winMgr->setValue ("class", player.getClass().mName); + mUpdatePlayer = false; MWBase::WindowManager::SkillList majorSkills (5); @@ -274,11 +280,11 @@ namespace MWMechanics for (int i=0; i<5; ++i) { - minorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().mData.mSkills[i][0]; - majorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().mData.mSkills[i][1]; + minorSkills[i] = player.getClass().mData.mSkills[i][0]; + majorSkills[i] = player.getClass().mData.mSkills[i][1]; } - MWBase::Environment::get().getWindowManager()->configureSkills (majorSkills, minorSkills); + winMgr->configureSkills (majorSkills, minorSkills); } mActors.update (movement, duration, paused); @@ -313,7 +319,9 @@ namespace MWMechanics void MechanicsManager::setPlayerClass (const std::string& id) { - MWBase::Environment::get().getWorld()->getPlayer().setClass (*MWBase::Environment::get().getWorld()->getStore().classes.find (id)); + MWBase::Environment::get().getWorld()->getPlayer().setClass ( + *MWBase::Environment::get().getWorld()->getStore().get().find (id) + ); mClassSelected = true; buildPlayer(); mUpdatePlayer = true; diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index e01f7cc1c..c0da99aaf 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -81,7 +81,8 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla if (level<0) level = static_cast (getSkill (skillIndex).getBase()); - const ESM::Skill *skill = MWBase::Environment::get().getWorld()->getStore().skills.find (skillIndex); + const ESM::Skill *skill = + MWBase::Environment::get().getWorld()->getStore().get().find (skillIndex); float skillFactor = 1; @@ -96,14 +97,15 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla throw std::runtime_error ("invalid skill gain factor"); } - float typeFactor = - MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMiscSkillBonus")->getFloat(); + const MWWorld::Store &gmst = + MWBase::Environment::get().getWorld()->getStore().get(); + + float typeFactor = gmst.find ("fMiscSkillBonus")->getFloat(); for (int i=0; i<5; ++i) if (class_.mData.mSkills[i][0]==skillIndex) { - typeFactor = - MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMinorSkillBonus")->getFloat(); + typeFactor = gmst.find ("fMinorSkillBonus")->getFloat(); break; } @@ -111,8 +113,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla for (int i=0; i<5; ++i) if (class_.mData.mSkills[i][1]==skillIndex) { - typeFactor = - MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMajorSkillBonus")->getFloat(); + typeFactor = gmst.find ("fMajorSkillBonus")->getFloat(); break; } @@ -124,8 +125,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla if (skill->mData.mSpecialization==class_.mData.mSpecialization) { - specialisationFactor = - MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fSpecialSkillBonus")->getFloat(); + specialisationFactor = gmst.find ("fSpecialSkillBonus")->getFloat(); if (specialisationFactor<=0) throw std::runtime_error ("invalid skill specialisation factor"); @@ -178,7 +178,8 @@ void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &clas mLevelProgress += levelProgress; // check the attribute this skill belongs to - const ESM::Skill* skill = MWBase::Environment::get().getWorld ()->getStore ().skills.find(skillIndex); + const ESM::Skill* skill = + MWBase::Environment::get().getWorld ()->getStore ().get().find(skillIndex); ++mSkillIncreases[skill->mData.mAttribute]; // Play sound & skill progress notification diff --git a/apps/openmw/mwmechanics/spellsuccess.hpp b/apps/openmw/mwmechanics/spellsuccess.hpp index 9928966bb..2dacee57b 100644 --- a/apps/openmw/mwmechanics/spellsuccess.hpp +++ b/apps/openmw/mwmechanics/spellsuccess.hpp @@ -40,7 +40,8 @@ namespace MWMechanics for (std::vector::const_iterator it = effects.begin(); it != effects.end(); ++it) { - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->mEffectID); + const ESM::MagicEffect* effect = + MWBase::Environment::get().getWorld()->getStore().get().find(it->mEffectID); int _school = effect->mData.mSchool; int _skillLevel = stats.getSkill (spellSchoolToSkill(_school)).getModified(); @@ -61,7 +62,8 @@ namespace MWMechanics inline int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); + const ESM::Spell* spell = + MWBase::Environment::get().getWorld()->getStore().getgetStore().spells.find(spellId); + const ESM::Spell* spell = + MWBase::Environment::get().getWorld()->getStore().get().find(spellId); return getSpellSuccessChance(spell, actor); } }