forked from mirror/openmw-tes3mp
rewrote dialgoue filter access to local variables
This commit is contained in:
parent
9f69db0d69
commit
f6b502b195
1 changed files with 20 additions and 32 deletions
|
@ -1,11 +1,14 @@
|
||||||
|
|
||||||
#include "filter.hpp"
|
#include "filter.hpp"
|
||||||
|
|
||||||
|
#include <components/compiler/locals.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/journal.hpp"
|
#include "../mwbase/journal.hpp"
|
||||||
#include "../mwbase/mechanicsmanager.hpp"
|
#include "../mwbase/mechanicsmanager.hpp"
|
||||||
#include "../mwbase/dialoguemanager.hpp"
|
#include "../mwbase/dialoguemanager.hpp"
|
||||||
|
#include "../mwbase/scriptmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
|
@ -187,33 +190,28 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c
|
||||||
if (scriptName.empty())
|
if (scriptName.empty())
|
||||||
return false; // no script
|
return false; // no script
|
||||||
|
|
||||||
const ESM::Script *script =
|
std::string name = Misc::StringUtils::lowerCase (select.getName());
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptName);
|
|
||||||
|
|
||||||
std::string name = select.getName();
|
const Compiler::Locals& localDefs =
|
||||||
|
MWBase::Environment::get().getScriptManager()->getLocals (scriptName);
|
||||||
|
|
||||||
int i = 0;
|
char type = localDefs.getType (name);
|
||||||
|
|
||||||
for (; i<static_cast<int> (script->mVarNames.size()); ++i)
|
if (type==' ')
|
||||||
if (Misc::StringUtils::ciEqual(script->mVarNames[i], name))
|
return false; // script does not have a variable of this name.
|
||||||
break;
|
|
||||||
|
|
||||||
if (i>=static_cast<int> (script->mVarNames.size()))
|
int index = localDefs.getIndex (name);
|
||||||
return false; // script does not have a variable of this name
|
|
||||||
|
|
||||||
const MWScript::Locals& locals = mActor.getRefData().getLocals();
|
const MWScript::Locals& locals = mActor.getRefData().getLocals();
|
||||||
|
|
||||||
if (i<script->mData.mNumShorts)
|
switch (type)
|
||||||
return select.selectCompare (static_cast<int> (locals.mShorts[i]));
|
{
|
||||||
|
case 's': return select.selectCompare (static_cast<int> (locals.mShorts[index]));
|
||||||
|
case 'l': return select.selectCompare (locals.mLongs[index]);
|
||||||
|
case 'f': return select.selectCompare (locals.mFloats[index]);
|
||||||
|
}
|
||||||
|
|
||||||
i -= script->mData.mNumShorts;
|
throw std::logic_error ("unknown local variable type in dialogue filter");
|
||||||
|
|
||||||
if (i<script->mData.mNumLongs)
|
|
||||||
return select.selectCompare (locals.mLongs[i]);
|
|
||||||
|
|
||||||
i -= script->mData.mNumLongs;
|
|
||||||
|
|
||||||
return select.selectCompare (locals.mFloats.at (i));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case SelectWrapper::Function_PcHealthPercent:
|
case SelectWrapper::Function_PcHealthPercent:
|
||||||
|
@ -453,20 +451,10 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
||||||
// This actor has no attached script, so there is no local variable
|
// This actor has no attached script, so there is no local variable
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const ESM::Script *script =
|
const Compiler::Locals& localDefs =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptName);
|
MWBase::Environment::get().getScriptManager()->getLocals (scriptName);
|
||||||
|
|
||||||
std::string name = select.getName();
|
return localDefs.getIndex (Misc::StringUtils::lowerCase (select.getName()))==-1;
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for (; i < static_cast<int> (script->mVarNames.size()); ++i)
|
|
||||||
if (Misc::StringUtils::ciEqual(script->mVarNames[i], name))
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (i >= static_cast<int> (script->mVarNames.size()))
|
|
||||||
return true; // script does not have a variable of this name
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case SelectWrapper::Function_SameGender:
|
case SelectWrapper::Function_SameGender:
|
||||||
|
|
Loading…
Reference in a new issue