1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-05 17:41:32 +00:00

Replace switch statements

This commit is contained in:
Evil Eye 2022-11-04 12:20:37 +01:00
parent 29a46b0fc0
commit f61083d02c

View file

@ -32,16 +32,13 @@ namespace
return !Misc::StringUtils::ciEqual(actor.getCellRef().getRefId(), select.getName()); return !Misc::StringUtils::ciEqual(actor.getCellRef().getRefId(), select.getName());
if (actor.getClass().isNpc()) if (actor.getClass().isNpc())
{ {
switch (select.getFunction()) if (select.getFunction() == MWDialogue::SelectWrapper::Function_NotFaction)
{
case MWDialogue::SelectWrapper::Function_NotFaction:
return !Misc::StringUtils::ciEqual(actor.getClass().getPrimaryFaction(actor), select.getName()); return !Misc::StringUtils::ciEqual(actor.getClass().getPrimaryFaction(actor), select.getName());
case MWDialogue::SelectWrapper::Function_NotClass: else if (select.getFunction() == MWDialogue::SelectWrapper::Function_NotClass)
return !Misc::StringUtils::ciEqual(actor.get<ESM::NPC>()->mBase->mClass, select.getName()); return !Misc::StringUtils::ciEqual(actor.get<ESM::NPC>()->mBase->mClass, select.getName());
case MWDialogue::SelectWrapper::Function_NotRace: else if (select.getFunction() == MWDialogue::SelectWrapper::Function_NotRace)
return !Misc::StringUtils::ciEqual(actor.get<ESM::NPC>()->mBase->mRace, select.getName()); return !Misc::StringUtils::ciEqual(actor.get<ESM::NPC>()->mBase->mRace, select.getName());
} }
}
return true; return true;
} }
@ -50,22 +47,17 @@ namespace
for (const ESM::DialInfo::SelectStruct& select : info.mSelects) for (const ESM::DialInfo::SelectStruct& select : info.mSelects)
{ {
MWDialogue::SelectWrapper wrapper = select; MWDialogue::SelectWrapper wrapper = select;
if (wrapper.getType() == MWDialogue::SelectWrapper::Type_Boolean)
switch (wrapper.getType())
{
case MWDialogue::SelectWrapper::Type_Boolean:
{ {
if (!wrapper.selectCompare(matchesStaticFilters(wrapper, actor))) if (!wrapper.selectCompare(matchesStaticFilters(wrapper, actor)))
return false; return false;
break;
} }
case MWDialogue::SelectWrapper::Type_Inverted: else if (wrapper.getType() == MWDialogue::SelectWrapper::Type_Inverted)
{ {
if (!matchesStaticFilters(wrapper, actor)) if (!matchesStaticFilters(wrapper, actor))
return false; return false;
break;
} }
case MWDialogue::SelectWrapper::Type_Numeric: else if (wrapper.getType() == MWDialogue::SelectWrapper::Type_Numeric)
{ {
if (wrapper.getFunction() == MWDialogue::SelectWrapper::Function_Local) if (wrapper.getFunction() == MWDialogue::SelectWrapper::Function_Local)
{ {
@ -78,8 +70,6 @@ namespace
if (type == ' ') if (type == ' ')
return false; // script does not have a variable of this name. return false; // script does not have a variable of this name.
} }
break;
}
} }
} }
return true; return true;