metaforce/DataSpec/DNAMP1/EVNT.cpp

108 lines
2.6 KiB
C++
Raw Normal View History

2015-08-15 04:12:15 +00:00
#include "EVNT.hpp"
namespace Retro
{
namespace DNAMP1
{
void EVNT::read(Athena::io::IStreamReader& reader)
{
version = reader.readUint32Big();
atUint32 loopCount = reader.readUint32Big();
reader.enumerate(loopEvents, loopCount);
uevtEvents.clear();
2016-01-19 05:32:34 +00:00
atUint32 uevtCount = reader.readUint32Big();
reader.enumerate(uevtEvents, uevtCount);
2015-08-15 04:12:15 +00:00
atUint32 effectCount = reader.readUint32Big();
reader.enumerate(effectEvents, effectCount);
2016-01-19 05:32:34 +00:00
if (version == 2)
{
atUint32 sfxCount = reader.readUint32Big();
reader.enumerate(sfxEvents, sfxCount);
}
2015-08-15 04:12:15 +00:00
}
void EVNT::write(Athena::io::IStreamWriter& writer) const
{
writer.writeUint32Big(version);
writer.writeUint32Big(loopEvents.size());
writer.enumerate(loopEvents);
2016-01-19 05:32:34 +00:00
writer.writeUint32Big(uevtEvents.size());
writer.enumerate(uevtEvents);
2015-08-15 04:12:15 +00:00
writer.writeUint32Big(effectEvents.size());
writer.enumerate(effectEvents);
2016-01-19 05:32:34 +00:00
if (version == 2)
{
writer.writeUint32Big(sfxEvents.size());
writer.enumerate(sfxEvents);
}
2015-08-15 04:12:15 +00:00
}
2016-01-04 05:31:02 +00:00
void EVNT::read(Athena::io::YAMLDocReader& reader)
2015-08-15 04:12:15 +00:00
{
version = reader.readUint32("version");
atUint32 loopCount = reader.readUint32("loopCount");
reader.enumerate("loopEvents", loopEvents, loopCount);
uevtEvents.clear();
2016-01-19 05:32:34 +00:00
atUint32 uevtCount = reader.readUint32("uevtCount");
reader.enumerate("uevtEvents", uevtEvents, uevtCount);
2015-08-15 04:12:15 +00:00
atUint32 effectCount = reader.readUint32("effectCount");
reader.enumerate("effectEvents", effectEvents, effectCount);
2016-01-19 05:32:34 +00:00
if (version == 2)
{
atUint32 sfxCount = reader.readUint32("sfxCount");
reader.enumerate("sfxEvents", sfxEvents, sfxCount);
}
2015-08-15 04:12:15 +00:00
}
2016-01-04 05:31:02 +00:00
void EVNT::write(Athena::io::YAMLDocWriter& writer) const
2015-08-15 04:12:15 +00:00
{
writer.writeUint32("version", version);
writer.writeUint32("loopCount", loopEvents.size());
writer.enumerate("loopEvents", loopEvents);
2016-01-19 05:32:34 +00:00
writer.writeUint32("uevtCount", uevtEvents.size());
writer.enumerate("uevtEvents", uevtEvents);
writer.writeUint32("effectCount", effectEvents.size());
writer.enumerate("effectEvents", effectEvents);
2015-08-15 04:12:15 +00:00
if (version == 2)
{
2016-01-19 05:32:34 +00:00
writer.writeUint32("sfxCount", sfxEvents.size());
writer.enumerate("sfxEvents", sfxEvents);
2015-08-15 04:12:15 +00:00
}
2016-01-19 05:32:34 +00:00
}
2015-08-15 04:12:15 +00:00
2016-01-19 05:32:34 +00:00
const char* EVNT::DNAType()
{
return "Retro::DNAMP1::EVNT";
}
size_t EVNT::binarySize(size_t __isz) const
{
__isz = __EnumerateSize(__isz, loopEvents);
__isz = __EnumerateSize(__isz, uevtEvents);
__isz = __EnumerateSize(__isz, effectEvents);
if (version == 2)
__isz = __EnumerateSize(__isz, sfxEvents);
2015-08-15 04:12:15 +00:00
2016-01-19 05:32:34 +00:00
return __isz + (version == 2 ? 20 : 16);
2015-08-15 04:12:15 +00:00
}
}
}