mirror of
https://github.com/OpenMW/openmw.git
synced 2025-11-30 08:04:30 +00:00
Convert global script targets
This commit is contained in:
parent
8deb050ea2
commit
35a9a47eac
5 changed files with 14 additions and 14 deletions
|
|
@ -11,7 +11,7 @@ namespace ESSImport
|
|||
{
|
||||
out.mId = ESM::RefId::stringRefId(scpt.mSCHD.mName.toString());
|
||||
out.mRunning = scpt.mRunning;
|
||||
out.mTargetRef = ESM::RefNum{}; // TODO: convert target reference of global script
|
||||
out.mTargetRef = scpt.mRefNum;
|
||||
convertSCRI(scpt.mSCRI, out.mLocals);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@ namespace ESSImport
|
|||
|
||||
mSCRI.load(esm);
|
||||
|
||||
mRefNum = -1;
|
||||
if (esm.isNextSub("RNAM"))
|
||||
{
|
||||
mRunning = true;
|
||||
esm.getHT(mRefNum);
|
||||
ESM::FormId32 refNum;
|
||||
esm.getHT(refNum);
|
||||
mRefNum = ESM::RefNum::fromUint32(refNum);
|
||||
mRefNum.mContentFile--;
|
||||
}
|
||||
else
|
||||
mRunning = false;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <components/esm/esmcommon.hpp>
|
||||
#include <components/esm3/loadscpt.hpp>
|
||||
#include <components/esm3/refnum.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
|
@ -35,7 +36,7 @@ namespace ESSImport
|
|||
SCRI mSCRI;
|
||||
|
||||
bool mRunning;
|
||||
int32_t mRefNum; // Targeted reference, -1: no reference
|
||||
ESM::RefNum mRefNum; // Targeted reference
|
||||
|
||||
void load(ESM::ESMReader& esm);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -60,10 +60,10 @@ namespace
|
|||
|
||||
MWWorld::Ptr operator()(const std::pair<ESM::RefNum, ESM::RefId>& pair) const
|
||||
{
|
||||
if (pair.second.empty())
|
||||
return MWWorld::Ptr();
|
||||
else if (pair.first.hasContentFile())
|
||||
if (pair.first.hasContentFile())
|
||||
return MWBase::Environment::get().getWorldModel()->getPtr(pair.first);
|
||||
else if (pair.second.empty())
|
||||
return MWWorld::Ptr();
|
||||
return MWBase::Environment::get().getWorld()->searchPtr(pair.second, false);
|
||||
}
|
||||
};
|
||||
|
|
@ -256,7 +256,7 @@ namespace MWScript
|
|||
try
|
||||
{
|
||||
auto desc = std::make_shared<GlobalScriptDesc>();
|
||||
if (!script.mTargetId.empty())
|
||||
if (!script.mTargetId.empty() || script.mTargetRef.isSet())
|
||||
{
|
||||
desc->mTarget = std::make_pair(script.mTargetRef, script.mTargetId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,12 +38,9 @@ namespace ESM
|
|||
if (mRunning)
|
||||
esm.writeHNT("RUN_", int32_t{ 1 });
|
||||
|
||||
if (!mTargetId.empty())
|
||||
{
|
||||
esm.writeHNORefId("TARG", mTargetId);
|
||||
if (mTargetRef.isSet())
|
||||
esm.writeFormId(mTargetRef, true, "FRMR");
|
||||
}
|
||||
esm.writeHNORefId("TARG", mTargetId);
|
||||
if (mTargetRef.isSet())
|
||||
esm.writeFormId(mTargetRef, true, "FRMR");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue