forked from mirror/openmw-tes3mp
Merge pull request #1175 from MiroslavR/pcrank-condition
Fix for "PC Rank" info condition
This commit is contained in:
commit
cf47299723
1 changed files with 14 additions and 2 deletions
|
@ -107,11 +107,11 @@ bool MWDialogue::Filter::testActor (const ESM::DialInfo& info) const
|
||||||
bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const
|
bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const
|
||||||
{
|
{
|
||||||
const MWWorld::Ptr player = MWMechanics::getPlayer();
|
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())
|
if (!info.mPcFaction.empty())
|
||||||
{
|
{
|
||||||
MWMechanics::NpcStats& stats = player.getClass().getNpcStats (player);
|
|
||||||
std::map<std::string,int>::const_iterator iter = stats.getFactionRanks().find (Misc::StringUtils::lowerCase (info.mPcFaction));
|
std::map<std::string,int>::const_iterator iter = stats.getFactionRanks().find (Misc::StringUtils::lowerCase (info.mPcFaction));
|
||||||
|
|
||||||
if(iter==stats.getFactionRanks().end())
|
if(iter==stats.getFactionRanks().end())
|
||||||
|
@ -121,6 +121,18 @@ bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const
|
||||||
if (iter->second < info.mData.mPCrank)
|
if (iter->second < info.mData.mPCrank)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if (info.mData.mPCrank != -1)
|
||||||
|
{
|
||||||
|
// required PC faction is not specified but PC rank is; use speaker's faction
|
||||||
|
std::map<std::string,int>::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
|
// check cell
|
||||||
if (!info.mCell.empty())
|
if (!info.mCell.empty())
|
||||||
|
|
Loading…
Reference in a new issue