forked from teamnwah/openmw-tes3coop
ESSImport: convert running global scripts
This commit is contained in:
parent
3d80bb3207
commit
d34086ac8f
7 changed files with 58 additions and 2 deletions
|
@ -24,6 +24,7 @@ set(ESSIMPORTER_FILES
|
|||
convertcrec.cpp
|
||||
convertcntc.cpp
|
||||
convertscri.cpp
|
||||
convertscpt.cpp
|
||||
)
|
||||
|
||||
add_executable(openmw-essimporter
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <components/esm/custommarkerstate.hpp>
|
||||
#include <components/esm/loadcrea.hpp>
|
||||
#include <components/esm/weatherstate.hpp>
|
||||
#include <components/esm/globalscript.hpp>
|
||||
|
||||
#include "importcrec.hpp"
|
||||
#include "importcntc.hpp"
|
||||
|
@ -30,6 +31,7 @@
|
|||
|
||||
#include "convertacdt.hpp"
|
||||
#include "convertnpcc.hpp"
|
||||
#include "convertscpt.hpp"
|
||||
|
||||
namespace ESSImport
|
||||
{
|
||||
|
@ -529,7 +531,21 @@ public:
|
|||
{
|
||||
SCPT script;
|
||||
script.load(esm);
|
||||
ESM::GlobalScript out;
|
||||
convertSCPT(script, out);
|
||||
mScripts.push_back(out);
|
||||
}
|
||||
virtual void write(ESM::ESMWriter &esm)
|
||||
{
|
||||
for (std::vector<ESM::GlobalScript>::const_iterator it = mScripts.begin(); it != mScripts.end(); ++it)
|
||||
{
|
||||
esm.startRecord(ESM::REC_GSCR);
|
||||
it->save(esm);
|
||||
esm.endRecord(ESM::REC_GSCR);
|
||||
}
|
||||
}
|
||||
private:
|
||||
std::vector<ESM::GlobalScript> mScripts;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
17
apps/essimporter/convertscpt.cpp
Normal file
17
apps/essimporter/convertscpt.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include "convertscpt.hpp"
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
#include "convertscri.hpp"
|
||||
|
||||
namespace ESSImport
|
||||
{
|
||||
|
||||
void convertSCPT(const SCPT &scpt, ESM::GlobalScript &out)
|
||||
{
|
||||
out.mId = Misc::StringUtils::lowerCase(scpt.mSCHD.mName.toString());
|
||||
out.mRunning = scpt.mHasRNAM;
|
||||
convertSCRI(scpt.mSCRI, out.mLocals);
|
||||
}
|
||||
|
||||
}
|
15
apps/essimporter/convertscpt.hpp
Normal file
15
apps/essimporter/convertscpt.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef OPENMW_ESSIMPORT_CONVERTSCPT_H
|
||||
#define OPENMW_ESSIMPORT_CONVERTSCPT_H
|
||||
|
||||
#include <components/esm/globalscript.hpp>
|
||||
|
||||
#include "importscpt.hpp"
|
||||
|
||||
namespace ESSImport
|
||||
{
|
||||
|
||||
void convertSCPT(const SCPT& scpt, ESM::GlobalScript& out);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -14,7 +14,13 @@ namespace ESSImport
|
|||
mSCRI.load(esm);
|
||||
|
||||
mRNAM = -1;
|
||||
esm.getHNOT(mRNAM, "RNAM");
|
||||
if (esm.isNextSub("RNAM"))
|
||||
{
|
||||
mHasRNAM = true;
|
||||
esm.getHT(mRNAM);
|
||||
}
|
||||
else
|
||||
mHasRNAM = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace ESSImport
|
|||
// values of local variables
|
||||
SCRI mSCRI;
|
||||
|
||||
bool mHasRNAM;
|
||||
int mRNAM; // unknown, seems to be -1 for some scripts, some huge integer for others
|
||||
|
||||
void load(ESM::ESMReader& esm);
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace ESM
|
|||
|
||||
struct GlobalScript
|
||||
{
|
||||
std::string mId;
|
||||
std::string mId; /// \note must be lowercase
|
||||
Locals mLocals;
|
||||
int mRunning;
|
||||
std::string mTargetId; // for targeted scripts
|
||||
|
|
Loading…
Reference in a new issue