From e2031279520aefbe00f053bd9dd75e2f842e2198 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 22 Jan 2015 03:54:33 +0100 Subject: [PATCH] ESSImport: read script variables (not converted yet) --- apps/essimporter/CMakeLists.txt | 2 + apps/essimporter/converter.hpp | 12 ++++++ apps/essimporter/importacdt.cpp | 13 +------ apps/essimporter/importacdt.hpp | 4 +- apps/essimporter/importer.cpp | 1 + apps/essimporter/importinventory.cpp | 13 +------ apps/essimporter/importinventory.hpp | 2 + apps/essimporter/importscpt.cpp | 20 ++++++++++ apps/essimporter/importscpt.hpp | 32 ++++++++++++++++ apps/essimporter/importscri.cpp | 55 ++++++++++++++++++++++++++++ apps/essimporter/importscri.hpp | 30 +++++++++++++++ components/esm/loadscpt.cpp | 32 ---------------- components/esm/loadscpt.hpp | 5 +++ 13 files changed, 164 insertions(+), 57 deletions(-) create mode 100644 apps/essimporter/importscpt.cpp create mode 100644 apps/essimporter/importscpt.hpp create mode 100644 apps/essimporter/importscri.cpp create mode 100644 apps/essimporter/importscri.hpp diff --git a/apps/essimporter/CMakeLists.txt b/apps/essimporter/CMakeLists.txt index 70eaefe2c..5db3a86dc 100644 --- a/apps/essimporter/CMakeLists.txt +++ b/apps/essimporter/CMakeLists.txt @@ -14,6 +14,8 @@ set(ESSIMPORTER_FILES importdial.cpp importques.cpp importjour.cpp + importscri.cpp + importscpt.cpp importercontext.cpp converter.cpp convertacdt.cpp diff --git a/apps/essimporter/converter.hpp b/apps/essimporter/converter.hpp index a88a364d2..9894de299 100644 --- a/apps/essimporter/converter.hpp +++ b/apps/essimporter/converter.hpp @@ -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 diff --git a/apps/essimporter/importacdt.cpp b/apps/essimporter/importacdt.cpp index 4d4a87a35..e590e2826 100644 --- a/apps/essimporter/importacdt.cpp +++ b/apps/essimporter/importacdt.cpp @@ -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(); diff --git a/apps/essimporter/importacdt.hpp b/apps/essimporter/importacdt.hpp index 271f6df74..3e3003f58 100644 --- a/apps/essimporter/importacdt.hpp +++ b/apps/essimporter/importacdt.hpp @@ -5,6 +5,8 @@ #include +#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); }; diff --git a/apps/essimporter/importer.cpp b/apps/essimporter/importer.cpp index 8603200da..a29d26e2a 100644 --- a/apps/essimporter/importer.cpp +++ b/apps/essimporter/importer.cpp @@ -234,6 +234,7 @@ namespace ESSImport converters[ESM::REC_DIAL] = boost::shared_ptr(new ConvertDIAL()); converters[ESM::REC_QUES] = boost::shared_ptr(new ConvertQUES()); converters[recJOUR ] = boost::shared_ptr(new ConvertJOUR()); + converters[ESM::REC_SCPT] = boost::shared_ptr(new ConvertSCPT()); std::set unknownRecords; diff --git a/apps/essimporter/importinventory.cpp b/apps/essimporter/importinventory.cpp index a20584ff5..d27cd5c8c 100644 --- a/apps/essimporter/importinventory.cpp +++ b/apps/essimporter/importinventory.cpp @@ -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); diff --git a/apps/essimporter/importinventory.hpp b/apps/essimporter/importinventory.hpp index 99fed9b20..0b5405d96 100644 --- a/apps/essimporter/importinventory.hpp +++ b/apps/essimporter/importinventory.hpp @@ -5,6 +5,7 @@ #include #include +#include "importscri.hpp" namespace ESM { @@ -21,6 +22,7 @@ namespace ESSImport std::string mId; int mCount; int mRelativeEquipmentSlot; + SCRI mSCRI; }; std::vector mItems; diff --git a/apps/essimporter/importscpt.cpp b/apps/essimporter/importscpt.cpp new file mode 100644 index 000000000..374fd05fa --- /dev/null +++ b/apps/essimporter/importscpt.cpp @@ -0,0 +1,20 @@ +#include "importscpt.hpp" + +#include + + + +namespace ESSImport +{ + + void SCPT::load(ESM::ESMReader &esm) + { + esm.getHNT(mSCHD, "SCHD"); + + mSCRI.load(esm); + + mRNAM = -1; + esm.getHNOT(mRNAM, "RNAM"); + } + +} diff --git a/apps/essimporter/importscpt.hpp b/apps/essimporter/importscpt.hpp new file mode 100644 index 000000000..ca2439dda --- /dev/null +++ b/apps/essimporter/importscpt.hpp @@ -0,0 +1,32 @@ +#ifndef OPENMW_ESSIMPORT_IMPORTSCPT_H +#define OPENMW_ESSIMPORT_IMPORTSCPT_H + +#include "importscri.hpp" + +#include + +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 diff --git a/apps/essimporter/importscri.cpp b/apps/essimporter/importscri.cpp new file mode 100644 index 000000000..de0b35c86 --- /dev/null +++ b/apps/essimporter/importscri.cpp @@ -0,0 +1,55 @@ +#include "importscri.hpp" + +#include + +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 + +#include + +namespace ESM +{ + class ESMReader; +} + +namespace ESSImport +{ + + /// Local variable assigments for a running script + struct SCRI + { + std::string mScript; + + std::vector mShorts; + std::vector mLongs; + std::vector mFloats; + + void load(ESM::ESMReader& esm); + }; + +} + +#endif diff --git a/components/esm/loadscpt.cpp b/components/esm/loadscpt.cpp index f2f13d086..2df8e66ce 100644 --- a/components/esm/loadscpt.cpp +++ b/components/esm/loadscpt.cpp @@ -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