mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
ESSImport: read script variables (not converted yet)
This commit is contained in:
parent
98402e579d
commit
e203127952
13 changed files with 164 additions and 57 deletions
|
@ -14,6 +14,8 @@ set(ESSIMPORTER_FILES
|
|||
importdial.cpp
|
||||
importques.cpp
|
||||
importjour.cpp
|
||||
importscri.cpp
|
||||
importscpt.cpp
|
||||
importercontext.cpp
|
||||
converter.cpp
|
||||
convertacdt.cpp
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "importdial.hpp"
|
||||
#include "importques.hpp"
|
||||
#include "importjour.hpp"
|
||||
#include "importscpt.hpp"
|
||||
|
||||
#include "convertacdt.hpp"
|
||||
#include "convertnpcc.hpp"
|
||||
|
@ -437,6 +438,17 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/// Running global script
|
||||
class ConvertSCPT : public Converter
|
||||
{
|
||||
public:
|
||||
virtual void read(ESM::ESMReader &esm)
|
||||
{
|
||||
SCPT script;
|
||||
script.load(esm);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -81,18 +81,7 @@ namespace ESSImport
|
|||
if (esm.isNextSub("CRED")) // creature only
|
||||
esm.getHExact(mCombatStats, 3*2*sizeof(int));
|
||||
|
||||
mScript = esm.getHNOString("SCRI");
|
||||
|
||||
// script variables?
|
||||
if (!mScript.empty())
|
||||
{
|
||||
if (esm.isNextSub("SLCS"))
|
||||
esm.skipHSub();
|
||||
if (esm.isNextSub("SLSD")) // Short Data?
|
||||
esm.skipHSub();
|
||||
if (esm.isNextSub("SLFD")) // Float Data?
|
||||
esm.skipHSub();
|
||||
}
|
||||
mSCRI.load(esm);
|
||||
|
||||
if (esm.isNextSub("ND3D"))
|
||||
esm.skipHSub();
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <components/esm/cellref.hpp>
|
||||
|
||||
#include "importscri.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct ESMReader;
|
||||
|
@ -50,7 +52,7 @@ namespace ESSImport
|
|||
// to change them ingame
|
||||
int mCombatStats[3][2];
|
||||
|
||||
std::string mScript;
|
||||
SCRI mSCRI;
|
||||
|
||||
void load(ESM::ESMReader& esm);
|
||||
};
|
||||
|
|
|
@ -234,6 +234,7 @@ namespace ESSImport
|
|||
converters[ESM::REC_DIAL] = boost::shared_ptr<Converter>(new ConvertDIAL());
|
||||
converters[ESM::REC_QUES] = boost::shared_ptr<Converter>(new ConvertQUES());
|
||||
converters[recJOUR ] = boost::shared_ptr<Converter>(new ConvertJOUR());
|
||||
converters[ESM::REC_SCPT] = boost::shared_ptr<Converter>(new ConvertSCPT());
|
||||
|
||||
std::set<unsigned int> unknownRecords;
|
||||
|
||||
|
|
|
@ -29,18 +29,7 @@ namespace ESSImport
|
|||
if (esm.isNextSub("XIDX")) // index in the stack?
|
||||
esm.skipHSub();
|
||||
|
||||
std::string script = esm.getHNOString("SCRI");
|
||||
// script variables?
|
||||
// unsure if before or after ESM::CellRef
|
||||
if (!script.empty())
|
||||
{
|
||||
if (esm.isNextSub("SLCS"))
|
||||
esm.skipHSub();
|
||||
if (esm.isNextSub("SLSD")) // Short Data?
|
||||
esm.skipHSub();
|
||||
if (esm.isNextSub("SLFD")) // Float Data?
|
||||
esm.skipHSub();
|
||||
}
|
||||
item.mSCRI.load(esm);
|
||||
|
||||
// for XSOL and XCHG seen so far, but probably others too
|
||||
item.ESM::CellRef::loadData(esm);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <string>
|
||||
|
||||
#include <components/esm/cellref.hpp>
|
||||
#include "importscri.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
@ -21,6 +22,7 @@ namespace ESSImport
|
|||
std::string mId;
|
||||
int mCount;
|
||||
int mRelativeEquipmentSlot;
|
||||
SCRI mSCRI;
|
||||
};
|
||||
std::vector<InventoryItem> mItems;
|
||||
|
||||
|
|
20
apps/essimporter/importscpt.cpp
Normal file
20
apps/essimporter/importscpt.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include "importscpt.hpp"
|
||||
|
||||
#include <components/esm/esmreader.hpp>
|
||||
|
||||
|
||||
|
||||
namespace ESSImport
|
||||
{
|
||||
|
||||
void SCPT::load(ESM::ESMReader &esm)
|
||||
{
|
||||
esm.getHNT(mSCHD, "SCHD");
|
||||
|
||||
mSCRI.load(esm);
|
||||
|
||||
mRNAM = -1;
|
||||
esm.getHNOT(mRNAM, "RNAM");
|
||||
}
|
||||
|
||||
}
|
32
apps/essimporter/importscpt.hpp
Normal file
32
apps/essimporter/importscpt.hpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#ifndef OPENMW_ESSIMPORT_IMPORTSCPT_H
|
||||
#define OPENMW_ESSIMPORT_IMPORTSCPT_H
|
||||
|
||||
#include "importscri.hpp"
|
||||
|
||||
#include <components/esm/loadscpt.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
}
|
||||
|
||||
namespace ESSImport
|
||||
{
|
||||
|
||||
// A running global script
|
||||
// TODO: test how targeted scripts are saved
|
||||
struct SCPT
|
||||
{
|
||||
ESM::Script::SCHD mSCHD;
|
||||
|
||||
// values of local variables
|
||||
SCRI mSCRI;
|
||||
|
||||
int mRNAM; // unknown, seems to be -1 for some scripts, some huge integer for others
|
||||
|
||||
void load(ESM::ESMReader& esm);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
55
apps/essimporter/importscri.cpp
Normal file
55
apps/essimporter/importscri.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include "importscri.hpp"
|
||||
|
||||
#include <components/esm/esmreader.hpp>
|
||||
|
||||
namespace ESSImport
|
||||
{
|
||||
|
||||
void SCRI::load(ESM::ESMReader &esm)
|
||||
{
|
||||
mScript = esm.getHNOString("SCRI");
|
||||
|
||||
int numShorts = 0, numLongs = 0, numFloats = 0;
|
||||
if (esm.isNextSub("SLCS"))
|
||||
{
|
||||
esm.getSubHeader();
|
||||
esm.getT(numShorts);
|
||||
esm.getT(numLongs);
|
||||
esm.getT(numFloats);
|
||||
}
|
||||
|
||||
if (esm.isNextSub("SLSD"))
|
||||
{
|
||||
esm.getSubHeader();
|
||||
for (int i=0; i<numShorts; ++i)
|
||||
{
|
||||
short val;
|
||||
esm.getT(val);
|
||||
mShorts.push_back(val);
|
||||
}
|
||||
}
|
||||
// I haven't seen Longs in a save file yet, but SLLD would make sense for the name
|
||||
// TODO: test this
|
||||
if (esm.isNextSub("SLLD"))
|
||||
{
|
||||
esm.getSubHeader();
|
||||
for (int i=0; i<numLongs; ++i)
|
||||
{
|
||||
int val;
|
||||
esm.getT(val);
|
||||
mLongs.push_back(val);
|
||||
}
|
||||
}
|
||||
if (esm.isNextSub("SLFD"))
|
||||
{
|
||||
esm.getSubHeader();
|
||||
for (int i=0; i<numFloats; ++i)
|
||||
{
|
||||
float val;
|
||||
esm.getT(val);
|
||||
mFloats.push_back(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
30
apps/essimporter/importscri.hpp
Normal file
30
apps/essimporter/importscri.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#ifndef OPENMW_ESSIMPORT_IMPORTSCRI_H
|
||||
#define OPENMW_ESSIMPORT_IMPORTSCRI_H
|
||||
|
||||
#include <components/esm/variant.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
}
|
||||
|
||||
namespace ESSImport
|
||||
{
|
||||
|
||||
/// Local variable assigments for a running script
|
||||
struct SCRI
|
||||
{
|
||||
std::string mScript;
|
||||
|
||||
std::vector<short> mShorts;
|
||||
std::vector<int> mLongs;
|
||||
std::vector<float> mFloats;
|
||||
|
||||
void load(ESM::ESMReader& esm);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -7,12 +7,6 @@
|
|||
namespace ESM
|
||||
{
|
||||
|
||||
struct SCHD
|
||||
{
|
||||
NAME32 mName;
|
||||
Script::SCHDstruct mData;
|
||||
};
|
||||
|
||||
unsigned int Script::sRecordId = REC_SCPT;
|
||||
|
||||
void Script::load(ESMReader &esm)
|
||||
|
@ -92,32 +86,6 @@ void Script::load(ESMReader &esm)
|
|||
if (esm.isNextSub("SCVR")) {
|
||||
esm.skipHSub();
|
||||
}
|
||||
|
||||
// ESS only, TODO: move
|
||||
if (esm.isNextSub("SLCS"))
|
||||
{
|
||||
esm.getSubHeader();
|
||||
char unknown[12];
|
||||
esm.getExact(unknown, 12);
|
||||
}
|
||||
if (esm.isNextSub("SLSD"))
|
||||
{
|
||||
float read;
|
||||
esm.getSubHeader();
|
||||
// values of variables?
|
||||
for (int i=0; i<mData.mNumShorts; ++i)
|
||||
esm.getExact(&read, 2);
|
||||
for (int i=0; i<mData.mNumLongs; ++i)
|
||||
esm.getExact(&read, 4);
|
||||
for (int i=0; i<mData.mNumFloats; ++i)
|
||||
esm.getExact(&read, 4);
|
||||
}
|
||||
if (esm.isNextSub("RNAM"))
|
||||
{
|
||||
// RefNum? something to do with targetted scripts?
|
||||
int refnum;
|
||||
esm.getHT(refnum);
|
||||
}
|
||||
}
|
||||
void Script::save(ESMWriter &esm) const
|
||||
{
|
||||
|
|
|
@ -26,6 +26,11 @@ public:
|
|||
/// Data from script-precompling in the editor.
|
||||
/// \warning Do not use them. OpenCS currently does not precompile scripts.
|
||||
int mNumShorts, mNumLongs, mNumFloats, mScriptDataSize, mStringTableSize;
|
||||
};
|
||||
struct SCHD
|
||||
{
|
||||
NAME32 mName;
|
||||
Script::SCHDstruct mData;
|
||||
}; // 52 bytes
|
||||
|
||||
std::string mId;
|
||||
|
|
Loading…
Reference in a new issue