From 000597236e07b30ce8533b1877ee62e92de9e17a Mon Sep 17 00:00:00 2001 From: ae-g-i-s Date: Sun, 6 Mar 2016 18:29:15 +0100 Subject: [PATCH] Fix incorrect handling of baseDisposition >= 100 in testDisposition(), enable unbounded getDerivedDisposition() (Fixes #3233) --- apps/openmw/mwbase/mechanicsmanager.hpp | 2 +- apps/openmw/mwdialogue/filter.cpp | 2 +- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 4 ++-- apps/openmw/mwmechanics/mechanicsmanagerimp.hpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index 42da1a052..4b7db53cf 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -97,7 +97,7 @@ namespace MWBase virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) = 0; ///< This is used by every service to determine the price of objects given the trading skills of the player and NPC. - virtual int getDerivedDisposition(const MWWorld::Ptr& ptr) = 0; + virtual int getDerivedDisposition(const MWWorld::Ptr& ptr, bool bounded = true) = 0; ///< Calculate the diposition of an NPC toward the player. virtual int countDeaths (const std::string& id) const = 0; diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 69df38ccf..40d4076ae 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -145,7 +145,7 @@ bool MWDialogue::Filter::testDisposition (const ESM::DialInfo& info, bool invert if (isCreature) return true; - int actorDisposition = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor) + int actorDisposition = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor, false) + MWBase::Environment::get().getDialogueManager()->getTemporaryDispositionChange(); // For service refusal, the disposition check is inverted. However, a value of 0 still means "always succeed". return invert ? (info.mData.mDisposition == 0 || actorDisposition < info.mData.mDisposition) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 7fbc3a853..74bb3eda6 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -581,7 +581,7 @@ namespace MWMechanics mUpdatePlayer = true; } - int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr) + int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr, bool bounded /* = true */) { const MWMechanics::NpcStats& npcSkill = ptr.getClass().getNpcStats(ptr); float x = static_cast(npcSkill.getBaseDisposition()); @@ -653,7 +653,7 @@ namespace MWMechanics x += ptr.getClass().getCreatureStats(ptr).getMagicEffects().get(ESM::MagicEffect::Charm).getMagnitude(); - int effective_disposition = std::max(0,std::min(int(x),100));//, normally clamped to [0..100] when used + int effective_disposition = std::max(0,std::min(int(x), (bounded ? 100 : std::numeric_limits::max()) )); // clamped to [0..100] unless !bounded return effective_disposition; } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index fb29c07ea..891c0587c 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -92,7 +92,7 @@ namespace MWMechanics virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying); ///< This is used by every service to determine the price of objects given the trading skills of the player and NPC. - virtual int getDerivedDisposition(const MWWorld::Ptr& ptr); + virtual int getDerivedDisposition(const MWWorld::Ptr& ptr, bool bounded = true); ///< Calculate the diposition of an NPC toward the player. virtual int countDeaths (const std::string& id) const;