diff --git a/DataSpec/DNACommon/CRSC.cpp b/DataSpec/DNACommon/CRSC.cpp index 076bef247..6a7d8432c 100644 --- a/DataSpec/DNACommon/CRSC.cpp +++ b/DataSpec/DNACommon/CRSC.cpp @@ -81,43 +81,40 @@ void CRSM::read(athena::io::YAMLDocReader& r) continue; } - 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; - }); - if (gen != GeneratorTypes.end()) + if (auto rec = r.enterSubRecord(elem.first.c_str())) { - x0_generators[clsId].read(r); - r.leaveSubRecord(); - continue; - } + FourCC clsId(elem.first.c_str()); + auto gen = std::find_if(GeneratorTypes.begin(), GeneratorTypes.end(), [&clsId](const FourCC& other) -> bool{ + return clsId == other; + }); + if (gen != GeneratorTypes.end()) + { + x0_generators[clsId].read(r); + continue; + } - auto sfx = std::find_if(SFXTypes.begin(), SFXTypes.end(), [&clsId](const FourCC& other) -> bool{ - return clsId == other; - }); - if (sfx != SFXTypes.end()) - { - x10_sfx[clsId] = r.readInt32(clsId.toString().c_str()); - r.leaveSubRecord(); - continue; - } + auto sfx = std::find_if(SFXTypes.begin(), SFXTypes.end(), [&clsId](const FourCC& other) -> bool{ + return clsId == other; + }); + if (sfx != SFXTypes.end()) + { + x10_sfx[clsId] = r.readInt32(clsId.toString().c_str()); + continue; + } - auto decal = std::find_if(DecalTypes.begin(), DecalTypes.end(), [&clsId](const FourCC& other) -> bool{ - return clsId == other; - }); - if (decal != DecalTypes.end()) - { - x20_decals[clsId].read(r); - r.leaveSubRecord(); - continue; + auto decal = std::find_if(DecalTypes.begin(), DecalTypes.end(), [&clsId](const FourCC& other) -> bool{ + return clsId == other; + }); + if (decal != DecalTypes.end()) + { + x20_decals[clsId].read(r); + continue; + } + if (clsId == SBIG('RNGE')) + x30_RNGE = r.readFloat(nullptr); + else if (clsId == SBIG('FOFF')) + x34_FOFF = r.readFloat(nullptr); } - 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 void CRSM::write(athena::io::YAMLDocWriter& w) const { for (const auto& pair : x0_generators) - { if (pair.second) - { - w.enterSubRecord(pair.first.toString().c_str()); - pair.second.write(w); - w.leaveSubRecord(); - } - } + if (auto rec = w.enterSubRecord(pair.first.toString().c_str())) + pair.second.write(w); 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()); - pair.second.write(w); - w.leaveSubRecord(); - } - } + if (auto rec = w.enterSubRecord(pair.first.toString().c_str())) + pair.second.write(w); if (x30_RNGE != 50.f) w.writeFloat("RNGE", x30_RNGE); diff --git a/DataSpec/DNACommon/DNACommon.hpp b/DataSpec/DNACommon/DNACommon.hpp index 84ea6d2cd..f31d6360e 100644 --- a/DataSpec/DNACommon/DNACommon.hpp +++ b/DataSpec/DNACommon/DNACommon.hpp @@ -63,21 +63,23 @@ public: void read(athena::io::YAMLDocReader& reader) { size_t count; - 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(); + 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; + } } void write(athena::io::YAMLDocWriter& writer) const { - writer.enterSubVector(nullptr); - writer.writeFloat(nullptr, r); - writer.writeFloat(nullptr, g); - writer.writeFloat(nullptr, b); - writer.writeFloat(nullptr, a); - writer.leaveSubVector(); + if (auto v = writer.enterSubVector(nullptr)) + { + writer.writeFloat(nullptr, r); + writer.writeFloat(nullptr, g); + writer.writeFloat(nullptr, b); + writer.writeFloat(nullptr, a); + } } size_t binarySize(size_t __isz) const {return __isz + 4;} diff --git a/DataSpec/DNACommon/DPSC.cpp b/DataSpec/DNACommon/DPSC.cpp index 4fb04b146..4c485f769 100644 --- a/DataSpec/DNACommon/DPSC.cpp +++ b/DataSpec/DNACommon/DPSC.cpp @@ -15,58 +15,58 @@ void DPSM::read(athena::io::YAMLDocReader& r) continue; } - r.enterSubRecord(elem.first.c_str()); - bool loadFirstDesc = false; - uint32_t clsId = *reinterpret_cast(elem.first.c_str()); - switch(clsId) + if (auto rec = r.enterSubRecord(elem.first.c_str())) { - case SBIG('1SZE'): - case SBIG('1LFT'): - case SBIG('1ROT'): - case SBIG('1OFF'): - case SBIG('1CLR'): - case SBIG('1TEX'): - case SBIG('1ADD'): - loadFirstDesc = true; - case SBIG('2SZE'): - case SBIG('2LFT'): - case SBIG('2ROT'): - case SBIG('2OFF'): - case SBIG('2CLR'): - case SBIG('2TEX'): - case SBIG('2ADD'): - if (loadFirstDesc) - readQuadDecalInfo(r, clsId, x0_quad); - else - readQuadDecalInfo(r, clsId, x1c_quad); - break; - case SBIG('DMDL'): - x38_DMDL.read(r); - break; - case SBIG('DLFT'): - x48_DLFT.read(r); - break; - case SBIG('DMOP'): - x4c_DMOP.read(r); - break; - case SBIG('DMRT'): - x50_DMRT.read(r); - break; - case SBIG('DMSC'): - x54_DMSC.read(r); - break; - case SBIG('DMCL'): - x58_DMCL.read(r); - break; - case SBIG('DMAB'): - x5c_24_DMAB = r.readBool(nullptr); - break; - case SBIG('DMOO'): - x5c_25_DMOO = r.readBool(nullptr); - break; + bool loadFirstDesc = false; + uint32_t clsId = *reinterpret_cast(elem.first.c_str()); + switch(clsId) + { + case SBIG('1SZE'): + case SBIG('1LFT'): + case SBIG('1ROT'): + case SBIG('1OFF'): + case SBIG('1CLR'): + case SBIG('1TEX'): + case SBIG('1ADD'): + loadFirstDesc = true; + case SBIG('2SZE'): + case SBIG('2LFT'): + case SBIG('2ROT'): + case SBIG('2OFF'): + case SBIG('2CLR'): + case SBIG('2TEX'): + case SBIG('2ADD'): + if (loadFirstDesc) + readQuadDecalInfo(r, clsId, x0_quad); + else + readQuadDecalInfo(r, clsId, x1c_quad); + break; + case SBIG('DMDL'): + x38_DMDL.read(r); + break; + case SBIG('DLFT'): + x48_DLFT.read(r); + break; + case SBIG('DMOP'): + x4c_DMOP.read(r); + break; + case SBIG('DMRT'): + x50_DMRT.read(r); + break; + case SBIG('DMSC'): + x54_DMSC.read(r); + break; + case SBIG('DMCL'): + x58_DMCL.read(r); + break; + case SBIG('DMAB'): + x5c_24_DMAB = r.readBool(nullptr); + break; + case SBIG('DMOO'): + x5c_25_DMOO = r.readBool(nullptr); + break; + } } - - r.leaveSubRecord(); } } @@ -77,41 +77,24 @@ void DPSM::write(athena::io::YAMLDocWriter& w) const writeQuadDecalInfo(w, x1c_quad, false); if (x38_DMDL) - { - w.enterSubRecord("DMDL"); - x38_DMDL.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("DMDL")) + x38_DMDL.write(w); if (x48_DLFT) - { - w.enterSubRecord("DLFT"); - x48_DLFT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("DLFT")) + x48_DLFT.write(w); if (x4c_DMOP) - { - w.enterSubRecord("DMOP"); - x4c_DMOP.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("DMOP")) + x4c_DMOP.write(w); if (x50_DMRT) - { - w.enterSubRecord("DMRT"); - x50_DMRT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("DMRT")) + x50_DMRT.write(w); if (x54_DMSC) - { - w.enterSubRecord("DMSC"); - x54_DMSC.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("DMSC")) + x54_DMSC.write(w); if (x58_DMCL) - { - w.enterSubRecord("DMCL"); - x54_DMSC.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("DMCL")) + x54_DMSC.write(w); + if (x5c_24_DMAB) w.writeBool("DMAB", x5c_24_DMAB); if (x5c_25_DMOO) @@ -160,48 +143,26 @@ void DPSM::writeQuadDecalInfo(athena::io::YAMLDocWriter& w, const typename DPSM::SQuadDescr& quad, bool first) const { if (quad.x0_LFT) - { - w.enterSubRecord((first ? "1LFT" : "2LFT")); - quad.x0_LFT.write(w); - w.leaveSubRecord(); - } - + if (auto rec = w.enterSubRecord((first ? "1LFT" : "2LFT"))) + quad.x0_LFT.write(w); if (quad.x4_SZE) - { - w.enterSubRecord((first ? "1SZE" : "2SZE")); - quad.x4_SZE.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord((first ? "1SZE" : "2SZE"))) + quad.x4_SZE.write(w); if (quad.x8_ROT) - { - w.enterSubRecord((first ? "1ROT" : "2ROT")); - quad.x8_ROT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord((first ? "1ROT" : "2ROT"))) + quad.x8_ROT.write(w); if (quad.xc_OFF) - { - w.enterSubRecord((first ? "1OFF" : "2OFF")); - quad.xc_OFF.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord((first ? "1OFF" : "2OFF"))) + quad.xc_OFF.write(w); if (quad.x10_CLR) - { - w.enterSubRecord((first ? "1CLR" : "2CLR")); - quad.x10_CLR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord((first ? "1CLR" : "2CLR"))) + quad.x10_CLR.write(w); if (quad.x14_TEX) - { - w.enterSubRecord((first ? "1TEX" : "2TEX")); - quad.x14_TEX.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord((first ? "1TEX" : "2TEX"))) + quad.x14_TEX.write(w); if (quad.x18_ADD) - { - w.enterSubRecord((first ? "1ADD" : "2ADD")); - quad.x18_ADD.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord((first ? "1ADD" : "2ADD"))) + quad.x18_ADD.write(w); } template diff --git a/DataSpec/DNACommon/ELSC.cpp b/DataSpec/DNACommon/ELSC.cpp index 629714e50..09c59d929 100644 --- a/DataSpec/DNACommon/ELSC.cpp +++ b/DataSpec/DNACommon/ELSC.cpp @@ -84,125 +84,65 @@ template void ELSM::write(athena::io::YAMLDocWriter& w) const { if (x0_LIFE) - { - w.enterSubRecord("LIFE"); - x0_LIFE.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LIFE")) + x0_LIFE.write(w); if (x4_SLIF) - { - w.enterSubRecord("SLIF"); - x4_SLIF.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SLIF")) + x4_SLIF.write(w); if (x8_GRAT) - { - w.enterSubRecord("GRAT"); - x8_GRAT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("GRAT")) + x8_GRAT.write(w); if (xc_SCNT) - { - w.enterSubRecord("SCNT"); - xc_SCNT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SCNT")) + xc_SCNT.write(w); if (x10_SSEG) - { - w.enterSubRecord("SSEG"); - x10_SSEG.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SSEG")) + x10_SSEG.write(w); if (x14_COLR) - { - w.enterSubRecord("COLR"); - x14_COLR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("COLR")) + x14_COLR.write(w); if (x18_IEMT) - { - w.enterSubRecord("IEMT"); - x18_IEMT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("IEMT")) + x18_IEMT.write(w); if (x1c_FEMT) - { - w.enterSubRecord("FEMT"); - x1c_FEMT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("FEMT")) + x1c_FEMT.write(w); if (x20_AMPL) - { - w.enterSubRecord("AMPL"); - x20_AMPL.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("AMPL")) + x20_AMPL.write(w); if (x24_AMPD) - { - w.enterSubRecord("AMPD"); - x24_AMPD.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("AMPD")) + x24_AMPD.write(w); if (x28_LWD1) - { - w.enterSubRecord("LWD1"); - x28_LWD1.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LWD1")) + x28_LWD1.write(w); if (x2c_LWD2) - { - w.enterSubRecord("LWD2"); - x2c_LWD2.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LWD2")) + x2c_LWD2.write(w); if (x30_LWD3) - { - w.enterSubRecord("LWD3"); - x30_LWD3.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LWD3")) + x30_LWD3.write(w); if (x34_LCL1) - { - w.enterSubRecord("LCL1"); - x34_LCL1.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LCL1")) + x34_LCL1.write(w); if (x38_LCL2) - { - w.enterSubRecord("LCL2"); - x38_LCL2.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LCL2")) + x38_LCL2.write(w); if (x3c_LCL3) - { - w.enterSubRecord("LCL3"); - x3c_LCL3.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LCL3")) + x3c_LCL3.write(w); if (x40_SSWH) - { - w.enterSubRecord("SSWH"); - x40_SSWH.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SSWH")) + x40_SSWH.write(w); if (x50_GPSM) - { - w.enterSubRecord("GPSM"); - x50_GPSM.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("GPSM")) + x50_GPSM.write(w); if (x60_EPSM) - { - w.enterSubRecord("EPSM"); - x60_EPSM.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("EPSM")) + x60_EPSM.write(w); if (x70_ZERY) - { - w.enterSubRecord("ZERY"); - x70_ZERY.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ZERY")) + x70_ZERY.write(w); } template diff --git a/DataSpec/DNACommon/FONT.cpp b/DataSpec/DNACommon/FONT.cpp index 7d1e35a7c..7145bf3d5 100644 --- a/DataSpec/DNACommon/FONT.cpp +++ b/DataSpec/DNACommon/FONT.cpp @@ -186,20 +186,20 @@ void FONT::read(athena::io::YAMLDocReader& __dna_docin) /* glyphCount */ /* glyphs */ size_t count; - __dna_docin.enterSubVector("glyphs", count); - glyphCount = count; - for (atUint32 i = 0; i < glyphCount; i++) + if (auto v = __dna_docin.enterSubVector("glyphs", count)) { - if (version < 4) - glyphs.emplace_back(new GlyphMP1); - else - glyphs.emplace_back(new GlyphMP2); + glyphCount = count; + for (atUint32 i = 0; i < glyphCount; i++) + { + if (version < 4) + glyphs.emplace_back(new GlyphMP1); + else + glyphs.emplace_back(new GlyphMP2); - __dna_docin.enterSubRecord(nullptr); - glyphs.back()->read(__dna_docin); - __dna_docin.leaveSubRecord(); + if (auto rec = __dna_docin.enterSubRecord(nullptr)) + glyphs.back()->read(__dna_docin); + } } - __dna_docin.leaveSubVector(); /* kerningInfoCount squelched */ /* kerningInfo */ kerningInfoCount = __dna_docin.enumerate("kerningInfo", kerningInfo); @@ -234,16 +234,10 @@ void FONT::write(athena::io::YAMLDocWriter& __dna_docout) const __dna_docout.writeUint32("textureFormat", textureFormat); /* glyphCount squelched */ /* glyphs */ - __dna_docout.enterSubVector("glyphs"); - - for (const std::unique_ptr& glyph : glyphs) - { - __dna_docout.enterSubRecord(nullptr); - glyph->write(__dna_docout); - __dna_docout.leaveSubRecord(); - } - - __dna_docout.leaveSubVector(); + if (auto v = __dna_docout.enterSubVector("glyphs")) + for (const std::unique_ptr& glyph : glyphs) + if (auto rec = __dna_docout.enterSubRecord(nullptr)) + glyph->write(__dna_docout); /* kerningInfoCount squelched */ /* kerningInfo */ __dna_docout.enumerate("kerningInfo", kerningInfo); diff --git a/DataSpec/DNACommon/PAK.cpp b/DataSpec/DNACommon/PAK.cpp index 1dfca75c6..20768c9d3 100644 --- a/DataSpec/DNACommon/PAK.cpp +++ b/DataSpec/DNACommon/PAK.cpp @@ -207,18 +207,20 @@ void PAKRouter::build(std::vector& bridges, std::functio { if (namedEntry.name == "holo_cinf") continue; /* Problematic corner case */ - catalogWriter.enterSubRecord(namedEntry.name.c_str()); - hecl::ProjectPath working = getWorking(namedEntry.id); - if (working.getAuxInfoUTF8().size()) + if (auto rec = catalogWriter.enterSubRecord(namedEntry.name.c_str())) { - catalogWriter.enterSubVector(nullptr); - catalogWriter.writeString(nullptr, working.getRelativePathUTF8().c_str()); - catalogWriter.writeString(nullptr, working.getAuxInfoUTF8().c_str()); - catalogWriter.leaveSubVector(); + hecl::ProjectPath working = getWorking(namedEntry.id); + if (working.getAuxInfoUTF8().size()) + { + if (auto v = catalogWriter.enterSubVector(nullptr)) + { + catalogWriter.writeString(nullptr, working.getRelativePathUTF8().c_str()); + catalogWriter.writeString(nullptr, working.getAuxInfoUTF8().c_str()); + } + } + else + catalogWriter.writeString(nullptr, working.getRelativePathUTF8().c_str()); } - else - catalogWriter.writeString(nullptr, working.getRelativePathUTF8().c_str()); - catalogWriter.leaveSubRecord(); } /* Write catalog */ diff --git a/DataSpec/DNACommon/PART.cpp b/DataSpec/DNACommon/PART.cpp index e0efb4a35..62c6f4867 100644 --- a/DataSpec/DNACommon/PART.cpp +++ b/DataSpec/DNACommon/PART.cpp @@ -16,253 +16,254 @@ void GPSM::read(athena::io::YAMLDocReader& r) continue; } - r.enterSubRecord(elem.first.c_str()); - switch (*reinterpret_cast(elem.first.data())) + if (auto rec = r.enterSubRecord(elem.first.c_str())) { - case SBIG('PMCL'): - x78_PMCL.read(r); - break; - case SBIG('LFOR'): - x118_LFOR.read(r); - break; - case SBIG('IDTS'): - xa4_IDTS.read(r); - break; - case SBIG('EMTR'): - x40_EMTR.read(r); - break; - case SBIG('COLR'): - x30_COLR.read(r); - break; - case SBIG('CIND'): - x45_30_CIND = r.readBool(nullptr); - break; - case SBIG('AAPH'): - x44_26_AAPH = r.readBool(nullptr); - break; - case SBIG('CSSD'): - xa0_CSSD.read(r); - break; - case SBIG('GRTE'): - x2c_GRTE.read(r); - break; - case SBIG('FXLL'): - x44_25_FXLL = r.readBool(nullptr); - break; - case SBIG('ICTS'): - x8c_ICTS.read(r); - break; - case SBIG('KSSM'): - xd0_KSSM.read(r); - break; - case SBIG('ILOC'): - x38_ILOC.read(r); - break; - case SBIG('IITS'): - xb8_IITS.read(r); - break; - case SBIG('IVEC'): - x3c_IVEC.read(r); - break; - case SBIG('LDIR'): - x110_LDIR.read(r); - break; - case SBIG('LCLR'): - x104_LCLR.read(r); - break; - case SBIG('LENG'): - x20_LENG.read(r); - break; - case SBIG('MAXP'): - x28_MAXP.read(r); - break; - case SBIG('LOFF'): - x10c_LOFF.read(r); - break; - case SBIG('LINT'): - x108_LINT.read(r); - break; - case SBIG('LINE'): - x44_24_LINE = r.readBool(nullptr); - break; - case SBIG('LFOT'): - x114_LFOT.read(r); - break; - case SBIG('LIT_'): - x44_29_LIT_ = r.readBool(nullptr); - break; - case SBIG('LTME'): - x34_LTME.read(r); - break; - case SBIG('LSLA'): - x11c_LSLA.read(r); - break; - case SBIG('LTYP'): - x100_LTYP.read(r); - break; - case SBIG('NDSY'): - xb4_NDSY.read(r); - break; - case SBIG('MBSP'): - x48_MBSP.read(r); - break; - case SBIG('MBLR'): - x44_30_MBLR = r.readBool(nullptr); - break; - case SBIG('NCSY'): - x9c_NCSY.read(r); - break; - case SBIG('PISY'): - xc8_PISY.read(r); - break; - case SBIG('OPTS'): - x45_31_OPTS = r.readBool(nullptr); - break; - case SBIG('PMAB'): - x44_31_PMAB = r.readBool(nullptr); - break; - case SBIG('SESD'): - xf8_SESD.read(r); - break; - case SBIG('SEPO'): - xfc_SEPO.read(r); - break; - case SBIG('PSLT'): - xc_PSLT.read(r); - break; - case SBIG('PMSC'): - x74_PMSC.read(r); - break; - case SBIG('PMOP'): - x6c_PMOP.read(r); - break; - case SBIG('PMDL'): - x5c_PMDL.read(r); - break; - case SBIG('PMRT'): - x70_PMRT.read(r); - break; - case SBIG('POFS'): - x18_POFS.read(r); - break; - case SBIG('PMUS'): - x45_24_PMUS = r.readBool(nullptr); - break; - case SBIG('PSIV'): - x0_PSIV.read(r); - break; - case SBIG('ROTA'): - x50_ROTA.read(r); - break; - case SBIG('PSVM'): - x4_PSVM.read(r); - break; - case SBIG('PSTS'): - x14_PSTS.read(r); - break; - case SBIG('PSOV'): - x8_PSOV.read(r); - break; - case SBIG('PSWT'): - x10_PSWT.read(r); - break; - case SBIG('PMLC'): - xec_PMLC.read(r); - break; - case SBIG('SEED'): - x1c_SEED.read(r); - break; - case SBIG('PMOO'): - x45_25_PMOO = r.readBool(nullptr); - break; - case SBIG('SSSD'): - xe4_SSSD.read(r); - break; - case SBIG('SORT'): - x44_28_SORT = r.readBool(nullptr); - break; - case SBIG('SIZE'): - x4c_SIZE.read(r); - break; - case SBIG('SISY'): - xcc_SISY.read(r); - break; - case SBIG('SSPO'): - xe8_SSPO.read(r); - break; - case SBIG('TEXR'): - x54_TEXR.read(r); - break; - case SBIG('SSWH'): - xd4_SSWH.read(r); - break; - case SBIG('TIND'): - x58_TIND.read(r); - break; - case SBIG('VMD4'): - x45_29_VMD4 = r.readBool(nullptr); - break; - case SBIG('VMD3'): - x45_28_VMD3 = r.readBool(nullptr); - break; - case SBIG('VMD2'): - x45_27_VMD2 = r.readBool(nullptr); - break; - case SBIG('VMD1'): - x45_26_VMD1 = r.readBool(nullptr); - break; - case SBIG('VEL4'): - x88_VEL4.read(r); - break; - case SBIG('VEL3'): - x84_VEL3.read(r); - break; - case SBIG('VEL2'): - x80_VEL2.read(r); - break; - case SBIG('VEL1'): - x7c_VEL1.read(r); - break; - case SBIG('ZBUF'): - x44_27_ZBUF = r.readBool(nullptr); - break; - case SBIG('WIDT'): - x24_WIDT.read(r); - break; - case SBIG('ORNT'): - x30_30_ORNT = r.readBool(nullptr); - break; - case SBIG('RSOP'): - x30_31_RSOP = r.readBool(nullptr); - break; - case SBIG('ADV1'): - x10c_ADV1.read(r); - break; - case SBIG('ADV2'): - x110_ADV2.read(r); - break; - case SBIG('ADV3'): - x114_ADV3.read(r); - break; - case SBIG('ADV4'): - x118_ADV4.read(r); - break; - case SBIG('ADV5'): - x11c_ADV5.read(r); - break; - case SBIG('ADV6'): - x120_ADV6.read(r); - break; - case SBIG('ADV7'): - x124_ADV7.read(r); - break; - case SBIG('SELC'): - xd8_SELC.read(r); - break; - default: - break; + switch (*reinterpret_cast(elem.first.data())) + { + case SBIG('PMCL'): + x78_PMCL.read(r); + break; + case SBIG('LFOR'): + x118_LFOR.read(r); + break; + case SBIG('IDTS'): + xa4_IDTS.read(r); + break; + case SBIG('EMTR'): + x40_EMTR.read(r); + break; + case SBIG('COLR'): + x30_COLR.read(r); + break; + case SBIG('CIND'): + x45_30_CIND = r.readBool(nullptr); + break; + case SBIG('AAPH'): + x44_26_AAPH = r.readBool(nullptr); + break; + case SBIG('CSSD'): + xa0_CSSD.read(r); + break; + case SBIG('GRTE'): + x2c_GRTE.read(r); + break; + case SBIG('FXLL'): + x44_25_FXLL = r.readBool(nullptr); + break; + case SBIG('ICTS'): + x8c_ICTS.read(r); + break; + case SBIG('KSSM'): + xd0_KSSM.read(r); + break; + case SBIG('ILOC'): + x38_ILOC.read(r); + break; + case SBIG('IITS'): + xb8_IITS.read(r); + break; + case SBIG('IVEC'): + x3c_IVEC.read(r); + break; + case SBIG('LDIR'): + x110_LDIR.read(r); + break; + case SBIG('LCLR'): + x104_LCLR.read(r); + break; + case SBIG('LENG'): + x20_LENG.read(r); + break; + case SBIG('MAXP'): + x28_MAXP.read(r); + break; + case SBIG('LOFF'): + x10c_LOFF.read(r); + break; + case SBIG('LINT'): + x108_LINT.read(r); + break; + case SBIG('LINE'): + x44_24_LINE = r.readBool(nullptr); + break; + case SBIG('LFOT'): + x114_LFOT.read(r); + break; + case SBIG('LIT_'): + x44_29_LIT_ = r.readBool(nullptr); + break; + case SBIG('LTME'): + x34_LTME.read(r); + break; + case SBIG('LSLA'): + x11c_LSLA.read(r); + break; + case SBIG('LTYP'): + x100_LTYP.read(r); + break; + case SBIG('NDSY'): + xb4_NDSY.read(r); + break; + case SBIG('MBSP'): + x48_MBSP.read(r); + break; + case SBIG('MBLR'): + x44_30_MBLR = r.readBool(nullptr); + break; + case SBIG('NCSY'): + x9c_NCSY.read(r); + break; + case SBIG('PISY'): + xc8_PISY.read(r); + break; + case SBIG('OPTS'): + x45_31_OPTS = r.readBool(nullptr); + break; + case SBIG('PMAB'): + x44_31_PMAB = r.readBool(nullptr); + break; + case SBIG('SESD'): + xf8_SESD.read(r); + break; + case SBIG('SEPO'): + xfc_SEPO.read(r); + break; + case SBIG('PSLT'): + xc_PSLT.read(r); + break; + case SBIG('PMSC'): + x74_PMSC.read(r); + break; + case SBIG('PMOP'): + x6c_PMOP.read(r); + break; + case SBIG('PMDL'): + x5c_PMDL.read(r); + break; + case SBIG('PMRT'): + x70_PMRT.read(r); + break; + case SBIG('POFS'): + x18_POFS.read(r); + break; + case SBIG('PMUS'): + x45_24_PMUS = r.readBool(nullptr); + break; + case SBIG('PSIV'): + x0_PSIV.read(r); + break; + case SBIG('ROTA'): + x50_ROTA.read(r); + break; + case SBIG('PSVM'): + x4_PSVM.read(r); + break; + case SBIG('PSTS'): + x14_PSTS.read(r); + break; + case SBIG('PSOV'): + x8_PSOV.read(r); + break; + case SBIG('PSWT'): + x10_PSWT.read(r); + break; + case SBIG('PMLC'): + xec_PMLC.read(r); + break; + case SBIG('SEED'): + x1c_SEED.read(r); + break; + case SBIG('PMOO'): + x45_25_PMOO = r.readBool(nullptr); + break; + case SBIG('SSSD'): + xe4_SSSD.read(r); + break; + case SBIG('SORT'): + x44_28_SORT = r.readBool(nullptr); + break; + case SBIG('SIZE'): + x4c_SIZE.read(r); + break; + case SBIG('SISY'): + xcc_SISY.read(r); + break; + case SBIG('SSPO'): + xe8_SSPO.read(r); + break; + case SBIG('TEXR'): + x54_TEXR.read(r); + break; + case SBIG('SSWH'): + xd4_SSWH.read(r); + break; + case SBIG('TIND'): + x58_TIND.read(r); + break; + case SBIG('VMD4'): + x45_29_VMD4 = r.readBool(nullptr); + break; + case SBIG('VMD3'): + x45_28_VMD3 = r.readBool(nullptr); + break; + case SBIG('VMD2'): + x45_27_VMD2 = r.readBool(nullptr); + break; + case SBIG('VMD1'): + x45_26_VMD1 = r.readBool(nullptr); + break; + case SBIG('VEL4'): + x88_VEL4.read(r); + break; + case SBIG('VEL3'): + x84_VEL3.read(r); + break; + case SBIG('VEL2'): + x80_VEL2.read(r); + break; + case SBIG('VEL1'): + x7c_VEL1.read(r); + break; + case SBIG('ZBUF'): + x44_27_ZBUF = r.readBool(nullptr); + break; + case SBIG('WIDT'): + x24_WIDT.read(r); + break; + case SBIG('ORNT'): + x30_30_ORNT = r.readBool(nullptr); + break; + case SBIG('RSOP'): + x30_31_RSOP = r.readBool(nullptr); + break; + case SBIG('ADV1'): + x10c_ADV1.read(r); + break; + case SBIG('ADV2'): + x110_ADV2.read(r); + break; + case SBIG('ADV3'): + x114_ADV3.read(r); + break; + case SBIG('ADV4'): + x118_ADV4.read(r); + break; + case SBIG('ADV5'): + x11c_ADV5.read(r); + break; + case SBIG('ADV6'): + x120_ADV6.read(r); + break; + case SBIG('ADV7'): + x124_ADV7.read(r); + break; + case SBIG('SELC'): + xd8_SELC.read(r); + break; + default: + break; + } } - r.leaveSubRecord(); } } @@ -270,107 +271,56 @@ template void GPSM::write(athena::io::YAMLDocWriter& w) const { if (x0_PSIV) - { - w.enterSubRecord("PSIV"); - x0_PSIV.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PSIV")) + x0_PSIV.write(w); if (x4_PSVM) - { - w.enterSubRecord("PSVM"); - x4_PSVM.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PSVM")) + x4_PSVM.write(w); if (x8_PSOV) - { - w.enterSubRecord("PSOV"); - x8_PSOV.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PSOV")) + x8_PSOV.write(w); if (xc_PSLT) - { - w.enterSubRecord("PSLT"); - xc_PSLT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PSLT")) + xc_PSLT.write(w); if (x10_PSWT) - { - w.enterSubRecord("PSWT"); - x10_PSWT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PSWT")) + x10_PSWT.write(w); if (x14_PSTS) - { - w.enterSubRecord("PSTS"); - x14_PSTS.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PSTS")) + x14_PSTS.write(w); if (x18_POFS) - { - w.enterSubRecord("POFS"); - x18_POFS.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("POFS")) + x18_POFS.write(w); if (x1c_SEED) - { - w.enterSubRecord("SEED"); - x1c_SEED.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SEED")) + x1c_SEED.write(w); if (x20_LENG) - { - w.enterSubRecord("LENG"); - x20_LENG.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LENG")) + x20_LENG.write(w); if (x24_WIDT) - { - w.enterSubRecord("WIDT"); - x24_WIDT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("WIDT")) + x24_WIDT.write(w); if (x28_MAXP) - { - w.enterSubRecord("MAXP"); - x28_MAXP.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("MAXP")) + x28_MAXP.write(w); if (x2c_GRTE) - { - w.enterSubRecord("GRTE"); - x2c_GRTE.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("GRTE")) + x2c_GRTE.write(w); if (x30_COLR) - { - w.enterSubRecord("COLR"); - x30_COLR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("COLR")) + x30_COLR.write(w); if (x34_LTME) - { - w.enterSubRecord("LTME"); - x34_LTME.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LTME")) + x34_LTME.write(w); if (x38_ILOC) - { - w.enterSubRecord("ILOC"); - x38_ILOC.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ILOC")) + x38_ILOC.write(w); if (x3c_IVEC) - { - w.enterSubRecord("IVEC"); - x3c_IVEC.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("IVEC")) + x3c_IVEC.write(w); if (x40_EMTR) - { - w.enterSubRecord("EMTR"); - x40_EMTR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("EMTR")) + x40_EMTR.write(w); if (x44_24_LINE) w.writeBool("LINE", true); if (x44_25_FXLL) @@ -408,281 +358,143 @@ void GPSM::write(athena::io::YAMLDocWriter& w) const if (x30_31_RSOP) w.writeBool("RSOP", true); if (x48_MBSP) - { - w.enterSubRecord("MPSB"); - x48_MBSP.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("MPSB")) + x48_MBSP.write(w); if (x4c_SIZE) - { - w.enterSubRecord("SIZE"); - x4c_SIZE.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SIZE")) + x4c_SIZE.write(w); if (x50_ROTA) - { - w.enterSubRecord("ROTA"); - x50_ROTA.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ROTA")) + x50_ROTA.write(w); if (x54_TEXR) - { - w.enterSubRecord("TEXR"); - x54_TEXR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("TEXR")) + x54_TEXR.write(w); if (x58_TIND) - { - w.enterSubRecord("TIND"); - x58_TIND.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("TIND")) + x58_TIND.write(w); if (x5c_PMDL) - { - w.enterSubRecord("PMDL"); - x5c_PMDL.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PMDL")) + x5c_PMDL.write(w); if (x6c_PMOP) - { - w.enterSubRecord("PMOP"); - x6c_PMOP.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PMOP")) + x6c_PMOP.write(w); if (x70_PMRT) - { - w.enterSubRecord("PMRT"); - x70_PMRT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PMRT")) + x70_PMRT.write(w); if (x74_PMSC) - { - w.enterSubRecord("PMSC"); - x74_PMSC.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PMSC")) + x74_PMSC.write(w); if (x78_PMCL) - { - w.enterSubRecord("PMCL"); - x78_PMCL.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PMCL")) + x78_PMCL.write(w); if (x7c_VEL1) - { - w.enterSubRecord("VEL1"); - x7c_VEL1.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("VEL1")) + x7c_VEL1.write(w); if (x80_VEL2) - { - w.enterSubRecord("VEL2"); - x80_VEL2.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("VEL2")) + x80_VEL2.write(w); if (x84_VEL3) - { - w.enterSubRecord("VEL3"); - x84_VEL3.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("VEL3")) + x84_VEL3.write(w); if (x88_VEL4) - { - w.enterSubRecord("VEL4"); - x88_VEL4.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("VEL4")) + x88_VEL4.write(w); if (x8c_ICTS) - { - w.enterSubRecord("ICTS"); - x8c_ICTS.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ICTS")) + x8c_ICTS.write(w); if (x9c_NCSY) - { - w.enterSubRecord("NCSY"); - x9c_NCSY.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("NCSY")) + x9c_NCSY.write(w); if (xa0_CSSD) - { - w.enterSubRecord("CSSD"); - xa0_CSSD.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("CSSD")) + xa0_CSSD.write(w); if (xa4_IDTS) - { - w.enterSubRecord("IDTS"); - xa4_IDTS.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("IDTS")) + xa4_IDTS.write(w); if (xb4_NDSY) - { - w.enterSubRecord("NDSY"); - xb4_NDSY.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("NDSY")) + xb4_NDSY.write(w); if (xb8_IITS) - { - w.enterSubRecord("IITS"); - xb8_IITS.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("IITS")) + xb8_IITS.write(w); if (xc8_PISY) - { - w.enterSubRecord("PISY"); - xc8_PISY.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PISY")) + xc8_PISY.write(w); if (xcc_SISY) - { - w.enterSubRecord("SISY"); - xcc_SISY.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SISY")) + xcc_SISY.write(w); if (xd0_KSSM) - { - w.enterSubRecord("KSSM"); - xd0_KSSM.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("KSSM")) + xd0_KSSM.write(w); if (xd4_SSWH) - { - w.enterSubRecord("SSWH"); - xd4_SSWH.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SSWH")) + xd4_SSWH.write(w); if (xd8_SELC) - { - w.enterSubRecord("SELC"); - xd8_SELC.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SELC")) + xd8_SELC.write(w); if (xe4_SSSD) - { - w.enterSubRecord("SSSD"); - xe4_SSSD.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SSSD")) + xe4_SSSD.write(w); if (xe8_SSPO) - { - w.enterSubRecord("SSPO"); - xe8_SSPO.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SSPO")) + xe8_SSPO.write(w); if (xf8_SESD) - { - w.enterSubRecord("SESD"); - xf8_SESD.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SESD")) + xf8_SESD.write(w); if (xfc_SEPO) - { - w.enterSubRecord("SEPO"); - xfc_SEPO.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SEPO")) + xfc_SEPO.write(w); if (xec_PMLC) - { - w.enterSubRecord("PMLC"); - xec_PMLC.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PMLC")) + xec_PMLC.write(w); if (x100_LTYP) - { - w.enterSubRecord("LTYP"); - x100_LTYP.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LTYP")) + x100_LTYP.write(w); if (x104_LCLR) - { - w.enterSubRecord("LCLR"); - x104_LCLR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LCLR")) + x104_LCLR.write(w); if (x108_LINT) - { - w.enterSubRecord("LINT"); - x108_LINT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LINT")) + x108_LINT.write(w); if (x10c_LOFF) - { - w.enterSubRecord("LOFF"); - x10c_LOFF.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LOFF")) + x10c_LOFF.write(w); if (x110_LDIR) - { - w.enterSubRecord("LDIR"); - x110_LDIR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LDIR")) + x110_LDIR.write(w); if (x114_LFOT) - { - w.enterSubRecord("LFOT"); - x114_LFOT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LFOT")) + x114_LFOT.write(w); if (x118_LFOR) - { - w.enterSubRecord("LFOR"); - x118_LFOR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LFOR")) + x118_LFOR.write(w); if (x11c_LSLA) - { - w.enterSubRecord("LSLA"); - x11c_LSLA.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LSLA")) + x11c_LSLA.write(w); if (x10c_ADV1) - { - w.enterSubRecord("ADV1"); - x10c_ADV1.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ADV1")) + x10c_ADV1.write(w); if (x110_ADV2) - { - w.enterSubRecord("ADV2"); - x110_ADV2.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ADV2")) + x110_ADV2.write(w); if (x114_ADV3) - { - w.enterSubRecord("ADV3"); - x114_ADV3.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ADV3")) + x114_ADV3.write(w); if (x118_ADV4) - { - w.enterSubRecord("ADV4"); - x118_ADV4.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ADV4")) + x118_ADV4.write(w); if (x11c_ADV5) - { - w.enterSubRecord("ADV5"); - x11c_ADV5.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ADV5")) + x11c_ADV5.write(w); if (x120_ADV6) - { - w.enterSubRecord("ADV6"); - x120_ADV6.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ADV6")) + x120_ADV6.write(w); if (x124_ADV7) - { - w.enterSubRecord("ADV7"); - x124_ADV7.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ADV7")) + x124_ADV7.write(w); if (x128_ADV8) - { - w.enterSubRecord("ADV8"); - x128_ADV8.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ADV8")) + x128_ADV8.write(w); } template diff --git a/DataSpec/DNACommon/ParticleCommon.cpp b/DataSpec/DNACommon/ParticleCommon.cpp index 1bd486bcf..e35c1269e 100644 --- a/DataSpec/DNACommon/ParticleCommon.cpp +++ b/DataSpec/DNACommon/ParticleCommon.cpp @@ -125,19 +125,15 @@ void RealElementFactory::read(athena::io::YAMLDocReader& r) m_elem.reset(); return; } - r.enterSubRecord(elem.first.c_str()); - m_elem->read(r); - r.leaveSubRecord(); + if (auto rec = r.enterSubRecord(elem.first.c_str())) + m_elem->read(r); } void RealElementFactory::write(athena::io::YAMLDocWriter& w) const { if (m_elem) - { - w.enterSubRecord(m_elem->ClassID()); - m_elem->write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord(m_elem->ClassID())) + m_elem->write(w); } 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()); - m_elem->read(r); - r.leaveSubRecord(); + if (auto rec = r.enterSubRecord(elem.first.c_str())) + m_elem->read(r); } void IntElementFactory::write(athena::io::YAMLDocWriter& w) const { if (m_elem) - { - w.enterSubRecord(m_elem->ClassID()); - m_elem->write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord(m_elem->ClassID())) + m_elem->write(w); } 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()); - m_elem->read(r); - r.leaveSubRecord(); + if (auto rec = r.enterSubRecord(elem.first.c_str())) + m_elem->read(r); } void VectorElementFactory::write(athena::io::YAMLDocWriter& w) const { if (m_elem) - { - w.enterSubRecord(m_elem->ClassID()); - m_elem->write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord(m_elem->ClassID())) + m_elem->write(w); } 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()); - m_elem->read(r); - r.leaveSubRecord(); + if (auto rec = r.enterSubRecord(elem.first.c_str())) + m_elem->read(r); } void ColorElementFactory::write(athena::io::YAMLDocWriter& w) const { if (m_elem) - { - w.enterSubRecord(m_elem->ClassID()); - m_elem->write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord(m_elem->ClassID())) + m_elem->write(w); } 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()); - m_elem->read(r); - r.leaveSubRecord(); + if (auto rec = r.enterSubRecord(elem.first.c_str())) + m_elem->read(r); } void ModVectorElementFactory::write(athena::io::YAMLDocWriter& w) const { if (m_elem) - { - w.enterSubRecord(m_elem->ClassID()); - m_elem->write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord(m_elem->ClassID())) + m_elem->write(w); } 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()); - m_elem->read(r); - r.leaveSubRecord(); + if (auto rec = r.enterSubRecord(elem.first.c_str())) + m_elem->read(r); } void EmitterElementFactory::write(athena::io::YAMLDocWriter& w) const { if (m_elem) - { - w.enterSubRecord(m_elem->ClassID()); - m_elem->write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord(m_elem->ClassID())) + m_elem->write(w); } size_t EmitterElementFactory::binarySize(size_t __isz) const diff --git a/DataSpec/DNACommon/ParticleCommon.hpp b/DataSpec/DNACommon/ParticleCommon.hpp index dca952350..5a54ab2b2 100644 --- a/DataSpec/DNACommon/ParticleCommon.hpp +++ b/DataSpec/DNACommon/ParticleCommon.hpp @@ -631,25 +631,21 @@ struct VEConstant : IVectorElement void read(athena::io::YAMLDocReader& r) { size_t elemCount; - r.enterSubVector(nullptr, elemCount); - for (int i=0 ; i<3 && i); m_elem->read(r); - r.leaveSubRecord(); } - else if (r.enterSubRecord("ATEX")) + else if (auto rec = r.enterSubRecord("ATEX")) { m_elem.reset(new struct UVEAnimTexture); 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()); - m_elem->write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord(m_elem->ClassID())) + m_elem->write(w); } 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"); - id.write(w); - w.leaveSubRecord(); + if (auto rec = w.enterSubRecord("id")) + id.write(w); 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); - info.read(r); - r.leaveSubRecord(); + if (auto rec = r.enterSubRecord(nullptr)) + info.read(r); } - 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"); - for (const auto& spawn : spawns) + if (auto v = w.enterSubVector("spawns")) { - w.enterSubRecord(nullptr); - w.writeUint32("startFrame", spawn.first); - w.enterSubVector("systems"); - for (const auto& info : spawn.second) + for (const auto& spawn : spawns) { - w.enterSubRecord(nullptr); - info.write(w); - w.leaveSubRecord(); + if (auto rec = 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.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"); - id.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("CNST")) + id.write(w); } size_t binarySize(size_t __isz) const { diff --git a/DataSpec/DNACommon/SWHC.cpp b/DataSpec/DNACommon/SWHC.cpp index b46f62a12..7c8ff7ff0 100644 --- a/DataSpec/DNACommon/SWHC.cpp +++ b/DataSpec/DNACommon/SWHC.cpp @@ -16,96 +16,96 @@ void SWSH::read(athena::io::YAMLDocReader& r) continue; } - r.enterSubRecord(elem.first.c_str()); - switch(*reinterpret_cast(elem.first.data())) + if (auto rec = r.enterSubRecord(elem.first.c_str())) { - case SBIG('PSLT'): - x0_PSLT.read(r); - break; - case SBIG('TIME'): - x4_TIME.read(r); - break; - case SBIG('LRAD'): - x8_LRAD.read(r); - break; - case SBIG('RRAD'): - xc_RRAD.read(r); - break; - case SBIG('LENG'): - x10_LENG.read(r); - break; - case SBIG('COLR'): - x14_COLR.read(r); - break; - case SBIG('SIDE'): - x18_SIDE.read(r); - break; - case SBIG('IROT'): - x1c_IROT.read(r); - break; - case SBIG('ROTM'): - x20_ROTM.read(r); - break; - case SBIG('POFS'): - x24_POFS.read(r); - break; - case SBIG('IVEL'): - x28_IVEL.read(r); - break; - case SBIG('NPOS'): - x2c_NPOS.read(r); - break; - case SBIG('VELM'): - x30_VELM.read(r); - break; - case SBIG('VLM2'): - x34_VLM2.read(r); - break; - case SBIG('SPLN'): - x38_SPLN.read(r); - break; - case SBIG('TEXR'): - x3c_TEXR.read(r); - break; - case SBIG('TSPN'): - x40_TSPN.read(r); - break; - case SBIG('LLRD'): - x44_24_LLRD = r.readBool(nullptr); - break; - case SBIG('CROS'): - x44_25_CROS = r.readBool(nullptr); - break; - case SBIG('VLS1'): - x44_26_VLS1 = r.readBool(nullptr); - break; - case SBIG('VLS2'): - x44_27_VLS2 = r.readBool(nullptr); - break; - case SBIG('SROT'): - x44_28_SROT = r.readBool(nullptr); - break; - case SBIG('WIRE'): - x44_29_WIRE = r.readBool(nullptr); - break; - case SBIG('TEXW'): - x44_30_TEXW = r.readBool(nullptr); - break; - case SBIG('AALP'): - x44_31_AALP = r.readBool(nullptr); - break; - case SBIG('ZBUF'): - x45_24_ZBUF = r.readBool(nullptr); - break; - case SBIG('ORNT'): - x45_25_ORNT = r.readBool(nullptr); - break; - case SBIG('CRND'): - x45_26_CRND = r.readBool(nullptr); - break; + switch(*reinterpret_cast(elem.first.data())) + { + case SBIG('PSLT'): + x0_PSLT.read(r); + break; + case SBIG('TIME'): + x4_TIME.read(r); + break; + case SBIG('LRAD'): + x8_LRAD.read(r); + break; + case SBIG('RRAD'): + xc_RRAD.read(r); + break; + case SBIG('LENG'): + x10_LENG.read(r); + break; + case SBIG('COLR'): + x14_COLR.read(r); + break; + case SBIG('SIDE'): + x18_SIDE.read(r); + break; + case SBIG('IROT'): + x1c_IROT.read(r); + break; + case SBIG('ROTM'): + x20_ROTM.read(r); + break; + case SBIG('POFS'): + x24_POFS.read(r); + break; + case SBIG('IVEL'): + x28_IVEL.read(r); + break; + case SBIG('NPOS'): + x2c_NPOS.read(r); + break; + case SBIG('VELM'): + x30_VELM.read(r); + break; + case SBIG('VLM2'): + x34_VLM2.read(r); + break; + case SBIG('SPLN'): + x38_SPLN.read(r); + break; + case SBIG('TEXR'): + x3c_TEXR.read(r); + break; + case SBIG('TSPN'): + x40_TSPN.read(r); + break; + case SBIG('LLRD'): + x44_24_LLRD = r.readBool(nullptr); + break; + case SBIG('CROS'): + x44_25_CROS = r.readBool(nullptr); + break; + case SBIG('VLS1'): + x44_26_VLS1 = r.readBool(nullptr); + break; + case SBIG('VLS2'): + x44_27_VLS2 = r.readBool(nullptr); + break; + case SBIG('SROT'): + x44_28_SROT = r.readBool(nullptr); + break; + case SBIG('WIRE'): + x44_29_WIRE = r.readBool(nullptr); + break; + case SBIG('TEXW'): + x44_30_TEXW = r.readBool(nullptr); + break; + case SBIG('AALP'): + x44_31_AALP = r.readBool(nullptr); + break; + case SBIG('ZBUF'): + x45_24_ZBUF = r.readBool(nullptr); + break; + case SBIG('ORNT'): + x45_25_ORNT = r.readBool(nullptr); + break; + case SBIG('CRND'): + x45_26_CRND = r.readBool(nullptr); + break; + } } - - r.leaveSubRecord(); } } @@ -113,107 +113,56 @@ template void SWSH::write(athena::io::YAMLDocWriter& w) const { if (x0_PSLT) - { - w.enterSubRecord("PSLT"); - x0_PSLT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PSLT")) + x0_PSLT.write(w); if (x4_TIME) - { - w.enterSubRecord("TIME"); - x4_TIME.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("TIME")) + x4_TIME.write(w); if (x8_LRAD) - { - w.enterSubRecord("LRAD"); - x8_LRAD.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LRAD")) + x8_LRAD.write(w); if (xc_RRAD) - { - w.enterSubRecord("RRAD"); - xc_RRAD.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("RRAD")) + xc_RRAD.write(w); if (x10_LENG) - { - w.enterSubRecord("LENG"); - x10_LENG.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LENG")) + x10_LENG.write(w); if (x14_COLR) - { - w.enterSubRecord("COLR"); - x14_COLR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("COLR")) + x14_COLR.write(w); if (x18_SIDE) - { - w.enterSubRecord("SIDE"); - x18_SIDE.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SIDE")) + x18_SIDE.write(w); if (x1c_IROT) - { - w.enterSubRecord("IROT"); - x1c_IROT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("IROT")) + x1c_IROT.write(w); if (x20_ROTM) - { - w.enterSubRecord("ROTM"); - x20_ROTM.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ROTM")) + x20_ROTM.write(w); if (x24_POFS) - { - w.enterSubRecord("POFS"); - x24_POFS.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("POFS")) + x24_POFS.write(w); if (x28_IVEL) - { - w.enterSubRecord("IVEL"); - x28_IVEL.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("IVEL")) + x28_IVEL.write(w); if (x2c_NPOS) - { - w.enterSubRecord("NPOS"); - x2c_NPOS.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("NPOS")) + x2c_NPOS.write(w); if (x30_VELM) - { - w.enterSubRecord("VELM"); - x30_VELM.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("VELM")) + x30_VELM.write(w); if (x34_VLM2) - { - w.enterSubRecord("VLM2"); - x34_VLM2.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("VLM2")) + x34_VLM2.write(w); if (x38_SPLN) - { - w.enterSubRecord("SPLN"); - x38_SPLN.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SPLN")) + x38_SPLN.write(w); if (x3c_TEXR) - { - w.enterSubRecord("TEXR"); - x3c_TEXR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("TEXR")) + x3c_TEXR.write(w); if (x40_TSPN) - { - w.enterSubRecord("TSPN"); - x40_TSPN.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("TSPN")) + x40_TSPN.write(w); if (x44_24_LLRD) w.writeBool("LLRD", true); diff --git a/DataSpec/DNACommon/WPSC.cpp b/DataSpec/DNACommon/WPSC.cpp index 4dbb8f6f9..8ad735fd6 100644 --- a/DataSpec/DNACommon/WPSC.cpp +++ b/DataSpec/DNACommon/WPSC.cpp @@ -16,115 +16,114 @@ void WPSM::read(athena::io::YAMLDocReader& r) continue; } - r.enterSubRecord(elem.first.c_str()); - - switch (*reinterpret_cast(elem.first.data())) + if (auto rec = r.enterSubRecord(elem.first.c_str())) { - case SBIG('IORN'): - x0_IORN.read(r); - break; - case SBIG('IVEC'): - x4_IVEC.read(r); - break; - case SBIG('PSOV'): - x8_PSOV.read(r); - break; - case SBIG('PSVM'): - xc_PSVM.read(r); - break; - case SBIG('VMD2'): - x10_VMD2.read(r); - break; - case SBIG('PSLT'): - x14_PSLT.read(r); - break; - case SBIG('PSCL'): - x18_PSCL.read(r); - break; - case SBIG('PCOL'): - x1c_PCOL.read(r); - break; - case SBIG('POFS'): - x20_POFS.read(r); - break; - case SBIG('OFST'): - x24_OFST.read(r); - break; - case SBIG('APSO'): - x28_APSO.read(r); - break; - case SBIG('HOMG'): - x29_HOMG.read(r); - break; - case SBIG('AP11'): - x2a_AP11.read(r); - break; - case SBIG('AP21'): - x2b_AP21.read(r); - break; - case SBIG('AS11'): - x2c_AS11.read(r); - break; - case SBIG('AS12'): - x2d_AS12.read(r); - break; - case SBIG('AS13'): - x2e_AS13.read(r); - break; - case SBIG('TRAT'): - x30_TRAT.read(r); - break; - case SBIG('APSM'): - x34_APSM.read(r); - break; - case SBIG('APS2'): - x44_APS2.read(r); - break; - case SBIG('ASW1'): - x54_ASW1.read(r); - break; - case SBIG('ASW2'): - x64_ASW2.read(r); - break; - case SBIG('ASW3'): - x74_ASW3.read(r); - break; - case SBIG('OHEF'): - x84_OHEF.read(r); - break; - case SBIG('COLR'): - x94_COLR.read(r); - break; - case SBIG('EWTR'): - xa4_EWTR.read(r); - break; - case SBIG('LWTR'): - xa5_LWTR.read(r); - break; - case SBIG('SWTR'): - xa6_SWTR.read(r); - break; - case SBIG('PJFX'): - xa8_PJFX = r.readUint32(nullptr); - break; - case SBIG('RNGE'): - xac_RNGE.read(r); - break; - case SBIG('FOFF'): - xb0_FOFF.read(r); - break; - case SBIG('FC60'): - xunk_FC60.read(r); - break; - case SBIG('SPS1'): - xunk_SPS2.read(r); - break; - case SBIG('SPS2'): - xunk_SPS2.read(r); - break; + switch (*reinterpret_cast(elem.first.data())) + { + case SBIG('IORN'): + x0_IORN.read(r); + break; + case SBIG('IVEC'): + x4_IVEC.read(r); + break; + case SBIG('PSOV'): + x8_PSOV.read(r); + break; + case SBIG('PSVM'): + xc_PSVM.read(r); + break; + case SBIG('VMD2'): + x10_VMD2.read(r); + break; + case SBIG('PSLT'): + x14_PSLT.read(r); + break; + case SBIG('PSCL'): + x18_PSCL.read(r); + break; + case SBIG('PCOL'): + x1c_PCOL.read(r); + break; + case SBIG('POFS'): + x20_POFS.read(r); + break; + case SBIG('OFST'): + x24_OFST.read(r); + break; + case SBIG('APSO'): + x28_APSO.read(r); + break; + case SBIG('HOMG'): + x29_HOMG.read(r); + break; + case SBIG('AP11'): + x2a_AP11.read(r); + break; + case SBIG('AP21'): + x2b_AP21.read(r); + break; + case SBIG('AS11'): + x2c_AS11.read(r); + break; + case SBIG('AS12'): + x2d_AS12.read(r); + break; + case SBIG('AS13'): + x2e_AS13.read(r); + break; + case SBIG('TRAT'): + x30_TRAT.read(r); + break; + case SBIG('APSM'): + x34_APSM.read(r); + break; + case SBIG('APS2'): + x44_APS2.read(r); + break; + case SBIG('ASW1'): + x54_ASW1.read(r); + break; + case SBIG('ASW2'): + x64_ASW2.read(r); + break; + case SBIG('ASW3'): + x74_ASW3.read(r); + break; + case SBIG('OHEF'): + x84_OHEF.read(r); + break; + case SBIG('COLR'): + x94_COLR.read(r); + break; + case SBIG('EWTR'): + xa4_EWTR.read(r); + break; + case SBIG('LWTR'): + xa5_LWTR.read(r); + break; + case SBIG('SWTR'): + xa6_SWTR.read(r); + break; + case SBIG('PJFX'): + xa8_PJFX = r.readUint32(nullptr); + break; + case SBIG('RNGE'): + xac_RNGE.read(r); + break; + case SBIG('FOFF'): + xb0_FOFF.read(r); + break; + case SBIG('FC60'): + xunk_FC60.read(r); + break; + case SBIG('SPS1'): + xunk_SPS2.read(r); + break; + case SBIG('SPS2'): + xunk_SPS2.read(r); + break; + } } - - r.leaveSubRecord(); } } @@ -132,205 +131,106 @@ template void WPSM::write(athena::io::YAMLDocWriter& w) const { if (x0_IORN) - { - w.enterSubRecord("IORN"); - x0_IORN.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("IORN")) + x0_IORN.write(w); if (x4_IVEC) - { - w.enterSubRecord("IVEC"); - x4_IVEC.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("IVEC")) + x4_IVEC.write(w); if (x8_PSOV) - { - w.enterSubRecord("PSOV"); - x8_PSOV.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PSOV")) + x8_PSOV.write(w); if (xc_PSVM) - { - w.enterSubRecord("PSVM"); - xc_PSVM.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PSVM")) + xc_PSVM.write(w); if (x10_VMD2) - { - w.enterSubRecord("VMD2"); - x10_VMD2.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("VMD2")) + x10_VMD2.write(w); if (x14_PSLT) - { - w.enterSubRecord("PSLT"); - x14_PSLT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PSLT")) + x14_PSLT.write(w); if (x18_PSCL) - { - w.enterSubRecord("PSCL"); - x18_PSCL.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PSCL")) + x18_PSCL.write(w); if (x1c_PCOL) - { - w.enterSubRecord("PCOL"); - x1c_PCOL.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("PCOL")) + x1c_PCOL.write(w); if (x20_POFS) - { - w.enterSubRecord("POFS"); - x20_POFS.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("POFS")) + x20_POFS.write(w); if (x24_OFST) - { - w.enterSubRecord("OFST"); - x24_OFST.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("OFST")) + x24_OFST.write(w); if (x28_APSO) - { - w.enterSubRecord("APSO"); - x28_APSO.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("APSO")) + x28_APSO.write(w); if (x29_HOMG) - { - w.enterSubRecord("HOMG"); - x29_HOMG.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("HOMG")) + x29_HOMG.write(w); if (x2a_AP11) - { - w.enterSubRecord("AP11"); - x2a_AP11.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("AP11")) + x2a_AP11.write(w); if (x2b_AP21) - { - w.enterSubRecord("AP21"); - x2b_AP21.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("AP21")) + x2b_AP21.write(w); if (x2c_AS11) - { - w.enterSubRecord("AS11"); - x2c_AS11.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("AS11")) + x2c_AS11.write(w); if (x2d_AS12) - { - w.enterSubRecord("AS12"); - x2d_AS12.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("AS12")) + x2d_AS12.write(w); if (x2e_AS13) - { - w.enterSubRecord("AS13"); - x2e_AS13.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("AS13")) + x2e_AS13.write(w); if (x30_TRAT) - { - w.enterSubRecord("TRAT"); - x30_TRAT.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("TRAT")) + x30_TRAT.write(w); if (x34_APSM) - { - w.enterSubRecord("APSM"); - x34_APSM.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("APSM")) + x34_APSM.write(w); if (x44_APS2) - { - w.enterSubRecord("APS2"); - x44_APS2.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("APS2")) + x44_APS2.write(w); if (x54_ASW1) - { - w.enterSubRecord("ASW1"); - x54_ASW1.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ASW1")) + x54_ASW1.write(w); if (x64_ASW2) - { - w.enterSubRecord("ASW2"); - x64_ASW2.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ASW2")) + x64_ASW2.write(w); if (x74_ASW3) - { - w.enterSubRecord("ASW3"); - x74_ASW3.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("ASW3")) + x74_ASW3.write(w); if (x84_OHEF) - { - w.enterSubRecord("OHEF"); - x84_OHEF.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("OHEF")) + x84_OHEF.write(w); if (x94_COLR) - { - w.enterSubRecord("COLR"); - x94_COLR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("COLR")) + x94_COLR.write(w); if (!xa4_EWTR) - { - w.enterSubRecord("EWTR"); - xa4_EWTR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("EWTR")) + xa4_EWTR.write(w); if (!xa5_LWTR) - { - w.enterSubRecord("LWTR"); - xa5_LWTR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("LWTR")) + xa5_LWTR.write(w); if (!xa6_SWTR) - { - w.enterSubRecord("SWTR"); - xa6_SWTR.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SWTR")) + xa6_SWTR.write(w); if (xa8_PJFX != ~0) w.writeUint32("PJFX", xa8_PJFX); if (xac_RNGE) - { - w.enterSubRecord("RNGE"); - xac_RNGE.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("RNGE")) + xac_RNGE.write(w); if (xb0_FOFF) - { - w.enterSubRecord("FOFF"); - xb0_FOFF.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("FOFF")) + xb0_FOFF.write(w); if (xunk_FC60) - { - w.enterSubRecord("FC60"); - xunk_FC60.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("FC60")) + xunk_FC60.write(w); if (xunk_SPS1) - { - w.enterSubRecord("SPS1"); - xunk_SPS1.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SPS1")) + xunk_SPS1.write(w); if (xunk_SPS1) - { - w.enterSubRecord("SPS2"); - xunk_SPS2.write(w); - w.leaveSubRecord(); - } + if (auto rec = w.enterSubRecord("SPS2")) + xunk_SPS2.write(w); } template diff --git a/DataSpec/DNAMP1/ANCS.cpp b/DataSpec/DNAMP1/ANCS.cpp index e7cf7849e..3312155ed 100644 --- a/DataSpec/DNAMP1/ANCS.cpp +++ b/DataSpec/DNAMP1/ANCS.cpp @@ -86,29 +86,30 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::read(a unk1 = reader.readUint32("unk1"); unk2 = reader.readFloat("unk2"); size_t parmValCount; - reader.enterSubVector("parmVals", parmValCount); - switch (DataType(parmType)) + if (auto v = reader.enterSubVector("parmVals", parmValCount)) { - case DataType::Int32: - parmVals[0].int32 = reader.readInt32(nullptr); - parmVals[1].int32 = reader.readInt32(nullptr); - break; - case DataType::UInt32: - case DataType::Enum: - parmVals[0].uint32 = reader.readUint32(nullptr); - parmVals[1].uint32 = reader.readUint32(nullptr); - break; - case DataType::Float: - parmVals[0].float32 = reader.readFloat(nullptr); - parmVals[1].float32 = reader.readFloat(nullptr); - break; - case DataType::Bool: - parmVals[0].bool1 = reader.readBool(nullptr); - parmVals[1].bool1 = reader.readBool(nullptr); - break; - default: break; + switch (DataType(parmType)) + { + case DataType::Int32: + parmVals[0].int32 = reader.readInt32(nullptr); + parmVals[1].int32 = reader.readInt32(nullptr); + break; + case DataType::UInt32: + case DataType::Enum: + parmVals[0].uint32 = reader.readUint32(nullptr); + parmVals[1].uint32 = reader.readUint32(nullptr); + break; + case DataType::Float: + parmVals[0].float32 = reader.readFloat(nullptr); + parmVals[1].float32 = reader.readFloat(nullptr); + break; + case DataType::Bool: + parmVals[0].bool1 = reader.readBool(nullptr); + parmVals[1].bool1 = reader.readBool(nullptr); + break; + default: break; + } } - reader.leaveSubVector(); } void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::write(athena::io::YAMLDocWriter& writer) const @@ -116,28 +117,29 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::write( writer.writeUint32("parmType", parmType); writer.writeUint32("unk1", unk1); writer.writeFloat("unk2", unk2); - writer.enterSubVector("parmVals"); - switch (DataType(parmType)) + if (auto v = writer.enterSubVector("parmVals")) { - case DataType::Int32: - writer.writeInt32(nullptr, parmVals[0].int32); - writer.writeInt32(nullptr, parmVals[1].int32); - break; - case DataType::UInt32: - case DataType::Enum: - writer.writeUint32(nullptr, parmVals[0].uint32); - writer.writeUint32(nullptr, parmVals[0].uint32); - break; - case DataType::Float: - writer.writeFloat(nullptr, parmVals[0].float32); - writer.writeFloat(nullptr, parmVals[0].float32); - break; - case DataType::Bool: - writer.writeBool(nullptr, parmVals[0].bool1); - writer.writeBool(nullptr, parmVals[0].bool1); - break; + switch (DataType(parmType)) + { + case DataType::Int32: + writer.writeInt32(nullptr, parmVals[0].int32); + writer.writeInt32(nullptr, parmVals[1].int32); + break; + case DataType::UInt32: + case DataType::Enum: + writer.writeUint32(nullptr, parmVals[0].uint32); + writer.writeUint32(nullptr, parmVals[0].uint32); + break; + case DataType::Float: + writer.writeFloat(nullptr, parmVals[0].float32); + writer.writeFloat(nullptr, parmVals[0].float32); + break; + case DataType::Bool: + writer.writeBool(nullptr, parmVals[0].bool1); + writer.writeBool(nullptr, parmVals[0].bool1); + break; + } } - writer.leaveSubVector(); } const char* ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::DNAType() @@ -260,28 +262,29 @@ 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); - for (const ParmInfo& pi : parmInfos) + if (auto v = reader.enterSubVector("parms", parmValCount)) { - switch (ParmInfo::DataType(pi.parmType)) + for (const ParmInfo& pi : parmInfos) { - case ParmInfo::DataType::Int32: - ai.parmVals.emplace_back(reader.readInt32(nullptr)); - break; - case ParmInfo::DataType::UInt32: - case ParmInfo::DataType::Enum: - ai.parmVals.emplace_back(reader.readUint32(nullptr)); - break; - case ParmInfo::DataType::Float: - ai.parmVals.emplace_back(reader.readFloat(nullptr)); - break; - case ParmInfo::DataType::Bool: - ai.parmVals.emplace_back(reader.readBool(nullptr)); - break; - default: break; + switch (ParmInfo::DataType(pi.parmType)) + { + case ParmInfo::DataType::Int32: + ai.parmVals.emplace_back(reader.readInt32(nullptr)); + break; + case ParmInfo::DataType::UInt32: + case ParmInfo::DataType::Enum: + ai.parmVals.emplace_back(reader.readUint32(nullptr)); + break; + case ParmInfo::DataType::Float: + ai.parmVals.emplace_back(reader.readFloat(nullptr)); + break; + case ParmInfo::DataType::Bool: + ai.parmVals.emplace_back(reader.readBool(nullptr)); + break; + default: break; + } } } - reader.leaveSubVector(); }); } @@ -296,31 +299,32 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::write(athena::io { writer.writeUint32("id", ai.id); auto it = ai.parmVals.begin(); - writer.enterSubVector("parms"); - for (const ParmInfo& pi : parmInfos) + if (auto v = writer.enterSubVector("parms")) { - ParmInfo::Parm pVal; - if (it != ai.parmVals.end()) - pVal = *it++; - switch (ParmInfo::DataType(pi.parmType)) + for (const ParmInfo& pi : parmInfos) { - case ParmInfo::DataType::Int32: - writer.writeInt32(nullptr, pVal.int32); - break; - case ParmInfo::DataType::UInt32: - case ParmInfo::DataType::Enum: - writer.writeUint32(nullptr, pVal.uint32); - break; - case ParmInfo::DataType::Float: - writer.writeFloat(nullptr, pVal.float32); - break; - case ParmInfo::DataType::Bool: - writer.writeBool(nullptr, pVal.bool1); - break; - default: break; + ParmInfo::Parm pVal; + if (it != ai.parmVals.end()) + pVal = *it++; + switch (ParmInfo::DataType(pi.parmType)) + { + case ParmInfo::DataType::Int32: + writer.writeInt32(nullptr, pVal.int32); + break; + case ParmInfo::DataType::UInt32: + case ParmInfo::DataType::Enum: + writer.writeUint32(nullptr, pVal.uint32); + break; + case ParmInfo::DataType::Float: + writer.writeFloat(nullptr, pVal.float32); + break; + case ParmInfo::DataType::Bool: + writer.writeBool(nullptr, pVal.bool1); + break; + default: break; + } } } - writer.leaveSubVector(); }); } diff --git a/DataSpec/DNAMP1/ANCS.hpp b/DataSpec/DNAMP1/ANCS.hpp index aeaef0d1e..5b6ba96f1 100644 --- a/DataSpec/DNAMP1/ANCS.hpp +++ b/DataSpec/DNAMP1/ANCS.hpp @@ -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& 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, diff --git a/DataSpec/DNAMP1/CSNG.cpp b/DataSpec/DNAMP1/CSNG.cpp index 43181b20e..9807ca276 100644 --- a/DataSpec/DNAMP1/CSNG.cpp +++ b/DataSpec/DNAMP1/CSNG.cpp @@ -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"); - head.agscId.write(dw); - dw.leaveSubRecord(); + if (auto rec = dw.enterSubRecord("agscId")) + head.agscId.write(dw); 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"); - head.agscId.read(dr); - dr.leaveSubRecord(); + if (auto rec = dr.enterSubRecord("agscId")) + head.agscId.read(dr); head.sngLength = sngData.size(); head.write(w); } diff --git a/DataSpec/DNAMP1/SCLY.cpp b/DataSpec/DNAMP1/SCLY.cpp index d1ef91001..4ce5bc338 100644 --- a/DataSpec/DNAMP1/SCLY.cpp +++ b/DataSpec/DNAMP1/SCLY.cpp @@ -143,30 +143,29 @@ 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); - 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; }); - - if (iter != SCRIPT_OBJECT_DB.end()) + if (auto rec = rs.enterSubRecord(nullptr)) { - std::unique_ptr obj((*iter)->a()); - obj->read(rs); - obj->type = type; - objects.push_back(std::move(obj)); - } - else - Log.report(logvisor::Fatal, _S("Unable to find type 0x%X in object database"), (atUint32)type); + 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; }); - rs.leaveSubRecord(); + if (iter != SCRIPT_OBJECT_DB.end()) + { + std::unique_ptr obj((*iter)->a()); + obj->read(rs); + obj->type = type; + objects.push_back(std::move(obj)); + } + else + Log.report(logvisor::Fatal, _S("Unable to find type 0x%X in object database"), (atUint32)type); + } } - 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"); - for (const std::unique_ptr& obj : objects) + if (auto v = ws.enterSubVector("objects")) { - ws.enterSubRecord(nullptr); - ws.writeUByte("type", obj->type); - obj->write(ws); - ws.leaveSubRecord(); - }; - ws.leaveSubVector(); + for (const std::unique_ptr& obj : objects) + { + if (auto rec = ws.enterSubRecord(nullptr)) + { + ws.writeUByte("type", obj->type); + obj->write(ws); + } + } + } } const char* SCLY::ScriptLayer::DNAType() diff --git a/DataSpec/DNAMP1/STRG.cpp b/DataSpec/DNAMP1/STRG.cpp index 2ac1bb318..79cb8739e 100644 --- a/DataSpec/DNAMP1/STRG.cpp +++ b/DataSpec/DNAMP1/STRG.cpp @@ -562,10 +562,9 @@ void STRG::write(athena::io::YAMLDocWriter& writer) const { for (const auto& lang : langs) { - writer.enterSubVector(lang.first.toString().c_str()); - for (const std::u16string& str : lang.second) - writer.writeU16String(nullptr, str); - writer.leaveSubVector(); + if (auto v = writer.enterSubVector(lang.first.toString().c_str())) + for (const std::u16string& str : lang.second) + writer.writeU16String(nullptr, str); } } diff --git a/DataSpec/DNAMP1/Tweaks/CTweakBall.cpp b/DataSpec/DNAMP1/Tweaks/CTweakBall.cpp index 83134b9a3..e18a7402a 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakBall.cpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakBall.cpp @@ -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_ */ diff --git a/DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp b/DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp index 5f04b81e3..60c484e1a 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp @@ -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_ */ diff --git a/DataSpec/DNAMP2/STRG.cpp b/DataSpec/DNAMP2/STRG.cpp index f042043d1..86588bb5f 100644 --- a/DataSpec/DNAMP2/STRG.cpp +++ b/DataSpec/DNAMP2/STRG.cpp @@ -229,21 +229,16 @@ void STRG::write(athena::io::YAMLDocWriter& writer) const { for (const auto& lang : langs) { - writer.enterSubVector(lang.first.toString().c_str()); - for (const std::u16string& str : lang.second) - writer.writeU16String(nullptr, str); - writer.leaveSubVector(); + if (auto v = writer.enterSubVector(lang.first.toString().c_str())) + for (const std::u16string& str : lang.second) + writer.writeU16String(nullptr, str); } if (names.size()) { - writer.enterSubRecord("names"); - for (const auto& name : names) - { - writer.enterSubRecord(name.first.c_str()); - writer.writeInt32(nullptr, name.second); - writer.leaveSubRecord(); - } - writer.leaveSubRecord(); + if (auto rec = writer.enterSubRecord("names")) + for (const auto& name : names) + if (auto rec = writer.enterSubRecord(name.first.c_str())) + writer.writeInt32(nullptr, name.second); } } diff --git a/DataSpec/DNAMP3/STRG.cpp b/DataSpec/DNAMP3/STRG.cpp index 9e3a8adcc..e91d8c1df 100644 --- a/DataSpec/DNAMP3/STRG.cpp +++ b/DataSpec/DNAMP3/STRG.cpp @@ -247,22 +247,17 @@ void STRG::write(athena::io::YAMLDocWriter& writer) const { for (const auto& item : langs) { - writer.enterSubVector(item.first.toString().c_str()); - for (const std::string& str : item.second) - writer.writeString(nullptr, str); - writer.leaveSubVector(); + if (auto v = writer.enterSubVector(item.first.toString().c_str())) + for (const std::string& str : item.second) + writer.writeString(nullptr, str); } if (names.size()) { - writer.enterSubRecord("names"); - for (const auto& item : names) - { - writer.enterSubRecord(item.first.c_str()); - writer.writeInt32(nullptr, item.second); - writer.leaveSubRecord(); - } - writer.leaveSubRecord(); + if (auto rec = writer.enterSubRecord("names")) + for (const auto& item : names) + if (auto rec = writer.enterSubRecord(item.first.c_str())) + writer.writeInt32(nullptr, item.second); } } diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index d9c02e7d4..4613b39b8 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -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; diff --git a/Editor/ProjectResourceFactoryBase.cpp b/Editor/ProjectResourceFactoryBase.cpp index 99c001ae0..4fff8a7ff 100644 --- a/Editor/ProjectResourceFactoryBase.cpp +++ b/Editor/ProjectResourceFactoryBase.cpp @@ -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); - cacheWriter.writeString(nullptr, pathTag.type.toString().c_str()); - cacheWriter.writeString(nullptr, path.getAuxInfo().size() ? - (path.getRelativePathUTF8() + '|' + path.getAuxInfoUTF8()) : - path.getRelativePathUTF8()); - cacheWriter.leaveSubVector(); + 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()); + } } static void WriteNameTag(athena::io::YAMLDocWriter& nameWriter, diff --git a/Editor/ProjectResourceFactoryMP1.cpp b/Editor/ProjectResourceFactoryMP1.cpp index 7581a7f26..38624c433 100644 --- a/Editor/ProjectResourceFactoryMP1.cpp +++ b/Editor/ProjectResourceFactoryMP1.cpp @@ -118,6 +118,19 @@ void ProjectResourceFactoryMP1::IndexMP1Resources(hecl::Database::Project& proj, m_origIds = sp.GetObj("MP1OriginalIDs"); } +void ProjectResourceFactoryMP1::GetTagListForFile(const char* pakName, std::vector& out) const +{ + std::string pathPrefix("MP1/"); + pathPrefix += pakName; + pathPrefix += '/'; + + std::unique_lock lk( + const_cast(*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(); diff --git a/Editor/ProjectResourceFactoryMP1.hpp b/Editor/ProjectResourceFactoryMP1.hpp index a3c77c044..051f36986 100644 --- a/Editor/ProjectResourceFactoryMP1.hpp +++ b/Editor/ProjectResourceFactoryMP1.hpp @@ -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& out) const; void Shutdown(); ResId TranslateOriginalToNew(ResId id) const; diff --git a/Editor/Space.hpp b/Editor/Space.hpp index 36a2d9e30..0e20ebfd3 100644 --- a/Editor/Space.hpp +++ b/Editor/Space.hpp @@ -173,9 +173,8 @@ public: : RootSpace(vm) { m_state.read(r); - r.enterSubRecord("spaceTree"); - m_spaceTree.reset(NewSpaceFromConfigStream(vm, this, r)); - r.leaveSubRecord(); + if (auto rec = r.enterSubRecord("spaceTree")) + m_spaceTree.reset(NewSpaceFromConfigStream(vm, this, r)); } void think() @@ -200,12 +199,13 @@ public: w.writeUint32("class", atUint32(m_class)); m_state.write(w); - w.enterSubRecord("spaceTree"); - if (m_spaceTree) - m_spaceTree->saveState(w); - else - w.writeUint32("class", 0); - w.leaveSubRecord(); + if (auto rec = w.enterSubRecord("spaceTree")) + { + if (m_spaceTree) + m_spaceTree->saveState(w); + else + w.writeUint32("class", 0); + } } void setChild(std::unique_ptr&& space) @@ -248,12 +248,10 @@ public: : SplitSpace(vm, parent, specter::SplitView::Axis::Horizontal) { m_state.read(r); - r.enterSubRecord("slot0"); - m_slots[0].reset(NewSpaceFromConfigStream(vm, this, r)); - r.leaveSubRecord(); - r.enterSubRecord("slot1"); - m_slots[1].reset(NewSpaceFromConfigStream(vm, this, r)); - r.leaveSubRecord(); + if (auto rec = r.enterSubRecord("slot0")) + m_slots[0].reset(NewSpaceFromConfigStream(vm, this, r)); + if (auto rec = r.enterSubRecord("slot1")) + m_slots[1].reset(NewSpaceFromConfigStream(vm, this, r)); reloadState(); } @@ -300,19 +298,21 @@ public: w.writeUint32("class", atUint32(m_class)); m_state.write(w); - w.enterSubRecord("slot0"); - if (m_slots[0]) - m_slots[0]->saveState(w); - else - w.writeUint32("class", 0); - w.leaveSubRecord(); + if (auto rec = w.enterSubRecord("slot0")) + { + if (m_slots[0]) + m_slots[0]->saveState(w); + else + w.writeUint32("class", 0); + } - w.enterSubRecord("slot1"); - if (m_slots[1]) - m_slots[1]->saveState(w); - else - w.writeUint32("class", 0); - w.leaveSubRecord(); + if (auto rec = w.enterSubRecord("slot1")) + { + if (m_slots[1]) + m_slots[1]->saveState(w); + else + w.writeUint32("class", 0); + } } void setChildSlot(unsigned slot, std::unique_ptr&& space); diff --git a/Runtime/IFactory.hpp b/Runtime/IFactory.hpp index 964ab1cac..6d4d67000 100644 --- a/Runtime/IFactory.hpp +++ b/Runtime/IFactory.hpp @@ -41,6 +41,8 @@ public: virtual std::unique_ptr LoadResourceSync(const urde::SObjectTag& tag)=0; virtual std::unique_ptr LoadResourcePartSync(const urde::SObjectTag& tag, u32 size, u32 off)=0; + virtual void GetTagListForFile(const char* pakName, std::vector& out) const {} + virtual ResId TranslateOriginalToNew(ResId id) const { return -1; } virtual ResId TranslateNewToOriginal(ResId id) const { return -1; } }; diff --git a/Runtime/MP1/CMFGame.cpp b/Runtime/MP1/CMFGame.cpp index eb3476e39..95e15e97c 100644 --- a/Runtime/MP1/CMFGame.cpp +++ b/Runtime/MP1/CMFGame.cpp @@ -65,9 +65,23 @@ CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader") } } +static const char* LoadDepPAKs[] = +{ + "TestAnim", + "SamusGun", + "SamGunFx", + nullptr +}; + void CMFGameLoader::MakeLoadDependencyList() { + std::vector 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(*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) { - if (!x18_guiMgr) - { - x18_guiMgr = std::make_shared(*x14_stateMgr, queue); - } + queue.Push( + MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 10, 1000, + std::make_shared(x14_stateMgr, x18_guiMgr, queue))); + return EMessageReturn::RemoveIOWinAndExit; } } default: diff --git a/Runtime/MP1/CMFGame.hpp b/Runtime/MP1/CMFGame.hpp index b0dbff81f..5b07d0f38 100644 --- a/Runtime/MP1/CMFGame.hpp +++ b/Runtime/MP1/CMFGame.hpp @@ -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; }; diff --git a/hecl b/hecl index e86501e66..bcffcf310 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit e86501e66a219e5370b82be6379da449cb23381a +Subproject commit bcffcf3105090648ba44b3aa69a5d906986be531