1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-29 22:20:33 +00:00

fixed a faction case folding issue

This commit is contained in:
scrawl 2012-05-21 03:10:55 +02:00
parent 4a009fc2bb
commit 76d71f86bc
4 changed files with 16 additions and 5 deletions

View File

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

View File

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

View File

@ -20,6 +20,7 @@ namespace MWMechanics
{ {
// NPCs other than the player can only have one faction. But for the sake of consistency // 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. // 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; std::map<std::string, int> mFactionRank;
Stat<float> mSkill[27]; Stat<float> mSkill[27];

View File

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