|
|
|
@ -44,7 +44,7 @@ namespace MWScript
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Locals& InterpreterContext::getMemberLocals(std::reference_wrapper<const ESM::RefId>& id, bool global) const
|
|
|
|
|
const Locals& InterpreterContext::getMemberLocals(bool global, ESM::RefId& id) const
|
|
|
|
|
{
|
|
|
|
|
if (global)
|
|
|
|
|
{
|
|
|
|
@ -54,7 +54,7 @@ namespace MWScript
|
|
|
|
|
{
|
|
|
|
|
const MWWorld::Ptr ptr = getReferenceImp(id, false);
|
|
|
|
|
|
|
|
|
|
id = std::ref(ptr.getClass().getScript(ptr));
|
|
|
|
|
id = ptr.getClass().getScript(ptr);
|
|
|
|
|
|
|
|
|
|
ptr.getRefData().setLocals(*MWBase::Environment::get().getESMStore()->get<ESM::Script>().find(id));
|
|
|
|
|
|
|
|
|
@ -62,7 +62,7 @@ namespace MWScript
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Locals& InterpreterContext::getMemberLocals(std::reference_wrapper<const ESM::RefId>& id, bool global)
|
|
|
|
|
Locals& InterpreterContext::getMemberLocals(bool global, ESM::RefId& id)
|
|
|
|
|
{
|
|
|
|
|
if (global)
|
|
|
|
|
{
|
|
|
|
@ -72,7 +72,7 @@ namespace MWScript
|
|
|
|
|
{
|
|
|
|
|
const MWWorld::Ptr ptr = getReferenceImp(id, false);
|
|
|
|
|
|
|
|
|
|
id = std::ref(ptr.getClass().getScript(ptr));
|
|
|
|
|
id = ptr.getClass().getScript(ptr);
|
|
|
|
|
|
|
|
|
|
ptr.getRefData().setLocals(*MWBase::Environment::get().getESMStore()->get<ESM::Script>().find(id));
|
|
|
|
|
|
|
|
|
@ -133,13 +133,13 @@ namespace MWScript
|
|
|
|
|
mGlobalScriptDesc = globalScriptDesc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ESM::RefId& InterpreterContext::getTarget() const
|
|
|
|
|
ESM::RefId InterpreterContext::getTarget() const
|
|
|
|
|
{
|
|
|
|
|
if (!mReference.isEmpty())
|
|
|
|
|
return mReference.mRef->mRef.getRefId();
|
|
|
|
|
else if (mGlobalScriptDesc)
|
|
|
|
|
return mGlobalScriptDesc->getId();
|
|
|
|
|
return ESM::RefId::sEmpty;
|
|
|
|
|
return ESM::RefId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int InterpreterContext::getLocalShort(int index) const
|
|
|
|
@ -435,52 +435,46 @@ namespace MWScript
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int InterpreterContext::getMemberShort(const ESM::RefId& id, std::string_view name, bool global) const
|
|
|
|
|
int InterpreterContext::getMemberShort(ESM::RefId id, std::string_view name, bool global) const
|
|
|
|
|
{
|
|
|
|
|
auto idRefWrapper = std::ref(id);
|
|
|
|
|
const Locals& locals = getMemberLocals(idRefWrapper, global);
|
|
|
|
|
const Locals& locals = getMemberLocals(global, id);
|
|
|
|
|
|
|
|
|
|
return locals.mShorts[findLocalVariableIndex(idRefWrapper, name, 's')];
|
|
|
|
|
return locals.mShorts[findLocalVariableIndex(id, name, 's')];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int InterpreterContext::getMemberLong(const ESM::RefId& id, std::string_view name, bool global) const
|
|
|
|
|
int InterpreterContext::getMemberLong(ESM::RefId id, std::string_view name, bool global) const
|
|
|
|
|
{
|
|
|
|
|
auto idRefWrapper = std::ref(id);
|
|
|
|
|
const Locals& locals = getMemberLocals(idRefWrapper, global);
|
|
|
|
|
const Locals& locals = getMemberLocals(global, id);
|
|
|
|
|
|
|
|
|
|
return locals.mLongs[findLocalVariableIndex(idRefWrapper, name, 'l')];
|
|
|
|
|
return locals.mLongs[findLocalVariableIndex(id, name, 'l')];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float InterpreterContext::getMemberFloat(const ESM::RefId& id, std::string_view name, bool global) const
|
|
|
|
|
float InterpreterContext::getMemberFloat(ESM::RefId id, std::string_view name, bool global) const
|
|
|
|
|
{
|
|
|
|
|
auto idRefWrapper = std::ref(id);
|
|
|
|
|
const Locals& locals = getMemberLocals(idRefWrapper, global);
|
|
|
|
|
const Locals& locals = getMemberLocals(global, id);
|
|
|
|
|
|
|
|
|
|
return locals.mFloats[findLocalVariableIndex(idRefWrapper, name, 'f')];
|
|
|
|
|
return locals.mFloats[findLocalVariableIndex(id, name, 'f')];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InterpreterContext::setMemberShort(const ESM::RefId& id, std::string_view name, int value, bool global)
|
|
|
|
|
void InterpreterContext::setMemberShort(ESM::RefId id, std::string_view name, int value, bool global)
|
|
|
|
|
{
|
|
|
|
|
auto idRefWrapper = std::ref(id);
|
|
|
|
|
Locals& locals = getMemberLocals(idRefWrapper, global);
|
|
|
|
|
Locals& locals = getMemberLocals(global, id);
|
|
|
|
|
|
|
|
|
|
locals.mShorts[findLocalVariableIndex(idRefWrapper, name, 's')] = value;
|
|
|
|
|
locals.mShorts[findLocalVariableIndex(id, name, 's')] = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InterpreterContext::setMemberLong(const ESM::RefId& id, std::string_view name, int value, bool global)
|
|
|
|
|
void InterpreterContext::setMemberLong(ESM::RefId id, std::string_view name, int value, bool global)
|
|
|
|
|
{
|
|
|
|
|
auto idRefWrapper = std::ref(id);
|
|
|
|
|
Locals& locals = getMemberLocals(idRefWrapper, global);
|
|
|
|
|
Locals& locals = getMemberLocals(global, id);
|
|
|
|
|
|
|
|
|
|
locals.mLongs[findLocalVariableIndex(idRefWrapper, name, 'l')] = value;
|
|
|
|
|
locals.mLongs[findLocalVariableIndex(id, name, 'l')] = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InterpreterContext::setMemberFloat(const ESM::RefId& id, std::string_view name, float value, bool global)
|
|
|
|
|
void InterpreterContext::setMemberFloat(ESM::RefId id, std::string_view name, float value, bool global)
|
|
|
|
|
{
|
|
|
|
|
auto idRefWrapper = std::ref(id);
|
|
|
|
|
Locals& locals = getMemberLocals(idRefWrapper, global);
|
|
|
|
|
Locals& locals = getMemberLocals(global, id);
|
|
|
|
|
|
|
|
|
|
locals.mFloats[findLocalVariableIndex(idRefWrapper, name, 'f')] = value;
|
|
|
|
|
locals.mFloats[findLocalVariableIndex(id, name, 'f')] = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr InterpreterContext::getReference(bool required) const
|
|
|
|
|