mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 17:19:56 +00:00
49d912e5b6
Nice side effects: - Subrecord name comparison now uses magic number instead of string (faster) - Improves the error message for unknown subrecords: will print the record in question instead of failing to read the next record with a strange error
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#include "loadsscr.hpp"
|
|
|
|
#include "esmreader.hpp"
|
|
#include "esmwriter.hpp"
|
|
#include "defs.hpp"
|
|
|
|
namespace ESM
|
|
{
|
|
unsigned int StartScript::sRecordId = REC_SSCR;
|
|
|
|
void StartScript::load(ESMReader &esm)
|
|
{
|
|
bool hasData = false;
|
|
bool hasName = false;
|
|
while (esm.hasMoreSubs())
|
|
{
|
|
esm.getSubName();
|
|
uint32_t name = esm.retSubName().val;
|
|
switch (name)
|
|
{
|
|
case ESM::FourCC<'D','A','T','A'>::value:
|
|
mData = esm.getHString();
|
|
hasData = true;
|
|
break;
|
|
case ESM::FourCC<'N','A','M','E'>::value:
|
|
mScript = esm.getHString();
|
|
hasName = true;
|
|
break;
|
|
default:
|
|
esm.fail("Unknown subrecord");
|
|
}
|
|
}
|
|
if (!hasData)
|
|
esm.fail("Missing DATA");
|
|
if (!hasName)
|
|
esm.fail("Missing NAME");
|
|
}
|
|
void StartScript::save(ESMWriter &esm) const
|
|
{
|
|
esm.writeHNString("DATA", mData);
|
|
esm.writeHNString("NAME", mScript);
|
|
}
|
|
|
|
}
|