1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 17:59:56 +00:00
openmw/components/esm3/loadtes3.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
2.3 KiB
C++
Raw Normal View History

#include "loadtes3.hpp"
#include "components/esm/esmcommon.hpp"
#include "esmreader.hpp"
#include "esmwriter.hpp"
namespace ESM
{
void Header::blank()
{
mData.version.ui = VER_130;
mData.type = 0;
mData.author.clear();
mData.desc.clear();
mData.records = 0;
mFormatVersion = CurrentContentFormatVersion;
mMaster.clear();
}
void Header::load(ESMReader& esm)
{
2023-12-20 11:28:34 +00:00
mFormatVersion = DefaultFormatVersion;
esm.getHNOT("FORM", mFormatVersion);
if (esm.isNextSub("HEDR"))
{
esm.getSubHeader();
esm.getT(mData.version.ui);
2021-05-05 19:23:06 +00:00
esm.getT(mData.type);
mData.author = esm.getMaybeFixedStringSize(32);
mData.desc = esm.getMaybeFixedStringSize(256);
esm.getT(mData.records);
}
while (esm.isNextSub("MAST"))
2022-09-22 18:26:05 +00:00
{
MasterData m;
m.name = esm.getHString();
2021-05-05 19:23:06 +00:00
esm.getHNT(m.size, "DATA");
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);
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());
}
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
}
}
void Header::save(ESMWriter& esm)
{
if (mFormatVersion > DefaultFormatVersion)
esm.writeHNT("FORM", mFormatVersion);
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);
esm.writeT(mData.records);
esm.endRecord("HEDR");
2021-05-05 19:23:06 +00:00
for (const Header::MasterData& data : mMaster)
{
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
}
}
}