YAML RAII refactor

This commit is contained in:
Jack Andersen 2017-02-12 13:56:03 -10:00
parent 1b8baca988
commit 748e81ae6e
29 changed files with 1314 additions and 1842 deletions

View File

@ -81,7 +81,8 @@ void CRSM<IDType>::read(athena::io::YAMLDocReader& r)
continue;
}
r.enterSubRecord(elem.first.c_str());
if (auto rec = r.enterSubRecord(elem.first.c_str()))
{
FourCC clsId(elem.first.c_str());
auto gen = std::find_if(GeneratorTypes.begin(), GeneratorTypes.end(), [&clsId](const FourCC& other) -> bool{
return clsId == other;
@ -89,7 +90,6 @@ void CRSM<IDType>::read(athena::io::YAMLDocReader& r)
if (gen != GeneratorTypes.end())
{
x0_generators[clsId].read(r);
r.leaveSubRecord();
continue;
}
@ -99,7 +99,6 @@ void CRSM<IDType>::read(athena::io::YAMLDocReader& r)
if (sfx != SFXTypes.end())
{
x10_sfx[clsId] = r.readInt32(clsId.toString().c_str());
r.leaveSubRecord();
continue;
}
@ -109,15 +108,13 @@ void CRSM<IDType>::read(athena::io::YAMLDocReader& r)
if (decal != DecalTypes.end())
{
x20_decals[clsId].read(r);
r.leaveSubRecord();
continue;
}
if (clsId == SBIG('RNGE'))
x30_RNGE = r.readFloat(nullptr);
else if (clsId == SBIG('FOFF'))
x34_FOFF = r.readFloat(nullptr);
r.leaveSubRecord();
}
}
}
@ -125,30 +122,18 @@ template <class IDType>
void CRSM<IDType>::write(athena::io::YAMLDocWriter& w) const
{
for (const auto& pair : x0_generators)
{
if (pair.second)
{
w.enterSubRecord(pair.first.toString().c_str());
if (auto rec = w.enterSubRecord(pair.first.toString().c_str()))
pair.second.write(w);
w.leaveSubRecord();
}
}
for (const auto& pair : x10_sfx)
{
if (pair.second != ~0)
w.writeUint32(pair.first.toString().c_str(), pair.second);
}
for (const auto& pair : x20_decals)
{
if (pair.second)
{
w.enterSubRecord(pair.first.toString().c_str());
if (auto rec = w.enterSubRecord(pair.first.toString().c_str()))
pair.second.write(w);
w.leaveSubRecord();
}
}
if (x30_RNGE != 50.f)
w.writeFloat("RNGE", x30_RNGE);

View File

@ -63,21 +63,23 @@ public:
void read(athena::io::YAMLDocReader& reader)
{
size_t count;
reader.enterSubVector(nullptr, count);
if (auto v = reader.enterSubVector(nullptr, count))
{
r = (count >= 1) ? reader.readFloat(nullptr) : 0.f;
g = (count >= 2) ? reader.readFloat(nullptr) : 0.f;
b = (count >= 3) ? reader.readFloat(nullptr) : 0.f;
a = (count >= 4) ? reader.readFloat(nullptr) : 0.f;
reader.leaveSubVector();
}
}
void write(athena::io::YAMLDocWriter& writer) const
{
writer.enterSubVector(nullptr);
if (auto v = writer.enterSubVector(nullptr))
{
writer.writeFloat(nullptr, r);
writer.writeFloat(nullptr, g);
writer.writeFloat(nullptr, b);
writer.writeFloat(nullptr, a);
writer.leaveSubVector();
}
}
size_t binarySize(size_t __isz) const
{return __isz + 4;}

View File

@ -15,7 +15,8 @@ void DPSM<IDType>::read(athena::io::YAMLDocReader& r)
continue;
}
r.enterSubRecord(elem.first.c_str());
if (auto rec = r.enterSubRecord(elem.first.c_str()))
{
bool loadFirstDesc = false;
uint32_t clsId = *reinterpret_cast<const uint32_t*>(elem.first.c_str());
switch(clsId)
@ -65,8 +66,7 @@ void DPSM<IDType>::read(athena::io::YAMLDocReader& r)
x5c_25_DMOO = r.readBool(nullptr);
break;
}
r.leaveSubRecord();
}
}
}
@ -77,41 +77,24 @@ void DPSM<IDType>::write(athena::io::YAMLDocWriter& w) const
writeQuadDecalInfo(w, x1c_quad, false);
if (x38_DMDL)
{
w.enterSubRecord("DMDL");
if (auto rec = w.enterSubRecord("DMDL"))
x38_DMDL.write(w);
w.leaveSubRecord();
}
if (x48_DLFT)
{
w.enterSubRecord("DLFT");
if (auto rec = w.enterSubRecord("DLFT"))
x48_DLFT.write(w);
w.leaveSubRecord();
}
if (x4c_DMOP)
{
w.enterSubRecord("DMOP");
if (auto rec = w.enterSubRecord("DMOP"))
x4c_DMOP.write(w);
w.leaveSubRecord();
}
if (x50_DMRT)
{
w.enterSubRecord("DMRT");
if (auto rec = w.enterSubRecord("DMRT"))
x50_DMRT.write(w);
w.leaveSubRecord();
}
if (x54_DMSC)
{
w.enterSubRecord("DMSC");
if (auto rec = w.enterSubRecord("DMSC"))
x54_DMSC.write(w);
w.leaveSubRecord();
}
if (x58_DMCL)
{
w.enterSubRecord("DMCL");
if (auto rec = w.enterSubRecord("DMCL"))
x54_DMSC.write(w);
w.leaveSubRecord();
}
if (x5c_24_DMAB)
w.writeBool("DMAB", x5c_24_DMAB);
if (x5c_25_DMOO)
@ -160,48 +143,26 @@ void DPSM<IDType>::writeQuadDecalInfo(athena::io::YAMLDocWriter& w,
const typename DPSM<IDType>::SQuadDescr& quad, bool first) const
{
if (quad.x0_LFT)
{
w.enterSubRecord((first ? "1LFT" : "2LFT"));
if (auto rec = w.enterSubRecord((first ? "1LFT" : "2LFT")))
quad.x0_LFT.write(w);
w.leaveSubRecord();
}
if (quad.x4_SZE)
{
w.enterSubRecord((first ? "1SZE" : "2SZE"));
if (auto rec = w.enterSubRecord((first ? "1SZE" : "2SZE")))
quad.x4_SZE.write(w);
w.leaveSubRecord();
}
if (quad.x8_ROT)
{
w.enterSubRecord((first ? "1ROT" : "2ROT"));
if (auto rec = w.enterSubRecord((first ? "1ROT" : "2ROT")))
quad.x8_ROT.write(w);
w.leaveSubRecord();
}
if (quad.xc_OFF)
{
w.enterSubRecord((first ? "1OFF" : "2OFF"));
if (auto rec = w.enterSubRecord((first ? "1OFF" : "2OFF")))
quad.xc_OFF.write(w);
w.leaveSubRecord();
}
if (quad.x10_CLR)
{
w.enterSubRecord((first ? "1CLR" : "2CLR"));
if (auto rec = w.enterSubRecord((first ? "1CLR" : "2CLR")))
quad.x10_CLR.write(w);
w.leaveSubRecord();
}
if (quad.x14_TEX)
{
w.enterSubRecord((first ? "1TEX" : "2TEX"));
if (auto rec = w.enterSubRecord((first ? "1TEX" : "2TEX")))
quad.x14_TEX.write(w);
w.leaveSubRecord();
}
if (quad.x18_ADD)
{
w.enterSubRecord((first ? "1ADD" : "2ADD"));
if (auto rec = w.enterSubRecord((first ? "1ADD" : "2ADD")))
quad.x18_ADD.write(w);
w.leaveSubRecord();
}
}
template <class IDType>

View File

@ -84,125 +84,65 @@ template <class IDType>
void ELSM<IDType>::write(athena::io::YAMLDocWriter& w) const
{
if (x0_LIFE)
{
w.enterSubRecord("LIFE");
if (auto rec = w.enterSubRecord("LIFE"))
x0_LIFE.write(w);
w.leaveSubRecord();
}
if (x4_SLIF)
{
w.enterSubRecord("SLIF");
if (auto rec = w.enterSubRecord("SLIF"))
x4_SLIF.write(w);
w.leaveSubRecord();
}
if (x8_GRAT)
{
w.enterSubRecord("GRAT");
if (auto rec = w.enterSubRecord("GRAT"))
x8_GRAT.write(w);
w.leaveSubRecord();
}
if (xc_SCNT)
{
w.enterSubRecord("SCNT");
if (auto rec = w.enterSubRecord("SCNT"))
xc_SCNT.write(w);
w.leaveSubRecord();
}
if (x10_SSEG)
{
w.enterSubRecord("SSEG");
if (auto rec = w.enterSubRecord("SSEG"))
x10_SSEG.write(w);
w.leaveSubRecord();
}
if (x14_COLR)
{
w.enterSubRecord("COLR");
if (auto rec = w.enterSubRecord("COLR"))
x14_COLR.write(w);
w.leaveSubRecord();
}
if (x18_IEMT)
{
w.enterSubRecord("IEMT");
if (auto rec = w.enterSubRecord("IEMT"))
x18_IEMT.write(w);
w.leaveSubRecord();
}
if (x1c_FEMT)
{
w.enterSubRecord("FEMT");
if (auto rec = w.enterSubRecord("FEMT"))
x1c_FEMT.write(w);
w.leaveSubRecord();
}
if (x20_AMPL)
{
w.enterSubRecord("AMPL");
if (auto rec = w.enterSubRecord("AMPL"))
x20_AMPL.write(w);
w.leaveSubRecord();
}
if (x24_AMPD)
{
w.enterSubRecord("AMPD");
if (auto rec = w.enterSubRecord("AMPD"))
x24_AMPD.write(w);
w.leaveSubRecord();
}
if (x28_LWD1)
{
w.enterSubRecord("LWD1");
if (auto rec = w.enterSubRecord("LWD1"))
x28_LWD1.write(w);
w.leaveSubRecord();
}
if (x2c_LWD2)
{
w.enterSubRecord("LWD2");
if (auto rec = w.enterSubRecord("LWD2"))
x2c_LWD2.write(w);
w.leaveSubRecord();
}
if (x30_LWD3)
{
w.enterSubRecord("LWD3");
if (auto rec = w.enterSubRecord("LWD3"))
x30_LWD3.write(w);
w.leaveSubRecord();
}
if (x34_LCL1)
{
w.enterSubRecord("LCL1");
if (auto rec = w.enterSubRecord("LCL1"))
x34_LCL1.write(w);
w.leaveSubRecord();
}
if (x38_LCL2)
{
w.enterSubRecord("LCL2");
if (auto rec = w.enterSubRecord("LCL2"))
x38_LCL2.write(w);
w.leaveSubRecord();
}
if (x3c_LCL3)
{
w.enterSubRecord("LCL3");
if (auto rec = w.enterSubRecord("LCL3"))
x3c_LCL3.write(w);
w.leaveSubRecord();
}
if (x40_SSWH)
{
w.enterSubRecord("SSWH");
if (auto rec = w.enterSubRecord("SSWH"))
x40_SSWH.write(w);
w.leaveSubRecord();
}
if (x50_GPSM)
{
w.enterSubRecord("GPSM");
if (auto rec = w.enterSubRecord("GPSM"))
x50_GPSM.write(w);
w.leaveSubRecord();
}
if (x60_EPSM)
{
w.enterSubRecord("EPSM");
if (auto rec = w.enterSubRecord("EPSM"))
x60_EPSM.write(w);
w.leaveSubRecord();
}
if (x70_ZERY)
{
w.enterSubRecord("ZERY");
if (auto rec = w.enterSubRecord("ZERY"))
x70_ZERY.write(w);
w.leaveSubRecord();
}
}
template <class IDType>

View File

@ -186,7 +186,8 @@ void FONT<IDType>::read(athena::io::YAMLDocReader& __dna_docin)
/* glyphCount */
/* glyphs */
size_t count;
__dna_docin.enterSubVector("glyphs", count);
if (auto v = __dna_docin.enterSubVector("glyphs", count))
{
glyphCount = count;
for (atUint32 i = 0; i < glyphCount; i++)
{
@ -195,11 +196,10 @@ void FONT<IDType>::read(athena::io::YAMLDocReader& __dna_docin)
else
glyphs.emplace_back(new GlyphMP2);
__dna_docin.enterSubRecord(nullptr);
if (auto rec = __dna_docin.enterSubRecord(nullptr))
glyphs.back()->read(__dna_docin);
__dna_docin.leaveSubRecord();
}
__dna_docin.leaveSubVector();
}
/* kerningInfoCount squelched */
/* kerningInfo */
kerningInfoCount = __dna_docin.enumerate("kerningInfo", kerningInfo);
@ -234,16 +234,10 @@ void FONT<IDType>::write(athena::io::YAMLDocWriter& __dna_docout) const
__dna_docout.writeUint32("textureFormat", textureFormat);
/* glyphCount squelched */
/* glyphs */
__dna_docout.enterSubVector("glyphs");
if (auto v = __dna_docout.enterSubVector("glyphs"))
for (const std::unique_ptr<IGlyph>& glyph : glyphs)
{
__dna_docout.enterSubRecord(nullptr);
if (auto rec = __dna_docout.enterSubRecord(nullptr))
glyph->write(__dna_docout);
__dna_docout.leaveSubRecord();
}
__dna_docout.leaveSubVector();
/* kerningInfoCount squelched */
/* kerningInfo */
__dna_docout.enumerate("kerningInfo", kerningInfo);

View File

@ -207,18 +207,20 @@ void PAKRouter<BRIDGETYPE>::build(std::vector<BRIDGETYPE>& bridges, std::functio
{
if (namedEntry.name == "holo_cinf")
continue; /* Problematic corner case */
catalogWriter.enterSubRecord(namedEntry.name.c_str());
if (auto rec = catalogWriter.enterSubRecord(namedEntry.name.c_str()))
{
hecl::ProjectPath working = getWorking(namedEntry.id);
if (working.getAuxInfoUTF8().size())
{
catalogWriter.enterSubVector(nullptr);
if (auto v = catalogWriter.enterSubVector(nullptr))
{
catalogWriter.writeString(nullptr, working.getRelativePathUTF8().c_str());
catalogWriter.writeString(nullptr, working.getAuxInfoUTF8().c_str());
catalogWriter.leaveSubVector();
}
}
else
catalogWriter.writeString(nullptr, working.getRelativePathUTF8().c_str());
catalogWriter.leaveSubRecord();
}
}
/* Write catalog */

View File

@ -16,7 +16,8 @@ void GPSM<IDType>::read(athena::io::YAMLDocReader& r)
continue;
}
r.enterSubRecord(elem.first.c_str());
if (auto rec = r.enterSubRecord(elem.first.c_str()))
{
switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
{
case SBIG('PMCL'):
@ -262,7 +263,7 @@ void GPSM<IDType>::read(athena::io::YAMLDocReader& r)
default:
break;
}
r.leaveSubRecord();
}
}
}
@ -270,107 +271,56 @@ template <class IDType>
void GPSM<IDType>::write(athena::io::YAMLDocWriter& w) const
{
if (x0_PSIV)
{
w.enterSubRecord("PSIV");
if (auto rec = w.enterSubRecord("PSIV"))
x0_PSIV.write(w);
w.leaveSubRecord();
}
if (x4_PSVM)
{
w.enterSubRecord("PSVM");
if (auto rec = w.enterSubRecord("PSVM"))
x4_PSVM.write(w);
w.leaveSubRecord();
}
if (x8_PSOV)
{
w.enterSubRecord("PSOV");
if (auto rec = w.enterSubRecord("PSOV"))
x8_PSOV.write(w);
w.leaveSubRecord();
}
if (xc_PSLT)
{
w.enterSubRecord("PSLT");
if (auto rec = w.enterSubRecord("PSLT"))
xc_PSLT.write(w);
w.leaveSubRecord();
}
if (x10_PSWT)
{
w.enterSubRecord("PSWT");
if (auto rec = w.enterSubRecord("PSWT"))
x10_PSWT.write(w);
w.leaveSubRecord();
}
if (x14_PSTS)
{
w.enterSubRecord("PSTS");
if (auto rec = w.enterSubRecord("PSTS"))
x14_PSTS.write(w);
w.leaveSubRecord();
}
if (x18_POFS)
{
w.enterSubRecord("POFS");
if (auto rec = w.enterSubRecord("POFS"))
x18_POFS.write(w);
w.leaveSubRecord();
}
if (x1c_SEED)
{
w.enterSubRecord("SEED");
if (auto rec = w.enterSubRecord("SEED"))
x1c_SEED.write(w);
w.leaveSubRecord();
}
if (x20_LENG)
{
w.enterSubRecord("LENG");
if (auto rec = w.enterSubRecord("LENG"))
x20_LENG.write(w);
w.leaveSubRecord();
}
if (x24_WIDT)
{
w.enterSubRecord("WIDT");
if (auto rec = w.enterSubRecord("WIDT"))
x24_WIDT.write(w);
w.leaveSubRecord();
}
if (x28_MAXP)
{
w.enterSubRecord("MAXP");
if (auto rec = w.enterSubRecord("MAXP"))
x28_MAXP.write(w);
w.leaveSubRecord();
}
if (x2c_GRTE)
{
w.enterSubRecord("GRTE");
if (auto rec = w.enterSubRecord("GRTE"))
x2c_GRTE.write(w);
w.leaveSubRecord();
}
if (x30_COLR)
{
w.enterSubRecord("COLR");
if (auto rec = w.enterSubRecord("COLR"))
x30_COLR.write(w);
w.leaveSubRecord();
}
if (x34_LTME)
{
w.enterSubRecord("LTME");
if (auto rec = w.enterSubRecord("LTME"))
x34_LTME.write(w);
w.leaveSubRecord();
}
if (x38_ILOC)
{
w.enterSubRecord("ILOC");
if (auto rec = w.enterSubRecord("ILOC"))
x38_ILOC.write(w);
w.leaveSubRecord();
}
if (x3c_IVEC)
{
w.enterSubRecord("IVEC");
if (auto rec = w.enterSubRecord("IVEC"))
x3c_IVEC.write(w);
w.leaveSubRecord();
}
if (x40_EMTR)
{
w.enterSubRecord("EMTR");
if (auto rec = w.enterSubRecord("EMTR"))
x40_EMTR.write(w);
w.leaveSubRecord();
}
if (x44_24_LINE)
w.writeBool("LINE", true);
if (x44_25_FXLL)
@ -408,281 +358,143 @@ void GPSM<IDType>::write(athena::io::YAMLDocWriter& w) const
if (x30_31_RSOP)
w.writeBool("RSOP", true);
if (x48_MBSP)
{
w.enterSubRecord("MPSB");
if (auto rec = w.enterSubRecord("MPSB"))
x48_MBSP.write(w);
w.leaveSubRecord();
}
if (x4c_SIZE)
{
w.enterSubRecord("SIZE");
if (auto rec = w.enterSubRecord("SIZE"))
x4c_SIZE.write(w);
w.leaveSubRecord();
}
if (x50_ROTA)
{
w.enterSubRecord("ROTA");
if (auto rec = w.enterSubRecord("ROTA"))
x50_ROTA.write(w);
w.leaveSubRecord();
}
if (x54_TEXR)
{
w.enterSubRecord("TEXR");
if (auto rec = w.enterSubRecord("TEXR"))
x54_TEXR.write(w);
w.leaveSubRecord();
}
if (x58_TIND)
{
w.enterSubRecord("TIND");
if (auto rec = w.enterSubRecord("TIND"))
x58_TIND.write(w);
w.leaveSubRecord();
}
if (x5c_PMDL)
{
w.enterSubRecord("PMDL");
if (auto rec = w.enterSubRecord("PMDL"))
x5c_PMDL.write(w);
w.leaveSubRecord();
}
if (x6c_PMOP)
{
w.enterSubRecord("PMOP");
if (auto rec = w.enterSubRecord("PMOP"))
x6c_PMOP.write(w);
w.leaveSubRecord();
}
if (x70_PMRT)
{
w.enterSubRecord("PMRT");
if (auto rec = w.enterSubRecord("PMRT"))
x70_PMRT.write(w);
w.leaveSubRecord();
}
if (x74_PMSC)
{
w.enterSubRecord("PMSC");
if (auto rec = w.enterSubRecord("PMSC"))
x74_PMSC.write(w);
w.leaveSubRecord();
}
if (x78_PMCL)
{
w.enterSubRecord("PMCL");
if (auto rec = w.enterSubRecord("PMCL"))
x78_PMCL.write(w);
w.leaveSubRecord();
}
if (x7c_VEL1)
{
w.enterSubRecord("VEL1");
if (auto rec = w.enterSubRecord("VEL1"))
x7c_VEL1.write(w);
w.leaveSubRecord();
}
if (x80_VEL2)
{
w.enterSubRecord("VEL2");
if (auto rec = w.enterSubRecord("VEL2"))
x80_VEL2.write(w);
w.leaveSubRecord();
}
if (x84_VEL3)
{
w.enterSubRecord("VEL3");
if (auto rec = w.enterSubRecord("VEL3"))
x84_VEL3.write(w);
w.leaveSubRecord();
}
if (x88_VEL4)
{
w.enterSubRecord("VEL4");
if (auto rec = w.enterSubRecord("VEL4"))
x88_VEL4.write(w);
w.leaveSubRecord();
}
if (x8c_ICTS)
{
w.enterSubRecord("ICTS");
if (auto rec = w.enterSubRecord("ICTS"))
x8c_ICTS.write(w);
w.leaveSubRecord();
}
if (x9c_NCSY)
{
w.enterSubRecord("NCSY");
if (auto rec = w.enterSubRecord("NCSY"))
x9c_NCSY.write(w);
w.leaveSubRecord();
}
if (xa0_CSSD)
{
w.enterSubRecord("CSSD");
if (auto rec = w.enterSubRecord("CSSD"))
xa0_CSSD.write(w);
w.leaveSubRecord();
}
if (xa4_IDTS)
{
w.enterSubRecord("IDTS");
if (auto rec = w.enterSubRecord("IDTS"))
xa4_IDTS.write(w);
w.leaveSubRecord();
}
if (xb4_NDSY)
{
w.enterSubRecord("NDSY");
if (auto rec = w.enterSubRecord("NDSY"))
xb4_NDSY.write(w);
w.leaveSubRecord();
}
if (xb8_IITS)
{
w.enterSubRecord("IITS");
if (auto rec = w.enterSubRecord("IITS"))
xb8_IITS.write(w);
w.leaveSubRecord();
}
if (xc8_PISY)
{
w.enterSubRecord("PISY");
if (auto rec = w.enterSubRecord("PISY"))
xc8_PISY.write(w);
w.leaveSubRecord();
}
if (xcc_SISY)
{
w.enterSubRecord("SISY");
if (auto rec = w.enterSubRecord("SISY"))
xcc_SISY.write(w);
w.leaveSubRecord();
}
if (xd0_KSSM)
{
w.enterSubRecord("KSSM");
if (auto rec = w.enterSubRecord("KSSM"))
xd0_KSSM.write(w);
w.leaveSubRecord();
}
if (xd4_SSWH)
{
w.enterSubRecord("SSWH");
if (auto rec = w.enterSubRecord("SSWH"))
xd4_SSWH.write(w);
w.leaveSubRecord();
}
if (xd8_SELC)
{
w.enterSubRecord("SELC");
if (auto rec = w.enterSubRecord("SELC"))
xd8_SELC.write(w);
w.leaveSubRecord();
}
if (xe4_SSSD)
{
w.enterSubRecord("SSSD");
if (auto rec = w.enterSubRecord("SSSD"))
xe4_SSSD.write(w);
w.leaveSubRecord();
}
if (xe8_SSPO)
{
w.enterSubRecord("SSPO");
if (auto rec = w.enterSubRecord("SSPO"))
xe8_SSPO.write(w);
w.leaveSubRecord();
}
if (xf8_SESD)
{
w.enterSubRecord("SESD");
if (auto rec = w.enterSubRecord("SESD"))
xf8_SESD.write(w);
w.leaveSubRecord();
}
if (xfc_SEPO)
{
w.enterSubRecord("SEPO");
if (auto rec = w.enterSubRecord("SEPO"))
xfc_SEPO.write(w);
w.leaveSubRecord();
}
if (xec_PMLC)
{
w.enterSubRecord("PMLC");
if (auto rec = w.enterSubRecord("PMLC"))
xec_PMLC.write(w);
w.leaveSubRecord();
}
if (x100_LTYP)
{
w.enterSubRecord("LTYP");
if (auto rec = w.enterSubRecord("LTYP"))
x100_LTYP.write(w);
w.leaveSubRecord();
}
if (x104_LCLR)
{
w.enterSubRecord("LCLR");
if (auto rec = w.enterSubRecord("LCLR"))
x104_LCLR.write(w);
w.leaveSubRecord();
}
if (x108_LINT)
{
w.enterSubRecord("LINT");
if (auto rec = w.enterSubRecord("LINT"))
x108_LINT.write(w);
w.leaveSubRecord();
}
if (x10c_LOFF)
{
w.enterSubRecord("LOFF");
if (auto rec = w.enterSubRecord("LOFF"))
x10c_LOFF.write(w);
w.leaveSubRecord();
}
if (x110_LDIR)
{
w.enterSubRecord("LDIR");
if (auto rec = w.enterSubRecord("LDIR"))
x110_LDIR.write(w);
w.leaveSubRecord();
}
if (x114_LFOT)
{
w.enterSubRecord("LFOT");
if (auto rec = w.enterSubRecord("LFOT"))
x114_LFOT.write(w);
w.leaveSubRecord();
}
if (x118_LFOR)
{
w.enterSubRecord("LFOR");
if (auto rec = w.enterSubRecord("LFOR"))
x118_LFOR.write(w);
w.leaveSubRecord();
}
if (x11c_LSLA)
{
w.enterSubRecord("LSLA");
if (auto rec = w.enterSubRecord("LSLA"))
x11c_LSLA.write(w);
w.leaveSubRecord();
}
if (x10c_ADV1)
{
w.enterSubRecord("ADV1");
if (auto rec = w.enterSubRecord("ADV1"))
x10c_ADV1.write(w);
w.leaveSubRecord();
}
if (x110_ADV2)
{
w.enterSubRecord("ADV2");
if (auto rec = w.enterSubRecord("ADV2"))
x110_ADV2.write(w);
w.leaveSubRecord();
}
if (x114_ADV3)
{
w.enterSubRecord("ADV3");
if (auto rec = w.enterSubRecord("ADV3"))
x114_ADV3.write(w);
w.leaveSubRecord();
}
if (x118_ADV4)
{
w.enterSubRecord("ADV4");
if (auto rec = w.enterSubRecord("ADV4"))
x118_ADV4.write(w);
w.leaveSubRecord();
}
if (x11c_ADV5)
{
w.enterSubRecord("ADV5");
if (auto rec = w.enterSubRecord("ADV5"))
x11c_ADV5.write(w);
w.leaveSubRecord();
}
if (x120_ADV6)
{
w.enterSubRecord("ADV6");
if (auto rec = w.enterSubRecord("ADV6"))
x120_ADV6.write(w);
w.leaveSubRecord();
}
if (x124_ADV7)
{
w.enterSubRecord("ADV7");
if (auto rec = w.enterSubRecord("ADV7"))
x124_ADV7.write(w);
w.leaveSubRecord();
}
if (x128_ADV8)
{
w.enterSubRecord("ADV8");
if (auto rec = w.enterSubRecord("ADV8"))
x128_ADV8.write(w);
w.leaveSubRecord();
}
}
template <class IDType>

View File

@ -125,19 +125,15 @@ void RealElementFactory::read(athena::io::YAMLDocReader& r)
m_elem.reset();
return;
}
r.enterSubRecord(elem.first.c_str());
if (auto rec = r.enterSubRecord(elem.first.c_str()))
m_elem->read(r);
r.leaveSubRecord();
}
void RealElementFactory::write(athena::io::YAMLDocWriter& w) const
{
if (m_elem)
{
w.enterSubRecord(m_elem->ClassID());
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
m_elem->write(w);
w.leaveSubRecord();
}
}
size_t RealElementFactory::binarySize(size_t __isz) const
@ -348,19 +344,15 @@ void IntElementFactory::read(athena::io::YAMLDocReader& r)
m_elem.reset();
return;
}
r.enterSubRecord(elem.first.c_str());
if (auto rec = r.enterSubRecord(elem.first.c_str()))
m_elem->read(r);
r.leaveSubRecord();
}
void IntElementFactory::write(athena::io::YAMLDocWriter& w) const
{
if (m_elem)
{
w.enterSubRecord(m_elem->ClassID());
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
m_elem->write(w);
w.leaveSubRecord();
}
}
size_t IntElementFactory::binarySize(size_t __isz) const
@ -522,19 +514,15 @@ void VectorElementFactory::read(athena::io::YAMLDocReader& r)
m_elem.reset();
return;
}
r.enterSubRecord(elem.first.c_str());
if (auto rec = r.enterSubRecord(elem.first.c_str()))
m_elem->read(r);
r.leaveSubRecord();
}
void VectorElementFactory::write(athena::io::YAMLDocWriter& w) const
{
if (m_elem)
{
w.enterSubRecord(m_elem->ClassID());
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
m_elem->write(w);
w.leaveSubRecord();
}
}
size_t VectorElementFactory::binarySize(size_t __isz) const
@ -664,19 +652,15 @@ void ColorElementFactory::read(athena::io::YAMLDocReader& r)
m_elem.reset();
return;
}
r.enterSubRecord(elem.first.c_str());
if (auto rec = r.enterSubRecord(elem.first.c_str()))
m_elem->read(r);
r.leaveSubRecord();
}
void ColorElementFactory::write(athena::io::YAMLDocWriter& w) const
{
if (m_elem)
{
w.enterSubRecord(m_elem->ClassID());
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
m_elem->write(w);
w.leaveSubRecord();
}
}
size_t ColorElementFactory::binarySize(size_t __isz) const
@ -790,19 +774,15 @@ void ModVectorElementFactory::read(athena::io::YAMLDocReader& r)
m_elem.reset();
return;
}
r.enterSubRecord(elem.first.c_str());
if (auto rec = r.enterSubRecord(elem.first.c_str()))
m_elem->read(r);
r.leaveSubRecord();
}
void ModVectorElementFactory::write(athena::io::YAMLDocWriter& w) const
{
if (m_elem)
{
w.enterSubRecord(m_elem->ClassID());
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
m_elem->write(w);
w.leaveSubRecord();
}
}
size_t ModVectorElementFactory::binarySize(size_t __isz) const
@ -909,19 +889,15 @@ void EmitterElementFactory::read(athena::io::YAMLDocReader& r)
m_elem.reset();
return;
}
r.enterSubRecord(elem.first.c_str());
if (auto rec = r.enterSubRecord(elem.first.c_str()))
m_elem->read(r);
r.leaveSubRecord();
}
void EmitterElementFactory::write(athena::io::YAMLDocWriter& w) const
{
if (m_elem)
{
w.enterSubRecord(m_elem->ClassID());
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
m_elem->write(w);
w.leaveSubRecord();
}
}
size_t EmitterElementFactory::binarySize(size_t __isz) const

View File

@ -631,25 +631,21 @@ struct VEConstant : IVectorElement
void read(athena::io::YAMLDocReader& r)
{
size_t elemCount;
r.enterSubVector(nullptr, elemCount);
if (auto v = r.enterSubVector(nullptr, elemCount))
{
for (int i=0 ; i<3 && i<elemCount ; ++i)
{
r.enterSubRecord(nullptr);
if (auto rec = r.enterSubRecord(nullptr))
comps[i].read(r);
r.leaveSubRecord();
}
r.leaveSubVector();
}
}
void write(athena::io::YAMLDocWriter& w) const
{
w.enterSubVector(nullptr);
if (auto v = w.enterSubVector(nullptr))
for (int i=0 ; i<3 ; ++i)
{
w.enterSubRecord(nullptr);
if (auto rec = w.enterSubRecord(nullptr))
comps[i].write(w);
w.leaveSubRecord();
}
w.leaveSubVector();
}
size_t binarySize(size_t __isz) const
{
@ -782,22 +778,15 @@ struct CEConstant : IColorElement
void read(athena::io::YAMLDocReader& r)
{
for (int i=0 ; i<4 ; ++i)
{
r.enterSubRecord(nullptr);
if (auto rec = r.enterSubRecord(nullptr))
comps[i].read(r);
r.leaveSubRecord();
}
}
void write(athena::io::YAMLDocWriter& w) const
{
w.enterSubVector(nullptr);
if (auto v = w.enterSubVector(nullptr))
for (int i=0 ; i<4 ; ++i)
{
w.enterSubRecord(nullptr);
if (auto rec = w.enterSubRecord(nullptr))
comps[i].write(w);
w.leaveSubRecord();
}
w.leaveSubVector();
}
size_t binarySize(size_t __isz) const
{
@ -912,22 +901,15 @@ struct MVEConstant : IModVectorElement
void read(athena::io::YAMLDocReader& r)
{
for (int i=0 ; i<3 ; ++i)
{
r.enterSubRecord(nullptr);
if (auto rec = r.enterSubRecord(nullptr))
comps[i].read(r);
r.leaveSubRecord();
}
}
void write(athena::io::YAMLDocWriter& w) const
{
w.enterSubVector(nullptr);
if (auto v = w.enterSubVector(nullptr))
for (int i=0 ; i<3 ; ++i)
{
w.enterSubRecord(nullptr);
if (auto rec = w.enterSubRecord(nullptr))
comps[i].write(w);
w.leaveSubRecord();
}
w.leaveSubVector();
}
size_t binarySize(size_t __isz) const
{
@ -1050,25 +1032,17 @@ struct EESimpleEmitterTR : EESimpleEmitter
{
position.m_elem.reset();
velocity.m_elem.reset();
if (r.enterSubRecord("ILOC"))
{
if (auto rec = r.enterSubRecord("ILOC"))
position.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("IVEC"))
{
if (auto rec = r.enterSubRecord("IVEC"))
velocity.read(r);
r.leaveSubRecord();
}
}
void write(athena::io::YAMLDocWriter& w) const
{
w.enterSubRecord("ILOC");
if (auto rec = w.enterSubRecord("ILOC"))
position.write(w);
w.leaveSubRecord();
w.enterSubRecord("IVEC");
if (auto rec = w.enterSubRecord("IVEC"))
velocity.write(w);
w.leaveSubRecord();
}
size_t binarySize(size_t __isz) const
{
@ -1109,17 +1083,13 @@ struct UVEConstant : IUVElement
void read(athena::io::YAMLDocReader& r)
{
tex.clear();
if (r.enterSubRecord("tex"))
{
if (auto rec = r.enterSubRecord("tex"))
tex.read(r);
r.leaveSubRecord();
}
}
void write(athena::io::YAMLDocWriter& w) const
{
w.enterSubRecord("tex");
if (auto rec = w.enterSubRecord("tex"))
tex.write(w);
w.leaveSubRecord();
}
size_t binarySize(size_t __isz) const
{
@ -1160,62 +1130,35 @@ struct UVEAnimTexture : IUVElement
void read(athena::io::YAMLDocReader& r)
{
tex.clear();
if (r.enterSubRecord("tex"))
{
if (auto rec = r.enterSubRecord("tex"))
tex.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("tileW"))
{
if (auto rec = r.enterSubRecord("tileW"))
tileW.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("tileH"))
{
if (auto rec = r.enterSubRecord("tileH"))
tileH.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("strideW"))
{
if (auto rec = r.enterSubRecord("strideW"))
strideW.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("strideH"))
{
if (auto rec = r.enterSubRecord("strideH"))
strideH.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("cycleFrames"))
{
if (auto rec = r.enterSubRecord("cycleFrames"))
cycleFrames.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("loop"))
{
if (auto rec = r.enterSubRecord("loop"))
loop = r.readBool(nullptr);
r.leaveSubRecord();
}
}
void write(athena::io::YAMLDocWriter& w) const
{
w.enterSubRecord("tex");
if (auto rec = w.enterSubRecord("tex"))
tex.write(w);
w.leaveSubRecord();
w.enterSubRecord("tileW");
if (auto rec = w.enterSubRecord("tileW"))
tileW.write(w);
w.leaveSubRecord();
w.enterSubRecord("tileH");
if (auto rec = w.enterSubRecord("tileH"))
tileH.write(w);
w.leaveSubRecord();
w.enterSubRecord("strideW");
if (auto rec = w.enterSubRecord("strideW"))
strideW.write(w);
w.leaveSubRecord();
w.enterSubRecord("strideH");
if (auto rec = w.enterSubRecord("strideH"))
strideH.write(w);
w.leaveSubRecord();
w.enterSubRecord("cycleFrames");
if (auto rec = w.enterSubRecord("cycleFrames"))
cycleFrames.write(w);
w.leaveSubRecord();
w.writeBool("loop", loop);
}
size_t binarySize(size_t __isz) const
@ -1274,17 +1217,15 @@ struct UVElementFactory : BigYAML
void read(athena::io::YAMLDocReader& r)
{
if (r.enterSubRecord("CNST"))
if (auto rec = r.enterSubRecord("CNST"))
{
m_elem.reset(new struct UVEConstant<IDType>);
m_elem->read(r);
r.leaveSubRecord();
}
else if (r.enterSubRecord("ATEX"))
else if (auto rec = r.enterSubRecord("ATEX"))
{
m_elem.reset(new struct UVEAnimTexture<IDType>);
m_elem->read(r);
r.leaveSubRecord();
}
else
m_elem.reset();
@ -1293,11 +1234,8 @@ struct UVElementFactory : BigYAML
void write(athena::io::YAMLDocWriter& w) const
{
if (m_elem)
{
w.enterSubRecord(m_elem->ClassID());
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
m_elem->write(w);
w.leaveSubRecord();
}
}
size_t binarySize(size_t __isz) const
@ -1358,32 +1296,19 @@ struct SpawnSystemKeyframeData : BigYAML
void read(athena::io::YAMLDocReader& r)
{
if (r.enterSubRecord("id"))
{
if (auto rec = r.enterSubRecord("id"))
id.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("a"))
{
if (auto rec = r.enterSubRecord("a"))
a = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("b"))
{
if (auto rec = r.enterSubRecord("b"))
b = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("c"))
{
if (auto rec = r.enterSubRecord("c"))
c = r.readUint32(nullptr);
r.leaveSubRecord();
}
}
void write(athena::io::YAMLDocWriter& w) const
{
w.enterSubRecord("id");
if (auto rec = w.enterSubRecord("id"))
id.write(w);
w.leaveSubRecord();
w.writeUint32("a", a);
w.writeUint32("b", b);
w.writeUint32("c", c);
@ -1412,55 +1337,39 @@ struct SpawnSystemKeyframeData : BigYAML
void read(athena::io::YAMLDocReader& r)
{
if (r.enterSubRecord("a"))
{
if (auto rec = r.enterSubRecord("a"))
a = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("b"))
{
if (auto rec = r.enterSubRecord("b"))
b = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("endFrame"))
{
if (auto rec = r.enterSubRecord("endFrame"))
endFrame = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("d"))
{
if (auto rec = r.enterSubRecord("d"))
d = r.readUint32(nullptr);
r.leaveSubRecord();
}
spawns.clear();
size_t spawnCount;
if (r.enterSubVector("spawns", spawnCount))
if (auto v = r.enterSubVector("spawns", spawnCount))
{
spawns.reserve(spawnCount);
for (const auto& child : r.getCurNode()->m_seqChildren)
{
if (r.enterSubRecord(nullptr))
if (auto rec = r.enterSubRecord(nullptr))
{
spawns.emplace_back();
spawns.back().first = r.readUint32("startFrame");
size_t systemCount;
if (r.enterSubVector("systems", systemCount))
if (auto v = r.enterSubVector("systems", systemCount))
{
spawns.back().second.reserve(systemCount);
for (const auto& in : r.getCurNode()->m_seqChildren)
{
spawns.back().second.emplace_back();
SpawnSystemKeyframeInfo& info = spawns.back().second.back();
r.enterSubRecord(nullptr);
if (auto rec = r.enterSubRecord(nullptr))
info.read(r);
r.leaveSubRecord();
}
r.leaveSubVector();
}
r.leaveSubRecord();
}
}
r.leaveSubVector();
}
}
}
}
void write(athena::io::YAMLDocWriter& w) const
@ -1471,22 +1380,20 @@ struct SpawnSystemKeyframeData : BigYAML
w.writeUint32("b", b);
w.writeUint32("endFrame", endFrame);
w.writeUint32("d", d);
w.enterSubVector("spawns");
if (auto v = w.enterSubVector("spawns"))
{
for (const auto& spawn : spawns)
{
w.enterSubRecord(nullptr);
w.writeUint32("startFrame", spawn.first);
w.enterSubVector("systems");
for (const auto& info : spawn.second)
if (auto rec = w.enterSubRecord(nullptr))
{
w.enterSubRecord(nullptr);
w.writeUint32("startFrame", spawn.first);
if (auto v = w.enterSubVector("systems"))
for (const auto& info : spawn.second)
if (auto rec = w.enterSubRecord(nullptr))
info.write(w);
w.leaveSubRecord();
}
w.leaveSubVector();
w.leaveSubRecord();
}
w.leaveSubVector();
}
}
size_t binarySize(size_t __isz) const
{
@ -1566,20 +1473,14 @@ struct ChildResourceFactory : BigYAML
void read(athena::io::YAMLDocReader& r)
{
id.clear();
if (r.enterSubRecord("CNST"))
{
if (auto rec = r.enterSubRecord("CNST"))
id.read(r);
r.leaveSubRecord();
}
}
void write(athena::io::YAMLDocWriter& w) const
{
if (id)
{
w.enterSubRecord("CNST");
if (auto rec = w.enterSubRecord("CNST"))
id.write(w);
w.leaveSubRecord();
}
}
size_t binarySize(size_t __isz) const
{

View File

@ -16,7 +16,8 @@ void SWSH<IDType>::read(athena::io::YAMLDocReader& r)
continue;
}
r.enterSubRecord(elem.first.c_str());
if (auto rec = r.enterSubRecord(elem.first.c_str()))
{
switch(*reinterpret_cast<const uint32_t*>(elem.first.data()))
{
case SBIG('PSLT'):
@ -104,8 +105,7 @@ void SWSH<IDType>::read(athena::io::YAMLDocReader& r)
x45_26_CRND = r.readBool(nullptr);
break;
}
r.leaveSubRecord();
}
}
}
@ -113,107 +113,56 @@ template <class IDType>
void SWSH<IDType>::write(athena::io::YAMLDocWriter& w) const
{
if (x0_PSLT)
{
w.enterSubRecord("PSLT");
if (auto rec = w.enterSubRecord("PSLT"))
x0_PSLT.write(w);
w.leaveSubRecord();
}
if (x4_TIME)
{
w.enterSubRecord("TIME");
if (auto rec = w.enterSubRecord("TIME"))
x4_TIME.write(w);
w.leaveSubRecord();
}
if (x8_LRAD)
{
w.enterSubRecord("LRAD");
if (auto rec = w.enterSubRecord("LRAD"))
x8_LRAD.write(w);
w.leaveSubRecord();
}
if (xc_RRAD)
{
w.enterSubRecord("RRAD");
if (auto rec = w.enterSubRecord("RRAD"))
xc_RRAD.write(w);
w.leaveSubRecord();
}
if (x10_LENG)
{
w.enterSubRecord("LENG");
if (auto rec = w.enterSubRecord("LENG"))
x10_LENG.write(w);
w.leaveSubRecord();
}
if (x14_COLR)
{
w.enterSubRecord("COLR");
if (auto rec = w.enterSubRecord("COLR"))
x14_COLR.write(w);
w.leaveSubRecord();
}
if (x18_SIDE)
{
w.enterSubRecord("SIDE");
if (auto rec = w.enterSubRecord("SIDE"))
x18_SIDE.write(w);
w.leaveSubRecord();
}
if (x1c_IROT)
{
w.enterSubRecord("IROT");
if (auto rec = w.enterSubRecord("IROT"))
x1c_IROT.write(w);
w.leaveSubRecord();
}
if (x20_ROTM)
{
w.enterSubRecord("ROTM");
if (auto rec = w.enterSubRecord("ROTM"))
x20_ROTM.write(w);
w.leaveSubRecord();
}
if (x24_POFS)
{
w.enterSubRecord("POFS");
if (auto rec = w.enterSubRecord("POFS"))
x24_POFS.write(w);
w.leaveSubRecord();
}
if (x28_IVEL)
{
w.enterSubRecord("IVEL");
if (auto rec = w.enterSubRecord("IVEL"))
x28_IVEL.write(w);
w.leaveSubRecord();
}
if (x2c_NPOS)
{
w.enterSubRecord("NPOS");
if (auto rec = w.enterSubRecord("NPOS"))
x2c_NPOS.write(w);
w.leaveSubRecord();
}
if (x30_VELM)
{
w.enterSubRecord("VELM");
if (auto rec = w.enterSubRecord("VELM"))
x30_VELM.write(w);
w.leaveSubRecord();
}
if (x34_VLM2)
{
w.enterSubRecord("VLM2");
if (auto rec = w.enterSubRecord("VLM2"))
x34_VLM2.write(w);
w.leaveSubRecord();
}
if (x38_SPLN)
{
w.enterSubRecord("SPLN");
if (auto rec = w.enterSubRecord("SPLN"))
x38_SPLN.write(w);
w.leaveSubRecord();
}
if (x3c_TEXR)
{
w.enterSubRecord("TEXR");
if (auto rec = w.enterSubRecord("TEXR"))
x3c_TEXR.write(w);
w.leaveSubRecord();
}
if (x40_TSPN)
{
w.enterSubRecord("TSPN");
if (auto rec = w.enterSubRecord("TSPN"))
x40_TSPN.write(w);
w.leaveSubRecord();
}
if (x44_24_LLRD)
w.writeBool("LLRD", true);

View File

@ -16,8 +16,8 @@ void WPSM<IDType>::read(athena::io::YAMLDocReader& r)
continue;
}
r.enterSubRecord(elem.first.c_str());
if (auto rec = r.enterSubRecord(elem.first.c_str()))
{
switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
{
case SBIG('IORN'):
@ -123,8 +123,7 @@ void WPSM<IDType>::read(athena::io::YAMLDocReader& r)
xunk_SPS2.read(r);
break;
}
r.leaveSubRecord();
}
}
}
@ -132,205 +131,106 @@ template <class IDType>
void WPSM<IDType>::write(athena::io::YAMLDocWriter& w) const
{
if (x0_IORN)
{
w.enterSubRecord("IORN");
if (auto rec = w.enterSubRecord("IORN"))
x0_IORN.write(w);
w.leaveSubRecord();
}
if (x4_IVEC)
{
w.enterSubRecord("IVEC");
if (auto rec = w.enterSubRecord("IVEC"))
x4_IVEC.write(w);
w.leaveSubRecord();
}
if (x8_PSOV)
{
w.enterSubRecord("PSOV");
if (auto rec = w.enterSubRecord("PSOV"))
x8_PSOV.write(w);
w.leaveSubRecord();
}
if (xc_PSVM)
{
w.enterSubRecord("PSVM");
if (auto rec = w.enterSubRecord("PSVM"))
xc_PSVM.write(w);
w.leaveSubRecord();
}
if (x10_VMD2)
{
w.enterSubRecord("VMD2");
if (auto rec = w.enterSubRecord("VMD2"))
x10_VMD2.write(w);
w.leaveSubRecord();
}
if (x14_PSLT)
{
w.enterSubRecord("PSLT");
if (auto rec = w.enterSubRecord("PSLT"))
x14_PSLT.write(w);
w.leaveSubRecord();
}
if (x18_PSCL)
{
w.enterSubRecord("PSCL");
if (auto rec = w.enterSubRecord("PSCL"))
x18_PSCL.write(w);
w.leaveSubRecord();
}
if (x1c_PCOL)
{
w.enterSubRecord("PCOL");
if (auto rec = w.enterSubRecord("PCOL"))
x1c_PCOL.write(w);
w.leaveSubRecord();
}
if (x20_POFS)
{
w.enterSubRecord("POFS");
if (auto rec = w.enterSubRecord("POFS"))
x20_POFS.write(w);
w.leaveSubRecord();
}
if (x24_OFST)
{
w.enterSubRecord("OFST");
if (auto rec = w.enterSubRecord("OFST"))
x24_OFST.write(w);
w.leaveSubRecord();
}
if (x28_APSO)
{
w.enterSubRecord("APSO");
if (auto rec = w.enterSubRecord("APSO"))
x28_APSO.write(w);
w.leaveSubRecord();
}
if (x29_HOMG)
{
w.enterSubRecord("HOMG");
if (auto rec = w.enterSubRecord("HOMG"))
x29_HOMG.write(w);
w.leaveSubRecord();
}
if (x2a_AP11)
{
w.enterSubRecord("AP11");
if (auto rec = w.enterSubRecord("AP11"))
x2a_AP11.write(w);
w.leaveSubRecord();
}
if (x2b_AP21)
{
w.enterSubRecord("AP21");
if (auto rec = w.enterSubRecord("AP21"))
x2b_AP21.write(w);
w.leaveSubRecord();
}
if (x2c_AS11)
{
w.enterSubRecord("AS11");
if (auto rec = w.enterSubRecord("AS11"))
x2c_AS11.write(w);
w.leaveSubRecord();
}
if (x2d_AS12)
{
w.enterSubRecord("AS12");
if (auto rec = w.enterSubRecord("AS12"))
x2d_AS12.write(w);
w.leaveSubRecord();
}
if (x2e_AS13)
{
w.enterSubRecord("AS13");
if (auto rec = w.enterSubRecord("AS13"))
x2e_AS13.write(w);
w.leaveSubRecord();
}
if (x30_TRAT)
{
w.enterSubRecord("TRAT");
if (auto rec = w.enterSubRecord("TRAT"))
x30_TRAT.write(w);
w.leaveSubRecord();
}
if (x34_APSM)
{
w.enterSubRecord("APSM");
if (auto rec = w.enterSubRecord("APSM"))
x34_APSM.write(w);
w.leaveSubRecord();
}
if (x44_APS2)
{
w.enterSubRecord("APS2");
if (auto rec = w.enterSubRecord("APS2"))
x44_APS2.write(w);
w.leaveSubRecord();
}
if (x54_ASW1)
{
w.enterSubRecord("ASW1");
if (auto rec = w.enterSubRecord("ASW1"))
x54_ASW1.write(w);
w.leaveSubRecord();
}
if (x64_ASW2)
{
w.enterSubRecord("ASW2");
if (auto rec = w.enterSubRecord("ASW2"))
x64_ASW2.write(w);
w.leaveSubRecord();
}
if (x74_ASW3)
{
w.enterSubRecord("ASW3");
if (auto rec = w.enterSubRecord("ASW3"))
x74_ASW3.write(w);
w.leaveSubRecord();
}
if (x84_OHEF)
{
w.enterSubRecord("OHEF");
if (auto rec = w.enterSubRecord("OHEF"))
x84_OHEF.write(w);
w.leaveSubRecord();
}
if (x94_COLR)
{
w.enterSubRecord("COLR");
if (auto rec = w.enterSubRecord("COLR"))
x94_COLR.write(w);
w.leaveSubRecord();
}
if (!xa4_EWTR)
{
w.enterSubRecord("EWTR");
if (auto rec = w.enterSubRecord("EWTR"))
xa4_EWTR.write(w);
w.leaveSubRecord();
}
if (!xa5_LWTR)
{
w.enterSubRecord("LWTR");
if (auto rec = w.enterSubRecord("LWTR"))
xa5_LWTR.write(w);
w.leaveSubRecord();
}
if (!xa6_SWTR)
{
w.enterSubRecord("SWTR");
if (auto rec = w.enterSubRecord("SWTR"))
xa6_SWTR.write(w);
w.leaveSubRecord();
}
if (xa8_PJFX != ~0)
w.writeUint32("PJFX", xa8_PJFX);
if (xac_RNGE)
{
w.enterSubRecord("RNGE");
if (auto rec = w.enterSubRecord("RNGE"))
xac_RNGE.write(w);
w.leaveSubRecord();
}
if (xb0_FOFF)
{
w.enterSubRecord("FOFF");
if (auto rec = w.enterSubRecord("FOFF"))
xb0_FOFF.write(w);
w.leaveSubRecord();
}
if (xunk_FC60)
{
w.enterSubRecord("FC60");
if (auto rec = w.enterSubRecord("FC60"))
xunk_FC60.write(w);
w.leaveSubRecord();
}
if (xunk_SPS1)
{
w.enterSubRecord("SPS1");
if (auto rec = w.enterSubRecord("SPS1"))
xunk_SPS1.write(w);
w.leaveSubRecord();
}
if (xunk_SPS1)
{
w.enterSubRecord("SPS2");
if (auto rec = w.enterSubRecord("SPS2"))
xunk_SPS2.write(w);
w.leaveSubRecord();
}
}
template <class IDType>

View File

@ -86,7 +86,8 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::read(a
unk1 = reader.readUint32("unk1");
unk2 = reader.readFloat("unk2");
size_t parmValCount;
reader.enterSubVector("parmVals", parmValCount);
if (auto v = reader.enterSubVector("parmVals", parmValCount))
{
switch (DataType(parmType))
{
case DataType::Int32:
@ -108,7 +109,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::read(a
break;
default: break;
}
reader.leaveSubVector();
}
}
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::write(athena::io::YAMLDocWriter& writer) const
@ -116,7 +117,8 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::write(
writer.writeUint32("parmType", parmType);
writer.writeUint32("unk1", unk1);
writer.writeFloat("unk2", unk2);
writer.enterSubVector("parmVals");
if (auto v = writer.enterSubVector("parmVals"))
{
switch (DataType(parmType))
{
case DataType::Int32:
@ -137,7 +139,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::write(
writer.writeBool(nullptr, parmVals[0].bool1);
break;
}
writer.leaveSubVector();
}
}
const char* ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::DNAType()
@ -260,7 +262,8 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::read(athena::io:
ai.id = reader.readUint32("id");
ai.parmVals.reserve(parmInfoCount);
size_t parmValCount;
reader.enterSubVector("parmVals", parmValCount);
if (auto v = reader.enterSubVector("parms", parmValCount))
{
for (const ParmInfo& pi : parmInfos)
{
switch (ParmInfo::DataType(pi.parmType))
@ -281,7 +284,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::read(athena::io:
default: break;
}
}
reader.leaveSubVector();
}
});
}
@ -296,7 +299,8 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::write(athena::io
{
writer.writeUint32("id", ai.id);
auto it = ai.parmVals.begin();
writer.enterSubVector("parms");
if (auto v = writer.enterSubVector("parms"))
{
for (const ParmInfo& pi : parmInfos)
{
ParmInfo::Parm pVal;
@ -320,7 +324,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::write(athena::io
default: break;
}
}
writer.leaveSubVector();
}
});
}

View File

@ -499,12 +499,13 @@ struct ANCS : BigYAML
{
out.clear();
for (const AnimationSet::Animation& ai : animationSet.animations)
ai.metaAnim.m_anim->gatherPrimitives(out);
if (AnimationSet::IMetaAnim* anim = ai.metaAnim.m_anim.get())
anim->gatherPrimitives(out);
for (const AnimationSet::Transition& ti : animationSet.transitions)
if (ti.metaTrans.m_trans)
ti.metaTrans.m_trans->gatherPrimitives(out);
if (animationSet.defaultTransition.m_trans)
animationSet.defaultTransition.m_trans->gatherPrimitives(out);
if (AnimationSet::IMetaTrans* trans = ti.metaTrans.m_trans.get())
trans->gatherPrimitives(out);
if (AnimationSet::IMetaTrans* trans = animationSet.defaultTransition.m_trans.get())
trans->gatherPrimitives(out);
for (auto& anim : out)
{
for (const AnimationSet::AnimationResources& res : animationSet.animResources)
@ -521,10 +522,13 @@ struct ANCS : BigYAML
void enumeratePrimitives(const std::function<bool(AnimationSet::MetaAnimPrimitive& prim)>& func)
{
for (const AnimationSet::Animation& ai : animationSet.animations)
ai.metaAnim.m_anim->enumeratePrimitives(func);
if (AnimationSet::IMetaAnim* anim = ai.metaAnim.m_anim.get())
anim->enumeratePrimitives(func);
for (const AnimationSet::Transition& ti : animationSet.transitions)
ti.metaTrans.m_trans->enumeratePrimitives(func);
animationSet.defaultTransition.m_trans->enumeratePrimitives(func);
if (AnimationSet::IMetaTrans* trans = ti.metaTrans.m_trans.get())
trans->enumeratePrimitives(func);
if (AnimationSet::IMetaTrans* trans = animationSet.defaultTransition.m_trans.get())
trans->enumeratePrimitives(func);
}
static bool Extract(const SpecBase& dataSpec,

View File

@ -18,9 +18,8 @@ bool CSNG::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
athena::io::YAMLDocWriter dw("CSNG");
dw.writeUint32("midiSetupId", head.midiSetupId);
dw.writeUint32("songGroupId", head.songGroupId);
dw.enterSubRecord("agscId");
if (auto rec = dw.enterSubRecord("agscId"))
head.agscId.write(dw);
dw.leaveSubRecord();
athena::io::FileWriter w(yamlPath.getAbsolutePath());
if (w.hasError())
@ -76,9 +75,8 @@ bool CSNG::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat
Header head;
head.midiSetupId = dr.readUint32("midiSetupId");
head.songGroupId = dr.readUint32("songGroupId");
dr.enterSubRecord("agscId");
if (auto rec = dr.enterSubRecord("agscId"))
head.agscId.read(dr);
dr.leaveSubRecord();
head.sngLength = sngData.size();
head.write(w);
}

View File

@ -143,13 +143,14 @@ void SCLY::ScriptLayer::read(athena::io::YAMLDocReader& rs)
unknown = rs.readUByte("unknown");
size_t objCount;
objects.clear();
if (rs.enterSubVector("objects", objCount))
if (auto v = rs.enterSubVector("objects", objCount))
{
objectCount = objCount;
objects.reserve(objCount);
for (atUint32 i = 0; i < objectCount; i++)
{
rs.enterSubRecord(nullptr);
if (auto rec = rs.enterSubRecord(nullptr))
{
atUint8 type = rs.readUByte("type");
auto iter = std::find_if(SCRIPT_OBJECT_DB.begin(), SCRIPT_OBJECT_DB.end(), [&type](const ScriptObjectSpec* obj) -> bool
{ return obj->type == type; });
@ -163,10 +164,8 @@ void SCLY::ScriptLayer::read(athena::io::YAMLDocReader& rs)
}
else
Log.report(logvisor::Fatal, _S("Unable to find type 0x%X in object database"), (atUint32)type);
rs.leaveSubRecord();
}
rs.leaveSubVector();
}
}
else
objectCount = 0;
@ -203,15 +202,17 @@ size_t SCLY::ScriptLayer::binarySize(size_t __isz) const
void SCLY::ScriptLayer::write(athena::io::YAMLDocWriter& ws) const
{
ws.writeUByte("unknown", unknown);
ws.enterSubVector("objects");
if (auto v = ws.enterSubVector("objects"))
{
for (const std::unique_ptr<IScriptObject>& obj : objects)
{
ws.enterSubRecord(nullptr);
if (auto rec = ws.enterSubRecord(nullptr))
{
ws.writeUByte("type", obj->type);
obj->write(ws);
ws.leaveSubRecord();
};
ws.leaveSubVector();
}
}
}
}
const char* SCLY::ScriptLayer::DNAType()

View File

@ -562,10 +562,9 @@ void STRG::write(athena::io::YAMLDocWriter& writer) const
{
for (const auto& lang : langs)
{
writer.enterSubVector(lang.first.toString().c_str());
if (auto v = writer.enterSubVector(lang.first.toString().c_str()))
for (const std::u16string& str : lang.second)
writer.writeU16String(nullptr, str);
writer.leaveSubVector();
}
}

View File

@ -449,7 +449,8 @@ void CTweakBall::read(athena::io::YAMLDocReader& __dna_docin)
{
/* x4_ */
size_t __x4_Count;
__dna_docin.enterSubVector("x4_", __x4_Count);
if (auto v = __dna_docin.enterSubVector("x4_", __x4_Count))
{
/* x4_[0] */
x4_[0] = __dna_docin.readFloat("x4_");
/* x4_[1] */
@ -466,11 +467,11 @@ void CTweakBall::read(athena::io::YAMLDocReader& __dna_docin)
x4_[6] = __dna_docin.readFloat("x4_");
/* x4_[7] */
x4_[7] = __dna_docin.readFloat("x4_");
/* */
__dna_docin.leaveSubVector();
}
/* x24_ */
size_t __x24_Count;
__dna_docin.enterSubVector("x24_", __x24_Count);
if (auto v = __dna_docin.enterSubVector("x24_", __x24_Count))
{
/* x24_[0] */
x24_[0] = __dna_docin.readFloat("x24_");
/* x24_[1] */
@ -487,11 +488,11 @@ void CTweakBall::read(athena::io::YAMLDocReader& __dna_docin)
x24_[6] = __dna_docin.readFloat("x24_");
/* x24_[7] */
x24_[7] = __dna_docin.readFloat("x24_");
/* */
__dna_docin.leaveSubVector();
}
/* x44_ */
size_t __x44_Count;
__dna_docin.enterSubVector("x44_", __x44_Count);
if (auto v = __dna_docin.enterSubVector("x44_", __x44_Count))
{
/* x44_[0] */
x44_[0] = __dna_docin.readFloat("x44_");
/* x44_[1] */
@ -508,8 +509,7 @@ void CTweakBall::read(athena::io::YAMLDocReader& __dna_docin)
x44_[6] = __dna_docin.readFloat("x44_");
/* x44_[7] */
x44_[7] = __dna_docin.readFloat("x44_");
/* */
__dna_docin.leaveSubVector();
}
/* x64_ */
x64_ = __dna_docin.readFloat("x64_");
/* x68_ */
@ -520,7 +520,8 @@ void CTweakBall::read(athena::io::YAMLDocReader& __dna_docin)
x70_ = __dna_docin.readFloat("x70_");
/* xc4_ */
size_t __xc4_Count;
__dna_docin.enterSubVector("xc4_", __xc4_Count);
if (auto v = __dna_docin.enterSubVector("xc4_", __xc4_Count))
{
/* xc4_[0] */
xc4_[0] = __dna_docin.readFloat("xc4_");
/* xc4_[1] */
@ -537,8 +538,7 @@ void CTweakBall::read(athena::io::YAMLDocReader& __dna_docin)
xc4_[6] = __dna_docin.readFloat("xc4_");
/* xc4_[7] */
xc4_[7] = __dna_docin.readFloat("xc4_");
/* */
__dna_docin.leaveSubVector();
}
/* xe4_ */
xe4_ = __dna_docin.readFloat("xe4_");
/* xe8_ */
@ -688,7 +688,8 @@ void CTweakBall::read(athena::io::YAMLDocReader& __dna_docin)
void CTweakBall::write(athena::io::YAMLDocWriter& __dna_docout) const
{
/* x4_ */
__dna_docout.enterSubVector("x4_");
if (auto v = __dna_docout.enterSubVector("x4_"))
{
/* x4_[0] */
__dna_docout.writeFloat("x4_", x4_[0]);
/* x4_[1] */
@ -705,10 +706,10 @@ void CTweakBall::write(athena::io::YAMLDocWriter& __dna_docout) const
__dna_docout.writeFloat("x4_", x4_[6]);
/* x4_[7] */
__dna_docout.writeFloat("x4_", x4_[7]);
/* */
__dna_docout.leaveSubVector();
}
/* x24_ */
__dna_docout.enterSubVector("x24_");
if (auto v = __dna_docout.enterSubVector("x24_"))
{
/* x24_[0] */
__dna_docout.writeFloat("x24_", x24_[0]);
/* x24_[1] */
@ -725,10 +726,10 @@ void CTweakBall::write(athena::io::YAMLDocWriter& __dna_docout) const
__dna_docout.writeFloat("x24_", x24_[6]);
/* x24_[7] */
__dna_docout.writeFloat("x24_", x24_[7]);
/* */
__dna_docout.leaveSubVector();
}
/* x44_ */
__dna_docout.enterSubVector("x44_");
if (auto v = __dna_docout.enterSubVector("x44_"))
{
/* x44_[0] */
__dna_docout.writeFloat("x44_", x44_[0]);
/* x44_[1] */
@ -745,8 +746,7 @@ void CTweakBall::write(athena::io::YAMLDocWriter& __dna_docout) const
__dna_docout.writeFloat("x44_", x44_[6]);
/* x44_[7] */
__dna_docout.writeFloat("x44_", x44_[7]);
/* */
__dna_docout.leaveSubVector();
}
/* x64_ */
__dna_docout.writeFloat("x64_", x64_);
/* x68_ */
@ -756,7 +756,8 @@ void CTweakBall::write(athena::io::YAMLDocWriter& __dna_docout) const
/* x70_ */
__dna_docout.writeFloat("x70_", x70_);
/* xc4_ */
__dna_docout.enterSubVector("xc4_");
if (auto v = __dna_docout.enterSubVector("xc4_"))
{
/* xc4_[0] */
__dna_docout.writeFloat("xc4_", xc4_[0]);
/* xc4_[1] */
@ -773,8 +774,7 @@ void CTweakBall::write(athena::io::YAMLDocWriter& __dna_docout) const
__dna_docout.writeFloat("xc4_", xc4_[6]);
/* xc4_[7] */
__dna_docout.writeFloat("xc4_", xc4_[7]);
/* */
__dna_docout.leaveSubVector();
}
/* xe4_ */
__dna_docout.writeFloat("xe4_", xe4_);
/* xe8_ */

View File

@ -889,7 +889,8 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
{
/* x4_ */
size_t __x4_Count;
__dna_docin.enterSubVector("x4_", __x4_Count);
if (auto v = __dna_docin.enterSubVector("x4_", __x4_Count))
{
/* x4_[0] */
x4_[0] = __dna_docin.readFloat("x4_");
/* x4_[1] */
@ -906,11 +907,11 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
x4_[6] = __dna_docin.readFloat("x4_");
/* x4_[7] */
x4_[7] = __dna_docin.readFloat("x4_");
/* */
__dna_docin.leaveSubVector();
}
/* x24_ */
size_t __x24_Count;
__dna_docin.enterSubVector("x24_", __x24_Count);
if (auto v = __dna_docin.enterSubVector("x24_", __x24_Count))
{
/* x24_[0] */
x24_[0] = __dna_docin.readFloat("x24_");
/* x24_[1] */
@ -927,11 +928,11 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
x24_[6] = __dna_docin.readFloat("x24_");
/* x24_[7] */
x24_[7] = __dna_docin.readFloat("x24_");
/* */
__dna_docin.leaveSubVector();
}
/* x44_ */
size_t __x44_Count;
__dna_docin.enterSubVector("x44_", __x44_Count);
if (auto v = __dna_docin.enterSubVector("x44_", __x44_Count))
{
/* x44_[0] */
x44_[0] = __dna_docin.readFloat("x44_");
/* x44_[1] */
@ -948,11 +949,11 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
x44_[6] = __dna_docin.readFloat("x44_");
/* x44_[7] */
x44_[7] = __dna_docin.readFloat("x44_");
/* */
__dna_docin.leaveSubVector();
}
/* x64_ */
size_t __x64_Count;
__dna_docin.enterSubVector("x64_", __x64_Count);
if (auto v = __dna_docin.enterSubVector("x64_", __x64_Count))
{
/* x64_[0] */
x64_[0] = __dna_docin.readFloat("x64_");
/* x64_[1] */
@ -969,11 +970,11 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
x64_[6] = __dna_docin.readFloat("x64_");
/* x64_[7] */
x64_[7] = __dna_docin.readFloat("x64_");
/* */
__dna_docin.leaveSubVector();
}
/* x84_ */
size_t __x84_Count;
__dna_docin.enterSubVector("x84_", __x84_Count);
if (auto v = __dna_docin.enterSubVector("x84_", __x84_Count))
{
/* x84_[0] */
x84_[0] = __dna_docin.readFloat("x84_");
/* x84_[1] */
@ -990,11 +991,11 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
x84_[6] = __dna_docin.readFloat("x84_");
/* x84_[7] */
x84_[7] = __dna_docin.readFloat("x84_");
/* */
__dna_docin.leaveSubVector();
}
/* xa4_ */
size_t __xa4_Count;
__dna_docin.enterSubVector("xa4_", __xa4_Count);
if (auto v = __dna_docin.enterSubVector("xa4_", __xa4_Count))
{
/* xa4_[0] */
xa4_[0] = __dna_docin.readFloat("xa4_");
/* xa4_[1] */
@ -1011,8 +1012,7 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
xa4_[6] = __dna_docin.readFloat("xa4_");
/* xa4_[7] */
xa4_[7] = __dna_docin.readFloat("xa4_");
/* */
__dna_docin.leaveSubVector();
}
/* xc4_ */
xc4_ = __dna_docin.readFloat("xc4_");
/* xc8_ */
@ -1163,37 +1163,37 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
x268_ = __dna_docin.readFloat("x268_");
/* x158_ */
size_t __x158_Count;
__dna_docin.enterSubVector("x158_", __x158_Count);
if (auto v = __dna_docin.enterSubVector("x158_", __x158_Count))
{
/* x158_[0] */
x158_[0] = __dna_docin.readFloat("x158_");
/* x158_[1] */
x158_[1] = __dna_docin.readFloat("x158_");
/* x158_[2] */
x158_[2] = __dna_docin.readFloat("x158_");
/* */
__dna_docin.leaveSubVector();
}
/* x164_ */
size_t __x164_Count;
__dna_docin.enterSubVector("x164_", __x164_Count);
if (auto v = __dna_docin.enterSubVector("x164_", __x164_Count))
{
/* x164_[0] */
x164_[0] = __dna_docin.readFloat("x164_");
/* x164_[1] */
x164_[1] = __dna_docin.readFloat("x164_");
/* x164_[2] */
x164_[2] = __dna_docin.readFloat("x164_");
/* */
__dna_docin.leaveSubVector();
}
/* x170_ */
size_t __x170_Count;
__dna_docin.enterSubVector("x170_", __x170_Count);
if (auto v = __dna_docin.enterSubVector("x170_", __x170_Count))
{
/* x170_[0] */
x170_[0] = __dna_docin.readFloat("x170_");
/* x170_[1] */
x170_[1] = __dna_docin.readFloat("x170_");
/* x170_[2] */
x170_[2] = __dna_docin.readFloat("x170_");
/* */
__dna_docin.leaveSubVector();
}
/* x17c_ */
x17c_ = __dna_docin.readFloat("x17c_");
/* x180_ */
@ -1218,58 +1218,58 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
x1a4_ = __dna_docin.readFloat("x1a4_");
/* x1a8_ */
size_t __x1a8_Count;
__dna_docin.enterSubVector("x1a8_", __x1a8_Count);
if (auto v = __dna_docin.enterSubVector("x1a8_", __x1a8_Count))
{
/* x1a8_[0] */
x1a8_[0] = __dna_docin.readUint32("x1a8_");
/* x1a8_[1] */
x1a8_[1] = __dna_docin.readUint32("x1a8_");
/* */
__dna_docin.leaveSubVector();
}
/* x1b0_ */
size_t __x1b0_Count;
__dna_docin.enterSubVector("x1b0_", __x1b0_Count);
if (auto v = __dna_docin.enterSubVector("x1b0_", __x1b0_Count))
{
/* x1b0_[0] */
x1b0_[0] = __dna_docin.readUint32("x1b0_");
/* x1b0_[1] */
x1b0_[1] = __dna_docin.readUint32("x1b0_");
/* */
__dna_docin.leaveSubVector();
}
/* x1b8_ */
size_t __x1b8_Count;
__dna_docin.enterSubVector("x1b8_", __x1b8_Count);
if (auto v = __dna_docin.enterSubVector("x1b8_", __x1b8_Count))
{
/* x1b8_[0] */
x1b8_[0] = __dna_docin.readUint32("x1b8_");
/* x1b8_[1] */
x1b8_[1] = __dna_docin.readUint32("x1b8_");
/* */
__dna_docin.leaveSubVector();
}
/* x1c0_ */
size_t __x1c0_Count;
__dna_docin.enterSubVector("x1c0_", __x1c0_Count);
if (auto v = __dna_docin.enterSubVector("x1c0_", __x1c0_Count))
{
/* x1c0_[0] */
x1c0_[0] = __dna_docin.readUint32("x1c0_");
/* x1c0_[1] */
x1c0_[1] = __dna_docin.readUint32("x1c0_");
/* */
__dna_docin.leaveSubVector();
}
/* x1c8_ */
size_t __x1c8_Count;
__dna_docin.enterSubVector("x1c8_", __x1c8_Count);
if (auto v = __dna_docin.enterSubVector("x1c8_", __x1c8_Count))
{
/* x1c8_[0] */
x1c8_[0] = __dna_docin.readUint32("x1c8_");
/* x1c8_[1] */
x1c8_[1] = __dna_docin.readUint32("x1c8_");
/* */
__dna_docin.leaveSubVector();
}
/* x1d0_ */
size_t __x1d0_Count;
__dna_docin.enterSubVector("x1d0_", __x1d0_Count);
if (auto v = __dna_docin.enterSubVector("x1d0_", __x1d0_Count))
{
/* x1d0_[0] */
x1d0_[0] = __dna_docin.readUint32("x1d0_");
/* x1d0_[1] */
x1d0_[1] = __dna_docin.readUint32("x1d0_");
/* */
__dna_docin.leaveSubVector();
}
/* x1d8_ */
x1d8_ = __dna_docin.readFloat("x1d8_");
/* x1dc_ */
@ -1403,7 +1403,8 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) const
{
/* x4_ */
__dna_docout.enterSubVector("x4_");
if (auto v = __dna_docout.enterSubVector("x4_"))
{
/* x4_[0] */
__dna_docout.writeFloat("x4_", x4_[0]);
/* x4_[1] */
@ -1420,10 +1421,10 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout)
__dna_docout.writeFloat("x4_", x4_[6]);
/* x4_[7] */
__dna_docout.writeFloat("x4_", x4_[7]);
/* */
__dna_docout.leaveSubVector();
}
/* x24_ */
__dna_docout.enterSubVector("x24_");
if (auto v = __dna_docout.enterSubVector("x24_"))
{
/* x24_[0] */
__dna_docout.writeFloat("x24_", x24_[0]);
/* x24_[1] */
@ -1440,10 +1441,10 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout)
__dna_docout.writeFloat("x24_", x24_[6]);
/* x24_[7] */
__dna_docout.writeFloat("x24_", x24_[7]);
/* */
__dna_docout.leaveSubVector();
}
/* x44_ */
__dna_docout.enterSubVector("x44_");
if (auto v = __dna_docout.enterSubVector("x44_"))
{
/* x44_[0] */
__dna_docout.writeFloat("x44_", x44_[0]);
/* x44_[1] */
@ -1460,10 +1461,10 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout)
__dna_docout.writeFloat("x44_", x44_[6]);
/* x44_[7] */
__dna_docout.writeFloat("x44_", x44_[7]);
/* */
__dna_docout.leaveSubVector();
}
/* x64_ */
__dna_docout.enterSubVector("x64_");
if (auto v = __dna_docout.enterSubVector("x64_"))
{
/* x64_[0] */
__dna_docout.writeFloat("x64_", x64_[0]);
/* x64_[1] */
@ -1480,10 +1481,10 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout)
__dna_docout.writeFloat("x64_", x64_[6]);
/* x64_[7] */
__dna_docout.writeFloat("x64_", x64_[7]);
/* */
__dna_docout.leaveSubVector();
}
/* x84_ */
__dna_docout.enterSubVector("x84_");
if (auto v = __dna_docout.enterSubVector("x84_"))
{
/* x84_[0] */
__dna_docout.writeFloat("x84_", x84_[0]);
/* x84_[1] */
@ -1500,10 +1501,10 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout)
__dna_docout.writeFloat("x84_", x84_[6]);
/* x84_[7] */
__dna_docout.writeFloat("x84_", x84_[7]);
/* */
__dna_docout.leaveSubVector();
}
/* xa4_ */
__dna_docout.enterSubVector("xa4_");
if (auto v = __dna_docout.enterSubVector("xa4_"))
{
/* xa4_[0] */
__dna_docout.writeFloat("xa4_", xa4_[0]);
/* xa4_[1] */
@ -1520,8 +1521,7 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout)
__dna_docout.writeFloat("xa4_", xa4_[6]);
/* xa4_[7] */
__dna_docout.writeFloat("xa4_", xa4_[7]);
/* */
__dna_docout.leaveSubVector();
}
/* xc4_ */
__dna_docout.writeFloat("xc4_", xc4_);
/* xc8_ */
@ -1671,35 +1671,35 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout)
/* x268_ */
__dna_docout.writeFloat("x268_", x268_);
/* x158_ */
__dna_docout.enterSubVector("x158_");
if (auto v = __dna_docout.enterSubVector("x158_"))
{
/* x158_[0] */
__dna_docout.writeFloat("x158_", x158_[0]);
/* x158_[1] */
__dna_docout.writeFloat("x158_", x158_[1]);
/* x158_[2] */
__dna_docout.writeFloat("x158_", x158_[2]);
/* */
__dna_docout.leaveSubVector();
}
/* x164_ */
__dna_docout.enterSubVector("x164_");
if (auto v = __dna_docout.enterSubVector("x164_"))
{
/* x164_[0] */
__dna_docout.writeFloat("x164_", x164_[0]);
/* x164_[1] */
__dna_docout.writeFloat("x164_", x164_[1]);
/* x164_[2] */
__dna_docout.writeFloat("x164_", x164_[2]);
/* */
__dna_docout.leaveSubVector();
}
/* x170_ */
__dna_docout.enterSubVector("x170_");
if (auto v = __dna_docout.enterSubVector("x170_"))
{
/* x170_[0] */
__dna_docout.writeFloat("x170_", x170_[0]);
/* x170_[1] */
__dna_docout.writeFloat("x170_", x170_[1]);
/* x170_[2] */
__dna_docout.writeFloat("x170_", x170_[2]);
/* */
__dna_docout.leaveSubVector();
}
/* x17c_ */
__dna_docout.writeFloat("x17c_", x17c_);
/* x180_ */
@ -1723,53 +1723,53 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout)
/* x1a4_ */
__dna_docout.writeFloat("x1a4_", x1a4_);
/* x1a8_ */
__dna_docout.enterSubVector("x1a8_");
if (auto v = __dna_docout.enterSubVector("x1a8_"))
{
/* x1a8_[0] */
__dna_docout.writeUint32("x1a8_", x1a8_[0]);
/* x1a8_[1] */
__dna_docout.writeUint32("x1a8_", x1a8_[1]);
/* */
__dna_docout.leaveSubVector();
}
/* x1b0_ */
__dna_docout.enterSubVector("x1b0_");
if (auto v = __dna_docout.enterSubVector("x1b0_"))
{
/* x1b0_[0] */
__dna_docout.writeUint32("x1b0_", x1b0_[0]);
/* x1b0_[1] */
__dna_docout.writeUint32("x1b0_", x1b0_[1]);
/* */
__dna_docout.leaveSubVector();
}
/* x1b8_ */
__dna_docout.enterSubVector("x1b8_");
if (auto v = __dna_docout.enterSubVector("x1b8_"))
{
/* x1b8_[0] */
__dna_docout.writeUint32("x1b8_", x1b8_[0]);
/* x1b8_[1] */
__dna_docout.writeUint32("x1b8_", x1b8_[1]);
/* */
__dna_docout.leaveSubVector();
}
/* x1c0_ */
__dna_docout.enterSubVector("x1c0_");
if (auto v = __dna_docout.enterSubVector("x1c0_"))
{
/* x1c0_[0] */
__dna_docout.writeUint32("x1c0_", x1c0_[0]);
/* x1c0_[1] */
__dna_docout.writeUint32("x1c0_", x1c0_[1]);
/* */
__dna_docout.leaveSubVector();
}
/* x1c8_ */
__dna_docout.enterSubVector("x1c8_");
if (auto v = __dna_docout.enterSubVector("x1c8_"))
{
/* x1c8_[0] */
__dna_docout.writeUint32("x1c8_", x1c8_[0]);
/* x1c8_[1] */
__dna_docout.writeUint32("x1c8_", x1c8_[1]);
/* */
__dna_docout.leaveSubVector();
}
/* x1d0_ */
__dna_docout.enterSubVector("x1d0_");
if (auto v = __dna_docout.enterSubVector("x1d0_"))
{
/* x1d0_[0] */
__dna_docout.writeUint32("x1d0_", x1d0_[0]);
/* x1d0_[1] */
__dna_docout.writeUint32("x1d0_", x1d0_[1]);
/* */
__dna_docout.leaveSubVector();
}
/* x1d8_ */
__dna_docout.writeFloat("x1d8_", x1d8_);
/* x1dc_ */

View File

@ -229,21 +229,16 @@ void STRG::write(athena::io::YAMLDocWriter& writer) const
{
for (const auto& lang : langs)
{
writer.enterSubVector(lang.first.toString().c_str());
if (auto v = writer.enterSubVector(lang.first.toString().c_str()))
for (const std::u16string& str : lang.second)
writer.writeU16String(nullptr, str);
writer.leaveSubVector();
}
if (names.size())
{
writer.enterSubRecord("names");
if (auto rec = writer.enterSubRecord("names"))
for (const auto& name : names)
{
writer.enterSubRecord(name.first.c_str());
if (auto rec = writer.enterSubRecord(name.first.c_str()))
writer.writeInt32(nullptr, name.second);
writer.leaveSubRecord();
}
writer.leaveSubRecord();
}
}

View File

@ -247,22 +247,17 @@ void STRG::write(athena::io::YAMLDocWriter& writer) const
{
for (const auto& item : langs)
{
writer.enterSubVector(item.first.toString().c_str());
if (auto v = writer.enterSubVector(item.first.toString().c_str()))
for (const std::string& str : item.second)
writer.writeString(nullptr, str);
writer.leaveSubVector();
}
if (names.size())
{
writer.enterSubRecord("names");
if (auto rec = writer.enterSubRecord("names"))
for (const auto& item : names)
{
writer.enterSubRecord(item.first.c_str());
if (auto rec = writer.enterSubRecord(item.first.c_str()))
writer.writeInt32(nullptr, item.second);
writer.leaveSubRecord();
}
writer.leaveSubRecord();
}
}

View File

@ -676,6 +676,15 @@ struct SpecMP1 : SpecBase
void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,
hecl::BlenderToken& btok, FCookProgress progress)
{
/*
if (hecl::StringUtils::EndsWith(in.getAuxInfo(), _S(".CINF")))
return {SBIG('CINF'), path.hash().val32()};
else if (hecl::StringUtils::EndsWith(in.getAuxInfo(), _S(".CSKR")))
return {SBIG('CSKR'), path.hash().val32()};
else if (hecl::StringUtils::EndsWith(in.getAuxInfo(), _S(".ANIM")))
return {SBIG('ANIM'), path.hash().val32()};
*/
Actor actor = ds.compileActor();
DNAMP1::ANCS::Cook(out, in, actor, ds, m_pc, [&](const hecl::ProjectPath& modelPath) -> bool {
hecl::ProjectPath cooked;

View File

@ -12,12 +12,13 @@ static void WriteTag(athena::io::YAMLDocWriter& cacheWriter,
{
char idStr[9];
snprintf(idStr, 9, "%08X", uint32_t(pathTag.id));
cacheWriter.enterSubVector(idStr);
if (auto v = cacheWriter.enterSubVector(idStr))
{
cacheWriter.writeString(nullptr, pathTag.type.toString().c_str());
cacheWriter.writeString(nullptr, path.getAuxInfo().size() ?
(path.getRelativePathUTF8() + '|' + path.getAuxInfoUTF8()) :
path.getRelativePathUTF8());
cacheWriter.leaveSubVector();
}
}
static void WriteNameTag(athena::io::YAMLDocWriter& nameWriter,

View File

@ -118,6 +118,19 @@ void ProjectResourceFactoryMP1::IndexMP1Resources(hecl::Database::Project& proj,
m_origIds = sp.GetObj("MP1OriginalIDs");
}
void ProjectResourceFactoryMP1::GetTagListForFile(const char* pakName, std::vector<SObjectTag>& out) const
{
std::string pathPrefix("MP1/");
pathPrefix += pakName;
pathPrefix += '/';
std::unique_lock<std::mutex> lk(
const_cast<ProjectResourceFactoryMP1&>(*this).m_backgroundIndexMutex);
for (const auto& tag : m_tagToPath)
if (!tag.second.getRelativePathUTF8().compare(0, pathPrefix.size(), pathPrefix))
out.push_back(tag.first);
}
void ProjectResourceFactoryMP1::Shutdown()
{
m_origIds = TLockedToken<MP1OriginalIDs>();

View File

@ -15,6 +15,7 @@ class ProjectResourceFactoryMP1 : public ProjectResourceFactoryBase
public:
ProjectResourceFactoryMP1(hecl::ClientProcess& clientProc);
void IndexMP1Resources(hecl::Database::Project& proj, CSimplePool& sp);
void GetTagListForFile(const char* pakName, std::vector<SObjectTag>& out) const;
void Shutdown();
ResId TranslateOriginalToNew(ResId id) const;

View File

@ -173,9 +173,8 @@ public:
: RootSpace(vm)
{
m_state.read(r);
r.enterSubRecord("spaceTree");
if (auto rec = r.enterSubRecord("spaceTree"))
m_spaceTree.reset(NewSpaceFromConfigStream(vm, this, r));
r.leaveSubRecord();
}
void think()
@ -200,12 +199,13 @@ public:
w.writeUint32("class", atUint32(m_class));
m_state.write(w);
w.enterSubRecord("spaceTree");
if (auto rec = w.enterSubRecord("spaceTree"))
{
if (m_spaceTree)
m_spaceTree->saveState(w);
else
w.writeUint32("class", 0);
w.leaveSubRecord();
}
}
void setChild(std::unique_ptr<Space>&& space)
@ -248,12 +248,10 @@ public:
: SplitSpace(vm, parent, specter::SplitView::Axis::Horizontal)
{
m_state.read(r);
r.enterSubRecord("slot0");
if (auto rec = r.enterSubRecord("slot0"))
m_slots[0].reset(NewSpaceFromConfigStream(vm, this, r));
r.leaveSubRecord();
r.enterSubRecord("slot1");
if (auto rec = r.enterSubRecord("slot1"))
m_slots[1].reset(NewSpaceFromConfigStream(vm, this, r));
r.leaveSubRecord();
reloadState();
}
@ -300,19 +298,21 @@ public:
w.writeUint32("class", atUint32(m_class));
m_state.write(w);
w.enterSubRecord("slot0");
if (auto rec = w.enterSubRecord("slot0"))
{
if (m_slots[0])
m_slots[0]->saveState(w);
else
w.writeUint32("class", 0);
w.leaveSubRecord();
}
w.enterSubRecord("slot1");
if (auto rec = w.enterSubRecord("slot1"))
{
if (m_slots[1])
m_slots[1]->saveState(w);
else
w.writeUint32("class", 0);
w.leaveSubRecord();
}
}
void setChildSlot(unsigned slot, std::unique_ptr<Space>&& space);

View File

@ -41,6 +41,8 @@ public:
virtual std::unique_ptr<u8[]> LoadResourceSync(const urde::SObjectTag& tag)=0;
virtual std::unique_ptr<u8[]> LoadResourcePartSync(const urde::SObjectTag& tag, u32 size, u32 off)=0;
virtual void GetTagListForFile(const char* pakName, std::vector<SObjectTag>& out) const {}
virtual ResId TranslateOriginalToNew(ResId id) const { return -1; }
virtual ResId TranslateNewToOriginal(ResId id) const { return -1; }
};

View File

@ -65,9 +65,23 @@ CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader")
}
}
static const char* LoadDepPAKs[] =
{
"TestAnim",
"SamusGun",
"SamGunFx",
nullptr
};
void CMFGameLoader::MakeLoadDependencyList()
{
std::vector<SObjectTag> tags;
for (int i=0 ; LoadDepPAKs[i] ; ++i)
g_ResFactory->GetTagListForFile(LoadDepPAKs[i], tags);
x1c_loadList.reserve(tags.size());
for (const SObjectTag& tag : tags)
x1c_loadList.push_back(g_SimplePool->GetObj(tag));
}
CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue)
@ -124,12 +138,26 @@ CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg,
wldState.GetDesiredAreaAssetId());
return EMessageReturn::Exit;
}
else
{
if (!x18_guiMgr)
{
x18_guiMgr = std::make_shared<CInGameGuiManager>(*x14_stateMgr, queue);
if (!x18_guiMgr->CheckLoadComplete(*x14_stateMgr))
return EMessageReturn::Exit;
x1c_loadList.clear();
wtMgr->StartTextFadeOut();
x2c_25_transitionFinished = wtMgr->IsTransitionFinished();
return EMessageReturn::Exit;
}
case EArchMsgType::FrameBegin:
{
if (x2c_25_transitionFinished)
{
queue.Push(
MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 10, 1000,
std::make_shared<CMFGame>(x14_stateMgr, x18_guiMgr, queue)));
return EMessageReturn::RemoveIOWinAndExit;
}
}
default:

View File

@ -47,7 +47,7 @@ class CMFGameLoader : public CMFGameLoaderBase
struct
{
bool x2c_24_initialized : 1;
bool x2c_25_ : 1;
bool x2c_25_transitionFinished : 1;
};
u8 _dummy = 0;
};

2
hecl

@ -1 +1 @@
Subproject commit e86501e66a219e5370b82be6379da449cb23381a
Subproject commit bcffcf3105090648ba44b3aa69a5d906986be531