From 5f234f89529f3b8dbe5d67ee22bb3099b7ab2a77 Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Fri, 23 Dec 2016 19:03:59 +0100 Subject: [PATCH] Dialogue: "PC Rank" condition now uses speaker's faction if "PC Faction" is not given (Fixes #3689) --- apps/openmw/mwdialogue/filter.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 37a84b287..d51918152 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -107,11 +107,11 @@ bool MWDialogue::Filter::testActor (const ESM::DialInfo& info) const bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const { const MWWorld::Ptr player = MWMechanics::getPlayer(); + MWMechanics::NpcStats& stats = player.getClass().getNpcStats (player); - // check player faction + // check player faction and rank if (!info.mPcFaction.empty()) { - MWMechanics::NpcStats& stats = player.getClass().getNpcStats (player); std::map::const_iterator iter = stats.getFactionRanks().find (Misc::StringUtils::lowerCase (info.mPcFaction)); if(iter==stats.getFactionRanks().end()) @@ -121,6 +121,18 @@ bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const if (iter->second < info.mData.mPCrank) return false; } + else if (info.mData.mPCrank != -1) + { + // required PC faction is not specified but PC rank is; use speaker's faction + std::map::const_iterator iter = stats.getFactionRanks().find (Misc::StringUtils::lowerCase (mActor.getClass().getPrimaryFaction(mActor))); + + if(iter==stats.getFactionRanks().end()) + return false; + + // check rank + if (iter->second < info.mData.mPCrank) + return false; + } // check cell if (!info.mCell.empty())