mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 12:53:51 +00:00
Fix inverted dialogue functions (NotClass etc.)
The comparison present is useless for these functions.
This commit is contained in:
parent
3bd545ed8e
commit
ad3478c8f2
3 changed files with 25 additions and 16 deletions
|
@ -136,8 +136,12 @@ bool MWDialogue::Filter::testDisposition (const ESM::DialInfo& info, bool invert
|
|||
|
||||
bool MWDialogue::Filter::testSelectStruct (const SelectWrapper& select) const
|
||||
{
|
||||
if (select.isNpcOnly() && mActor.getTypeName()!=typeid (ESM::NPC).name())
|
||||
return select.isInverted();
|
||||
if (select.isNpcOnly() && (mActor.getTypeName() != typeid (ESM::NPC).name()))
|
||||
// If the actor is a creature, we do not test the conditions applicable
|
||||
// only to NPCs. Such conditions can never be satisfied, apart
|
||||
// inverted ones (NotClass, NotRace, NotFaction return true
|
||||
// because creatures are not of any race, class or faction).
|
||||
return select.getType() == SelectWrapper::Type_Inverted;
|
||||
|
||||
switch (select.getType())
|
||||
{
|
||||
|
@ -145,6 +149,9 @@ bool MWDialogue::Filter::testSelectStruct (const SelectWrapper& select) const
|
|||
case SelectWrapper::Type_Integer: return select.selectCompare (getSelectStructInteger (select));
|
||||
case SelectWrapper::Type_Numeric: return testSelectStructNumeric (select);
|
||||
case SelectWrapper::Type_Boolean: return select.selectCompare (getSelectStructBoolean (select));
|
||||
|
||||
// We must not do the comparison for inverted functions (eg. Function_NotClass)
|
||||
case SelectWrapper::Type_Inverted: return getSelectStructBoolean (select);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -219,7 +219,6 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
|
|||
static const Function booleanFunctions[] =
|
||||
{
|
||||
Function_False,
|
||||
Function_NotId, Function_NotFaction, Function_NotClass, Function_NotRace, Function_NotCell,
|
||||
Function_SameGender, Function_SameRace, Function_SameFaction,
|
||||
Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus,
|
||||
Function_PcExpelled,
|
||||
|
@ -231,6 +230,13 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
|
|||
Function_None // end marker
|
||||
};
|
||||
|
||||
static const Function invertedBooleanFunctions[] =
|
||||
{
|
||||
Function_NotId, Function_NotFaction, Function_NotClass,
|
||||
Function_NotRace, Function_NotCell,
|
||||
Function_None // end marker
|
||||
};
|
||||
|
||||
Function function = getFunction();
|
||||
|
||||
for (int i=0; integerFunctions[i]!=Function_None; ++i)
|
||||
|
@ -245,16 +251,13 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
|
|||
if (booleanFunctions[i]==function)
|
||||
return Type_Boolean;
|
||||
|
||||
for (int i=0; invertedBooleanFunctions[i]!=Function_None; ++i)
|
||||
if (invertedBooleanFunctions[i]==function)
|
||||
return Type_Inverted;
|
||||
|
||||
return Type_None;
|
||||
}
|
||||
|
||||
bool MWDialogue::SelectWrapper::isInverted() const
|
||||
{
|
||||
char type = mSelect.mSelectRule[1];
|
||||
|
||||
return type=='7' || type=='8' || type=='9' || type=='A' || type=='B' || type=='C';
|
||||
}
|
||||
|
||||
bool MWDialogue::SelectWrapper::isNpcOnly() const
|
||||
{
|
||||
static const Function functions[] =
|
||||
|
@ -283,17 +286,17 @@ bool MWDialogue::SelectWrapper::isNpcOnly() const
|
|||
|
||||
bool MWDialogue::SelectWrapper::selectCompare (int value) const
|
||||
{
|
||||
return selectCompareImp (mSelect, value)!=isInverted(); // logic XOR
|
||||
return selectCompareImp (mSelect, value);
|
||||
}
|
||||
|
||||
bool MWDialogue::SelectWrapper::selectCompare (float value) const
|
||||
{
|
||||
return selectCompareImp (mSelect, value)!=isInverted(); // logic XOR
|
||||
return selectCompareImp (mSelect, value);
|
||||
}
|
||||
|
||||
bool MWDialogue::SelectWrapper::selectCompare (bool value) const
|
||||
{
|
||||
return selectCompareImp (mSelect, static_cast<int> (value))!=isInverted(); // logic XOR
|
||||
return selectCompareImp (mSelect, static_cast<int> (value));
|
||||
}
|
||||
|
||||
std::string MWDialogue::SelectWrapper::getName() const
|
||||
|
|
|
@ -50,7 +50,8 @@ namespace MWDialogue
|
|||
Type_None,
|
||||
Type_Integer,
|
||||
Type_Numeric,
|
||||
Type_Boolean
|
||||
Type_Boolean,
|
||||
Type_Inverted
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -67,8 +68,6 @@ namespace MWDialogue
|
|||
|
||||
Type getType() const;
|
||||
|
||||
bool isInverted() const;
|
||||
|
||||
bool isNpcOnly() const;
|
||||
///< \attention Do not call any of the select functions for this select struct!
|
||||
|
||||
|
|
Loading…
Reference in a new issue