2013-03-22 04:50:54 +00:00
|
|
|
#include "loadlock.hpp"
|
|
|
|
|
|
|
|
#include "esmreader.hpp"
|
|
|
|
#include "esmwriter.hpp"
|
2013-09-24 11:17:28 +00:00
|
|
|
#include "defs.hpp"
|
2013-03-22 04:50:54 +00:00
|
|
|
|
|
|
|
namespace ESM
|
|
|
|
{
|
2013-09-24 11:17:28 +00:00
|
|
|
unsigned int Lockpick::sRecordId = REC_LOCK;
|
2013-03-22 04:50:54 +00:00
|
|
|
|
2015-07-20 14:23:14 +00:00
|
|
|
void Lockpick::load(ESMReader &esm, bool &isDeleted)
|
2015-02-12 03:56:05 +00:00
|
|
|
{
|
2015-07-20 14:23:14 +00:00
|
|
|
isDeleted = false;
|
2021-06-29 13:25:26 +00:00
|
|
|
mRecordFlags = esm.getRecordFlags();
|
2015-07-07 12:37:42 +00:00
|
|
|
|
2015-07-16 16:52:31 +00:00
|
|
|
bool hasName = false;
|
|
|
|
bool hasData = false;
|
2015-02-12 03:56:05 +00:00
|
|
|
while (esm.hasMoreSubs())
|
|
|
|
{
|
|
|
|
esm.getSubName();
|
2016-05-07 17:32:51 +00:00
|
|
|
switch (esm.retSubName().intval)
|
2015-02-12 03:56:05 +00:00
|
|
|
{
|
2015-11-13 17:07:18 +00:00
|
|
|
case ESM::SREC_NAME:
|
2015-07-16 16:52:31 +00:00
|
|
|
mId = esm.getHString();
|
2015-07-16 19:31:59 +00:00
|
|
|
hasName = true;
|
2015-07-16 16:52:31 +00:00
|
|
|
break;
|
2015-02-12 03:56:05 +00:00
|
|
|
case ESM::FourCC<'M','O','D','L'>::value:
|
|
|
|
mModel = esm.getHString();
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'F','N','A','M'>::value:
|
|
|
|
mName = esm.getHString();
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'L','K','D','T'>::value:
|
|
|
|
esm.getHT(mData, 16);
|
|
|
|
hasData = true;
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'S','C','R','I'>::value:
|
|
|
|
mScript = esm.getHString();
|
|
|
|
break;
|
|
|
|
case ESM::FourCC<'I','T','E','X'>::value:
|
|
|
|
mIcon = esm.getHString();
|
|
|
|
break;
|
2015-11-13 17:07:18 +00:00
|
|
|
case ESM::SREC_DELE:
|
2015-07-20 14:23:14 +00:00
|
|
|
esm.skipHSub();
|
|
|
|
isDeleted = true;
|
|
|
|
break;
|
2015-02-12 03:56:05 +00:00
|
|
|
default:
|
|
|
|
esm.fail("Unknown subrecord");
|
2015-07-16 16:52:31 +00:00
|
|
|
break;
|
2015-02-12 03:56:05 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-16 16:52:31 +00:00
|
|
|
|
|
|
|
if (!hasName)
|
|
|
|
esm.fail("Missing NAME subrecord");
|
2015-07-20 14:23:14 +00:00
|
|
|
if (!hasData && !isDeleted)
|
2015-02-12 03:56:05 +00:00
|
|
|
esm.fail("Missing LKDT subrecord");
|
|
|
|
}
|
2013-03-22 04:50:54 +00:00
|
|
|
|
2015-07-20 14:23:14 +00:00
|
|
|
void Lockpick::save(ESMWriter &esm, bool isDeleted) const
|
2015-02-12 03:56:05 +00:00
|
|
|
{
|
2015-07-07 12:37:42 +00:00
|
|
|
esm.writeHNCString("NAME", mId);
|
2015-07-16 16:52:31 +00:00
|
|
|
|
2015-07-20 14:23:14 +00:00
|
|
|
if (isDeleted)
|
2015-07-07 12:37:42 +00:00
|
|
|
{
|
2021-07-06 04:57:58 +00:00
|
|
|
esm.writeHNString("DELE", "", 3);
|
2015-07-07 12:37:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-12 03:56:05 +00:00
|
|
|
esm.writeHNCString("MODL", mModel);
|
|
|
|
esm.writeHNOCString("FNAM", mName);
|
2013-05-06 12:10:43 +00:00
|
|
|
|
2015-02-12 03:56:05 +00:00
|
|
|
esm.writeHNT("LKDT", mData, 16);
|
|
|
|
esm.writeHNOString("SCRI", mScript);
|
|
|
|
esm.writeHNOCString("ITEX", mIcon);
|
|
|
|
}
|
2013-03-22 04:50:54 +00:00
|
|
|
|
2013-05-06 12:10:43 +00:00
|
|
|
void Lockpick::blank()
|
|
|
|
{
|
|
|
|
mData.mWeight = 0;
|
|
|
|
mData.mValue = 0;
|
|
|
|
mData.mQuality = 0;
|
|
|
|
mData.mUses = 0;
|
|
|
|
mName.clear();
|
|
|
|
mModel.clear();
|
|
|
|
mIcon.clear();
|
|
|
|
mScript.clear();
|
|
|
|
}
|
2013-03-22 04:50:54 +00:00
|
|
|
}
|