mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
move most of the files from esm to esm3, keep common code in esm; this is make space for a future with esm4
esm typo esm typo
This commit is contained in:
parent
c263bbf0f6
commit
d1fb854521
448 changed files with 686 additions and 683 deletions
97
components/esm3/loadbook.cpp
Normal file
97
components/esm3/loadbook.cpp
Normal file
|
@ -0,0 +1,97 @@
|
|||
#include "loadbook.hpp"
|
||||
|
||||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
#include "components/esm/defs.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
unsigned int Book::sRecordId = REC_BOOK;
|
||||
|
||||
void Book::load(ESMReader &esm, bool &isDeleted)
|
||||
{
|
||||
isDeleted = false;
|
||||
mRecordFlags = esm.getRecordFlags();
|
||||
|
||||
bool hasName = false;
|
||||
bool hasData = false;
|
||||
while (esm.hasMoreSubs())
|
||||
{
|
||||
esm.getSubName();
|
||||
switch (esm.retSubName().toInt())
|
||||
{
|
||||
case ESM::SREC_NAME:
|
||||
mId = esm.getHString();
|
||||
hasName = true;
|
||||
break;
|
||||
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<'B','K','D','T'>::value:
|
||||
esm.getHT(mData, 20);
|
||||
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;
|
||||
case ESM::FourCC<'E','N','A','M'>::value:
|
||||
mEnchant = esm.getHString();
|
||||
break;
|
||||
case ESM::FourCC<'T','E','X','T'>::value:
|
||||
mText = 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");
|
||||
if (!hasData && !isDeleted)
|
||||
esm.fail("Missing BKDT subrecord");
|
||||
}
|
||||
void Book::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.writeHNT("BKDT", mData, 20);
|
||||
esm.writeHNOCString("SCRI", mScript);
|
||||
esm.writeHNOCString("ITEX", mIcon);
|
||||
esm.writeHNOString("TEXT", mText);
|
||||
esm.writeHNOCString("ENAM", mEnchant);
|
||||
}
|
||||
|
||||
void Book::blank()
|
||||
{
|
||||
mData.mWeight = 0;
|
||||
mData.mValue = 0;
|
||||
mData.mIsScroll = 0;
|
||||
mData.mSkillId = 0;
|
||||
mData.mEnchant = 0;
|
||||
mName.clear();
|
||||
mModel.clear();
|
||||
mIcon.clear();
|
||||
mScript.clear();
|
||||
mEnchant.clear();
|
||||
mText.clear();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue