From 02dec787fda62398de31d0c2740ab9fc250f9b48 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 27 Sep 2014 22:44:20 +0200 Subject: [PATCH] Cache GMSTs in getDerivedDisposition --- .../mwmechanics/mechanicsmanagerimp.cpp | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 6ca4a4336..d5cb23806 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -566,11 +566,14 @@ namespace MWMechanics MWWorld::LiveCellRef* player = playerPtr.get(); const MWMechanics::NpcStats &playerStats = playerPtr.getClass().getNpcStats(playerPtr); + const MWWorld::Store& gmst = MWBase::Environment::get().getWorld()->getStore().get(); + static float fDispRaceMod = gmst.find("fDispRaceMod")->getFloat(); if (Misc::StringUtils::ciEqual(npc->mBase->mRace, player->mBase->mRace)) - x += MWBase::Environment::get().getWorld()->getStore().get().find("fDispRaceMod")->getFloat(); + x += fDispRaceMod; - x += MWBase::Environment::get().getWorld()->getStore().get().find("fDispPersonalityMult")->getFloat() - * (playerStats.getAttribute(ESM::Attribute::Personality).getModified() - MWBase::Environment::get().getWorld()->getStore().get().find("fDispPersonalityBase")->getFloat()); + static float fDispPersonalityMult = gmst.find("fDispPersonalityMult")->getFloat(); + static float fDispPersonalityBase = gmst.find("fDispPersonalityBase")->getFloat(); + x += fDispPersonalityMult * (playerStats.getAttribute(ESM::Attribute::Personality).getModified() - fDispPersonalityBase); float reaction = 0; int rank = 0; @@ -606,16 +609,23 @@ namespace MWMechanics reaction = 0; rank = 0; } - x += (MWBase::Environment::get().getWorld()->getStore().get().find("fDispFactionRankMult")->getFloat() * rank - + MWBase::Environment::get().getWorld()->getStore().get().find("fDispFactionRankBase")->getFloat()) - * MWBase::Environment::get().getWorld()->getStore().get().find("fDispFactionMod")->getFloat() * reaction; - x -= MWBase::Environment::get().getWorld()->getStore().get().find("fDispCrimeMod")->getFloat() * playerStats.getBounty(); + static float fDispFactionRankMult = gmst.find("fDispFactionRankMult")->getFloat(); + static float fDispFactionRankBase = gmst.find("fDispFactionRankBase")->getFloat(); + static float fDispFactionMod = gmst.find("fDispFactionMod")->getFloat(); + x += (fDispFactionRankMult * rank + + fDispFactionRankBase) + * fDispFactionMod * reaction; + + static float fDispCrimeMod = gmst.find("fDispCrimeMod")->getFloat(); + static float fDispDiseaseMod = gmst.find("fDispDiseaseMod")->getFloat(); + x -= fDispCrimeMod * playerStats.getBounty(); if (playerStats.hasCommonDisease() || playerStats.hasBlightDisease()) - x += MWBase::Environment::get().getWorld()->getStore().get().find("fDispDiseaseMod")->getFloat(); + x += fDispDiseaseMod; + static float fDispWeaponDrawn = gmst.find("fDispWeaponDrawn")->getFloat(); if (playerStats.getDrawState() == MWMechanics::DrawState_Weapon) - x += MWBase::Environment::get().getWorld()->getStore().get().find("fDispWeaponDrawn")->getFloat(); + x += fDispWeaponDrawn; x += ptr.getClass().getCreatureStats(ptr).getMagicEffects().get(ESM::MagicEffect::Charm).getMagnitude();