mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 13:49:40 +00:00
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
|
convertcrec.cpp
|
||||||
convertcntc.cpp
|
convertcntc.cpp
|
||||||
convertscri.cpp
|
convertscri.cpp
|
||||||
|
convertscpt.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(openmw-essimporter
|
add_executable(openmw-essimporter
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <components/esm/custommarkerstate.hpp>
|
#include <components/esm/custommarkerstate.hpp>
|
||||||
#include <components/esm/loadcrea.hpp>
|
#include <components/esm/loadcrea.hpp>
|
||||||
#include <components/esm/weatherstate.hpp>
|
#include <components/esm/weatherstate.hpp>
|
||||||
|
#include <components/esm/globalscript.hpp>
|
||||||
|
|
||||||
#include "importcrec.hpp"
|
#include "importcrec.hpp"
|
||||||
#include "importcntc.hpp"
|
#include "importcntc.hpp"
|
||||||
|
@ -30,6 +31,7 @@
|
||||||
|
|
||||||
#include "convertacdt.hpp"
|
#include "convertacdt.hpp"
|
||||||
#include "convertnpcc.hpp"
|
#include "convertnpcc.hpp"
|
||||||
|
#include "convertscpt.hpp"
|
||||||
|
|
||||||
namespace ESSImport
|
namespace ESSImport
|
||||||
{
|
{
|
||||||
|
@ -529,7 +531,21 @@ public:
|
||||||
{
|
{
|
||||||
SCPT script;
|
SCPT script;
|
||||||
script.load(esm);
|
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);
|
mSCRI.load(esm);
|
||||||
|
|
||||||
mRNAM = -1;
|
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
|
// values of local variables
|
||||||
SCRI mSCRI;
|
SCRI mSCRI;
|
||||||
|
|
||||||
|
bool mHasRNAM;
|
||||||
int mRNAM; // unknown, seems to be -1 for some scripts, some huge integer for others
|
int mRNAM; // unknown, seems to be -1 for some scripts, some huge integer for others
|
||||||
|
|
||||||
void load(ESM::ESMReader& esm);
|
void load(ESM::ESMReader& esm);
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ESM
|
||||||
|
|
||||||
struct GlobalScript
|
struct GlobalScript
|
||||||
{
|
{
|
||||||
std::string mId;
|
std::string mId; /// \note must be lowercase
|
||||||
Locals mLocals;
|
Locals mLocals;
|
||||||
int mRunning;
|
int mRunning;
|
||||||
std::string mTargetId; // for targeted scripts
|
std::string mTargetId; // for targeted scripts
|
||||||
|
|
Loading…
Reference in a new issue