2011-04-08 17:58:21 +04:00
|
|
|
#include "loadsscr.hpp"
|
|
|
|
|
2012-09-23 22:41:41 +04:00
|
|
|
#include "esmreader.hpp"
|
|
|
|
#include "esmwriter.hpp"
|
2013-09-24 13:17:28 +02:00
|
|
|
#include "defs.hpp"
|
2012-09-17 11:37:50 +04:00
|
|
|
|
2011-04-08 17:58:21 +04:00
|
|
|
namespace ESM
|
|
|
|
{
|
2013-09-24 13:17:28 +02:00
|
|
|
unsigned int StartScript::sRecordId = REC_SSCR;
|
2011-04-08 17:58:21 +04:00
|
|
|
|
2015-07-20 17:23:14 +03:00
|
|
|
void StartScript::load(ESMReader &esm, bool &isDeleted)
|
2015-02-12 04:56:05 +01:00
|
|
|
{
|
2015-07-20 17:23:14 +03:00
|
|
|
isDeleted = false;
|
2015-07-16 22:17:49 +03:00
|
|
|
|
2015-02-12 04:56:05 +01:00
|
|
|
bool hasData = false;
|
|
|
|
bool hasName = false;
|
|
|
|
while (esm.hasMoreSubs())
|
|
|
|
{
|
|
|
|
esm.getSubName();
|
2016-05-07 20:32:51 +03:00
|
|
|
switch (esm.retSubName().intval)
|
2015-02-12 04:56:05 +01:00
|
|
|
{
|
2015-11-13 18:07:18 +01:00
|
|
|
case ESM::SREC_NAME:
|
2015-03-03 13:04:57 +01:00
|
|
|
mId = esm.getHString();
|
2015-02-12 04:56:05 +01:00
|
|
|
hasName = true;
|
|
|
|
break;
|
2015-07-28 15:04:22 +03:00
|
|
|
case ESM::FourCC<'D','A','T','A'>::value:
|
|
|
|
mData = esm.getHString();
|
|
|
|
hasData = true;
|
|
|
|
break;
|
2015-11-13 18:07:18 +01:00
|
|
|
case ESM::SREC_DELE:
|
2015-07-16 22:17:49 +03:00
|
|
|
esm.skipHSub();
|
2015-07-20 17:23:14 +03:00
|
|
|
isDeleted = true;
|
2015-07-16 22:17:49 +03:00
|
|
|
break;
|
2015-02-12 04:56:05 +01:00
|
|
|
default:
|
|
|
|
esm.fail("Unknown subrecord");
|
2015-07-16 22:17:49 +03:00
|
|
|
break;
|
2015-02-12 04:56:05 +01:00
|
|
|
}
|
|
|
|
}
|
2015-07-16 22:17:49 +03:00
|
|
|
|
2015-02-12 04:56:05 +01:00
|
|
|
if (!hasName)
|
|
|
|
esm.fail("Missing NAME");
|
2015-07-28 15:04:22 +03:00
|
|
|
if (!hasData && !isDeleted)
|
|
|
|
esm.fail("Missing DATA");
|
2015-02-12 04:56:05 +01:00
|
|
|
}
|
2015-07-20 17:23:14 +03:00
|
|
|
void StartScript::save(ESMWriter &esm, bool isDeleted) const
|
2015-02-12 04:56:05 +01:00
|
|
|
{
|
2015-07-28 15:04:22 +03:00
|
|
|
esm.writeHNCString("NAME", mId);
|
2015-07-20 17:23:14 +03:00
|
|
|
if (isDeleted)
|
2015-07-16 22:17:49 +03:00
|
|
|
{
|
|
|
|
esm.writeHNCString("DELE", "");
|
|
|
|
}
|
2015-07-28 15:04:22 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
esm.writeHNString("DATA", mData);
|
|
|
|
}
|
2015-02-12 04:56:05 +01:00
|
|
|
}
|
2011-04-08 17:58:21 +04:00
|
|
|
|
2015-03-03 13:52:36 +01:00
|
|
|
void StartScript::blank()
|
|
|
|
{
|
|
|
|
mData.clear();
|
|
|
|
}
|
2011-04-08 17:58:21 +04:00
|
|
|
}
|