Clean up the NpcStats expelled interface. Show message box when expelled.

actorid
scrawl 11 years ago
parent 098f9712f1
commit 19d63f392f

@ -507,9 +507,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
std::string faction =
MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first;
std::set<std::string>& expelled = MWWorld::Class::get (player).getNpcStats (player).getExpelled();
return expelled.find (faction)!=expelled.end();
return player.getClass().getNpcStats(player).getExpelled(faction);
}
case SelectWrapper::Function_PcVampire:

@ -470,7 +470,7 @@ namespace MWMechanics
it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.end(); ++it)
{
if(Misc::StringUtils::lowerCase(it->mFaction) == Misc::StringUtils::lowerCase(npcFaction)
&& playerStats.getExpelled().find(Misc::StringUtils::lowerCase(it->mFaction)) == playerStats.getExpelled().end())
&& !playerStats.getExpelled(it->mFaction))
reaction = it->mReaction;
}
rank = playerStats.getFactionRanks().find(Misc::StringUtils::lowerCase(npcFaction))->second;

@ -108,14 +108,26 @@ std::map<std::string, int>& MWMechanics::NpcStats::getFactionRanks()
return mFactionRank;
}
const std::set<std::string>& MWMechanics::NpcStats::getExpelled() const
bool MWMechanics::NpcStats::getExpelled(const std::string& factionID) const
{
return mExpelled;
return mExpelled.find(Misc::StringUtils::lowerCase(factionID)) != mExpelled.end();
}
std::set<std::string>& MWMechanics::NpcStats::getExpelled()
void MWMechanics::NpcStats::expell(const std::string& factionID)
{
return mExpelled;
std::string lower = Misc::StringUtils::lowerCase(factionID);
if (mExpelled.find(lower) == mExpelled.end())
{
std::string message = "#{sExpelledMessage}";
message += MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(factionID)->mName;
MWBase::Environment::get().getWindowManager()->messageBox(message);
mExpelled.insert(lower);
}
}
void MWMechanics::NpcStats::clearExpelled(const std::string& factionID)
{
mExpelled.erase(Misc::StringUtils::lowerCase(factionID));
}
bool MWMechanics::NpcStats::isSameFaction (const NpcStats& npcStats) const

@ -99,8 +99,10 @@ namespace MWMechanics
const std::map<std::string, int>& getFactionRanks() const;
std::map<std::string, int>& getFactionRanks();
const std::set<std::string>& getExpelled() const;
std::set<std::string>& getExpelled();
const std::set<std::string>& getExpelled() const { return mExpelled; }
bool getExpelled(const std::string& factionID) const;
void expell(const std::string& factionID);
void clearExpelled(const std::string& factionID);
bool isSameFaction (const NpcStats& npcStats) const;
///< Do *this and \a npcStats share a faction?

@ -905,15 +905,7 @@ namespace MWScript
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
if(factionID!="")
{
std::set<std::string>& expelled = MWWorld::Class::get(player).getNpcStats(player).getExpelled ();
if (expelled.find (factionID) != expelled.end())
{
runtime.push(1);
}
else
{
runtime.push(0);
}
runtime.push(player.getClass().getNpcStats(player).getExpelled(factionID));
}
else
{
@ -951,9 +943,7 @@ namespace MWScript
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
if(factionID!="")
{
std::set<std::string>& expelled = MWWorld::Class::get(player).getNpcStats(player).getExpelled ();
Misc::StringUtils::toLower(factionID);
expelled.insert(factionID);
player.getClass().getNpcStats(player).expell(factionID);
}
}
};
@ -986,11 +976,7 @@ namespace MWScript
}
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
if(factionID!="")
{
std::set<std::string>& expelled = MWWorld::Class::get(player).getNpcStats(player).getExpelled ();
Misc::StringUtils::toLower(factionID);
expelled.erase (factionID);
}
player.getClass().getNpcStats(player).clearExpelled(factionID);
}
};

Loading…
Cancel
Save