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:
parent
29a46b0fc0
commit
f61083d02c
1 changed files with 25 additions and 35 deletions
|
@ -32,15 +32,12 @@ 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)
|
||||||
{
|
return !Misc::StringUtils::ciEqual(actor.getClass().getPrimaryFaction(actor), select.getName());
|
||||||
case MWDialogue::SelectWrapper::Function_NotFaction:
|
else if (select.getFunction() == MWDialogue::SelectWrapper::Function_NotClass)
|
||||||
return !Misc::StringUtils::ciEqual(actor.getClass().getPrimaryFaction(actor), select.getName());
|
return !Misc::StringUtils::ciEqual(actor.get<ESM::NPC>()->mBase->mClass, select.getName());
|
||||||
case MWDialogue::SelectWrapper::Function_NotClass:
|
else if (select.getFunction() == MWDialogue::SelectWrapper::Function_NotRace)
|
||||||
return !Misc::StringUtils::ciEqual(actor.get<ESM::NPC>()->mBase->mClass, select.getName());
|
return !Misc::StringUtils::ciEqual(actor.get<ESM::NPC>()->mBase->mRace, select.getName());
|
||||||
case MWDialogue::SelectWrapper::Function_NotRace:
|
|
||||||
return !Misc::StringUtils::ciEqual(actor.get<ESM::NPC>()->mBase->mRace, select.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -50,35 +47,28 @@ 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)))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (wrapper.getType() == MWDialogue::SelectWrapper::Type_Inverted)
|
||||||
|
{
|
||||||
|
if (!matchesStaticFilters(wrapper, actor))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (wrapper.getType() == MWDialogue::SelectWrapper::Type_Numeric)
|
||||||
|
{
|
||||||
|
if (wrapper.getFunction() == MWDialogue::SelectWrapper::Function_Local)
|
||||||
{
|
{
|
||||||
if (!wrapper.selectCompare(matchesStaticFilters(wrapper, actor)))
|
std::string_view scriptName = actor.getClass().getScript(actor);
|
||||||
|
if (scriptName.empty())
|
||||||
return false;
|
return false;
|
||||||
break;
|
const Compiler::Locals& localDefs
|
||||||
}
|
= MWBase::Environment::get().getScriptManager()->getLocals(scriptName);
|
||||||
case MWDialogue::SelectWrapper::Type_Inverted:
|
char type = localDefs.getType(wrapper.getName());
|
||||||
{
|
if (type == ' ')
|
||||||
if (!matchesStaticFilters(wrapper, actor))
|
return false; // script does not have a variable of this name.
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MWDialogue::SelectWrapper::Type_Numeric:
|
|
||||||
{
|
|
||||||
if (wrapper.getFunction() == MWDialogue::SelectWrapper::Function_Local)
|
|
||||||
{
|
|
||||||
std::string_view scriptName = actor.getClass().getScript(actor);
|
|
||||||
if (scriptName.empty())
|
|
||||||
return false;
|
|
||||||
const Compiler::Locals& localDefs
|
|
||||||
= MWBase::Environment::get().getScriptManager()->getLocals(scriptName);
|
|
||||||
char type = localDefs.getType(wrapper.getName());
|
|
||||||
if (type == ' ')
|
|
||||||
return false; // script does not have a variable of this name.
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue