2013-03-12 08:16:03 +00:00
|
|
|
#include "loadtes3.hpp"
|
|
|
|
|
2022-01-22 14:58:41 +00:00
|
|
|
#include "components/esm/esmcommon.hpp"
|
2013-03-12 08:16:03 +00:00
|
|
|
#include "esmreader.hpp"
|
|
|
|
#include "esmwriter.hpp"
|
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
namespace ESM
|
2013-03-12 08:16:03 +00:00
|
|
|
{
|
2022-04-11 22:18:39 +00:00
|
|
|
|
|
|
|
void Header::blank()
|
2013-03-12 13:33:35 +00:00
|
|
|
{
|
2024-01-01 10:56:48 +00:00
|
|
|
mData.version.ui = VER_130;
|
2013-03-12 08:16:03 +00:00
|
|
|
mData.type = 0;
|
2013-03-12 13:33:35 +00:00
|
|
|
mData.author.clear();
|
|
|
|
mData.desc.clear();
|
|
|
|
mData.records = 0;
|
2023-02-10 12:16:52 +00:00
|
|
|
mFormatVersion = CurrentContentFormatVersion;
|
2013-09-27 09:36:06 +00:00
|
|
|
mMaster.clear();
|
2013-03-12 13:33:35 +00:00
|
|
|
}
|
|
|
|
|
2013-12-21 08:33:05 +00:00
|
|
|
void Header::load(ESMReader& esm)
|
|
|
|
{
|
2023-12-20 11:28:34 +00:00
|
|
|
mFormatVersion = DefaultFormatVersion;
|
|
|
|
esm.getHNOT("FORM", mFormatVersion);
|
2013-11-19 12:44:18 +00:00
|
|
|
|
2013-03-12 08:16:03 +00:00
|
|
|
if (esm.isNextSub("HEDR"))
|
|
|
|
{
|
|
|
|
esm.getSubHeader();
|
2024-01-01 10:56:48 +00:00
|
|
|
esm.getT(mData.version.ui);
|
2021-05-05 19:23:06 +00:00
|
|
|
esm.getT(mData.type);
|
2023-02-12 18:36:56 +00:00
|
|
|
mData.author = esm.getMaybeFixedStringSize(32);
|
|
|
|
mData.desc = esm.getMaybeFixedStringSize(256);
|
2013-03-12 08:16:03 +00:00
|
|
|
esm.getT(mData.records);
|
|
|
|
}
|
2015-01-16 23:11:36 +00:00
|
|
|
|
2013-03-12 13:33:35 +00:00
|
|
|
while (esm.isNextSub("MAST"))
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
2013-03-12 08:16:03 +00:00
|
|
|
MasterData m;
|
|
|
|
m.name = esm.getHString();
|
2021-05-05 19:23:06 +00:00
|
|
|
esm.getHNT(m.size, "DATA");
|
2013-03-12 08:16:03 +00:00
|
|
|
mMaster.push_back(m);
|
2022-09-22 18:26:05 +00:00
|
|
|
}
|
|
|
|
|
2023-12-20 11:28:34 +00:00
|
|
|
esm.getHNOT("GMDT", mGameData.mCurrentHealth, mGameData.mMaximumHealth, mGameData.mHour, mGameData.unknown1,
|
|
|
|
mGameData.mCurrentCell.mData, mGameData.unknown2, mGameData.mPlayerName.mData);
|
2015-01-16 23:11:36 +00:00
|
|
|
if (esm.isNextSub("SCRD"))
|
|
|
|
{
|
|
|
|
esm.getSubHeader();
|
|
|
|
mSCRD.resize(esm.getSubSize());
|
2016-02-22 18:06:12 +00:00
|
|
|
if (!mSCRD.empty())
|
2021-05-05 19:23:06 +00:00
|
|
|
esm.getExact(mSCRD.data(), mSCRD.size());
|
2015-01-16 23:11:36 +00:00
|
|
|
}
|
|
|
|
if (esm.isNextSub("SCRS"))
|
|
|
|
{
|
|
|
|
esm.getSubHeader();
|
|
|
|
mSCRS.resize(esm.getSubSize());
|
2016-02-22 18:06:12 +00:00
|
|
|
if (!mSCRS.empty())
|
2021-05-05 19:23:06 +00:00
|
|
|
esm.getExact(mSCRS.data(), mSCRS.size());
|
2022-09-22 18:26:05 +00:00
|
|
|
}
|
2015-01-16 23:11:36 +00:00
|
|
|
}
|
2013-03-12 08:16:03 +00:00
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
void Header::save(ESMWriter& esm)
|
2013-03-12 08:16:03 +00:00
|
|
|
{
|
2023-02-10 12:16:52 +00:00
|
|
|
if (mFormatVersion > DefaultFormatVersion)
|
|
|
|
esm.writeHNT("FORM", mFormatVersion);
|
2013-03-12 13:33:35 +00:00
|
|
|
|
2015-06-26 18:16:32 +00:00
|
|
|
esm.startSubRecord("HEDR");
|
|
|
|
esm.writeT(mData.version);
|
|
|
|
esm.writeT(mData.type);
|
2023-02-12 16:03:01 +00:00
|
|
|
esm.writeMaybeFixedSizeString(mData.author, 32);
|
|
|
|
esm.writeMaybeFixedSizeString(mData.desc, 256);
|
2015-06-26 18:16:32 +00:00
|
|
|
esm.writeT(mData.records);
|
|
|
|
esm.endRecord("HEDR");
|
2013-11-19 12:44:18 +00:00
|
|
|
|
2021-05-05 19:23:06 +00:00
|
|
|
for (const Header::MasterData& data : mMaster)
|
2013-03-12 08:16:03 +00:00
|
|
|
{
|
2021-05-05 19:23:06 +00:00
|
|
|
esm.writeHNCString("MAST", data.name);
|
|
|
|
esm.writeHNT("DATA", data.size);
|
2022-09-22 18:26:05 +00:00
|
|
|
}
|
2013-03-12 08:16:03 +00:00
|
|
|
}
|
2022-04-11 22:18:39 +00:00
|
|
|
|
|
|
|
}
|