fixed a faction case folding issue

actorid
scrawl 13 years ago
parent 4a009fc2bb
commit 76d71f86bc

@ -3,6 +3,8 @@
#include <memory>
#include <boost/algorithm/string.hpp>
#include <OgreSceneNode.h>
#include <components/esm/loadnpc.hpp>
@ -56,13 +58,15 @@ namespace MWClass
// NPC stats
if (!ref->base->faction.empty())
{
std::string faction = ref->base->faction;
boost::algorithm::to_lower(faction);
if(ref->base->npdt52.gold != -10)
{
data->mNpcStats.mFactionRank[ref->base->faction] = (int)ref->base->npdt52.rank;
data->mNpcStats.mFactionRank[faction] = (int)ref->base->npdt52.rank;
}
else
{
data->mNpcStats.mFactionRank[ref->base->faction] = (int)ref->base->npdt12.rank;
data->mNpcStats.mFactionRank[faction] = (int)ref->base->npdt12.rank;
}
}

@ -206,7 +206,7 @@ namespace MWDialogue
if(!NPCstats.mFactionRank.empty())
{
std::string NPCFaction = NPCstats.mFactionRank.begin()->first;
if(PCstats.mFactionRank.find(NPCFaction) != PCstats.mFactionRank.end()) sameFaction = 1;
if(PCstats.mFactionRank.find(toLower(NPCFaction)) != PCstats.mFactionRank.end()) sameFaction = 1;
}
if(!selectCompare<int,int>(comp,sameFaction,select.i)) return false;
}
@ -525,7 +525,7 @@ namespace MWDialogue
//MWWorld::Class npcClass = MWWorld::Class::get(actor);
MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(actor);
std::map<std::string,int>::iterator it = stats.mFactionRank.find(info.npcFaction);
std::map<std::string,int>::iterator it = stats.mFactionRank.find(toLower(info.npcFaction));
if(it!=stats.mFactionRank.end())
{
//check rank
@ -542,7 +542,7 @@ namespace MWDialogue
if(!info.pcFaction.empty())
{
MWMechanics::NpcStats stats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
std::map<std::string,int>::iterator it = stats.mFactionRank.find(info.pcFaction);
std::map<std::string,int>::iterator it = stats.mFactionRank.find(toLower(info.pcFaction));
if(it!=stats.mFactionRank.end())
{
//check rank

@ -20,6 +20,7 @@ namespace MWMechanics
{
// NPCs other than the player can only have one faction. But for the sake of consistency
// we use the same data structure for the PC and the NPCs.
/// \note the faction key must be in lowercase
std::map<std::string, int> mFactionRank;
Stat<float> mSkill[27];

@ -1,6 +1,8 @@
#include "statsextensions.hpp"
#include <boost/algorithm/string.hpp>
#include <components/compiler/extensions.hpp>
#include <components/interpreter/interpreter.hpp>
@ -362,6 +364,7 @@ namespace MWScript
factionID = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
}
boost::algorithm::to_lower(factionID);
if(factionID != "")
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
@ -390,6 +393,7 @@ namespace MWScript
factionID = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
}
boost::algorithm::to_lower(factionID);
if(factionID != "")
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
@ -422,6 +426,7 @@ namespace MWScript
factionID = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
}
boost::algorithm::to_lower(factionID);
if(factionID != "")
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
@ -459,6 +464,7 @@ namespace MWScript
factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).mFactionRank.begin()->first;
}
}
boost::algorithm::to_lower(factionID);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
if(factionID!="")
{

Loading…
Cancel
Save