mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
3a117cac22
Add static asssert on wrong size
81 lines
2.1 KiB
C++
81 lines
2.1 KiB
C++
#include "loaddoor.hpp"
|
|
|
|
#include "esmreader.hpp"
|
|
#include "esmwriter.hpp"
|
|
#include "components/esm/defs.hpp"
|
|
|
|
namespace ESM
|
|
{
|
|
unsigned int Door::sRecordId = REC_DOOR;
|
|
|
|
void Door::load(ESMReader &esm, bool &isDeleted)
|
|
{
|
|
isDeleted = false;
|
|
mRecordFlags = esm.getRecordFlags();
|
|
|
|
bool hasName = false;
|
|
while (esm.hasMoreSubs())
|
|
{
|
|
esm.getSubName();
|
|
switch (esm.retSubName().toInt())
|
|
{
|
|
case ESM::SREC_NAME:
|
|
mId = esm.getHString();
|
|
hasName = true;
|
|
break;
|
|
case ESM::fourCC("MODL"):
|
|
mModel = esm.getHString();
|
|
break;
|
|
case ESM::fourCC("FNAM"):
|
|
mName = esm.getHString();
|
|
break;
|
|
case ESM::fourCC("SCRI"):
|
|
mScript = esm.getHString();
|
|
break;
|
|
case ESM::fourCC("SNAM"):
|
|
mOpenSound = esm.getHString();
|
|
break;
|
|
case ESM::fourCC("ANAM"):
|
|
mCloseSound = esm.getHString();
|
|
break;
|
|
case ESM::SREC_DELE:
|
|
esm.skipHSub();
|
|
isDeleted = true;
|
|
break;
|
|
default:
|
|
esm.fail("Unknown subrecord");
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!hasName)
|
|
esm.fail("Missing NAME subrecord");
|
|
}
|
|
|
|
void Door::save(ESMWriter &esm, bool isDeleted) const
|
|
{
|
|
esm.writeHNCString("NAME", mId);
|
|
|
|
if (isDeleted)
|
|
{
|
|
esm.writeHNString("DELE", "", 3);
|
|
return;
|
|
}
|
|
|
|
esm.writeHNCString("MODL", mModel);
|
|
esm.writeHNOCString("FNAM", mName);
|
|
esm.writeHNOCString("SCRI", mScript);
|
|
esm.writeHNOCString("SNAM", mOpenSound);
|
|
esm.writeHNOCString("ANAM", mCloseSound);
|
|
}
|
|
|
|
void Door::blank()
|
|
{
|
|
mName.clear();
|
|
mModel.clear();
|
|
mScript.clear();
|
|
mOpenSound.clear();
|
|
mCloseSound.clear();
|
|
}
|
|
}
|