1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 02:53:53 +00:00

Issue #219: fixed function decoding and moved choice function from DialogueManager to Filter

This commit is contained in:
Marc Zinnschlag 2012-11-10 09:48:20 +01:00
parent a752536cea
commit c425b3f4a3
5 changed files with 22 additions and 16 deletions

View file

@ -137,13 +137,6 @@ namespace MWDialogue
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
break;
case 50://choice
if(choice)
{
if(!selectCompare<int,int>(comp,mChoice,select.mI)) return false;
}
break;
case 60://PC Vampire
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
break;
@ -287,7 +280,7 @@ namespace MWDialogue
const MWWorld::Store<ESM::Dialogue> &dialogs =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
Filter filter (actor);
Filter filter (actor, mChoice);
MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin();
for (; it != dialogs.end(); ++it)
@ -391,7 +384,7 @@ namespace MWDialogue
const MWWorld::Store<ESM::Dialogue> &dialogs =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
Filter filter (mActor);
Filter filter (mActor, mChoice);
MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin();
for (; it != dialogs.end(); ++it)
@ -478,7 +471,7 @@ namespace MWDialogue
ESM::Dialogue ndialogue = mDialogueMap[keyword];
if(ndialogue.mType == ESM::Dialogue::Topic)
{
Filter filter (mActor);
Filter filter (mActor, mChoice);
for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin();
iter!=ndialogue.mInfo.end(); ++iter)
@ -525,7 +518,7 @@ namespace MWDialogue
ESM::Dialogue ndialogue = mDialogueMap[mLastTopic];
if(ndialogue.mType == ESM::Dialogue::Topic)
{
Filter filter (mActor);
Filter filter (mActor, mChoice);
for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin();
iter!=ndialogue.mInfo.end(); ++iter)

View file

@ -220,6 +220,10 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
return MWBase::Environment::get().getMechanicsManager()->countDeaths (select.getName());
case SelectWrapper::Function_Choice:
return mChoice;
default:
throw std::runtime_error ("unknown integer select function");
@ -264,7 +268,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
}
}
MWDialogue::Filter::Filter (const MWWorld::Ptr& actor) : mActor (actor) {}
MWDialogue::Filter::Filter (const MWWorld::Ptr& actor, int choice) : mActor (actor), mChoice (choice) {}
bool MWDialogue::Filter::operator() (const ESM::DialInfo& info) const
{

View file

@ -15,6 +15,7 @@ namespace MWDialogue
class Filter
{
MWWorld::Ptr mActor;
int mChoice;
bool testActor (const ESM::DialInfo& info) const;
///< Is this the right actor for this \a info?
@ -35,7 +36,7 @@ namespace MWDialogue
public:
Filter (const MWWorld::Ptr& actor);
Filter (const MWWorld::Ptr& actor, int choice);
bool operator() (const ESM::DialInfo& info) const;
///< \return does the dialogue match?

View file

@ -59,7 +59,13 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction()
std::istringstream (mSelect.mSelectRule.substr(2,2)) >> index;
return static_cast<Function> (index);
switch (index)
{
case 46: return Function_SameFaction;
case 50: return Function_Choice;
}
return Function_None;
}
MWDialogue::SelectWrapper::SelectWrapper (const ESM::DialInfo::SelectStruct& select) : mSelect (select) {}
@ -92,6 +98,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
static const Function integerFunctions[] =
{
Function_Journal, Function_Item, Function_Dead,
Function_Choice,
Function_None // end marker
};

View file

@ -13,7 +13,7 @@ namespace MWDialogue
enum Function
{
Function_None = 0,
Function_None,
Function_Journal,
Function_Item,
Function_Dead,
@ -24,7 +24,8 @@ namespace MWDialogue
Function_Cell,
Function_Local,
Function_Global,
Function_SameFaction
Function_SameFaction,
Function_Choice
};
enum Type