diff --git a/components/esm/loadscpt.cpp b/components/esm/loadscpt.cpp index fd807ddd3..67c1b8f6f 100644 --- a/components/esm/loadscpt.cpp +++ b/components/esm/loadscpt.cpp @@ -3,6 +3,7 @@ #include "esmreader.hpp" #include "esmwriter.hpp" #include "defs.hpp" +#include "util.hpp" #include @@ -65,6 +66,10 @@ namespace ESM mData = data.mData; mId = data.mName.toString(); + // In scripts DELE sub-record appears after a header. + // The script data is following after DELE in this case. + mIsDeleted = readDeleSubRecord(esm); + mVarNames.clear(); while (esm.hasMoreSubs()) @@ -106,6 +111,11 @@ namespace ESM esm.writeHNT("SCHD", data, 52); + if (mIsDeleted) + { + writeDeleSubRecord(esm); + } + if (!mVarNames.empty()) { esm.startSubRecord("SCVR"); @@ -136,6 +146,8 @@ namespace ESM mScriptText = "Begin \"" + mId + "\"\n\nEnd " + mId + "\n"; else mScriptText = "Begin " + mId + "\n\nEnd " + mId + "\n"; + + mIsDeleted = false; } } diff --git a/components/esm/loadscpt.hpp b/components/esm/loadscpt.hpp index 56390f384..401dfe105 100644 --- a/components/esm/loadscpt.hpp +++ b/components/esm/loadscpt.hpp @@ -50,6 +50,8 @@ public: /// Script source code std::string mScriptText; + bool mIsDeleted; + void load(ESMReader &esm); void save(ESMWriter &esm) const;