diff --git a/DataSpec/DNACommon/AROTBuilder.cpp b/DataSpec/DNACommon/AROTBuilder.cpp index 52315572a..fbe48dd41 100644 --- a/DataSpec/DNACommon/AROTBuilder.cpp +++ b/DataSpec/DNACommon/AROTBuilder.cpp @@ -1,15 +1,19 @@ #include "AROTBuilder.hpp" + +#include +#include + #include "hecl/Blender/Connection.hpp" #include "../DNAMP1/PATH.hpp" namespace DataSpec { logvisor::Module Log("AROTBuilder"); -#define AROT_MAX_LEVEL 10 -#define AROT_MIN_SUBDIV 10.f -#define AROT_MIN_MODELS 8 -#define COLLISION_MIN_NODE_TRIANGLES 8 -#define PATH_MIN_NODE_REGIONS 16 +constexpr s32 AROT_MAX_LEVEL = 10; +constexpr s32 AROT_MIN_MODELS = 8; +constexpr s32 COLLISION_MIN_NODE_TRIANGLES = 8; +constexpr s32 PATH_MIN_NODE_REGIONS = 16; +constexpr float AROT_MIN_SUBDIV = 10.f; static zeus::CAABox SplitAABB(const zeus::CAABox& aabb, int i) { zeus::CAABox pos, neg; @@ -128,7 +132,9 @@ size_t AROTBuilder::BitmapPool::addIndices(const std::set& indices) { return m_pool.size() - 1; } -static const uint32_t AROTChildCounts[] = {0, 2, 2, 4, 2, 4, 4, 8}; +constexpr std::array AROTChildCounts{ + 0, 2, 2, 4, 2, 4, 4, 8, +}; void AROTBuilder::Node::nodeCount(size_t& sz, size_t& idxRefs, BitmapPool& bmpPool, size_t& curOff) { sz += 1; @@ -176,7 +182,7 @@ void AROTBuilder::Node::writeNodes(athena::io::MemoryWriter& w, int nodeIdx) { if (curIdx > 65535) Log.report(logvisor::Fatal, fmt("AROT node exceeds 16-bit node addressing; area too complex")); - int childIndices[8]; + std::array childIndices; for (int k = 0; k < 1 + ((compSubdivs & 0x4) != 0); ++k) { for (int j = 0; j < 1 + ((compSubdivs & 0x2) != 0); ++j) { @@ -280,17 +286,16 @@ void AROTBuilder::Node::pathWrite(DNAMP1::PATH& path, const zeus::CAABox& curAAB n.aabb[0] = curAABB.min; n.aabb[1] = curAABB.max; n.centroid = curAABB.center(); - for (int i = 0; i < 8; ++i) - n.children[i] = 0xffffffff; + std::fill(std::begin(n.children), std::end(n.children), 0xFFFFFFFF); n.regionCount = childIndices.size(); n.regionStart = path.octreeRegionLookup.size(); for (int r : childIndices) path.octreeRegionLookup.push_back(r); } else { - atUint32 children[8]; - for (int i = 0; i < 8; ++i) { + std::array children; + for (size_t i = 0; i < children.size(); ++i) { /* Head recursion (first node will be a leaf) */ - childNodes[i].pathWrite(path, SplitAABB(curAABB, i)); + childNodes[i].pathWrite(path, SplitAABB(curAABB, static_cast(i))); children[i] = path.octree.size() - 1; } @@ -300,8 +305,7 @@ void AROTBuilder::Node::pathWrite(DNAMP1::PATH& path, const zeus::CAABox& curAAB n.aabb[0] = curAABB.min; n.aabb[1] = curAABB.max; n.centroid = curAABB.center(); - for (int i = 0; i < 8; ++i) - n.children[i] = children[i]; + std::copy(children.cbegin(), children.cend(), std::begin(n.children)); n.regionCount = 0; n.regionStart = 0; } @@ -343,18 +347,20 @@ void AROTBuilder::build(std::vector>& secs, const zeus::CAA auto bmpIt = bmp.cbegin(); if (bmpIt != bmp.cend()) { int curIdx = 0; - for (size_t w = 0; w < bmpWordCount; ++w) { - for (int b = 0; b < 32; ++b) { + for (size_t word = 0; word < bmpWordCount; ++word) { + for (u32 b = 0; b < 32; ++b) { if (*bmpIt == curIdx) { - bmpWords[w] |= 1 << b; + bmpWords[word] |= 1U << b; ++bmpIt; - if (bmpIt == bmp.cend()) + if (bmpIt == bmp.cend()) { break; + } } ++curIdx; } - if (bmpIt == bmp.cend()) + if (bmpIt == bmp.cend()) { break; + } } } @@ -377,12 +383,11 @@ std::pair, uint32_t> AROTBuilder::buildCol(const ColM std::vector triBoxes; triBoxes.reserve(mesh.trianges.size()); for (const ColMesh::Triangle& tri : mesh.trianges) { - triBoxes.emplace_back(); - zeus::CAABox& aabb = triBoxes.back(); - for (int e = 0; e < 3; ++e) { - const ColMesh::Edge& edge = mesh.edges[tri.edges[e]]; - for (int v = 0; v < 2; ++v) { - const auto& vert = mesh.verts[edge.verts[v]]; + zeus::CAABox& aabb = triBoxes.emplace_back(); + for (const u32 edgeIdx : tri.edges) { + const ColMesh::Edge& edge = mesh.edges[edgeIdx]; + for (const u32 vertIdx : edge.verts) { + const auto& vert = mesh.verts[vertIdx]; aabb.accumulateBounds(zeus::CVector3f(vert)); } } diff --git a/DataSpec/DNACommon/ATBL.cpp b/DataSpec/DNACommon/ATBL.cpp index 24b4a37f1..10e5f3ead 100644 --- a/DataSpec/DNACommon/ATBL.cpp +++ b/DataSpec/DNACommon/ATBL.cpp @@ -48,9 +48,7 @@ bool ATBL::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat maxI = std::max(maxI, i); } - std::vector vecOut; - vecOut.resize(maxI + 1, 0xffff); - + std::vector vecOut(maxI + 1, 0xffff); for (const auto& pair : dr.getRootNode()->m_mapChildren) { unsigned long i = strtoul(pair.first.c_str(), nullptr, 0); vecOut[i] = hecl::SBig(uint16_t(strtoul(pair.second->m_scalarString.c_str(), nullptr, 0))); diff --git a/DataSpec/DNACommon/CRSC.cpp b/DataSpec/DNACommon/CRSC.cpp index e5e8c7878..45069cd35 100644 --- a/DataSpec/DNACommon/CRSC.cpp +++ b/DataSpec/DNACommon/CRSC.cpp @@ -1,248 +1,24 @@ #include "DataSpec/DNACommon/CRSC.hpp" - -#include - #include "DataSpec/DNACommon/PAK.hpp" -#include - namespace DataSpec::DNAParticle { -static const std::vector GeneratorTypes = { - SBIG('NODP'), SBIG('DEFS'), SBIG('CRTS'), SBIG('MTLS'), SBIG('GRAS'), SBIG('ICEE'), SBIG('GOOO'), SBIG('WODS'), - SBIG('WATR'), SBIG('1MUD'), SBIG('1LAV'), SBIG('1SAN'), SBIG('1PRJ'), SBIG('DCHR'), SBIG('DCHS'), SBIG('DCSH'), - SBIG('DENM'), SBIG('DESP'), SBIG('DESH'), SBIG('BTLE'), SBIG('WASP'), SBIG('TALP'), SBIG('PTGM'), SBIG('SPIR'), - SBIG('FPIR'), SBIG('FFLE'), SBIG('PARA'), SBIG('BMON'), SBIG('BFLR'), SBIG('PBOS'), SBIG('IBOS'), SBIG('1SVA'), - SBIG('1RPR'), SBIG('1MTR'), SBIG('1PDS'), SBIG('1FLB'), SBIG('1DRN'), SBIG('1MRE'), SBIG('CHOZ'), SBIG('JZAP'), - SBIG('1ISE'), SBIG('1BSE'), SBIG('1ATB'), SBIG('1ATA'), SBIG('BTSP'), SBIG('WWSP'), SBIG('TASP'), SBIG('TGSP'), - SBIG('SPSP'), SBIG('FPSP'), SBIG('FFSP'), SBIG('PSSP'), SBIG('BMSP'), SBIG('BFSP'), SBIG('PBSP'), SBIG('IBSP'), - SBIG('2SVA'), SBIG('2RPR'), SBIG('2MTR'), SBIG('2PDS'), SBIG('2FLB'), SBIG('2DRN'), SBIG('2MRE'), SBIG('CHSP'), - SBIG('JZSP'), SBIG('3ISE'), SBIG('3BSE'), SBIG('3ATB'), SBIG('3ATA'), SBIG('BTSH'), SBIG('WWSH'), SBIG('TASH'), - SBIG('TGSH'), SBIG('SPSH'), SBIG('FPSH'), SBIG('FFSH'), SBIG('PSSH'), SBIG('BMSH'), SBIG('BFSH'), SBIG('PBSH'), - SBIG('IBSH'), SBIG('3SVA'), SBIG('3RPR'), SBIG('3MTR'), SBIG('3PDS'), SBIG('3FLB'), SBIG('3DRN'), SBIG('3MRE'), - SBIG('CHSH'), SBIG('JZSH'), SBIG('5ISE'), SBIG('5BSE'), SBIG('5ATB'), SBIG('5ATA')}; -static const std::vector SFXTypes = { - SBIG('DSFX'), SBIG('CSFX'), SBIG('MSFX'), SBIG('GRFX'), SBIG('NSFX'), SBIG('DSFX'), SBIG('CSFX'), SBIG('MSFX'), - SBIG('GRFX'), SBIG('ICFX'), SBIG('GOFX'), SBIG('WSFX'), SBIG('WTFX'), SBIG('2MUD'), SBIG('2LAV'), SBIG('2SAN'), - SBIG('2PRJ'), SBIG('DCFX'), SBIG('DSFX'), SBIG('DSHX'), SBIG('DEFX'), SBIG('ESFX'), SBIG('SHFX'), SBIG('BEFX'), - SBIG('WWFX'), SBIG('TAFX'), SBIG('GTFX'), SBIG('SPFX'), SBIG('FPFX'), SBIG('FFFX'), SBIG('PAFX'), SBIG('BMFX'), - SBIG('BFFX'), SBIG('PBFX'), SBIG('IBFX'), SBIG('4SVA'), SBIG('4RPR'), SBIG('4MTR'), SBIG('4PDS'), SBIG('4FLB'), - SBIG('4DRN'), SBIG('4MRE'), SBIG('CZFX'), SBIG('JZAS'), SBIG('2ISE'), SBIG('2BSE'), SBIG('2ATB'), SBIG('2ATA'), - SBIG('BSFX'), SBIG('WSFX'), SBIG('TSFX'), SBIG('GSFX'), SBIG('SSFX'), SBIG('FSFX'), SBIG('SFFX'), SBIG('PSFX'), - SBIG('MSFX'), SBIG('SBFX'), SBIG('PBSX'), SBIG('IBSX'), SBIG('5SVA'), SBIG('5RPR'), SBIG('5MTR'), SBIG('5PDS'), - SBIG('5FLB'), SBIG('5DRN'), SBIG('5MRE'), SBIG('CSFX'), SBIG('JZPS'), SBIG('4ISE'), SBIG('4BSE'), SBIG('4ATB'), - SBIG('4ATA'), SBIG('BHFX'), SBIG('WHFX'), SBIG('THFX'), SBIG('GHFX'), SBIG('SHFX'), SBIG('FHFX'), SBIG('HFFX'), - SBIG('PHFX'), SBIG('MHFX'), SBIG('HBFX'), SBIG('PBHX'), SBIG('IBHX'), SBIG('6SVA'), SBIG('6RPR'), SBIG('6MTR'), - SBIG('6PDS'), SBIG('6FLB'), SBIG('6DRN'), SBIG('6MRE'), SBIG('CHFX'), SBIG('JZHS'), SBIG('6ISE'), SBIG('6BSE'), - SBIG('6ATB'), SBIG('6ATA'), -}; +template struct PPImpl<_CRSM>; +template struct PPImpl<_CRSM>; -static const std::vector DecalTypes = {SBIG('NCDL'), SBIG('DDCL'), SBIG('CODL'), SBIG('MEDL'), SBIG('GRDL'), - SBIG('ICDL'), SBIG('GODL'), SBIG('WODL'), SBIG('WTDL'), SBIG('3MUD'), - SBIG('3LAV'), SBIG('3SAN'), SBIG('CHDL'), SBIG('ENDL')}; +AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_CRSM>) +AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_CRSM>) template <> -std::string_view CRSM::DNAType() { - return "CRSM"sv; +std::string_view PPImpl<_CRSM>::DNAType() { + return "urde::CRSM"sv; } template <> -std::string_view CRSM::DNAType() { - return "CRSM"sv; +std::string_view PPImpl<_CRSM>::DNAType() { + return "urde::CRSM"sv; } -template -void CRSM::_read(athena::io::YAMLDocReader& r) { - for (const auto& elem : r.getCurNode()->m_mapChildren) { - if (elem.first.size() < 4) { - LogModule.report(logvisor::Warning, fmt("short FourCC in element '{}'"), elem.first); - continue; - } - - if (auto rec = r.enterSubRecord(elem.first.c_str())) { - FourCC clsId(elem.first.c_str()); - auto gen = std::find_if(GeneratorTypes.begin(), GeneratorTypes.end(), - [&clsId](const FourCC& other) { 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) { return clsId == other; }); - if (sfx != SFXTypes.end()) { - x10_sfx[clsId] = r.readInt32(clsId.toString()); - continue; - } - - auto decal = std::find_if(DecalTypes.begin(), DecalTypes.end(), - [&clsId](const FourCC& other) { return clsId == other; }); - if (decal != DecalTypes.end()) { - x20_decals[clsId].read(r); - continue; - } - if (clsId == SBIG('RNGE')) - x30_RNGE = r.readFloat(); - else if (clsId == SBIG('FOFF')) - x34_FOFF = r.readFloat(); - } - } -} - -template -void CRSM::_write(athena::io::YAMLDocWriter& w) const { - for (const auto& pair : x0_generators) - if (pair.second) - if (auto rec = w.enterSubRecord(pair.first.toString())) - pair.second.write(w); - - for (const auto& pair : x10_sfx) - if (pair.second != UINT32_MAX) - w.writeUint32(pair.first.toString(), pair.second); - - for (const auto& pair : x20_decals) - if (pair.second) - if (auto rec = w.enterSubRecord(pair.first.toString())) - pair.second.write(w); - - if (x30_RNGE != 50.f) - w.writeFloat("RNGE", x30_RNGE); - if (x34_FOFF != 0.2f) - w.writeFloat("FOFF", x34_FOFF); -} - -template -void CRSM::_binarySize(size_t& __isz) const { - __isz += 4; - for (const auto& pair : x0_generators) { - if (pair.second) { - __isz += 4; - pair.second.binarySize(__isz); - } - } - for (const auto& pair : x10_sfx) { - if (pair.second != UINT32_MAX) - __isz += 12; - } - - for (const auto& pair : x20_decals) { - if (pair.second) { - __isz += 4; - pair.second.binarySize(__isz); - } - } - - if (x30_RNGE != 50.f) - __isz += 12; - if (x34_FOFF != 0.2f) - __isz += 12; -} - -template -void CRSM::_read(athena::io::IStreamReader& r) { - DNAFourCC clsId; - clsId.read(r); - if (clsId != SBIG('CRSM')) { - LogModule.report(logvisor::Warning, fmt("non CRSM provided to CRSM parser")); - return; - } - - while (clsId != SBIG('_END')) { - clsId.read(r); - auto gen = std::find_if(GeneratorTypes.begin(), GeneratorTypes.end(), - [&clsId](const FourCC& other) { 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) { return clsId == other; }); - if (sfx != SFXTypes.end()) { - DNAFourCC fcc; - fcc.read(r); - if (fcc != SBIG('NONE')) - x10_sfx[clsId] = r.readInt32Big(); - else - x10_sfx[clsId] = ~0; - continue; - } - - auto decal = std::find_if(DecalTypes.begin(), DecalTypes.end(), - [&clsId](const FourCC& other) { return clsId == other; }); - if (decal != DecalTypes.end()) { - x20_decals[clsId].read(r); - continue; - } - if (clsId == SBIG('RNGE')) { - r.readUint32(); - x30_RNGE = r.readFloatBig(); - continue; - } - if (clsId == SBIG('FOFF')) { - r.readUint32(); - x34_FOFF = r.readFloatBig(); - continue; - } - if (clsId != SBIG('_END')) - LogModule.report(logvisor::Fatal, fmt("Unknown CRSM class {} @{}"), clsId, r.position()); - } -} - -template -void CRSM::_write(athena::io::IStreamWriter& w) const { - w.writeBytes("CRSM", 4); - for (const auto& pair : x0_generators) { - w.writeBytes(pair.first.getChars(), 4); - pair.second.write(w); - } - - for (const auto& pair : x10_sfx) { - w.writeBytes(pair.first.getChars(), 4); - if (pair.second != UINT32_MAX) { - w.writeBytes("CNST", 4); - w.writeUint32Big(pair.second); - } else { - w.writeBytes("NONE", 4); - } - } - - for (const auto& pair : x20_decals) { - w.writeBytes(pair.first.getChars(), 4); - pair.second.write(w); - } - - if (x30_RNGE != 50.f) { - w.writeBytes("RNGECNST", 8); - w.writeFloatBig(x30_RNGE); - } - if (x34_FOFF != 0.2f) { - w.writeBytes("FOFFCNST", 8); - w.writeFloatBig(x34_FOFF); - } - w.writeBytes("_END", 4); -} - -AT_SUBSPECIALIZE_DNA_YAML(CRSM) -AT_SUBSPECIALIZE_DNA_YAML(CRSM) - -template -void CRSM::gatherDependencies(std::vector& pathsOut) const { - for (const auto& p : x0_generators) - g_curSpec->flattenDependencies(p.second.id, pathsOut); - for (const auto& p : x20_decals) - g_curSpec->flattenDependencies(p.second.id, pathsOut); -} - -template -CRSM::CRSM() : x30_RNGE(50.f), x34_FOFF(0.2f) { - for (const auto& sfx : SFXTypes) - x10_sfx[sfx] = ~0; -} - -template struct CRSM; -template struct CRSM; - template bool ExtractCRSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { athena::io::FileWriter writer(outPath.getAbsolutePath()); diff --git a/DataSpec/DNACommon/CRSC.def b/DataSpec/DNACommon/CRSC.def new file mode 100644 index 000000000..6fe2e2b7e --- /dev/null +++ b/DataSpec/DNACommon/CRSC.def @@ -0,0 +1,222 @@ +#ifndef ENTRY +#define ENTRY(name, identifier) +#endif + +#ifndef RES_ENTRY +#define RES_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef U32_ENTRY +#define U32_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef FLOAT_ENTRY +#define FLOAT_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +RES_ENTRY('NODP', NODP) +RES_ENTRY('DEFS', DEFS) +RES_ENTRY('CRTS', CRTS) +RES_ENTRY('MTLS', MTLS) +RES_ENTRY('GRAS', GRAS) +RES_ENTRY('ICEE', ICEE) +RES_ENTRY('GOOO', GOOO) +RES_ENTRY('WODS', WODS) +RES_ENTRY('WATR', WATR) +RES_ENTRY('1MUD', _1MUD) +RES_ENTRY('1LAV', _1LAV) +RES_ENTRY('1SAN', _1SAN) +RES_ENTRY('1PRJ', _1PRJ) +RES_ENTRY('DCHR', DCHR) +RES_ENTRY('DCHS', DCHS) +RES_ENTRY('DCSH', DCSH) +RES_ENTRY('DENM', DENM) +RES_ENTRY('DESP', DESP) +RES_ENTRY('DESH', DESH) +RES_ENTRY('BTLE', BTLE) +RES_ENTRY('WASP', WASP) +RES_ENTRY('TALP', TALP) +RES_ENTRY('PTGM', PTGM) +RES_ENTRY('SPIR', SPIR) +RES_ENTRY('FPIR', FPIR) +RES_ENTRY('FFLE', FFLE) +RES_ENTRY('PARA', PARA) +RES_ENTRY('BMON', BMON) +RES_ENTRY('BFLR', BFLR) +RES_ENTRY('PBOS', PBOS) +RES_ENTRY('IBOS', IBOS) +RES_ENTRY('1SVA', _1SVA) +RES_ENTRY('1RPR', _1RPR) +RES_ENTRY('1MTR', _1MTR) +RES_ENTRY('1PDS', _1PDS) +RES_ENTRY('1FLB', _1FLB) +RES_ENTRY('1DRN', _1DRN) +RES_ENTRY('1MRE', _1MRE) +RES_ENTRY('CHOZ', CHOZ) +RES_ENTRY('JZAP', JZAP) +RES_ENTRY('1ISE', _1ISE) +RES_ENTRY('1BSE', _1BSE) +RES_ENTRY('1ATB', _1ATB) +RES_ENTRY('1ATA', _1ATA) +RES_ENTRY('BTSP', BTSP) +RES_ENTRY('WWSP', WWSP) +RES_ENTRY('TASP', TASP) +RES_ENTRY('TGSP', TGSP) +RES_ENTRY('SPSP', SPSP) +RES_ENTRY('FPSP', FPSP) +RES_ENTRY('FFSP', FFSP) +RES_ENTRY('PSSP', PSSP) +RES_ENTRY('BMSP', BMSP) +RES_ENTRY('BFSP', BFSP) +RES_ENTRY('PBSP', PBSP) +RES_ENTRY('IBSP', IBSP) +RES_ENTRY('2SVA', _2SVA) +RES_ENTRY('2RPR', _2RPR) +RES_ENTRY('2MTR', _2MTR) +RES_ENTRY('2PDS', _2PDS) +RES_ENTRY('2FLB', _2FLB) +RES_ENTRY('2DRN', _2DRN) +RES_ENTRY('2MRE', _2MRE) +RES_ENTRY('CHSP', CHSP) +RES_ENTRY('JZSP', JZSP) +RES_ENTRY('3ISE', _3ISE) +RES_ENTRY('3BSE', _3BSE) +RES_ENTRY('3ATB', _3ATB) +RES_ENTRY('3ATA', _3ATA) +RES_ENTRY('BTSH', BTSH) +RES_ENTRY('WWSH', WWSH) +RES_ENTRY('TASH', TASH) +RES_ENTRY('TGSH', TGSH) +RES_ENTRY('SPSH', SPSH) +RES_ENTRY('FPSH', FPSH) +RES_ENTRY('FFSH', FFSH) +RES_ENTRY('PSSH', PSSH) +RES_ENTRY('BMSH', BMSH) +RES_ENTRY('BFSH', BFSH) +RES_ENTRY('PBSH', PBSH) +RES_ENTRY('IBSH', IBSH) +RES_ENTRY('3SVA', _3SVA) +RES_ENTRY('3RPR', _3RPR) +RES_ENTRY('3MTR', _3MTR) +RES_ENTRY('3PDS', _3PDS) +RES_ENTRY('3FLB', _3FLB) +RES_ENTRY('3DRN', _3DRN) +RES_ENTRY('3MRE', _3MRE) +RES_ENTRY('CHSH', CHSH) +RES_ENTRY('JZSH', JZSH) +RES_ENTRY('5ISE', _5ISE) +RES_ENTRY('5BSE', _5BSE) +RES_ENTRY('5ATB', _5ATB) +RES_ENTRY('5ATA', _5ATA) +RES_ENTRY('NCDL', NCDL) +RES_ENTRY('DDCL', DDCL) +RES_ENTRY('CODL', CODL) +RES_ENTRY('MEDL', MEDL) +RES_ENTRY('GRDL', GRDL) +RES_ENTRY('ICDL', ICDL) +RES_ENTRY('GODL', GODL) +RES_ENTRY('WODL', WODL) +RES_ENTRY('WTDL', WTDL) +RES_ENTRY('3MUD', _3MUD) +RES_ENTRY('3LAV', _3LAV) +RES_ENTRY('3SAN', _3SAN) +RES_ENTRY('CHDL', CHDL) +RES_ENTRY('ENDL', ENDL) + +U32_ENTRY('NSFX', NSFX) +U32_ENTRY('DSFX', DSFX) +U32_ENTRY('CSFX', CSFX) +U32_ENTRY('MSFX', MSFX) +U32_ENTRY('GRFX', GRFX) +U32_ENTRY('ICFX', ICFX) +U32_ENTRY('GOFX', GOFX) +U32_ENTRY('WSFX', WSFX) +U32_ENTRY('WTFX', WTFX) +U32_ENTRY('2MUD', _2MUD) +U32_ENTRY('2LAV', _2LAV) +U32_ENTRY('2SAN', _2SAN) +U32_ENTRY('2PRJ', _2PRJ) +U32_ENTRY('DCFX', DCFX) +U32_ENTRY('DSHX', DSHX) +U32_ENTRY('DEFX', DEFX) +U32_ENTRY('ESFX', ESFX) +U32_ENTRY('SHFX', SHFX) +U32_ENTRY('BEFX', BEFX) +U32_ENTRY('WWFX', WWFX) +U32_ENTRY('TAFX', TAFX) +U32_ENTRY('GTFX', GTFX) +U32_ENTRY('SPFX', SPFX) +U32_ENTRY('FPFX', FPFX) +U32_ENTRY('FFFX', FFFX) +U32_ENTRY('PAFX', PAFX) +U32_ENTRY('BMFX', BMFX) +U32_ENTRY('BFFX', BFFX) +U32_ENTRY('PBFX', PBFX) +U32_ENTRY('IBFX', IBFX) +U32_ENTRY('4SVA', _4SVA) +U32_ENTRY('4RPR', _4RPR) +U32_ENTRY('4MTR', _4MTR) +U32_ENTRY('4PDS', _4PDS) +U32_ENTRY('4FLB', _4FLB) +U32_ENTRY('4DRN', _4DRN) +U32_ENTRY('4MRE', _4MRE) +U32_ENTRY('CZFX', CZFX) +U32_ENTRY('JZAS', JZAS) +U32_ENTRY('2ISE', _2ISE) +U32_ENTRY('2BSE', _2BSE) +U32_ENTRY('2ATB', _2ATB) +U32_ENTRY('2ATA', _2ATA) +U32_ENTRY('BSFX', BSFX) +U32_ENTRY('TSFX', TSFX) +U32_ENTRY('GSFX', GSFX) +U32_ENTRY('SSFX', SSFX) +U32_ENTRY('FSFX', FSFX) +U32_ENTRY('SFFX', SFFX) +U32_ENTRY('PSFX', PSFX) +U32_ENTRY('SBFX', SBFX) +U32_ENTRY('PBSX', PBSX) +U32_ENTRY('IBSX', IBSX) +U32_ENTRY('5SVA', _5SVA) +U32_ENTRY('5RPR', _5RPR) +U32_ENTRY('5MTR', _5MTR) +U32_ENTRY('5PDS', _5PDS) +U32_ENTRY('5FLB', _5FLB) +U32_ENTRY('5DRN', _5DRN) +U32_ENTRY('5MRE', _5MRE) +U32_ENTRY('JZPS', JZPS) +U32_ENTRY('4ISE', _4ISE) +U32_ENTRY('4BSE', _4BSE) +U32_ENTRY('4ATB', _4ATB) +U32_ENTRY('4ATA', _4ATA) +U32_ENTRY('BHFX', BHFX) +U32_ENTRY('WHFX', WHFX) +U32_ENTRY('THFX', THFX) +U32_ENTRY('GHFX', GHFX) +U32_ENTRY('FHFX', FHFX) +U32_ENTRY('HFFX', HFFX) +U32_ENTRY('PHFX', PHFX) +U32_ENTRY('MHFX', MHFX) +U32_ENTRY('HBFX', HBFX) +U32_ENTRY('PBHX', PBHX) +U32_ENTRY('IBHX', IBHX) +U32_ENTRY('6SVA', _6SVA) +U32_ENTRY('6RPR', _6RPR) +U32_ENTRY('6MTR', _6MTR) +U32_ENTRY('6PDS', _6PDS) +U32_ENTRY('6FLB', _6FLB) +U32_ENTRY('6DRN', _6DRN) +U32_ENTRY('6MRE', _6MRE) +U32_ENTRY('CHFX', CHFX) +U32_ENTRY('JZHS', JZHS) +U32_ENTRY('6ISE', _6ISE) +U32_ENTRY('6BSE', _6BSE) +U32_ENTRY('6ATB', _6ATB) +U32_ENTRY('6ATA', _6ATA) + +FLOAT_ENTRY('RNGE', x30_RNGE) +FLOAT_ENTRY('FOFF', x34_FOFF) + +#undef ENTRY +#undef RES_ENTRY +#undef U32_ENTRY +#undef FLOAT_ENTRY diff --git a/DataSpec/DNACommon/CRSC.hpp b/DataSpec/DNACommon/CRSC.hpp index 3bc7ff2f1..bab40f942 100644 --- a/DataSpec/DNACommon/CRSC.hpp +++ b/DataSpec/DNACommon/CRSC.hpp @@ -18,20 +18,33 @@ class ProjectPath; } namespace DataSpec::DNAParticle { + template -struct CRSM : BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - AT_SUBDECL_DNA - std::unordered_map> x0_generators; - std::unordered_map x10_sfx; - std::unordered_map> x20_decals; - float x30_RNGE; - float x34_FOFF; +struct _CRSM { + static constexpr ParticleType Type = ParticleType::CRSM; +#define RES_ENTRY(name, identifier) ChildResourceFactory identifier; +#define U32_ENTRY(name, identifier) uint32_t identifier = ~0; +#define FLOAT_ENTRY(name, identifier) float identifier = 0.f; +#include "CRSC.def" - CRSM(); + template + void constexpr Enumerate(_Func f) { +#define ENTRY(name, identifier) f(FOURCC(name), identifier); +#include "CRSC.def" + } - void gatherDependencies(std::vector&) const; + template + bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { +#define ENTRY(name, identifier) case SBIG(name): f(identifier); return true; +#include "CRSC.def" + default: return false; + } + } }; +template +using CRSM = PPImpl<_CRSM>; + template bool ExtractCRSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath); diff --git a/DataSpec/DNACommon/DPSC.cpp b/DataSpec/DNACommon/DPSC.cpp index ed3bc334d..4b88eda08 100644 --- a/DataSpec/DNACommon/DPSC.cpp +++ b/DataSpec/DNACommon/DPSC.cpp @@ -1,391 +1,24 @@ #include "DataSpec/DNACommon/DPSC.hpp" - #include "DataSpec/DNACommon/PAK.hpp" -#include -#include - namespace DataSpec::DNAParticle { +template struct PPImpl<_DPSM>; +template struct PPImpl<_DPSM>; + +AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_DPSM>) +AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_DPSM>) + template <> -std::string_view DPSM::DNAType() { +std::string_view PPImpl<_DPSM>::DNAType() { return "DPSM"sv; } template <> -std::string_view DPSM::DNAType() { +std::string_view PPImpl<_DPSM>::DNAType() { return "DPSM"sv; } -template -void DPSM::_read(athena::io::YAMLDocReader& r) { - for (const auto& elem : r.getCurNode()->m_mapChildren) { - if (elem.first.size() < 4) { - LogModule.report(logvisor::Warning, fmt("short FourCC in element '{}'"), elem.first); - continue; - } - - if (auto rec = r.enterSubRecord(elem.first.c_str())) { - 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; - [[fallthrough]]; - 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(); - break; - case SBIG('DMOO'): - x5c_25_DMOO = r.readBool(); - break; - } - } - } -} - -template -void DPSM::_write(athena::io::YAMLDocWriter& w) const { - writeQuadDecalInfo(w, x0_quad, true); - writeQuadDecalInfo(w, x1c_quad, false); - - if (x38_DMDL) - if (auto rec = w.enterSubRecord("DMDL")) - x38_DMDL.write(w); - if (x48_DLFT) - if (auto rec = w.enterSubRecord("DLFT")) - x48_DLFT.write(w); - if (x4c_DMOP) - if (auto rec = w.enterSubRecord("DMOP")) - x4c_DMOP.write(w); - if (x50_DMRT) - if (auto rec = w.enterSubRecord("DMRT")) - x50_DMRT.write(w); - if (x54_DMSC) - if (auto rec = w.enterSubRecord("DMSC")) - x54_DMSC.write(w); - if (x58_DMCL) - if (auto rec = w.enterSubRecord("DMCL")) - x54_DMSC.write(w); - - if (x5c_24_DMAB) - w.writeBool("DMAB", x5c_24_DMAB); - if (x5c_25_DMOO) - w.writeBool("DMOO", x5c_25_DMOO); -} - -template -template -void DPSM::readQuadDecalInfo(Reader& r, FourCC clsId, typename DPSM::SQuadDescr& quad) { - switch (clsId.toUint32()) { - case SBIG('1LFT'): - case SBIG('2LFT'): - quad.x0_LFT.read(r); - break; - case SBIG('1SZE'): - case SBIG('2SZE'): - quad.x4_SZE.read(r); - break; - case SBIG('1ROT'): - case SBIG('2ROT'): - quad.x8_ROT.read(r); - break; - case SBIG('1OFF'): - case SBIG('2OFF'): - quad.xc_OFF.read(r); - break; - case SBIG('1CLR'): - case SBIG('2CLR'): - quad.x10_CLR.read(r); - break; - case SBIG('1TEX'): - case SBIG('2TEX'): - quad.x14_TEX.read(r); - break; - case SBIG('1ADD'): - case SBIG('2ADD'): - quad.x18_ADD.read(r); - break; - } -} - -template -void DPSM::writeQuadDecalInfo(athena::io::YAMLDocWriter& w, const typename DPSM::SQuadDescr& quad, - bool first) const { - if (quad.x0_LFT) - if (auto rec = w.enterSubRecord((first ? "1LFT" : "2LFT"))) - quad.x0_LFT.write(w); - if (quad.x4_SZE) - if (auto rec = w.enterSubRecord((first ? "1SZE" : "2SZE"))) - quad.x4_SZE.write(w); - if (quad.x8_ROT) - if (auto rec = w.enterSubRecord((first ? "1ROT" : "2ROT"))) - quad.x8_ROT.write(w); - if (quad.xc_OFF) - if (auto rec = w.enterSubRecord((first ? "1OFF" : "2OFF"))) - quad.xc_OFF.write(w); - if (quad.x10_CLR) - if (auto rec = w.enterSubRecord((first ? "1CLR" : "2CLR"))) - quad.x10_CLR.write(w); - if (quad.x14_TEX) - if (auto rec = w.enterSubRecord((first ? "1TEX" : "2TEX"))) - quad.x14_TEX.write(w); - if (quad.x18_ADD) - if (auto rec = w.enterSubRecord((first ? "1ADD" : "2ADD"))) - quad.x18_ADD.write(w); -} - -template -void DPSM::_binarySize(size_t& s) const { - s += 4; - getQuadDecalBinarySize(s, x0_quad); - getQuadDecalBinarySize(s, x1c_quad); - if (x38_DMDL) { - s += 4; - x38_DMDL.binarySize(s); - } - if (x48_DLFT) { - s += 4; - x48_DLFT.binarySize(s); - } - if (x4c_DMOP) { - s += 4; - x4c_DMOP.binarySize(s); - } - if (x50_DMRT) { - s += 4; - x50_DMRT.binarySize(s); - } - if (x54_DMSC) { - s += 4; - x54_DMSC.binarySize(s); - } - if (x58_DMCL) { - x58_DMCL.binarySize(s); - } - if (x5c_24_DMAB) - s += 9; - if (x5c_25_DMOO) - s += 9; -} - -template -void DPSM::getQuadDecalBinarySize(size_t& s, const typename DPSM::SQuadDescr& quad) const { - if (quad.x0_LFT) { - s += 4; - quad.x0_LFT.binarySize(s); - } - if (quad.x4_SZE) { - s += 4; - quad.x4_SZE.binarySize(s); - } - if (quad.x8_ROT) { - s += 4; - quad.x8_ROT.binarySize(s); - } - if (quad.xc_OFF) { - s += 4; - quad.xc_OFF.binarySize(s); - } - if (quad.x10_CLR) { - s += 4; - quad.x10_CLR.binarySize(s); - } - if (quad.x14_TEX) { - s += 4; - quad.x14_TEX.binarySize(s); - } - if (quad.x18_ADD) { - s += 4; - quad.x18_ADD.binarySize(s); - } -} - -template -void DPSM::_read(athena::io::IStreamReader& r) { - DNAFourCC clsId; - clsId.read(r); - if (clsId != SBIG('DPSM')) { - LogModule.report(logvisor::Warning, fmt("non DPSM provided to DPSM parser")); - return; - } - bool loadFirstDesc = false; - clsId.read(r); - while (clsId != SBIG('_END')) { - switch (clsId.toUint32()) { - case SBIG('1SZE'): - case SBIG('1LFT'): - case SBIG('1ROT'): - case SBIG('1OFF'): - case SBIG('1CLR'): - case SBIG('1TEX'): - case SBIG('1ADD'): - loadFirstDesc = true; - [[fallthrough]]; - 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'): - r.readUint32(); - x5c_24_DMAB = r.readBool(); - break; - case SBIG('DMOO'): - r.readUint32(); - x5c_25_DMOO = r.readBool(); - break; - default: - LogModule.report(logvisor::Fatal, fmt("Unknown DPSM class {} @{}"), clsId, r.position()); - break; - } - clsId.read(r); - } -} - -template -void DPSM::_write(athena::io::IStreamWriter& w) const { - w.writeBytes("DPSM", 4); - writeQuadDecalInfo(w, x0_quad, true); - writeQuadDecalInfo(w, x1c_quad, false); - if (x38_DMDL) { - w.writeBytes("DMDL", 4); - x38_DMDL.write(w); - } - if (x48_DLFT) { - w.writeBytes("DLFT", 4); - x48_DLFT.write(w); - } - if (x4c_DMOP) { - w.writeBytes("DMOP", 4); - x4c_DMOP.write(w); - } - if (x50_DMRT) { - w.writeBytes("DMRT", 4); - x50_DMRT.write(w); - } - if (x54_DMSC) { - w.writeBytes("DMSC", 4); - x54_DMSC.write(w); - } - if (x58_DMCL) { - w.writeBytes("DMCL", 4); - x58_DMCL.write(w); - } - if (x5c_24_DMAB) - w.writeBytes("DMABCNST\x01", 9); - if (x5c_25_DMOO) - w.writeBytes("DMOOCNST\x01", 9); - w.writeBytes("_END", 4); -} - -template -void DPSM::writeQuadDecalInfo(athena::io::IStreamWriter& w, const typename DPSM::SQuadDescr& quad, - bool first) const { - if (quad.x0_LFT) { - w.writeBytes((first ? "1LFT" : "2LFT"), 4); - quad.x0_LFT.write(w); - } - if (quad.x4_SZE) { - w.writeBytes((first ? "1SZE" : "2SZE"), 4); - quad.x4_SZE.write(w); - } - if (quad.x8_ROT) { - w.writeBytes((first ? "1ROT" : "2ROT"), 4); - quad.x8_ROT.write(w); - } - if (quad.xc_OFF) { - w.writeBytes((first ? "1OFF" : "2OFF"), 4); - quad.xc_OFF.write(w); - } - if (quad.x10_CLR) { - w.writeBytes((first ? "1CLR" : "2CLR"), 4); - quad.x10_CLR.write(w); - } - if (quad.x14_TEX) { - w.writeBytes((first ? "1TEX" : "2TEX"), 4); - quad.x14_TEX.write(w); - } - if (quad.x18_ADD) { - w.writeBytes((first ? "1ADD" : "2ADD"), 4); - quad.x18_ADD.write(w); - } -} - -template -void DPSM::gatherDependencies(std::vector& pathsOut) const { - if (x0_quad.x14_TEX.m_elem) - x0_quad.x14_TEX.m_elem->gatherDependencies(pathsOut); - if (x1c_quad.x14_TEX.m_elem) - x1c_quad.x14_TEX.m_elem->gatherDependencies(pathsOut); - g_curSpec->flattenDependencies(x38_DMDL.id, pathsOut); -} - -AT_SUBSPECIALIZE_DNA_YAML(DPSM) -AT_SUBSPECIALIZE_DNA_YAML(DPSM) -template struct DPSM; -template struct DPSM; - template bool ExtractDPSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { athena::io::FileWriter writer(outPath.getAbsolutePath()); diff --git a/DataSpec/DNACommon/DPSC.def b/DataSpec/DNACommon/DPSC.def new file mode 100644 index 000000000..ac61eb49f --- /dev/null +++ b/DataSpec/DNACommon/DPSC.def @@ -0,0 +1,28 @@ +#ifndef ENTRY +#define ENTRY(name, identifier) +#endif + +ENTRY('1LFT', x0_quad.x0_LFT) +ENTRY('1SZE', x0_quad.x4_SZE) +ENTRY('1ROT', x0_quad.x8_ROT) +ENTRY('1OFF', x0_quad.xc_OFF) +ENTRY('1CLR', x0_quad.x10_CLR) +ENTRY('1TEX', x0_quad.x14_TEX) +ENTRY('1ADD', x0_quad.x18_ADD) +ENTRY('2LFT', x1c_quad.x0_LFT) +ENTRY('2SZE', x1c_quad.x4_SZE) +ENTRY('2ROT', x1c_quad.x8_ROT) +ENTRY('2OFF', x1c_quad.xc_OFF) +ENTRY('2CLR', x1c_quad.x10_CLR) +ENTRY('2TEX', x1c_quad.x14_TEX) +ENTRY('2ADD', x1c_quad.x18_ADD) +ENTRY('DMDL', x38_DMDL) +ENTRY('DLFT', x48_DLFT) +ENTRY('DMOP', x4c_DMOP) +ENTRY('DMRT', x50_DMRT) +ENTRY('DMSC', x54_DMSC) +ENTRY('DMCL', x58_DMCL) +ENTRY('DMAB', x5c_24_DMAB) +ENTRY('DMOO', x5c_25_DMOO) + +#undef ENTRY diff --git a/DataSpec/DNACommon/DPSC.hpp b/DataSpec/DNACommon/DPSC.hpp index f8feab5eb..2ef2c547c 100644 --- a/DataSpec/DNACommon/DPSC.hpp +++ b/DataSpec/DNACommon/DPSC.hpp @@ -20,9 +20,8 @@ class ProjectPath; namespace DataSpec::DNAParticle { template -struct DPSM : BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - AT_SUBDECL_DNA +struct _DPSM { + static constexpr ParticleType Type = ParticleType::DPSM; struct SQuadDescr { IntElementFactory x0_LFT; @@ -31,7 +30,7 @@ struct DPSM : BigDNA { VectorElementFactory xc_OFF; ColorElementFactory x10_CLR; UVElementFactory x14_TEX; - BoolHelper x18_ADD; + bool x18_ADD = false; }; SQuadDescr x0_quad; @@ -42,21 +41,27 @@ struct DPSM : BigDNA { VectorElementFactory x50_DMRT; VectorElementFactory x54_DMSC; ColorElementFactory x58_DMCL; - union { - struct { - bool x5c_24_DMAB : 1; - bool x5c_25_DMOO : 1; - }; - uint8_t dummy; - }; - template - void readQuadDecalInfo(Reader& r, FourCC clsId, SQuadDescr& quad); - void writeQuadDecalInfo(athena::io::YAMLDocWriter& w, const SQuadDescr& quad, bool first) const; - void getQuadDecalBinarySize(size_t& s, const SQuadDescr& desc) const; - void writeQuadDecalInfo(athena::io::IStreamWriter& w, const SQuadDescr& quad, bool first) const; - void gatherDependencies(std::vector&) const; + bool x5c_24_DMAB = false; + bool x5c_25_DMOO = false; + + template + void constexpr Enumerate(_Func f) { +#define ENTRY(name, identifier) f(FOURCC(name), identifier); +#include "DPSC.def" + } + + template + bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { +#define ENTRY(name, identifier) case SBIG(name): f(identifier); return true; +#include "DPSC.def" + default: return false; + } + } }; +template +using DPSM = PPImpl<_DPSM>; template bool ExtractDPSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath); diff --git a/DataSpec/DNACommon/ELSC.cpp b/DataSpec/DNACommon/ELSC.cpp index b0e4703c7..7ea266f71 100644 --- a/DataSpec/DNACommon/ELSC.cpp +++ b/DataSpec/DNACommon/ELSC.cpp @@ -1,403 +1,13 @@ #include "DataSpec/DNACommon/ELSC.hpp" - -#include +#include "DataSpec/DNACommon/PAK.hpp" namespace DataSpec::DNAParticle { -template -void ELSM::_read(athena::io::IStreamReader& r) { - DNAFourCC clsId; - clsId.read(r); - if (clsId != SBIG('ELSM')) { - LogModule.report(logvisor::Warning, fmt("non ELSM provided to ELSM parser")); - return; - } +template struct PPImpl<_ELSM>; +template struct PPImpl<_ELSM>; - clsId.read(r); - while (clsId != SBIG('_END')) { - switch (clsId.toUint32()) { - case SBIG('LIFE'): - x0_LIFE.read(r); - break; - case SBIG('SLIF'): - x4_SLIF.read(r); - break; - case SBIG('GRAT'): - x8_GRAT.read(r); - break; - case SBIG('SCNT'): - xc_SCNT.read(r); - break; - case SBIG('SSEG'): - x10_SSEG.read(r); - break; - case SBIG('COLR'): - x14_COLR.read(r); - break; - case SBIG('IEMT'): - x18_IEMT.read(r); - break; - case SBIG('FEMT'): - x1c_FEMT.read(r); - break; - case SBIG('AMPL'): - x20_AMPL.read(r); - break; - case SBIG('AMPD'): - x24_AMPD.read(r); - break; - case SBIG('LWD1'): - x28_LWD1.read(r); - break; - case SBIG('LWD2'): - x2c_LWD2.read(r); - break; - case SBIG('LWD3'): - x30_LWD3.read(r); - break; - case SBIG('LCL1'): - x34_LCL1.read(r); - break; - case SBIG('LCL2'): - x38_LCL2.read(r); - break; - case SBIG('LCL3'): - x3c_LCL3.read(r); - break; - case SBIG('SSWH'): - x40_SSWH.read(r); - break; - case SBIG('GPSM'): - x50_GPSM.read(r); - break; - case SBIG('EPSM'): - x60_EPSM.read(r); - break; - case SBIG('ZERY'): - x70_ZERY.read(r); - break; - default: - LogModule.report(logvisor::Fatal, fmt("Unknown ELSM class {} @{}"), clsId, r.position()); - break; - } - clsId.read(r); - } -} - -template -void ELSM::_write(athena::io::IStreamWriter& w) const { - w.writeBytes((atInt8*)"ELSM", 4); - if (x0_LIFE) { - w.writeBytes((atInt8*)"LIFE", 4); - x0_LIFE.write(w); - } - if (x4_SLIF) { - w.writeBytes((atInt8*)"SLIF", 4); - x4_SLIF.write(w); - } - if (x8_GRAT) { - w.writeBytes((atInt8*)"GRAT", 4); - x8_GRAT.write(w); - } - if (xc_SCNT) { - w.writeBytes((atInt8*)"SCNT", 4); - xc_SCNT.write(w); - } - if (x10_SSEG) { - w.writeBytes((atInt8*)"SSEG", 4); - x10_SSEG.write(w); - } - if (x14_COLR) { - w.writeBytes((atInt8*)"COLR", 4); - x14_COLR.write(w); - } - if (x18_IEMT) { - w.writeBytes((atInt8*)"IEMT", 4); - x18_IEMT.write(w); - } - if (x1c_FEMT) { - w.writeBytes((atInt8*)"FEMT", 4); - x1c_FEMT.write(w); - } - if (x20_AMPL) { - w.writeBytes((atInt8*)"AMPL", 4); - x20_AMPL.write(w); - } - if (x24_AMPD) { - w.writeBytes((atInt8*)"AMPD", 4); - x24_AMPD.write(w); - } - if (x28_LWD1) { - w.writeBytes((atInt8*)"LWD1", 4); - x28_LWD1.write(w); - } - if (x2c_LWD2) { - w.writeBytes((atInt8*)"LWD2", 4); - x2c_LWD2.write(w); - } - if (x30_LWD3) { - w.writeBytes((atInt8*)"LWD3", 4); - x30_LWD3.write(w); - } - if (x34_LCL1) { - w.writeBytes((atInt8*)"LCL1", 4); - x34_LCL1.write(w); - } - if (x38_LCL2) { - w.writeBytes((atInt8*)"LCL2", 4); - x38_LCL2.write(w); - } - if (x3c_LCL3) { - w.writeBytes((atInt8*)"LCL3", 4); - x3c_LCL3.write(w); - } - if (x40_SSWH) { - w.writeBytes((atInt8*)"SSWH", 4); - x40_SSWH.write(w); - } - if (x50_GPSM) { - w.writeBytes((atInt8*)"GPSM", 4); - x50_GPSM.write(w); - } - if (x60_EPSM) { - w.writeBytes((atInt8*)"EPSM", 4); - x60_EPSM.write(w); - } - if (x70_ZERY) { - w.writeBytes((atInt8*)"ZERY", 4); - x70_ZERY.write(w); - } - w.writeBytes("_END", 4); -} - -template -void ELSM::_binarySize(size_t& s) const { - s += 4; - if (x0_LIFE) { - s += 4; - x0_LIFE.binarySize(s); - } - if (x4_SLIF) { - s += 4; - x4_SLIF.binarySize(s); - } - if (x8_GRAT) { - s += 4; - x8_GRAT.binarySize(s); - } - if (xc_SCNT) { - s += 4; - xc_SCNT.binarySize(s); - } - if (x10_SSEG) { - s += 4; - x10_SSEG.binarySize(s); - } - if (x14_COLR) { - s += 4; - x14_COLR.binarySize(s); - } - if (x18_IEMT) { - s += 4; - x18_IEMT.binarySize(s); - } - if (x1c_FEMT) { - s += 4; - x1c_FEMT.binarySize(s); - } - if (x20_AMPL) { - s += 4; - x20_AMPL.binarySize(s); - } - if (x24_AMPD) { - s += 4; - x24_AMPD.binarySize(s); - } - if (x28_LWD1) { - s += 4; - x28_LWD1.binarySize(s); - } - if (x2c_LWD2) { - s += 4; - x2c_LWD2.binarySize(s); - } - if (x30_LWD3) { - s += 4; - x30_LWD3.binarySize(s); - } - if (x34_LCL1) { - s += 4; - x34_LCL1.binarySize(s); - } - if (x38_LCL2) { - s += 4; - x38_LCL2.binarySize(s); - } - if (x3c_LCL3) { - s += 4; - x3c_LCL3.binarySize(s); - } - if (x40_SSWH) { - s += 4; - x40_SSWH.binarySize(s); - } - if (x50_GPSM) { - s += 4; - x50_GPSM.binarySize(s); - } - if (x60_EPSM) { - s += 4; - x60_EPSM.binarySize(s); - } - if (x70_ZERY) { - s += 4; - x70_ZERY.binarySize(s); - } -} - -template -void ELSM::_read(athena::io::YAMLDocReader& r) { - for (const auto& elem : r.getCurNode()->m_mapChildren) { - if (elem.first.size() < 4) { - LogModule.report(logvisor::Warning, fmt("short FourCC in element '{}'"), elem.first); - continue; - } - - if (auto rec = r.enterSubRecord(elem.first.c_str())) { - switch (*reinterpret_cast(elem.first.data())) { - case SBIG('LIFE'): - x0_LIFE.read(r); - break; - case SBIG('SLIF'): - x4_SLIF.read(r); - break; - case SBIG('GRAT'): - x8_GRAT.read(r); - break; - case SBIG('SCNT'): - xc_SCNT.read(r); - break; - case SBIG('SSEG'): - x10_SSEG.read(r); - break; - case SBIG('COLR'): - x14_COLR.read(r); - break; - case SBIG('IEMT'): - x18_IEMT.read(r); - break; - case SBIG('FEMT'): - x1c_FEMT.read(r); - break; - case SBIG('AMPL'): - x20_AMPL.read(r); - break; - case SBIG('AMPD'): - x24_AMPD.read(r); - break; - case SBIG('LWD1'): - x28_LWD1.read(r); - break; - case SBIG('LWD2'): - x2c_LWD2.read(r); - break; - case SBIG('LWD3'): - x30_LWD3.read(r); - break; - case SBIG('LCL1'): - x34_LCL1.read(r); - break; - case SBIG('LCL2'): - x38_LCL2.read(r); - break; - case SBIG('LCL3'): - x3c_LCL3.read(r); - break; - case SBIG('SSWH'): - x40_SSWH.read(r); - break; - case SBIG('GPSM'): - x50_GPSM.read(r); - break; - case SBIG('EPSM'): - x60_EPSM.read(r); - break; - case SBIG('ZERY'): - x70_ZERY.read(r); - break; - default: - break; - } - } - } -} - -template -void ELSM::_write(athena::io::YAMLDocWriter& w) const { - if (x0_LIFE) - if (auto rec = w.enterSubRecord("LIFE")) - x0_LIFE.write(w); - if (x4_SLIF) - if (auto rec = w.enterSubRecord("SLIF")) - x4_SLIF.write(w); - if (x8_GRAT) - if (auto rec = w.enterSubRecord("GRAT")) - x8_GRAT.write(w); - if (xc_SCNT) - if (auto rec = w.enterSubRecord("SCNT")) - xc_SCNT.write(w); - if (x10_SSEG) - if (auto rec = w.enterSubRecord("SSEG")) - x10_SSEG.write(w); - if (x14_COLR) - if (auto rec = w.enterSubRecord("COLR")) - x14_COLR.write(w); - if (x18_IEMT) - if (auto rec = w.enterSubRecord("IEMT")) - x18_IEMT.write(w); - if (x1c_FEMT) - if (auto rec = w.enterSubRecord("FEMT")) - x1c_FEMT.write(w); - if (x20_AMPL) - if (auto rec = w.enterSubRecord("AMPL")) - x20_AMPL.write(w); - if (x24_AMPD) - if (auto rec = w.enterSubRecord("AMPD")) - x24_AMPD.write(w); - if (x28_LWD1) - if (auto rec = w.enterSubRecord("LWD1")) - x28_LWD1.write(w); - if (x2c_LWD2) - if (auto rec = w.enterSubRecord("LWD2")) - x2c_LWD2.write(w); - if (x30_LWD3) - if (auto rec = w.enterSubRecord("LWD3")) - x30_LWD3.write(w); - if (x34_LCL1) - if (auto rec = w.enterSubRecord("LCL1")) - x34_LCL1.write(w); - if (x38_LCL2) - if (auto rec = w.enterSubRecord("LCL2")) - x38_LCL2.write(w); - if (x3c_LCL3) - if (auto rec = w.enterSubRecord("LCL3")) - x3c_LCL3.write(w); - if (x40_SSWH) - if (auto rec = w.enterSubRecord("SSWH")) - x40_SSWH.write(w); - if (x50_GPSM) - if (auto rec = w.enterSubRecord("GPSM")) - x50_GPSM.write(w); - if (x60_EPSM) - if (auto rec = w.enterSubRecord("EPSM")) - x60_EPSM.write(w); - if (x70_ZERY) - if (auto rec = w.enterSubRecord("ZERY")) - x70_ZERY.write(w); -} - -AT_SUBSPECIALIZE_DNA_YAML(ELSM) -AT_SUBSPECIALIZE_DNA_YAML(ELSM) +AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_ELSM>) +AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_ELSM>) template <> std::string_view ELSM::DNAType() { @@ -409,16 +19,6 @@ std::string_view ELSM::DNAType() { return "urde::ELSM"sv; } -template -void ELSM::gatherDependencies(std::vector& pathsOut) const { - g_curSpec->flattenDependencies(x40_SSWH.id, pathsOut); - g_curSpec->flattenDependencies(x50_GPSM.id, pathsOut); - g_curSpec->flattenDependencies(x60_EPSM.id, pathsOut); -} - -template struct ELSM; -template struct ELSM; - template bool ExtractELSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { athena::io::FileWriter writer(outPath.getAbsolutePath()); diff --git a/DataSpec/DNACommon/ELSC.def b/DataSpec/DNACommon/ELSC.def new file mode 100644 index 000000000..b8498ab1a --- /dev/null +++ b/DataSpec/DNACommon/ELSC.def @@ -0,0 +1,56 @@ +#ifndef ENTRY +#define ENTRY(name, identifier) +#endif + +#ifndef INT_ENTRY +#define INT_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef REAL_ENTRY +#define REAL_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef COLOR_ENTRY +#define COLOR_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef EMITTER_ENTRY +#define EMITTER_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef RES_ENTRY +#define RES_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef BOOL_ENTRY +#define BOOL_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +INT_ENTRY('LIFE', x0_LIFE) +INT_ENTRY('SLIF', x4_SLIF) +REAL_ENTRY('GRAT', x8_GRAT) +INT_ENTRY('SCNT', xc_SCNT) +INT_ENTRY('SSEG', x10_SSEG) +COLOR_ENTRY('COLR', x14_COLR) +EMITTER_ENTRY('IEMT', x18_IEMT) +EMITTER_ENTRY('FEMT', x1c_FEMT) +REAL_ENTRY('AMPL', x20_AMPL) +REAL_ENTRY('AMPD', x24_AMPD) +REAL_ENTRY('LWD1', x28_LWD1) +REAL_ENTRY('LWD2', x2c_LWD2) +REAL_ENTRY('LWD3', x30_LWD3) +COLOR_ENTRY('LCL1', x34_LCL1) +COLOR_ENTRY('LCL2', x38_LCL2) +COLOR_ENTRY('LCL3', x3c_LCL3) +RES_ENTRY('SSWH', x40_SSWH) +RES_ENTRY('GPSM', x50_GPSM) +RES_ENTRY('EPSM', x60_EPSM) +BOOL_ENTRY('ZERY', x70_ZERY) + +#undef ENTRY +#undef INT_ENTRY +#undef REAL_ENTRY +#undef COLOR_ENTRY +#undef EMITTER_ENTRY +#undef RES_ENTRY +#undef BOOL_ENTRY diff --git a/DataSpec/DNACommon/ELSC.hpp b/DataSpec/DNACommon/ELSC.hpp index 52ff09e35..a6eaaf41d 100644 --- a/DataSpec/DNACommon/ELSC.hpp +++ b/DataSpec/DNACommon/ELSC.hpp @@ -12,33 +12,36 @@ class ProjectPath; } namespace DataSpec::DNAParticle { -template -struct ELSM : BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - AT_SUBDECL_DNA - IntElementFactory x0_LIFE; - IntElementFactory x4_SLIF; - RealElementFactory x8_GRAT; - IntElementFactory xc_SCNT; - IntElementFactory x10_SSEG; - ColorElementFactory x14_COLR; - EmitterElementFactory x18_IEMT; - EmitterElementFactory x1c_FEMT; - RealElementFactory x20_AMPL; - RealElementFactory x24_AMPD; - RealElementFactory x28_LWD1; - RealElementFactory x2c_LWD2; - RealElementFactory x30_LWD3; - ColorElementFactory x34_LCL1; - ColorElementFactory x38_LCL2; - ColorElementFactory x3c_LCL3; - ChildResourceFactory x40_SSWH; - ChildResourceFactory x50_GPSM; - ChildResourceFactory x60_EPSM; - BoolHelper x70_ZERY; - void gatherDependencies(std::vector&) const; +template +struct _ELSM { + static constexpr ParticleType Type = ParticleType::ELSM; + +#define INT_ENTRY(name, identifier) IntElementFactory identifier; +#define REAL_ENTRY(name, identifier) RealElementFactory identifier; +#define COLOR_ENTRY(name, identifier) ColorElementFactory identifier; +#define EMITTER_ENTRY(name, identifier) EmitterElementFactory identifier; +#define RES_ENTRY(name, identifier) ChildResourceFactory identifier; +#define BOOL_ENTRY(name, identifier) bool identifier = false; +#include "ELSC.def" + + template + void constexpr Enumerate(_Func f) { +#define ENTRY(name, identifier) f(FOURCC(name), identifier); +#include "ELSC.def" + } + + template + bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { +#define ENTRY(name, identifier) case SBIG(name): f(identifier); return true; +#include "ELSC.def" + default: return false; + } + } }; +template +using ELSM = PPImpl<_ELSM>; template bool ExtractELSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath); diff --git a/DataSpec/DNACommon/PART.cpp b/DataSpec/DNACommon/PART.cpp index abdeea0d2..23176e42a 100644 --- a/DataSpec/DNACommon/PART.cpp +++ b/DataSpec/DNACommon/PART.cpp @@ -1,9 +1,14 @@ #include "DataSpec/DNACommon/PART.hpp" - #include "DataSpec/DNACommon/PAK.hpp" namespace DataSpec::DNAParticle { +template struct PPImpl<_GPSM>; +template struct PPImpl<_GPSM>; + +AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_GPSM>) +AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_GPSM>) + template <> std::string_view GPSM::DNAType() { return "GPSM"sv; @@ -14,1399 +19,6 @@ std::string_view GPSM::DNAType() { return "GPSM"sv; } -template -void GPSM::_read(typename ReadYaml::StreamT& r) { - for (const auto& elem : r.getCurNode()->m_mapChildren) { - if (elem.first.size() < 4) { - LogModule.report(logvisor::Warning, fmt("short FourCC in element '{}'"), elem.first); - continue; - } - - if (auto rec = r.enterSubRecord(elem.first.c_str())) { - 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(); - break; - case SBIG('AAPH'): - x44_26_AAPH = r.readBool(); - 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(); - 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(); - break; - case SBIG('LFOT'): - x114_LFOT.read(r); - break; - case SBIG('LIT_'): - x44_29_LIT_ = r.readBool(); - 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(); - 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(); - break; - case SBIG('PMAB'): - x44_31_PMAB = r.readBool(); - 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(); - 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(); - break; - case SBIG('SSSD'): - xe4_SSSD.read(r); - break; - case SBIG('SORT'): - x44_28_SORT = r.readBool(); - 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(); - break; - case SBIG('VMD3'): - x45_28_VMD3 = r.readBool(); - break; - case SBIG('VMD2'): - x45_27_VMD2 = r.readBool(); - break; - case SBIG('VMD1'): - x45_26_VMD1 = r.readBool(); - 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(); - break; - case SBIG('WIDT'): - x24_WIDT.read(r); - break; - case SBIG('ORNT'): - x30_30_ORNT = r.readBool(); - break; - case SBIG('RSOP'): - x30_31_RSOP = r.readBool(); - 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; - } - } - } -} - -template -void GPSM::_write(typename WriteYaml::StreamT& w) const { - if (x0_PSIV) - if (auto rec = w.enterSubRecord("PSIV")) - x0_PSIV.write(w); - if (x4_PSVM) - if (auto rec = w.enterSubRecord("PSVM")) - x4_PSVM.write(w); - if (x8_PSOV) - if (auto rec = w.enterSubRecord("PSOV")) - x8_PSOV.write(w); - if (xc_PSLT) - if (auto rec = w.enterSubRecord("PSLT")) - xc_PSLT.write(w); - if (x10_PSWT) - if (auto rec = w.enterSubRecord("PSWT")) - x10_PSWT.write(w); - if (x14_PSTS) - if (auto rec = w.enterSubRecord("PSTS")) - x14_PSTS.write(w); - if (x18_POFS) - if (auto rec = w.enterSubRecord("POFS")) - x18_POFS.write(w); - if (x1c_SEED) - if (auto rec = w.enterSubRecord("SEED")) - x1c_SEED.write(w); - if (x20_LENG) - if (auto rec = w.enterSubRecord("LENG")) - x20_LENG.write(w); - if (x24_WIDT) - if (auto rec = w.enterSubRecord("WIDT")) - x24_WIDT.write(w); - if (x28_MAXP) - if (auto rec = w.enterSubRecord("MAXP")) - x28_MAXP.write(w); - if (x2c_GRTE) - if (auto rec = w.enterSubRecord("GRTE")) - x2c_GRTE.write(w); - if (x30_COLR) - if (auto rec = w.enterSubRecord("COLR")) - x30_COLR.write(w); - if (x34_LTME) - if (auto rec = w.enterSubRecord("LTME")) - x34_LTME.write(w); - if (x38_ILOC) - if (auto rec = w.enterSubRecord("ILOC")) - x38_ILOC.write(w); - if (x3c_IVEC) - if (auto rec = w.enterSubRecord("IVEC")) - x3c_IVEC.write(w); - if (x40_EMTR) - if (auto rec = w.enterSubRecord("EMTR")) - x40_EMTR.write(w); - if (x44_24_LINE) - w.writeBool("LINE", true); - if (x44_25_FXLL) - w.writeBool("FXLL", true); - if (x44_26_AAPH) - w.writeBool("AAPH", true); - if (x44_27_ZBUF) - w.writeBool("ZBUF", true); - if (x44_28_SORT) - w.writeBool("SORT", true); - if (x44_29_LIT_) - w.writeBool("LIT_", true); - if (x44_30_MBLR) - w.writeBool("MBLR", true); - if (x44_31_PMAB) - w.writeBool("PMAB", true); - if (x45_24_PMUS) - w.writeBool("PMUS", true); - if (!x45_25_PMOO) - w.writeBool("PMOO", false); - if (x45_26_VMD1) - w.writeBool("VMD1", true); - if (x45_27_VMD2) - w.writeBool("VMD2", true); - if (x45_28_VMD3) - w.writeBool("VMD3", true); - if (x45_29_VMD4) - w.writeBool("VMD4", true); - if (x45_30_CIND) - w.writeBool("CIND", true); - if (x45_31_OPTS) - w.writeBool("OPTS", true); - if (x30_30_ORNT) - w.writeBool("ORNT", true); - if (x30_31_RSOP) - w.writeBool("RSOP", true); - if (x48_MBSP) - if (auto rec = w.enterSubRecord("MBSP")) - x48_MBSP.write(w); - if (x4c_SIZE) - if (auto rec = w.enterSubRecord("SIZE")) - x4c_SIZE.write(w); - if (x50_ROTA) - if (auto rec = w.enterSubRecord("ROTA")) - x50_ROTA.write(w); - if (x54_TEXR) - if (auto rec = w.enterSubRecord("TEXR")) - x54_TEXR.write(w); - if (x58_TIND) - if (auto rec = w.enterSubRecord("TIND")) - x58_TIND.write(w); - if (x5c_PMDL) - if (auto rec = w.enterSubRecord("PMDL")) - x5c_PMDL.write(w); - if (x6c_PMOP) - if (auto rec = w.enterSubRecord("PMOP")) - x6c_PMOP.write(w); - if (x70_PMRT) - if (auto rec = w.enterSubRecord("PMRT")) - x70_PMRT.write(w); - if (x74_PMSC) - if (auto rec = w.enterSubRecord("PMSC")) - x74_PMSC.write(w); - if (x78_PMCL) - if (auto rec = w.enterSubRecord("PMCL")) - x78_PMCL.write(w); - if (x7c_VEL1) - if (auto rec = w.enterSubRecord("VEL1")) - x7c_VEL1.write(w); - if (x80_VEL2) - if (auto rec = w.enterSubRecord("VEL2")) - x80_VEL2.write(w); - if (x84_VEL3) - if (auto rec = w.enterSubRecord("VEL3")) - x84_VEL3.write(w); - if (x88_VEL4) - if (auto rec = w.enterSubRecord("VEL4")) - x88_VEL4.write(w); - if (x8c_ICTS) - if (auto rec = w.enterSubRecord("ICTS")) - x8c_ICTS.write(w); - if (x9c_NCSY) - if (auto rec = w.enterSubRecord("NCSY")) - x9c_NCSY.write(w); - if (xa0_CSSD) - if (auto rec = w.enterSubRecord("CSSD")) - xa0_CSSD.write(w); - if (xa4_IDTS) - if (auto rec = w.enterSubRecord("IDTS")) - xa4_IDTS.write(w); - if (xb4_NDSY) - if (auto rec = w.enterSubRecord("NDSY")) - xb4_NDSY.write(w); - if (xb8_IITS) - if (auto rec = w.enterSubRecord("IITS")) - xb8_IITS.write(w); - if (xc8_PISY) - if (auto rec = w.enterSubRecord("PISY")) - xc8_PISY.write(w); - if (xcc_SISY) - if (auto rec = w.enterSubRecord("SISY")) - xcc_SISY.write(w); - if (xd0_KSSM) - if (auto rec = w.enterSubRecord("KSSM")) - xd0_KSSM.write(w); - if (xd4_SSWH) - if (auto rec = w.enterSubRecord("SSWH")) - xd4_SSWH.write(w); - if (xd8_SELC) - if (auto rec = w.enterSubRecord("SELC")) - xd8_SELC.write(w); - if (xe4_SSSD) - if (auto rec = w.enterSubRecord("SSSD")) - xe4_SSSD.write(w); - if (xe8_SSPO) - if (auto rec = w.enterSubRecord("SSPO")) - xe8_SSPO.write(w); - if (xf8_SESD) - if (auto rec = w.enterSubRecord("SESD")) - xf8_SESD.write(w); - if (xfc_SEPO) - if (auto rec = w.enterSubRecord("SEPO")) - xfc_SEPO.write(w); - if (xec_PMLC) - if (auto rec = w.enterSubRecord("PMLC")) - xec_PMLC.write(w); - if (x100_LTYP) - if (auto rec = w.enterSubRecord("LTYP")) - x100_LTYP.write(w); - if (x104_LCLR) - if (auto rec = w.enterSubRecord("LCLR")) - x104_LCLR.write(w); - if (x108_LINT) - if (auto rec = w.enterSubRecord("LINT")) - x108_LINT.write(w); - if (x10c_LOFF) - if (auto rec = w.enterSubRecord("LOFF")) - x10c_LOFF.write(w); - if (x110_LDIR) - if (auto rec = w.enterSubRecord("LDIR")) - x110_LDIR.write(w); - if (x114_LFOT) - if (auto rec = w.enterSubRecord("LFOT")) - x114_LFOT.write(w); - if (x118_LFOR) - if (auto rec = w.enterSubRecord("LFOR")) - x118_LFOR.write(w); - if (x11c_LSLA) - if (auto rec = w.enterSubRecord("LSLA")) - x11c_LSLA.write(w); - if (x10c_ADV1) - if (auto rec = w.enterSubRecord("ADV1")) - x10c_ADV1.write(w); - if (x110_ADV2) - if (auto rec = w.enterSubRecord("ADV2")) - x110_ADV2.write(w); - if (x114_ADV3) - if (auto rec = w.enterSubRecord("ADV3")) - x114_ADV3.write(w); - if (x118_ADV4) - if (auto rec = w.enterSubRecord("ADV4")) - x118_ADV4.write(w); - if (x11c_ADV5) - if (auto rec = w.enterSubRecord("ADV5")) - x11c_ADV5.write(w); - if (x120_ADV6) - if (auto rec = w.enterSubRecord("ADV6")) - x120_ADV6.write(w); - if (x124_ADV7) - if (auto rec = w.enterSubRecord("ADV7")) - x124_ADV7.write(w); - if (x128_ADV8) - if (auto rec = w.enterSubRecord("ADV8")) - x128_ADV8.write(w); -} - -template -void GPSM::_binarySize(typename BinarySize::StreamT& s) const { - s += 4; - if (x0_PSIV) { - s += 4; - x0_PSIV.binarySize(s); - } - if (x4_PSVM) { - s += 4; - x4_PSVM.binarySize(s); - } - if (x8_PSOV) { - s += 4; - x8_PSOV.binarySize(s); - } - if (xc_PSLT) { - s += 4; - xc_PSLT.binarySize(s); - } - if (x10_PSWT) { - s += 4; - x10_PSWT.binarySize(s); - } - if (x14_PSTS) { - s += 4; - x14_PSTS.binarySize(s); - } - if (x18_POFS) { - s += 4; - x18_POFS.binarySize(s); - } - if (x1c_SEED) { - s += 4; - x1c_SEED.binarySize(s); - } - if (x20_LENG) { - s += 4; - x20_LENG.binarySize(s); - } - if (x24_WIDT) { - s += 4; - x24_WIDT.binarySize(s); - } - if (x28_MAXP) { - s += 4; - x28_MAXP.binarySize(s); - } - if (x2c_GRTE) { - s += 4; - x2c_GRTE.binarySize(s); - } - if (x30_COLR) { - s += 4; - x30_COLR.binarySize(s); - } - if (x34_LTME) { - s += 4; - x34_LTME.binarySize(s); - } - if (x38_ILOC) { - s += 4; - x38_ILOC.binarySize(s); - } - if (x3c_IVEC) { - s += 4; - x3c_IVEC.binarySize(s); - } - if (x40_EMTR) { - s += 4; - x40_EMTR.binarySize(s); - } - if (x44_24_LINE) - s += 9; - if (x44_25_FXLL) - s += 9; - if (x44_26_AAPH) - s += 9; - if (x44_27_ZBUF) - s += 9; - if (x44_28_SORT) - s += 9; - if (x44_29_LIT_) - s += 9; - if (x44_30_MBLR) - s += 9; - if (x44_31_PMAB) - s += 9; - if (x45_24_PMUS) - s += 9; - if (!x45_25_PMOO) - s += 9; - if (x45_26_VMD1) - s += 9; - if (x45_27_VMD2) - s += 9; - if (x45_28_VMD3) - s += 9; - if (x45_29_VMD4) - s += 9; - if (x45_30_CIND) - s += 9; - if (x45_31_OPTS) - s += 9; - if (x30_30_ORNT) - s += 9; - if (x30_31_RSOP) - s += 9; - if (x48_MBSP) { - s += 4; - x48_MBSP.binarySize(s); - } - if (x4c_SIZE) { - s += 4; - x4c_SIZE.binarySize(s); - } - if (x50_ROTA) { - s += 4; - x50_ROTA.binarySize(s); - } - if (x54_TEXR) { - s += 4; - x54_TEXR.binarySize(s); - } - if (x58_TIND) { - s += 4; - x58_TIND.binarySize(s); - } - if (x5c_PMDL) { - s += 4; - x5c_PMDL.binarySize(s); - } - if (x6c_PMOP) { - s += 4; - x6c_PMOP.binarySize(s); - } - if (x70_PMRT) { - s += 4; - x70_PMRT.binarySize(s); - } - if (x74_PMSC) { - s += 4; - x74_PMSC.binarySize(s); - } - if (x78_PMCL) { - s += 4; - x78_PMCL.binarySize(s); - } - if (x7c_VEL1) { - s += 4; - x7c_VEL1.binarySize(s); - } - if (x80_VEL2) { - s += 4; - x80_VEL2.binarySize(s); - } - if (x84_VEL3) { - s += 4; - x84_VEL3.binarySize(s); - } - if (x88_VEL4) { - s += 4; - x88_VEL4.binarySize(s); - } - if (x8c_ICTS) { - s += 4; - x8c_ICTS.binarySize(s); - } - if (x9c_NCSY) { - s += 4; - x9c_NCSY.binarySize(s); - } - if (xa0_CSSD) { - s += 4; - xa0_CSSD.binarySize(s); - } - if (xa4_IDTS) { - s += 4; - xa4_IDTS.binarySize(s); - } - if (xb4_NDSY) { - s += 4; - xb4_NDSY.binarySize(s); - } - if (xb8_IITS) { - s += 4; - xb8_IITS.binarySize(s); - } - if (xc8_PISY) { - s += 4; - xc8_PISY.binarySize(s); - } - if (xcc_SISY) { - s += 4; - xcc_SISY.binarySize(s); - } - if (xd0_KSSM) { - s += 4; - xd0_KSSM.binarySize(s); - } - if (xd4_SSWH) { - s += 4; - xd4_SSWH.binarySize(s); - } - if (xd8_SELC) { - s += 4; - xd8_SELC.binarySize(s); - } - if (xe4_SSSD) { - s += 4; - xe4_SSSD.binarySize(s); - } - if (xe8_SSPO) { - s += 4; - xe8_SSPO.binarySize(s); - } - if (xf8_SESD) { - s += 4; - xf8_SESD.binarySize(s); - } - if (xfc_SEPO) { - s += 4; - xfc_SEPO.binarySize(s); - } - if (xec_PMLC) { - s += 4; - xec_PMLC.binarySize(s); - } - if (x100_LTYP) { - s += 4; - x100_LTYP.binarySize(s); - } - if (x104_LCLR) { - s += 4; - x104_LCLR.binarySize(s); - } - if (x108_LINT) { - s += 4; - x108_LINT.binarySize(s); - } - if (x10c_LOFF) { - s += 4; - x10c_LOFF.binarySize(s); - } - if (x110_LDIR) { - s += 4; - x110_LDIR.binarySize(s); - } - if (x114_LFOT) { - s += 4; - x114_LFOT.binarySize(s); - } - if (x118_LFOR) { - s += 4; - x118_LFOR.binarySize(s); - } - if (x11c_LSLA) { - s += 4; - x11c_LSLA.binarySize(s); - } - if (x10c_ADV1) { - s += 4; - x10c_ADV1.binarySize(s); - } - if (x110_ADV2) { - s += 4; - x110_ADV2.binarySize(s); - } - if (x114_ADV3) { - s += 4; - x114_ADV3.binarySize(s); - } - if (x118_ADV4) { - s += 4; - x118_ADV4.binarySize(s); - } - if (x11c_ADV5) { - s += 4; - x11c_ADV5.binarySize(s); - } - if (x120_ADV6) { - s += 4; - x120_ADV6.binarySize(s); - } - if (x124_ADV7) { - s += 4; - x124_ADV7.binarySize(s); - } - if (x128_ADV8) { - s += 4; - x128_ADV8.binarySize(s); - } -} - -template -void GPSM::_read(typename Read::StreamT& r) { - DNAFourCC clsId; - clsId.read(r); - if (clsId != SBIG('GPSM')) { - LogModule.report(logvisor::Warning, fmt("non GPSM provided to GPSM parser")); - return; - } - clsId.read(r); - while (clsId != SBIG('_END')) { - switch (clsId.toUint32()) { - 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'): - r.readUint32Big(); - x45_30_CIND = r.readBool(); - break; - case SBIG('AAPH'): - r.readUint32Big(); - x44_26_AAPH = r.readBool(); - break; - case SBIG('CSSD'): - xa0_CSSD.read(r); - break; - case SBIG('GRTE'): - x2c_GRTE.read(r); - break; - case SBIG('FXLL'): - r.readUint32Big(); - x44_25_FXLL = r.readBool(); - 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'): - r.readUint32Big(); - x44_24_LINE = r.readBool(); - break; - case SBIG('LFOT'): - x114_LFOT.read(r); - break; - case SBIG('LIT_'): - r.readUint32Big(); - x44_29_LIT_ = r.readBool(); - 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'): - r.readUint32Big(); - x44_30_MBLR = r.readBool(); - break; - case SBIG('NCSY'): - x9c_NCSY.read(r); - break; - case SBIG('PISY'): - xc8_PISY.read(r); - break; - case SBIG('OPTS'): - r.readUint32Big(); - x45_31_OPTS = r.readBool(); - break; - case SBIG('PMAB'): - r.readUint32Big(); - x44_31_PMAB = r.readBool(); - 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'): - r.readUint32Big(); - x45_24_PMUS = r.readBool(); - 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'): - r.readUint32Big(); - x45_25_PMOO = r.readBool(); - break; - case SBIG('SSSD'): - xe4_SSSD.read(r); - break; - case SBIG('SORT'): - r.readUint32Big(); - x44_28_SORT = r.readBool(); - 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'): - r.readUint32Big(); - x45_29_VMD4 = r.readBool(); - break; - case SBIG('VMD3'): - r.readUint32Big(); - x45_28_VMD3 = r.readBool(); - break; - case SBIG('VMD2'): - r.readUint32Big(); - x45_27_VMD2 = r.readBool(); - break; - case SBIG('VMD1'): - r.readUint32Big(); - x45_26_VMD1 = r.readBool(); - 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'): - r.readUint32Big(); - x44_27_ZBUF = r.readBool(); - break; - case SBIG('WIDT'): - x24_WIDT.read(r); - break; - case SBIG('ORNT'): - r.readUint32Big(); - x30_30_ORNT = r.readBool(); - break; - case SBIG('RSOP'): - r.readUint32Big(); - x30_31_RSOP = r.readBool(); - 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('ADV8'): - x128_ADV8.read(r); - break; - case SBIG('SELC'): - xd8_SELC.read(r); - break; - default: - LogModule.report(logvisor::Fatal, fmt("Unknown GPSM class {} @{}"), clsId, r.position()); - break; - } - clsId.read(r); - } -} - -template -void GPSM::_write(typename Write::StreamT& w) const { - w.writeBytes((atInt8*)"GPSM", 4); - if (x0_PSIV) { - w.writeBytes((atInt8*)"PSIV", 4); - x0_PSIV.write(w); - } - if (x4_PSVM) { - w.writeBytes((atInt8*)"PSVM", 4); - x4_PSVM.write(w); - } - if (x8_PSOV) { - w.writeBytes((atInt8*)"PSOV", 4); - x8_PSOV.write(w); - } - if (xc_PSLT) { - w.writeBytes((atInt8*)"PSLT", 4); - xc_PSLT.write(w); - } - if (x10_PSWT) { - w.writeBytes((atInt8*)"PSWT", 4); - x10_PSWT.write(w); - } - if (x14_PSTS) { - w.writeBytes((atInt8*)"PSTS", 4); - x14_PSTS.write(w); - } - if (x18_POFS) { - w.writeBytes((atInt8*)"POFS", 4); - x18_POFS.write(w); - } - if (x1c_SEED) { - w.writeBytes((atInt8*)"SEED", 4); - x1c_SEED.write(w); - } - if (x20_LENG) { - w.writeBytes((atInt8*)"LENG", 4); - x20_LENG.write(w); - } - if (x24_WIDT) { - w.writeBytes((atInt8*)"WIDT", 4); - x24_WIDT.write(w); - } - if (x28_MAXP) { - w.writeBytes((atInt8*)"MAXP", 4); - x28_MAXP.write(w); - } - if (x2c_GRTE) { - w.writeBytes((atInt8*)"GRTE", 4); - x2c_GRTE.write(w); - } - if (x30_COLR) { - w.writeBytes((atInt8*)"COLR", 4); - x30_COLR.write(w); - } - if (x34_LTME) { - w.writeBytes((atInt8*)"LTME", 4); - x34_LTME.write(w); - } - if (x38_ILOC) { - w.writeBytes((atInt8*)"ILOC", 4); - x38_ILOC.write(w); - } - if (x3c_IVEC) { - w.writeBytes((atInt8*)"IVEC", 4); - x3c_IVEC.write(w); - } - if (x40_EMTR) { - w.writeBytes((atInt8*)"EMTR", 4); - x40_EMTR.write(w); - } - if (x44_24_LINE) { - w.writeBytes((atInt8*)"LINECNST\x01", 9); - } - if (x44_25_FXLL) { - w.writeBytes((atInt8*)"FXLLCNST\x01", 9); - } - if (x44_26_AAPH) { - w.writeBytes((atInt8*)"AAPHCNST\x01", 9); - } - if (x44_27_ZBUF) { - w.writeBytes((atInt8*)"ZBUFCNST\x01", 9); - } - if (x44_28_SORT) { - w.writeBytes((atInt8*)"SORTCNST\x01", 9); - } - if (x44_29_LIT_) { - w.writeBytes((atInt8*)"LIT_CNST\x01", 9); - } - if (x44_30_MBLR) { - w.writeBytes((atInt8*)"MBLRCNST\x01", 9); - } - if (x44_31_PMAB) { - w.writeBytes((atInt8*)"PMABCNST\x01", 9); - } - if (x45_24_PMUS) { - w.writeBytes((atInt8*)"PMUSCNST\x01", 9); - } - if (!x45_25_PMOO) { - w.writeBytes((atInt8*)"PMOOCNST\x00", 9); - } - if (x45_26_VMD1) { - w.writeBytes((atInt8*)"VMD1CNST\x01", 9); - } - if (x45_27_VMD2) { - w.writeBytes((atInt8*)"VMD2CNST\x01", 9); - } - if (x45_28_VMD3) { - w.writeBytes((atInt8*)"VMD3CNST\x01", 9); - } - if (x45_29_VMD4) { - w.writeBytes((atInt8*)"VMD4CNST\x01", 9); - } - if (x45_30_CIND) { - w.writeBytes((atInt8*)"CINDCNST\x01", 9); - } - if (x45_31_OPTS) { - w.writeBytes((atInt8*)"OPTSCNST\x01", 9); - } - if (x30_30_ORNT) { - w.writeBytes((atInt8*)"ORNTCNST\x01", 9); - } - if (x30_31_RSOP) { - w.writeBytes((atInt8*)"RSOPCNST\x01", 9); - } - if (x48_MBSP) { - w.writeBytes((atInt8*)"MBSP", 4); - x48_MBSP.write(w); - } - if (x4c_SIZE) { - w.writeBytes((atInt8*)"SIZE", 4); - x4c_SIZE.write(w); - } - if (x50_ROTA) { - w.writeBytes((atInt8*)"ROTA", 4); - x50_ROTA.write(w); - } - if (x54_TEXR) { - w.writeBytes((atInt8*)"TEXR", 4); - x54_TEXR.write(w); - } - if (x58_TIND) { - w.writeBytes((atInt8*)"TIND", 4); - x58_TIND.write(w); - } - if (x5c_PMDL) { - w.writeBytes((atInt8*)"PMDL", 4); - x5c_PMDL.write(w); - } - if (x6c_PMOP) { - w.writeBytes((atInt8*)"PMOP", 4); - x6c_PMOP.write(w); - } - if (x70_PMRT) { - w.writeBytes((atInt8*)"PMRT", 4); - x70_PMRT.write(w); - } - if (x74_PMSC) { - w.writeBytes((atInt8*)"PMSC", 4); - x74_PMSC.write(w); - } - if (x78_PMCL) { - w.writeBytes((atInt8*)"PMCL", 4); - x78_PMCL.write(w); - } - if (x7c_VEL1) { - w.writeBytes((atInt8*)"VEL1", 4); - x7c_VEL1.write(w); - } - if (x80_VEL2) { - w.writeBytes((atInt8*)"VEL2", 4); - x80_VEL2.write(w); - } - if (x84_VEL3) { - w.writeBytes((atInt8*)"VEL3", 4); - x84_VEL3.write(w); - } - if (x88_VEL4) { - w.writeBytes((atInt8*)"VEL4", 4); - x88_VEL4.write(w); - } - if (x8c_ICTS) { - w.writeBytes((atInt8*)"ICTS", 4); - x8c_ICTS.write(w); - } - if (x9c_NCSY) { - w.writeBytes((atInt8*)"NCSY", 4); - x9c_NCSY.write(w); - } - if (xa0_CSSD) { - w.writeBytes((atInt8*)"CSSD", 4); - xa0_CSSD.write(w); - } - if (xa4_IDTS) { - w.writeBytes((atInt8*)"IDTS", 4); - xa4_IDTS.write(w); - } - if (xb4_NDSY) { - w.writeBytes((atInt8*)"NDSY", 4); - xb4_NDSY.write(w); - } - if (xb8_IITS) { - w.writeBytes((atInt8*)"IITS", 4); - xb8_IITS.write(w); - } - if (xc8_PISY) { - w.writeBytes((atInt8*)"PISY", 4); - xc8_PISY.write(w); - } - if (xcc_SISY) { - w.writeBytes((atInt8*)"SISY", 4); - xcc_SISY.write(w); - } - if (xd0_KSSM) { - w.writeBytes((atInt8*)"KSSM", 4); - xd0_KSSM.write(w); - } - if (xd4_SSWH) { - w.writeBytes((atInt8*)"SSWH", 4); - xd4_SSWH.write(w); - } - if (xd8_SELC) { - w.writeBytes((atInt8*)"SELC", 4); - xd8_SELC.write(w); - } - if (xe4_SSSD) { - w.writeBytes((atInt8*)"SSSD", 4); - xe4_SSSD.write(w); - } - if (xe8_SSPO) { - w.writeBytes((atInt8*)"SSPO", 4); - xe8_SSPO.write(w); - } - if (xf8_SESD) { - w.writeBytes((atInt8*)"SESD", 4); - xf8_SESD.write(w); - } - if (xfc_SEPO) { - w.writeBytes((atInt8*)"SEPO", 4); - xfc_SEPO.write(w); - } - if (xec_PMLC) { - w.writeBytes((atInt8*)"PMLC", 4); - xec_PMLC.write(w); - } - if (x100_LTYP) { - w.writeBytes((atInt8*)"LTYP", 4); - x100_LTYP.write(w); - } - if (x104_LCLR) { - w.writeBytes((atInt8*)"LCLR", 4); - x104_LCLR.write(w); - } - if (x108_LINT) { - w.writeBytes((atInt8*)"LINT", 4); - x108_LINT.write(w); - } - if (x10c_LOFF) { - w.writeBytes((atInt8*)"LOFF", 4); - x10c_LOFF.write(w); - } - if (x110_LDIR) { - w.writeBytes((atInt8*)"LDIR", 4); - x110_LDIR.write(w); - } - if (x114_LFOT) { - w.writeBytes((atInt8*)"LFOT", 4); - x114_LFOT.write(w); - } - if (x118_LFOR) { - w.writeBytes((atInt8*)"LFOR", 4); - x118_LFOR.write(w); - } - if (x11c_LSLA) { - w.writeBytes((atInt8*)"LSLA", 4); - x11c_LSLA.write(w); - } - if (x10c_ADV1) { - w.writeBytes((atInt8*)"ADV1", 4); - x10c_ADV1.write(w); - } - if (x110_ADV2) { - w.writeBytes((atInt8*)"ADV2", 4); - x110_ADV2.write(w); - } - if (x114_ADV3) { - w.writeBytes((atInt8*)"ADV3", 4); - x114_ADV3.write(w); - } - if (x118_ADV4) { - w.writeBytes((atInt8*)"ADV4", 4); - x118_ADV4.write(w); - } - if (x11c_ADV5) { - w.writeBytes((atInt8*)"ADV5", 4); - x11c_ADV5.write(w); - } - if (x120_ADV6) { - w.writeBytes((atInt8*)"ADV6", 4); - x120_ADV6.write(w); - } - if (x124_ADV7) { - w.writeBytes((atInt8*)"ADV7", 4); - x124_ADV7.write(w); - } - if (x128_ADV8) { - w.writeBytes((atInt8*)"ADV8", 4); - x128_ADV8.write(w); - } - w.writeBytes("_END", 4); -} - -AT_SUBSPECIALIZE_DNA_YAML(GPSM) -AT_SUBSPECIALIZE_DNA_YAML(GPSM) - -template -void GPSM::gatherDependencies(std::vector& pathsOut) const { - if (x54_TEXR.m_elem) - x54_TEXR.m_elem->gatherDependencies(pathsOut); - if (x58_TIND.m_elem) - x58_TIND.m_elem->gatherDependencies(pathsOut); - g_curSpec->flattenDependencies(x5c_PMDL.id, pathsOut); - g_curSpec->flattenDependencies(x8c_ICTS.id, pathsOut); - g_curSpec->flattenDependencies(xa4_IDTS.id, pathsOut); - g_curSpec->flattenDependencies(xb8_IITS.id, pathsOut); - xd0_KSSM.gatherDependencies(pathsOut); - g_curSpec->flattenDependencies(xd4_SSWH.id, pathsOut); - g_curSpec->flattenDependencies(xec_PMLC.id, pathsOut); - g_curSpec->flattenDependencies(xd8_SELC.id, pathsOut); -} - -template struct GPSM; -template struct GPSM; - template bool ExtractGPSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { athena::io::FileWriter writer(outPath.getAbsolutePath()); diff --git a/DataSpec/DNACommon/PART.def b/DataSpec/DNACommon/PART.def new file mode 100644 index 000000000..8b932cbf3 --- /dev/null +++ b/DataSpec/DNACommon/PART.def @@ -0,0 +1,141 @@ +#ifndef ENTRY +#define ENTRY(name, identifier) +#endif + +#ifndef INT_ENTRY +#define INT_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef REAL_ENTRY +#define REAL_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef VECTOR_ENTRY +#define VECTOR_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef MOD_VECTOR_ENTRY +#define MOD_VECTOR_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef COLOR_ENTRY +#define COLOR_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef EMITTER_ENTRY +#define EMITTER_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef UV_ENTRY +#define UV_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef RES_ENTRY +#define RES_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef KSSM_ENTRY +#define KSSM_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef BOOL_ENTRY +#define BOOL_ENTRY(name, identifier, def) ENTRY(name, identifier) +#endif + +VECTOR_ENTRY('PSIV', x0_PSIV) +MOD_VECTOR_ENTRY('PSVM', x4_PSVM) +VECTOR_ENTRY('PSOV', x8_PSOV) +INT_ENTRY('PSLT', xc_PSLT) +INT_ENTRY('PSWT', x10_PSWT) +REAL_ENTRY('PSTS', x14_PSTS) +VECTOR_ENTRY('POFS', x18_POFS) +INT_ENTRY('SEED', x1c_SEED) +REAL_ENTRY('LENG', x20_LENG) +REAL_ENTRY('WIDT', x24_WIDT) +INT_ENTRY('MAXP', x28_MAXP) +REAL_ENTRY('GRTE', x2c_GRTE) +COLOR_ENTRY('COLR', x30_COLR) +INT_ENTRY('LTME', x34_LTME) +VECTOR_ENTRY('ILOC', x38_ILOC) +VECTOR_ENTRY('IVEC', x3c_IVEC) +EMITTER_ENTRY('EMTR', x40_EMTR) +INT_ENTRY('MBSP', x48_MBSP) +REAL_ENTRY('SIZE', x4c_SIZE) +REAL_ENTRY('ROTA', x50_ROTA) +UV_ENTRY('TEXR', x54_TEXR) +UV_ENTRY('TIND', x58_TIND) +RES_ENTRY('PMDL', x5c_PMDL) +VECTOR_ENTRY('PMOP', x6c_PMOP) +VECTOR_ENTRY('PMRT', x70_PMRT) +VECTOR_ENTRY('PMSC', x74_PMSC) +COLOR_ENTRY('PMCL', x78_PMCL) +MOD_VECTOR_ENTRY('VEL1', x7c_VEL1) +MOD_VECTOR_ENTRY('VEL2', x80_VEL2) +MOD_VECTOR_ENTRY('VEL3', x84_VEL3) +MOD_VECTOR_ENTRY('VEL4', x88_VEL4) +RES_ENTRY('ICTS', x8c_ICTS) +INT_ENTRY('NCSY', x9c_NCSY) +INT_ENTRY('CSSD', xa0_CSSD) +RES_ENTRY('IDTS', xa4_IDTS) +INT_ENTRY('NDSY', xb4_NDSY) +RES_ENTRY('IITS', xb8_IITS) +INT_ENTRY('PISY', xc8_PISY) +INT_ENTRY('SISY', xcc_SISY) +KSSM_ENTRY('KSSM', xd0_KSSM) +RES_ENTRY('SSWH', xd4_SSWH) +INT_ENTRY('SSSD', xe4_SSSD) +VECTOR_ENTRY('SSPO', xe8_SSPO) +INT_ENTRY('SESD', xf8_SESD) +VECTOR_ENTRY('SEPO', xfc_SEPO) +RES_ENTRY('PMLC', xec_PMLC) +INT_ENTRY('LTYP', x100_LTYP) +COLOR_ENTRY('LCLR', x104_LCLR) +REAL_ENTRY('LINT', x108_LINT) +VECTOR_ENTRY('LOFF', x10c_LOFF) +VECTOR_ENTRY('LDIR', x110_LDIR) +INT_ENTRY('LFOT', x114_LFOT) +REAL_ENTRY('LFOR', x118_LFOR) +REAL_ENTRY('LSLA', x11c_LSLA) + +/* 0-00 additions */ +RES_ENTRY('SELC', xd8_SELC) +REAL_ENTRY('ADV1', x10c_ADV1) +REAL_ENTRY('ADV2', x110_ADV2) +REAL_ENTRY('ADV3', x114_ADV3) +REAL_ENTRY('ADV4', x118_ADV4) +REAL_ENTRY('ADV5', x11c_ADV5) +REAL_ENTRY('ADV6', x120_ADV6) +REAL_ENTRY('ADV7', x124_ADV7) +REAL_ENTRY('ADV8', x128_ADV8) + +BOOL_ENTRY('SORT', x44_28_SORT, false) +BOOL_ENTRY('MBLR', x44_30_MBLR, false) +BOOL_ENTRY('LINE', x44_24_LINE, false) +BOOL_ENTRY('LIT_', x44_29_LIT_, false) +BOOL_ENTRY('AAPH', x44_26_AAPH, false) +BOOL_ENTRY('ZBUF', x44_27_ZBUF, false) +BOOL_ENTRY('FXLL', x44_25_FXLL, false) +BOOL_ENTRY('PMAB', x44_31_PMAB, false) +BOOL_ENTRY('VMD4', x45_29_VMD4, false) +BOOL_ENTRY('VMD3', x45_28_VMD3, false) +BOOL_ENTRY('VMD2', x45_27_VMD2, false) +BOOL_ENTRY('VMD1', x45_26_VMD1, false) +BOOL_ENTRY('OPTS', x45_31_OPTS, false) +BOOL_ENTRY('PMUS', x45_24_PMUS, false) +BOOL_ENTRY('PMOO', x45_25_PMOO, true) +BOOL_ENTRY('CIND', x45_30_CIND, false) + +BOOL_ENTRY('ORNT', x30_30_ORNT, false) +BOOL_ENTRY('RSOP', x30_31_RSOP, false) + +#undef ENTRY +#undef INT_ENTRY +#undef REAL_ENTRY +#undef VECTOR_ENTRY +#undef MOD_VECTOR_ENTRY +#undef COLOR_ENTRY +#undef EMITTER_ENTRY +#undef UV_ENTRY +#undef RES_ENTRY +#undef KSSM_ENTRY +#undef BOOL_ENTRY diff --git a/DataSpec/DNACommon/PART.hpp b/DataSpec/DNACommon/PART.hpp index 0475dc217..8c30dc28d 100644 --- a/DataSpec/DNACommon/PART.hpp +++ b/DataSpec/DNACommon/PART.hpp @@ -17,107 +17,39 @@ class ProjectPath; namespace DataSpec::DNAParticle { template -struct GPSM : BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - AT_SUBDECL_DNA - VectorElementFactory x0_PSIV; - ModVectorElementFactory x4_PSVM; - VectorElementFactory x8_PSOV; - IntElementFactory xc_PSLT; - IntElementFactory x10_PSWT; - RealElementFactory x14_PSTS; - VectorElementFactory x18_POFS; - IntElementFactory x1c_SEED; - RealElementFactory x20_LENG; - RealElementFactory x24_WIDT; - IntElementFactory x28_MAXP; - RealElementFactory x2c_GRTE; - ColorElementFactory x30_COLR; - IntElementFactory x34_LTME; - VectorElementFactory x38_ILOC; - VectorElementFactory x3c_IVEC; - EmitterElementFactory x40_EMTR; - union { - struct { - bool x44_28_SORT : 1; - bool x44_30_MBLR : 1; - bool x44_24_LINE : 1; - bool x44_29_LIT_ : 1; - bool x44_26_AAPH : 1; - bool x44_27_ZBUF : 1; - bool x44_25_FXLL : 1; - bool x44_31_PMAB : 1; - bool x45_29_VMD4 : 1; - bool x45_28_VMD3 : 1; - bool x45_27_VMD2 : 1; - bool x45_26_VMD1 : 1; - bool x45_31_OPTS : 1; - bool x45_24_PMUS : 1; - bool x45_25_PMOO : 1; - bool x45_30_CIND : 1; - }; - uint16_t dummy1 = 0; - }; - IntElementFactory x48_MBSP; - RealElementFactory x4c_SIZE; - RealElementFactory x50_ROTA; - UVElementFactory x54_TEXR; - UVElementFactory x58_TIND; - ChildResourceFactory x5c_PMDL; - VectorElementFactory x6c_PMOP; - VectorElementFactory x70_PMRT; - VectorElementFactory x74_PMSC; - ColorElementFactory x78_PMCL; - ModVectorElementFactory x7c_VEL1; - ModVectorElementFactory x80_VEL2; - ModVectorElementFactory x84_VEL3; - ModVectorElementFactory x88_VEL4; - ChildResourceFactory x8c_ICTS; - IntElementFactory x9c_NCSY; - IntElementFactory xa0_CSSD; - ChildResourceFactory xa4_IDTS; - IntElementFactory xb4_NDSY; - ChildResourceFactory xb8_IITS; - IntElementFactory xc8_PISY; - IntElementFactory xcc_SISY; - SpawnSystemKeyframeData xd0_KSSM; - ChildResourceFactory xd4_SSWH; - IntElementFactory xe4_SSSD; - VectorElementFactory xe8_SSPO; - IntElementFactory xf8_SESD; - VectorElementFactory xfc_SEPO; - ChildResourceFactory xec_PMLC; - IntElementFactory x100_LTYP; - ColorElementFactory x104_LCLR; - RealElementFactory x108_LINT; - VectorElementFactory x10c_LOFF; - VectorElementFactory x110_LDIR; - IntElementFactory x114_LFOT; - RealElementFactory x118_LFOR; - RealElementFactory x11c_LSLA; +struct _GPSM { + static constexpr ParticleType Type = ParticleType::GPSM; - /* 0-00 additions */ - ChildResourceFactory xd8_SELC; - union { - struct { - bool x30_30_ORNT : 1; - bool x30_31_RSOP : 1; - }; - uint16_t dummy2 = 0; - }; - RealElementFactory x10c_ADV1; - RealElementFactory x110_ADV2; - RealElementFactory x114_ADV3; - RealElementFactory x118_ADV4; - RealElementFactory x11c_ADV5; - RealElementFactory x120_ADV6; - RealElementFactory x124_ADV7; - RealElementFactory x128_ADV8; +#define INT_ENTRY(name, identifier) IntElementFactory identifier; +#define REAL_ENTRY(name, identifier) RealElementFactory identifier; +#define VECTOR_ENTRY(name, identifier) VectorElementFactory identifier; +#define MOD_VECTOR_ENTRY(name, identifier) ModVectorElementFactory identifier; +#define COLOR_ENTRY(name, identifier) ColorElementFactory identifier; +#define EMITTER_ENTRY(name, identifier) EmitterElementFactory identifier; +#define UV_ENTRY(name, identifier) UVElementFactory identifier; +#define RES_ENTRY(name, identifier) ChildResourceFactory identifier; +#define KSSM_ENTRY(name, identifier) SpawnSystemKeyframeData identifier; +#define BOOL_ENTRY(name, identifier, def) bool identifier = def; +#include "PART.def" - GPSM() { x45_25_PMOO = true; } + template + void constexpr Enumerate(_Func f) { +#define ENTRY(name, identifier) f(FOURCC(name), identifier); +#define BOOL_ENTRY(name, identifier, def) f(FOURCC(name), identifier, def); +#include "PART.def" + } - void gatherDependencies(std::vector&) const; + template + bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { +#define ENTRY(name, identifier) case SBIG(name): f(identifier); return true; +#include "PART.def" + default: return false; + } + } }; +template +using GPSM = PPImpl<_GPSM>; template bool ExtractGPSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath); diff --git a/DataSpec/DNACommon/ParticleCommon.cpp b/DataSpec/DNACommon/ParticleCommon.cpp index 7ef172e8b..301f6ac56 100644 --- a/DataSpec/DNACommon/ParticleCommon.cpp +++ b/DataSpec/DNACommon/ParticleCommon.cpp @@ -3,6 +3,24 @@ namespace DataSpec::DNAParticle { logvisor::Module LogModule("urde::DNAParticle"); +template struct PEImpl<_RealElementFactory>; +template struct PEImpl<_IntElementFactory>; +template struct PEImpl<_VectorElementFactory>; +template struct PEImpl<_ColorElementFactory>; +template struct PEImpl<_ModVectorElementFactory>; +template struct PEImpl<_EmitterElementFactory>; +template struct PEImpl<_UVElementFactory>; +template struct PEImpl<_UVElementFactory>; + +AT_SUBSPECIALIZE_DNA_YAML(PEImpl<_RealElementFactory>) +AT_SUBSPECIALIZE_DNA_YAML(PEImpl<_IntElementFactory>) +AT_SUBSPECIALIZE_DNA_YAML(PEImpl<_VectorElementFactory>) +AT_SUBSPECIALIZE_DNA_YAML(PEImpl<_ColorElementFactory>) +AT_SUBSPECIALIZE_DNA_YAML(PEImpl<_ModVectorElementFactory>) +AT_SUBSPECIALIZE_DNA_YAML(PEImpl<_EmitterElementFactory>) +AT_SUBSPECIALIZE_DNA_YAML(PEImpl<_UVElementFactory>) +AT_SUBSPECIALIZE_DNA_YAML(PEImpl<_UVElementFactory>) + template <> void REConstant::Enumerate(typename ReadYaml::StreamT& r) { val = r.readFloat(); @@ -148,908 +166,6 @@ void MVEConstant::Enumerate(typename Write::StreamT& w) { comps[2].write(w); } -template <> -void RealElementFactory::Enumerate(typename ReadYaml::StreamT& r) { - const auto& mapChildren = r.getCurNode()->m_mapChildren; - if (mapChildren.empty()) { - m_elem.reset(); - return; - } - - const auto& elem = mapChildren[0]; - if (elem.first.size() < 4) - LogModule.report(logvisor::Fatal, fmt("short FourCC in element '{}'"), elem.first); - - switch (*reinterpret_cast(elem.first.data())) { - case SBIG('LFTW'): - m_elem.reset(new struct RELifetimeTween); - break; - case SBIG('CNST'): - m_elem.reset(new struct REConstant); - break; - case SBIG('CHAN'): - m_elem.reset(new struct RETimeChain); - break; - case SBIG('ADD_'): - m_elem.reset(new struct REAdd); - break; - case SBIG('CLMP'): - m_elem.reset(new struct REClamp); - break; - case SBIG('KEYE'): - case SBIG('KEYP'): - m_elem.reset(new struct REKeyframeEmitter); - break; - case SBIG('IRND'): - m_elem.reset(new struct REInitialRandom); - break; - case SBIG('RAND'): - m_elem.reset(new struct RERandom); - break; - case SBIG('MULT'): - m_elem.reset(new struct REMultiply); - break; - case SBIG('PULS'): - m_elem.reset(new struct REPulse); - break; - case SBIG('SCAL'): - m_elem.reset(new struct RETimeScale); - break; - case SBIG('RLPT'): - m_elem.reset(new struct RELifetimePercent); - break; - case SBIG('SINE'): - m_elem.reset(new struct RESineWave); - break; - case SBIG('ISWT'): - m_elem.reset(new struct REInitialSwitch); - break; - case SBIG('CLTN'): - m_elem.reset(new struct RECompareLessThan); - break; - case SBIG('CEQL'): - m_elem.reset(new struct RECompareEquals); - break; - case SBIG('PAP1'): - m_elem.reset(new struct REParticleAdvanceParam1); - break; - case SBIG('PAP2'): - m_elem.reset(new struct REParticleAdvanceParam2); - break; - case SBIG('PAP3'): - m_elem.reset(new struct REParticleAdvanceParam3); - break; - case SBIG('PAP4'): - m_elem.reset(new struct REParticleAdvanceParam4); - break; - case SBIG('PAP5'): - m_elem.reset(new struct REParticleAdvanceParam5); - break; - case SBIG('PAP6'): - m_elem.reset(new struct REParticleAdvanceParam6); - break; - case SBIG('PAP7'): - m_elem.reset(new struct REParticleAdvanceParam7); - break; - case SBIG('PAP8'): - m_elem.reset(new struct REParticleAdvanceParam8); - break; - case SBIG('PSLL'): - m_elem.reset(new struct REParticleSizeOrLineLength); - break; - case SBIG('PRLW'): - m_elem.reset(new struct REParticleRotationOrLineWidth); - break; - case SBIG('SUB_'): - m_elem.reset(new struct RESubtract); - break; - case SBIG('VMAG'): - m_elem.reset(new struct REVectorMagnitude); - break; - case SBIG('VXTR'): - m_elem.reset(new struct REVectorXToReal); - break; - case SBIG('VYTR'): - m_elem.reset(new struct REVectorYToReal); - break; - case SBIG('VZTR'): - m_elem.reset(new struct REVectorZToReal); - break; - case SBIG('CEXT'): - m_elem.reset(new struct RECEXT); - break; - case SBIG('ITRL'): - m_elem.reset(new struct REIntTimesReal); - break; - default: - m_elem.reset(); - return; - } - if (auto rec = r.enterSubRecord(elem.first.c_str())) - m_elem->read(r); -} - -template <> -void RealElementFactory::Enumerate(typename WriteYaml::StreamT& w) { - if (m_elem) - if (auto rec = w.enterSubRecord(m_elem->ClassID())) - m_elem->write(w); -} - -template <> -void RealElementFactory::Enumerate(typename BinarySize::StreamT& s) { - s += 4; - if (m_elem) - m_elem->binarySize(s); -} - -template <> -void RealElementFactory::Enumerate(typename Read::StreamT& r) { - DNAFourCC clsId; - clsId.read(r); - switch (clsId.toUint32()) { - case SBIG('LFTW'): - m_elem.reset(new struct RELifetimeTween); - break; - case SBIG('CNST'): - m_elem.reset(new struct REConstant); - break; - case SBIG('CHAN'): - m_elem.reset(new struct RETimeChain); - break; - case SBIG('ADD_'): - m_elem.reset(new struct REAdd); - break; - case SBIG('CLMP'): - m_elem.reset(new struct REClamp); - break; - case SBIG('KEYE'): - case SBIG('KEYP'): - m_elem.reset(new struct REKeyframeEmitter); - break; - case SBIG('IRND'): - m_elem.reset(new struct REInitialRandom); - break; - case SBIG('RAND'): - m_elem.reset(new struct RERandom); - break; - case SBIG('MULT'): - m_elem.reset(new struct REMultiply); - break; - case SBIG('PULS'): - m_elem.reset(new struct REPulse); - break; - case SBIG('SCAL'): - m_elem.reset(new struct RETimeScale); - break; - case SBIG('RLPT'): - m_elem.reset(new struct RELifetimePercent); - break; - case SBIG('SINE'): - m_elem.reset(new struct RESineWave); - break; - case SBIG('ISWT'): - m_elem.reset(new struct REInitialSwitch); - break; - case SBIG('CLTN'): - m_elem.reset(new struct RECompareLessThan); - break; - case SBIG('CEQL'): - m_elem.reset(new struct RECompareEquals); - break; - case SBIG('PAP1'): - m_elem.reset(new struct REParticleAdvanceParam1); - break; - case SBIG('PAP2'): - m_elem.reset(new struct REParticleAdvanceParam2); - break; - case SBIG('PAP3'): - m_elem.reset(new struct REParticleAdvanceParam3); - break; - case SBIG('PAP4'): - m_elem.reset(new struct REParticleAdvanceParam4); - break; - case SBIG('PAP5'): - m_elem.reset(new struct REParticleAdvanceParam5); - break; - case SBIG('PAP6'): - m_elem.reset(new struct REParticleAdvanceParam6); - break; - case SBIG('PAP7'): - m_elem.reset(new struct REParticleAdvanceParam7); - break; - case SBIG('PAP8'): - m_elem.reset(new struct REParticleAdvanceParam8); - break; - case SBIG('PSLL'): - m_elem.reset(new struct REParticleSizeOrLineLength); - break; - case SBIG('PRLW'): - m_elem.reset(new struct REParticleRotationOrLineWidth); - break; - case SBIG('SUB_'): - m_elem.reset(new struct RESubtract); - break; - case SBIG('VMAG'): - m_elem.reset(new struct REVectorMagnitude); - break; - case SBIG('VXTR'): - m_elem.reset(new struct REVectorXToReal); - break; - case SBIG('VYTR'): - m_elem.reset(new struct REVectorYToReal); - break; - case SBIG('VZTR'): - m_elem.reset(new struct REVectorZToReal); - break; - case SBIG('CEXT'): - m_elem.reset(new struct RECEXT); - break; - case SBIG('ITRL'): - m_elem.reset(new struct REIntTimesReal); - break; - case SBIG('NONE'): - m_elem.reset(); - return; - default: - m_elem.reset(); - LogModule.report(logvisor::Fatal, fmt("Unknown RealElement class {} @{}"), clsId, r.position()); - return; - } - m_elem->read(r); -} - -template <> -void RealElementFactory::Enumerate(typename Write::StreamT& w) { - if (m_elem) { - w.writeBytes((atInt8*)m_elem->ClassID().data(), 4); - m_elem->write(w); - } else - w.writeBytes((atInt8*)"NONE", 4); -} - -template <> -void IntElementFactory::Enumerate(typename ReadYaml::StreamT& r) { - const auto& mapChildren = r.getCurNode()->m_mapChildren; - if (mapChildren.empty()) { - m_elem.reset(); - return; - } - - const auto& elem = mapChildren[0]; - if (elem.first.size() < 4) - LogModule.report(logvisor::Fatal, fmt("short FourCC in element '{}'"), elem.first); - - switch (*reinterpret_cast(elem.first.data())) { - case SBIG('KEYE'): - case SBIG('KEYP'): - m_elem.reset(new struct IEKeyframeEmitter); - break; - case SBIG('DETH'): - m_elem.reset(new struct IEDeath); - break; - case SBIG('CLMP'): - m_elem.reset(new struct IEClamp); - break; - case SBIG('CHAN'): - m_elem.reset(new struct IETimeChain); - break; - case SBIG('ADD_'): - m_elem.reset(new struct IEAdd); - break; - case SBIG('CNST'): - m_elem.reset(new struct IEConstant); - break; - case SBIG('IMPL'): - m_elem.reset(new struct IEImpulse); - break; - case SBIG('ILPT'): - m_elem.reset(new struct IELifetimePercent); - break; - case SBIG('IRND'): - m_elem.reset(new struct IEInitialRandom); - break; - case SBIG('PULS'): - m_elem.reset(new struct IEPulse); - break; - case SBIG('MULT'): - m_elem.reset(new struct IEMultiply); - break; - case SBIG('SPAH'): - m_elem.reset(new struct IESampleAndHold); - break; - case SBIG('RAND'): - m_elem.reset(new struct IERandom); - break; - case SBIG('TSCL'): - m_elem.reset(new struct IETimeScale); - break; - case SBIG('GTCP'): - m_elem.reset(new struct IEGTCP); - break; - case SBIG('MODU'): - m_elem.reset(new struct IEModulo); - break; - case SBIG('SUB_'): - m_elem.reset(new struct IESubtract); - break; - default: - m_elem.reset(); - return; - } - if (auto rec = r.enterSubRecord(elem.first.c_str())) - m_elem->read(r); -} - -template <> -void IntElementFactory::Enumerate(typename WriteYaml::StreamT& w) { - if (m_elem) - if (auto rec = w.enterSubRecord(m_elem->ClassID())) - m_elem->write(w); -} - -template <> -void IntElementFactory::Enumerate(typename BinarySize::StreamT& s) { - s += 4; - if (m_elem) - m_elem->binarySize(s); -} - -template <> -void IntElementFactory::Enumerate(typename Read::StreamT& r) { - DNAFourCC clsId; - clsId.read(r); - switch (clsId.toUint32()) { - case SBIG('KEYE'): - case SBIG('KEYP'): - m_elem.reset(new struct IEKeyframeEmitter); - break; - case SBIG('DETH'): - m_elem.reset(new struct IEDeath); - break; - case SBIG('CLMP'): - m_elem.reset(new struct IEClamp); - break; - case SBIG('CHAN'): - m_elem.reset(new struct IETimeChain); - break; - case SBIG('ADD_'): - m_elem.reset(new struct IEAdd); - break; - case SBIG('CNST'): - m_elem.reset(new struct IEConstant); - break; - case SBIG('IMPL'): - m_elem.reset(new struct IEImpulse); - break; - case SBIG('ILPT'): - m_elem.reset(new struct IELifetimePercent); - break; - case SBIG('IRND'): - m_elem.reset(new struct IEInitialRandom); - break; - case SBIG('PULS'): - m_elem.reset(new struct IEPulse); - break; - case SBIG('MULT'): - m_elem.reset(new struct IEMultiply); - break; - case SBIG('SPAH'): - m_elem.reset(new struct IESampleAndHold); - break; - case SBIG('RAND'): - m_elem.reset(new struct IERandom); - break; - case SBIG('TSCL'): - m_elem.reset(new struct IETimeScale); - break; - case SBIG('GTCP'): - m_elem.reset(new struct IEGTCP); - break; - case SBIG('MODU'): - m_elem.reset(new struct IEModulo); - break; - case SBIG('SUB_'): - m_elem.reset(new struct IESubtract); - break; - case SBIG('NONE'): - m_elem.reset(); - return; - default: - m_elem.reset(); - LogModule.report(logvisor::Fatal, fmt("Unknown IntElement class {} @{}"), clsId, r.position()); - return; - } - m_elem->read(r); -} - -template <> -void IntElementFactory::Enumerate(typename Write::StreamT& w) { - if (m_elem) { - w.writeBytes((atInt8*)m_elem->ClassID().data(), 4); - m_elem->write(w); - } else - w.writeBytes((atInt8*)"NONE", 4); -} - -template <> -void VectorElementFactory::Enumerate(typename ReadYaml::StreamT& r) { - const auto& mapChildren = r.getCurNode()->m_mapChildren; - if (mapChildren.empty()) { - m_elem.reset(); - return; - } - - const auto& elem = mapChildren[0]; - if (elem.first.size() < 4) - LogModule.report(logvisor::Fatal, fmt("short FourCC in element '{}'"), elem.first); - - switch (*reinterpret_cast(elem.first.data())) { - case SBIG('CONE'): - m_elem.reset(new struct VECone); - break; - case SBIG('CHAN'): - m_elem.reset(new struct VETimeChain); - break; - case SBIG('ANGC'): - m_elem.reset(new struct VEAngleCone); - break; - case SBIG('ADD_'): - m_elem.reset(new struct VEAdd); - break; - case SBIG('CCLU'): - m_elem.reset(new struct VECircleCluster); - break; - case SBIG('CNST'): - m_elem.reset(new struct VEConstant); - break; - case SBIG('CIRC'): - m_elem.reset(new struct VECircle); - break; - case SBIG('KEYE'): - case SBIG('KEYP'): - m_elem.reset(new struct VEKeyframeEmitter); - break; - case SBIG('MULT'): - m_elem.reset(new struct VEMultiply); - break; - case SBIG('RTOV'): - m_elem.reset(new struct VERealToVector); - break; - case SBIG('PULS'): - m_elem.reset(new struct VEPulse); - break; - case SBIG('PVEL'): - m_elem.reset(new struct VEParticleVelocity); - break; - case SBIG('SPOS'): - m_elem.reset(new struct VESPOS); - break; - case SBIG('PLCO'): - m_elem.reset(new struct VEPLCO); - break; - case SBIG('PLOC'): - m_elem.reset(new struct VEPLOC); - break; - case SBIG('PSOR'): - m_elem.reset(new struct VEPSOR); - break; - case SBIG('PSOF'): - m_elem.reset(new struct VEPSOF); - break; - default: - m_elem.reset(); - return; - } - if (auto rec = r.enterSubRecord(elem.first.c_str())) - m_elem->read(r); -} - -template <> -void VectorElementFactory::Enumerate(typename WriteYaml::StreamT& w) { - if (m_elem) - if (auto rec = w.enterSubRecord(m_elem->ClassID())) - m_elem->write(w); -} - -template <> -void VectorElementFactory::Enumerate(typename BinarySize::StreamT& s) { - s += 4; - if (m_elem) - m_elem->binarySize(s); -} - -template <> -void VectorElementFactory::Enumerate(typename Read::StreamT& r) { - DNAFourCC clsId; - clsId.read(r); - switch (clsId.toUint32()) { - case SBIG('CONE'): - m_elem.reset(new struct VECone); - break; - case SBIG('CHAN'): - m_elem.reset(new struct VETimeChain); - break; - case SBIG('ANGC'): - m_elem.reset(new struct VEAngleCone); - break; - case SBIG('ADD_'): - m_elem.reset(new struct VEAdd); - break; - case SBIG('CCLU'): - m_elem.reset(new struct VECircleCluster); - break; - case SBIG('CNST'): - m_elem.reset(new struct VEConstant); - break; - case SBIG('CIRC'): - m_elem.reset(new struct VECircle); - break; - case SBIG('KEYE'): - case SBIG('KEYP'): - m_elem.reset(new struct VEKeyframeEmitter); - break; - case SBIG('MULT'): - m_elem.reset(new struct VEMultiply); - break; - case SBIG('RTOV'): - m_elem.reset(new struct VERealToVector); - break; - case SBIG('PULS'): - m_elem.reset(new struct VEPulse); - break; - case SBIG('PVEL'): - m_elem.reset(new struct VEParticleVelocity); - break; - case SBIG('SPOS'): - m_elem.reset(new struct VESPOS); - break; - case SBIG('PLCO'): - m_elem.reset(new struct VEPLCO); - break; - case SBIG('PLOC'): - m_elem.reset(new struct VEPLOC); - break; - case SBIG('PSOR'): - m_elem.reset(new struct VEPSOR); - break; - case SBIG('PSOF'): - m_elem.reset(new struct VEPSOF); - break; - case SBIG('NONE'): - m_elem.reset(); - return; - default: - m_elem.reset(); - LogModule.report(logvisor::Fatal, fmt("Unknown VectorElement class {} @{}"), clsId, r.position()); - return; - } - m_elem->read(r); -} - -template <> -void VectorElementFactory::Enumerate(typename Write::StreamT& w) { - if (m_elem) { - w.writeBytes((atInt8*)m_elem->ClassID().data(), 4); - m_elem->write(w); - } else - w.writeBytes((atInt8*)"NONE", 4); -} - -template <> -void ColorElementFactory::Enumerate(typename ReadYaml::StreamT& r) { - const auto& mapChildren = r.getCurNode()->m_mapChildren; - if (mapChildren.empty()) { - m_elem.reset(); - return; - } - - const auto& elem = mapChildren[0]; - if (elem.first.size() < 4) - LogModule.report(logvisor::Fatal, fmt("short FourCC in element '{}'"), elem.first); - - switch (*reinterpret_cast(elem.first.data())) { - case SBIG('KEYE'): - case SBIG('KEYP'): - m_elem.reset(new struct CEKeyframeEmitter); - break; - case SBIG('CNST'): - m_elem.reset(new struct CEConstant); - break; - case SBIG('CHAN'): - m_elem.reset(new struct CETimeChain); - break; - case SBIG('CFDE'): - m_elem.reset(new struct CEFadeEnd); - break; - case SBIG('FADE'): - m_elem.reset(new struct CEFade); - break; - case SBIG('PULS'): - m_elem.reset(new struct CEPulse); - break; - default: - m_elem.reset(); - return; - } - if (auto rec = r.enterSubRecord(elem.first.c_str())) - m_elem->read(r); -} - -template <> -void ColorElementFactory::Enumerate(typename WriteYaml::StreamT& w) { - if (m_elem) - if (auto rec = w.enterSubRecord(m_elem->ClassID())) - m_elem->write(w); -} - -template <> -void ColorElementFactory::Enumerate(typename BinarySize::StreamT& s) { - s += 4; - if (m_elem) - m_elem->binarySize(s); -} - -template <> -void ColorElementFactory::Enumerate(typename Read::StreamT& r) { - DNAFourCC clsId; - clsId.read(r); - switch (clsId.toUint32()) { - case SBIG('KEYE'): - case SBIG('KEYP'): - m_elem.reset(new struct CEKeyframeEmitter); - break; - case SBIG('CNST'): - m_elem.reset(new struct CEConstant); - break; - case SBIG('CHAN'): - m_elem.reset(new struct CETimeChain); - break; - case SBIG('CFDE'): - m_elem.reset(new struct CEFadeEnd); - break; - case SBIG('FADE'): - m_elem.reset(new struct CEFade); - break; - case SBIG('PULS'): - m_elem.reset(new struct CEPulse); - break; - case SBIG('NONE'): - m_elem.reset(); - return; - default: - m_elem.reset(); - LogModule.report(logvisor::Fatal, fmt("Unknown ColorElement class {} @{}"), clsId, r.position()); - return; - } - m_elem->read(r); -} - -template <> -void ColorElementFactory::Enumerate(typename Write::StreamT& w) { - if (m_elem) { - w.writeBytes((atInt8*)m_elem->ClassID().data(), 4); - m_elem->write(w); - } else - w.writeBytes((atInt8*)"NONE", 4); -} - -template <> -void ModVectorElementFactory::Enumerate(typename ReadYaml::StreamT& r) { - const auto& mapChildren = r.getCurNode()->m_mapChildren; - if (mapChildren.empty()) { - m_elem.reset(); - return; - } - - const auto& elem = mapChildren[0]; - if (elem.first.size() < 4) - LogModule.report(logvisor::Fatal, fmt("short FourCC in element '{}'"), elem.first); - - switch (*reinterpret_cast(elem.first.data())) { - case SBIG('IMPL'): - m_elem.reset(new struct MVEImplosion); - break; - case SBIG('EMPL'): - m_elem.reset(new struct MVEExponentialImplosion); - break; - case SBIG('CHAN'): - m_elem.reset(new struct MVETimeChain); - break; - case SBIG('BNCE'): - m_elem.reset(new struct MVEBounce); - break; - case SBIG('CNST'): - m_elem.reset(new struct MVEConstant); - break; - case SBIG('GRAV'): - m_elem.reset(new struct MVEGravity); - break; - case SBIG('EXPL'): - m_elem.reset(new struct MVEExplode); - break; - case SBIG('SPOS'): - m_elem.reset(new struct MVESetPosition); - break; - case SBIG('LMPL'): - m_elem.reset(new struct MVELinearImplosion); - break; - case SBIG('PULS'): - m_elem.reset(new struct MVEPulse); - break; - case SBIG('WIND'): - m_elem.reset(new struct MVEWind); - break; - case SBIG('SWRL'): - m_elem.reset(new struct MVESwirl); - break; - default: - m_elem.reset(); - return; - } - if (auto rec = r.enterSubRecord(elem.first.c_str())) - m_elem->read(r); -} - -template <> -void ModVectorElementFactory::Enumerate(typename WriteYaml::StreamT& w) { - if (m_elem) - if (auto rec = w.enterSubRecord(m_elem->ClassID())) - m_elem->write(w); -} - -template <> -void ModVectorElementFactory::Enumerate(typename BinarySize::StreamT& s) { - s += 4; - if (m_elem) - m_elem->binarySize(s); -} - -template <> -void ModVectorElementFactory::Enumerate(typename Read::StreamT& r) { - DNAFourCC clsId; - clsId.read(r); - switch (clsId.toUint32()) { - case SBIG('IMPL'): - m_elem.reset(new struct MVEImplosion); - break; - case SBIG('EMPL'): - m_elem.reset(new struct MVEExponentialImplosion); - break; - case SBIG('CHAN'): - m_elem.reset(new struct MVETimeChain); - break; - case SBIG('BNCE'): - m_elem.reset(new struct MVEBounce); - break; - case SBIG('CNST'): - m_elem.reset(new struct MVEConstant); - break; - case SBIG('GRAV'): - m_elem.reset(new struct MVEGravity); - break; - case SBIG('EXPL'): - m_elem.reset(new struct MVEExplode); - break; - case SBIG('SPOS'): - m_elem.reset(new struct MVESetPosition); - break; - case SBIG('LMPL'): - m_elem.reset(new struct MVELinearImplosion); - break; - case SBIG('PULS'): - m_elem.reset(new struct MVEPulse); - break; - case SBIG('WIND'): - m_elem.reset(new struct MVEWind); - break; - case SBIG('SWRL'): - m_elem.reset(new struct MVESwirl); - break; - case SBIG('NONE'): - m_elem.reset(); - return; - default: - m_elem.reset(); - LogModule.report(logvisor::Fatal, fmt("Unknown ModVectorElement class {} @{}"), clsId, r.position()); - return; - } - m_elem->read(r); -} - -template <> -void ModVectorElementFactory::Enumerate(typename Write::StreamT& w) { - if (m_elem) { - w.writeBytes((atInt8*)m_elem->ClassID().data(), 4); - m_elem->write(w); - } else - w.writeBytes((atInt8*)"NONE", 4); -} - -template <> -void EmitterElementFactory::Enumerate(typename ReadYaml::StreamT& r) { - const auto& mapChildren = r.getCurNode()->m_mapChildren; - if (mapChildren.empty()) { - m_elem.reset(); - return; - } - - const auto& elem = mapChildren[0]; - if (elem.first.size() < 4) - LogModule.report(logvisor::Fatal, fmt("short FourCC in element '{}'"), elem.first); - - switch (*reinterpret_cast(elem.first.data())) { - case SBIG('SETR'): - m_elem.reset(new struct EESimpleEmitterTR); - break; - case SBIG('SEMR'): - m_elem.reset(new struct EESimpleEmitter); - break; - case SBIG('SPHE'): - m_elem.reset(new struct VESphere); - break; - case SBIG('ASPH'): - m_elem.reset(new struct VEAngleSphere); - break; - default: - m_elem.reset(); - return; - } - if (auto rec = r.enterSubRecord(elem.first.c_str())) - m_elem->read(r); -} - -template <> -void EmitterElementFactory::Enumerate(typename WriteYaml::StreamT& w) { - if (m_elem) - if (auto rec = w.enterSubRecord(m_elem->ClassID())) - m_elem->write(w); -} - -template <> -void EmitterElementFactory::Enumerate(typename BinarySize::StreamT& s) { - s += 4; - if (m_elem) - m_elem->binarySize(s); -} - -template <> -void EmitterElementFactory::Enumerate(typename Read::StreamT& r) { - DNAFourCC clsId; - clsId.read(r); - switch (clsId.toUint32()) { - case SBIG('SETR'): - m_elem.reset(new struct EESimpleEmitterTR); - break; - case SBIG('SEMR'): - m_elem.reset(new struct EESimpleEmitter); - break; - case SBIG('SPHE'): - m_elem.reset(new struct VESphere); - break; - case SBIG('ASPH'): - m_elem.reset(new struct VEAngleSphere); - break; - case SBIG('NONE'): - m_elem.reset(); - return; - default: - m_elem.reset(); - LogModule.report(logvisor::Fatal, fmt("Unknown EmitterElement class {} @{}"), clsId, r.position()); - return; - } - m_elem->read(r); -} - -template <> -void EmitterElementFactory::Enumerate(typename Write::StreamT& w) { - if (m_elem) { - w.writeBytes((atInt8*)m_elem->ClassID().data(), 4); - m_elem->write(w); - } else - w.writeBytes((atInt8*)"NONE", 4); -} - template <> void BoolHelper::Enumerate(typename ReadYaml::StreamT& r) { value = r.readBool(); @@ -1073,14 +189,20 @@ void BoolHelper::Enumerate(typename Read::StreamT& r) { } template <> void BoolHelper::Enumerate(typename Write::StreamT& w) { - w.writeBytes((atInt8*)"CNST", 4); + w.writeBytes("CNST", 4); w.writeBool(value); } +template struct ValueHelper; +template struct ValueHelper; + +AT_SUBSPECIALIZE_DNA_YAML(ValueHelper) +AT_SUBSPECIALIZE_DNA_YAML(ValueHelper) + template <> void EESimpleEmitterTR::Enumerate(typename ReadYaml::StreamT& r) { - position.m_elem.reset(); - velocity.m_elem.reset(); + position.reset(); + velocity.reset(); if (auto rec = r.enterSubRecord("ILOC")) position.read(r); if (auto rec = r.enterSubRecord("IVEC")) @@ -1101,8 +223,8 @@ void EESimpleEmitterTR::Enumerate(typename BinarySize::Strea } template <> void EESimpleEmitterTR::Enumerate(typename Read::StreamT& r) { - position.m_elem.reset(); - velocity.m_elem.reset(); + position.reset(); + velocity.reset(); uint32_t clsId; r.readBytesToBuf(&clsId, 4); if (clsId == SBIG('ILOC')) { @@ -1114,9 +236,9 @@ void EESimpleEmitterTR::Enumerate(typename Read::StreamT& r) { } template <> void EESimpleEmitterTR::Enumerate(typename Write::StreamT& w) { - w.writeBytes((atInt8*)"ILOC", 4); + w.writeBytes("ILOC", 4); position.write(w); - w.writeBytes((atInt8*)"IVEC", 4); + w.writeBytes("IVEC", 4); velocity.write(w); } @@ -1155,7 +277,7 @@ void UVEConstant::_read(typename Read::StreamT& r) { } template void UVEConstant::_write(typename Write::StreamT& w) const { - w.writeBytes((atInt8*)"CNST", 4); + w.writeBytes("CNST", 4); tex.write(w); } @@ -1236,14 +358,14 @@ void UVEAnimTexture::_read(typename Read::StreamT& r) { } template void UVEAnimTexture::_write(typename Write::StreamT& w) const { - w.writeBytes((atInt8*)"CNST", 4); + w.writeBytes("CNST", 4); tex.write(w); tileW.write(w); tileH.write(w); strideW.write(w); strideH.write(w); cycleFrames.write(w); - w.writeBytes((atInt8*)"CNST", 4); + w.writeBytes("CNST", 4); w.writeBool(loop); } @@ -1262,61 +384,6 @@ std::string_view UVElementFactory::DNAType() { return "UVElementFactory"sv; } -template -void UVElementFactory::_read(typename Read::StreamT& r) { - uint32_t clsId; - r.readBytesToBuf(&clsId, 4); - switch (clsId) { - case SBIG('CNST'): - m_elem.reset(new struct UVEConstant); - break; - case SBIG('ATEX'): - m_elem.reset(new struct UVEAnimTexture); - break; - default: - m_elem.reset(); - return; - } - m_elem->read(r); -} -template -void UVElementFactory::_write(typename Write::StreamT& w) const { - if (m_elem) { - w.writeBytes((atInt8*)m_elem->ClassID().data(), 4); - m_elem->write(w); - } else - w.writeBytes((atInt8*)"NONE", 4); -} -template -void UVElementFactory::_read(typename ReadYaml::StreamT& r) { - if (auto rec = r.enterSubRecord("CNST")) { - m_elem.reset(new struct UVEConstant); - m_elem->read(r); - } else if (auto rec = r.enterSubRecord("ATEX")) { - m_elem.reset(new struct UVEAnimTexture); - m_elem->read(r); - } else - m_elem.reset(); -} -template -void UVElementFactory::_write(typename WriteYaml::StreamT& w) const { - if (m_elem) - if (auto rec = w.enterSubRecord(m_elem->ClassID())) - m_elem->write(w); -} -template -void UVElementFactory::_binarySize(typename BinarySize::StreamT& _s) const { - if (m_elem) - m_elem->binarySize(_s); - _s += 4; -} - -AT_SUBSPECIALIZE_DNA_YAML(UVElementFactory) -AT_SUBSPECIALIZE_DNA_YAML(UVElementFactory) - -template struct UVElementFactory; -template struct UVElementFactory; - template <> std::string_view SpawnSystemKeyframeData::SpawnSystemKeyframeInfo::DNAType() { return "SpawnSystemKeyframeData::SpawnSystemKeyframeInfo"sv; @@ -1439,10 +506,10 @@ void SpawnSystemKeyframeData::_read(typename Read::StreamT& r) { template void SpawnSystemKeyframeData::_write(typename Write::StreamT& w) const { if (spawns.empty()) { - w.writeBytes((atInt8*)"NONE", 4); + w.writeBytes("NONE", 4); return; } - w.writeBytes((atInt8*)"CNST", 4); + w.writeBytes("CNST", 4); w.writeUint32Big(a); w.writeUint32Big(b); w.writeUint32Big(endFrame); @@ -1504,10 +571,10 @@ void ChildResourceFactory::_read(typename Read::StreamT& r) { template void ChildResourceFactory::_write(typename Write::StreamT& w) const { if (id.isValid()) { - w.writeBytes((atInt8*)"CNST", 4); + w.writeBytes("CNST", 4); id.write(w); } else - w.writeBytes((atInt8*)"NONE", 4); + w.writeBytes("NONE", 4); } AT_SUBSPECIALIZE_DNA_YAML(ChildResourceFactory) diff --git a/DataSpec/DNACommon/ParticleCommon.hpp b/DataSpec/DNACommon/ParticleCommon.hpp index 803a02f41..159cc85fd 100644 --- a/DataSpec/DNACommon/ParticleCommon.hpp +++ b/DataSpec/DNACommon/ParticleCommon.hpp @@ -10,6 +10,257 @@ namespace DataSpec::DNAParticle { extern logvisor::Module LogModule; +enum class ParticleType { + GPSM = SBIG('GPSM'), + SWSH = SBIG('SWSH'), + ELSM = SBIG('ELSM'), + DPSM = SBIG('DPSM'), + CRSM = SBIG('CRSM'), + WPSM = SBIG('WPSM') +}; + +/* + * The particle property (PP) metaclass system provides common compile-time utilities + * for storing, enumerating, and streaming particle scripts. + */ + +template +struct PPImpl : BigDNA, _Basis { + AT_DECL_EXPLICIT_DNA_YAML + + template + static constexpr bool _shouldStore(T& p, bool defaultBool) { + if constexpr (std::is_same_v) { + return p != defaultBool; + } else if constexpr (std::is_same_v) { + return p != 0xffffffff; + } else if constexpr (std::is_same_v) { + return true; + } else { + return p.operator bool(); + } + } + + constexpr void _read(athena::io::IStreamReader& r) { + constexpr FourCC RefType = uint32_t(_Basis::Type); + DNAFourCC clsId(r); + if (clsId != RefType) { + LogModule.report(logvisor::Warning, fmt("non {} provided to {} parser"), RefType, RefType); + return; + } + clsId.read(r); + while (clsId != SBIG('_END')) { + if (!_Basis::Lookup(clsId, [&](auto& p) { + using Tp = std::decay_t; + if constexpr (std::is_same_v) { + DNAFourCC tp(r); + if (tp == SBIG('CNST')) + p = r.readBool(); + } else if constexpr (std::is_same_v) { + DNAFourCC tp(r); + if (tp == SBIG('CNST')) + p = r.readUint32Big(); + } else if constexpr (std::is_same_v) { + DNAFourCC tp(r); + if (tp == SBIG('CNST')) + p = r.readFloatBig(); + } else { + p.read(r); + } + })) { + LogModule.report(logvisor::Fatal, fmt("Unknown {} class {} @{}"), RefType, clsId, r.position()); + } + clsId.read(r); + } + } + + constexpr void _write(athena::io::IStreamWriter& w) { + constexpr DNAFourCC RefType = uint32_t(_Basis::Type); + RefType.write(w); + _Basis::Enumerate([&](FourCC fcc, auto& p, bool defaultBool = false) { + if (_shouldStore(p, defaultBool)) { + using Tp = std::decay_t; + DNAFourCC(fcc).write(w); + if constexpr (std::is_same_v) { + w.writeBytes("CNST", 4); + w.writeBool(p); + } else if constexpr (std::is_same_v) { + w.writeBytes("CNST", 4); + w.writeUint32Big(p); + } else if constexpr (std::is_same_v) { + w.writeBytes("CNST", 4); + w.writeFloatBig(p); + } else { + p.write(w); + } + } + }); + w.writeBytes("_END", 4); + } + + constexpr void _binarySize(std::size_t& s) { + constexpr DNAFourCC RefType = uint32_t(_Basis::Type); + RefType.binarySize(s); + _Basis::Enumerate([&](FourCC fcc, auto& p, bool defaultBool = false) { + if (_shouldStore(p, defaultBool)) { + using Tp = std::decay_t; + DNAFourCC(fcc).binarySize(s); + if constexpr (std::is_same_v) { + s += 5; + } else if constexpr (std::is_same_v || std::is_same_v) { + s += 8; + } else { + p.binarySize(s); + } + } + }); + s += 4; + } + + void _read(athena::io::YAMLDocReader& r) { + constexpr DNAFourCC RefType = uint32_t(_Basis::Type); + + for (const auto& [key, value] : r.getCurNode()->m_mapChildren) { + if (key == "DNAType"sv) + continue; + if (key.size() < 4) { + LogModule.report(logvisor::Warning, fmt("short FourCC in element '{}'"), key); + continue; + } + + if (auto rec = r.enterSubRecord(key)) { + const DNAFourCC clsId = key.c_str(); + if (!_Basis::Lookup(clsId, [&](auto& p) { + using Tp = std::decay_t; + if constexpr (std::is_same_v) { + p = r.readBool(); + } else if constexpr (std::is_same_v) { + p = r.readUint32(); + } else if constexpr (std::is_same_v) { + p = r.readFloat(); + } else { + p.read(r); + } + })) { + LogModule.report(logvisor::Fatal, fmt("Unknown {} class {}"), RefType, clsId); + } + } + } + } + + constexpr void _write(athena::io::YAMLDocWriter& w) { + _Basis::Enumerate([&](FourCC fcc, auto& p, bool defaultBool = false) { + if (_shouldStore(p, defaultBool)) { + using Tp = std::decay_t; + if (auto rec = w.enterSubRecord(fcc.toStringView())) { + if constexpr (std::is_same_v) { + w.writeBool(p); + } else if constexpr (std::is_same_v) { + w.writeUint32(p); + } else if constexpr (std::is_same_v) { + w.writeFloat(p); + } else { + p.write(w); + } + } + } + }); + } + + constexpr void gatherDependencies(std::vector& deps) { + _Basis::Enumerate([&](FourCC fcc, auto& p, bool defaultBool = false) { + using Tp = std::decay_t; + if constexpr (!std::is_same_v && !std::is_same_v && !std::is_same_v) + p.gatherDependencies(deps); + }); + } + + constexpr void gatherDependencies(std::vector& deps) const { + const_cast(*this).gatherDependencies(deps); + } +}; + +template +struct PEType { + using Type = _Type; +}; + +template +struct PEImpl : BigDNA { + AT_DECL_EXPLICIT_DNA_YAML + using _PtrType = typename _Basis::PtrType; + + void _read(athena::io::IStreamReader& r) { + DNAFourCC clsId(r); + if (clsId == FOURCC('NONE')) { + m_elem.reset(); + return; + } + if (!_Basis::Lookup(clsId, [&](auto&& p) { + using Tp = std::decay_t; + m_elem = std::make_unique(); + m_elem->read(r); + })) { + LogModule.report(logvisor::Fatal, fmt("Unknown {} class {} @{}"), _PtrType::TypeName, clsId, r.position()); + } + } + + void _write(athena::io::IStreamWriter& w) { + if (m_elem) { + w.writeBytes(m_elem->ClassID().data(), 4); + m_elem->write(w); + } else { + w.writeBytes("NONE", 4); + } + } + + void _binarySize(std::size_t& s) { + if (m_elem) + m_elem->binarySize(s); + s += 4; + } + + void _read(athena::io::YAMLDocReader& r) { + const auto& mapChildren = r.getCurNode()->m_mapChildren; + if (mapChildren.empty()) { + m_elem.reset(); + return; + } + + const auto& [key, value] = mapChildren[0]; + if (key.size() < 4) + LogModule.report(logvisor::Fatal, fmt("short FourCC in element '{}'"), key); + + if (auto rec = r.enterSubRecord(key)) { + const DNAFourCC clsId = key.c_str(); + if (!_Basis::Lookup(clsId, [&](auto&& p) { + using Tp = std::decay_t; + m_elem = std::make_unique(); + m_elem->read(r); + })) { + LogModule.report(logvisor::Fatal, fmt("Unknown {} class {}"), _PtrType::TypeName, clsId); + } + } + } + + void _write(athena::io::YAMLDocWriter& w) { + if (m_elem) + if (auto rec = w.enterSubRecord(m_elem->ClassID())) + m_elem->write(w); + } + + void gatherDependencies(std::vector& deps) const { + _Basis::gatherDependencies(deps, m_elem); + } + + operator bool() const { return m_elem.operator bool(); } + auto* get() const { return m_elem.get(); } + auto* operator->() const { return get(); } + void reset() { m_elem.reset(); } +private: + std::unique_ptr<_PtrType> m_elem; +}; + struct IElement : BigDNAVYaml { Delete _d; ~IElement() override = default; @@ -19,61 +270,296 @@ struct IElement : BigDNAVYaml { struct IRealElement : IElement { Delete _d2; + static constexpr std::string_view TypeName = "RealElement"sv; }; -struct RealElementFactory : BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - std::unique_ptr m_elem; - operator bool() const { return m_elem.operator bool(); } +struct RELifetimeTween; +struct REConstant; +struct RETimeChain; +struct REAdd; +struct REClamp; +struct REKeyframeEmitter; +struct REKeyframeEmitter; +struct REInitialRandom; +struct RERandom; +struct REMultiply; +struct REPulse; +struct RETimeScale; +struct RELifetimePercent; +struct RESineWave; +struct REInitialSwitch; +struct RECompareLessThan; +struct RECompareEquals; +struct REParticleAdvanceParam1; +struct REParticleAdvanceParam2; +struct REParticleAdvanceParam3; +struct REParticleAdvanceParam4; +struct REParticleAdvanceParam5; +struct REParticleAdvanceParam6; +struct REParticleAdvanceParam7; +struct REParticleAdvanceParam8; +struct REParticleSizeOrLineLength; +struct REParticleRotationOrLineWidth; +struct RESubtract; +struct REVectorMagnitude; +struct REVectorXToReal; +struct REVectorYToReal; +struct REVectorZToReal; +struct RECEXT; +struct REIntTimesReal; +struct _RealElementFactory { + using PtrType = IRealElement; + template + static bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { + case SBIG('LFTW'): f(PEType{}); return true; + case SBIG('CNST'): f(PEType{}); return true; + case SBIG('CHAN'): f(PEType{}); return true; + case SBIG('ADD_'): f(PEType{}); return true; + case SBIG('CLMP'): f(PEType{}); return true; + case SBIG('KEYE'): f(PEType{}); return true; + case SBIG('KEYP'): f(PEType{}); return true; + case SBIG('IRND'): f(PEType{}); return true; + case SBIG('RAND'): f(PEType{}); return true; + case SBIG('MULT'): f(PEType{}); return true; + case SBIG('PULS'): f(PEType{}); return true; + case SBIG('SCAL'): f(PEType{}); return true; + case SBIG('RLPT'): f(PEType{}); return true; + case SBIG('SINE'): f(PEType{}); return true; + case SBIG('ISWT'): f(PEType{}); return true; + case SBIG('CLTN'): f(PEType{}); return true; + case SBIG('CEQL'): f(PEType{}); return true; + case SBIG('PAP1'): f(PEType{}); return true; + case SBIG('PAP2'): f(PEType{}); return true; + case SBIG('PAP3'): f(PEType{}); return true; + case SBIG('PAP4'): f(PEType{}); return true; + case SBIG('PAP5'): f(PEType{}); return true; + case SBIG('PAP6'): f(PEType{}); return true; + case SBIG('PAP7'): f(PEType{}); return true; + case SBIG('PAP8'): f(PEType{}); return true; + case SBIG('PSLL'): f(PEType{}); return true; + case SBIG('PRLW'): f(PEType{}); return true; + case SBIG('SUB_'): f(PEType{}); return true; + case SBIG('VMAG'): f(PEType{}); return true; + case SBIG('VXTR'): f(PEType{}); return true; + case SBIG('VYTR'): f(PEType{}); return true; + case SBIG('VZTR'): f(PEType{}); return true; + case SBIG('CEXT'): f(PEType{}); return true; + case SBIG('ITRL'): f(PEType{}); return true; + default: return false; + } + } + static constexpr void gatherDependencies(std::vector& pathsOut, + const std::unique_ptr& elemPtr) {} }; +using RealElementFactory = PEImpl<_RealElementFactory>; struct IIntElement : IElement { Delete _d2; + static constexpr std::string_view TypeName = "IntElement"sv; }; -struct IntElementFactory : BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - std::unique_ptr m_elem; - operator bool() const { return m_elem.operator bool(); } +struct IEKeyframeEmitter; +struct IEKeyframeEmitter; +struct IEDeath; +struct IEClamp; +struct IETimeChain; +struct IEAdd; +struct IEConstant; +struct IEImpulse; +struct IELifetimePercent; +struct IEInitialRandom; +struct IEPulse; +struct IEMultiply; +struct IESampleAndHold; +struct IERandom; +struct IETimeScale; +struct IEGTCP; +struct IEModulo; +struct IESubtract; +struct _IntElementFactory { + using PtrType = IIntElement; + template + static bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { + case SBIG('KEYE'): f(PEType{}); return true; + case SBIG('KEYP'): f(PEType{}); return true; + case SBIG('DETH'): f(PEType{}); return true; + case SBIG('CLMP'): f(PEType{}); return true; + case SBIG('CHAN'): f(PEType{}); return true; + case SBIG('ADD_'): f(PEType{}); return true; + case SBIG('CNST'): f(PEType{}); return true; + case SBIG('IMPL'): f(PEType{}); return true; + case SBIG('ILPT'): f(PEType{}); return true; + case SBIG('IRND'): f(PEType{}); return true; + case SBIG('PULS'): f(PEType{}); return true; + case SBIG('MULT'): f(PEType{}); return true; + case SBIG('SPAH'): f(PEType{}); return true; + case SBIG('RAND'): f(PEType{}); return true; + case SBIG('TSCL'): f(PEType{}); return true; + case SBIG('GTCP'): f(PEType{}); return true; + case SBIG('MODU'): f(PEType{}); return true; + case SBIG('SUB_'): f(PEType{}); return true; + default: return false; + } + } + static constexpr void gatherDependencies(std::vector& pathsOut, + const std::unique_ptr& elemPtr) {} }; +using IntElementFactory = PEImpl<_IntElementFactory>; struct IVectorElement : IElement { Delete _d2; + static constexpr std::string_view TypeName = "VectorElement"sv; }; -struct VectorElementFactory : BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - std::unique_ptr m_elem; - operator bool() const { return m_elem.operator bool(); } +struct VECone; +struct VETimeChain; +struct VEAngleCone; +struct VEAdd; +struct VECircleCluster; +struct VEConstant; +struct VECircle; +struct VEKeyframeEmitter; +struct VEKeyframeEmitter; +struct VEMultiply; +struct VERealToVector; +struct VEPulse; +struct VEParticleVelocity; +struct VESPOS; +struct VEPLCO; +struct VEPLOC; +struct VEPSOR; +struct VEPSOF; +struct _VectorElementFactory { + using PtrType = IVectorElement; + template + static bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { + case SBIG('CONE'): f(PEType{}); return true; + case SBIG('CHAN'): f(PEType{}); return true; + case SBIG('ANGC'): f(PEType{}); return true; + case SBIG('ADD_'): f(PEType{}); return true; + case SBIG('CCLU'): f(PEType{}); return true; + case SBIG('CNST'): f(PEType{}); return true; + case SBIG('CIRC'): f(PEType{}); return true; + case SBIG('KEYE'): f(PEType{}); return true; + case SBIG('KEYP'): f(PEType{}); return true; + case SBIG('MULT'): f(PEType{}); return true; + case SBIG('RTOV'): f(PEType{}); return true; + case SBIG('PULS'): f(PEType{}); return true; + case SBIG('PVEL'): f(PEType{}); return true; + case SBIG('SPOS'): f(PEType{}); return true; + case SBIG('PLCO'): f(PEType{}); return true; + case SBIG('PLOC'): f(PEType{}); return true; + case SBIG('PSOR'): f(PEType{}); return true; + case SBIG('PSOF'): f(PEType{}); return true; + default: return false; + } + } + static constexpr void gatherDependencies(std::vector& pathsOut, + const std::unique_ptr& elemPtr) {} }; +using VectorElementFactory = PEImpl<_VectorElementFactory>; struct IColorElement : IElement { Delete _d2; + static constexpr std::string_view TypeName = "ColorElement"sv; }; -struct ColorElementFactory : BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - std::unique_ptr m_elem; - operator bool() const { return m_elem.operator bool(); } +struct CEKeyframeEmitter; +struct CEKeyframeEmitter; +struct CEConstant; +struct CETimeChain; +struct CEFadeEnd; +struct CEFade; +struct CEPulse; +struct _ColorElementFactory { + using PtrType = IColorElement; + template + static bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { + case SBIG('KEYE'): f(PEType{}); return true; + case SBIG('KEYP'): f(PEType{}); return true; + case SBIG('CNST'): f(PEType{}); return true; + case SBIG('CHAN'): f(PEType{}); return true; + case SBIG('CFDE'): f(PEType{}); return true; + case SBIG('FADE'): f(PEType{}); return true; + case SBIG('PULS'): f(PEType{}); return true; + default: return false; + } + } + static constexpr void gatherDependencies(std::vector& pathsOut, + const std::unique_ptr& elemPtr) {} }; +using ColorElementFactory = PEImpl<_ColorElementFactory>; struct IModVectorElement : IElement { Delete _d2; + static constexpr std::string_view TypeName = "ModVectorElement"sv; }; -struct ModVectorElementFactory : BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - std::unique_ptr m_elem; - operator bool() const { return m_elem.operator bool(); } +struct MVEImplosion; +struct MVEExponentialImplosion; +struct MVETimeChain; +struct MVEBounce; +struct MVEConstant; +struct MVEGravity; +struct MVEExplode; +struct MVESetPosition; +struct MVELinearImplosion; +struct MVEPulse; +struct MVEWind; +struct MVESwirl; +struct _ModVectorElementFactory { + using PtrType = IModVectorElement; + template + static bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { + case SBIG('IMPL'): f(PEType{}); return true; + case SBIG('EMPL'): f(PEType{}); return true; + case SBIG('CHAN'): f(PEType{}); return true; + case SBIG('BNCE'): f(PEType{}); return true; + case SBIG('CNST'): f(PEType{}); return true; + case SBIG('GRAV'): f(PEType{}); return true; + case SBIG('EXPL'): f(PEType{}); return true; + case SBIG('SPOS'): f(PEType{}); return true; + case SBIG('LMPL'): f(PEType{}); return true; + case SBIG('PULS'): f(PEType{}); return true; + case SBIG('WIND'): f(PEType{}); return true; + case SBIG('SWRL'): f(PEType{}); return true; + default: return false; + } + } + static constexpr void gatherDependencies(std::vector& pathsOut, + const std::unique_ptr& elemPtr) {} }; +using ModVectorElementFactory = PEImpl<_ModVectorElementFactory>; struct IEmitterElement : IElement { Delete _d2; + static constexpr std::string_view TypeName = "EmitterElement"sv; }; -struct EmitterElementFactory : BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - std::unique_ptr m_elem; - operator bool() const { return m_elem.operator bool(); } +struct EESimpleEmitterTR; +struct EESimpleEmitter; +struct VESphere; +struct VEAngleSphere; +struct _EmitterElementFactory { + using PtrType = IEmitterElement; + template + static bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { + case SBIG('SETR'): f(PEType{}); return true; + case SBIG('SEMR'): f(PEType{}); return true; + case SBIG('SPHE'): f(PEType{}); return true; + case SBIG('ASPH'): f(PEType{}); return true; + default: return false; + } + } + static constexpr void gatherDependencies(std::vector& pathsOut, + const std::unique_ptr& elemPtr) {} }; +using EmitterElementFactory = PEImpl<_EmitterElementFactory>; struct IUVElement : IElement { Delete _d2; virtual void gatherDependencies(std::vector& pathsOut) const = 0; + static constexpr std::string_view TypeName = "UVElement"sv; }; struct BoolHelper : IElement { @@ -87,6 +573,46 @@ struct BoolHelper : IElement { std::string_view ClassID() const override { return "BoolHelper"sv; } }; +template +struct ValueHelper : BigDNA { + AT_DECL_EXPLICIT_DNA_YAML + + void _read(athena::io::IStreamReader& r) { + hecl::DNAFourCC ValueType; + ValueType.read(r); + if (ValueType == FOURCC('CNST')) + athena::io::Read::Do({}, value.emplace(), r); + else + value = std::nullopt; + } + void _write(athena::io::IStreamWriter& w) { + if (value) { + w.writeBytes("CNST", 4); + athena::io::Write::Do({}, *value, w); + } else { + w.writeBytes("NONE", 4); + } + } + void _binarySize(std::size_t& s) { + s += 4; + if (value) + athena::io::BinarySize::Do({}, *value, s); + } + void _read(athena::io::YAMLDocReader& r) { + athena::io::ReadYaml::Do({}, value.emplace(), r); + } + void _write(athena::io::YAMLDocWriter& w) { + athena::io::WriteYaml::Do({}, *value, w); + } + + static constexpr void gatherDependencies(std::vector& pathsOut) {} + + std::optional value = {}; + void emplace(Tp val) { value.emplace(val); } + Tp operator*() const { return *value; } + operator bool() const { return value.operator bool(); } +}; + struct RELifetimeTween : IRealElement { AT_DECL_DNA_YAMLV_NO_TYPE RealElementFactory a; @@ -743,7 +1269,8 @@ struct UVEConstant : IUVElement { std::string_view ClassID() const override { return "CNST"sv; } void gatherDependencies(std::vector& pathsOut) const override { - g_curSpec->flattenDependencies(tex, pathsOut); + if (tex.isValid()) + g_curSpec->flattenDependencies(tex, pathsOut); } }; @@ -761,18 +1288,30 @@ struct UVEAnimTexture : IUVElement { std::string_view ClassID() const override { return "ATEX"sv; } void gatherDependencies(std::vector& pathsOut) const override { - g_curSpec->flattenDependencies(tex, pathsOut); + if (tex.isValid()) + g_curSpec->flattenDependencies(tex, pathsOut); } }; template -struct UVElementFactory : BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - AT_SUBDECL_DNA - DNAFourCC m_type; - std::unique_ptr m_elem; - operator bool() const { return m_elem.operator bool(); } +struct _UVElementFactory { + using PtrType = IUVElement; + template + static bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { + case SBIG('CNST'): f(PEType>{}); return true; + case SBIG('ATEX'): f(PEType>{}); return true; + default: return false; + } + } + static constexpr void gatherDependencies(std::vector& pathsOut, + const std::unique_ptr& elemPtr) { + if (elemPtr) + elemPtr->gatherDependencies(pathsOut); + } }; +template +using UVElementFactory = PEImpl<_UVElementFactory>; template struct SpawnSystemKeyframeData : BigDNA { @@ -809,6 +1348,10 @@ struct ChildResourceFactory : BigDNA { AT_DECL_EXPLICIT_DNA_YAML AT_SUBDECL_DNA operator bool() const { return id.isValid(); } + void gatherDependencies(std::vector& pathsOut) const { + if (id.isValid()) + g_curSpec->flattenDependencies(id, pathsOut); + } }; } // namespace DataSpec::DNAParticle diff --git a/DataSpec/DNACommon/SWHC.cpp b/DataSpec/DNACommon/SWHC.cpp index 3ff2b8ebd..404de21af 100644 --- a/DataSpec/DNACommon/SWHC.cpp +++ b/DataSpec/DNACommon/SWHC.cpp @@ -1,11 +1,14 @@ #include "DataSpec/DNACommon/SWHC.hpp" - #include "DataSpec/DNACommon/PAK.hpp" -#include - namespace DataSpec::DNAParticle { +template struct PPImpl<_SWSH>; +template struct PPImpl<_SWSH>; + +AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_SWSH>) +AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_SWSH>) + template <> std::string_view SWSH::DNAType() { return "SWSH"sv; @@ -16,504 +19,6 @@ std::string_view SWSH::DNAType() { return "SWSH"sv; } -template -void SWSH::_read(typename BigDNA::ReadYaml::StreamT& r) { - for (const auto& elem : r.getCurNode()->m_mapChildren) { - if (elem.first.size() < 4) { - LogModule.report(logvisor::Warning, fmt("short FourCC in element '{}'"), elem.first); - continue; - } - - if (auto rec = r.enterSubRecord(elem.first.c_str())) { - 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(); - break; - case SBIG('CROS'): - x44_25_CROS = r.readBool(); - break; - case SBIG('VLS1'): - x44_26_VLS1 = r.readBool(); - break; - case SBIG('VLS2'): - x44_27_VLS2 = r.readBool(); - break; - case SBIG('SROT'): - x44_28_SROT = r.readBool(); - break; - case SBIG('WIRE'): - x44_29_WIRE = r.readBool(); - break; - case SBIG('TEXW'): - x44_30_TEXW = r.readBool(); - break; - case SBIG('AALP'): - x44_31_AALP = r.readBool(); - break; - case SBIG('ZBUF'): - x45_24_ZBUF = r.readBool(); - break; - case SBIG('ORNT'): - x45_25_ORNT = r.readBool(); - break; - case SBIG('CRND'): - x45_26_CRND = r.readBool(); - break; - default: - break; - } - } - } -} - -template -void SWSH::_write(typename BigDNA::WriteYaml::StreamT& w) const { - if (x0_PSLT) - if (auto rec = w.enterSubRecord("PSLT")) - x0_PSLT.write(w); - if (x4_TIME) - if (auto rec = w.enterSubRecord("TIME")) - x4_TIME.write(w); - if (x8_LRAD) - if (auto rec = w.enterSubRecord("LRAD")) - x8_LRAD.write(w); - if (xc_RRAD) - if (auto rec = w.enterSubRecord("RRAD")) - xc_RRAD.write(w); - if (x10_LENG) - if (auto rec = w.enterSubRecord("LENG")) - x10_LENG.write(w); - if (x14_COLR) - if (auto rec = w.enterSubRecord("COLR")) - x14_COLR.write(w); - if (x18_SIDE) - if (auto rec = w.enterSubRecord("SIDE")) - x18_SIDE.write(w); - if (x1c_IROT) - if (auto rec = w.enterSubRecord("IROT")) - x1c_IROT.write(w); - if (x20_ROTM) - if (auto rec = w.enterSubRecord("ROTM")) - x20_ROTM.write(w); - if (x24_POFS) - if (auto rec = w.enterSubRecord("POFS")) - x24_POFS.write(w); - if (x28_IVEL) - if (auto rec = w.enterSubRecord("IVEL")) - x28_IVEL.write(w); - if (x2c_NPOS) - if (auto rec = w.enterSubRecord("NPOS")) - x2c_NPOS.write(w); - if (x30_VELM) - if (auto rec = w.enterSubRecord("VELM")) - x30_VELM.write(w); - if (x34_VLM2) - if (auto rec = w.enterSubRecord("VLM2")) - x34_VLM2.write(w); - if (x38_SPLN) - if (auto rec = w.enterSubRecord("SPLN")) - x38_SPLN.write(w); - if (x3c_TEXR) - if (auto rec = w.enterSubRecord("TEXR")) - x3c_TEXR.write(w); - if (x40_TSPN) - if (auto rec = w.enterSubRecord("TSPN")) - x40_TSPN.write(w); - - if (x44_24_LLRD) - w.writeBool("LLRD", true); - if (!x44_25_CROS) - w.writeBool("CROS", false); - if (x44_26_VLS1) - w.writeBool("VLS1", true); - if (x44_27_VLS2) - w.writeBool("VLS2", true); - if (x44_28_SROT) - w.writeBool("SROT", true); - if (x44_29_WIRE) - w.writeBool("WIRE", true); - if (x44_30_TEXW) - w.writeBool("TEXW", true); - if (x44_31_AALP) - w.writeBool("AALP", true); - if (x45_24_ZBUF) - w.writeBool("ZBUF", true); - if (x45_25_ORNT) - w.writeBool("ORNT", true); - if (x45_26_CRND) - w.writeBool("CRND", true); -} - -template -void SWSH::_binarySize(typename BigDNA::BinarySize::StreamT& s) const { - s += 4; - if (x0_PSLT) { - s += 4; - x0_PSLT.binarySize(s); - } - if (x4_TIME) { - s += 4; - x4_TIME.binarySize(s); - } - if (x8_LRAD) { - s += 4; - x8_LRAD.binarySize(s); - } - if (xc_RRAD) { - s += 4; - xc_RRAD.binarySize(s); - } - if (x10_LENG) { - s += 4; - x10_LENG.binarySize(s); - } - if (x14_COLR) { - s += 4; - x14_COLR.binarySize(s); - } - if (x18_SIDE) { - s += 4; - x18_SIDE.binarySize(s); - } - if (x1c_IROT) { - s += 4; - x1c_IROT.binarySize(s); - } - if (x20_ROTM) { - s += 4; - x20_ROTM.binarySize(s); - } - if (x24_POFS) { - s += 4; - x24_POFS.binarySize(s); - } - if (x28_IVEL) { - s += 4; - x28_IVEL.binarySize(s); - } - if (x2c_NPOS) { - s += 4; - x2c_NPOS.binarySize(s); - } - if (x30_VELM) { - s += 4; - x30_VELM.binarySize(s); - } - if (x34_VLM2) { - s += 4; - x34_VLM2.binarySize(s); - } - if (x38_SPLN) { - s += 4; - x38_SPLN.binarySize(s); - } - if (x3c_TEXR) { - s += 4; - x3c_TEXR.binarySize(s); - } - if (x40_TSPN) { - s += 4; - x40_TSPN.binarySize(s); - } - if (x44_24_LLRD) - s += 9; - if (!x44_25_CROS) - s += 9; - if (x44_26_VLS1) - s += 9; - if (x44_27_VLS2) - s += 9; - if (x44_28_SROT) - s += 9; - if (x44_29_WIRE) - s += 9; - if (x44_30_TEXW) - s += 9; - if (x44_31_AALP) - s += 9; - if (x45_24_ZBUF) - s += 9; - if (x45_25_ORNT) - s += 9; - if (x45_26_CRND) - s += 9; -} - -template -void SWSH::_read(typename BigDNA::Read::StreamT& r) { - DNAFourCC clsId; - clsId.read(r); - if (clsId != SBIG('SWSH')) { - LogModule.report(logvisor::Warning, fmt("non SWSH provided to SWSH parser")); - return; - } - - clsId.read(r); - while (clsId != SBIG('_END')) { - switch (clsId.toUint32()) { - 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'): - r.readUint32Big(); - x44_24_LLRD = r.readBool(); - break; - case SBIG('CROS'): - r.readUint32Big(); - x44_25_CROS = r.readBool(); - break; - case SBIG('VLS1'): - r.readUint32Big(); - x44_26_VLS1 = r.readBool(); - break; - case SBIG('VLS2'): - r.readUint32Big(); - x44_27_VLS2 = r.readBool(); - break; - case SBIG('SROT'): - r.readUint32Big(); - x44_28_SROT = r.readBool(); - break; - case SBIG('WIRE'): - r.readUint32Big(); - x44_29_WIRE = r.readBool(); - break; - case SBIG('TEXW'): - r.readUint32Big(); - x44_30_TEXW = r.readBool(); - break; - case SBIG('AALP'): - r.readUint32Big(); - x44_31_AALP = r.readBool(); - break; - case SBIG('ZBUF'): - r.readUint32Big(); - x45_24_ZBUF = r.readBool(); - break; - case SBIG('ORNT'): - r.readUint32Big(); - x45_25_ORNT = r.readBool(); - break; - case SBIG('CRND'): - r.readUint32Big(); - x45_26_CRND = r.readBool(); - break; - default: - LogModule.report(logvisor::Fatal, fmt("Unknown SWSH class {} @{}"), clsId, r.position()); - break; - } - clsId.read(r); - } -} - -template -void SWSH::_write(typename BigDNA::Write::StreamT& w) const { - w.writeBytes((atInt8*)"SWSH", 4); - if (x0_PSLT) { - w.writeBytes((atInt8*)"PSLT", 4); - x0_PSLT.write(w); - } - if (x4_TIME) { - w.writeBytes((atInt8*)"TIME", 4); - x4_TIME.write(w); - } - if (x8_LRAD) { - w.writeBytes((atInt8*)"LRAD", 4); - x8_LRAD.write(w); - } - if (xc_RRAD) { - w.writeBytes((atInt8*)"RRAD", 4); - xc_RRAD.write(w); - } - if (x10_LENG) { - w.writeBytes((atInt8*)"LENG", 4); - x10_LENG.write(w); - } - if (x14_COLR) { - w.writeBytes((atInt8*)"COLR", 4); - x14_COLR.write(w); - } - if (x18_SIDE) { - w.writeBytes((atInt8*)"SIDE", 4); - x18_SIDE.write(w); - } - if (x1c_IROT) { - w.writeBytes((atInt8*)"IROT", 4); - x1c_IROT.write(w); - } - if (x20_ROTM) { - w.writeBytes((atInt8*)"ROTM", 4); - x20_ROTM.write(w); - } - if (x24_POFS) { - w.writeBytes((atInt8*)"POFS", 4); - x24_POFS.write(w); - } - if (x28_IVEL) { - w.writeBytes((atInt8*)"IVEL", 4); - x28_IVEL.write(w); - } - if (x2c_NPOS) { - w.writeBytes((atInt8*)"NPOS", 4); - x2c_NPOS.write(w); - } - if (x30_VELM) { - w.writeBytes((atInt8*)"VELM", 4); - x30_VELM.write(w); - } - if (x34_VLM2) { - w.writeBytes((atInt8*)"VLM2", 4); - x34_VLM2.write(w); - } - if (x38_SPLN) { - w.writeBytes((atInt8*)"SPLN", 4); - x38_SPLN.write(w); - } - if (x3c_TEXR) { - w.writeBytes((atInt8*)"TEXR", 4); - x3c_TEXR.write(w); - } - if (x40_TSPN) { - w.writeBytes((atInt8*)"TSPN", 4); - x40_TSPN.write(w); - } - - if (x44_24_LLRD) - w.writeBytes("LLRDCNST\x01", 9); - if (!x44_25_CROS) - w.writeBytes("CROSCNST\x00", 9); - if (x44_26_VLS1) - w.writeBytes("VLS1CNST\x01", 9); - if (x44_27_VLS2) - w.writeBytes("VLS2CNST\x01", 9); - if (x44_28_SROT) - w.writeBytes("SROTCNST\x01", 9); - if (x44_29_WIRE) - w.writeBytes("WIRECNST\x01", 9); - if (x44_30_TEXW) - w.writeBytes("TEXWCNST\x01", 9); - if (x44_31_AALP) - w.writeBytes("AALPCNST\x01", 9); - if (x45_24_ZBUF) - w.writeBytes("ZBUFCNST\x01", 9); - if (x45_25_ORNT) - w.writeBytes("ORNTCNST\x01", 9); - if (x45_26_CRND) - w.writeBytes("CRNDCNST\x01", 9); - w.writeBytes("_END", 4); -} - -AT_SUBSPECIALIZE_DNA_YAML(SWSH) -AT_SUBSPECIALIZE_DNA_YAML(SWSH) - -template -void SWSH::gatherDependencies(std::vector& pathsOut) const { - if (x3c_TEXR.m_elem) - x3c_TEXR.m_elem->gatherDependencies(pathsOut); -} - -template struct SWSH; -template struct SWSH; - template bool ExtractSWSH(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { athena::io::FileWriter writer(outPath.getAbsolutePath()); diff --git a/DataSpec/DNACommon/SWHC.def b/DataSpec/DNACommon/SWHC.def new file mode 100644 index 000000000..675d8b5ec --- /dev/null +++ b/DataSpec/DNACommon/SWHC.def @@ -0,0 +1,69 @@ +#ifndef ENTRY +#define ENTRY(name, identifier) +#endif + +#ifndef INT_ENTRY +#define INT_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef REAL_ENTRY +#define REAL_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef VECTOR_ENTRY +#define VECTOR_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef MOD_VECTOR_ENTRY +#define MOD_VECTOR_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef COLOR_ENTRY +#define COLOR_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef UV_ENTRY +#define UV_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef BOOL_ENTRY +#define BOOL_ENTRY(name, identifier, def) ENTRY(name, identifier) +#endif + +INT_ENTRY('PSLT', x0_PSLT) +REAL_ENTRY('TIME', x4_TIME) +REAL_ENTRY('LRAD', x8_LRAD) +REAL_ENTRY('RRAD', xc_RRAD) +INT_ENTRY('LENG', x10_LENG) +COLOR_ENTRY('COLR', x14_COLR) +INT_ENTRY('SIDE', x18_SIDE) +REAL_ENTRY('IROT', x1c_IROT) +REAL_ENTRY('ROTM', x20_ROTM) +VECTOR_ENTRY('POFS', x24_POFS) +VECTOR_ENTRY('IVEL', x28_IVEL) +VECTOR_ENTRY('NPOS', x2c_NPOS) +MOD_VECTOR_ENTRY('VELM', x30_VELM) +MOD_VECTOR_ENTRY('VLM2', x34_VLM2) +INT_ENTRY('SPLN', x38_SPLN) +UV_ENTRY('TEXR', x3c_TEXR) +INT_ENTRY('TSPN', x40_TSPN) +BOOL_ENTRY('LLRD', x44_24_LLRD, false) +BOOL_ENTRY('CROS', x44_25_CROS, true) +BOOL_ENTRY('VLS1', x44_26_VLS1, false) +BOOL_ENTRY('VLS2', x44_27_VLS2, false) +BOOL_ENTRY('SROT', x44_28_SROT, false) +BOOL_ENTRY('WIRE', x44_29_WIRE, false) +BOOL_ENTRY('TEXW', x44_30_TEXW, false) +BOOL_ENTRY('AALP', x44_31_AALP, false) +BOOL_ENTRY('ZBUF', x45_24_ZBUF, false) +BOOL_ENTRY('ORNT', x45_25_ORNT, false) +BOOL_ENTRY('CRND', x45_26_CRND, false) + +#undef ENTRY +#undef INT_ENTRY +#undef REAL_ENTRY +#undef VECTOR_ENTRY +#undef MOD_VECTOR_ENTRY +#undef COLOR_ENTRY +#undef UV_ENTRY +#undef BOOL_ENTRY diff --git a/DataSpec/DNACommon/SWHC.hpp b/DataSpec/DNACommon/SWHC.hpp index 3c81344c0..269828ed2 100644 --- a/DataSpec/DNACommon/SWHC.hpp +++ b/DataSpec/DNACommon/SWHC.hpp @@ -16,48 +16,36 @@ class ProjectPath; namespace DataSpec::DNAParticle { template -struct SWSH : public BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - AT_SUBDECL_DNA +struct _SWSH { + static constexpr ParticleType Type = ParticleType::SWSH; - IntElementFactory x0_PSLT; - RealElementFactory x4_TIME; - RealElementFactory x8_LRAD; - RealElementFactory xc_RRAD; - IntElementFactory x10_LENG; - ColorElementFactory x14_COLR; - IntElementFactory x18_SIDE; - RealElementFactory x1c_IROT; - RealElementFactory x20_ROTM; - VectorElementFactory x24_POFS; - VectorElementFactory x28_IVEL; - VectorElementFactory x2c_NPOS; - ModVectorElementFactory x30_VELM; - ModVectorElementFactory x34_VLM2; - IntElementFactory x38_SPLN; - UVElementFactory x3c_TEXR; - IntElementFactory x40_TSPN; - union { - struct { - bool x44_24_LLRD : 1; - bool x44_25_CROS : 1; - bool x44_26_VLS1 : 1; - bool x44_27_VLS2 : 1; - bool x44_28_SROT : 1; - bool x44_29_WIRE : 1; - bool x44_30_TEXW : 1; - bool x44_31_AALP : 1; - bool x45_24_ZBUF : 1; - bool x45_25_ORNT : 1; - bool x45_26_CRND : 1; - }; - uint16_t dummy = 0; - }; +#define INT_ENTRY(name, identifier) IntElementFactory identifier; +#define REAL_ENTRY(name, identifier) RealElementFactory identifier; +#define VECTOR_ENTRY(name, identifier) VectorElementFactory identifier; +#define MOD_VECTOR_ENTRY(name, identifier) ModVectorElementFactory identifier; +#define COLOR_ENTRY(name, identifier) ColorElementFactory identifier; +#define UV_ENTRY(name, identifier) UVElementFactory identifier; +#define BOOL_ENTRY(name, identifier, def) bool identifier = def; +#include "SWHC.def" - SWSH() { x44_25_CROS = true; } + template + void constexpr Enumerate(_Func f) { +#define ENTRY(name, identifier) f(FOURCC(name), identifier); +#define BOOL_ENTRY(name, identifier, def) f(FOURCC(name), identifier, def); +#include "SWHC.def" + } - void gatherDependencies(std::vector&) const; + template + bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { +#define ENTRY(name, identifier) case SBIG(name): f(identifier); return true; +#include "SWHC.def" + default: return false; + } + } }; +template +using SWSH = PPImpl<_SWSH>; template bool ExtractSWSH(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath); diff --git a/DataSpec/DNACommon/WPSC.cpp b/DataSpec/DNACommon/WPSC.cpp index 67fcfb57c..c801d8789 100644 --- a/DataSpec/DNACommon/WPSC.cpp +++ b/DataSpec/DNACommon/WPSC.cpp @@ -1,645 +1,13 @@ #include "DataSpec/DNACommon/WPSC.hpp" - #include "DataSpec/DNACommon/PAK.hpp" -#include - namespace DataSpec::DNAParticle { -template -void WPSM::_read(athena::io::YAMLDocReader& r) { - for (const auto& elem : r.getCurNode()->m_mapChildren) { - if (elem.first.size() < 4) { - LogModule.report(logvisor::Warning, fmt("short FourCC in element '{}'"), elem.first); - continue; - } +template struct PPImpl<_WPSM>; +template struct PPImpl<_WPSM>; - if (auto rec = r.enterSubRecord(elem.first.c_str())) { - 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(); - 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_SPS1.read(r); - break; - case SBIG('SPS2'): - xunk_SPS2.read(r); - break; - } - } - } -} - -template -void WPSM::_write(athena::io::YAMLDocWriter& w) const { - if (x0_IORN) - if (auto rec = w.enterSubRecord("IORN")) - x0_IORN.write(w); - if (x4_IVEC) - if (auto rec = w.enterSubRecord("IVEC")) - x4_IVEC.write(w); - if (x8_PSOV) - if (auto rec = w.enterSubRecord("PSOV")) - x8_PSOV.write(w); - if (xc_PSVM) - if (auto rec = w.enterSubRecord("PSVM")) - xc_PSVM.write(w); - if (x10_VMD2) - if (auto rec = w.enterSubRecord("VMD2")) - x10_VMD2.write(w); - if (x14_PSLT) - if (auto rec = w.enterSubRecord("PSLT")) - x14_PSLT.write(w); - if (x18_PSCL) - if (auto rec = w.enterSubRecord("PSCL")) - x18_PSCL.write(w); - if (x1c_PCOL) - if (auto rec = w.enterSubRecord("PCOL")) - x1c_PCOL.write(w); - if (x20_POFS) - if (auto rec = w.enterSubRecord("POFS")) - x20_POFS.write(w); - if (x24_OFST) - if (auto rec = w.enterSubRecord("OFST")) - x24_OFST.write(w); - if (x28_APSO) - if (auto rec = w.enterSubRecord("APSO")) - x28_APSO.write(w); - if (x29_HOMG) - if (auto rec = w.enterSubRecord("HOMG")) - x29_HOMG.write(w); - if (x2a_AP11) - if (auto rec = w.enterSubRecord("AP11")) - x2a_AP11.write(w); - if (x2b_AP21) - if (auto rec = w.enterSubRecord("AP21")) - x2b_AP21.write(w); - if (x2c_AS11) - if (auto rec = w.enterSubRecord("AS11")) - x2c_AS11.write(w); - if (x2d_AS12) - if (auto rec = w.enterSubRecord("AS12")) - x2d_AS12.write(w); - if (x2e_AS13) - if (auto rec = w.enterSubRecord("AS13")) - x2e_AS13.write(w); - if (x30_TRAT) - if (auto rec = w.enterSubRecord("TRAT")) - x30_TRAT.write(w); - if (x34_APSM) - if (auto rec = w.enterSubRecord("APSM")) - x34_APSM.write(w); - if (x44_APS2) - if (auto rec = w.enterSubRecord("APS2")) - x44_APS2.write(w); - if (x54_ASW1) - if (auto rec = w.enterSubRecord("ASW1")) - x54_ASW1.write(w); - if (x64_ASW2) - if (auto rec = w.enterSubRecord("ASW2")) - x64_ASW2.write(w); - if (x74_ASW3) - if (auto rec = w.enterSubRecord("ASW3")) - x74_ASW3.write(w); - if (x84_OHEF) - if (auto rec = w.enterSubRecord("OHEF")) - x84_OHEF.write(w); - if (x94_COLR) - if (auto rec = w.enterSubRecord("COLR")) - x94_COLR.write(w); - if (!xa4_EWTR) - if (auto rec = w.enterSubRecord("EWTR")) - xa4_EWTR.write(w); - if (!xa5_LWTR) - if (auto rec = w.enterSubRecord("LWTR")) - xa5_LWTR.write(w); - if (!xa6_SWTR) - if (auto rec = w.enterSubRecord("SWTR")) - xa6_SWTR.write(w); - if (xa8_PJFX != UINT32_MAX) - w.writeUint32("PJFX", xa8_PJFX); - if (xac_RNGE) - if (auto rec = w.enterSubRecord("RNGE")) - xac_RNGE.write(w); - if (xb0_FOFF) - if (auto rec = w.enterSubRecord("FOFF")) - xb0_FOFF.write(w); - if (xunk_FC60) - if (auto rec = w.enterSubRecord("FC60")) - xunk_FC60.write(w); - if (xunk_SPS1) - if (auto rec = w.enterSubRecord("SPS1")) - xunk_SPS1.write(w); - if (xunk_SPS1) - if (auto rec = w.enterSubRecord("SPS2")) - xunk_SPS2.write(w); -} - -template -void WPSM::_binarySize(size_t& __isz) const { - __isz += 4; - if (x0_IORN) { - __isz += 4; - x0_IORN.binarySize(__isz); - } - if (x4_IVEC) { - __isz += 4; - x4_IVEC.binarySize(__isz); - } - if (x8_PSOV) { - __isz += 4; - x8_PSOV.binarySize(__isz); - } - if (xc_PSVM) { - __isz += 4; - xc_PSVM.binarySize(__isz); - } - if (x10_VMD2) { - __isz += 4; - x10_VMD2.binarySize(__isz); - } - if (x14_PSLT) { - __isz += 4; - x14_PSLT.binarySize(__isz); - } - if (x18_PSCL) { - __isz += 4; - x18_PSCL.binarySize(__isz); - } - if (x1c_PCOL) { - __isz += 4; - x1c_PCOL.binarySize(__isz); - } - if (x20_POFS) { - __isz += 4; - x20_POFS.binarySize(__isz); - } - if (x24_OFST) { - __isz += 4; - x24_OFST.binarySize(__isz); - } - if (x28_APSO) { - __isz += 4; - x28_APSO.binarySize(__isz); - } - if (x29_HOMG) { - __isz += 4; - x29_HOMG.binarySize(__isz); - } - if (x2a_AP11) { - __isz += 4; - x2a_AP11.binarySize(__isz); - } - if (x2b_AP21) { - __isz += 4; - x2b_AP21.binarySize(__isz); - } - if (x2c_AS11) { - __isz += 4; - x2c_AS11.binarySize(__isz); - } - if (x2d_AS12) { - __isz += 4; - x2d_AS12.binarySize(__isz); - } - if (x2e_AS13) { - __isz += 4; - x2e_AS13.binarySize(__isz); - } - if (x30_TRAT) { - __isz += 4; - x30_TRAT.binarySize(__isz); - } - if (x34_APSM) { - __isz += 4; - x34_APSM.binarySize(__isz); - } - if (x44_APS2) { - __isz += 4; - x44_APS2.binarySize(__isz); - } - if (x54_ASW1) { - __isz += 4; - x54_ASW1.binarySize(__isz); - } - if (x64_ASW2) { - __isz += 4; - x64_ASW2.binarySize(__isz); - } - if (x74_ASW3) { - __isz += 4; - x74_ASW3.binarySize(__isz); - } - if (x84_OHEF) { - __isz += 4; - x84_OHEF.binarySize(__isz); - } - if (x94_COLR) { - __isz += 4; - x94_COLR.binarySize(__isz); - } - if (!xa4_EWTR) { - __isz += 4; - xa4_EWTR.binarySize(__isz); - } - if (!xa5_LWTR) { - __isz += 4; - xa5_LWTR.binarySize(__isz); - } - if (!xa6_SWTR) { - __isz += 4; - xa6_SWTR.binarySize(__isz); - } - if (xa8_PJFX != UINT32_MAX) - __isz += 12; - if (xac_RNGE) { - __isz += 4; - xac_RNGE.binarySize(__isz); - } - if (xb0_FOFF) { - __isz += 4; - xb0_FOFF.binarySize(__isz); - } - if (xunk_FC60) { - __isz += 4; - xunk_FC60.binarySize(__isz); - } - if (xunk_SPS1) { - __isz += 4; - xunk_SPS1.binarySize(__isz); - } - if (xunk_SPS2) { - __isz += 4; - xunk_SPS2.binarySize(__isz); - } -} - -template -void WPSM::_read(athena::io::IStreamReader& r) { - DNAFourCC clsId; - clsId.read(r); - if (clsId != SBIG('WPSM')) { - LogModule.report(logvisor::Warning, fmt("non WPSM provided to WPSM parser")); - return; - } - clsId.read(r); - while (clsId != SBIG('_END')) { - switch (clsId.toUint32()) { - 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'): - r.readUint32(); - x28_APSO = r.readBool(); - 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'): - r.readUint32(); - xa4_EWTR = r.readBool(); - break; - case SBIG('LWTR'): - r.readUint32(); - xa5_LWTR = r.readBool(); - break; - case SBIG('SWTR'): - r.readUint32(); - xa6_SWTR = r.readBool(); - break; - case SBIG('PJFX'): { - uint32_t fcc; - r.readBytesToBuf(&fcc, 4); - if (fcc != SBIG('NONE')) - xa8_PJFX = r.readUint32Big(); - } 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_SPS1.read(r); - break; - case SBIG('SPS2'): - xunk_SPS2.read(r); - break; - default: - LogModule.report(logvisor::Fatal, fmt("Unknown WPSM class {} @{}"), clsId, r.position()); - break; - } - clsId.read(r); - } -} - -template -void WPSM::_write(athena::io::IStreamWriter& w) const { - w.writeBytes("WPSM", 4); - if (x0_IORN) { - w.writeBytes("IORN", 4); - x0_IORN.write(w); - } - if (x4_IVEC) { - w.writeBytes("IVEC", 4); - x4_IVEC.write(w); - } - if (x8_PSOV) { - w.writeBytes("PSOV", 4); - x8_PSOV.write(w); - } - if (xc_PSVM) { - w.writeBytes("PSVM", 4); - xc_PSVM.write(w); - } - if (x10_VMD2) { - w.writeBytes("VMD2", 4); - x10_VMD2.write(w); - } - if (x14_PSLT) { - w.writeBytes("PSLT", 4); - x14_PSLT.write(w); - } - if (x18_PSCL) { - w.writeBytes("PSCL", 4); - x18_PSCL.write(w); - } - if (x1c_PCOL) { - w.writeBytes("PCOL", 4); - x1c_PCOL.write(w); - } - if (x20_POFS) { - w.writeBytes("POFS", 4); - x20_POFS.write(w); - } - if (x24_OFST) { - w.writeBytes("OFST", 4); - x24_OFST.write(w); - } - if (x28_APSO) { - w.writeBytes("APSO", 4); - x28_APSO.write(w); - } - if (x29_HOMG) { - w.writeBytes("HOMG", 4); - x29_HOMG.write(w); - } - if (x2a_AP11) { - w.writeBytes("AP11", 4); - x2a_AP11.write(w); - } - if (x2b_AP21) { - w.writeBytes("AP21", 4); - x2b_AP21.write(w); - } - if (x2c_AS11) { - w.writeBytes("AS11", 4); - x2c_AS11.write(w); - } - if (x2d_AS12) { - w.writeBytes("AS12", 4); - x2d_AS12.write(w); - } - if (x2e_AS13) { - w.writeBytes("AS13", 4); - x2e_AS13.write(w); - } - if (x30_TRAT) { - w.writeBytes("TRAT", 4); - x30_TRAT.write(w); - } - if (x34_APSM) { - w.writeBytes("APSM", 4); - x34_APSM.write(w); - } - if (x44_APS2) { - w.writeBytes("APS2", 4); - x44_APS2.write(w); - } - if (x54_ASW1) { - w.writeBytes("ASW1", 4); - x54_ASW1.write(w); - } - if (x64_ASW2) { - w.writeBytes("ASW2", 4); - x64_ASW2.write(w); - } - if (x74_ASW3) { - w.writeBytes("ASW3", 4); - x74_ASW3.write(w); - } - if (x84_OHEF) { - w.writeBytes("OHEF", 4); - x84_OHEF.write(w); - } - if (x94_COLR) { - w.writeBytes("COLR", 4); - x94_COLR.write(w); - } - if (!xa4_EWTR) { - w.writeBytes("EWTR", 4); - xa4_EWTR.write(w); - } - if (!xa5_LWTR) { - w.writeBytes("LWTR", 4); - xa5_LWTR.write(w); - } - if (!xa6_SWTR) { - w.writeBytes("SWTR", 4); - xa6_SWTR.write(w); - } - if (xa8_PJFX != UINT32_MAX) { - w.writeBytes("PJFXCNST", 8); - w.writeUint32(xa8_PJFX); - } - if (xac_RNGE) { - w.writeBytes("RNGE", 4); - xac_RNGE.write(w); - } - if (xb0_FOFF) { - w.writeBytes("FOFF", 4); - xb0_FOFF.write(w); - } - if (xunk_FC60) { - w.writeBytes("FC60", 4); - xunk_FC60.write(w); - } - if (xunk_SPS1) { - w.writeBytes("SPS1", 4); - xunk_SPS1.write(w); - } - if (xunk_SPS2) { - w.writeBytes("SPS2", 4); - xunk_SPS2.write(w); - } - - w.writeBytes("_END", 4); -} - -AT_SUBSPECIALIZE_DNA_YAML(WPSM) -AT_SUBSPECIALIZE_DNA_YAML(WPSM) +AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_WPSM>) +AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_WPSM>) template <> std::string_view WPSM::DNAType() { @@ -651,20 +19,6 @@ std::string_view WPSM::DNAType() { return "WPSM"sv; } -template -void WPSM::gatherDependencies(std::vector& pathsOut) const { - g_curSpec->flattenDependencies(x34_APSM.id, pathsOut); - g_curSpec->flattenDependencies(x44_APS2.id, pathsOut); - g_curSpec->flattenDependencies(x54_ASW1.id, pathsOut); - g_curSpec->flattenDependencies(x64_ASW2.id, pathsOut); - g_curSpec->flattenDependencies(x74_ASW3.id, pathsOut); - g_curSpec->flattenDependencies(x84_OHEF.id, pathsOut); - g_curSpec->flattenDependencies(x94_COLR.id, pathsOut); -} - -template struct WPSM; -template struct WPSM; - template bool ExtractWPSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { athena::io::FileWriter writer(outPath.getAbsolutePath()); diff --git a/DataSpec/DNACommon/WPSC.def b/DataSpec/DNACommon/WPSC.def new file mode 100644 index 000000000..04b6ce33f --- /dev/null +++ b/DataSpec/DNACommon/WPSC.def @@ -0,0 +1,87 @@ +#ifndef ENTRY +#define ENTRY(name, identifier) +#endif + +#ifndef INT_ENTRY +#define INT_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef U32_ENTRY +#define U32_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef REAL_ENTRY +#define REAL_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef VECTOR_ENTRY +#define VECTOR_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef MOD_VECTOR_ENTRY +#define MOD_VECTOR_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef COLOR_ENTRY +#define COLOR_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef UV_ENTRY +#define UV_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef RES_ENTRY +#define RES_ENTRY(name, identifier) ENTRY(name, identifier) +#endif + +#ifndef BOOL_ENTRY +#define BOOL_ENTRY(name, identifier, def) ENTRY(name, identifier) +#endif + +VECTOR_ENTRY('IORN', x0_IORN) +VECTOR_ENTRY('IVEC', x4_IVEC) +VECTOR_ENTRY('PSOV', x8_PSOV) +MOD_VECTOR_ENTRY('PSVM', xc_PSVM) +INT_ENTRY('PSLT', x14_PSLT) +VECTOR_ENTRY('PSCL', x18_PSCL) +COLOR_ENTRY('PCOL', x1c_PCOL) +VECTOR_ENTRY('POFS', x20_POFS) +VECTOR_ENTRY('OFST', x24_OFST) + +REAL_ENTRY('TRAT', x30_TRAT) +RES_ENTRY('APSM', x34_APSM) +RES_ENTRY('APS2', x44_APS2) +RES_ENTRY('ASW1', x54_ASW1) +RES_ENTRY('ASW2', x64_ASW2) +RES_ENTRY('ASW3', x74_ASW3) +RES_ENTRY('OHEF', x84_OHEF) +RES_ENTRY('COLR', x94_COLR) +U32_ENTRY('PJFX', xa8_PJFX) +REAL_ENTRY('RNGE', xac_RNGE) +REAL_ENTRY('FOFF', xb0_FOFF) + +BOOL_ENTRY('VMD2', x10_VMD2, false) +BOOL_ENTRY('APSO', x28_APSO, false) +BOOL_ENTRY('HOMG', x29_HOMG, false) +BOOL_ENTRY('AP11', x2a_AP11, false) +BOOL_ENTRY('AP21', x2b_AP21, false) +BOOL_ENTRY('AS11', x2c_AS11, false) +BOOL_ENTRY('AS12', x2d_AS12, false) +BOOL_ENTRY('AS13', x2e_AS13, false) +BOOL_ENTRY('EWTR', xa4_EWTR, true) +BOOL_ENTRY('LWTR', xa5_LWTR, true) +BOOL_ENTRY('SWTR', xa6_SWTR, true) +BOOL_ENTRY('FC60', xunk_FC60, false) +BOOL_ENTRY('SPS1', xunk_SPS1, false) +BOOL_ENTRY('SPS2', xunk_SPS2, false) + +#undef ENTRY +#undef INT_ENTRY +#undef U32_ENTRY +#undef REAL_ENTRY +#undef VECTOR_ENTRY +#undef MOD_VECTOR_ENTRY +#undef COLOR_ENTRY +#undef UV_ENTRY +#undef RES_ENTRY +#undef BOOL_ENTRY diff --git a/DataSpec/DNACommon/WPSC.hpp b/DataSpec/DNACommon/WPSC.hpp index 3df67b7bd..6a387ef7a 100644 --- a/DataSpec/DNACommon/WPSC.hpp +++ b/DataSpec/DNACommon/WPSC.hpp @@ -12,53 +12,40 @@ class ProjectPath; } namespace DataSpec::DNAParticle { -template -struct WPSM : BigDNA { - AT_DECL_EXPLICIT_DNA_YAML - AT_SUBDECL_DNA - VectorElementFactory x0_IORN; - VectorElementFactory x4_IVEC; - VectorElementFactory x8_PSOV; - ModVectorElementFactory xc_PSVM; - BoolHelper x10_VMD2; - IntElementFactory x14_PSLT; - VectorElementFactory x18_PSCL; - ColorElementFactory x1c_PCOL; - VectorElementFactory x20_POFS; - VectorElementFactory x24_OFST; - BoolHelper x28_APSO; - BoolHelper x29_HOMG; - BoolHelper x2a_AP11; - BoolHelper x2b_AP21; - BoolHelper x2c_AS11; - BoolHelper x2d_AS12; - BoolHelper x2e_AS13; - RealElementFactory x30_TRAT; - ChildResourceFactory x34_APSM; - ChildResourceFactory x44_APS2; - ChildResourceFactory x54_ASW1; - ChildResourceFactory x64_ASW2; - ChildResourceFactory x74_ASW3; - ChildResourceFactory x84_OHEF; - ChildResourceFactory x94_COLR; - BoolHelper xa4_EWTR; - BoolHelper xa5_LWTR; - BoolHelper xa6_SWTR; - uint32_t xa8_PJFX = ~0; - RealElementFactory xac_RNGE; - RealElementFactory xb0_FOFF; - BoolHelper xunk_FC60; - BoolHelper xunk_SPS1; - BoolHelper xunk_SPS2; - WPSM() { - xa4_EWTR = true; - xa5_LWTR = true; - xa6_SWTR = true; +template +struct _WPSM { + static constexpr ParticleType Type = ParticleType::WPSM; + +#define INT_ENTRY(name, identifier) IntElementFactory identifier; +#define U32_ENTRY(name, identifier) uint32_t identifier = ~0; +#define REAL_ENTRY(name, identifier) RealElementFactory identifier; +#define VECTOR_ENTRY(name, identifier) VectorElementFactory identifier; +#define MOD_VECTOR_ENTRY(name, identifier) ModVectorElementFactory identifier; +#define COLOR_ENTRY(name, identifier) ColorElementFactory identifier; +#define UV_ENTRY(name, identifier) UVElementFactory identifier; +#define RES_ENTRY(name, identifier) ChildResourceFactory identifier; +#define BOOL_ENTRY(name, identifier, def) bool identifier = def; +#include "WPSC.def" + + template + void constexpr Enumerate(_Func f) { +#define ENTRY(name, identifier) f(FOURCC(name), identifier); +#define BOOL_ENTRY(name, identifier, def) f(FOURCC(name), identifier, def); +#include "WPSC.def" } - void gatherDependencies(std::vector&) const; + template + bool constexpr Lookup(FourCC fcc, _Func f) { + switch (fcc.toUint32()) { +#define ENTRY(name, identifier) case SBIG(name): f(identifier); return true; +#include "WPSC.def" + default: return false; + } + } }; +template +using WPSM = PPImpl<_WPSM>; template bool ExtractWPSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath); diff --git a/Runtime/Audio/CAudioGroupSet.hpp b/Runtime/Audio/CAudioGroupSet.hpp index ef9d37f2e..d0b8c968b 100644 --- a/Runtime/Audio/CAudioGroupSet.hpp +++ b/Runtime/Audio/CAudioGroupSet.hpp @@ -21,7 +21,7 @@ class CAudioGroupSet { amuse::AudioGroupData LoadData(); public: - CAudioGroupSet(std::unique_ptr&& in); + explicit CAudioGroupSet(std::unique_ptr&& in); const amuse::AudioGroupData& GetAudioGroupData() const { return m_data; } std::string_view GetName() const { return x20_name; } }; diff --git a/Runtime/Audio/CMidiManager.hpp b/Runtime/Audio/CMidiManager.hpp index ebf757d5c..75b915473 100644 --- a/Runtime/Audio/CMidiManager.hpp +++ b/Runtime/Audio/CMidiManager.hpp @@ -19,7 +19,7 @@ public: u16 GetGroupId() const { return x2_groupId; } CAssetId GetAGSCAssetId() const { return x4_agscId; } const u8* GetArrData() const { return x8_arrData.get(); } - CMidiData(CInputStream& in); + explicit CMidiData(CInputStream& in); }; class CMidiWrapper { diff --git a/Runtime/Audio/CStaticAudioPlayer.hpp b/Runtime/Audio/CStaticAudioPlayer.hpp index b2ee5551e..8ffb59460 100644 --- a/Runtime/Audio/CStaticAudioPlayer.hpp +++ b/Runtime/Audio/CStaticAudioPlayer.hpp @@ -53,7 +53,7 @@ class CStaticAudioPlayer { memset(data, 0, 4 * frames); return frames; } - AudioVoiceCallback(CStaticAudioPlayer& p) : m_parent(p) {} + explicit AudioVoiceCallback(CStaticAudioPlayer& p) : m_parent(p) {} } m_voiceCallback; boo::ObjToken m_voice; diff --git a/Runtime/Audio/CStreamAudioManager.cpp b/Runtime/Audio/CStreamAudioManager.cpp index adf9d3175..1660e097f 100644 --- a/Runtime/Audio/CStreamAudioManager.cpp +++ b/Runtime/Audio/CStreamAudioManager.cpp @@ -50,7 +50,7 @@ struct SDSPStreamInfo { s16 x1c_coef[8][2]; SDSPStreamInfo() = default; - SDSPStreamInfo(const CDSPStreamManager& stream); + explicit SDSPStreamInfo(const CDSPStreamManager& stream); }; struct SDSPStream : boo::IAudioVoiceCallback { diff --git a/Runtime/AutoMapper/CAutoMapper.hpp b/Runtime/AutoMapper/CAutoMapper.hpp index a49a76984..a2d5d168d 100644 --- a/Runtime/AutoMapper/CAutoMapper.hpp +++ b/Runtime/AutoMapper/CAutoMapper.hpp @@ -224,7 +224,7 @@ private: CAssetId GetAreaHintDescriptionString(CAssetId mreaId); public: - CAutoMapper(CStateManager& stateMgr); + explicit CAutoMapper(CStateManager& stateMgr); bool CheckLoadComplete(); bool CanLeaveMapScreen(const CStateManager& mgr) const; float GetMapRotationX() const { return xa8_renderStates[0].x1c_camAngle; } diff --git a/Runtime/AutoMapper/CMapArea.hpp b/Runtime/AutoMapper/CMapArea.hpp index 80c6c8379..ff4f8233f 100644 --- a/Runtime/AutoMapper/CMapArea.hpp +++ b/Runtime/AutoMapper/CMapArea.hpp @@ -38,7 +38,7 @@ public: std::vector m_instances; public: - CMapAreaSurface(const void* surfBuf); + explicit CMapAreaSurface(const void* surfBuf); CMapAreaSurface(CMapAreaSurface&&) = default; void PostConstruct(const u8* buf, std::vector& index); void Draw(const zeus::CVector3f* verts, const zeus::CColor& surfColor, const zeus::CColor& lineColor, @@ -69,7 +69,7 @@ private: boo::ObjToken m_ibo; public: - CMapArea(CInputStream& in, u32 size); + explicit CMapArea(CInputStream& in, u32 size); void PostConstruct(); bool GetIsVisibleToAutoMapper(bool worldVis, bool areaVis) const; zeus::CVector3f GetAreaCenterPoint() const { return x10_box.center(); } diff --git a/Runtime/AutoMapper/CMapUniverse.hpp b/Runtime/AutoMapper/CMapUniverse.hpp index 989a629f5..c961db60e 100644 --- a/Runtime/AutoMapper/CMapUniverse.hpp +++ b/Runtime/AutoMapper/CMapUniverse.hpp @@ -84,7 +84,7 @@ public: zeus::CVector3f x64_centerPoint = zeus::skZero3f; public: - CMapWorldData(CInputStream& in, u32 version); + explicit CMapWorldData(CInputStream& in, u32 version); CAssetId GetWorldAssetId() const { return x10_worldAssetId; } const zeus::CVector3f& GetWorldCenterPoint() const { return x64_centerPoint; } std::string_view GetWorldLabel() const { return x0_label; } @@ -105,7 +105,7 @@ private: float x2c_universeRadius = 1600.f; public: - CMapUniverse(CInputStream&, u32); + explicit CMapUniverse(CInputStream&, u32); const CMapWorldData& GetMapWorldData(s32 idx) const { return x10_worldDatas[idx]; } const CMapWorldData& GetMapWorldDataByWorldId(CAssetId id) const { for (const CMapWorldData& data : x10_worldDatas) diff --git a/Runtime/AutoMapper/CMapWorld.cpp b/Runtime/AutoMapper/CMapWorld.cpp index 481474da1..6defe74ce 100644 --- a/Runtime/AutoMapper/CMapWorld.cpp +++ b/Runtime/AutoMapper/CMapWorld.cpp @@ -1,6 +1,7 @@ #include "Runtime/AutoMapper/CMapWorld.hpp" #include +#include #include "Runtime/CSimplePool.hpp" #include "Runtime/CStateManager.hpp" @@ -9,6 +10,254 @@ #include "Runtime/World/CWorld.hpp" namespace urde { +namespace { +struct Support { + int x0_; + std::array x4_; +}; + +struct Circle2 { + zeus::CVector2f x0_point; + float x8_radiusSq; +}; + +struct Circle { + zeus::CVector2f x0_point; + float x8_radius; + Circle(const Circle2& circ2) : x0_point(circ2.x0_point), x8_radius(std::sqrt(circ2.x8_radiusSq)) {} +}; + +Circle2 ExactCircle1(const zeus::CVector2f* a) { return {*a, 0.f}; } + +Circle2 ExactCircle2(const zeus::CVector2f* a, const zeus::CVector2f* b) { + Circle2 ret = {}; + ret.x0_point = 0.5f * (*a + *b); + ret.x8_radiusSq = (*b - *a).magSquared() * 0.25f; + return ret; +} + +Circle2 ExactCircle3(const zeus::CVector2f* a, const zeus::CVector2f* b, const zeus::CVector2f* c) { + Circle2 ret = {}; + zeus::CVector2f d1 = *b - *a; + zeus::CVector2f d2 = *c - *a; + float cross = d1.cross(d2); + zeus::CVector2f magVec(d1.magSquared() * 0.5f, d2.magSquared() * 0.5f); + if (std::fabs(cross) > 0.01f) { + zeus::CVector2f tmp((d2.y() * magVec.x() - d1.y() * magVec.y()) / cross, + (d1.x() * magVec.y() - d2.x() * magVec.x()) / cross); + ret.x0_point = *a + tmp; + ret.x8_radiusSq = tmp.magSquared(); + } else { + ret.x8_radiusSq = FLT_MAX; + } + return ret; +} + +bool PointInsideCircle(const zeus::CVector2f& point, const Circle2& circ, float& intersect) { + intersect = (point - circ.x0_point).magSquared() - circ.x8_radiusSq; + return intersect <= 0.f; +} + +Circle2 UpdateSupport1(int idx, const zeus::CVector2f** list, Support& support) { + Circle2 ret = ExactCircle2(list[support.x4_[0]], list[idx]); + support.x0_ = 2; + support.x4_[1] = idx; + return ret; +} + +Circle2 UpdateSupport2(int idx, const zeus::CVector2f** list, Support& support) { + std::array circs{}; + float intersect; + int circIdx = -1; + float minRad = FLT_MAX; + + circs[0] = ExactCircle2(list[support.x4_[0]], list[idx]); + if (PointInsideCircle(*list[support.x4_[1]], circs[0], intersect)) { + minRad = circs[0].x8_radiusSq; + circIdx = 0; + } + + circs[1] = ExactCircle2(list[support.x4_[1]], list[idx]); + if (circs[1].x8_radiusSq < minRad && PointInsideCircle(*list[support.x4_[0]], circs[1], intersect)) { + circIdx = 1; + } + + Circle2 ret; + if (circIdx != -1) { + ret = circs[circIdx]; + support.x4_[1 - circIdx] = idx; + } else { + ret = ExactCircle3(list[support.x4_[0]], list[support.x4_[1]], list[idx]); + support.x0_ = 3; + support.x4_[2] = idx; + } + return ret; +} + +Circle2 UpdateSupport3(int idx, const zeus::CVector2f** list, Support& support) { + std::array circs{}; + float intersect; + int circIdxA = -1; + int circIdxB = -1; + float minRadA = FLT_MAX; + float minRadB = FLT_MAX; + + circs[0] = ExactCircle2(list[support.x4_[0]], list[idx]); + if (PointInsideCircle(*list[support.x4_[1]], circs[0], intersect)) { + if (PointInsideCircle(*list[support.x4_[2]], circs[0], intersect)) { + minRadA = circs[0].x8_radiusSq; + circIdxA = 0; + } else { + minRadB = intersect; + circIdxB = 0; + } + } else { + minRadB = intersect; + circIdxB = 0; + } + + circs[1] = ExactCircle2(list[support.x4_[1]], list[idx]); + if (circs[1].x8_radiusSq < minRadA) { + if (PointInsideCircle(*list[support.x4_[0]], circs[1], intersect)) { + if (PointInsideCircle(*list[support.x4_[2]], circs[1], intersect)) { + minRadA = circs[1].x8_radiusSq; + circIdxA = 1; + } else if (intersect < minRadB) { + minRadB = intersect; + circIdxB = 1; + } + } else if (intersect < minRadB) { + minRadB = intersect; + circIdxB = 1; + } + } + + circs[2] = ExactCircle2(list[support.x4_[2]], list[idx]); + if (circs[2].x8_radiusSq < minRadA) { + if (PointInsideCircle(*list[support.x4_[0]], circs[2], intersect)) { + if (PointInsideCircle(*list[support.x4_[1]], circs[2], intersect)) { + minRadA = circs[2].x8_radiusSq; + circIdxA = 2; + } else if (intersect < minRadB) { + minRadB = intersect; + circIdxB = 2; + } + } else if (intersect < minRadB) { + minRadB = intersect; + circIdxB = 2; + } + } + + circs[3] = ExactCircle3(list[support.x4_[0]], list[support.x4_[1]], list[idx]); + if (circs[3].x8_radiusSq < minRadA) { + if (PointInsideCircle(*list[support.x4_[2]], circs[3], intersect)) { + minRadA = circs[3].x8_radiusSq; + circIdxA = 3; + } else if (intersect < minRadB) { + minRadB = intersect; + circIdxB = 3; + } + } + + circs[4] = ExactCircle3(list[support.x4_[0]], list[support.x4_[2]], list[idx]); + if (circs[4].x8_radiusSq < minRadA) { + if (PointInsideCircle(*list[support.x4_[1]], circs[4], intersect)) { + minRadA = circs[4].x8_radiusSq; + circIdxA = 4; + } else if (intersect < minRadB) { + minRadB = intersect; + circIdxB = 4; + } + } + + circs[5] = ExactCircle3(list[support.x4_[1]], list[support.x4_[2]], list[idx]); + if (circs[5].x8_radiusSq < minRadA) { + if (PointInsideCircle(*list[support.x4_[0]], circs[5], intersect)) { + circIdxA = 5; + } else if (intersect < minRadB) { + circIdxB = 5; + } + } + + if (circIdxA == -1) + circIdxA = circIdxB; + + switch (circIdxA) { + case 0: + support.x0_ = 2; + support.x4_[1] = idx; + break; + case 1: + support.x0_ = 2; + support.x4_[0] = idx; + break; + case 2: + support.x0_ = 2; + support.x4_[0] = support.x4_[2]; + support.x4_[1] = idx; + break; + case 3: + support.x4_[2] = idx; + break; + case 4: + support.x4_[1] = idx; + break; + case 5: + support.x4_[0] = idx; + break; + default: + break; + } + + return circs[circIdxA]; +} + +using FSupport = Circle2 (*)(int idx, const zeus::CVector2f** list, Support& support); +constexpr std::array SupportFuncs{ + nullptr, + UpdateSupport1, + UpdateSupport2, + UpdateSupport3, +}; + +Circle MinCircle(const std::vector& coords) { + Circle2 ret = {}; + if (coords.size() >= 1) { + std::unique_ptr randArr(new const zeus::CVector2f*[coords.size()]); + for (size_t i = 0; i < coords.size(); ++i) + randArr[i] = &coords[i]; + for (int i = coords.size() - 1; i >= 0; --i) { + int shuf = rand() % (i + 1); + if (shuf != i) + std::swap(randArr[i], randArr[shuf]); + } + ret = ExactCircle1(randArr[0]); + + Support support = {}; + support.x0_ = 1; + for (size_t i = 1; i < coords.size();) { + bool broke = false; + for (int j = 0; j < support.x0_; ++j) { + if ((*randArr[i] - *randArr[support.x4_[j]]).magSquared() < 0.01f) { + broke = true; + break; + } + } + float intersect; + if (!broke && !PointInsideCircle(*randArr[i], ret, intersect)) { + Circle2 circ = SupportFuncs[support.x0_](i, randArr.get(), support); + if (circ.x8_radiusSq > ret.x8_radiusSq) { + i = 0; + ret = circ; + continue; + } + } + ++i; + } + } + return ret; +} +} // Anonymous namespace CMapWorld::CMapAreaData::CMapAreaData(CAssetId areaRes, EMapAreaList list, CMapAreaData* next) : x0_area(g_SimplePool->GetObj(SObjectTag{FOURCC('MAPA'), areaRes})), x10_list(list), x14_next(next) {} @@ -378,248 +627,6 @@ void CMapWorld::DrawAreas(const CMapWorld::CMapWorldDrawParms& parms, int selAre } } -struct Support { - int x0_; - int x4_[3]; -}; - -struct Circle2 { - zeus::CVector2f x0_point; - float x8_radiusSq; -}; - -struct Circle { - zeus::CVector2f x0_point; - float x8_radius; - Circle(const Circle2& circ2) : x0_point(circ2.x0_point), x8_radius(std::sqrt(circ2.x8_radiusSq)) {} -}; - -static Circle2 ExactCircle1(const zeus::CVector2f* a) { return {*a, 0.f}; } - -static Circle2 ExactCircle2(const zeus::CVector2f* a, const zeus::CVector2f* b) { - Circle2 ret = {}; - ret.x0_point = 0.5f * (*a + *b); - ret.x8_radiusSq = (*b - *a).magSquared() * 0.25f; - return ret; -} - -static Circle2 ExactCircle3(const zeus::CVector2f* a, const zeus::CVector2f* b, const zeus::CVector2f* c) { - Circle2 ret = {}; - zeus::CVector2f d1 = *b - *a; - zeus::CVector2f d2 = *c - *a; - float cross = d1.cross(d2); - zeus::CVector2f magVec(d1.magSquared() * 0.5f, d2.magSquared() * 0.5f); - if (std::fabs(cross) > 0.01f) { - zeus::CVector2f tmp((d2.y() * magVec.x() - d1.y() * magVec.y()) / cross, - (d1.x() * magVec.y() - d2.x() * magVec.x()) / cross); - ret.x0_point = *a + tmp; - ret.x8_radiusSq = tmp.magSquared(); - } else { - ret.x8_radiusSq = FLT_MAX; - } - return ret; -} - -static bool PointInsideCircle(const zeus::CVector2f& point, const Circle2& circ, float& intersect) { - intersect = (point - circ.x0_point).magSquared() - circ.x8_radiusSq; - return intersect <= 0.f; -} - -static Circle2 UpdateSupport1(int idx, const zeus::CVector2f** list, Support& support) { - Circle2 ret = ExactCircle2(list[support.x4_[0]], list[idx]); - support.x0_ = 2; - support.x4_[1] = idx; - return ret; -} - -static Circle2 UpdateSupport2(int idx, const zeus::CVector2f** list, Support& support) { - Circle2 circs[3] = {}; - float intersect; - int circIdx = -1; - float minRad = FLT_MAX; - - circs[0] = ExactCircle2(list[support.x4_[0]], list[idx]); - if (PointInsideCircle(*list[support.x4_[1]], circs[0], intersect)) { - minRad = circs[0].x8_radiusSq; - circIdx = 0; - } - - circs[1] = ExactCircle2(list[support.x4_[1]], list[idx]); - if (circs[1].x8_radiusSq < minRad && PointInsideCircle(*list[support.x4_[0]], circs[1], intersect)) { - circIdx = 1; - } - - Circle2 ret; - if (circIdx != -1) { - ret = circs[circIdx]; - support.x4_[1 - circIdx] = idx; - } else { - ret = ExactCircle3(list[support.x4_[0]], list[support.x4_[1]], list[idx]); - support.x0_ = 3; - support.x4_[2] = idx; - } - return ret; -} - -static Circle2 UpdateSupport3(int idx, const zeus::CVector2f** list, Support& support) { - Circle2 circs[6] = {}; - float intersect; - int circIdxA = -1; - int circIdxB = -1; - float minRadA = FLT_MAX; - float minRadB = FLT_MAX; - - circs[0] = ExactCircle2(list[support.x4_[0]], list[idx]); - if (PointInsideCircle(*list[support.x4_[1]], circs[0], intersect)) { - if (PointInsideCircle(*list[support.x4_[2]], circs[0], intersect)) { - minRadA = circs[0].x8_radiusSq; - circIdxA = 0; - } else { - minRadB = intersect; - circIdxB = 0; - } - } else { - minRadB = intersect; - circIdxB = 0; - } - - circs[1] = ExactCircle2(list[support.x4_[1]], list[idx]); - if (circs[1].x8_radiusSq < minRadA) { - if (PointInsideCircle(*list[support.x4_[0]], circs[1], intersect)) { - if (PointInsideCircle(*list[support.x4_[2]], circs[1], intersect)) { - minRadA = circs[1].x8_radiusSq; - circIdxA = 1; - } else if (intersect < minRadB) { - minRadB = intersect; - circIdxB = 1; - } - } else if (intersect < minRadB) { - minRadB = intersect; - circIdxB = 1; - } - } - - circs[2] = ExactCircle2(list[support.x4_[2]], list[idx]); - if (circs[2].x8_radiusSq < minRadA) { - if (PointInsideCircle(*list[support.x4_[0]], circs[2], intersect)) { - if (PointInsideCircle(*list[support.x4_[1]], circs[2], intersect)) { - minRadA = circs[2].x8_radiusSq; - circIdxA = 2; - } else if (intersect < minRadB) { - minRadB = intersect; - circIdxB = 2; - } - } else if (intersect < minRadB) { - minRadB = intersect; - circIdxB = 2; - } - } - - circs[3] = ExactCircle3(list[support.x4_[0]], list[support.x4_[1]], list[idx]); - if (circs[3].x8_radiusSq < minRadA) { - if (PointInsideCircle(*list[support.x4_[2]], circs[3], intersect)) { - minRadA = circs[3].x8_radiusSq; - circIdxA = 3; - } else if (intersect < minRadB) { - minRadB = intersect; - circIdxB = 3; - } - } - - circs[4] = ExactCircle3(list[support.x4_[0]], list[support.x4_[2]], list[idx]); - if (circs[4].x8_radiusSq < minRadA) { - if (PointInsideCircle(*list[support.x4_[1]], circs[4], intersect)) { - minRadA = circs[4].x8_radiusSq; - circIdxA = 4; - } else if (intersect < minRadB) { - minRadB = intersect; - circIdxB = 4; - } - } - - circs[5] = ExactCircle3(list[support.x4_[1]], list[support.x4_[2]], list[idx]); - if (circs[5].x8_radiusSq < minRadA) { - if (PointInsideCircle(*list[support.x4_[0]], circs[5], intersect)) { - circIdxA = 5; - } else if (intersect < minRadB) { - circIdxB = 5; - } - } - - if (circIdxA == -1) - circIdxA = circIdxB; - - switch (circIdxA) { - case 0: - support.x0_ = 2; - support.x4_[1] = idx; - break; - case 1: - support.x0_ = 2; - support.x4_[0] = idx; - break; - case 2: - support.x0_ = 2; - support.x4_[0] = support.x4_[2]; - support.x4_[1] = idx; - break; - case 3: - support.x4_[2] = idx; - break; - case 4: - support.x4_[1] = idx; - break; - case 5: - support.x4_[0] = idx; - break; - default: - break; - } - - return circs[circIdxA]; -} - -typedef Circle2 (*FSupport)(int idx, const zeus::CVector2f** list, Support& support); -static const FSupport SupportFuncs[] = {nullptr, UpdateSupport1, UpdateSupport2, UpdateSupport3}; - -static Circle MinCircle(const std::vector& coords) { - Circle2 ret = {}; - if (coords.size() >= 1) { - std::unique_ptr randArr(new const zeus::CVector2f*[coords.size()]); - for (size_t i = 0; i < coords.size(); ++i) - randArr[i] = &coords[i]; - for (int i = coords.size() - 1; i >= 0; --i) { - int shuf = rand() % (i + 1); - if (shuf != i) - std::swap(randArr[i], randArr[shuf]); - } - ret = ExactCircle1(randArr[0]); - - Support support = {}; - support.x0_ = 1; - for (size_t i = 1; i < coords.size();) { - bool broke = false; - for (int j = 0; j < support.x0_; ++j) { - if ((*randArr[i] - *randArr[support.x4_[j]]).magSquared() < 0.01f) { - broke = true; - break; - } - } - float intersect; - if (!broke && !PointInsideCircle(*randArr[i], ret, intersect)) { - Circle2 circ = SupportFuncs[support.x0_](i, randArr.get(), support); - if (circ.x8_radiusSq > ret.x8_radiusSq) { - i = 0; - ret = circ; - continue; - } - } - ++i; - } - } - return ret; -} - void CMapWorld::RecalculateWorldSphere(const CMapWorldInfo& mwInfo, const IWorld& wld) { std::vector coords; coords.reserve(x0_areas.size() * 8); diff --git a/Runtime/AutoMapper/CMapWorldInfo.hpp b/Runtime/AutoMapper/CMapWorldInfo.hpp index ae18e2d3e..030d4fbca 100644 --- a/Runtime/AutoMapper/CMapWorldInfo.hpp +++ b/Runtime/AutoMapper/CMapWorldInfo.hpp @@ -18,7 +18,7 @@ class CMapWorldInfo { public: CMapWorldInfo() = default; - CMapWorldInfo(CBitStreamReader&, const CSaveWorld& saveWorld, CAssetId mlvlId); + explicit CMapWorldInfo(CBitStreamReader&, const CSaveWorld& saveWorld, CAssetId mlvlId); void PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, CAssetId mlvlId) const; bool IsMapped(TAreaId) const; void SetIsMapped(TAreaId, bool); diff --git a/Runtime/AutoMapper/CMappableObject.hpp b/Runtime/AutoMapper/CMappableObject.hpp index 53cde42bb..7a50cf8e5 100644 --- a/Runtime/AutoMapper/CMappableObject.hpp +++ b/Runtime/AutoMapper/CMappableObject.hpp @@ -63,7 +63,7 @@ private: struct DoorSurface { CMapSurfaceShader m_surface; CLineRenderer m_outline; - DoorSurface(boo::IGraphicsDataFactory::Context& ctx) + explicit DoorSurface(boo::IGraphicsDataFactory::Context& ctx) : m_surface(ctx, g_doorVbo, g_doorIbo) , m_outline(ctx, CLineRenderer::EPrimitiveMode::LineLoop, 5, nullptr, false, false, true) {} }; @@ -74,7 +74,7 @@ private: std::pair GetDoorColors(int idx, const CMapWorldInfo& mwInfo, float alpha) const; public: - CMappableObject(const void* buf); + explicit CMappableObject(const void* buf); CMappableObject(CMappableObject&&) = default; void PostConstruct(const void*); const zeus::CTransform& GetTransform() const { return x10_transform; } diff --git a/Runtime/CGameState.cpp b/Runtime/CGameState.cpp index d15b41bed..2bd9531f6 100644 --- a/Runtime/CGameState.cpp +++ b/Runtime/CGameState.cpp @@ -38,15 +38,17 @@ CWorldLayerState::CWorldLayerState(CBitStreamReader& reader, const CSaveWorld& s void CWorldLayerState::PutTo(CBitStreamWriter& writer) const { u32 totalLayerCount = 0; - for (int i = 0; i < x0_areaLayers.size(); ++i) - totalLayerCount += GetAreaLayerCount(i) - 1; + for (size_t i = 0; i < x0_areaLayers.size(); ++i) { + totalLayerCount += GetAreaLayerCount(s32(i)) - 1; + } writer.WriteEncoded(totalLayerCount, 10); - for (int i = 0; i < x0_areaLayers.size(); ++i) { - u32 count = GetAreaLayerCount(i); - for (u32 l = 1; l < count; ++l) - writer.WriteEncoded(IsLayerActive(i, l), 1); + for (size_t i = 0; i < x0_areaLayers.size(); ++i) { + const u32 count = GetAreaLayerCount(s32(i)); + for (u32 l = 1; l < count; ++l) { + writer.WriteEncoded(IsLayerActive(s32(i), s32(l)), 1); + } } } @@ -95,8 +97,9 @@ CGameState::GameFileStateInfo CGameState::LoadGameFileState(const u8* data) { CBitStreamReader stream(data, 4096); GameFileStateInfo ret; - for (u32 i = 0; i < 128; i++) + for (u32 i = 0; i < 128; i++) { stream.ReadEncoded(8); + } ret.x14_timestamp = stream.ReadEncoded(32); ret.x20_hardMode = stream.ReadEncoded(1); @@ -143,8 +146,9 @@ CGameState::CGameState(CBitStreamReader& stream, u32 saveIdx) : x20c_saveFileIdx x9c_transManager = std::make_shared(); x228_25_initPowerupsAtFirstSpawn = true; - for (u32 i = 0; i < 128; i++) - x0_[i] = stream.ReadEncoded(8); + for (bool& value : x0_) { + value = stream.ReadEncoded(8) != 0; + } stream.ReadEncoded(32); x228_24_hardMode = stream.ReadEncoded(1); @@ -205,9 +209,10 @@ void CGameState::WriteBackupBuf() { PutTo(w); } -void CGameState::PutTo(CBitStreamWriter& writer) const { - for (u32 i = 0; i < 128; i++) - writer.WriteEncoded(x0_[i], 8); +void CGameState::PutTo(CBitStreamWriter& writer) { + for (const bool value : x0_) { + writer.WriteEncoded(u32(value), 8); + } writer.WriteEncoded(CBasics::ToWiiTime(std::chrono::system_clock::now()) / CBasics::TICKS_PER_SECOND, 32); writer.WriteEncoded(x228_24_hardMode, 1); @@ -227,7 +232,7 @@ void CGameState::PutTo(CBitStreamWriter& writer) const { for (const auto& memWorld : memWorlds) { TLockedToken saveWorld = g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), memWorld.second.GetSaveWorldAssetId()}); - const CWorldState& wld = const_cast(*this).StateForWorld(memWorld.first); + const CWorldState& wld = StateForWorld(memWorld.first); wld.PutTo(writer, *saveWorld); } } diff --git a/Runtime/CGameState.hpp b/Runtime/CGameState.hpp index 5790af0d9..32349f8d9 100644 --- a/Runtime/CGameState.hpp +++ b/Runtime/CGameState.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -67,7 +68,7 @@ public: class CGameState { friend class CStateManager; - bool x0_[128] = {}; + std::array x0_{}; u32 x80_; CAssetId x84_mlvlId; std::vector x88_worldStates; @@ -116,7 +117,7 @@ public: void SetFileIdx(u32 idx) { x20c_saveFileIdx = idx; } void SetCardSerial(u64 serial) { x210_cardSerial = serial; } u64 GetCardSerial() const { return x210_cardSerial; } - void PutTo(CBitStreamWriter& writer) const; + void PutTo(CBitStreamWriter& writer); float GetHardModeDamageMultiplier() const; float GetHardModeWeaponMultiplier() const; void InitializeMemoryWorlds(); diff --git a/Runtime/CIOWin.hpp b/Runtime/CIOWin.hpp index 35639ef0e..43a3df3d8 100644 --- a/Runtime/CIOWin.hpp +++ b/Runtime/CIOWin.hpp @@ -21,8 +21,8 @@ public: virtual ~CIOWin() = default; virtual EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) = 0; virtual bool GetIsContinueDraw() const { return true; } - virtual void Draw() const {} - virtual void PreDraw() const {} + virtual void Draw() {} + virtual void PreDraw() {} std::string_view GetName() const { return x4_name; } size_t GetNameHash() const { return m_nameHash; } diff --git a/Runtime/CPlayMovieBase.hpp b/Runtime/CPlayMovieBase.hpp index 068ef615a..0c86a81f4 100644 --- a/Runtime/CPlayMovieBase.hpp +++ b/Runtime/CPlayMovieBase.hpp @@ -11,7 +11,7 @@ class CPlayMovieBase : public CIOWin { public: CPlayMovieBase(const char* iowName, const char* path) : CIOWin(iowName), x18_moviePlayer(path, 0.0, false, false) {} EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override { return EMessageReturn::Normal; } - void Draw() const override {} + void Draw() override {} }; } // namespace urde diff --git a/Runtime/CSortedLists.cpp b/Runtime/CSortedLists.cpp index e22c0166e..2a9ecbb99 100644 --- a/Runtime/CSortedLists.cpp +++ b/Runtime/CSortedLists.cpp @@ -30,17 +30,19 @@ void CSortedListManager::Reset() { } } -void CSortedListManager::AddToLinkedList(s16 nodeId, s16& headId, s16& tailId) const { +void CSortedListManager::AddToLinkedList(s16 nodeId, s16& headId, s16& tailId) { if (headId == -1) { - const_cast(AccessElement(x0_nodes, nodeId)).x28_next = headId; + AccessElement(x0_nodes, nodeId).x28_next = headId; headId = nodeId; tailId = nodeId; } else { - if (AccessElement(x0_nodes, nodeId).x28_next != -1) + if (AccessElement(x0_nodes, nodeId).x28_next != -1) { return; - if (tailId == nodeId) + } + if (tailId == nodeId) { return; - const_cast(AccessElement(x0_nodes, nodeId)).x28_next = headId; + } + AccessElement(x0_nodes, nodeId).x28_next = headId; headId = nodeId; } } @@ -114,19 +116,19 @@ void CSortedListManager::InsertInList(ESortedList list, SNode& node) { ++sl.x800_size; } -s16 CSortedListManager::FindInListUpper(ESortedList list, float val) const { +s16 CSortedListManager::FindInListUpper(ESortedList list, float value) const { const auto listIndex = static_cast(list); const SSortedList& sl = xb000_sortedLists[listIndex]; int idx = 0; for (int i = sl.x800_size; i > 0;) { - /* Binary search cycle to find index */ - if (!(val < AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + i / 2)).x4_box[listIndex])) { - /* Upper */ + // Binary search cycle to find index + if (!(value < AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + i / 2)).x4_box[listIndex])) { + // Upper idx = idx + i / 2 + 1; i = i - i / 2 - 1; } else { - /* Lower */ + // Lower i /= 2; } } @@ -134,19 +136,19 @@ s16 CSortedListManager::FindInListUpper(ESortedList list, float val) const { return idx; } -s16 CSortedListManager::FindInListLower(ESortedList list, float val) const { +s16 CSortedListManager::FindInListLower(ESortedList list, float value) const { const auto listIndex = static_cast(list); const SSortedList& sl = xb000_sortedLists[listIndex]; int idx = 0; for (int i = sl.x800_size; i > 0;) { - /* Binary search cycle to find index */ - if (AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + i / 2)).x4_box[listIndex] < val) { - /* Upper */ + // Binary search cycle to find index + if (AccessElement(x0_nodes, AccessElement(sl.x0_ids, idx + i / 2)).x4_box[listIndex] < value) { + // Upper idx = idx + i / 2 + 1; i = i - i / 2 - 1; } else { - /* Lower */ + // Lower i /= 2; } } @@ -233,48 +235,52 @@ s16 CSortedListManager::CalculateIntersections(ESortedList la, ESortedList lb, s void CSortedListManager::BuildNearList(rstl::reserved_vector& out, const zeus::CVector3f& pos, const zeus::CVector3f& dir, float mag, const CMaterialFilter& filter, - const CActor* actor) const { - if (mag == 0.f) + const CActor* actor) { + if (mag == 0.f) { mag = 8000.f; + } const zeus::CVector3f ray = dir * mag; const zeus::CVector3f sum = ray + pos; - zeus::CVector3f maxs(std::max(pos.x(), sum.x()), std::max(pos.y(), sum.y()), std::max(pos.z(), sum.z())); - zeus::CVector3f mins(std::min(sum.x(), pos.x()), std::min(sum.y(), pos.y()), std::min(sum.z(), pos.z())); + const zeus::CVector3f maxs(std::max(pos.x(), sum.x()), std::max(pos.y(), sum.y()), std::max(pos.z(), sum.z())); + const zeus::CVector3f mins(std::min(sum.x(), pos.x()), std::min(sum.y(), pos.y()), std::min(sum.z(), pos.z())); BuildNearList(out, zeus::CAABox(mins, maxs), filter, actor); } void CSortedListManager::BuildNearList(rstl::reserved_vector& out, const CActor& actor, - const zeus::CAABox& aabb) const { + const zeus::CAABox& aabb) { const CMaterialFilter& filter = actor.GetMaterialFilter(); - s16 id = const_cast(*this).ConstructIntersectionArray(aabb); + s16 id = ConstructIntersectionArray(aabb); while (id != -1) { - const SNode& node = AccessElement(x0_nodes, id); + SNode& node = AccessElement(x0_nodes, id); if (&actor != node.x0_actor && filter.Passes(node.x0_actor->GetMaterialList()) && - node.x0_actor->GetMaterialFilter().Passes(actor.GetMaterialList())) + node.x0_actor->GetMaterialFilter().Passes(actor.GetMaterialList())) { out.push_back(node.x0_actor->GetUniqueId()); + } id = node.x28_next; - const_cast(node).x28_next = -1; + node.x28_next = -1; } } void CSortedListManager::BuildNearList(rstl::reserved_vector& out, const zeus::CAABox& aabb, - const CMaterialFilter& filter, const CActor* actor) const { - s16 id = const_cast(*this).ConstructIntersectionArray(aabb); + const CMaterialFilter& filter, const CActor* actor) { + s16 id = ConstructIntersectionArray(aabb); while (id != -1) { - const SNode& node = AccessElement(x0_nodes, id); - if (actor != node.x0_actor && filter.Passes(node.x0_actor->GetMaterialList())) + SNode& node = AccessElement(x0_nodes, id); + if (actor != node.x0_actor && filter.Passes(node.x0_actor->GetMaterialList())) { out.push_back(node.x0_actor->GetUniqueId()); + } id = node.x28_next; - const_cast(node).x28_next = -1; + node.x28_next = -1; } } -void CSortedListManager::Remove(const CActor* act) { - SNode& node = AccessElement(x0_nodes, act->GetUniqueId().Value()); - if (!node.x2a_populated) +void CSortedListManager::Remove(const CActor* actor) { + SNode& node = AccessElement(x0_nodes, actor->GetUniqueId().Value()); + if (!node.x2a_populated) { return; + } RemoveFromList(ESortedList::MinX, node.x1c_selfIdxs[0]); RemoveFromList(ESortedList::MaxX, node.x1c_selfIdxs[3]); @@ -285,8 +291,8 @@ void CSortedListManager::Remove(const CActor* act) { node.x2a_populated = false; } -void CSortedListManager::Move(const CActor* act, const zeus::CAABox& aabb) { - SNode& node = AccessElement(x0_nodes, act->GetUniqueId().Value()); +void CSortedListManager::Move(const CActor* actor, const zeus::CAABox& aabb) { + SNode& node = AccessElement(x0_nodes, actor->GetUniqueId().Value()); node.x4_box = aabb; MoveInList(ESortedList::MinX, node.x1c_selfIdxs[0]); @@ -297,14 +303,14 @@ void CSortedListManager::Move(const CActor* act, const zeus::CAABox& aabb) { MoveInList(ESortedList::MaxZ, node.x1c_selfIdxs[5]); } -void CSortedListManager::Insert(const CActor* act, const zeus::CAABox& aabb) { - SNode& node = AccessElement(x0_nodes, act->GetUniqueId().Value()); +void CSortedListManager::Insert(const CActor* actor, const zeus::CAABox& aabb) { + SNode& node = AccessElement(x0_nodes, actor->GetUniqueId().Value()); if (node.x2a_populated) { - Move(act, aabb); + Move(actor, aabb); return; } - SNode newNode(act, aabb); + SNode newNode(actor, aabb); InsertInList(ESortedList::MinX, newNode); InsertInList(ESortedList::MaxX, newNode); InsertInList(ESortedList::MinY, newNode); @@ -314,10 +320,11 @@ void CSortedListManager::Insert(const CActor* act, const zeus::CAABox& aabb) { node = newNode; } -bool CSortedListManager::ActorInLists(const CActor* act) const { - if (!act) +bool CSortedListManager::ActorInLists(const CActor* actor) const { + if (!actor) { return false; - const SNode& node = AccessElement(x0_nodes, act->GetUniqueId().Value()); + } + const SNode& node = AccessElement(x0_nodes, actor->GetUniqueId().Value()); return node.x2a_populated; } diff --git a/Runtime/CSortedLists.hpp b/Runtime/CSortedLists.hpp index f251ff662..ce7d49e4a 100644 --- a/Runtime/CSortedLists.hpp +++ b/Runtime/CSortedLists.hpp @@ -31,27 +31,27 @@ class CSortedListManager { std::array x0_nodes; std::array xb000_sortedLists; void Reset(); - void AddToLinkedList(s16 a, s16& b, s16& c) const; - void RemoveFromList(ESortedList, s16); - void MoveInList(ESortedList, s16); - void InsertInList(ESortedList, SNode& node); - s16 FindInListUpper(ESortedList, float) const; - s16 FindInListLower(ESortedList, float) const; - s16 ConstructIntersectionArray(const zeus::CAABox&); - s16 CalculateIntersections(ESortedList, ESortedList, s16, s16, s16, s16, ESortedList, ESortedList, ESortedList, - ESortedList, const zeus::CAABox&); + void AddToLinkedList(s16 nodeId, s16& headId, s16& tailId); + void RemoveFromList(ESortedList list, s16 idx); + void MoveInList(ESortedList list, s16 idx); + void InsertInList(ESortedList list, SNode& node); + s16 FindInListUpper(ESortedList list, float value) const; + s16 FindInListLower(ESortedList list, float value) const; + s16 ConstructIntersectionArray(const zeus::CAABox& aabb); + s16 CalculateIntersections(ESortedList la, ESortedList lb, s16 a, s16 b, s16 c, s16 d, ESortedList slA, + ESortedList slB, ESortedList slC, ESortedList slD, const zeus::CAABox& aabb); public: CSortedListManager(); - void BuildNearList(rstl::reserved_vector&, const zeus::CVector3f&, const zeus::CVector3f&, float, - const CMaterialFilter&, const CActor*) const; - void BuildNearList(rstl::reserved_vector&, const CActor&, const zeus::CAABox&) const; - void BuildNearList(rstl::reserved_vector&, const zeus::CAABox&, const CMaterialFilter&, - const CActor*) const; - void Remove(const CActor*); - void Move(const CActor* act, const zeus::CAABox& aabb); - void Insert(const CActor* act, const zeus::CAABox& aabb); - bool ActorInLists(const CActor* act) const; + void BuildNearList(rstl::reserved_vector& out, const zeus::CVector3f& pos, + const zeus::CVector3f& dir, float mag, const CMaterialFilter& filter, const CActor* actor); + void BuildNearList(rstl::reserved_vector& out, const CActor& actor, const zeus::CAABox& aabb); + void BuildNearList(rstl::reserved_vector& out, const zeus::CAABox& aabb, + const CMaterialFilter& filter, const CActor* actor); + void Remove(const CActor* actor); + void Move(const CActor* actor, const zeus::CAABox& aabb); + void Insert(const CActor* actor, const zeus::CAABox& aabb); + bool ActorInLists(const CActor* actor) const; }; } // namespace urde diff --git a/Runtime/CStateManager.hpp b/Runtime/CStateManager.hpp index 69717cd90..565a08efa 100644 --- a/Runtime/CStateManager.hpp +++ b/Runtime/CStateManager.hpp @@ -216,8 +216,8 @@ private: u32 xf94_ = 0; }; - CColoredQuadFilter m_deathWhiteout = {EFilterType::Add}; - CColoredQuadFilter m_escapeWhiteout = {EFilterType::Add}; + CColoredQuadFilter m_deathWhiteout{EFilterType::Add}; + CColoredQuadFilter m_escapeWhiteout{EFilterType::Add}; bool m_warping = false; void UpdateThermalVisor(); diff --git a/Runtime/Camera/CCameraManager.hpp b/Runtime/Camera/CCameraManager.hpp index 0bcf5c4c4..d3c2f2204 100644 --- a/Runtime/Camera/CCameraManager.hpp +++ b/Runtime/Camera/CCameraManager.hpp @@ -80,7 +80,7 @@ class CCameraManager { void EnterCinematic(CStateManager& mgr); public: - CCameraManager(TUniqueId curCameraId = kInvalidUniqueId); + explicit CCameraManager(TUniqueId curCameraId = kInvalidUniqueId); static float Aspect() { return 1.42f; } static float FarPlane() { return 750.0f; } diff --git a/Runtime/Camera/CCameraShakeData.hpp b/Runtime/Camera/CCameraShakeData.hpp index e425fa913..94e22cdbe 100644 --- a/Runtime/Camera/CCameraShakeData.hpp +++ b/Runtime/Camera/CCameraShakeData.hpp @@ -61,7 +61,7 @@ public: const CCameraShakerComponent& shaker1, const CCameraShakerComponent& shaker2, const CCameraShakerComponent& shaker3); CCameraShakeData(float duration, float magnitude); - CCameraShakeData(CInputStream&); + explicit CCameraShakeData(CInputStream&); static CCameraShakeData BuildLandingCameraShakeData(float duration, float magnitude); static CCameraShakeData BuildProjectileCameraShake(float duration, float magnitude); static CCameraShakeData BuildMissileCameraShake(float duration, float magnitude, float sfxDistance, diff --git a/Runtime/Camera/CCinematicCamera.cpp b/Runtime/Camera/CCinematicCamera.cpp index 505f2218e..fc98ad994 100644 --- a/Runtime/Camera/CCinematicCamera.cpp +++ b/Runtime/Camera/CCinematicCamera.cpp @@ -296,11 +296,11 @@ void CCinematicCamera::GenerateMoveOutofIntoPoints(bool outOfEye, CStateManager& behindDelta = -behindDelta; } for (int i = 0; i < 2; ++i) { - x188_viewPoints.push_back(behindPos); - x198_viewOrientations.push_back(q); - x1a8_viewPointArrivals.push_back(mgr.GetPlayer().GetUniqueId()); - x1b8_targets.push_back(eyePos); - x1c8_targetArrivals.push_back(kInvalidUniqueId); + x188_viewPoints.emplace_back(behindPos); + x198_viewOrientations.emplace_back(q); + x1a8_viewPointArrivals.emplace_back(mgr.GetPlayer().GetUniqueId()); + x1b8_targets.emplace_back(eyePos); + x1c8_targetArrivals.emplace_back(kInvalidUniqueId); behindPos += behindDelta; } CalculateMoveOutofIntoEyePosition(outOfEye, mgr); diff --git a/Runtime/Camera/CInterpolationCamera.hpp b/Runtime/Camera/CInterpolationCamera.hpp index 260b47203..395efe605 100644 --- a/Runtime/Camera/CInterpolationCamera.hpp +++ b/Runtime/Camera/CInterpolationCamera.hpp @@ -26,7 +26,7 @@ class CInterpolationCamera : public CGameCamera { float maxTime, float curTime); public: - CInterpolationCamera(TUniqueId uid, const zeus::CTransform& xf); + explicit CInterpolationCamera(TUniqueId uid, const zeus::CTransform& xf); void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void ProcessInput(const CFinalInput&, CStateManager& mgr) override; diff --git a/Runtime/Character/CAdditiveAnimPlayback.hpp b/Runtime/Character/CAdditiveAnimPlayback.hpp index 582bbeb48..637a287d8 100644 --- a/Runtime/Character/CAdditiveAnimPlayback.hpp +++ b/Runtime/Character/CAdditiveAnimPlayback.hpp @@ -20,7 +20,7 @@ public: x4_fadeOutDur = in.readFloatBig(); } CAdditiveAnimationInfo() = default; - CAdditiveAnimationInfo(CInputStream& in) { read(in); } + explicit CAdditiveAnimationInfo(CInputStream& in) { read(in); } float GetFadeInDuration() const { return x0_fadeInDur; } float GetFadeOutDuration() const { return x4_fadeOutDur; } }; diff --git a/Runtime/Character/CAllFormatsAnimSource.hpp b/Runtime/Character/CAllFormatsAnimSource.hpp index 862c7bd4f..b8a60f9e8 100644 --- a/Runtime/Character/CAllFormatsAnimSource.hpp +++ b/Runtime/Character/CAllFormatsAnimSource.hpp @@ -26,7 +26,7 @@ class CAnimFormatUnion { static void SubConstruct(u8* storage, EAnimFormat fmt, CInputStream& in, IObjectStore& store); public: - CAnimFormatUnion(CInputStream& in, IObjectStore& store); + explicit CAnimFormatUnion(CInputStream& in, IObjectStore& store); ~CAnimFormatUnion(); EAnimFormat GetFormat() const { return x0_format; } CAnimSource& GetAsCAnimSource() { return *reinterpret_cast(x4_storage); } @@ -40,7 +40,7 @@ class CAllFormatsAnimSource : public CAnimFormatUnion { SObjectTag x74_tag; public: - CAllFormatsAnimSource(CInputStream& in, IObjectStore& store, const SObjectTag& tag); + explicit CAllFormatsAnimSource(CInputStream& in, IObjectStore& store, const SObjectTag& tag); static std::shared_ptr GetNewReader(const TLockedToken& tok, const CCharAnimTime& startTime); }; diff --git a/Runtime/Character/CAnimCharacterSet.hpp b/Runtime/Character/CAnimCharacterSet.hpp index 749abeb31..94bba47cf 100644 --- a/Runtime/Character/CAnimCharacterSet.hpp +++ b/Runtime/Character/CAnimCharacterSet.hpp @@ -12,7 +12,7 @@ class CAnimCharacterSet { CAnimationSet x1c_animationSet; public: - CAnimCharacterSet(CInputStream& in); + explicit CAnimCharacterSet(CInputStream& in); const CCharacterSet& GetCharacterSet() const { return x4_characterSet; } const CAnimationSet& GetAnimationSet() const { return x1c_animationSet; } }; diff --git a/Runtime/Character/CAnimData.cpp b/Runtime/Character/CAnimData.cpp index c621ed647..f201b064b 100644 --- a/Runtime/Character/CAnimData.cpp +++ b/Runtime/Character/CAnimData.cpp @@ -56,7 +56,7 @@ CAnimData::CAnimData(CAssetId id, const CCharacterInfo& character, int defaultAn , x204_charIdx(charIdx) , x208_defaultAnim(defaultAnim) , x224_pose(layout->GetSegIdList().GetList().size()) -, x2fc_poseBuilder(layout) +, x2fc_poseBuilder(CLayoutDescription{layout}) , m_drawInstCount(drawInstCount) { x220_25_loop = loop; @@ -72,7 +72,7 @@ CAnimData::CAnimData(CAssetId id, const CCharacterInfo& character, int defaultAn x108_aabb = xd8_modelData->GetModel()->GetAABB(); x120_particleDB.CacheParticleDesc(xc_charInfo.GetParticleResData()); - CHierarchyPoseBuilder pb(xcc_layoutData); + CHierarchyPoseBuilder pb(CLayoutDescription{xcc_layoutData}); pb.BuildNoScale(x224_pose); x220_30_poseBuilt = true; diff --git a/Runtime/Character/CAnimData.hpp b/Runtime/Character/CAnimData.hpp index 1bfe21217..2ea18709b 100644 --- a/Runtime/Character/CAnimData.hpp +++ b/Runtime/Character/CAnimData.hpp @@ -251,7 +251,7 @@ public: s32 GetCharacterIndex() const { return x204_charIdx; } u16 GetDefaultAnimation() const { return x208_defaultAnim; } - TLockedToken& IceModel() { return xe4_iceModelData; } + TLockedToken& GetIceModel() { return xe4_iceModelData; } const TLockedToken& GetIceModel() const { return xe4_iceModelData; } void SetParticleLightIdx(s32 idx) { x21c_particleLightIdx = idx; } diff --git a/Runtime/Character/CAnimPOIData.hpp b/Runtime/Character/CAnimPOIData.hpp index 84514f503..577bc688c 100644 --- a/Runtime/Character/CAnimPOIData.hpp +++ b/Runtime/Character/CAnimPOIData.hpp @@ -19,7 +19,7 @@ class CAnimPOIData { std::vector x34_soundNodes; public: - CAnimPOIData(CInputStream& in); + explicit CAnimPOIData(CInputStream& in); const std::vector& GetBoolPOIStream() const { return x4_boolNodes; } const std::vector& GetInt32POIStream() const { return x14_int32Nodes; } diff --git a/Runtime/Character/CAnimSource.hpp b/Runtime/Character/CAnimSource.hpp index 7e093c747..26dc312cb 100644 --- a/Runtime/Character/CAnimSource.hpp +++ b/Runtime/Character/CAnimSource.hpp @@ -39,7 +39,7 @@ public: struct CRotationAndOffsetVectors { std::vector x0_rotations; std::vector x10_offsets; - CRotationAndOffsetVectors(CInputStream& in); + explicit CRotationAndOffsetVectors(CInputStream& in); }; u32 GetFrameSizeInBytes() const; RotationAndOffsetStorage(const CRotationAndOffsetVectors& vectors, u32 frameCount); @@ -61,7 +61,7 @@ class CAnimSource { void CalcAverageVelocity(); public: - CAnimSource(CInputStream& in, IObjectStore& store); + explicit CAnimSource(CInputStream& in, IObjectStore& store); void GetSegStatementSet(const CSegIdList& list, CSegStatementSet& set, const CCharAnimTime& time) const; diff --git a/Runtime/Character/CAnimSourceReader.cpp b/Runtime/Character/CAnimSourceReader.cpp index e9c194da7..29c01fb9e 100644 --- a/Runtime/Character/CAnimSourceReader.cpp +++ b/Runtime/Character/CAnimSourceReader.cpp @@ -172,7 +172,7 @@ u32 CAnimSourceReaderBase::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOI return 0; } -bool CAnimSourceReaderBase::VGetBoolPOIState(const char* name) const { +bool CAnimSourceReaderBase::VGetBoolPOIState(std::string_view name) const { const auto iter = std::find_if(x24_boolStates.cbegin(), x24_boolStates.cend(), [name](const auto& entry) { return entry.first == name; }); @@ -183,7 +183,7 @@ bool CAnimSourceReaderBase::VGetBoolPOIState(const char* name) const { return iter->second; } -s32 CAnimSourceReaderBase::VGetInt32POIState(const char* name) const { +s32 CAnimSourceReaderBase::VGetInt32POIState(std::string_view name) const { const auto iter = std::find_if(x34_int32States.cbegin(), x34_int32States.cend(), [name](const auto& entry) { return entry.first == name; }); @@ -194,7 +194,7 @@ s32 CAnimSourceReaderBase::VGetInt32POIState(const char* name) const { return iter->second; } -CParticleData::EParentedMode CAnimSourceReaderBase::VGetParticlePOIState(const char* name) const { +CParticleData::EParentedMode CAnimSourceReaderBase::VGetParticlePOIState(std::string_view name) const { const auto iter = std::find_if(x44_particleStates.cbegin(), x44_particleStates.cend(), [name](const auto& entry) { return entry.first == name; }); diff --git a/Runtime/Character/CAnimSourceReader.hpp b/Runtime/Character/CAnimSourceReader.hpp index 5b55e5fb7..2628f3655 100644 --- a/Runtime/Character/CAnimSourceReader.hpp +++ b/Runtime/Character/CAnimSourceReader.hpp @@ -68,9 +68,9 @@ public: u32) const override; u32 VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator, u32) const override; - bool VGetBoolPOIState(const char* name) const override; - s32 VGetInt32POIState(const char* name) const override; - CParticleData::EParentedMode VGetParticlePOIState(const char* name) const override; + bool VGetBoolPOIState(std::string_view name) const override; + s32 VGetInt32POIState(std::string_view name) const override; + CParticleData::EParentedMode VGetParticlePOIState(std::string_view name) const override; using IAnimReader::VGetOffset; virtual zeus::CVector3f VGetOffset(const CSegId& seg, const CCharAnimTime& b) const = 0; diff --git a/Runtime/Character/CAnimTreeAnimReaderContainer.cpp b/Runtime/Character/CAnimTreeAnimReaderContainer.cpp index a7105b6ab..f508095a8 100644 --- a/Runtime/Character/CAnimTreeAnimReaderContainer.cpp +++ b/Runtime/Character/CAnimTreeAnimReaderContainer.cpp @@ -58,15 +58,15 @@ u32 CAnimTreeAnimReaderContainer::VGetSoundPOIList(const CCharAnimTime& time, CS return x14_reader->GetSoundPOIList(time, listOut, capacity, iterator, unk); } -bool CAnimTreeAnimReaderContainer::VGetBoolPOIState(const char* name) const { +bool CAnimTreeAnimReaderContainer::VGetBoolPOIState(std::string_view name) const { return x14_reader->VGetBoolPOIState(name); } -s32 CAnimTreeAnimReaderContainer::VGetInt32POIState(const char* name) const { - return x14_reader->VGetBoolPOIState(name); +s32 CAnimTreeAnimReaderContainer::VGetInt32POIState(std::string_view name) const { + return x14_reader->VGetInt32POIState(name); } -CParticleData::EParentedMode CAnimTreeAnimReaderContainer::VGetParticlePOIState(const char* name) const { +CParticleData::EParentedMode CAnimTreeAnimReaderContainer::VGetParticlePOIState(std::string_view name) const { return x14_reader->VGetParticlePOIState(name); } diff --git a/Runtime/Character/CAnimTreeAnimReaderContainer.hpp b/Runtime/Character/CAnimTreeAnimReaderContainer.hpp index aec904573..5df66319e 100644 --- a/Runtime/Character/CAnimTreeAnimReaderContainer.hpp +++ b/Runtime/Character/CAnimTreeAnimReaderContainer.hpp @@ -37,9 +37,9 @@ public: u32) const override; u32 VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator, u32) const override; - bool VGetBoolPOIState(const char*) const override; - s32 VGetInt32POIState(const char*) const override; - CParticleData::EParentedMode VGetParticlePOIState(const char*) const override; + bool VGetBoolPOIState(std::string_view name) const override; + s32 VGetInt32POIState(std::string_view name) const override; + CParticleData::EParentedMode VGetParticlePOIState(std::string_view name) const override; void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const override; void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const override; std::unique_ptr VClone() const override; diff --git a/Runtime/Character/CAnimTreeDoubleChild.cpp b/Runtime/Character/CAnimTreeDoubleChild.cpp index 5c3b1e69f..bd401390a 100644 --- a/Runtime/Character/CAnimTreeDoubleChild.cpp +++ b/Runtime/Character/CAnimTreeDoubleChild.cpp @@ -101,11 +101,11 @@ u32 CAnimTreeDoubleChild::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOIN return newCapacity; } -bool CAnimTreeDoubleChild::VGetBoolPOIState(const char* name) const { return x18_b->VGetBoolPOIState(name); } +bool CAnimTreeDoubleChild::VGetBoolPOIState(std::string_view name) const { return x18_b->VGetBoolPOIState(name); } -s32 CAnimTreeDoubleChild::VGetInt32POIState(const char* name) const { return x18_b->VGetBoolPOIState(name); } +s32 CAnimTreeDoubleChild::VGetInt32POIState(std::string_view name) const { return x18_b->VGetInt32POIState(name); } -CParticleData::EParentedMode CAnimTreeDoubleChild::VGetParticlePOIState(const char* name) const { +CParticleData::EParentedMode CAnimTreeDoubleChild::VGetParticlePOIState(std::string_view name) const { return x18_b->VGetParticlePOIState(name); } diff --git a/Runtime/Character/CAnimTreeDoubleChild.hpp b/Runtime/Character/CAnimTreeDoubleChild.hpp index 22c4b36e2..aa54957c9 100644 --- a/Runtime/Character/CAnimTreeDoubleChild.hpp +++ b/Runtime/Character/CAnimTreeDoubleChild.hpp @@ -41,9 +41,9 @@ public: u32) const override; u32 VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator, u32) const override; - bool VGetBoolPOIState(const char* name) const override; - s32 VGetInt32POIState(const char* name) const override; - CParticleData::EParentedMode VGetParticlePOIState(const char* name) const override; + bool VGetBoolPOIState(std::string_view name) const override; + s32 VGetInt32POIState(std::string_view name) const override; + CParticleData::EParentedMode VGetParticlePOIState(std::string_view name) const override; void VSetPhase(float) override; SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const override; u32 Depth() const override; diff --git a/Runtime/Character/CAnimTreeNode.hpp b/Runtime/Character/CAnimTreeNode.hpp index 61906c067..d18b94eb9 100644 --- a/Runtime/Character/CAnimTreeNode.hpp +++ b/Runtime/Character/CAnimTreeNode.hpp @@ -14,7 +14,7 @@ protected: std::string x4_name; public: - CAnimTreeNode(std::string_view name) : x4_name(name) {} + explicit CAnimTreeNode(std::string_view name) : x4_name(name) {} bool IsCAnimTreeNode() const override { return true; } static std::shared_ptr Cast(std::unique_ptr&& ptr) { if (ptr->IsCAnimTreeNode()) diff --git a/Runtime/Character/CAnimTreeSingleChild.cpp b/Runtime/Character/CAnimTreeSingleChild.cpp index a7c9bf851..258225459 100644 --- a/Runtime/Character/CAnimTreeSingleChild.cpp +++ b/Runtime/Character/CAnimTreeSingleChild.cpp @@ -35,11 +35,11 @@ u32 CAnimTreeSingleChild::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOIN return x14_child->GetSoundPOIList(time, listOut, capacity, iterator, unk); } -bool CAnimTreeSingleChild::VGetBoolPOIState(const char* name) const { return x14_child->VGetBoolPOIState(name); } +bool CAnimTreeSingleChild::VGetBoolPOIState(std::string_view name) const { return x14_child->VGetBoolPOIState(name); } -s32 CAnimTreeSingleChild::VGetInt32POIState(const char* name) const { return x14_child->VGetInt32POIState(name); } +s32 CAnimTreeSingleChild::VGetInt32POIState(std::string_view name) const { return x14_child->VGetInt32POIState(name); } -CParticleData::EParentedMode CAnimTreeSingleChild::VGetParticlePOIState(const char* name) const { +CParticleData::EParentedMode CAnimTreeSingleChild::VGetParticlePOIState(std::string_view name) const { return x14_child->VGetParticlePOIState(name); } diff --git a/Runtime/Character/CAnimTreeSingleChild.hpp b/Runtime/Character/CAnimTreeSingleChild.hpp index 1158de80e..801ef9e97 100644 --- a/Runtime/Character/CAnimTreeSingleChild.hpp +++ b/Runtime/Character/CAnimTreeSingleChild.hpp @@ -27,9 +27,9 @@ public: u32) const override; u32 VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator, u32) const override; - bool VGetBoolPOIState(const char* name) const override; - s32 VGetInt32POIState(const char* name) const override; - CParticleData::EParentedMode VGetParticlePOIState(const char* name) const override; + bool VGetBoolPOIState(std::string_view name) const override; + s32 VGetInt32POIState(std::string_view name) const override; + CParticleData::EParentedMode VGetParticlePOIState(std::string_view name) const override; void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const override; void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const override; void VSetPhase(float) override; diff --git a/Runtime/Character/CAnimTreeTimeScale.cpp b/Runtime/Character/CAnimTreeTimeScale.cpp index dbf5a754f..c1651e289 100644 --- a/Runtime/Character/CAnimTreeTimeScale.cpp +++ b/Runtime/Character/CAnimTreeTimeScale.cpp @@ -99,11 +99,11 @@ u32 CAnimTreeTimeScale::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINod return ret; } -bool CAnimTreeTimeScale::VGetBoolPOIState(const char* name) const { return x14_child->VGetBoolPOIState(name); } +bool CAnimTreeTimeScale::VGetBoolPOIState(std::string_view name) const { return x14_child->VGetBoolPOIState(name); } -s32 CAnimTreeTimeScale::VGetInt32POIState(const char* name) const { return x14_child->VGetInt32POIState(name); } +s32 CAnimTreeTimeScale::VGetInt32POIState(std::string_view name) const { return x14_child->VGetInt32POIState(name); } -CParticleData::EParentedMode CAnimTreeTimeScale::VGetParticlePOIState(const char* name) const { +CParticleData::EParentedMode CAnimTreeTimeScale::VGetParticlePOIState(std::string_view name) const { return x14_child->VGetParticlePOIState(name); } diff --git a/Runtime/Character/CAnimTreeTimeScale.hpp b/Runtime/Character/CAnimTreeTimeScale.hpp index a4ba6d016..7439b55de 100644 --- a/Runtime/Character/CAnimTreeTimeScale.hpp +++ b/Runtime/Character/CAnimTreeTimeScale.hpp @@ -34,9 +34,9 @@ public: u32) const override; u32 VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator, u32) const override; - bool VGetBoolPOIState(const char* name) const override; - s32 VGetInt32POIState(const char* name) const override; - CParticleData::EParentedMode VGetParticlePOIState(const char* name) const override; + bool VGetBoolPOIState(std::string_view name) const override; + s32 VGetInt32POIState(std::string_view name) const override; + CParticleData::EParentedMode VGetParticlePOIState(std::string_view name) const override; CAnimTreeEffectiveContribution VGetContributionOfHighestInfluence() const override; std::shared_ptr VGetBestUnblendedChild() const override; diff --git a/Runtime/Character/CAnimation.hpp b/Runtime/Character/CAnimation.hpp index 228284130..be592bbb4 100644 --- a/Runtime/Character/CAnimation.hpp +++ b/Runtime/Character/CAnimation.hpp @@ -14,7 +14,7 @@ class CAnimation { std::shared_ptr x10_anim; public: - CAnimation(CInputStream& in); + explicit CAnimation(CInputStream& in); const std::shared_ptr& GetMetaAnim() const { return x10_anim; } std::string_view GetMetaAnimName() const { return x0_name; } }; diff --git a/Runtime/Character/CAnimationDatabaseGame.hpp b/Runtime/Character/CAnimationDatabaseGame.hpp index 9d28a708c..f4051b01a 100644 --- a/Runtime/Character/CAnimationDatabaseGame.hpp +++ b/Runtime/Character/CAnimationDatabaseGame.hpp @@ -12,7 +12,7 @@ class CAnimationDatabaseGame final : public CAnimationDatabase { std::vector> x10_anims; public: - CAnimationDatabaseGame(const std::vector& anims); + explicit CAnimationDatabaseGame(const std::vector& anims); const std::shared_ptr& GetMetaAnim(s32 idx) const override; u32 GetNumMetaAnims() const override; const char* GetMetaAnimName(s32 idx) const override; diff --git a/Runtime/Character/CAnimationSet.hpp b/Runtime/Character/CAnimationSet.hpp index c7b58929b..55ae41fba 100644 --- a/Runtime/Character/CAnimationSet.hpp +++ b/Runtime/Character/CAnimationSet.hpp @@ -24,7 +24,7 @@ class CAnimationSet { std::vector> x50_animRes; public: - CAnimationSet(CInputStream& in); + explicit CAnimationSet(CInputStream& in); const std::vector& GetAnimations() const { return x4_animations; } const std::vector& GetTransitions() const { return x14_transitions; } diff --git a/Runtime/Character/CBodyState.hpp b/Runtime/Character/CBodyState.hpp index ed8a97ace..24f74799f 100644 --- a/Runtime/Character/CBodyState.hpp +++ b/Runtime/Character/CBodyState.hpp @@ -105,7 +105,7 @@ class CBSLieOnGround : public CBodyState { pas::EAnimationState GetBodyStateTransition(float dt, CBodyController& bc) const; public: - CBSLieOnGround(CActor& actor); + explicit CBSLieOnGround(CActor& actor); void Start(CBodyController& bc, CStateManager& mgr) override; pas::EAnimationState UpdateBody(float dt, CBodyController& bc, CStateManager& mgr) override; void Shutdown(CBodyController& bc) override; @@ -371,7 +371,7 @@ protected: } public: - CBSBiPedLocomotion(CActor& actor); + explicit CBSBiPedLocomotion(CActor& actor); bool IsMoving() const override { return x3c4_anim != pas::ELocomotionAnim::Idle; } void Start(CBodyController& bc, CStateManager& mgr) override; pas::EAnimationState UpdateBody(float dt, CBodyController& bc, CStateManager& mgr) override; @@ -384,7 +384,7 @@ class CBSFlyerLocomotion : public CBSBiPedLocomotion { bool x3cc_pitchable; public: - CBSFlyerLocomotion(CActor& actor, bool pitchable); + explicit CBSFlyerLocomotion(CActor& actor, bool pitchable); bool IsPitchable() const override { return x3cc_pitchable; } float ApplyLocomotionPhysics(float dt, CBodyController& bc) override; virtual bool IsBackPedal(CBodyController& bc) const { return false; } @@ -392,13 +392,13 @@ public: class CBSWallWalkerLocomotion : public CBSBiPedLocomotion { public: - CBSWallWalkerLocomotion(CActor& actor); + explicit CBSWallWalkerLocomotion(CActor& actor); float ApplyLocomotionPhysics(float dt, CBodyController& bc) override; }; class CBSNewFlyerLocomotion : public CBSBiPedLocomotion { public: - CBSNewFlyerLocomotion(CActor& actor); + explicit CBSNewFlyerLocomotion(CActor& actor); float ApplyLocomotionPhysics(float dt, CBodyController& bc) override; float UpdateLocomotionAnimation(float dt, float velMag, CBodyController& bc, bool init) override; }; @@ -408,7 +408,7 @@ class CBSRestrictedLocomotion : public CBSLocomotion { pas::ELocomotionAnim x44_anim = pas::ELocomotionAnim::Invalid; public: - CBSRestrictedLocomotion(CActor& actor); + explicit CBSRestrictedLocomotion(CActor& actor); bool IsMoving() const override { return false; } float GetLocomotionSpeed(pas::ELocomotionType type, pas::ELocomotionAnim anim) const override { return 0.f; } float UpdateLocomotionAnimation(float dt, float velMag, CBodyController& bc, bool init) override; @@ -416,7 +416,7 @@ public: class CBSRestrictedFlyerLocomotion : public CBSRestrictedLocomotion { public: - CBSRestrictedFlyerLocomotion(CActor& actor); + explicit CBSRestrictedFlyerLocomotion(CActor& actor); float ApplyLocomotionPhysics(float dt, CBodyController& bc) override; }; } // namespace urde diff --git a/Runtime/Character/CBodyStateCmdMgr.hpp b/Runtime/Character/CBodyStateCmdMgr.hpp index 717c686cd..a6ba84eef 100644 --- a/Runtime/Character/CBodyStateCmdMgr.hpp +++ b/Runtime/Character/CBodyStateCmdMgr.hpp @@ -13,7 +13,7 @@ class CBodyStateCmd { public: virtual ~CBodyStateCmd() = default; - CBodyStateCmd(EBodyStateCmd cmd) : x4_cmd(cmd) {} + explicit CBodyStateCmd(EBodyStateCmd cmd) : x4_cmd(cmd) {} EBodyStateCmd GetCommandId() const { return x4_cmd; } }; @@ -23,10 +23,11 @@ class CBCMeleeAttackCmd : public CBodyStateCmd { bool x18_hasTargetPos = false; public: - CBCMeleeAttackCmd() : CBodyStateCmd(EBodyStateCmd::MeleeAttack) {} - CBCMeleeAttackCmd(pas::ESeverity severity) : CBodyStateCmd(EBodyStateCmd::MeleeAttack), x8_severity(severity) {} - CBCMeleeAttackCmd(pas::ESeverity severity, const zeus::CVector3f& target) : CBodyStateCmd(EBodyStateCmd::MeleeAttack) - , x8_severity(severity), xc_targetPos(target), x18_hasTargetPos(true) {} + explicit CBCMeleeAttackCmd() : CBodyStateCmd(EBodyStateCmd::MeleeAttack) {} + explicit CBCMeleeAttackCmd(pas::ESeverity severity) + : CBodyStateCmd(EBodyStateCmd::MeleeAttack), x8_severity(severity) {} + explicit CBCMeleeAttackCmd(pas::ESeverity severity, const zeus::CVector3f& target) + : CBodyStateCmd(EBodyStateCmd::MeleeAttack), x8_severity(severity), xc_targetPos(target), x18_hasTargetPos(true) {} pas::ESeverity GetAttackSeverity() const { return x8_severity; } bool HasAttackTargetPos() const { return x18_hasTargetPos; } const zeus::CVector3f& GetAttackTargetPos() const { return xc_targetPos; } @@ -38,8 +39,8 @@ class CBCProjectileAttackCmd : public CBodyStateCmd { bool x18_blendAnims = false; public: - CBCProjectileAttackCmd() : CBodyStateCmd(EBodyStateCmd::ProjectileAttack) {} - CBCProjectileAttackCmd(pas::ESeverity severity, const zeus::CVector3f& vec, bool b) + explicit CBCProjectileAttackCmd() : CBodyStateCmd(EBodyStateCmd::ProjectileAttack) {} + explicit CBCProjectileAttackCmd(pas::ESeverity severity, const zeus::CVector3f& vec, bool b) : CBodyStateCmd(EBodyStateCmd::ProjectileAttack), x8_severity(severity), xc_target(vec), x18_blendAnims(b) {} pas::ESeverity GetAttackSeverity() const { return x8_severity; } const zeus::CVector3f& GetTargetPosition() const { return xc_target; } @@ -51,8 +52,8 @@ class CBCStepCmd : public CBodyStateCmd { pas::EStepType xc_type = pas::EStepType::Normal; public: - CBCStepCmd() : CBodyStateCmd(EBodyStateCmd::Step) {} - CBCStepCmd(pas::EStepDirection dir, pas::EStepType type) + explicit CBCStepCmd() : CBodyStateCmd(EBodyStateCmd::Step) {} + explicit CBCStepCmd(pas::EStepDirection dir, pas::EStepType type) : CBodyStateCmd(EBodyStateCmd::Step), x8_dir(dir), xc_type(type) {} pas::EStepDirection GetStepDirection() const { return x8_dir; } pas::EStepType GetStepType() const { return xc_type; } @@ -66,16 +67,16 @@ class CBCJumpCmd : public CBodyStateCmd { bool x24_25_startInJumpLoop : 1; public: - CBCJumpCmd() : CBodyStateCmd(EBodyStateCmd::Jump) { + explicit CBCJumpCmd() : CBodyStateCmd(EBodyStateCmd::Jump) { x24_24_wallJump = false; x24_25_startInJumpLoop = false; } - CBCJumpCmd(const zeus::CVector3f& wp1, pas::EJumpType type, bool startInLoop = false) + explicit CBCJumpCmd(const zeus::CVector3f& wp1, pas::EJumpType type, bool startInLoop = false) : CBodyStateCmd(EBodyStateCmd::Jump), x8_type(type), xc_waypoint1(wp1) { x24_24_wallJump = false; x24_25_startInJumpLoop = startInLoop; } - CBCJumpCmd(const zeus::CVector3f& wp1, const zeus::CVector3f& wp2, pas::EJumpType type) + explicit CBCJumpCmd(const zeus::CVector3f& wp1, const zeus::CVector3f& wp2, pas::EJumpType type) : CBodyStateCmd(EBodyStateCmd::Jump), x8_type(type), xc_waypoint1(wp1), x18_waypoint2(wp2) { x24_24_wallJump = true; x24_25_startInJumpLoop = false; @@ -95,22 +96,22 @@ class CBCGenerateCmd : public CBodyStateCmd { bool x1c_25_overrideAnim : 1; public: - CBCGenerateCmd() : CBodyStateCmd(EBodyStateCmd::Generate) { + explicit CBCGenerateCmd() : CBodyStateCmd(EBodyStateCmd::Generate) { x1c_24_targetTransform = false; x1c_25_overrideAnim = false; } - CBCGenerateCmd(pas::EGenerateType type) + explicit CBCGenerateCmd(pas::EGenerateType type) : CBodyStateCmd(EBodyStateCmd::Generate), x8_type(type) { x1c_24_targetTransform = false; x1c_25_overrideAnim = false; } - CBCGenerateCmd(pas::EGenerateType type, s32 animId) + explicit CBCGenerateCmd(pas::EGenerateType type, s32 animId) : CBodyStateCmd(EBodyStateCmd::Generate), x8_type(type), x18_animId(animId) { x1c_24_targetTransform = false; x1c_25_overrideAnim = animId != -1; } - CBCGenerateCmd(pas::EGenerateType type, const zeus::CVector3f& vec, bool targetTransform = false, - bool overrideAnim = false) + explicit CBCGenerateCmd(pas::EGenerateType type, const zeus::CVector3f& vec, bool targetTransform = false, + bool overrideAnim = false) : CBodyStateCmd(EBodyStateCmd::Generate), x8_type(type), xc_targetPos(vec) { x1c_24_targetTransform = targetTransform; x1c_25_overrideAnim = overrideAnim; @@ -127,8 +128,8 @@ class CBCKnockBackCmd : public CBodyStateCmd { pas::ESeverity x14_severity = pas::ESeverity::Invalid; public: - CBCKnockBackCmd() : CBodyStateCmd(EBodyStateCmd::KnockBack) {} - CBCKnockBackCmd(const zeus::CVector3f& vec, pas::ESeverity severity) + explicit CBCKnockBackCmd() : CBodyStateCmd(EBodyStateCmd::KnockBack) {} + explicit CBCKnockBackCmd(const zeus::CVector3f& vec, pas::ESeverity severity) : CBodyStateCmd(EBodyStateCmd::KnockBack), x8_dir(vec), x14_severity(severity) {} const zeus::CVector3f& GetHitDirection() const { return x8_dir; } pas::ESeverity GetHitSeverity() const { return x14_severity; } @@ -140,8 +141,8 @@ class CBCHurledCmd : public CBodyStateCmd { bool x20_startInKnockLoop = false; public: - CBCHurledCmd() : CBodyStateCmd(EBodyStateCmd::Hurled) {} - CBCHurledCmd(const zeus::CVector3f& dir, const zeus::CVector3f& launchVel, bool startInLoop = false) + explicit CBCHurledCmd() : CBodyStateCmd(EBodyStateCmd::Hurled) {} + explicit CBCHurledCmd(const zeus::CVector3f& dir, const zeus::CVector3f& launchVel, bool startInLoop = false) : CBodyStateCmd(EBodyStateCmd::Hurled) , x8_direction(dir) , x14_launchVel(launchVel) @@ -156,8 +157,8 @@ class CBCGetupCmd : public CBodyStateCmd { pas::EGetupType x8_type = pas::EGetupType::Invalid; public: - CBCGetupCmd() : CBodyStateCmd(EBodyStateCmd::Getup) {} - CBCGetupCmd(pas::EGetupType type) : CBodyStateCmd(EBodyStateCmd::Getup), x8_type(type) {} + explicit CBCGetupCmd() : CBodyStateCmd(EBodyStateCmd::Getup) {} + explicit CBCGetupCmd(pas::EGetupType type) : CBodyStateCmd(EBodyStateCmd::Getup), x8_type(type) {} pas::EGetupType GetGetupType() const { return x8_type; } }; @@ -165,8 +166,8 @@ class CBCLoopReactionCmd : public CBodyStateCmd { pas::EReactionType x8_type = pas::EReactionType::Invalid; public: - CBCLoopReactionCmd() : CBodyStateCmd(EBodyStateCmd::LoopReaction) {} - CBCLoopReactionCmd(pas::EReactionType type) : CBodyStateCmd(EBodyStateCmd::LoopReaction), x8_type(type) {} + explicit CBCLoopReactionCmd() : CBodyStateCmd(EBodyStateCmd::LoopReaction) {} + explicit CBCLoopReactionCmd(pas::EReactionType type) : CBodyStateCmd(EBodyStateCmd::LoopReaction), x8_type(type) {} pas::EReactionType GetReactionType() const { return x8_type; } }; @@ -174,8 +175,8 @@ class CBCLoopHitReactionCmd : public CBodyStateCmd { pas::EReactionType x8_type = pas::EReactionType::Invalid; public: - CBCLoopHitReactionCmd() : CBodyStateCmd(EBodyStateCmd::LoopHitReaction) {} - CBCLoopHitReactionCmd(pas::EReactionType type) : CBodyStateCmd(EBodyStateCmd::LoopHitReaction), x8_type(type) {} + explicit CBCLoopHitReactionCmd() : CBodyStateCmd(EBodyStateCmd::LoopHitReaction) {} + explicit CBCLoopHitReactionCmd(pas::EReactionType type) : CBodyStateCmd(EBodyStateCmd::LoopHitReaction), x8_type(type) {} pas::EReactionType GetReactionType() const { return x8_type; } }; @@ -184,8 +185,8 @@ class CBCKnockDownCmd : public CBodyStateCmd { pas::ESeverity x14_severity = pas::ESeverity::Invalid; public: - CBCKnockDownCmd() : CBodyStateCmd(EBodyStateCmd::KnockDown) {} - CBCKnockDownCmd(const zeus::CVector3f& vec, pas::ESeverity severity) + explicit CBCKnockDownCmd() : CBodyStateCmd(EBodyStateCmd::KnockDown) {} + explicit CBCKnockDownCmd(const zeus::CVector3f& vec, pas::ESeverity severity) : CBodyStateCmd(EBodyStateCmd::KnockDown), x8_dir(vec), x14_severity(severity) {} const zeus::CVector3f& GetHitDirection() const { return x8_dir; } pas::ESeverity GetHitSeverity() const { return x14_severity; } @@ -196,8 +197,8 @@ class CBCSlideCmd : public CBodyStateCmd { zeus::CVector3f xc_dir; public: - CBCSlideCmd() : CBodyStateCmd(EBodyStateCmd::Slide) {} - CBCSlideCmd(pas::ESlideType type, const zeus::CVector3f& dir) + explicit CBCSlideCmd() : CBodyStateCmd(EBodyStateCmd::Slide) {} + explicit CBCSlideCmd(pas::ESlideType type, const zeus::CVector3f& dir) : CBodyStateCmd(EBodyStateCmd::Slide), x8_type(type), xc_dir(dir) {} pas::ESlideType GetSlideType() const { return x8_type; } const zeus::CVector3f& GetSlideDirection() const { return xc_dir; } @@ -210,11 +211,11 @@ class CBCScriptedCmd : public CBodyStateCmd { float x10_loopDur = 0.f; public: - CBCScriptedCmd() : CBodyStateCmd(EBodyStateCmd::Scripted) { + explicit CBCScriptedCmd() : CBodyStateCmd(EBodyStateCmd::Scripted) { xc_24_loopAnim = false; xc_25_timedLoop = false; } - CBCScriptedCmd(int i, bool b1, bool b2, float f) + explicit CBCScriptedCmd(int i, bool b1, bool b2, float f) : CBodyStateCmd(EBodyStateCmd::Scripted), x8_anim(i), x10_loopDur(f) { xc_24_loopAnim = b1; xc_25_timedLoop = b2; @@ -231,8 +232,8 @@ class CBCCoverCmd : public CBodyStateCmd { zeus::CVector3f x18_alignDir; public: - CBCCoverCmd() : CBodyStateCmd(EBodyStateCmd::Cover) {} - CBCCoverCmd(pas::ECoverDirection dir, const zeus::CVector3f& v1, const zeus::CVector3f& v2) + explicit CBCCoverCmd() : CBodyStateCmd(EBodyStateCmd::Cover) {} + explicit CBCCoverCmd(pas::ECoverDirection dir, const zeus::CVector3f& v1, const zeus::CVector3f& v2) : CBodyStateCmd(EBodyStateCmd::Cover), x8_dir(dir), xc_targetPos(v1), x18_alignDir(v2) {} pas::ECoverDirection GetDirection() const { return x8_dir; } const zeus::CVector3f& GetTarget() const { return xc_targetPos; } @@ -243,22 +244,22 @@ class CBCWallHangCmd : public CBodyStateCmd { TUniqueId x8_wpId = kInvalidUniqueId; public: - CBCWallHangCmd() : CBodyStateCmd(EBodyStateCmd::WallHang) {} - CBCWallHangCmd(TUniqueId uid) : CBodyStateCmd(EBodyStateCmd::WallHang), x8_wpId(uid) {} + explicit CBCWallHangCmd() : CBodyStateCmd(EBodyStateCmd::WallHang) {} + explicit CBCWallHangCmd(TUniqueId uid) : CBodyStateCmd(EBodyStateCmd::WallHang), x8_wpId(uid) {} TUniqueId GetTarget() const { return x8_wpId; } }; class CBCAdditiveAimCmd : public CBodyStateCmd { public: - CBCAdditiveAimCmd() : CBodyStateCmd(EBodyStateCmd::AdditiveAim) {} + explicit CBCAdditiveAimCmd() : CBodyStateCmd(EBodyStateCmd::AdditiveAim) {} }; class CBCAdditiveFlinchCmd : public CBodyStateCmd { float x8_weight = 1.f; public: - CBCAdditiveFlinchCmd() : CBodyStateCmd(EBodyStateCmd::AdditiveFlinch) {} - CBCAdditiveFlinchCmd(float f) : CBodyStateCmd(EBodyStateCmd::AdditiveFlinch), x8_weight(f) {} + explicit CBCAdditiveFlinchCmd() : CBodyStateCmd(EBodyStateCmd::AdditiveFlinch) {} + explicit CBCAdditiveFlinchCmd(float f) : CBodyStateCmd(EBodyStateCmd::AdditiveFlinch), x8_weight(f) {} float GetWeight() const { return x8_weight; } }; @@ -268,9 +269,9 @@ class CBCAdditiveReactionCmd : public CBodyStateCmd { bool x10_active = false; public: - CBCAdditiveReactionCmd() : CBodyStateCmd(EBodyStateCmd::AdditiveReaction) {} - CBCAdditiveReactionCmd(pas::EAdditiveReactionType type, float f, bool active) - : CBodyStateCmd(EBodyStateCmd::AdditiveReaction), x8_weight(f), xc_type(type), x10_active(active) {} + explicit CBCAdditiveReactionCmd() : CBodyStateCmd(EBodyStateCmd::AdditiveReaction) {} + explicit CBCAdditiveReactionCmd(pas::EAdditiveReactionType type, float weight, bool active) + : CBodyStateCmd(EBodyStateCmd::AdditiveReaction), x8_weight(weight), xc_type(type), x10_active(active) {} pas::EAdditiveReactionType GetType() const { return xc_type; } float GetWeight() const { return x8_weight; } bool GetIsActive() const { return x10_active; } @@ -281,8 +282,8 @@ class CBCLoopAttackCmd : public CBodyStateCmd { u32 xc_waitForAnimOver = 0; public: - CBCLoopAttackCmd() : CBodyStateCmd(EBodyStateCmd::LoopAttack) {} - CBCLoopAttackCmd(pas::ELoopAttackType type) : CBodyStateCmd(EBodyStateCmd::LoopAttack), x8_type(type) {} + explicit CBCLoopAttackCmd() : CBodyStateCmd(EBodyStateCmd::LoopAttack) {} + explicit CBCLoopAttackCmd(pas::ELoopAttackType type) : CBodyStateCmd(EBodyStateCmd::LoopAttack), x8_type(type) {} pas::ELoopAttackType GetAttackType() const { return x8_type; } bool WaitForAnimOver() const { return xc_waitForAnimOver == 1; } }; @@ -291,8 +292,8 @@ class CBCTauntCmd : public CBodyStateCmd { pas::ETauntType x8_type = pas::ETauntType::Invalid; public: - CBCTauntCmd() : CBodyStateCmd(EBodyStateCmd::Taunt) {} - CBCTauntCmd(pas::ETauntType type) : CBodyStateCmd(EBodyStateCmd::Taunt), x8_type(type) {} + explicit CBCTauntCmd() : CBodyStateCmd(EBodyStateCmd::Taunt) {} + explicit CBCTauntCmd(pas::ETauntType type) : CBodyStateCmd(EBodyStateCmd::Taunt), x8_type(type) {} pas::ETauntType GetTauntType() const { return x8_type; } }; @@ -302,7 +303,7 @@ class CBCLocomotionCmd { float x18_weight; public: - CBCLocomotionCmd(const zeus::CVector3f& move, const zeus::CVector3f& face, float weight) + explicit CBCLocomotionCmd(const zeus::CVector3f& move, const zeus::CVector3f& face, float weight) : x0_move(move), xc_face(face), x18_weight(weight) {} const zeus::CVector3f& GetMoveVector() const { return x0_move; } const zeus::CVector3f& GetFaceVector() const { return xc_face; } @@ -324,7 +325,7 @@ class CBodyStateCmdMgr { u32 xb4_deliveredCmdMask = 0; CBCGetupCmd xb8_getup; CBCStepCmd xc4_step; - CBodyStateCmd xd4_die = {EBodyStateCmd::Die}; + CBodyStateCmd xd4_die{EBodyStateCmd::Die}; CBCKnockDownCmd xdc_knockDown; CBCKnockBackCmd xf4_knockBack; CBCMeleeAttackCmd x10c_meleeAttack; @@ -332,10 +333,10 @@ class CBodyStateCmdMgr { CBCLoopAttackCmd x144_loopAttack; CBCLoopReactionCmd x154_loopReaction; CBCLoopHitReactionCmd x160_loopHitReaction; - CBodyStateCmd x16c_exitState = {EBodyStateCmd::ExitState}; - CBodyStateCmd x174_leanFromCover = {EBodyStateCmd::LeanFromCover}; - CBodyStateCmd x17c_nextState = {EBodyStateCmd::NextState}; - CBodyStateCmd x184_maintainVelocity = {EBodyStateCmd::MaintainVelocity}; + CBodyStateCmd x16c_exitState{EBodyStateCmd::ExitState}; + CBodyStateCmd x174_leanFromCover{EBodyStateCmd::LeanFromCover}; + CBodyStateCmd x17c_nextState{EBodyStateCmd::NextState}; + CBodyStateCmd x184_maintainVelocity{EBodyStateCmd::MaintainVelocity}; CBCGenerateCmd x18c_generate; CBCHurledCmd x1ac_hurled; CBCJumpCmd x1d0_jump; @@ -344,12 +345,12 @@ class CBodyStateCmdMgr { CBCScriptedCmd x21c_scripted; CBCCoverCmd x230_cover; CBCWallHangCmd x254_wallHang; - CBodyStateCmd x260_locomotion = {EBodyStateCmd::Locomotion}; - CBodyStateCmd x268_additiveIdle = {EBodyStateCmd::AdditiveIdle}; + CBodyStateCmd x260_locomotion{EBodyStateCmd::Locomotion}; + CBodyStateCmd x268_additiveIdle{EBodyStateCmd::AdditiveIdle}; CBCAdditiveAimCmd x270_additiveAim; CBCAdditiveFlinchCmd x278_additiveFlinch; CBCAdditiveReactionCmd x284_additiveReaction; - CBodyStateCmd x298_stopReaction = {EBodyStateCmd::StopReaction}; + CBodyStateCmd x298_stopReaction{EBodyStateCmd::StopReaction}; void DeliverCmd(EBodyStateCmd cmd) { xb4_deliveredCmdMask |= (1 << int(cmd)); } public: diff --git a/Runtime/Character/CBodyStateInfo.cpp b/Runtime/Character/CBodyStateInfo.cpp index 027a5891b..09325a628 100644 --- a/Runtime/Character/CBodyStateInfo.cpp +++ b/Runtime/Character/CBodyStateInfo.cpp @@ -42,10 +42,10 @@ CBodyStateInfo::CBodyStateInfo(CActor& actor, EBodyType type) { } x1c_additiveStates.reserve(4); - x1c_additiveStates.push_back({pas::EAnimationState::AdditiveIdle, std::make_unique()}); - x1c_additiveStates.push_back({pas::EAnimationState::AdditiveAim, std::make_unique()}); - x1c_additiveStates.push_back({pas::EAnimationState::AdditiveFlinch, std::make_unique()}); - x1c_additiveStates.push_back({pas::EAnimationState::AdditiveReaction, std::make_unique()}); + x1c_additiveStates.emplace_back(pas::EAnimationState::AdditiveIdle, std::make_unique()); + x1c_additiveStates.emplace_back(pas::EAnimationState::AdditiveAim, std::make_unique()); + x1c_additiveStates.emplace_back(pas::EAnimationState::AdditiveFlinch, std::make_unique()); + x1c_additiveStates.emplace_back(pas::EAnimationState::AdditiveReaction, std::make_unique()); } std::unique_ptr CBodyStateInfo::SetupRestrictedFlyerBodyStates(int stateId, CActor& actor) const { diff --git a/Runtime/Character/CBoolPOINode.hpp b/Runtime/Character/CBoolPOINode.hpp index 9dae11934..c64468da7 100644 --- a/Runtime/Character/CBoolPOINode.hpp +++ b/Runtime/Character/CBoolPOINode.hpp @@ -9,8 +9,8 @@ class CBoolPOINode : public CPOINode { bool x38_val = false; public: - CBoolPOINode(); - CBoolPOINode(CInputStream& in); + explicit CBoolPOINode(); + explicit CBoolPOINode(CInputStream& in); bool GetValue() const { return x38_val; } static CBoolPOINode CopyNodeMinusStartTime(const CBoolPOINode& node, const CCharAnimTime& startTime); }; diff --git a/Runtime/Character/CCharacterInfo.hpp b/Runtime/Character/CCharacterInfo.hpp index b5e5a8d22..9f57b57d9 100644 --- a/Runtime/Character/CCharacterInfo.hpp +++ b/Runtime/Character/CCharacterInfo.hpp @@ -47,7 +47,7 @@ private: std::vector xb0_animIdxs; public: - CCharacterInfo(CInputStream& in); + explicit CCharacterInfo(CInputStream& in); std::string_view GetCharacterName() const { return x4_name; } CAssetId GetModelId() const { return x14_cmdl; } diff --git a/Runtime/Character/CCharacterSet.hpp b/Runtime/Character/CCharacterSet.hpp index 9bb0fcdba..f3c8e46f7 100644 --- a/Runtime/Character/CCharacterSet.hpp +++ b/Runtime/Character/CCharacterSet.hpp @@ -13,7 +13,7 @@ class CCharacterSet { std::map x4_characters; public: - CCharacterSet(CInputStream& in); + explicit CCharacterSet(CInputStream& in); const std::map& GetCharacterInfoMap() const { return x4_characters; } }; diff --git a/Runtime/Character/CEffectComponent.hpp b/Runtime/Character/CEffectComponent.hpp index ab290af75..f0a8a688c 100644 --- a/Runtime/Character/CEffectComponent.hpp +++ b/Runtime/Character/CEffectComponent.hpp @@ -18,7 +18,7 @@ class CEffectComponent { static SObjectTag GetSObjectTagFromStream(CInputStream& in); public: - CEffectComponent(CInputStream& in); + explicit CEffectComponent(CInputStream& in); std::string_view GetComponentName() const { return x0_name; } const SObjectTag& GetParticleTag() const { return x10_tag; } diff --git a/Runtime/Character/CFBStreamedAnimReader.hpp b/Runtime/Character/CFBStreamedAnimReader.hpp index 15af8800d..aa892f081 100644 --- a/Runtime/Character/CFBStreamedAnimReader.hpp +++ b/Runtime/Character/CFBStreamedAnimReader.hpp @@ -42,7 +42,7 @@ class CFBStreamedAnimReaderTotals { void Allocate(u32 chanCount); public: - CFBStreamedAnimReaderTotals(const CFBStreamedCompression& source); + explicit CFBStreamedAnimReaderTotals(const CFBStreamedCompression& source); void Initialize(const CFBStreamedCompression& source); void IncrementInto(CBitLevelLoader& loader, const CFBStreamedCompression& source, CFBStreamedAnimReaderTotals& dest); void CalculateDown(); @@ -61,7 +61,7 @@ class CFBStreamedPairOfTotals { float x78_t = 0.f; public: - CFBStreamedPairOfTotals(const TSubAnimTypeToken& source); + explicit CFBStreamedPairOfTotals(const TSubAnimTypeToken& source); void SetTime(CBitLevelLoader& loader, const CCharAnimTime& time); void DoIncrement(CBitLevelLoader& loader); float GetT() const { return x78_t; } @@ -76,7 +76,7 @@ class CBitLevelLoader { size_t m_bitIdx = 0; public: - CBitLevelLoader(const void* data) : m_data(reinterpret_cast(data)) {} + explicit CBitLevelLoader(const void* data) : m_data(reinterpret_cast(data)) {} void Reset() { m_bitIdx = 0; } u32 LoadUnsigned(u8 q); s32 LoadSigned(u8 q); @@ -88,7 +88,7 @@ class CSegIdToIndexConverter { std::array x0_indices; public: - CSegIdToIndexConverter(const CFBStreamedAnimReaderTotals& totals); + explicit CSegIdToIndexConverter(const CFBStreamedAnimReaderTotals& totals); s32 SegIdToIndex(const CSegId& id) const { return x0_indices[id]; } }; @@ -104,7 +104,7 @@ class CFBStreamedAnimReader : public CAnimSourceReaderBase { zeus::CQuaternion GetRotation(const CSegId& seg) const; public: - CFBStreamedAnimReader(const TSubAnimTypeToken& source, const CCharAnimTime& time); + explicit CFBStreamedAnimReader(const TSubAnimTypeToken& source, const CCharAnimTime& time); SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const override; bool VSupportsReverseView() const override { return false; } diff --git a/Runtime/Character/CFBStreamedCompression.hpp b/Runtime/Character/CFBStreamedCompression.hpp index 0c37c0fd6..5c519280f 100644 --- a/Runtime/Character/CFBStreamedCompression.hpp +++ b/Runtime/Character/CFBStreamedCompression.hpp @@ -66,7 +66,7 @@ private: float CalculateAverageVelocity(const u8* chans) const; public: - CFBStreamedCompression(CInputStream& in, IObjectStore& objStore, bool pc); + explicit CFBStreamedCompression(CInputStream& in, IObjectStore& objStore, bool pc); const Header& MainHeader() const { return *reinterpret_cast(xc_rotsAndOffs.get()); } const u32* GetTimes() const; const u8* GetPerChannelHeaders() const; diff --git a/Runtime/Character/CHalfTransition.hpp b/Runtime/Character/CHalfTransition.hpp index ad6ab9397..76d5a58bb 100644 --- a/Runtime/Character/CHalfTransition.hpp +++ b/Runtime/Character/CHalfTransition.hpp @@ -13,7 +13,7 @@ class CHalfTransition { std::shared_ptr x4_trans; public: - CHalfTransition(CInputStream& in); + explicit CHalfTransition(CInputStream& in); u32 GetId() const { return x0_id; } const std::shared_ptr& GetMetaTrans() const { return x4_trans; } }; diff --git a/Runtime/Character/CHierarchyPoseBuilder.hpp b/Runtime/Character/CHierarchyPoseBuilder.hpp index 24e196543..abe1f13e2 100644 --- a/Runtime/Character/CHierarchyPoseBuilder.hpp +++ b/Runtime/Character/CHierarchyPoseBuilder.hpp @@ -36,7 +36,7 @@ private: const zeus::CVector3f& offset) const; public: - CHierarchyPoseBuilder(const CLayoutDescription& layout); + explicit CHierarchyPoseBuilder(const CLayoutDescription& layout); const TLockedToken& CharLayoutInfo() const { return x0_layoutDesc.ScaledLayout(); } bool HasRoot() const { return x34_hasRoot; } diff --git a/Runtime/Character/CInt32POINode.hpp b/Runtime/Character/CInt32POINode.hpp index 898fff078..2ca709b42 100644 --- a/Runtime/Character/CInt32POINode.hpp +++ b/Runtime/Character/CInt32POINode.hpp @@ -15,7 +15,7 @@ class CInt32POINode : public CPOINode { public: CInt32POINode(); CInt32POINode(std::string_view, EPOIType, const CCharAnimTime&, s32, bool, float, s32, s32, s32, std::string_view); - CInt32POINode(CInputStream& in); + explicit CInt32POINode(CInputStream& in); s32 GetValue() const { return x38_val; } std::string_view GetLocatorName() const { return x3c_locatorName; } diff --git a/Runtime/Character/CLayoutDescription.hpp b/Runtime/Character/CLayoutDescription.hpp index 248f57486..05c2e041b 100644 --- a/Runtime/Character/CLayoutDescription.hpp +++ b/Runtime/Character/CLayoutDescription.hpp @@ -27,7 +27,7 @@ private: std::optional xc_scaled; public: - CLayoutDescription(const TLockedToken& token) : x0_layoutToken(token) {} + explicit CLayoutDescription(const TLockedToken& token) : x0_layoutToken(token) {} const std::optional& GetScaledLayoutDescription() const { return xc_scaled; } diff --git a/Runtime/Character/CMetaAnimBlend.hpp b/Runtime/Character/CMetaAnimBlend.hpp index a2be465be..52bee1aa7 100644 --- a/Runtime/Character/CMetaAnimBlend.hpp +++ b/Runtime/Character/CMetaAnimBlend.hpp @@ -14,7 +14,7 @@ class CMetaAnimBlend : public IMetaAnim { bool x10_; public: - CMetaAnimBlend(CInputStream& in); + explicit CMetaAnimBlend(CInputStream& in); EMetaAnimType GetType() const override { return EMetaAnimType::Blend; } void GetUniquePrimitives(std::set& primsOut) const override; diff --git a/Runtime/Character/CMetaAnimPhaseBlend.hpp b/Runtime/Character/CMetaAnimPhaseBlend.hpp index 81686f5c7..c8131ff59 100644 --- a/Runtime/Character/CMetaAnimPhaseBlend.hpp +++ b/Runtime/Character/CMetaAnimPhaseBlend.hpp @@ -14,7 +14,7 @@ class CMetaAnimPhaseBlend : public IMetaAnim { bool x10_; public: - CMetaAnimPhaseBlend(CInputStream& in); + explicit CMetaAnimPhaseBlend(CInputStream& in); EMetaAnimType GetType() const override { return EMetaAnimType::PhaseBlend; } void GetUniquePrimitives(std::set& primsOut) const override; diff --git a/Runtime/Character/CMetaAnimPlay.hpp b/Runtime/Character/CMetaAnimPlay.hpp index 4f056eeb0..2939fc24a 100644 --- a/Runtime/Character/CMetaAnimPlay.hpp +++ b/Runtime/Character/CMetaAnimPlay.hpp @@ -11,7 +11,7 @@ class CMetaAnimPlay : public IMetaAnim { CCharAnimTime x1c_startTime; public: - CMetaAnimPlay(CInputStream& in); + explicit CMetaAnimPlay(CInputStream& in); EMetaAnimType GetType() const override { return EMetaAnimType::Play; } void GetUniquePrimitives(std::set& primsOut) const override; diff --git a/Runtime/Character/CMetaAnimRandom.hpp b/Runtime/Character/CMetaAnimRandom.hpp index 9abb4e8a2..8ee2a6b29 100644 --- a/Runtime/Character/CMetaAnimRandom.hpp +++ b/Runtime/Character/CMetaAnimRandom.hpp @@ -15,7 +15,7 @@ class CMetaAnimRandom : public IMetaAnim { static RandomData CreateRandomData(CInputStream& in); public: - CMetaAnimRandom(CInputStream& in); + explicit CMetaAnimRandom(CInputStream& in); EMetaAnimType GetType() const override { return EMetaAnimType::Random; } void GetUniquePrimitives(std::set& primsOut) const override; diff --git a/Runtime/Character/CMetaAnimSequence.hpp b/Runtime/Character/CMetaAnimSequence.hpp index 57d68bf6d..bc644b3e9 100644 --- a/Runtime/Character/CMetaAnimSequence.hpp +++ b/Runtime/Character/CMetaAnimSequence.hpp @@ -13,7 +13,7 @@ class CMetaAnimSequence : public IMetaAnim { std::vector> CreateSequence(CInputStream& in); public: - CMetaAnimSequence(CInputStream& in); + explicit CMetaAnimSequence(CInputStream& in); EMetaAnimType GetType() const override { return EMetaAnimType::Sequence; } void GetUniquePrimitives(std::set& primsOut) const override; diff --git a/Runtime/Character/CMetaTransMetaAnim.hpp b/Runtime/Character/CMetaTransMetaAnim.hpp index 03f459254..21e193015 100644 --- a/Runtime/Character/CMetaTransMetaAnim.hpp +++ b/Runtime/Character/CMetaTransMetaAnim.hpp @@ -12,7 +12,7 @@ class CMetaTransMetaAnim : public IMetaTrans { std::shared_ptr x4_metaAnim; public: - CMetaTransMetaAnim(CInputStream& in); + explicit CMetaTransMetaAnim(CInputStream& in); EMetaTransType GetType() const override { return EMetaTransType::MetaAnim; } std::shared_ptr VGetTransitionTree(const std::weak_ptr& a, diff --git a/Runtime/Character/CMetaTransPhaseTrans.hpp b/Runtime/Character/CMetaTransPhaseTrans.hpp index b9e5c9e5e..49005655c 100644 --- a/Runtime/Character/CMetaTransPhaseTrans.hpp +++ b/Runtime/Character/CMetaTransPhaseTrans.hpp @@ -13,7 +13,7 @@ class CMetaTransPhaseTrans : public IMetaTrans { u32 x10_flags; public: - CMetaTransPhaseTrans(CInputStream& in); + explicit CMetaTransPhaseTrans(CInputStream& in); EMetaTransType GetType() const override { return EMetaTransType::PhaseTrans; } std::shared_ptr VGetTransitionTree(const std::weak_ptr& a, diff --git a/Runtime/Character/CMetaTransTrans.hpp b/Runtime/Character/CMetaTransTrans.hpp index b3cf33efd..f1f259975 100644 --- a/Runtime/Character/CMetaTransTrans.hpp +++ b/Runtime/Character/CMetaTransTrans.hpp @@ -13,7 +13,7 @@ class CMetaTransTrans : public IMetaTrans { u32 x10_flags; public: - CMetaTransTrans(CInputStream& in); + explicit CMetaTransTrans(CInputStream& in); EMetaTransType GetType() const override { return EMetaTransType::Trans; } std::shared_ptr VGetTransitionTree(const std::weak_ptr& a, diff --git a/Runtime/Character/CModelData.cpp b/Runtime/Character/CModelData.cpp index 1ac59a504..b035a378b 100644 --- a/Runtime/Character/CModelData.cpp +++ b/Runtime/Character/CModelData.cpp @@ -20,7 +20,7 @@ namespace urde { static logvisor::Module Log("urde::CModelData"); -CModelData::~CModelData() {} +CModelData::~CModelData() = default; CModelData::CModelData() {} CModelData CModelData::CModelDataNull() { return CModelData(); } diff --git a/Runtime/Character/CModelData.hpp b/Runtime/Character/CModelData.hpp index 917d45ab8..d11d8f36d 100644 --- a/Runtime/Character/CModelData.hpp +++ b/Runtime/Character/CModelData.hpp @@ -79,7 +79,7 @@ class CModelData { std::unique_ptr m_xrayModelInst; std::unique_ptr m_infraModelInst; - int m_drawInstCount; + int m_drawInstCount = 0; public: enum class EWhichModel { Normal, XRay, Thermal, ThermalHot }; @@ -88,8 +88,8 @@ public: bool GetSortThermal() const { return x14_25_sortThermal; } ~CModelData(); - CModelData(const CStaticRes& res, int instCount = 1); - CModelData(const CAnimRes& res, int instCount = 1); + explicit CModelData(const CStaticRes& res, int instCount = 1); + explicit CModelData(const CAnimRes& res, int instCount = 1); CModelData(CModelData&&) = default; CModelData& operator=(CModelData&&) = default; CModelData(); diff --git a/Runtime/Character/CPASAnimInfo.hpp b/Runtime/Character/CPASAnimInfo.hpp index 1a86d22b9..186f9afed 100644 --- a/Runtime/Character/CPASAnimInfo.hpp +++ b/Runtime/Character/CPASAnimInfo.hpp @@ -11,8 +11,8 @@ class CPASAnimInfo { rstl::reserved_vector x4_parms; public: - CPASAnimInfo(u32 id) : x0_id(id) {} - CPASAnimInfo(u32 id, rstl::reserved_vector&& parms); + explicit CPASAnimInfo(u32 id) : x0_id(id) {} + explicit CPASAnimInfo(u32 id, rstl::reserved_vector&& parms); u32 GetAnimId() const { return x0_id; } CPASAnimParm::UParmValue GetAnimParmValue(u32 idx) const; CPASAnimParm GetAnimParmData(u32, CPASAnimParm::EParmType) const; diff --git a/Runtime/Character/CPASAnimParmData.hpp b/Runtime/Character/CPASAnimParmData.hpp index b985f0682..41ad3521f 100644 --- a/Runtime/Character/CPASAnimParmData.hpp +++ b/Runtime/Character/CPASAnimParmData.hpp @@ -12,28 +12,18 @@ class CPASAnimParmData { public: CPASAnimParmData() = default; - CPASAnimParmData(s32 stateId, const CPASAnimParm& parm1 = CPASAnimParm::NoParameter(), - const CPASAnimParm& parm2 = CPASAnimParm::NoParameter(), - const CPASAnimParm& parm3 = CPASAnimParm::NoParameter(), - const CPASAnimParm& parm4 = CPASAnimParm::NoParameter(), - const CPASAnimParm& parm5 = CPASAnimParm::NoParameter(), - const CPASAnimParm& parm6 = CPASAnimParm::NoParameter(), - const CPASAnimParm& parm7 = CPASAnimParm::NoParameter(), - const CPASAnimParm& parm8 = CPASAnimParm::NoParameter()); + explicit CPASAnimParmData(s32 stateId, const CPASAnimParm& parm1 = CPASAnimParm::NoParameter(), + const CPASAnimParm& parm2 = CPASAnimParm::NoParameter(), + const CPASAnimParm& parm3 = CPASAnimParm::NoParameter(), + const CPASAnimParm& parm4 = CPASAnimParm::NoParameter(), + const CPASAnimParm& parm5 = CPASAnimParm::NoParameter(), + const CPASAnimParm& parm6 = CPASAnimParm::NoParameter(), + const CPASAnimParm& parm7 = CPASAnimParm::NoParameter(), + const CPASAnimParm& parm8 = CPASAnimParm::NoParameter()); s32 GetStateId() const { return x0_stateId; } const rstl::reserved_vector& GetAnimParmData() const { return x4_parms; } - static CPASAnimParmData NoParameters(s32 stateId) { - return {stateId, - CPASAnimParm::NoParameter(), - CPASAnimParm::NoParameter(), - CPASAnimParm::NoParameter(), - CPASAnimParm::NoParameter(), - CPASAnimParm::NoParameter(), - CPASAnimParm::NoParameter(), - CPASAnimParm::NoParameter(), - CPASAnimParm::NoParameter()}; - } + static auto NoParameters(s32 stateId) { return CPASAnimParmData(stateId); } }; } // namespace urde diff --git a/Runtime/Character/CPOINode.hpp b/Runtime/Character/CPOINode.hpp index a5777a3bd..3cc4c89b3 100644 --- a/Runtime/Character/CPOINode.hpp +++ b/Runtime/Character/CPOINode.hpp @@ -33,9 +33,9 @@ protected: s32 x34_flags; public: - CPOINode(std::string_view name, EPOIType type, const CCharAnimTime& time, s32 index, bool unique, float weight, - s32 charIdx, s32 flags); - CPOINode(CInputStream& in); + explicit CPOINode(std::string_view name, EPOIType type, const CCharAnimTime& time, s32 index, bool unique, + float weight, s32 charIdx, s32 flags); + explicit CPOINode(CInputStream& in); virtual ~CPOINode() = default; std::string_view GetString() const { return x8_name; } diff --git a/Runtime/Character/CParticleData.hpp b/Runtime/Character/CParticleData.hpp index 907f406d4..98428e200 100644 --- a/Runtime/Character/CParticleData.hpp +++ b/Runtime/Character/CParticleData.hpp @@ -22,7 +22,7 @@ private: public: CParticleData() = default; - CParticleData(CInputStream& in); + explicit CParticleData(CInputStream& in); u32 GetDuration() const { return x0_duration; } const SObjectTag& GetTag() const { return x4_particle; } std::string_view GetSegmentName() const { return xc_boneName; } diff --git a/Runtime/Character/CParticlePOINode.hpp b/Runtime/Character/CParticlePOINode.hpp index 065ad773c..33180a624 100644 --- a/Runtime/Character/CParticlePOINode.hpp +++ b/Runtime/Character/CParticlePOINode.hpp @@ -10,8 +10,8 @@ class CParticlePOINode : public CPOINode { CParticleData x38_data; public: - CParticlePOINode(); - CParticlePOINode(CInputStream& in); + explicit CParticlePOINode(); + explicit CParticlePOINode(CInputStream& in); const CParticleData& GetParticleData() const { return x38_data; } static CParticlePOINode CopyNodeMinusStartTime(const CParticlePOINode& node, const CCharAnimTime& startTime); diff --git a/Runtime/Character/CPrimitive.hpp b/Runtime/Character/CPrimitive.hpp index 16e7236cd..db9a44c8f 100644 --- a/Runtime/Character/CPrimitive.hpp +++ b/Runtime/Character/CPrimitive.hpp @@ -13,7 +13,7 @@ class CPrimitive { std::string x8_animName; public: - CPrimitive(CInputStream& in); + explicit CPrimitive(CInputStream& in); CAssetId GetAnimResId() const { return x0_animId; } u32 GetAnimDbIdx() const { return x4_animIdx; } std::string_view GetName() const { return x8_animName; } diff --git a/Runtime/Character/CSegIdList.hpp b/Runtime/Character/CSegIdList.hpp index 65f456371..37eceb21c 100644 --- a/Runtime/Character/CSegIdList.hpp +++ b/Runtime/Character/CSegIdList.hpp @@ -11,7 +11,7 @@ class CSegIdList { std::vector x0_list; public: - CSegIdList(CInputStream& in); + explicit CSegIdList(CInputStream& in); const std::vector& GetList() const { return x0_list; } }; diff --git a/Runtime/Character/CSkinBank.hpp b/Runtime/Character/CSkinBank.hpp index cce5921f0..604d19b17 100644 --- a/Runtime/Character/CSkinBank.hpp +++ b/Runtime/Character/CSkinBank.hpp @@ -12,7 +12,7 @@ class CSkinBank { std::vector x0_segments; public: - CSkinBank(CInputStream& in); + explicit CSkinBank(CInputStream& in); void GetBankTransforms(std::vector& out, const CPoseAsTransforms& pose) const; }; diff --git a/Runtime/Character/CSoundPOINode.hpp b/Runtime/Character/CSoundPOINode.hpp index 0f46bae1e..4e243fd5c 100644 --- a/Runtime/Character/CSoundPOINode.hpp +++ b/Runtime/Character/CSoundPOINode.hpp @@ -12,10 +12,10 @@ class CSoundPOINode : public CPOINode { float x40_maxDist; public: - CSoundPOINode(); - CSoundPOINode(CInputStream& in); - CSoundPOINode(std::string_view name, EPOIType type, const CCharAnimTime& time, u32 b, bool c, float d, u32 e, u32 f, - u32 sfxId, float falloff, float maxDist); + explicit CSoundPOINode(); + explicit CSoundPOINode(CInputStream& in); + explicit CSoundPOINode(std::string_view name, EPOIType type, const CCharAnimTime& time, u32 b, bool c, float d, u32 e, + u32 f, u32 sfxId, float falloff, float maxDist); static CSoundPOINode CopyNodeMinusStartTime(const CSoundPOINode& node, const CCharAnimTime& startTime); u32 GetSfxId() const { return x38_sfxId; } diff --git a/Runtime/Character/CTimeScaleFunctions.hpp b/Runtime/Character/CTimeScaleFunctions.hpp index e6bc159dc..0829b96e3 100644 --- a/Runtime/Character/CTimeScaleFunctions.hpp +++ b/Runtime/Character/CTimeScaleFunctions.hpp @@ -25,7 +25,7 @@ private: float x4_scale; public: - CConstantAnimationTimeScale(float scale) : x4_scale(scale) {} + explicit CConstantAnimationTimeScale(float scale) : x4_scale(scale) {} EVaryingAnimationTimeScaleType GetType() const override { return EVaryingAnimationTimeScaleType::Constant; } float VTimeScaleIntegral(float lowerLimit, float upperLimit) const override; @@ -46,7 +46,7 @@ class CLinearAnimationTimeScale : public IVaryingAnimationTimeScale { static float TimeScaleIntegralWithSortedLimits(const CFunctionDescription& desc, float lowerLimit, float upperLimit); public: - CLinearAnimationTimeScale(const CCharAnimTime& t1, float y1, const CCharAnimTime& t2, float y2); + explicit CLinearAnimationTimeScale(const CCharAnimTime& t1, float y1, const CCharAnimTime& t2, float y2); EVaryingAnimationTimeScaleType GetType() const override { return EVaryingAnimationTimeScaleType::Linear; } float VTimeScaleIntegral(float lowerLimit, float upperLimit) const override; diff --git a/Runtime/Character/CTransition.hpp b/Runtime/Character/CTransition.hpp index b7d7a0266..80f74ab70 100644 --- a/Runtime/Character/CTransition.hpp +++ b/Runtime/Character/CTransition.hpp @@ -15,7 +15,7 @@ class CTransition { std::shared_ptr xc_trans; public: - CTransition(CInputStream& in); + explicit CTransition(CInputStream& in); u32 GetAnimA() const { return x4_animA; } u32 GetAnimB() const { return x8_animB; } std::pair GetAnimPair() const { return {x4_animA, x8_animB}; } diff --git a/Runtime/Character/IAnimReader.hpp b/Runtime/Character/IAnimReader.hpp index 1f4962182..59f7e1df9 100644 --- a/Runtime/Character/IAnimReader.hpp +++ b/Runtime/Character/IAnimReader.hpp @@ -2,6 +2,7 @@ #include #include +#include #include "Runtime/CToken.hpp" #include "Runtime/RetroTypes.hpp" @@ -73,14 +74,15 @@ class TSubAnimTypeToken : public TLockedToken {}; template <> class TSubAnimTypeToken : public TLockedToken { public: - TSubAnimTypeToken(const TLockedToken& token) : TLockedToken(token) {} + // Converting constructor + TSubAnimTypeToken(const TLockedToken& token) : TLockedToken(token) {} - CAnimSource* GetObj() { + CAnimSource* GetObj() override { CAllFormatsAnimSource* source = reinterpret_cast(TLockedToken::GetObj()); return &source->GetAsCAnimSource(); } - const CAnimSource* GetObj() const { + const CAnimSource* GetObj() const override { return const_cast*>(this)->GetObj(); } }; @@ -88,16 +90,16 @@ public: template <> class TSubAnimTypeToken : public TLockedToken { public: - TSubAnimTypeToken(const TLockedToken& token) - : TLockedToken(token) {} + // Converting constructor + TSubAnimTypeToken(const TLockedToken& token) : TLockedToken(token) {} - CFBStreamedCompression* GetObj() { + CFBStreamedCompression* GetObj() override { CAllFormatsAnimSource* source = reinterpret_cast(TLockedToken::GetObj()); return &source->GetAsCFBStreamedCompression(); } - const CFBStreamedCompression* GetObj() const { + const CFBStreamedCompression* GetObj() const override { return const_cast*>(this)->GetObj(); } }; @@ -120,9 +122,9 @@ public: u32) const = 0; virtual u32 VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator, u32) const = 0; - virtual bool VGetBoolPOIState(const char*) const = 0; - virtual s32 VGetInt32POIState(const char*) const = 0; - virtual CParticleData::EParentedMode VGetParticlePOIState(const char*) const = 0; + virtual bool VGetBoolPOIState(std::string_view name) const = 0; + virtual s32 VGetInt32POIState(std::string_view name) const = 0; + virtual CParticleData::EParentedMode VGetParticlePOIState(std::string_view name) const = 0; virtual void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const = 0; virtual void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const = 0; diff --git a/Runtime/Character/IMetaAnim.hpp b/Runtime/Character/IMetaAnim.hpp index 71b3fc77a..c941dafc5 100644 --- a/Runtime/Character/IMetaAnim.hpp +++ b/Runtime/Character/IMetaAnim.hpp @@ -35,8 +35,8 @@ class CPreAdvanceIndicator { u16 x3c_; */ public: - CPreAdvanceIndicator(const CCharAnimTime& time) : x0_isTime(true), x4_time(time) {} - CPreAdvanceIndicator(const char* string) : x0_isTime(false), xc_string(string) {} + explicit CPreAdvanceIndicator(const CCharAnimTime& time) : x0_isTime(true), x4_time(time) {} + explicit CPreAdvanceIndicator(const char* string) : x0_isTime(false), xc_string(string) {} const char* GetString() const { return xc_string; } bool IsString() const { return !x0_isTime; } const CCharAnimTime& GetTime() const { return x4_time; } diff --git a/Runtime/Character/TSegIdMap.hpp b/Runtime/Character/TSegIdMap.hpp index bcef067be..304590769 100644 --- a/Runtime/Character/TSegIdMap.hpp +++ b/Runtime/Character/TSegIdMap.hpp @@ -18,7 +18,7 @@ class TSegIdMap { CSegId xd4_curPrevBone = 0; public: - TSegIdMap(const CSegId& capacity) : x1_capacity(capacity), xd0_bones(new T[capacity]) {} + explicit TSegIdMap(const CSegId& capacity) : x1_capacity(capacity), xd0_bones(new T[capacity]) {} T& operator[](const CSegId& id) { return SetElement(id); } const T& operator[](const CSegId& id) const { return xd0_bones[x8_indirectionMap[id].second]; } diff --git a/Runtime/Collision/CAABoxFilter.hpp b/Runtime/Collision/CAABoxFilter.hpp index de28e207a..59e5c92c6 100644 --- a/Runtime/Collision/CAABoxFilter.hpp +++ b/Runtime/Collision/CAABoxFilter.hpp @@ -7,7 +7,7 @@ class CCollisionInfoList; class CAABoxFilter : public ICollisionFilter { public: - CAABoxFilter(CActor& actor) : ICollisionFilter(actor) {} + explicit CAABoxFilter(CActor& actor) : ICollisionFilter(actor) {} void Filter(const CCollisionInfoList& in, CCollisionInfoList& out) const override; static void FilterBoxFloorCollisions(const CCollisionInfoList& in, CCollisionInfoList& out); }; diff --git a/Runtime/Collision/CAreaOctTree.hpp b/Runtime/Collision/CAreaOctTree.hpp index fec3b9455..a1c2b57ea 100644 --- a/Runtime/Collision/CAreaOctTree.hpp +++ b/Runtime/Collision/CAreaOctTree.hpp @@ -27,7 +27,7 @@ public: const u16* m_ptr; public: - TriListReference(const u16* ptr) : m_ptr(ptr) {} + explicit TriListReference(const u16* ptr) : m_ptr(ptr) {} u16 GetAt(int idx) const { return m_ptr[idx + 1]; } u16 GetSize() const { return m_ptr[0]; } }; diff --git a/Runtime/Collision/CBallFilter.hpp b/Runtime/Collision/CBallFilter.hpp index 803a72337..7ba532a03 100644 --- a/Runtime/Collision/CBallFilter.hpp +++ b/Runtime/Collision/CBallFilter.hpp @@ -8,7 +8,7 @@ class CPhysicsActor; class CBallFilter : public ICollisionFilter { public: - CBallFilter(CActor& actor) : ICollisionFilter(actor) {} + explicit CBallFilter(CActor& actor) : ICollisionFilter(actor) {} void Filter(const CCollisionInfoList& in, CCollisionInfoList& out) const override; }; diff --git a/Runtime/Collision/CCollidableOBBTreeGroup.hpp b/Runtime/Collision/CCollidableOBBTreeGroup.hpp index 9957a9a47..e48aafc77 100644 --- a/Runtime/Collision/CCollidableOBBTreeGroup.hpp +++ b/Runtime/Collision/CCollidableOBBTreeGroup.hpp @@ -19,7 +19,7 @@ class CCollidableOBBTreeGroupContainer { zeus::CAABox x20_aabox; public: - CCollidableOBBTreeGroupContainer(CInputStream& in); + explicit CCollidableOBBTreeGroupContainer(CInputStream& in); CCollidableOBBTreeGroupContainer(const zeus::CVector3f&, const zeus::CVector3f&); }; diff --git a/Runtime/Collision/CCollisionEdge.hpp b/Runtime/Collision/CCollisionEdge.hpp index 2b4a5db83..d60a37dc6 100644 --- a/Runtime/Collision/CCollisionEdge.hpp +++ b/Runtime/Collision/CCollisionEdge.hpp @@ -9,7 +9,7 @@ class CCollisionEdge { public: CCollisionEdge() = default; - CCollisionEdge(CInputStream&); + explicit CCollisionEdge(CInputStream&); CCollisionEdge(u16 v0, u16 v1) : x0_index1(v0), x2_index2(v1) {} u16 GetVertIndex1() const { return x0_index1; } diff --git a/Runtime/Collision/CCollisionPrimitive.hpp b/Runtime/Collision/CCollisionPrimitive.hpp index 79db8fbdc..bbe619908 100644 --- a/Runtime/Collision/CCollisionPrimitive.hpp +++ b/Runtime/Collision/CCollisionPrimitive.hpp @@ -134,7 +134,7 @@ private: public: CCollisionPrimitive() = default; - CCollisionPrimitive(const CMaterialList& list); + explicit CCollisionPrimitive(const CMaterialList& list); virtual u32 GetTableIndex() const = 0; virtual void SetMaterial(const CMaterialList&); virtual const CMaterialList& GetMaterial() const; diff --git a/Runtime/Collision/CCollisionResponseData.hpp b/Runtime/Collision/CCollisionResponseData.hpp index 8beccab37..4b61ca6d4 100644 --- a/Runtime/Collision/CCollisionResponseData.hpp +++ b/Runtime/Collision/CCollisionResponseData.hpp @@ -126,7 +126,7 @@ class CCollisionResponseData { bool CheckAndAddResourceToResponse(FourCC clsId, CInputStream& in, CSimplePool* resPool); public: - CCollisionResponseData(CInputStream& in, CSimplePool* resPool); + explicit CCollisionResponseData(CInputStream& in, CSimplePool* resPool); const std::optional>& GetParticleDescription(EWeaponCollisionResponseTypes type) const; const std::optional>& GetDecalDescription(EWeaponCollisionResponseTypes type) const; s32 GetSoundEffectId(EWeaponCollisionResponseTypes type) const; diff --git a/Runtime/Collision/CMetroidAreaCollider.hpp b/Runtime/Collision/CMetroidAreaCollider.hpp index 621c02e1a..5c39b56fb 100644 --- a/Runtime/Collision/CMetroidAreaCollider.hpp +++ b/Runtime/Collision/CMetroidAreaCollider.hpp @@ -121,7 +121,7 @@ public: bool x908_24_overflow : 1; public: - COctreeLeafCache(const CAreaOctTree& octTree); + explicit COctreeLeafCache(const CAreaOctTree& octTree); void AddLeaf(const CAreaOctTree::Node& node); u32 GetNumLeaves() const { return x4_nodeCache.size(); } bool HasCacheOverflowed() const { return x908_24_overflow; } @@ -179,7 +179,7 @@ class CAreaCollisionCache { }; public: - CAreaCollisionCache(const zeus::CAABox& aabb) : x0_aabb(aabb) {} + explicit CAreaCollisionCache(const zeus::CAABox& aabb) : x0_aabb(aabb) {} void ClearCache(); const zeus::CAABox& GetCacheBounds() const { return x0_aabb; } void SetCacheBounds(const zeus::CAABox& aabb) { x0_aabb = aabb; } diff --git a/Runtime/Collision/COBBTree.cpp b/Runtime/Collision/COBBTree.cpp index d543e8300..89d8bf84e 100644 --- a/Runtime/Collision/COBBTree.cpp +++ b/Runtime/Collision/COBBTree.cpp @@ -130,30 +130,37 @@ zeus::CAABox COBBTree::CalculateAABox(const zeus::CTransform& xf) const { COBBTree::SIndexData::SIndexData(CInputStream& in) { u32 count = in.readUint32Big(); x0_materials.reserve(count); - for (u32 i = 0; i < count; i++) - x0_materials.push_back(in.readUint32Big()); + for (u32 i = 0; i < count; i++) { + x0_materials.emplace_back(in.readUint32Big()); + } count = in.readUint32Big(); - for (u32 i = 0; i < count; i++) - x10_vertMaterials.push_back(in.readUByte()); + for (u32 i = 0; i < count; i++) { + x10_vertMaterials.emplace_back(in.readUByte()); + } count = in.readUint32Big(); - for (u32 i = 0; i < count; i++) - x20_edgeMaterials.push_back(in.readUByte()); + for (u32 i = 0; i < count; i++) { + x20_edgeMaterials.emplace_back(in.readUByte()); + } count = in.readUint32Big(); - for (u32 i = 0; i < count; i++) - x30_surfaceMaterials.push_back(in.readUByte()); + for (u32 i = 0; i < count; i++) { + x30_surfaceMaterials.emplace_back(in.readUByte()); + } count = in.readUint32Big(); - for (u32 i = 0; i < count; i++) - x40_edges.push_back(in); + for (u32 i = 0; i < count; i++) { + x40_edges.emplace_back(in); + } count = in.readUint32Big(); - for (u32 i = 0; i < count; i++) - x50_surfaceIndices.push_back(in.readUint16Big()); + for (u32 i = 0; i < count; i++) { + x50_surfaceIndices.emplace_back(in.readUint16Big()); + } count = in.readUint32Big(); - for (u32 i = 0; i < count; i++) - x60_vertices.push_back(zeus::CVector3f::ReadBig(in)); + for (u32 i = 0; i < count; i++) { + x60_vertices.emplace_back(zeus::CVector3f::ReadBig(in)); + } } COBBTree::CNode::CNode(const zeus::CTransform& xf, const zeus::CVector3f& point, @@ -195,14 +202,15 @@ COBBTree::CLeafData::CLeafData(std::vector&& surface) : x0_surface(std::mov const std::vector& COBBTree::CLeafData::GetSurfaceVector() const { return x0_surface; } size_t COBBTree::CLeafData::GetMemoryUsage() const { - size_t ret = (x0_surface.size() * 2) + /*sizeof(CLeafData)*/ 16; + const size_t ret = (x0_surface.size() * 2) + /*sizeof(CLeafData)*/ 16; return (ret + 3) & ~3; } COBBTree::CLeafData::CLeafData(CInputStream& in) { - u32 edgeCount = in.readUint32Big(); - for (u32 i = 0; i < edgeCount; i++) - x0_surface.push_back(in.readUint16Big()); + const u32 edgeCount = in.readUint32Big(); + for (u32 i = 0; i < edgeCount; i++) { + x0_surface.emplace_back(in.readUint16Big()); + } } } // namespace urde diff --git a/Runtime/Collision/COBBTree.hpp b/Runtime/Collision/COBBTree.hpp index 480bcf790..9ddd38acb 100644 --- a/Runtime/Collision/COBBTree.hpp +++ b/Runtime/Collision/COBBTree.hpp @@ -24,7 +24,7 @@ public: std::vector x50_surfaceIndices; std::vector x60_vertices; SIndexData() = default; - SIndexData(CInputStream&); + explicit SIndexData(CInputStream&); }; class CLeafData { @@ -32,8 +32,8 @@ public: public: CLeafData() = default; - CLeafData(std::vector&& surface); - CLeafData(CInputStream&); + explicit CLeafData(std::vector&& surface); + explicit CLeafData(CInputStream&); const std::vector& GetSurfaceVector() const; size_t GetMemoryUsage() const; @@ -51,7 +51,7 @@ public: CNode() = default; CNode(const zeus::CTransform&, const zeus::CVector3f&, std::unique_ptr&&, std::unique_ptr&&, std::unique_ptr&&); - CNode(CInputStream&); + explicit CNode(CInputStream&); bool WasHit() const { return x4c_hit; } void SetHit(bool h) { x4c_hit = h; } @@ -73,7 +73,7 @@ private: public: COBBTree() = default; - COBBTree(CInputStream&); + explicit COBBTree(CInputStream&); static std::unique_ptr BuildOrientedBoundingBoxTree(const zeus::CVector3f&, const zeus::CVector3f&); diff --git a/Runtime/Collision/ICollisionFilter.hpp b/Runtime/Collision/ICollisionFilter.hpp index 3c09e7fa3..c21f26b75 100644 --- a/Runtime/Collision/ICollisionFilter.hpp +++ b/Runtime/Collision/ICollisionFilter.hpp @@ -8,7 +8,7 @@ class ICollisionFilter { CActor& x4_actor; protected: - ICollisionFilter(CActor& actor) : x4_actor(actor) {} + explicit ICollisionFilter(CActor& actor) : x4_actor(actor) {} public: virtual void Filter(const CCollisionInfoList& in, CCollisionInfoList& out) const = 0; diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index 04ec2080f..8c07d64a7 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -220,7 +220,7 @@ CBooRenderer::CAreaListItem::CAreaListItem(const std::vector thisLights; @@ -1056,9 +1056,9 @@ std::pair CBooRenderer::SetViewportOrtho(bool void CBooRenderer::SetClippingPlanes(const zeus::CFrustum& frustum) { x44_frustumPlanes = frustum; } -void CBooRenderer::SetViewport(int l, int b, int w, int h) { - CGraphics::SetViewport(l, b, w, h); - CGraphics::SetScissor(l, b, w, h); +void CBooRenderer::SetViewport(int left, int bottom, int width, int height) { + CGraphics::SetViewport(left, bottom, width, height); + CGraphics::SetScissor(left, bottom, width, height); } void CBooRenderer::SetDebugOption(EDebugOption, int) {} diff --git a/Runtime/Graphics/CBooRenderer.hpp b/Runtime/Graphics/CBooRenderer.hpp index 321d8be4c..92ef59938 100644 --- a/Runtime/Graphics/CBooRenderer.hpp +++ b/Runtime/Graphics/CBooRenderer.hpp @@ -198,9 +198,9 @@ public: void AddWorldSurfaces(CBooModel& model); std::list::iterator FindStaticGeometry(const std::vector*); - void AddStaticGeometry(const std::vector*, const CAreaRenderOctTree*, int areaIdx, - const SShader* shaderSet) override; - void EnablePVS(const CPVSVisSet&, u32) override; + void AddStaticGeometry(const std::vector* geometry, const CAreaRenderOctTree* octTree, + int areaIdx, const SShader* shaderSet) override; + void EnablePVS(const CPVSVisSet& set, u32 areaIdx) override; void DisablePVS() override; void UpdateAreaUniforms(int areaIdx, EWorldShadowMode shadowMode = EWorldShadowMode::None, bool activateLights = true, int cubeFace = -1, const CModelFlags* ballShadowFlags = nullptr); @@ -212,17 +212,18 @@ public: void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) override; void PostRenderFogs() override; void SetModelMatrix(const zeus::CTransform& xf) override; - void AddParticleGen(const CParticleGen&) override; - void AddParticleGen(const CParticleGen&, const zeus::CVector3f&, const zeus::CAABox&) override; - void AddPlaneObject(const void*, const zeus::CAABox&, const zeus::CPlane&, int) override; - void AddDrawable(void const*, const zeus::CVector3f&, const zeus::CAABox&, int, EDrawableSorting) override; - void SetDrawableCallback(TDrawableCallback, const void*) override; - void SetWorldViewpoint(const zeus::CTransform&) override; - void SetPerspective(float, float, float, float, float) override; - void SetPerspective(float, float, float, float) override; - std::pair SetViewportOrtho(bool, float, float) override; + void AddParticleGen(const CParticleGen& gen) override; + void AddParticleGen(const CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) override; + void AddPlaneObject(const void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, int type) override; + void AddDrawable(const void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode, + EDrawableSorting sorting) override; + void SetDrawableCallback(TDrawableCallback cb, const void* ctx) override; + void SetWorldViewpoint(const zeus::CTransform& xf) override; + void SetPerspective(float fovy, float width, float height, float znear, float zfar) override; + void SetPerspective(float fovy, float aspect, float znear, float zfar) override; + std::pair SetViewportOrtho(bool centered, float znear, float zfar) override; void SetClippingPlanes(const zeus::CFrustum& frustum) override; - void SetViewport(int, int, int, int) override; + void SetViewport(int left, int bottom, int width, int height) override; // void SetDepthReadWrite(bool, bool); // void SetBlendMode_AdditiveAlpha(); // void SetBlendMode_AlphaBlended(); @@ -246,18 +247,18 @@ public: // void PrimColor(float, float, float, float); // void PrimColor(const zeus::CColor&); // void EndPrimitive(); - void SetAmbientColor(const zeus::CColor&) override; - void DrawString(const char*, int, int) override; + void SetAmbientColor(const zeus::CColor& color) override; + void DrawString(const char* string, int, int) override; u32 GetFPS() override; - void CacheReflection(TReflectionCallback, void*, bool) override; - void DrawSpaceWarp(const zeus::CVector3f&, float) override; + void CacheReflection(TReflectionCallback cb, void* ctx, bool clearAfter) override; + void DrawSpaceWarp(const zeus::CVector3f& pt, float strength) override; void DrawThermalModel(const CModel& model, const zeus::CColor& multCol, const zeus::CColor& addCol) override; void DrawXRayOutline(const zeus::CAABox&) override; - void SetWireframeFlags(int) override; - void SetWorldFog(ERglFogMode, float, float, const zeus::CColor&) override; - void RenderFogVolume(const zeus::CColor&, const zeus::CAABox&, const TLockedToken*, - const CSkinnedModel*) override; - void SetThermal(bool, float, const zeus::CColor&) override; + void SetWireframeFlags(int flags) override; + void SetWorldFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) override; + void RenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb, const TLockedToken* model, + const CSkinnedModel* sModel) override; + void SetThermal(bool thermal, float level, const zeus::CColor& color) override; void SetThermalColdScale(float scale) override; void DoThermalBlendCold() override; void DoThermalBlendHot() override; diff --git a/Runtime/Graphics/CGraphicsPalette.hpp b/Runtime/Graphics/CGraphicsPalette.hpp index 72e78b8b7..6c7b7e25b 100644 --- a/Runtime/Graphics/CGraphicsPalette.hpp +++ b/Runtime/Graphics/CGraphicsPalette.hpp @@ -21,8 +21,9 @@ class CGraphicsPalette { bool x1c_ = false; public: - CGraphicsPalette(EPaletteFormat fmt, int count) : x0_fmt(fmt), x8_entryCount(count), xc_entries(new u16[count]) {} - CGraphicsPalette(CInputStream& in) : x0_fmt(EPaletteFormat(in.readUint32Big())) { + explicit CGraphicsPalette(EPaletteFormat fmt, int count) + : x0_fmt(fmt), x8_entryCount(count), xc_entries(new u16[count]) {} + explicit CGraphicsPalette(CInputStream& in) : x0_fmt(EPaletteFormat(in.readUint32Big())) { u16 w = in.readUint16Big(); u16 h = in.readUint16Big(); x8_entryCount = w * h; diff --git a/Runtime/Graphics/CModel.hpp b/Runtime/Graphics/CModel.hpp index 62a79969f..9460599f3 100644 --- a/Runtime/Graphics/CModel.hpp +++ b/Runtime/Graphics/CModel.hpp @@ -106,7 +106,7 @@ struct SShader { MaterialSet m_matSet; std::optional m_geomLayout; int m_matSetIdx; - SShader(int idx) : m_matSetIdx(idx) { + explicit SShader(int idx) : m_matSetIdx(idx) { x0_textures.clear(); m_shaders.clear(); } diff --git a/Runtime/Graphics/CPVSAreaSet.hpp b/Runtime/Graphics/CPVSAreaSet.hpp index 732ca0e0e..fcd1ee99c 100644 --- a/Runtime/Graphics/CPVSAreaSet.hpp +++ b/Runtime/Graphics/CPVSAreaSet.hpp @@ -25,7 +25,7 @@ class CPVSAreaSet { } public: - CPVSAreaSet(const u8* data, u32 len); + explicit CPVSAreaSet(const u8* data, u32 len); u32 GetNumFeatures() const { return x0_numFeatures; } u32 GetNumActors() const { return xc_numActors; } u32 Get1stLightIndex(u32 lightIdx) const { return x0_numFeatures + x8_num2ndLights + lightIdx; } diff --git a/Runtime/Graphics/IRenderer.hpp b/Runtime/Graphics/IRenderer.hpp index 83c2e9aef..0d6bfae8c 100644 --- a/Runtime/Graphics/IRenderer.hpp +++ b/Runtime/Graphics/IRenderer.hpp @@ -27,7 +27,7 @@ struct SShader; class IRenderer { public: - typedef void (*TDrawableCallback)(const void*, const void*, int); + using TDrawableCallback = void (*)(const void*, const void*, int); using TReflectionCallback = std::function; enum class EDrawableSorting { SortedCallback, UnsortedCallback }; @@ -35,11 +35,11 @@ public: enum class EPrimitiveType {}; virtual ~IRenderer() = default; - virtual void AddStaticGeometry(const std::vector*, const CAreaRenderOctTree*, int, - const SShader*) = 0; - virtual void EnablePVS(const CPVSVisSet&, u32) = 0; + virtual void AddStaticGeometry(const std::vector* geometry, const CAreaRenderOctTree* octTree, + int areaIdx, const SShader* shaderSet) = 0; + virtual void EnablePVS(const CPVSVisSet& set, u32 areaIdx) = 0; virtual void DisablePVS() = 0; - virtual void RemoveStaticGeometry(const std::vector*) = 0; + virtual void RemoveStaticGeometry(const std::vector* geometry) = 0; virtual void DrawAreaGeometry(int areaIdx, int mask, int targetMask) = 0; virtual void DrawUnsortedGeometry(int areaIdx, int mask, int targetMask, bool shadowRender = false) = 0; virtual void DrawSortedGeometry(int areaIdx, int mask, int targetMask) = 0; @@ -47,17 +47,18 @@ public: virtual void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) = 0; virtual void PostRenderFogs() = 0; virtual void SetModelMatrix(const zeus::CTransform& xf) = 0; - virtual void AddParticleGen(const CParticleGen&) = 0; - virtual void AddParticleGen(const CParticleGen&, const zeus::CVector3f&, const zeus::CAABox&) = 0; - virtual void AddPlaneObject(const void*, const zeus::CAABox&, const zeus::CPlane&, int) = 0; - virtual void AddDrawable(void const*, const zeus::CVector3f&, const zeus::CAABox&, int, EDrawableSorting) = 0; - virtual void SetDrawableCallback(TDrawableCallback, const void*) = 0; - virtual void SetWorldViewpoint(const zeus::CTransform&) = 0; - virtual void SetPerspective(float, float, float, float, float) = 0; - virtual void SetPerspective(float, float, float, float) = 0; - virtual std::pair SetViewportOrtho(bool, float, float) = 0; - virtual void SetClippingPlanes(const zeus::CFrustum&) = 0; - virtual void SetViewport(int, int, int, int) = 0; + virtual void AddParticleGen(const CParticleGen& gen) = 0; + virtual void AddParticleGen(const CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) = 0; + virtual void AddPlaneObject(const void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, int type) = 0; + virtual void AddDrawable(const void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode, + EDrawableSorting sorting) = 0; + virtual void SetDrawableCallback(TDrawableCallback cb, const void* ctx) = 0; + virtual void SetWorldViewpoint(const zeus::CTransform& xf) = 0; + virtual void SetPerspective(float fovy, float width, float height, float znear, float zfar) = 0; + virtual void SetPerspective(float fovy, float aspect, float znear, float zfar) = 0; + virtual std::pair SetViewportOrtho(bool centered, float znear, float zfar) = 0; + virtual void SetClippingPlanes(const zeus::CFrustum& frustum) = 0; + virtual void SetViewport(int left, int bottom, int width, int height) = 0; // virtual void SetDepthReadWrite(bool, bool)=0; // virtual void SetBlendMode_AdditiveAlpha()=0; // virtual void SetBlendMode_AlphaBlended()=0; @@ -81,18 +82,18 @@ public: // virtual void PrimColor(float, float, float, float)=0; // virtual void PrimColor(const zeus::CColor&)=0; // virtual void EndPrimitive()=0; - virtual void SetAmbientColor(const zeus::CColor&) = 0; - virtual void DrawString(const char*, int, int) = 0; + virtual void SetAmbientColor(const zeus::CColor& color) = 0; + virtual void DrawString(const char* string, int, int) = 0; virtual u32 GetFPS() = 0; - virtual void CacheReflection(TReflectionCallback, void*, bool) = 0; - virtual void DrawSpaceWarp(const zeus::CVector3f&, float) = 0; - virtual void DrawThermalModel(const CModel&, const zeus::CColor&, const zeus::CColor&) = 0; - virtual void DrawXRayOutline(const zeus::CAABox&) = 0; - virtual void SetWireframeFlags(int) = 0; - virtual void SetWorldFog(ERglFogMode, float, float, const zeus::CColor&) = 0; - virtual void RenderFogVolume(const zeus::CColor&, const zeus::CAABox&, const TLockedToken*, - const CSkinnedModel*) = 0; - virtual void SetThermal(bool, float, const zeus::CColor&) = 0; + virtual void CacheReflection(TReflectionCallback cb, void* ctx, bool clearAfter) = 0; + virtual void DrawSpaceWarp(const zeus::CVector3f& pt, float strength) = 0; + virtual void DrawThermalModel(const CModel& model, const zeus::CColor& multCol, const zeus::CColor& addCol) = 0; + virtual void DrawXRayOutline(const zeus::CAABox& aabb) = 0; + virtual void SetWireframeFlags(int flags) = 0; + virtual void SetWorldFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) = 0; + virtual void RenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb, const TLockedToken* model, + const CSkinnedModel* sModel) = 0; + virtual void SetThermal(bool thermal, float level, const zeus::CColor& color) = 0; virtual void SetThermalColdScale(float scale) = 0; virtual void DoThermalBlendCold() = 0; virtual void DoThermalBlendHot() = 0; diff --git a/Runtime/Graphics/Shaders/CAABoxShader.hpp b/Runtime/Graphics/Shaders/CAABoxShader.hpp index 26b6e3096..ff3785fd0 100644 --- a/Runtime/Graphics/Shaders/CAABoxShader.hpp +++ b/Runtime/Graphics/Shaders/CAABoxShader.hpp @@ -24,7 +24,7 @@ class CAABoxShader { public: static void Initialize(); static void Shutdown(); - CAABoxShader(bool zOnly = false); + explicit CAABoxShader(bool zOnly = false); void setAABB(const zeus::CAABox& aabb); void draw(const zeus::CColor& color); }; diff --git a/Runtime/Graphics/Shaders/CColoredQuadFilter.hpp b/Runtime/Graphics/Shaders/CColoredQuadFilter.hpp index e6a61e281..631a4ee68 100644 --- a/Runtime/Graphics/Shaders/CColoredQuadFilter.hpp +++ b/Runtime/Graphics/Shaders/CColoredQuadFilter.hpp @@ -28,8 +28,8 @@ public: static void Initialize(); static void Shutdown(); static const zeus::CRectangle DefaultRect; - CColoredQuadFilter(EFilterType type); - CColoredQuadFilter(EFilterType type, const TLockedToken&) : CColoredQuadFilter(type) {} + explicit CColoredQuadFilter(EFilterType type); + explicit CColoredQuadFilter(EFilterType type, const TLockedToken&) : CColoredQuadFilter(type) {} void draw(const zeus::CColor& color, const zeus::CRectangle& rect = DefaultRect); void DrawFilter(EFilterShape shape, const zeus::CColor& color, float t) { draw(color); } }; @@ -39,8 +39,8 @@ class CWideScreenFilter { CColoredQuadFilter m_bottom; public: - CWideScreenFilter(EFilterType type) : m_top(type), m_bottom(type) {} - CWideScreenFilter(EFilterType type, const TLockedToken&) : CWideScreenFilter(type) {} + explicit CWideScreenFilter(EFilterType type) : m_top(type), m_bottom(type) {} + explicit CWideScreenFilter(EFilterType type, const TLockedToken&) : CWideScreenFilter(type) {} void draw(const zeus::CColor& color, float t); void DrawFilter(EFilterShape shape, const zeus::CColor& color, float t); diff --git a/Runtime/Graphics/Shaders/CRandomStaticFilter.hpp b/Runtime/Graphics/Shaders/CRandomStaticFilter.hpp index b48b224c8..858afe2b9 100644 --- a/Runtime/Graphics/Shaders/CRandomStaticFilter.hpp +++ b/Runtime/Graphics/Shaders/CRandomStaticFilter.hpp @@ -26,16 +26,16 @@ class CRandomStaticFilter { public: static void Initialize(); static void Shutdown(); - CRandomStaticFilter(EFilterType type, bool cookieCutter = false); - CRandomStaticFilter(EFilterType type, const TLockedToken&) : CRandomStaticFilter(type) {} + explicit CRandomStaticFilter(EFilterType type, bool cookieCutter = false); + explicit CRandomStaticFilter(EFilterType type, const TLockedToken&) : CRandomStaticFilter(type) {} void draw(const zeus::CColor& color, float t); void DrawFilter(EFilterShape, const zeus::CColor& color, float t) { draw(color, t); } }; class CCookieCutterDepthRandomStaticFilter : public CRandomStaticFilter { public: - CCookieCutterDepthRandomStaticFilter(EFilterType type) : CRandomStaticFilter(type, true) {} - CCookieCutterDepthRandomStaticFilter(EFilterType type, const TLockedToken&) + explicit CCookieCutterDepthRandomStaticFilter(EFilterType type) : CRandomStaticFilter(type, true) {} + explicit CCookieCutterDepthRandomStaticFilter(EFilterType type, const TLockedToken&) : CCookieCutterDepthRandomStaticFilter(type) {} }; diff --git a/Runtime/Graphics/Shaders/CScanLinesFilter.hpp b/Runtime/Graphics/Shaders/CScanLinesFilter.hpp index a789d957a..fd20fc785 100644 --- a/Runtime/Graphics/Shaders/CScanLinesFilter.hpp +++ b/Runtime/Graphics/Shaders/CScanLinesFilter.hpp @@ -23,21 +23,21 @@ class CScanLinesFilter { public: static void Initialize(); static void Shutdown(); - CScanLinesFilter(EFilterType type, bool even); + explicit CScanLinesFilter(EFilterType type, bool even); void draw(const zeus::CColor& color); void DrawFilter(EFilterShape, const zeus::CColor& color, float) { draw(color); } }; class CScanLinesFilterEven : public CScanLinesFilter { public: - CScanLinesFilterEven(EFilterType type) : CScanLinesFilter(type, true) {} - CScanLinesFilterEven(EFilterType type, const TLockedToken&) : CScanLinesFilterEven(type) {} + explicit CScanLinesFilterEven(EFilterType type) : CScanLinesFilter(type, true) {} + explicit CScanLinesFilterEven(EFilterType type, const TLockedToken&) : CScanLinesFilterEven(type) {} }; class CScanLinesFilterOdd : public CScanLinesFilter { public: - CScanLinesFilterOdd(EFilterType type) : CScanLinesFilter(type, false) {} - CScanLinesFilterOdd(EFilterType type, const TLockedToken&) : CScanLinesFilterOdd(type) {} + explicit CScanLinesFilterOdd(EFilterType type) : CScanLinesFilter(type, false) {} + explicit CScanLinesFilterOdd(EFilterType type, const TLockedToken&) : CScanLinesFilterOdd(type) {} }; } // namespace urde diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp b/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp index 9a96f973d..a035394e5 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp @@ -35,7 +35,7 @@ protected: ZTest m_zTest; bool m_flipRect = false; - CTexturedQuadFilter(const boo::ObjToken& tex); + explicit CTexturedQuadFilter(const boo::ObjToken& tex); public: struct Vert { @@ -45,8 +45,8 @@ public: static void Initialize(); static void Shutdown(); static const zeus::CRectangle DefaultRect; - CTexturedQuadFilter(EFilterType type, TLockedToken tex, ZTest zTest = ZTest::None); - CTexturedQuadFilter(EFilterType type, const boo::ObjToken& tex, ZTest zTest = ZTest::None); + explicit CTexturedQuadFilter(EFilterType type, TLockedToken tex, ZTest zTest = ZTest::None); + explicit CTexturedQuadFilter(EFilterType type, const boo::ObjToken& tex, ZTest zTest = ZTest::None); CTexturedQuadFilter(const CTexturedQuadFilter&) = delete; CTexturedQuadFilter& operator=(const CTexturedQuadFilter&) = delete; CTexturedQuadFilter(CTexturedQuadFilter&&) = default; @@ -63,8 +63,8 @@ class CTexturedQuadFilterAlpha : public CTexturedQuadFilter { public: static void Initialize(); static void Shutdown(); - CTexturedQuadFilterAlpha(EFilterType type, TLockedToken tex); - CTexturedQuadFilterAlpha(EFilterType type, const boo::ObjToken& tex); + explicit CTexturedQuadFilterAlpha(EFilterType type, TLockedToken tex); + explicit CTexturedQuadFilterAlpha(EFilterType type, const boo::ObjToken& tex); }; } // namespace urde diff --git a/Runtime/Graphics/Shaders/CWorldShadowShader.hpp b/Runtime/Graphics/Shaders/CWorldShadowShader.hpp index 0e0c189b6..b63708481 100644 --- a/Runtime/Graphics/Shaders/CWorldShadowShader.hpp +++ b/Runtime/Graphics/Shaders/CWorldShadowShader.hpp @@ -30,7 +30,7 @@ class CWorldShadowShader { public: static void Initialize(); static void Shutdown(); - CWorldShadowShader(u32 w, u32 h); + explicit CWorldShadowShader(u32 w, u32 h); void bindRenderTarget(); void drawBase(float extent); void lightenShadow(); diff --git a/Runtime/Graphics/Shaders/CXRayBlurFilter.hpp b/Runtime/Graphics/Shaders/CXRayBlurFilter.hpp index 35b08d986..704f9b235 100644 --- a/Runtime/Graphics/Shaders/CXRayBlurFilter.hpp +++ b/Runtime/Graphics/Shaders/CXRayBlurFilter.hpp @@ -24,7 +24,7 @@ class CXRayBlurFilter { public: static void Initialize(); static void Shutdown(); - CXRayBlurFilter(TLockedToken& tex); + explicit CXRayBlurFilter(TLockedToken& tex); void draw(float amount); }; diff --git a/Runtime/GuiSys/CAuiImagePane.cpp b/Runtime/GuiSys/CAuiImagePane.cpp index e73db407f..996e1ad4f 100644 --- a/Runtime/GuiSys/CAuiImagePane.cpp +++ b/Runtime/GuiSys/CAuiImagePane.cpp @@ -54,9 +54,9 @@ void CAuiImagePane::Update(float dt) { CAuiImagePane::Filters::Filters(TLockedToken& tex) : m_texId(tex.GetObjectTag()->id) , m_darkenerQuad(EFilterType::Blend, tex) -, m_flashQuad{{{EFilterType::Add, tex}, {EFilterType::Add, tex}}} -, m_alphaQuad{{{EFilterType::Blend, tex}, {EFilterType::Blend, tex}}} -, m_addQuad{{{EFilterType::Add, tex}, {EFilterType::Add, tex}}} {} +, m_flashQuad{{CTexturedQuadFilterAlpha{EFilterType::Add, tex}, CTexturedQuadFilterAlpha{EFilterType::Add, tex}}} +, m_alphaQuad{{CTexturedQuadFilterAlpha{EFilterType::Blend, tex}, CTexturedQuadFilterAlpha{EFilterType::Blend, tex}}} +, m_addQuad{{CTexturedQuadFilterAlpha{EFilterType::Add, tex}, CTexturedQuadFilterAlpha{EFilterType::Add, tex}}} {} void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, const CTexture& tex, int frame, float alpha, bool noBlur, CTexturedQuadFilterAlpha& quad) const { diff --git a/Runtime/GuiSys/CConsoleOutputWindow.cpp b/Runtime/GuiSys/CConsoleOutputWindow.cpp index 6348d0efe..f010c5de3 100644 --- a/Runtime/GuiSys/CConsoleOutputWindow.cpp +++ b/Runtime/GuiSys/CConsoleOutputWindow.cpp @@ -9,7 +9,7 @@ CIOWin::EMessageReturn CConsoleOutputWindow::OnMessage(const CArchitectureMessag return EMessageReturn::Normal; } -void CConsoleOutputWindow::Draw() const { +void CConsoleOutputWindow::Draw() { //SCOPED_GRAPHICS_DEBUG_GROUP("CConsoleOutputWindow::Draw", zeus::skGreen); } diff --git a/Runtime/GuiSys/CConsoleOutputWindow.hpp b/Runtime/GuiSys/CConsoleOutputWindow.hpp index 65fc0f862..40a8bb69f 100644 --- a/Runtime/GuiSys/CConsoleOutputWindow.hpp +++ b/Runtime/GuiSys/CConsoleOutputWindow.hpp @@ -8,7 +8,7 @@ class CConsoleOutputWindow : public CIOWin { public: CConsoleOutputWindow(int, float, float); EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override; - void Draw() const override; + void Draw() override; }; } // namespace urde diff --git a/Runtime/GuiSys/CErrorOutputWindow.cpp b/Runtime/GuiSys/CErrorOutputWindow.cpp index 4877135c7..04596dd20 100644 --- a/Runtime/GuiSys/CErrorOutputWindow.cpp +++ b/Runtime/GuiSys/CErrorOutputWindow.cpp @@ -15,7 +15,7 @@ CIOWin::EMessageReturn CErrorOutputWindow::OnMessage(const CArchitectureMessage& return EMessageReturn::Normal; } -void CErrorOutputWindow::Draw() const { +void CErrorOutputWindow::Draw() { //SCOPED_GRAPHICS_DEBUG_GROUP("CErrorOutputWindow::Draw", zeus::skGreen); } diff --git a/Runtime/GuiSys/CErrorOutputWindow.hpp b/Runtime/GuiSys/CErrorOutputWindow.hpp index 3049a1b3f..85b2231d6 100644 --- a/Runtime/GuiSys/CErrorOutputWindow.hpp +++ b/Runtime/GuiSys/CErrorOutputWindow.hpp @@ -27,7 +27,7 @@ public: explicit CErrorOutputWindow(bool); EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override; bool GetIsContinueDraw() const override { return int(x14_state) < 2; } - void Draw() const override; + void Draw() override; }; } // namespace urde diff --git a/Runtime/GuiSys/CGuiTextPane.cpp b/Runtime/GuiSys/CGuiTextPane.cpp index 57218caa7..681b89cf7 100644 --- a/Runtime/GuiSys/CGuiTextPane.cpp +++ b/Runtime/GuiSys/CGuiTextPane.cpp @@ -100,8 +100,7 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) { CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear); xd4_textSupport.Render(); - const_cast(this)->xd4_textSupport.SetGeometryColor - (geomCol * zeus::CColor(geomCol.a, geomCol.a, geomCol.a, 1.f)); + xd4_textSupport.SetGeometryColor(geomCol * zeus::CColor(geomCol.a, geomCol.a, geomCol.a, 1.f)); CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One, ERglBlendFactor::One, ERglLogicOp::Clear); xd4_textSupport.Render(); diff --git a/Runtime/GuiSys/CGuiTextSupport.cpp b/Runtime/GuiSys/CGuiTextSupport.cpp index 3f8834f48..a2a6cb993 100644 --- a/Runtime/GuiSys/CGuiTextSupport.cpp +++ b/Runtime/GuiSys/CGuiTextSupport.cpp @@ -25,21 +25,47 @@ CGuiTextSupport::CGuiTextSupport(CAssetId fontId, const CGuiTextProperties& prop x2cc_font = store->GetObj({SBIG('FONT'), fontId}); } -CTextRenderBuffer* CGuiTextSupport::GetCurrentPageRenderBuffer() const { - if (x60_renderBuf && !x308_multipageFlag) - return const_cast(&*x60_renderBuf); - if (!x308_multipageFlag || x2ec_renderBufferPages.size() <= x304_pageCounter) +CTextRenderBuffer* CGuiTextSupport::GetCurrentPageRenderBuffer() { + if (x60_renderBuf && !x308_multipageFlag) { + return &*x60_renderBuf; + } + + if (!x308_multipageFlag || x2ec_renderBufferPages.size() <= x304_pageCounter) { return nullptr; + } + int idx = 0; - for (const CTextRenderBuffer& buf : x2ec_renderBufferPages) - if (idx++ == x304_pageCounter) - return const_cast(&buf); + for (CTextRenderBuffer& buf : x2ec_renderBufferPages) { + if (idx++ == x304_pageCounter) { + return &buf; + } + } + + return nullptr; +} + +const CTextRenderBuffer* CGuiTextSupport::GetCurrentPageRenderBuffer() const { + if (x60_renderBuf && !x308_multipageFlag) { + return &*x60_renderBuf; + } + + if (!x308_multipageFlag || x2ec_renderBufferPages.size() <= x304_pageCounter) { + return nullptr; + } + + int idx = 0; + for (const CTextRenderBuffer& buf : x2ec_renderBufferPages) { + if (idx++ == x304_pageCounter) { + return &buf; + } + } + return nullptr; } float CGuiTextSupport::GetCurrentAnimationOverAge() const { float ret = 0.f; - if (CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) { + if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) { if (x50_typeEnable) { if (x40_primStartTimes.size()) { auto& lastTime = x40_primStartTimes.back(); @@ -53,16 +79,18 @@ float CGuiTextSupport::GetCurrentAnimationOverAge() const { } float CGuiTextSupport::GetNumCharsTotal() const { - if (CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) - if (x50_typeEnable) + if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) { + if (x50_typeEnable) { return buf->GetPrimitiveCount(); + } + } return 0.f; } float CGuiTextSupport::GetNumCharsPrinted() const { - if (CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) { + if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) { if (x50_typeEnable) { - float charsPrinted = x3c_curTime * x58_chRate; + const float charsPrinted = x3c_curTime * x58_chRate; return std::min(charsPrinted, float(buf->GetPrimitiveCount())); } } @@ -70,9 +98,11 @@ float CGuiTextSupport::GetNumCharsPrinted() const { } float CGuiTextSupport::GetTotalAnimationTime() const { - if (CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) - if (x50_typeEnable) + if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) { + if (x50_typeEnable) { return buf->GetPrimitiveCount() / x58_chRate; + } + } return 0.f; } @@ -235,16 +265,23 @@ void CGuiTextSupport::SetText(std::u16string_view str, bool multipage) { void CGuiTextSupport::SetText(std::string_view str, bool multipage) { SetText(hecl::UTF8ToChar16(str), multipage); } -bool CGuiTextSupport::_GetIsTextSupportFinishedLoading() const { - for (const CToken& tok : x2bc_assets) { - const_cast(tok).Lock(); - if (!tok.IsLoaded()) +bool CGuiTextSupport::_GetIsTextSupportFinishedLoading() { + for (CToken& tok : x2bc_assets) { + tok.Lock(); + + if (!tok.IsLoaded()) { return false; + } } - if (!x2cc_font) + + if (!x2cc_font) { return true; - if (x2cc_font.IsLoaded()) + } + + if (x2cc_font.IsLoaded()) { return x2cc_font->IsFinishedLoading(); + } + return false; } @@ -269,8 +306,8 @@ void CGuiTextSupport::SetImageBaseline(bool b) { } } -bool CGuiTextSupport::GetIsTextSupportFinishedLoading() const { - const_cast(this)->CheckAndRebuildRenderBuffer(); +bool CGuiTextSupport::GetIsTextSupportFinishedLoading() { + CheckAndRebuildRenderBuffer(); return _GetIsTextSupportFinishedLoading(); } diff --git a/Runtime/GuiSys/CGuiTextSupport.hpp b/Runtime/GuiSys/CGuiTextSupport.hpp index 3ca0dc5ab..6cc9c833f 100644 --- a/Runtime/GuiSys/CGuiTextSupport.hpp +++ b/Runtime/GuiSys/CGuiTextSupport.hpp @@ -84,8 +84,10 @@ class CGuiTextSupport { int x304_pageCounter = 0; bool x308_multipageFlag = false; - CTextRenderBuffer* GetCurrentPageRenderBuffer() const; - bool _GetIsTextSupportFinishedLoading() const; + CTextRenderBuffer* GetCurrentPageRenderBuffer(); + const CTextRenderBuffer* GetCurrentPageRenderBuffer() const; + + bool _GetIsTextSupportFinishedLoading(); public: CGuiTextSupport(CAssetId fontId, const CGuiTextProperties& props, const zeus::CColor& fontCol, @@ -114,7 +116,7 @@ public: void SetJustification(EJustification j); void SetVerticalJustification(EVerticalJustification j); void SetImageBaseline(bool b); - bool GetIsTextSupportFinishedLoading() const; + bool GetIsTextSupportFinishedLoading(); float GetCurTime() const { return x3c_curTime; } void SetCurTime(float t) { x3c_curTime = t; } std::u16string_view GetString() const { return x0_string; } diff --git a/Runtime/GuiSys/CHudDecoInterface.cpp b/Runtime/GuiSys/CHudDecoInterface.cpp index 5a7156584..d85df6618 100644 --- a/Runtime/GuiSys/CHudDecoInterface.cpp +++ b/Runtime/GuiSys/CHudDecoInterface.cpp @@ -17,7 +17,7 @@ namespace urde { void IHudDecoInterface::SetReticuleTransform(const zeus::CMatrix3f& xf) {} void IHudDecoInterface::SetDecoRotation(float angle) {} void IHudDecoInterface::SetFrameColorValue(float v) {} -void IHudDecoInterface::Draw() const {} +void IHudDecoInterface::Draw() {} void IHudDecoInterface::ProcessInput(const CFinalInput& input) {} float IHudDecoInterface::GetHudTextAlpha() const { return 1.f; } @@ -325,10 +325,11 @@ void CHudDecoInterfaceScan::Update(float dt, const CStateManager& stateMgr) { UpdateScanDisplay(stateMgr, dt); } -void CHudDecoInterfaceScan::Draw() const { +void CHudDecoInterfaceScan::Draw() { x18_scanDisplay.Draw(); - if (x10_loadedScanHudFlat) + if (x10_loadedScanHudFlat) { x10_loadedScanHudFlat->Draw(CGuiWidgetDrawParms::Default); + } } void CHudDecoInterfaceScan::ProcessInput(const CFinalInput& input) { x18_scanDisplay.ProcessInput(input); } diff --git a/Runtime/GuiSys/CHudDecoInterface.hpp b/Runtime/GuiSys/CHudDecoInterface.hpp index 8b489e854..e6e8f301e 100644 --- a/Runtime/GuiSys/CHudDecoInterface.hpp +++ b/Runtime/GuiSys/CHudDecoInterface.hpp @@ -28,7 +28,7 @@ public: virtual void SetDamageTransform(const zeus::CMatrix3f& rotation, const zeus::CVector3f& position) = 0; virtual void SetFrameColorValue(float v); virtual void Update(float dt, const CStateManager& stateMgr) = 0; - virtual void Draw() const; + virtual void Draw(); virtual void ProcessInput(const CFinalInput& input); virtual void UpdateCameraDebugSettings(float fov, float y, float z) = 0; virtual void UpdateHudAlpha() = 0; @@ -116,7 +116,7 @@ public: const CScannableObjectInfo* GetCurrScanInfo(const CStateManager& stateMgr) const; void UpdateScanDisplay(const CStateManager& stateMgr, float dt); void Update(float dt, const CStateManager& stateMgr) override; - void Draw() const override; + void Draw() override; void ProcessInput(const CFinalInput& input) override; void UpdateCameraDebugSettings(float fov, float y, float z) override; void UpdateHudAlpha() override; diff --git a/Runtime/GuiSys/CScanDisplay.cpp b/Runtime/GuiSys/CScanDisplay.cpp index 12dba9f4c..471f6ee18 100644 --- a/Runtime/GuiSys/CScanDisplay.cpp +++ b/Runtime/GuiSys/CScanDisplay.cpp @@ -35,20 +35,23 @@ void CScanDisplay::CDataDot::Update(float dt) { } } -void CScanDisplay::CDataDot::Draw(const zeus::CColor& col, float radius) const { - if (x24_alpha == 0.f) +void CScanDisplay::CDataDot::Draw(const zeus::CColor& col, float radius) { + if (x24_alpha == 0.f) { return; + } if (x0_dotState != EDotState::Hidden) { - zeus::CTransform xf = zeus::CTransform::Translate(xc_curPos.x(), 0.f, xc_curPos.y()); + const zeus::CTransform xf = zeus::CTransform::Translate(xc_curPos.x(), 0.f, xc_curPos.y()); CGraphics::SetModelMatrix(xf); zeus::CColor useColor = col; useColor.a() *= x24_alpha; - CTexturedQuadFilter::Vert verts[4] = {{{-radius, 0.f, radius}, {0.f, 1.f}}, - {{-radius, 0.f, -radius}, {0.f, 0.f}}, - {{radius, 0.f, radius}, {1.f, 1.f}}, - {{radius, 0.f, -radius}, {1.f, 0.f}}}; - const_cast(m_quad).drawVerts(useColor, verts); + const CTexturedQuadFilter::Vert verts[4] = { + {{-radius, 0.f, radius}, {0.f, 1.f}}, + {{-radius, 0.f, -radius}, {0.f, 0.f}}, + {{radius, 0.f, radius}, {1.f, 1.f}}, + {{radius, 0.f, -radius}, {1.f, 0.f}}, + }; + m_quad.drawVerts(useColor, verts); } } @@ -418,16 +421,18 @@ void CScanDisplay::Update(float dt, float scanningTime) { } } -void CScanDisplay::Draw() const { - if (!x0_dataDot.IsLoaded()) +void CScanDisplay::Draw() { + if (!x0_dataDot.IsLoaded()) { return; + } // No Z-test or write g_Renderer->SetViewportOrtho(true, -4096.f, 4096.f); // Additive alpha - float vpRatio = g_Viewport.xc_height / 480.f; - for (const CDataDot& dot : xbc_dataDots) + const float vpRatio = g_Viewport.xc_height / 480.f; + for (CDataDot& dot : xbc_dataDots) { dot.Draw(g_tweakGuiColors->GetScanDataDotColor(), g_tweakGui->GetScanDataDotRadius() * vpRatio); + } } } // namespace urde diff --git a/Runtime/GuiSys/CScanDisplay.hpp b/Runtime/GuiSys/CScanDisplay.hpp index 15ea47f0d..7b9c60d83 100644 --- a/Runtime/GuiSys/CScanDisplay.hpp +++ b/Runtime/GuiSys/CScanDisplay.hpp @@ -45,7 +45,7 @@ public: public: explicit CDataDot(const TLockedToken& dataDotTex) : m_quad(EFilterType::Add, dataDotTex) {} void Update(float dt); - void Draw(const zeus::CColor& color, float radius) const; + void Draw(const zeus::CColor& color, float radius); float GetTransitionFactor() const { return x1c_transDur > 0.f ? x20_remTime / x1c_transDur : 0.f; } void StartTransitionTo(const zeus::CVector2f&, float); void SetDestPosition(const zeus::CVector2f&); @@ -90,7 +90,7 @@ public: CGuiWidget* textGroup, CGuiModel* xmark, CGuiModel* abutton, CGuiModel* dash, float scanTime); void StopScan(); void Update(float dt, float scanningTime); - void Draw() const; + void Draw(); EScanState GetScanState() const { return xc_state; } TUniqueId ScanTarget() const { return x10_objId; } }; diff --git a/Runtime/GuiSys/CSplashScreen.cpp b/Runtime/GuiSys/CSplashScreen.cpp index 94938a13b..9c36cd163 100644 --- a/Runtime/GuiSys/CSplashScreen.cpp +++ b/Runtime/GuiSys/CSplashScreen.cpp @@ -48,19 +48,22 @@ CIOWin::EMessageReturn CSplashScreen::OnMessage(const CArchitectureMessage& msg, return EMessageReturn::Exit; } -void CSplashScreen::Draw() const { - if (!x25_textureLoaded) +void CSplashScreen::Draw() { + if (!x25_textureLoaded) { return; + } SCOPED_GRAPHICS_DEBUG_GROUP("CSplashScreen::Draw", zeus::skGreen); zeus::CColor color; - if (x14_which == ESplashScreen::Nintendo) + if (x14_which == ESplashScreen::Nintendo) { color = zeus::CColor{0.86f, 0.f, 0.f, 1.f}; + } - if (x18_splashTimeout > 1.5f) + if (x18_splashTimeout > 1.5f) { color.a() = 1.f - (x18_splashTimeout - 1.5f) * 2.f; - else if (x18_splashTimeout < 0.5f) + } else if (x18_splashTimeout < 0.5f) { color.a() = x18_splashTimeout * 2.f; + } zeus::CRectangle rect; rect.size.x() = m_quad.GetTex()->GetWidth() / (480.f * g_Viewport.aspect); @@ -68,7 +71,7 @@ void CSplashScreen::Draw() const { rect.position.x() = 0.5f - rect.size.x() / 2.f; rect.position.y() = 0.5f - rect.size.y() / 2.f; - const_cast(m_quad).draw(color, 1.f, rect); + m_quad.draw(color, 1.f, rect); } } // namespace urde diff --git a/Runtime/GuiSys/CSplashScreen.hpp b/Runtime/GuiSys/CSplashScreen.hpp index 435d4459c..4737ea26b 100644 --- a/Runtime/GuiSys/CSplashScreen.hpp +++ b/Runtime/GuiSys/CSplashScreen.hpp @@ -24,7 +24,7 @@ private: public: explicit CSplashScreen(ESplashScreen); EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override; - void Draw() const override; + void Draw() override; }; } // namespace urde diff --git a/Runtime/MP1/CCredits.cpp b/Runtime/MP1/CCredits.cpp index 72e4e73fa..1c229dbc7 100644 --- a/Runtime/MP1/CCredits.cpp +++ b/Runtime/MP1/CCredits.cpp @@ -10,7 +10,7 @@ CIOWin::EMessageReturn CCredits::OnMessage(const CArchitectureMessage& msg, CArc return EMessageReturn::Normal; } -void CCredits::Draw() const { +void CCredits::Draw() { SCOPED_GRAPHICS_DEBUG_GROUP("CCredits::Draw", zeus::skGreen); } diff --git a/Runtime/MP1/CCredits.hpp b/Runtime/MP1/CCredits.hpp index 624b00ee7..6648a8a83 100644 --- a/Runtime/MP1/CCredits.hpp +++ b/Runtime/MP1/CCredits.hpp @@ -9,7 +9,7 @@ public: CCredits(); EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override; bool GetIsContinueDraw() const override { return false; } - void Draw() const override; + void Draw() override; }; } // namespace urde::MP1 diff --git a/Runtime/MP1/CFaceplateDecoration.hpp b/Runtime/MP1/CFaceplateDecoration.hpp index 76518afd1..94891bfaa 100644 --- a/Runtime/MP1/CFaceplateDecoration.hpp +++ b/Runtime/MP1/CFaceplateDecoration.hpp @@ -18,7 +18,7 @@ class CFaceplateDecoration { std::optional m_texFilter; public: - CFaceplateDecoration(CStateManager& stateMgr); + explicit CFaceplateDecoration(CStateManager& stateMgr); void Update(float dt, CStateManager& stateMgr); void Draw(CStateManager& stateMgr); }; diff --git a/Runtime/MP1/CFrontEndUI.cpp b/Runtime/MP1/CFrontEndUI.cpp index 69aa28b0a..d63175e44 100644 --- a/Runtime/MP1/CFrontEndUI.cpp +++ b/Runtime/MP1/CFrontEndUI.cpp @@ -1906,9 +1906,10 @@ void CFrontEndUI::CompleteStateTransition() { void CFrontEndUI::HandleDebugMenuReturnValue(CGameDebug::EReturnValue val, CArchitectureQueue& queue) {} -void CFrontEndUI::Draw() const { - if (x14_phase < EPhase::DisplayFrontEnd) +void CFrontEndUI::Draw() { + if (x14_phase < EPhase::DisplayFrontEnd) { return; + } SCOPED_GRAPHICS_DEBUG_GROUP("CFrontEndUI::Draw", zeus::skGreen); if (xec_emuFrme) { diff --git a/Runtime/MP1/CFrontEndUI.hpp b/Runtime/MP1/CFrontEndUI.hpp index 8bbc37798..b1c2aac75 100644 --- a/Runtime/MP1/CFrontEndUI.hpp +++ b/Runtime/MP1/CFrontEndUI.hpp @@ -203,7 +203,7 @@ public: bool m_gbaOverride = false; - SFusionBonusFrame(CFrontEndUITouchBar& touchBar); + explicit SFusionBonusFrame(CFrontEndUITouchBar& touchBar); void FinishedLoading(); bool PumpLoad(); void SetTableColors(CGuiTableGroup* tbgp) const; @@ -354,7 +354,7 @@ private: std::unique_ptr xf0_optionsFrme; CStaticAudioPlayer* xf4_curAudio = nullptr; - CColoredQuadFilter m_fadeToBlack = {EFilterType::Blend}; + CColoredQuadFilter m_fadeToBlack{EFilterType::Blend}; std::optional m_pressStartQuad; std::unique_ptr m_touchBar; @@ -385,7 +385,7 @@ public: void StartStateTransition(EScreen screen); void CompleteStateTransition(); void HandleDebugMenuReturnValue(CGameDebug::EReturnValue val, CArchitectureQueue& queue); - void Draw() const override; + void Draw() override; void UpdateMovies(float dt); bool PumpMovieLoad(); void ProcessUserInput(const CFinalInput& input, CArchitectureQueue& queue); diff --git a/Runtime/MP1/CFrontEndUITouchBar.cpp b/Runtime/MP1/CFrontEndUITouchBar.cpp index ccc5ccf2f..6afb30f10 100644 --- a/Runtime/MP1/CFrontEndUITouchBar.cpp +++ b/Runtime/MP1/CFrontEndUITouchBar.cpp @@ -2,7 +2,7 @@ namespace urde { -CFrontEndUITouchBar::~CFrontEndUITouchBar() {} +CFrontEndUITouchBar::~CFrontEndUITouchBar() = default; void CFrontEndUITouchBar::SetPhase(EPhase ph) { m_phase = ph; } CFrontEndUITouchBar::EPhase CFrontEndUITouchBar::GetPhase() { return m_phase; } void CFrontEndUITouchBar::SetFileSelectPhase(const SFileSelectDetail details[3], bool eraseGame, bool galleryActive) { diff --git a/Runtime/MP1/CInGameGuiManager.hpp b/Runtime/MP1/CInGameGuiManager.hpp index 367c0e8e4..d59fb335e 100644 --- a/Runtime/MP1/CInGameGuiManager.hpp +++ b/Runtime/MP1/CInGameGuiManager.hpp @@ -98,9 +98,9 @@ private: std::optional m_deathRenderTexQuad; std::optional m_deathDotQuad; - CRandomStaticFilter m_randomStatic = {EFilterType::Blend}; - CColoredQuadFilter m_deathWhiteout = {EFilterType::Blend}; - CColoredQuadFilter m_deathBlackout = {EFilterType::Blend}; + CRandomStaticFilter m_randomStatic{EFilterType::Blend}; + CColoredQuadFilter m_deathWhiteout{EFilterType::Blend}; + CColoredQuadFilter m_deathBlackout{EFilterType::Blend}; union { struct { @@ -126,7 +126,7 @@ private: void RefreshHudOptions(); public: - CInGameGuiManager(CStateManager& stateMgr, CArchitectureQueue& archQueue); + explicit CInGameGuiManager(CStateManager& stateMgr, CArchitectureQueue& archQueue); bool CheckLoadComplete(CStateManager& stateMgr); void Update(CStateManager& stateMgr, float dt, CArchitectureQueue& archQueue, bool useHud); void ProcessControllerInput(CStateManager& stateMgr, const CFinalInput& input, CArchitectureQueue& archQueue); diff --git a/Runtime/MP1/CMFGame.cpp b/Runtime/MP1/CMFGame.cpp index 5bfa54a36..3b05488a0 100644 --- a/Runtime/MP1/CMFGame.cpp +++ b/Runtime/MP1/CMFGame.cpp @@ -193,9 +193,10 @@ void CMFGame::Touch() { player.GetMorphBall()->TouchModel(*x14_stateManager); } -void CMFGame::Draw() const { - if (!x2a_24_initialized) +void CMFGame::Draw() { + if (!x2a_24_initialized) { return; + } SCOPED_GRAPHICS_DEBUG_GROUP("CMFGame::Draw", zeus::skGreen); const_cast(*this).Touch(); @@ -210,8 +211,8 @@ void CMFGame::Draw() const { x18_guiManager->Draw(*x14_stateManager); if (x1c_flowState == EGameFlowState::CinematicSkip) { - float c = std::min(1.f, 1.f - x20_cineSkipTime); - const_cast(m_fadeToBlack).draw(zeus::CColor{c, c, c, c}); + const float c = std::min(1.f, 1.f - x20_cineSkipTime); + m_fadeToBlack.draw(zeus::CColor{c, c, c, c}); } } @@ -279,7 +280,7 @@ CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader") { } } -CMFGameLoader::~CMFGameLoader() {} +CMFGameLoader::~CMFGameLoader() = default; static const char* LoadDepPAKs[] = {"TestAnim", "SamusGun", "SamGunFx", nullptr}; @@ -364,7 +365,7 @@ CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg, return EMessageReturn::Exit; } -void CMFGameLoader::Draw() const { +void CMFGameLoader::Draw() { SCOPED_GRAPHICS_DEBUG_GROUP("CMFGameLoader::Draw", zeus::skGreen); g_GameState->GetWorldTransitionManager()->Draw(); } diff --git a/Runtime/MP1/CMFGame.hpp b/Runtime/MP1/CMFGame.hpp index 261bbba37..fe7d70ca3 100644 --- a/Runtime/MP1/CMFGame.hpp +++ b/Runtime/MP1/CMFGame.hpp @@ -31,7 +31,7 @@ class CMFGame : public CMFGameBase { u8 _dummy = 0; }; - CColoredQuadFilter m_fadeToBlack = {EFilterType::Multiply}; + CColoredQuadFilter m_fadeToBlack{EFilterType::Multiply}; bool IsCameraActiveFlow() const { return (x1c_flowState == EGameFlowState::InGame || x1c_flowState == EGameFlowState::SamusDied); @@ -43,7 +43,7 @@ public: ~CMFGame() override; CIOWin::EMessageReturn OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) override; void Touch(); - void Draw() const override; + void Draw() override; void PlayerDied(); void UnpauseGame(); void EnterMessageScreen(float time); @@ -72,7 +72,7 @@ public: CMFGameLoader(); ~CMFGameLoader() override; EMessageReturn OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) override; - void Draw() const override; + void Draw() override; }; } // namespace MP1 diff --git a/Runtime/MP1/CMainFlow.hpp b/Runtime/MP1/CMainFlow.hpp index ec2a5df57..04c0f0da1 100644 --- a/Runtime/MP1/CMainFlow.hpp +++ b/Runtime/MP1/CMainFlow.hpp @@ -14,7 +14,7 @@ public: void AdvanceGameState(CArchitectureQueue& queue) override; void SetGameState(EClientFlowStates state, CArchitectureQueue& queue) override; bool GetIsContinueDraw() const override { return false; } - void Draw() const override {} + void Draw() override {} }; } // namespace MP1 diff --git a/Runtime/MP1/CMemoryCardDriver.hpp b/Runtime/MP1/CMemoryCardDriver.hpp index 2e89cdd2d..59a161e75 100644 --- a/Runtime/MP1/CMemoryCardDriver.hpp +++ b/Runtime/MP1/CMemoryCardDriver.hpp @@ -99,7 +99,7 @@ private: u8 x0_saveBuffer[940] = {}; CGameState::GameFileStateInfo x944_fileInfo; SGameFileSlot(); - SGameFileSlot(CMemoryInStream& in); + explicit SGameFileSlot(CMemoryInStream& in); void InitializeFromGameState(); void LoadGameState(u32 idx); void DoPut(CMemoryOutStream& w) const { w.writeBytes(x0_saveBuffer, 940); } diff --git a/Runtime/MP1/CMessageScreen.hpp b/Runtime/MP1/CMessageScreen.hpp index ea0b77b7e..8998cb06f 100644 --- a/Runtime/MP1/CMessageScreen.hpp +++ b/Runtime/MP1/CMessageScreen.hpp @@ -39,7 +39,7 @@ class CMessageScreen { bool x78_24_exit : 1; public: - CMessageScreen(CAssetId msg, float time); + explicit CMessageScreen(CAssetId msg, float time); void ProcessControllerInput(const CFinalInput& input); bool Update(float dt, float blurAmt); void Draw() const; diff --git a/Runtime/MP1/CPauseScreenBlur.hpp b/Runtime/MP1/CPauseScreenBlur.hpp index 7ea1e5080..e96b2eafc 100644 --- a/Runtime/MP1/CPauseScreenBlur.hpp +++ b/Runtime/MP1/CPauseScreenBlur.hpp @@ -20,8 +20,8 @@ class CPauseScreenBlur { EState x14_nextState = EState::InGame; float x18_blurAmt = 0.f; CCameraBlurPass x1c_camBlur; - CTexturedQuadFilter m_quarterFilter = {EFilterType::Multiply, x4_mapLightQuarter}; - CScanLinesFilterEven m_linesFilter = {EFilterType::Multiply}; + CTexturedQuadFilter m_quarterFilter{EFilterType::Multiply, x4_mapLightQuarter}; + CScanLinesFilterEven m_linesFilter{EFilterType::Multiply}; union { struct { diff --git a/Runtime/MP1/CPlayMovie.hpp b/Runtime/MP1/CPlayMovie.hpp index cb1d7199e..f881461e1 100644 --- a/Runtime/MP1/CPlayMovie.hpp +++ b/Runtime/MP1/CPlayMovie.hpp @@ -32,7 +32,7 @@ private: static bool IsResultsScreen(EWhichMovie which); public: - CPlayMovie(EWhichMovie which); + explicit CPlayMovie(EWhichMovie which); }; } // namespace urde::MP1 diff --git a/Runtime/MP1/CPlayerVisor.hpp b/Runtime/MP1/CPlayerVisor.hpp index 46b19da3a..0d2077777 100644 --- a/Runtime/MP1/CPlayerVisor.hpp +++ b/Runtime/MP1/CPlayerVisor.hpp @@ -82,7 +82,7 @@ class CPlayerVisor { void BeginTransitionOut(); public: - CPlayerVisor(CStateManager& stateMgr); + explicit CPlayerVisor(CStateManager& stateMgr); ~CPlayerVisor(); void Update(float dt, const CStateManager& stateMgr); void Draw(const CStateManager& stateMgr, const CTargetingManager* tgtManager) const; diff --git a/Runtime/MP1/CQuitGameScreen.hpp b/Runtime/MP1/CQuitGameScreen.hpp index c0c5424f0..ea339d06a 100644 --- a/Runtime/MP1/CQuitGameScreen.hpp +++ b/Runtime/MP1/CQuitGameScreen.hpp @@ -36,7 +36,7 @@ public: EQuitAction Update(float dt); void Draw(); void ProcessUserInput(const CFinalInput& input); - CQuitGameScreen(EQuitType type); + explicit CQuitGameScreen(EQuitType type); }; } // namespace MP1 diff --git a/Runtime/MP1/CSamusFaceReflection.hpp b/Runtime/MP1/CSamusFaceReflection.hpp index 76193664e..23674de17 100644 --- a/Runtime/MP1/CSamusFaceReflection.hpp +++ b/Runtime/MP1/CSamusFaceReflection.hpp @@ -19,7 +19,7 @@ class CSamusFaceReflection { bool x70_hidden = true; public: - CSamusFaceReflection(CStateManager& stateMgr); + explicit CSamusFaceReflection(CStateManager& stateMgr); void PreDraw(const CStateManager& stateMgr); void Draw(const CStateManager& stateMgr) const; void Update(float dt, const CStateManager& stateMgr, CRandom16& rand); diff --git a/Runtime/MP1/CSamusHud.hpp b/Runtime/MP1/CSamusHud.hpp index 25c76597e..a89fd8d08 100644 --- a/Runtime/MP1/CSamusHud.hpp +++ b/Runtime/MP1/CSamusHud.hpp @@ -173,7 +173,7 @@ class CSamusHud { rstl::reserved_vector x7ac_; CColoredQuadFilter m_energyDrainFilter; - CCookieCutterDepthRandomStaticFilter m_cookieCutterStatic = {EFilterType::NoColor}; + CCookieCutterDepthRandomStaticFilter m_cookieCutterStatic{EFilterType::NoColor}; static CSamusHud* g_SamusHud; static rstl::reserved_vector BuildPlayerHasVisors(const CStateManager& mgr); @@ -211,7 +211,7 @@ class CSamusHud { static EHudState GetDesiredHudState(const CStateManager& mgr); public: - CSamusHud(CStateManager& stateMgr); + explicit CSamusHud(CStateManager& stateMgr); ~CSamusHud(); void Update(float dt, const CStateManager& mgr, CInGameGuiManager::EHelmetVisMode helmetVis, bool hudVis, bool targetingManager); diff --git a/Runtime/MP1/CSaveGameScreen.hpp b/Runtime/MP1/CSaveGameScreen.hpp index b37fab7e0..ee5735383 100644 --- a/Runtime/MP1/CSaveGameScreen.hpp +++ b/Runtime/MP1/CSaveGameScreen.hpp @@ -108,7 +108,7 @@ public: const CGameState::GameFileStateInfo* GetGameData(int idx) const; EUIType GetUIType() const { return x10_uiType; } bool IsSavingDisabled() const { return x92_savingDisabled; } - CSaveGameScreen(ESaveContext saveCtx, u64 serial); + explicit CSaveGameScreen(ESaveContext saveCtx, u64 serial); }; } // namespace MP1 diff --git a/Runtime/MP1/CSlideShow.cpp b/Runtime/MP1/CSlideShow.cpp index 60a3c6e6d..40b0d9571 100644 --- a/Runtime/MP1/CSlideShow.cpp +++ b/Runtime/MP1/CSlideShow.cpp @@ -124,18 +124,19 @@ CIOWin::EMessageReturn CSlideShow::OnMessage(const CArchitectureMessage& msg, CA return EMessageReturn::Exit; } -void CSlideShow::SSlideData::Draw() const { - if (!IsLoaded()) +void CSlideShow::SSlideData::Draw() { + if (!IsLoaded()) { return; + } - zeus::CRectangle rect; - const_cast(*m_texQuad).draw(x30_mulColor, 1.f, rect); + const zeus::CRectangle rect; + m_texQuad->draw(x30_mulColor, 1.f, rect); - zeus::CVector2f centeredOffset((x28_canvasSize.x() - m_texQuad->GetTex()->GetWidth()) * 0.5f, - (x28_canvasSize.y() - m_texQuad->GetTex()->GetHeight()) * 0.5f); + const zeus::CVector2f centeredOffset((x28_canvasSize.x() - m_texQuad->GetTex()->GetWidth()) * 0.5f, + (x28_canvasSize.y() - m_texQuad->GetTex()->GetHeight()) * 0.5f); } -void CSlideShow::Draw() const { +void CSlideShow::Draw() { SCOPED_GRAPHICS_DEBUG_GROUP("CSlideShow::Draw", zeus::skGreen); if (x14_phase == Phase::Five) { x5c_slideA.Draw(); diff --git a/Runtime/MP1/CSlideShow.hpp b/Runtime/MP1/CSlideShow.hpp index ceed2212e..11087684f 100644 --- a/Runtime/MP1/CSlideShow.hpp +++ b/Runtime/MP1/CSlideShow.hpp @@ -33,11 +33,11 @@ public: zeus::CVector2f x28_canvasSize; zeus::CColor x30_mulColor = zeus::skWhite; - SSlideData(CSlideShow& parent) : x0_parent(parent) { x30_mulColor.a() = 0.f; } + explicit SSlideData(CSlideShow& parent) : x0_parent(parent) { x30_mulColor.a() = 0.f; } void SetTexture(const TLockedToken& tex) { m_texQuad.emplace(EFilterType::Blend, tex); } bool IsLoaded() const { return m_texQuad && m_texQuad->GetTex().IsLoaded(); } - void Draw() const; + void Draw(); }; private: @@ -110,7 +110,7 @@ public: CSlideShow(); EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override; bool GetIsContinueDraw() const override { return false; } - void Draw() const override; + void Draw() override; static u32 SlideShowGalleryFlags(); }; diff --git a/Runtime/MP1/World/CBabygoth.hpp b/Runtime/MP1/World/CBabygoth.hpp index 634c77d33..706f0be2e 100644 --- a/Runtime/MP1/World/CBabygoth.hpp +++ b/Runtime/MP1/World/CBabygoth.hpp @@ -45,7 +45,7 @@ struct CBabygothData { CAssetId x174_flamePlayerIceTxtr; public: - CBabygothData(CInputStream&); + explicit CBabygothData(CInputStream&); const CDamageInfo& GetFireballDamage() const { return xc_fireballDamage; } CAssetId GetFireballResID() const { return x8_fireballWeapon; } float GetFireballAttackVariance() const { return x4_fireballAttackTimeVariance; } diff --git a/Runtime/MP1/World/CChozoGhost.hpp b/Runtime/MP1/World/CChozoGhost.hpp index 410e69c4d..82fb3f002 100644 --- a/Runtime/MP1/World/CChozoGhost.hpp +++ b/Runtime/MP1/World/CChozoGhost.hpp @@ -25,7 +25,7 @@ public: u32 x1c_numBolts; public: - CBehaveChance(CInputStream&); + explicit CBehaveChance(CInputStream&); EBehaveType GetBehave(EBehaveType type, CStateManager& mgr) const; float GetLurk() const { return x4_lurk; } diff --git a/Runtime/MP1/World/CFlaahgra.hpp b/Runtime/MP1/World/CFlaahgra.hpp index 64a7eaca9..46a01e1f1 100644 --- a/Runtime/MP1/World/CFlaahgra.hpp +++ b/Runtime/MP1/World/CFlaahgra.hpp @@ -48,7 +48,7 @@ class CFlaahgraData { public: static constexpr u32 GetNumProperties() { return 23; } - CFlaahgraData(CInputStream&); + explicit CFlaahgraData(CInputStream&); const CAnimationParameters& GetAnimationParameters() const { return x14c_animationParameters; } }; diff --git a/Runtime/MP1/World/CFlyingPirate.cpp b/Runtime/MP1/World/CFlyingPirate.cpp index 685f31c24..615bb13b1 100644 --- a/Runtime/MP1/World/CFlyingPirate.cpp +++ b/Runtime/MP1/World/CFlyingPirate.cpp @@ -337,8 +337,8 @@ CFlyingPirate::CFlyingPirate(TUniqueId uid, std::string_view name, const CEntity x7e0_gunSegId = animData->GetLocatorSegId("L_gun_LCTR"sv); x864_missileSegments.push_back(animData->GetLocatorSegId("L_Missile_LCTR"sv)); x864_missileSegments.push_back(animData->GetLocatorSegId("R_Missile_LCTR"sv)); - x850_height = - modelData->GetScale().x() * GetAnimationDistance({3, CPASAnimParm::FromEnum(3), CPASAnimParm::FromEnum(1)}); + x850_height = modelData->GetScale().x() * + GetAnimationDistance(CPASAnimParmData{3, CPASAnimParm::FromEnum(3), CPASAnimParm::FromEnum(1)}); if (x568_data.xd8_particleGen1.IsValid() && x568_data.xdc_particleGen2.IsValid() && x568_data.xe0_particleGen3.IsValid()) { x65c_particleGenDescs.push_back(g_SimplePool->GetObj({SBIG('PART'), x568_data.xd8_particleGen1})); @@ -763,7 +763,7 @@ void CFlyingPirate::FireProjectile(CStateManager& mgr, float dt) { } if (projectileFired) { const std::pair& anim = x450_bodyController->GetPASDatabase().FindBestAnimation( - {24, CPASAnimParm::FromEnum(2)}, *mgr.GetActiveRandom(), -1); + CPASAnimParmData{24, CPASAnimParm::FromEnum(2)}, *mgr.GetActiveRandom(), -1); if (anim.first > 0.f) { GetModelData()->GetAnimationData()->AddAdditiveAnimation(anim.second, 1.f, false, true); } diff --git a/Runtime/MP1/World/CMagdolite.hpp b/Runtime/MP1/World/CMagdolite.hpp index 5c61935ab..9346e6027 100644 --- a/Runtime/MP1/World/CMagdolite.hpp +++ b/Runtime/MP1/World/CMagdolite.hpp @@ -16,7 +16,7 @@ public: float x1c_; public: - CMagdoliteData(CInputStream&); + explicit CMagdoliteData(CInputStream&); }; private: diff --git a/Runtime/MP1/World/CMetroid.hpp b/Runtime/MP1/World/CMetroid.hpp index d9018c6a6..1a547f75c 100644 --- a/Runtime/MP1/World/CMetroid.hpp +++ b/Runtime/MP1/World/CMetroid.hpp @@ -25,7 +25,7 @@ class CMetroidData { bool x128_24_ : 1; public: - CMetroidData(CInputStream& in); + explicit CMetroidData(CInputStream& in); static u32 GetNumProperties() { return skNumProperties; } }; diff --git a/Runtime/MP1/World/CMetroidBeta.hpp b/Runtime/MP1/World/CMetroidBeta.hpp index 17386ab6e..2b09987cc 100644 --- a/Runtime/MP1/World/CMetroidBeta.hpp +++ b/Runtime/MP1/World/CMetroidBeta.hpp @@ -38,7 +38,7 @@ class CMetroidBetaData { bool x108_24_ : 1; public: - CMetroidBetaData(CInputStream&); + explicit CMetroidBetaData(CInputStream&); }; class CMetroidBeta : public CPatterned { s32 x568_progState = -1; diff --git a/Runtime/MP1/World/CSpacePirate.cpp b/Runtime/MP1/World/CSpacePirate.cpp index 92a857060..3e8d59d30 100644 --- a/Runtime/MP1/World/CSpacePirate.cpp +++ b/Runtime/MP1/World/CSpacePirate.cpp @@ -618,10 +618,11 @@ bool CSpacePirate::FireProjectile(float dt, CStateManager& mgr) { } } if (ret) { - auto bestAnim = x450_bodyController->GetPASDatabase().FindBestAnimation({24, CPASAnimParm::FromEnum(2)}, - *mgr.GetActiveRandom(), -1); - if (bestAnim.first > 0.f) + const auto bestAnim = x450_bodyController->GetPASDatabase().FindBestAnimation( + CPASAnimParmData{24, CPASAnimParm::FromEnum(2)}, *mgr.GetActiveRandom(), -1); + if (bestAnim.first > 0.f) { x64_modelData->GetAnimationData()->AddAdditiveAnimation(bestAnim.second, 1.f, false, true); + } CSfxManager::AddEmitter(x568_pirateData.x48_Sound_Projectile, GetTranslation(), zeus::skZero3f, true, false, 0x7f, kInvalidAreaId); } @@ -1876,8 +1877,8 @@ void CSpacePirate::Taunt(CStateManager& mgr, EStateMsg msg, float dt) { if (!x635_27_shadowPirate) { bool withOtherPirate = true; if (x634_27_melee) { - auto bestAnim = x450_bodyController->GetPASDatabase().FindBestAnimation({16, CPASAnimParm::FromEnum(2)}, - *mgr.GetActiveRandom(), -1); + const auto bestAnim = x450_bodyController->GetPASDatabase().FindBestAnimation( + CPASAnimParmData{16, CPASAnimParm::FromEnum(2)}, *mgr.GetActiveRandom(), -1); if (bestAnim.first > 0.f) { withOtherPirate = false; x760_taunt = pas::ETauntType::Two; diff --git a/Runtime/RetroTypes.hpp b/Runtime/RetroTypes.hpp index bc46c2c5e..6c0c70628 100644 --- a/Runtime/RetroTypes.hpp +++ b/Runtime/RetroTypes.hpp @@ -55,7 +55,7 @@ struct SObjectTag { [[nodiscard]] constexpr bool operator<(const SObjectTag& other) const noexcept { return id < other.id; } constexpr SObjectTag() noexcept = default; constexpr SObjectTag(FourCC tp, CAssetId rid) noexcept : type(tp), id(rid) {} - SObjectTag(CInputStream& in) { + explicit SObjectTag(CInputStream& in) { in.readBytesToBuf(&type, 4); id = CAssetId(in); } diff --git a/Runtime/Weapon/CPhazonBeam.hpp b/Runtime/Weapon/CPhazonBeam.hpp index 8de5486ab..5b63feb0a 100644 --- a/Runtime/Weapon/CPhazonBeam.hpp +++ b/Runtime/Weapon/CPhazonBeam.hpp @@ -22,8 +22,8 @@ class CPhazonBeam final : public CGunWeapon { bool x274_26_veinsAlphaActive : 1; bool x274_27_phazonVeinsIdx : 1; float x278_fireTime = 1.f / 3.f; - mutable CAABoxShader m_aaboxShaderScale = {true}; - mutable CAABoxShader m_aaboxShaderTranslate = {true}; + mutable CAABoxShader m_aaboxShaderScale{true}; + mutable CAABoxShader m_aaboxShaderTranslate{true}; void ReInitVariables(); void DrawClipScaleCube() const; void DrawClipTranslateCube() const; diff --git a/Runtime/Weapon/CPlayerGun.hpp b/Runtime/Weapon/CPlayerGun.hpp index 8ecefbd63..171b64131 100644 --- a/Runtime/Weapon/CPlayerGun.hpp +++ b/Runtime/Weapon/CPlayerGun.hpp @@ -198,7 +198,7 @@ private: float x664_ = 0.f; float x668_aimVerticalSpeed; float x66c_aimHorizontalSpeed; - std::pair x670_animSfx = {0xffff, {}}; + std::pair x670_animSfx{0xffff, {}}; CGunMorph x678_morph; CMotionState x6a0_motionState; zeus::CAABox x6c8_hologramClipCube; @@ -266,9 +266,9 @@ private: u32 _dummy = 0; }; - mutable CTexturedQuadFilter m_screenQuad = {EFilterType::Blend, CGraphics::g_SpareTexture.get(), - CTexturedQuadFilter::ZTest::GEqualZWrite}; - mutable CAABoxShader m_aaboxShader = {true}; + mutable CTexturedQuadFilter m_screenQuad{EFilterType::Blend, CGraphics::g_SpareTexture.get(), + CTexturedQuadFilter::ZTest::GEqualZWrite}; + mutable CAABoxShader m_aaboxShader{true}; void InitBeamData(); void InitBombData(); diff --git a/Runtime/World/CGameArea.hpp b/Runtime/World/CGameArea.hpp index bc0f85d0a..31623d90b 100644 --- a/Runtime/World/CGameArea.hpp +++ b/Runtime/World/CGameArea.hpp @@ -199,7 +199,7 @@ public: u32 x8_collisionSize = 0; std::optional xc_octTree; std::vector x4c_insts; - SShader m_materialSet = {0}; + SShader m_materialSet{0}; // std::unique_ptr x5c_; std::vector x60_lightsA; std::vector x70_gfxLightsA; diff --git a/Runtime/World/CPatterned.cpp b/Runtime/World/CPatterned.cpp index 100fc1b27..3bfbbb3ee 100644 --- a/Runtime/World/CPatterned.cpp +++ b/Runtime/World/CPatterned.cpp @@ -1586,7 +1586,7 @@ void CPatterned::RenderIceModelWithFlags(const CModelFlags& flags) const { CModelFlags useFlags = flags; useFlags.x1_matSetIdx = 0; CAnimData* animData = x64_modelData->GetAnimationData(); - if (CMorphableSkinnedModel* iceModel = animData->IceModel().GetObj()) + if (CMorphableSkinnedModel* iceModel = animData->GetIceModel().GetObj()) animData->Render(*iceModel, useFlags, {*x510_vertexMorph}, iceModel->GetMorphMagnitudes()); } diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index 668ddb2e4..cdc104b0a 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -185,7 +185,7 @@ constexpr std::array + #include "Runtime/CSimplePool.hpp" #include "Runtime/CStateManager.hpp" #include "Runtime/GameGlobalObjects.hpp" @@ -91,23 +93,29 @@ CWallCrawlerSwarm::CWallCrawlerSwarm(TUniqueId uid, bool active, std::string_vie x4b0_modelDatas.emplace_back(std::make_unique(launchAnimRes)); x4b0_modelDatas.emplace_back(std::make_unique(animRes)); if (aParams.GetXRayAssets().first.IsValid()) { - for (int i = 0; i < 9; ++i) + for (size_t i = 0; i < 9; ++i) { x4b0_modelDatas[i]->SetXRayModel(aParams.GetXRayAssets()); + } x560_26_modelAssetDirty = true; } if (aParams.GetThermalAssets().first.IsValid()) { - for (int i = 0; i < 9; ++i) + for (size_t i = 0; i < 9; ++i) { x4b0_modelDatas[i]->SetInfraModel(aParams.GetThermalAssets()); + } x560_26_modelAssetDirty = true; } - if (part1.IsValid()) + if (part1.IsValid()) { x4f0_particleDescs.push_back(g_SimplePool->GetObj({FOURCC('PART'), part1})); - if (part2.IsValid()) + } + if (part2.IsValid()) { x4f0_particleDescs.push_back(g_SimplePool->GetObj({FOURCC('PART'), part2})); - if (part3.IsValid()) + } + if (part3.IsValid()) { x4f0_particleDescs.push_back(g_SimplePool->GetObj({FOURCC('PART'), part3})); - if (part4.IsValid()) + } + if (part4.IsValid()) { x4f0_particleDescs.push_back(g_SimplePool->GetObj({FOURCC('PART'), part4})); + } for (const auto& t : x4f0_particleDescs) { x524_particleGens.emplace_back(new CElementGen(t)); x524_particleGens.back()->SetParticleEmission(false); @@ -118,12 +126,12 @@ void CWallCrawlerSwarm::Accept(IVisitor& visitor) { visitor.Visit(this); } void CWallCrawlerSwarm::AllocateSkinnedModels(CStateManager& mgr, CModelData::EWhichModel which) { //x430_.clear(); - for (int i = 0; i < 9; ++i) { + for (size_t i = 0; i < 9; ++i) { //x430_.push_back(x4b0_[i]->PickAnimatedModel(which).Clone()); x4b0_modelDatas[i]->EnableLooping(true); - x4b0_modelDatas[i]->AdvanceAnimation( - x4b0_modelDatas[i]->GetAnimationData()->GetAnimTimeRemaining("Whole Body"sv) * (i * 0.0625f), - mgr, x4_areaId, true); + x4b0_modelDatas[i]->AdvanceAnimation(x4b0_modelDatas[i]->GetAnimationData()->GetAnimTimeRemaining("Whole Body"sv) * + (float(i) * 0.0625f), + mgr, x4_areaId, true); } //x430_.push_back(x4b0_.back()->PickAnimatedModel(which).Clone()); x4dc_whichModel = which; @@ -131,17 +139,22 @@ void CWallCrawlerSwarm::AllocateSkinnedModels(CStateManager& mgr, CModelData::EW void CWallCrawlerSwarm::AddDoorRepulsors(CStateManager& mgr) { size_t doorCount = 0; - for (CEntity* ent : mgr.GetPhysicsActorObjectList()) { - if (TCastToPtr door = ent) - if (door->GetAreaIdAlways() == x4_areaId) - ++doorCount; - } - x4e0_doorRepulsors.reserve(doorCount); - for (CEntity* ent : mgr.GetPhysicsActorObjectList()) { - if (TCastToPtr door = ent) { + for (const CEntity* ent : mgr.GetPhysicsActorObjectList()) { + if (const TCastToConstPtr door = ent) { if (door->GetAreaIdAlways() == x4_areaId) { - if (auto tb = door->GetTouchBounds()) + ++doorCount; + } + } + } + + x4e0_doorRepulsors.reserve(doorCount); + + for (const CEntity* ent : mgr.GetPhysicsActorObjectList()) { + if (const TCastToConstPtr door = ent) { + if (door->GetAreaIdAlways() == x4_areaId) { + if (const auto tb = door->GetTouchBounds()) { x4e0_doorRepulsors.emplace_back(tb->center(), (tb->min - tb->max).magnitude() * 0.75f); + } } } } @@ -152,8 +165,9 @@ void CWallCrawlerSwarm::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId send switch (msg) { case EScriptObjectMessage::Registered: x108_boids.reserve(size_t(x548_numBoids)); - for (int i = 0; i < x548_numBoids; ++i) + for (int i = 0; i < x548_numBoids; ++i) { x108_boids.emplace_back(zeus::CTransform(), i); + } AllocateSkinnedModels(mgr, CModelData::EWhichModel::Normal); AddDoorRepulsors(mgr); CreateShadow(false); @@ -164,41 +178,44 @@ void CWallCrawlerSwarm::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId send } void CWallCrawlerSwarm::UpdateParticles(float dt) { - for (auto& p : x524_particleGens) + for (auto& p : x524_particleGens) { p->Update(dt); + } } int CWallCrawlerSwarm::SelectLockOnIdx(CStateManager& mgr) const { - zeus::CTransform fpCamXf = mgr.GetCameraManager()->GetFirstPersonCamera()->GetTransform(); + const zeus::CTransform fpCamXf = mgr.GetCameraManager()->GetFirstPersonCamera()->GetTransform(); if (x42c_lockOnIdx != -1) { const CBoid& b = x108_boids[x42c_lockOnIdx]; if (b.GetActive()) { zeus::CVector3f dir = b.GetTranslation() - fpCamXf.origin; - float mag = dir.magnitude(); + const float mag = dir.magnitude(); dir = dir / mag; if (fpCamXf.basis[1].dot(dir) > 0.92388f) { - if (mgr.RayStaticIntersection(fpCamXf.origin, dir, mag, - CMaterialFilter::MakeInclude(EMaterialTypes::Solid)).IsInvalid()) + if (mgr.RayStaticIntersection(fpCamXf.origin, dir, mag, CMaterialFilter::MakeInclude(EMaterialTypes::Solid)) + .IsInvalid()) { return x42c_lockOnIdx; + } } } return -1; } int ret = -1; - float omtd = mgr.GetPlayer().GetOrbitMaxTargetDistance(mgr); - float omtdSq = omtd * omtd; + const float omtd = mgr.GetPlayer().GetOrbitMaxTargetDistance(mgr); + const float omtdSq = omtd * omtd; float maxDot = 0.5f; - for (int i = 0; i < x108_boids.size(); ++i) { + for (size_t i = 0; i < x108_boids.size(); ++i) { const CBoid& b = x108_boids[i]; if (b.GetActive()) { zeus::CVector3f delta = b.GetTranslation() - fpCamXf.origin; - if (delta.magSquared() > omtdSq) + if (delta.magSquared() > omtdSq) { continue; + } if (delta.canBeNormalized()) { - float thisDot = fpCamXf.basis[1].dot(delta.normalized()); + const float thisDot = fpCamXf.basis[1].dot(delta.normalized()); if (thisDot > maxDot) { - ret = i; + ret = static_cast(i); maxDot = thisDot; } } @@ -208,24 +225,26 @@ int CWallCrawlerSwarm::SelectLockOnIdx(CStateManager& mgr) const { } zeus::CAABox CWallCrawlerSwarm::GetBoundingBox() const { - zeus::CVector3f he = x118_boundingBoxExtent * 0.75f; + const zeus::CVector3f he = x118_boundingBoxExtent * 0.75f; return zeus::CAABox(-he, he).getTransformedAABox(x34_transform); } TUniqueId CWallCrawlerSwarm::GetWaypointForState(EScriptObjectState state, CStateManager& mgr) const { for (const auto& c : GetConnectionList()) { - if (c.x0_state == state && c.x4_msg == EScriptObjectMessage::Follow) + if (c.x0_state == state && c.x4_msg == EScriptObjectMessage::Follow) { return mgr.GetIdForScript(c.x8_objId); + } } return kInvalidUniqueId; } bool CWallCrawlerSwarm::PointOnSurface(const CCollisionSurface& surf, const zeus::CVector3f& pos, const zeus::CPlane& plane) const { - zeus::CVector3f projPt = ProjectPointToPlane(pos, surf.GetVert(0), plane.normal()); + const zeus::CVector3f projPt = ProjectPointToPlane(pos, surf.GetVert(0), plane.normal()); for (int i = 0; i < 3; ++i) { - if (plane.normal().dot((projPt - surf.GetVert(i)).cross(surf.GetVert((i + 2) % 3) - surf.GetVert(i))) < 0.f) + if (plane.normal().dot((projPt - surf.GetVert(i)).cross(surf.GetVert((i + 2) % 3) - surf.GetVert(i))) < 0.f) { return false; + } } return true; } @@ -233,20 +252,21 @@ bool CWallCrawlerSwarm::PointOnSurface(const CCollisionSurface& surf, const zeus bool CWallCrawlerSwarm::FindBestSurface(const CAreaCollisionCache& ccache, const zeus::CVector3f& pos, float radius, CCollisionSurface& out) const { bool ret = false; - float radiusSq = radius * radius; + const float radiusSq = radius * radius; zeus::CSphere sphere(pos, radius); for (const auto& c : ccache) { for (const auto& n : c) { if (CCollidableSphere::Sphere_AABox_Bool(sphere, n.GetBoundingBox())) { - auto triList = n.GetTriangleArray(); + const auto triList = n.GetTriangleArray(); for (int i = 0; i < triList.GetSize(); ++i) { CCollisionSurface surf = n.GetOwner().GetMasterListTriangle(triList.GetAt(i)); - zeus::CPlane plane = surf.GetPlane(); - float distSq = std::fabs(plane.pointToPlaneDist(pos)); + const zeus::CPlane plane = surf.GetPlane(); + const float distSq = std::fabs(plane.pointToPlaneDist(pos)); if (distSq < radiusSq && PointOnSurface(surf, pos, plane)) { float dist = 0.f; - if (distSq != 0.f) + if (distSq != 0.f) { dist = std::sqrt(distSq); + } sphere.radius = dist; out = surf; ret = true; @@ -260,40 +280,45 @@ bool CWallCrawlerSwarm::FindBestSurface(const CAreaCollisionCache& ccache, const CCollisionSurface CWallCrawlerSwarm::FindBestCollisionInBox(CStateManager& mgr, const zeus::CVector3f& wpPos) const { CCollisionSurface ret(zeus::skRight, zeus::skForward, zeus::skUp, 0xffffffff); - zeus::CVector3f aabbExtents = GetBoundingBox().extents(); + const zeus::CVector3f aabbExtents = GetBoundingBox().extents(); float f25 = 0.1f; while (f25 < 1.f) { - zeus::CVector3f scaledExtents = aabbExtents * f25; + const zeus::CVector3f scaledExtents = aabbExtents * f25; CAreaCollisionCache ccache(zeus::CAABox(wpPos - scaledExtents, wpPos + scaledExtents)); CGameCollision::BuildAreaCollisionCache(mgr, ccache); - if (FindBestSurface(ccache, wpPos, 2.f * scaledExtents.magnitude(), ret)) + if (FindBestSurface(ccache, wpPos, 2.f * scaledExtents.magnitude(), ret)) { return ret; + } f25 += 0.1f; } return ret; } static zeus::CTransform LookAt(const zeus::CUnitVector3f& a, const zeus::CUnitVector3f& b, const zeus::CRelAngle& ang) { - float dot = a.dot(b); - if (zeus::close_enough(dot, 1.f)) + const float dot = a.dot(b); + if (zeus::close_enough(dot, 1.f)) { return zeus::CTransform(); - if (dot > -0.99981f) + } + if (dot > -0.99981f) { return zeus::CQuaternion::clampedRotateTo(a, b, ang).toTransform(); - if (a != zeus::skRight && b != zeus::skRight) + } + if (a != zeus::skRight && b != zeus::skRight) { return zeus::CQuaternion::fromAxisAngle(a.cross(zeus::skRight), ang).toTransform(); + } return zeus::CQuaternion::fromAxisAngle(a.cross(zeus::skUp), ang).toTransform(); } void CWallCrawlerSwarm::CreateBoid(CStateManager& mgr, int idx) { //zeus::CAABox aabb = GetBoundingBox(); - TUniqueId wpId = GetWaypointForState(EScriptObjectState::Patrol, mgr); + const TUniqueId wpId = GetWaypointForState(EScriptObjectState::Patrol, mgr); if (TCastToConstPtr wp = mgr.GetObjectById(wpId)) { - CCollisionSurface surf = FindBestCollisionInBox(mgr, wp->GetTranslation()); - x108_boids[idx].Transform() = zeus::CTransform::Translate( - ProjectPointToPlane(wp->GetTranslation(), surf.GetVert(0), surf.GetNormal()) + surf.GetNormal() * x374_boidRadius); + const CCollisionSurface surf = FindBestCollisionInBox(mgr, wp->GetTranslation()); + x108_boids[idx].Transform() = + zeus::CTransform::Translate(ProjectPointToPlane(wp->GetTranslation(), surf.GetVert(0), surf.GetNormal()) + + surf.GetNormal() * x374_boidRadius); if (zeus::close_enough(zeus::skUp.dot(surf.GetNormal()), -1.f)) { - x108_boids[idx].Transform().setRotation(zeus::CTransform( - zeus::skRight, zeus::skBack, zeus::skDown, zeus::skZero3f)); + x108_boids[idx].Transform().setRotation( + zeus::CTransform(zeus::skRight, zeus::skBack, zeus::skDown, zeus::skZero3f)); } else { x108_boids[idx].Transform().setRotation(LookAt(zeus::skUp, surf.GetNormal(), M_PIF)); } @@ -310,30 +335,33 @@ void CWallCrawlerSwarm::CreateBoid(CStateManager& mgr, int idx) { void CWallCrawlerSwarm::ExplodeBoid(CBoid& boid, CStateManager& mgr) { KillBoid(boid, mgr, 0.f, 1.f); mgr.ApplyDamageToWorld(GetUniqueId(), *this, boid.GetTranslation(), x3a0_scarabExplodeDamage, - CMaterialFilter::MakeInclude({EMaterialTypes::Player})); + CMaterialFilter::MakeInclude({EMaterialTypes::Player})); } void CWallCrawlerSwarm::SetExplodeTimers(const zeus::CVector3f& pos, float radius, float minTime, float maxTime) { - float radiusSq = radius * radius; - float range = maxTime - minTime; + const float radiusSq = radius * radius; + const float range = maxTime - minTime; + for (auto& b : x108_boids) { if (b.GetActive() && b.x48_timeToDie <= 0.f) { - float dist = (b.GetTranslation() - pos).magSquared(); + const float dist = (b.GetTranslation() - pos).magSquared(); if (dist < radiusSq) { - float fac = dist / radiusSq * range + minTime; - if (b.x4c_timeToExplode > fac || b.x4c_timeToExplode == 0.f) + const float fac = dist / radiusSq * range + minTime; + if (b.x4c_timeToExplode > fac || b.x4c_timeToExplode == 0.f) { b.x4c_timeToExplode = fac; + } } } } } CWallCrawlerSwarm::CBoid* CWallCrawlerSwarm::GetListAt(const zeus::CVector3f& pos) { - zeus::CAABox aabb = GetBoundingBox(); - zeus::CVector3f ints = (pos - aabb.min) / ((aabb.max - aabb.min) / 5.f); - int idx = int(ints.x()) + int(ints.y()) * 5 + int(ints.z()) * 25; - if (idx < 0 || idx >= 125) + const zeus::CAABox aabb = GetBoundingBox(); + const zeus::CVector3f ints = (pos - aabb.min) / ((aabb.max - aabb.min) / 5.f); + const int idx = int(ints.x()) + int(ints.y()) * 5 + int(ints.z()) * 25; + if (idx < 0 || idx >= 125) { return x360_outlierBoidList; + } return x168_partitionedBoidLists[idx]; } @@ -341,48 +369,54 @@ void CWallCrawlerSwarm::BuildBoidNearList(const CBoid& boid, float radius, rstl::reserved_vector& nearList) { CBoid* b = GetListAt(boid.GetTranslation()); while (b && nearList.size() < 50) { - float distSq = (b->GetTranslation() - boid.GetTranslation()).magSquared(); - if (distSq != 0.f && distSq < radius) + const float distSq = (b->GetTranslation() - boid.GetTranslation()).magSquared(); + if (distSq != 0.f && distSq < radius) { nearList.push_back(b); + } b = b->x44_next; } } void CWallCrawlerSwarm::ApplySeparation(const CBoid& boid, const rstl::reserved_vector& nearList, zeus::CVector3f& aheadVec) const { - if (nearList.empty()) + if (nearList.empty()) { return; + } + float minDist = FLT_MAX; zeus::CVector3f pos; - for (CBoid* b : nearList) { - float dist = (boid.GetTranslation() - b->GetTranslation()).magSquared(); + for (const CBoid* b : nearList) { + const float dist = (boid.GetTranslation() - b->GetTranslation()).magSquared(); if (dist != 0.f && dist < minDist) { minDist = dist; pos = b->GetTranslation(); } } + ApplySeparation(boid, pos, x13c_separationRadius, x148_separationMagnitude, aheadVec); } -void CWallCrawlerSwarm::ApplySeparation(const CBoid& boid, const zeus::CVector3f& separateFrom, - float separationRadius, float separationMagnitude, - zeus::CVector3f& aheadVec) const { - zeus::CVector3f delta = boid.GetTranslation() - separateFrom; - if (delta.canBeNormalized()) { - float deltaDistSq = delta.magSquared(); - float capDeltaDistSq = separationRadius * separationRadius; - if (deltaDistSq < capDeltaDistSq) - aheadVec += (1.f - deltaDistSq / capDeltaDistSq) * delta.normalized() * separationMagnitude; +void CWallCrawlerSwarm::ApplySeparation(const CBoid& boid, const zeus::CVector3f& separateFrom, float separationRadius, + float separationMagnitude, zeus::CVector3f& aheadVec) const { + const zeus::CVector3f delta = boid.GetTranslation() - separateFrom; + if (!delta.canBeNormalized()) { + return; + } + + const float deltaDistSq = delta.magSquared(); + const float capDeltaDistSq = separationRadius * separationRadius; + if (deltaDistSq < capDeltaDistSq) { + aheadVec += (1.f - deltaDistSq / capDeltaDistSq) * delta.normalized() * separationMagnitude; } } void CWallCrawlerSwarm::ScatterScarabBoid(CBoid& boid, CStateManager& mgr) const { - zeus::CVector3f oldDir = boid.Transform().basis[1]; + const zeus::CVector3f oldDir = boid.GetTransform().basis[1]; boid.Transform().setRotation(zeus::CTransform()); - boid.Transform() = LookAt(boid.Transform().basis[1], oldDir, M_PIF).multiplyIgnoreTranslation(boid.Transform()); + boid.Transform() = LookAt(boid.GetTransform().basis[1], oldDir, M_PIF).multiplyIgnoreTranslation(boid.GetTransform()); boid.x30_velocity = zeus::skZero3f; - float angle = mgr.GetActiveRandom()->Float() * (2.f * M_PIF); - float mag = mgr.GetActiveRandom()->Float() * x158_scarabScatterXYVelocity; + const float angle = mgr.GetActiveRandom()->Float() * (2.f * M_PIF); + const float mag = mgr.GetActiveRandom()->Float() * x158_scarabScatterXYVelocity; boid.x30_velocity.x() = mag * std::cos(angle); boid.x30_velocity.y() = mag * std::sin(angle); boid.x80_26_launched = true; @@ -391,8 +425,8 @@ void CWallCrawlerSwarm::ScatterScarabBoid(CBoid& boid, CStateManager& mgr) const } void CWallCrawlerSwarm::MoveToWayPoint(CBoid& boid, CStateManager& mgr, zeus::CVector3f& aheadVec) const { - if (TCastToPtr wp = mgr.ObjectById(boid.x3c_targetWaypoint)) { - CScriptWaypoint* useWp = wp.GetPtr(); + if (const TCastToConstPtr wp = mgr.ObjectById(boid.x3c_targetWaypoint)) { + const CScriptWaypoint* useWp = wp.GetPtr(); if ((useWp->GetTranslation() - boid.GetTranslation()).magSquared() < x164_waypointGoalRadius * x164_waypointGoalRadius) { boid.x3c_targetWaypoint = useWp->NextWaypoint(mgr); @@ -404,7 +438,7 @@ void CWallCrawlerSwarm::MoveToWayPoint(CBoid& boid, CStateManager& mgr, zeus::CV return; } } else { - useWp = TCastToPtr(mgr.ObjectById(boid.x3c_targetWaypoint)).GetPtr(); + useWp = TCastToConstPtr(mgr.ObjectById(boid.x3c_targetWaypoint)).GetPtr(); } } aheadVec += (useWp->GetTranslation() - boid.GetTranslation()).normalized() * x14c_moveToWaypointWeight; @@ -413,60 +447,71 @@ void CWallCrawlerSwarm::MoveToWayPoint(CBoid& boid, CStateManager& mgr, zeus::CV void CWallCrawlerSwarm::ApplyCohesion(const CBoid& boid, const rstl::reserved_vector& nearList, zeus::CVector3f& aheadVec) const { - if (nearList.empty()) + if (nearList.empty()) { return; + } + zeus::CVector3f avg; - for (CBoid* b : nearList) + for (const CBoid* b : nearList) { avg += b->GetTranslation(); + } + avg = avg / float(nearList.size()); ApplyCohesion(boid, avg, x13c_separationRadius, x140_cohesionMagnitude, aheadVec); } -void CWallCrawlerSwarm::ApplyCohesion(const CBoid& boid, const zeus::CVector3f& cohesionFrom, - float cohesionRadius, float cohesionMagnitude, - zeus::CVector3f& aheadVec) const { - zeus::CVector3f delta = cohesionFrom - boid.GetTranslation(); - if (delta.canBeNormalized()) { - float distSq = delta.magSquared(); - float capDistSq = cohesionRadius * cohesionRadius; - aheadVec += ((distSq > capDistSq) ? 1.f : distSq / capDistSq) * delta.normalized() * cohesionMagnitude; +void CWallCrawlerSwarm::ApplyCohesion(const CBoid& boid, const zeus::CVector3f& cohesionFrom, float cohesionRadius, + float cohesionMagnitude, zeus::CVector3f& aheadVec) const { + const zeus::CVector3f delta = cohesionFrom - boid.GetTranslation(); + if (!delta.canBeNormalized()) { + return; } + + const float distSq = delta.magSquared(); + const float capDistSq = cohesionRadius * cohesionRadius; + aheadVec += ((distSq > capDistSq) ? 1.f : distSq / capDistSq) * delta.normalized() * cohesionMagnitude; } void CWallCrawlerSwarm::ApplyAlignment(const CBoid& boid, const rstl::reserved_vector& nearList, zeus::CVector3f& aheadVec) const { - if (nearList.empty()) + if (nearList.empty()) { return; + } + zeus::CVector3f avg; - for (CBoid* b : nearList) - avg += b->Transform().basis[1]; + for (const CBoid* b : nearList) { + avg += b->GetTransform().basis[1]; + } + avg = avg / float(nearList.size()); aheadVec += zeus::CVector3f::getAngleDiff(boid.GetTransform().basis[1], avg) / M_PIF * (avg * x144_alignmentWeight); } -void CWallCrawlerSwarm::ApplyAttraction(const CBoid& boid, const zeus::CVector3f& attractTo, - float attractionRadius, float attractionMagnitude, - zeus::CVector3f& aheadVec) const { - zeus::CVector3f delta = attractTo - boid.GetTranslation(); - if (delta.canBeNormalized()) { - float distSq = delta.magSquared(); - float capDistSq = attractionRadius * attractionRadius; - aheadVec += ((distSq > capDistSq) ? 0.f : (1.f - distSq / capDistSq)) * delta.normalized() * attractionMagnitude; +void CWallCrawlerSwarm::ApplyAttraction(const CBoid& boid, const zeus::CVector3f& attractTo, float attractionRadius, + float attractionMagnitude, zeus::CVector3f& aheadVec) const { + const zeus::CVector3f delta = attractTo - boid.GetTranslation(); + if (!delta.canBeNormalized()) { + return; } + + const float distSq = delta.magSquared(); + const float capDistSq = attractionRadius * attractionRadius; + aheadVec += ((distSq > capDistSq) ? 0.f : (1.f - distSq / capDistSq)) * delta.normalized() * attractionMagnitude; } void CWallCrawlerSwarm::UpdateBoid(const CAreaCollisionCache& ccache, CStateManager& mgr, float dt, CBoid& boid) { if (boid.x80_27_scarabExplodeTimerEnabled) { if (x558_flavor == EFlavor::Scarab && boid.x4c_timeToExplode > 0.f) { boid.x4c_timeToExplode -= 2.f * dt; - if (boid.x4c_timeToExplode <= 0.f) + if (boid.x4c_timeToExplode <= 0.f) { ExplodeBoid(boid, mgr); + } } } else if (boid.x80_26_launched) { - float radius = 2.f * x374_boidRadius; - float boidMag = boid.x30_velocity.magnitude(); + const float radius = 2.f * x374_boidRadius; + const float boidMag = boid.x30_velocity.magnitude(); float f20 = boidMag * dt; - zeus::CVector3f f25 = (-boid.x30_velocity / boidMag) * x374_boidRadius; + const zeus::CVector3f f25 = (-boid.x30_velocity / boidMag) * x374_boidRadius; zeus::CVector3f f28 = boid.GetTranslation(); bool found = false; while (f20 >= 0.f && !found) { @@ -474,12 +519,12 @@ void CWallCrawlerSwarm::UpdateBoid(const CAreaCollisionCache& ccache, CStateMana if (FindBestSurface(ccache, boid.x30_velocity * dt * 1.5f + f28, radius, surf) && boid.x7c_remainingLaunchNotOnSurfaceFrames == 0) { if (x558_flavor != EFlavor::Scarab) { - boid.Transform() = - LookAt(boid.Transform().basis[2], surf.GetNormal(), M_PIF).multiplyIgnoreTranslation(boid.Transform()); + boid.Transform() = LookAt(boid.GetTransform().basis[2], surf.GetNormal(), M_PIF) + .multiplyIgnoreTranslation(boid.GetTransform()); } - auto plane = surf.GetPlane(); + const auto plane = surf.GetPlane(); boid.Translation() += - -(plane.pointToPlaneDist(boid.GetTranslation()) - x374_boidRadius - 0.01f) * plane.normal(); + -(plane.pointToPlaneDist(boid.GetTranslation()) - x374_boidRadius - 0.01f) * plane.normal(); boid.x7c_framesNotOnSurface = 0; boid.x80_26_launched = false; if (x558_flavor == EFlavor::Scarab) { @@ -493,23 +538,26 @@ void CWallCrawlerSwarm::UpdateBoid(const CAreaCollisionCache& ccache, CStateMana f28 += f25; } if (!found) { - boid.x30_velocity += zeus::CVector3f(0.f, 0.f, -(x558_flavor == EFlavor::Scarab ? 3.f * CPhysicsActor::GravityConstant() : CPhysicsActor::GravityConstant())) * dt; - if (boid.x7c_remainingLaunchNotOnSurfaceFrames) + boid.x30_velocity += zeus::CVector3f(0.f, 0.f, + -(x558_flavor == EFlavor::Scarab ? 3.f * CPhysicsActor::GravityConstant() + : CPhysicsActor::GravityConstant())) * + dt; + if (boid.x7c_remainingLaunchNotOnSurfaceFrames) { boid.x7c_remainingLaunchNotOnSurfaceFrames -= 1; + } } } else if (boid.x7c_framesNotOnSurface >= 30) { boid.x80_24_active = false; } else { - float radius = 2.f * x374_boidRadius; + const float radius = 2.f * x374_boidRadius; bool found = false; CCollisionSurface surf(zeus::skRight, zeus::skForward, zeus::skUp, 0xffffffff); if (FindBestSurface(ccache, boid.GetTranslation() + boid.x30_velocity * dt * 1.5f, radius, surf)) { boid.x50_surface = surf; - boid.Transform() = - LookAt(boid.Transform().basis[2], surf.GetNormal(), zeus::degToRad(180.f * dt)). - multiplyIgnoreTranslation(boid.Transform()); - auto plane = surf.GetPlane(); - float dist = plane.pointToPlaneDist(boid.GetTranslation()); + boid.Transform() = LookAt(boid.GetTransform().basis[2], surf.GetNormal(), zeus::degToRad(180.f * dt)) + .multiplyIgnoreTranslation(boid.GetTransform()); + const auto plane = surf.GetPlane(); + const float dist = plane.pointToPlaneDist(boid.GetTranslation()); if (dist <= 1.5f * x374_boidRadius) { boid.Translation() += -(dist - x374_boidRadius - 0.01f) * plane.normal(); boid.x7c_framesNotOnSurface = 0; @@ -517,21 +565,21 @@ void CWallCrawlerSwarm::UpdateBoid(const CAreaCollisionCache& ccache, CStateMana } } if (!found) { - boid.Transform() = - LookAt(boid.Transform().basis[2], boid.Transform().basis[1], - boid.x30_velocity.magnitude() / x374_boidRadius * dt). - multiplyIgnoreTranslation(boid.Transform()); + boid.Transform() = LookAt(boid.GetTransform().basis[2], boid.GetTransform().basis[1], + boid.x30_velocity.magnitude() / x374_boidRadius * dt) + .multiplyIgnoreTranslation(boid.GetTransform()); boid.x7c_framesNotOnSurface += 1; } rstl::reserved_vector nearList; BuildBoidNearList(boid, x13c_separationRadius, nearList); - zeus::CVector3f aheadVec = boid.Transform().basis[1] * 0.3f; + zeus::CVector3f aheadVec = boid.GetTransform().basis[1] * 0.3f; for (int r26 = 0; r26 < 8; ++r26) { switch (r26) { case 0: - for (auto& rep : x4e0_doorRepulsors) { - if ((rep.x0_center - boid.GetTranslation()).magSquared() < rep.xc_mag * rep.xc_mag) + for (const auto& rep : x4e0_doorRepulsors) { + if ((rep.x0_center - boid.GetTranslation()).magSquared() < rep.xc_mag * rep.xc_mag) { ApplySeparation(boid, rep.x0_center, rep.xc_mag, 4.5f, aheadVec); + } } break; case 4: @@ -553,38 +601,41 @@ void CWallCrawlerSwarm::UpdateBoid(const CAreaCollisionCache& ccache, CStateMana default: break; } - if (aheadVec.magSquared() >= 9.f) + if (aheadVec.magSquared() >= 9.f) { break; + } } - boid.Transform() = LookAt(boid.Transform().basis[1], - ProjectVectorToPlane(aheadVec, boid.Transform().basis[2]).normalized(), M_PIF * dt). - multiplyIgnoreTranslation(boid.Transform()); + boid.Transform() = LookAt(boid.GetTransform().basis[1], + ProjectVectorToPlane(aheadVec, boid.GetTransform().basis[2]).normalized(), M_PIF * dt) + .multiplyIgnoreTranslation(boid.GetTransform()); } } void CWallCrawlerSwarm::LaunchBoid(CBoid& boid, const zeus::CVector3f& dir) { - zeus::CVector3f pos = boid.GetTranslation(); + const zeus::CVector3f pos = boid.GetTranslation(); static float skAttackTime = std::sqrt(2.5f / CPhysicsActor::GravityConstant()) * 2.f; static float skAttackVelocity = 15.f / skAttackTime; zeus::CVector3f deltaFlat = dir - pos; - float deltaZ = deltaFlat.z(); + const float deltaZ = deltaFlat.z(); deltaFlat.z() = 0.f; - float deltaMag = deltaFlat.magnitude(); + const float deltaMag = deltaFlat.magnitude(); boid.Transform().setRotation(zeus::CTransform()); - boid.Transform() = - LookAt(boid.Transform().basis[1], deltaFlat.normalized(), M_PIF).multiplyIgnoreTranslation(boid.Transform()); - zeus::CVector3f vec(skAttackVelocity * boid.Transform().basis[1].toVec2f(), 0.5f * skAttackVelocity); + boid.Transform() = LookAt(boid.GetTransform().basis[1], deltaFlat.normalized(), M_PIF) + .multiplyIgnoreTranslation(boid.GetTransform()); + zeus::CVector3f vec(skAttackVelocity * boid.GetTransform().basis[1].toVec2f(), 0.5f * skAttackVelocity); if (deltaMag > FLT_EPSILON) { deltaFlat = deltaFlat / deltaMag; - float dot = deltaFlat.dot(vec); + const float dot = deltaFlat.dot(vec); if (dot > FLT_EPSILON) { - bool r29 = deltaZ < 0.f; + const bool r29 = deltaZ < 0.f; float _12c, _130; float f25 = 0.f; - if (CSteeringBehaviors::SolveQuadratic(-CPhysicsActor::GravityConstant(), vec.z(), -deltaZ, _12c, _130)) + if (CSteeringBehaviors::SolveQuadratic(-CPhysicsActor::GravityConstant(), vec.z(), -deltaZ, _12c, _130)) { f25 = r29 ? _130 : _12c; - if (!r29) + } + if (!r29) { f25 += deltaMag / dot; + } if (f25 < 10.f) { vec.x() = deltaMag / f25 * deltaFlat.x() * 0.6f; vec.y() = deltaMag / f25 * deltaFlat.y() * 0.6f; @@ -598,14 +649,14 @@ void CWallCrawlerSwarm::LaunchBoid(CBoid& boid, const zeus::CVector3f& dir) { CSfxManager::AddEmitter(x55c_launchSfx, pos, zeus::skZero3f, true, false, 0x7f, x4_areaId); } -static const int kParticleCounts[] = {8, 2, 0, 0}; - void CWallCrawlerSwarm::AddParticle(const zeus::CTransform& xf) { - int i = 0; + static constexpr std::array particleCounts{8, 2, 0, 0}; + + size_t i = 0; for (auto& p : x524_particleGens) { p->SetParticleEmission(true); p->SetTranslation(xf.origin); - p->ForceParticleCreation(kParticleCounts[i]); + p->ForceParticleCreation(particleCounts[i]); p->SetParticleEmission(false); ++i; } @@ -613,29 +664,33 @@ void CWallCrawlerSwarm::AddParticle(const zeus::CTransform& xf) { void CWallCrawlerSwarm::KillBoid(CBoid& boid, CStateManager& mgr, float deathRattleChance, float deadChance) { x130_lastKilledOffset = boid.GetTranslation(); - AddParticle(boid.Transform()); + AddParticle(boid.GetTransform()); boid.x80_24_active = false; - float sendDeadRoll = mgr.GetActiveRandom()->Float(); - float sendDeathRattleRoll = mgr.GetActiveRandom()->Float(); - if (sendDeathRattleRoll < deathRattleChance) + + const float sendDeadRoll = mgr.GetActiveRandom()->Float(); + const float sendDeathRattleRoll = mgr.GetActiveRandom()->Float(); + if (sendDeathRattleRoll < deathRattleChance) { SendScriptMsgs(EScriptObjectState::DeathRattle, mgr, EScriptObjectMessage::None); - if (sendDeadRoll < deadChance) + } + if (sendDeadRoll < deadChance) { SendScriptMsgs(EScriptObjectState::Dead, mgr, EScriptObjectMessage::None); + } } void CWallCrawlerSwarm::UpdatePartition() { x168_partitionedBoidLists.clear(); x168_partitionedBoidLists.resize(125); x360_outlierBoidList = nullptr; - zeus::CAABox aabb = GetBoundingBox(); - zeus::CVector3f vec = (aabb.max - aabb.min) / 5.f; + + const zeus::CAABox aabb = GetBoundingBox(); + const zeus::CVector3f vec = (aabb.max - aabb.min) / 5.f; for (auto& b : x108_boids) { if (b.GetActive()) { - zeus::CVector3f divVec = (b.Translation() - aabb.min) / vec; - int xIdx = int(divVec.x()); - int yIdx = int(divVec.y()); - int zIdx = int(divVec.z()); - int idx = xIdx + yIdx * 5 + zIdx * 25; + const zeus::CVector3f divVec = (b.GetTranslation() - aabb.min) / vec; + const int xIdx = int(divVec.x()); + const int yIdx = int(divVec.y()); + const int zIdx = int(divVec.z()); + const int idx = xIdx + yIdx * 5 + zIdx * 25; if (idx < 0 || idx >= 125 || xIdx < 0 || xIdx >= 5 || yIdx < 0 || yIdx >= 5 || zIdx < 0 || zIdx >= 5) { b.x44_next = x360_outlierBoidList; x360_outlierBoidList = &b; @@ -653,8 +708,8 @@ zeus::CVector3f CWallCrawlerSwarm::FindClosestCell(const zeus::CVector3f& pos) c for (int r28 = 0; r28 < 5; ++r28) { for (int r29 = 0; r29 < 5; ++r29) { for (int r25 = 0; r25 < 5; ++r25) { - zeus::CAABox aabb = BoxForPosition(r28, r29, r25, 0.1f); - float dist = (aabb.center() - pos).magSquared(); + const zeus::CAABox aabb = BoxForPosition(r28, r29, r25, 0.1f); + const float dist = (aabb.center() - pos).magSquared(); if (dist < minDist) { minDist = dist; ret = aabb.center(); @@ -666,48 +721,56 @@ zeus::CVector3f CWallCrawlerSwarm::FindClosestCell(const zeus::CVector3f& pos) c } void CWallCrawlerSwarm::UpdateEffects(CStateManager& mgr, CAnimData& aData, int vol) { - if (aData.GetPassedSoundPOICount() > 0 && !CAnimData::g_SoundPOINodes.empty()) { - for (int i = 0; i < aData.GetPassedSoundPOICount(); ++i) { - const CSoundPOINode& n = CAnimData::g_SoundPOINodes[i]; - if (n.GetPoiType() == EPOIType::Sound && - (n.GetCharacterIndex() == -1 || n.GetCharacterIndex() == aData.GetCharacterIndex())) { - u16 sfx = CSfxManager::TranslateSFXID(u16(n.GetSfxId() & 0xffff)); - bool loop = bool(n.GetSfxId() >> 31); - if (!loop) { - CAudioSys::C3DEmitterParmData parmData; - parmData.x0_pos = FindClosestCell(mgr.GetPlayer().GetTranslation()); - static float maxDist = n.GetMaxDist(); - static float falloff = n.GetFalloff(); - parmData.x18_maxDist = maxDist; - parmData.x1c_distComp = falloff; - parmData.x20_flags = 0x1; - parmData.x24_sfxId = sfx; - parmData.x26_maxVol = zeus::clamp(0, vol, 127) / 127.f; - parmData.x27_minVol = 20.f / 127.f; - parmData.x28_important = false; - parmData.x29_prio = 0x7f; - CSfxManager::AddEmitter(parmData, true, 0x7f, false, x4_areaId); - } - } + if (aData.GetPassedSoundPOICount() == 0 || CAnimData::g_SoundPOINodes.empty()) { + return; + } + + for (size_t i = 0; i < aData.GetPassedSoundPOICount(); ++i) { + const CSoundPOINode& n = CAnimData::g_SoundPOINodes[i]; + if (n.GetPoiType() != EPOIType::Sound || + (n.GetCharacterIndex() != -1 && n.GetCharacterIndex() != aData.GetCharacterIndex())) { + continue; } + + const u16 sfx = CSfxManager::TranslateSFXID(u16(n.GetSfxId() & 0xffff)); + const bool loop = bool(n.GetSfxId() >> 31); + if (loop) { + continue; + } + + CAudioSys::C3DEmitterParmData parmData; + parmData.x0_pos = FindClosestCell(mgr.GetPlayer().GetTranslation()); + static float maxDist = n.GetMaxDist(); + static float falloff = n.GetFalloff(); + parmData.x18_maxDist = maxDist; + parmData.x1c_distComp = falloff; + parmData.x20_flags = 0x1; + parmData.x24_sfxId = sfx; + parmData.x26_maxVol = zeus::clamp(0, vol, 127) / 127.f; + parmData.x27_minVol = 20.f / 127.f; + parmData.x28_important = false; + parmData.x29_prio = 0x7f; + CSfxManager::AddEmitter(parmData, true, 0x7f, false, x4_areaId); } } zeus::CAABox CWallCrawlerSwarm::BoxForPosition(int x, int y, int z, float f) const { - zeus::CAABox aabb = GetBoundingBox(); - zeus::CVector3f vec = (aabb.max - aabb.min) / 5.f; + const zeus::CAABox aabb = GetBoundingBox(); + const zeus::CVector3f vec = (aabb.max - aabb.min) / 5.f; return zeus::CAABox(zeus::CVector3f(x, y, z) * vec + aabb.min - f, zeus::CVector3f(x + 1, y + 1, z + 1) * vec + aabb.min + f); } void CWallCrawlerSwarm::Think(float dt, CStateManager& mgr) { - if (!GetActive()) + if (!GetActive()) { return; + } if (x560_26_modelAssetDirty && CModelData::GetRenderingModel(mgr) != x4dc_whichModel) { - auto which = CModelData::GetRenderingModel(mgr); - if (which != x4dc_whichModel) + const auto which = CModelData::GetRenderingModel(mgr); + if (which != x4dc_whichModel) { AllocateSkinnedModels(mgr, which); + } } xe4_27_notInSortedLists = true; @@ -715,15 +778,18 @@ void CWallCrawlerSwarm::Think(float dt, CStateManager& mgr) { x36c_crabDamageCooldownTimer -= dt; ++x100_thinkCounter; const CGameArea* area = mgr.GetWorld()->GetAreaAlways(x4_areaId); - auto occState = + const auto occState = area->IsPostConstructed() ? area->GetOcclusionState() : CGameArea::EOcclusionState::Occluded; if (occState != CGameArea::EOcclusionState::Visible) { - if (x104_occludedTimer > 0.f) + if (x104_occludedTimer > 0.f) { x104_occludedTimer -= dt; - if (x104_occludedTimer <= 0.f) + } + if (x104_occludedTimer <= 0.f) { return; - if (x100_thinkCounter & 0x2) + } + if (x100_thinkCounter & 0x2) { return; + } } else { x104_occludedTimer = 7.f; } @@ -732,15 +798,17 @@ void CWallCrawlerSwarm::Think(float dt, CStateManager& mgr) { x42c_lockOnIdx = SelectLockOnIdx(mgr); xe7_31_targetable = x42c_lockOnIdx != -1; - if (x42c_lockOnIdx == -1) + if (x42c_lockOnIdx == -1) { RemoveMaterial(EMaterialTypes::Target, EMaterialTypes::Orbit, mgr); - else + } else { AddMaterial(EMaterialTypes::Target, EMaterialTypes::Orbit, mgr); + } + while ((x54c_maxCreatedBoids == 0 || x550_createdBoids < x54c_maxCreatedBoids) && x368_boidGenCooldownTimer <= 0.f) { int idx = 0; bool madeBoid = false; - for (auto& b : x108_boids) { + for (const auto& b : x108_boids) { if (!b.GetActive()) { CreateBoid(mgr, idx); x550_createdBoids += 1; @@ -762,24 +830,25 @@ void CWallCrawlerSwarm::Think(float dt, CStateManager& mgr) { for (int r26 = 0; r26 < 5; ++r26) { for (int r27 = 0; r27 < 5; ++r27) { for (int r20 = 0; r20 < 5; ++r20) { - int idx = r20 * 25 + r27 * 5 + r26; + const int idx = r20 * 25 + r27 * 5 + r26; if (CBoid* boid = x168_partitionedBoidLists[idx]) { - zeus::CAABox aabb = BoxForPosition(r26, r27, r20, x374_boidRadius + 0.5f); + const zeus::CAABox aabb = BoxForPosition(r26, r27, r20, x374_boidRadius + 0.5f); CAreaCollisionCache ccache(aabb); CGameCollision::BuildAreaCollisionCache(mgr, ccache); while (boid) { r21 += 1; if (boid->GetActive()) { if (x558_flavor == EFlavor::Scarab) { - xe8_aabox.accumulateBounds(boid->Translation() + x37c_scarabBoxMargin); - xe8_aabox.accumulateBounds(boid->Translation() - x37c_scarabBoxMargin); + xe8_aabox.accumulateBounds(boid->GetTranslation() + x37c_scarabBoxMargin); + xe8_aabox.accumulateBounds(boid->GetTranslation() - x37c_scarabBoxMargin); } else { - xe8_aabox.accumulateBounds(boid->Translation()); + xe8_aabox.accumulateBounds(boid->GetTranslation()); } } if (((x100_thinkCounter & 0x1) == (r21 & 0x1) && boid->GetActive() && boid->x48_timeToDie < 0.1f) || - boid->x80_26_launched) + boid->x80_26_launched) { UpdateBoid(ccache, mgr, dt, *boid); + } boid = boid->x44_next; } } @@ -789,12 +858,13 @@ void CWallCrawlerSwarm::Think(float dt, CStateManager& mgr) { for (CBoid* boid = x360_outlierBoidList; boid; boid = boid->x44_next) { r21 += 1; - if (boid->GetActive()) - xe8_aabox.accumulateBounds(boid->Translation()); + if (boid->GetActive()) { + xe8_aabox.accumulateBounds(boid->GetTranslation()); + } if (((x100_thinkCounter & 0x1) == (r21 & 0x1) && boid->GetActive() && boid->x48_timeToDie < 0.1f) || boid->x80_26_launched) { - float margin = 1.5f + x374_boidRadius + 0.5f; - zeus::CAABox aabb(boid->Translation() - margin, boid->Translation() + margin); + const float margin = 1.5f + x374_boidRadius + 0.5f; + const zeus::CAABox aabb(boid->GetTranslation() - margin, boid->GetTranslation() + margin); CAreaCollisionCache ccache(aabb); CGameCollision::BuildAreaCollisionCache(mgr, ccache); UpdateBoid(ccache, mgr, dt, *boid); @@ -809,8 +879,8 @@ void CWallCrawlerSwarm::Think(float dt, CStateManager& mgr) { int r9 = 0; int r3 = 0; int r8 = 0; - bool _38F8[4] = {}; - bool _38F4[4] = {}; + std::array _38F8{}; + std::array _38F4{}; for (const auto& b : x108_boids) { if (b.GetActive() && !b.x80_26_launched) { if (b.x80_27_scarabExplodeTimerEnabled || b.x80_28_nearPlayer) { @@ -824,29 +894,32 @@ void CWallCrawlerSwarm::Think(float dt, CStateManager& mgr) { ++r9; } - for (int i = 0; i < 4; ++i) { + for (size_t i = 0; i < _38F4.size(); ++i) { x4b0_modelDatas[i]->GetAnimationData()->SetPlaybackRate(x160_animPlaybackSpeed); deltas1 = x4b0_modelDatas[i]->AdvanceAnimation(dt, mgr, x4_areaId, true); - x4b0_modelDatas[i+4]->GetAnimationData()->SetPlaybackRate(x160_animPlaybackSpeed); - deltas2 = x4b0_modelDatas[i+4]->AdvanceAnimation(dt, mgr, x4_areaId, true); - if (x4b0_modelDatas[i]->HasAnimData() && _38F4[i]) + x4b0_modelDatas[i + 4]->GetAnimationData()->SetPlaybackRate(x160_animPlaybackSpeed); + deltas2 = x4b0_modelDatas[i + 4]->AdvanceAnimation(dt, mgr, x4_areaId, true); + if (x4b0_modelDatas[i]->HasAnimData() && _38F4[i]) { UpdateEffects(mgr, *x4b0_modelDatas[i]->GetAnimationData(), r8 * 44 / x548_numBoids + 0x53); - if (x4b0_modelDatas[i+4]->HasAnimData() && _38F8[i]) - UpdateEffects(mgr, *x4b0_modelDatas[i+4]->GetAnimationData(), r3 * 44 / x548_numBoids + 0x53); - for (int r20 = i; r20 < x108_boids.size(); r20 += 4) { + } + if (x4b0_modelDatas[i + 4]->HasAnimData() && _38F8[i]) { + UpdateEffects(mgr, *x4b0_modelDatas[i + 4]->GetAnimationData(), r3 * 44 / x548_numBoids + 0x53); + } + for (size_t r20 = i; r20 < x108_boids.size(); r20 += 4) { CBoid& b = x108_boids[r20]; if (b.GetActive()) { if (b.x80_26_launched) { b.Translation() += b.x30_velocity * dt; } else if (b.x48_timeToDie > 0.f) { b.x48_timeToDie -= dt; - if (b.x48_timeToDie < 0.7f * mgr.GetActiveRandom()->Float()) + if (b.x48_timeToDie < 0.7f * mgr.GetActiveRandom()->Float()) { KillBoid(b, mgr, 1.f, 0.05f); + } } else if (b.x80_27_scarabExplodeTimerEnabled || b.x80_28_nearPlayer) { - b.x30_velocity = b.Transform().rotate(deltas2.x0_posDelta) * 1.5f / dt; + b.x30_velocity = b.GetTransform().rotate(deltas2.x0_posDelta) * 1.5f / dt; b.Translation() += b.x30_velocity * dt; } else { - b.x30_velocity = b.Transform().rotate(deltas1.x0_posDelta) * 1.5f / dt; + b.x30_velocity = b.GetTransform().rotate(deltas1.x0_posDelta) * 1.5f / dt; b.Translation() += b.x30_velocity * dt; } } @@ -854,29 +927,32 @@ void CWallCrawlerSwarm::Think(float dt, CStateManager& mgr) { } if (x558_flavor == EFlavor::Crab) { - zeus::CVector3f playerPos = mgr.GetPlayer().GetTranslation(); + const zeus::CVector3f playerPos = mgr.GetPlayer().GetTranslation(); for (auto& b : x108_boids) { - if (b.GetActive() && zeus::close_enough(b.x48_timeToDie, 0.f) && !b.x80_26_launched) - b.x80_28_nearPlayer = (playerPos - b.Translation()).magnitude() < x154_attractionRadius; + if (b.GetActive() && zeus::close_enough(b.x48_timeToDie, 0.f) && !b.x80_26_launched) { + b.x80_28_nearPlayer = (playerPos - b.GetTranslation()).magnitude() < x154_attractionRadius; + } } } if (x558_flavor == EFlavor::Parasite && x554_maxLaunches > 0) { - zeus::CVector3f _383c = mgr.GetPlayer().GetTranslation() + zeus::skUp; - static const CMaterialFilter filter = CMaterialFilter::MakeInclude(EMaterialTypes::Solid); + const zeus::CVector3f _383c = mgr.GetPlayer().GetTranslation() + zeus::skUp; + static constexpr auto filter = CMaterialFilter::MakeInclude(EMaterialTypes::Solid); int numLaunched = 0; - for (auto& b : x108_boids) { - if (b.GetActive() && b.x80_26_launched) + for (const auto& b : x108_boids) { + if (b.GetActive() && b.x80_26_launched) { ++numLaunched; + } } + for (auto it = x108_boids.begin(); it != x108_boids.end() && numLaunched < x554_maxLaunches; ++it) { CBoid& b = *it; if (b.GetActive() && zeus::close_enough(b.x48_timeToDie, 0.f) && !b.x80_26_launched && - (b.Translation() - _383c).magSquared() < 18.f * 18.f && mgr.GetActiveRandom()->Float() <= 0.02f) { - zeus::CVector3f dir = _383c - b.Translation(); - float mag = dir.magnitude(); + (b.GetTranslation() - _383c).magSquared() < 18.f * 18.f && mgr.GetActiveRandom()->Float() <= 0.02f) { + zeus::CVector3f dir = _383c - b.GetTranslation(); + const float mag = dir.magnitude(); dir = dir / mag; - if (mgr.RayStaticIntersection(b.Translation(), dir, mag, filter).IsInvalid()) { + if (mgr.RayStaticIntersection(b.GetTranslation(), dir, mag, filter).IsInvalid()) { LaunchBoid(b, _383c); ++numLaunched; } @@ -886,8 +962,9 @@ void CWallCrawlerSwarm::Think(float dt, CStateManager& mgr) { } void CWallCrawlerSwarm::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) { - for (int i = 0; i < 5; ++i) + for (size_t i = 0; i < 5; ++i) { x4b0_modelDatas[i]->GetAnimationData()->PreRender(); + } bool activeBoid = false; for (auto& b : x108_boids) { if (b.GetActive()) { @@ -901,19 +978,26 @@ void CWallCrawlerSwarm::PreRender(CStateManager& mgr, const zeus::CFrustum& frus } void CWallCrawlerSwarm::RenderParticles() const { - for (const auto& p : x524_particleGens) + for (const auto& p : x524_particleGens) { g_Renderer->AddParticleGen(*p); + } } void CWallCrawlerSwarm::AddToRenderer(const zeus::CFrustum&, const CStateManager& mgr) const { - if (GetActive()) { - RenderParticles(); - if (!xe4_30_outOfFrustum) { - if (CanRenderUnsorted(mgr)) - Render(mgr); - else - EnsureRendered(mgr); - } + if (!GetActive()) { + return; + } + + RenderParticles(); + + if (xe4_30_outOfFrustum) { + return; + } + + if (CanRenderUnsorted(mgr)) { + Render(mgr); + } else { + EnsureRendered(mgr); } } @@ -926,14 +1010,13 @@ zeus::CColor CWallCrawlerSwarm::SoftwareLight(const CStateManager& mgr, const ze lights.BuildDynamicLightList(mgr, aabb); zeus::CColor ret = lights.GetAmbientColor(); ret.a() = 1.f; - zeus::CVector3f center = aabb.center(); - u32 lightCount = lights.GetActiveLightCount(); + const zeus::CVector3f center = aabb.center(); + const u32 lightCount = lights.GetActiveLightCount(); for (u32 i = 0; i < lightCount; ++i) { const CLight& light = lights.GetLight(i); - float dist = (light.GetPosition() - center).magnitude(); - float att = 1.f / (dist * dist * light.GetAttenuationQuadratic() + - dist * light.GetAttenuationLinear() + - light.GetAttenuationConstant()); + const float dist = (light.GetPosition() - center).magnitude(); + const float att = 1.f / (dist * dist * light.GetAttenuationQuadratic() + dist * light.GetAttenuationLinear() + + light.GetAttenuationConstant()); ret += zeus::CColor::lerp(zeus::skBlack, light.GetColor(), 0.8f * std::min(att, 1.f)); } return ret; @@ -946,46 +1029,53 @@ void CWallCrawlerSwarm::HardwareLight(const CStateManager& mgr, const zeus::CAAB lights.SetFindShadowLight(false); lights.BuildAreaLightList(mgr, *mgr.GetWorld()->GetAreaAlways(x4_areaId), aabb); lights.BuildDynamicLightList(mgr, aabb); - for (auto& m : x4b0_modelDatas) { + for (const auto& m : x4b0_modelDatas) { lights.ActivateLights(*m->PickAnimatedModel(x4dc_whichModel).GetModelInst()); - if (auto iceModel = m->GetAnimationData()->GetIceModel()) + if (const auto iceModel = m->GetAnimationData()->GetIceModel()) { lights.ActivateLights(*iceModel->GetModelInst()); + } } } void CWallCrawlerSwarm::RenderBoid(const CBoid* boid, u32& drawMask, bool thermalHot, const CModelFlags& flags) const { u32 modelIndex = 0x0; - if (boid->x80_26_launched) + if (boid->x80_26_launched) { modelIndex = 0x8; - else if (boid->x48_timeToDie > 0.f) + } else if (boid->x48_timeToDie > 0.f) { modelIndex = 0x9; - else if (boid->x80_27_scarabExplodeTimerEnabled || boid->x80_28_nearPlayer) + } else if (boid->x80_27_scarabExplodeTimerEnabled || boid->x80_28_nearPlayer) { modelIndex += 0x4; + } + CModelData& mData = *x4b0_modelDatas[modelIndex]; CSkinnedModel& model = mData.PickAnimatedModel(x4dc_whichModel); - if (!model.GetModelInst()->TryLockTextures()) + if (!model.GetModelInst()->TryLockTextures()) { return; - u32 thisDrawMask = 1u << modelIndex; + } + + const u32 thisDrawMask = 1u << modelIndex; if (drawMask & thisDrawMask) { drawMask &= ~thisDrawMask; mData.GetAnimationData()->BuildPose(); } + model.GetModelInst()->SetAmbientColor(boid->x40_ambientLighting); CGraphics::SetModelMatrix(boid->GetTransform()); if (boid->x48_timeToDie > 0.f && !thermalHot) { - CModelFlags useFlags(0, 0, 3, zeus::skWhite); + const CModelFlags useFlags(0, 0, 3, zeus::skWhite); mData.GetAnimationData()->Render(model, useFlags, {}, nullptr); if (auto iceModel = mData.GetAnimationData()->GetIceModel()) { - if (!iceModel->GetModelInst()->TryLockTextures()) + if (!iceModel->GetModelInst()->TryLockTextures()) { return; + } iceModel->GetModelInst()->SetAmbientColor(zeus::skWhite); - float alpha = 1.f - boid->x48_timeToDie; - zeus::CColor color(1.f, alpha > 0.f ? boid->x48_timeToDie : 1.f); - CModelFlags iceFlags(5, 0, 3, color); + const float alpha = 1.f - boid->x48_timeToDie; + const zeus::CColor color(1.f, alpha > 0.f ? boid->x48_timeToDie : 1.f); + const CModelFlags iceFlags(5, 0, 3, color); mData.GetAnimationData()->Render(*iceModel, iceFlags, {}, nullptr); } } else if (thermalHot) { - CModelFlags thermFlags(5, 0, 3, zeus::skWhite); + const CModelFlags thermFlags(5, 0, 3, zeus::skWhite); mData.RenderThermal(zeus::skWhite, zeus::CColor(0.f, 0.25f), thermFlags); } else { mData.GetAnimationData()->Render(model, flags, {}, nullptr); @@ -996,28 +1086,32 @@ void CWallCrawlerSwarm::Render(const CStateManager& mgr) const { SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(fmt("CWallCrawlerSwarm::Render {} {} {}"), x8_uid, xc_editorId, x10_name).c_str(), zeus::skOrange); u32 drawMask = 0xffffffff; - bool r24 = x560_24_enableLighting; - bool r23 = x560_25_useSoftwareLight; + const bool r24 = x560_24_enableLighting; + const bool r23 = x560_25_useSoftwareLight; if (!r24) { // Ambient 50% grey } - bool thermalHot = mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot; + + const bool thermalHot = mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot; CModelFlags flags(0, 0, 3, zeus::skWhite); - if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay) + if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay) { flags = CModelFlags(5, 0, 3, zeus::CColor(1.f, 0.3f)); + } + for (int r27 = 0; r27 < 5; ++r27) { for (int r28 = 0; r28 < 5; ++r28) { for (int r21 = 0; r21 < 5; ++r21) { - int idx = r21 * 25 + r28 * 5 + r27; + const int idx = r21 * 25 + r28 * 5 + r27; if (CBoid* b = x168_partitionedBoidLists[idx]) { if (r24) { - zeus::CAABox aabb = BoxForPosition(r27, r28, r21, 0.f); + const zeus::CAABox aabb = BoxForPosition(r27, r28, r21, 0.f); if (r23) { if ((idx & 0x3) == (x100_thinkCounter & 0x3)) { - zeus::CColor color = SoftwareLight(mgr, aabb); + const zeus::CColor color = SoftwareLight(mgr, aabb); for (CBoid* b2 = b; b2; b2 = b2->x44_next) { - if (b2->GetActive()) + if (b2->GetActive()) { b2->x40_ambientLighting = zeus::CColor::lerp(b2->x40_ambientLighting, color, 0.3f); + } } } } else { @@ -1025,23 +1119,26 @@ void CWallCrawlerSwarm::Render(const CStateManager& mgr) const { } } for (CBoid* b2 = b; b2; b2 = b2->x44_next) { - if (b2->x80_25_inFrustum && b2->GetActive()) + if (b2->x80_25_inFrustum && b2->GetActive()) { RenderBoid(b2, drawMask, thermalHot, flags); + } } } } } } + CBoid* b = x360_outlierBoidList; for (int i = 1; b; ++i, b = b->x44_next) { if (b->x80_25_inFrustum && b->GetActive()) { if (r24) { - zeus::CAABox aabb(b->GetTranslation() - x374_boidRadius, b->GetTranslation() + x374_boidRadius); + const zeus::CAABox aabb(b->GetTranslation() - x374_boidRadius, b->GetTranslation() + x374_boidRadius); if (r23) { if ((i & 0x3) == (x100_thinkCounter & 0x3)) { zeus::CColor color = SoftwareLight(mgr, aabb); - if (b->GetActive()) + if (b->GetActive()) { b->x40_ambientLighting = zeus::CColor::lerp(b->x40_ambientLighting, color, 0.3f); + } } } else { HardwareLight(mgr, aabb); @@ -1067,37 +1164,40 @@ std::optional CWallCrawlerSwarm::GetTouchBounds() const { void CWallCrawlerSwarm::Touch(CActor& other, CStateManager& mgr) { CActor::Touch(other, mgr); - if (TCastToPtr proj = other) { + if (TCastToConstPtr proj = other) { if (x3c4_dVuln.WeaponHurts(proj->GetDamageInfo().GetWeaponMode(), false)) { if (auto projTb = proj->GetTouchBounds()) { - float f0 = 0.1f + x378_touchRadius; - float f30 = f0 * f0; + const float f0 = 0.1f + x378_touchRadius; + const float f30 = f0 * f0; for (auto& b : x108_boids) { if (b.GetActive()) { - zeus::CAABox aabb(b.GetTranslation() - f30, b.GetTranslation() + f30); + const zeus::CAABox aabb(b.GetTranslation() - f30, b.GetTranslation() + f30); if (aabb.intersects(*projTb)) { b.x78_health -= proj->GetDamageInfo().GetDamage(x3c4_dVuln); - if (b.x78_health <= 0.f) + if (b.x78_health <= 0.f) { KillBoid(b, mgr, 1.f, 0.1f); + } } } } } } } - if (TCastToPtr player = other) { - float radius = zeus::close_enough(x380_playerTouchRadius, 0.f) ? x378_touchRadius : x380_playerTouchRadius; + + if (TCastToConstPtr player = other) { + const float radius = zeus::close_enough(x380_playerTouchRadius, 0.f) ? x378_touchRadius : x380_playerTouchRadius; if (auto playerTb = player->GetTouchBounds()) { for (auto& b : x108_boids) { if (b.GetActive() && b.x48_timeToDie <= 0.f) { if (x558_flavor == EFlavor::Scarab && b.x80_27_scarabExplodeTimerEnabled) { - zeus::CAABox aabb(b.GetTranslation() - x37c_scarabBoxMargin, b.GetTranslation() + x37c_scarabBoxMargin); + const zeus::CAABox aabb(b.GetTranslation() - x37c_scarabBoxMargin, + b.GetTranslation() + x37c_scarabBoxMargin); if (playerTb->intersects(aabb)) { ExplodeBoid(b, mgr); SetExplodeTimers(b.GetTranslation(), 0.5f, 0.5f, 2.5f); } } - zeus::CAABox aabb(b.GetTranslation() - radius, b.GetTranslation() + radius); + const zeus::CAABox aabb(b.GetTranslation() - radius, b.GetTranslation() + radius); if (playerTb->intersects(aabb)) { if (b.GetActive() && x558_flavor == EFlavor::Parasite) { constexpr CDamageInfo dInfo(CWeaponMode(EWeaponType::AI), 2.0e-05f, 0.f, 0.f); @@ -1120,15 +1220,19 @@ void CWallCrawlerSwarm::Touch(CActor& other, CStateManager& mgr) { } zeus::CVector3f CWallCrawlerSwarm::GetOrbitPosition(const CStateManager&) const { - if (x42c_lockOnIdx == -1) + if (x42c_lockOnIdx == -1) { return x124_lastOrbitPosition; + } + x124_lastOrbitPosition = x108_boids[x42c_lockOnIdx].GetTranslation(); return x124_lastOrbitPosition; } zeus::CVector3f CWallCrawlerSwarm::GetAimPosition(const CStateManager&, float dt) const { - if (x42c_lockOnIdx == -1) + if (x42c_lockOnIdx == -1) { return x124_lastOrbitPosition; + } + return x108_boids[x42c_lockOnIdx].x30_velocity * dt + x124_lastOrbitPosition; } diff --git a/Runtime/World/CWorld.cpp b/Runtime/World/CWorld.cpp index fb8910c12..f2499f3ca 100644 --- a/Runtime/World/CWorld.cpp +++ b/Runtime/World/CWorld.cpp @@ -233,15 +233,18 @@ TAreaId CWorld::IGetAreaId(CAssetId id) const { } void CWorld::MoveToChain(CGameArea* area, EChain chain) { - if (area->x138_curChain == chain) + if (area->x138_curChain == chain) { return; + } - if (area->x138_curChain != EChain::Invalid) - if (x4c_chainHeads[int(area->x138_curChain)] == area) - x4c_chainHeads[int(area->x138_curChain)] = area->x130_next; + if (area->x138_curChain != EChain::Invalid) { + if (x4c_chainHeads[size_t(area->x138_curChain)] == area) { + x4c_chainHeads[size_t(area->x138_curChain)] = area->x130_next; + } + } - area->SetChain(x4c_chainHeads[int(chain)], chain); - x4c_chainHeads[int(chain)] = area; + area->SetChain(x4c_chainHeads[size_t(chain)], chain); + x4c_chainHeads[size_t(chain)] = area; } void CWorld::MoveAreaToAliveChain(TAreaId aid) { MoveToChain(x18_areas[aid].get(), EChain::Alive); } @@ -307,13 +310,15 @@ bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, CAssetId mreaId) r.readUint32Big(); x18_areas.reserve(areaCount); - for (u32 i = 0; i < areaCount; ++i) + for (u32 i = 0; i < areaCount; ++i) { x18_areas.push_back(std::make_unique(r, i, version)); + } - if (x48_chainCount < 5) { - for (int i = x48_chainCount; i < 5; ++i) + if (x48_chainCount < x4c_chainHeads.size()) { + for (size_t i = x48_chainCount; i < x4c_chainHeads.size(); ++i) { x4c_chainHeads[i] = nullptr; - x48_chainCount = 5; + } + x48_chainCount = x4c_chainHeads.size(); } for (std::unique_ptr& area : x18_areas) diff --git a/Runtime/World/CWorld.hpp b/Runtime/World/CWorld.hpp index 90c02aec1..2e2065d21 100644 --- a/Runtime/World/CWorld.hpp +++ b/Runtime/World/CWorld.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -123,7 +124,7 @@ private: std::unique_ptr x40_loadBuf; u32 x44_bufSz; u32 x48_chainCount = 0; - CGameArea* x4c_chainHeads[5] = {}; + std::array x4c_chainHeads{}; IObjectStore& x60_objectStore; IFactory& x64_resFactory; diff --git a/Runtime/World/CWorldTransManager.cpp b/Runtime/World/CWorldTransManager.cpp index 68127594a..43091ff55 100644 --- a/Runtime/World/CWorldTransManager.cpp +++ b/Runtime/World/CWorldTransManager.cpp @@ -349,7 +349,7 @@ void CWorldTransManager::TouchModels() { if (x4_modelData->x68_beamModelData.IsNull() && x4_modelData->x14c_beamModel.IsLoaded() && x4_modelData->x14c_beamModel.GetObj()) { - x4_modelData->x68_beamModelData = { + x4_modelData->x68_beamModelData = CModelData{ CStaticRes(x4_modelData->x14c_beamModel.GetObjectTag()->id, x4_modelData->x0_samusRes.GetScale()), 2}; } @@ -358,7 +358,7 @@ void CWorldTransManager::TouchModels() { x4_modelData->x164_suitSkin.GetObj()) { CAnimRes animRes(x4_modelData->x0_samusRes.GetId(), GetSuitCharIdx(), x4_modelData->x0_samusRes.GetScale(), x4_modelData->x0_samusRes.GetDefaultAnim(), true); - x4_modelData->x1c_samusModelData = {animRes, 2}; + x4_modelData->x1c_samusModelData = CModelData{animRes, 2}; CAnimPlaybackParms aData(animRes.GetDefaultAnim(), -1, 1.f, true); x4_modelData->x1c_samusModelData.GetAnimationData()->SetAnimation(aData, false); @@ -408,22 +408,23 @@ void CWorldTransManager::EnableTransition(const CAnimRes& samusRes, CAssetId pla x4_modelData->x164_suitSkin = g_SimplePool->GetObj(SObjectTag{FOURCC('CSKR'), info.GetSkinRulesId()}); if (platRes.IsValid()) { - x4_modelData->xb4_platformModelData = {CStaticRes(platRes, platScale), 2}; + x4_modelData->xb4_platformModelData = CModelData{CStaticRes(platRes, platScale), 2}; x4_modelData->xb4_platformModelData.Touch(CModelData::EWhichModel::Normal, 0); } if (bgRes.IsValid()) { - CStaticRes bg(bgRes, bgScale); - x4_modelData->x100_bgModelData[0] = bg; + const CStaticRes bg(bgRes, bgScale); + x4_modelData->x100_bgModelData[0] = CModelData{bg}; x4_modelData->x100_bgModelData[0].Touch(CModelData::EWhichModel::Normal, 0); - x4_modelData->x100_bgModelData[1] = bg; + x4_modelData->x100_bgModelData[1] = CModelData{bg}; x4_modelData->x100_bgModelData[1].Touch(CModelData::EWhichModel::Normal, 0); - x4_modelData->x100_bgModelData[2] = bg; + x4_modelData->x100_bgModelData[2] = CModelData{bg}; x4_modelData->x100_bgModelData[2].Touch(CModelData::EWhichModel::Normal, 0); - zeus::CAABox bounds = x4_modelData->x100_bgModelData[0].GetBounds(); + const zeus::CAABox bounds = x4_modelData->x100_bgModelData[0].GetBounds(); x1c_bgHeight = (bounds.max.z() - bounds.min.z()) * bgScale.z(); - } else + } else { x1c_bgHeight = 0.f; + } StartTransition(); TouchModels(); diff --git a/Runtime/World/CWorldTransManager.hpp b/Runtime/World/CWorldTransManager.hpp index 8c23547b7..978d0f447 100644 --- a/Runtime/World/CWorldTransManager.hpp +++ b/Runtime/World/CWorldTransManager.hpp @@ -80,9 +80,9 @@ private: u8 dummy = 0; }; - CColoredQuadFilter m_fadeToBlack = {EFilterType::Blend}; - CTexturedQuadFilter m_dissolve = {EFilterType::Blend, CGraphics::g_SpareTexture.get()}; - CWideScreenFilter m_widescreen = {EFilterType::Blend}; + CColoredQuadFilter m_fadeToBlack{EFilterType::Blend}; + CTexturedQuadFilter m_dissolve{EFilterType::Blend, CGraphics::g_SpareTexture.get()}; + CWideScreenFilter m_widescreen{EFilterType::Blend}; CCameraBlurFilter m_camblur; boo::ObjToken m_reflectionCube[2]; diff --git a/Runtime/World/IGameArea.hpp b/Runtime/World/IGameArea.hpp index 2a4cce25a..9eb2c870b 100644 --- a/Runtime/World/IGameArea.hpp +++ b/Runtime/World/IGameArea.hpp @@ -58,6 +58,13 @@ public: virtual const zeus::CTransform& IGetTM() const = 0; }; -enum class EChain { Invalid = -1, ToDeallocate, Deallocated, Loading, Alive, AliveJudgement }; +enum class EChain { + Invalid = -1, + ToDeallocate, + Deallocated, + Loading, + Alive, + AliveJudgement, +}; } // namespace urde diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index c7aacdedb..4e6e85906 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -435,10 +435,12 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in, int propC list.Add(EMaterialTypes::CameraPassthrough); CModelData data; - if (animType == SBIG('ANCS')) - data = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, aParms.GetInitialAnimation(), false); - else - data = CStaticRes(staticId, head.x40_scale); + if (animType == SBIG('ANCS')) { + data = CModelData{ + CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, aParms.GetInitialAnimation(), false)}; + } else { + data = CModelData{CStaticRes(staticId, head.x40_scale)}; + } if ((collisionExtent.x() < 0.f || collisionExtent.y() < 0.f || collisionExtent.z() < 0.f) || collisionExtent.isZero()) aabb = data.GetBounds(head.x10_transform.getRotation()); @@ -495,7 +497,7 @@ CEntity* ScriptLoader::LoadDoor(CStateManager& mgr, CInputStream& in, int propCo if (!g_ResFactory->GetResourceTypeById(aParms.GetACSFile()).IsValid()) return nullptr; - CModelData mData = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, 0, false); + CModelData mData{CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, 0, false)}; if (collisionExtent.isZero()) aabb = mData.GetBounds(head.x10_transform.getRotation()); @@ -655,10 +657,12 @@ CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in, int pr } CModelData data; - if (animType == SBIG('ANCS')) - data = CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, aParms.GetInitialAnimation(), true); - else - data = CStaticRes(staticId, head.x40_scale); + if (animType == SBIG('ANCS')) { + data = CModelData{ + CAnimRes(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, aParms.GetInitialAnimation(), true)}; + } else { + data = CModelData{CStaticRes(staticId, head.x40_scale)}; + } if (extent.isZero()) aabb = data.GetBounds(head.x10_transform.getRotation()); @@ -814,9 +818,9 @@ CEntity* ScriptLoader::LoadNewIntroBoss(CStateManager& mgr, CInputStream& in, in CAnimRes res(aParms.GetACSFile(), aParms.GetCharacter(), head.x40_scale, aParms.GetInitialAnimation(), true); - return new MP1::CNewIntroBoss(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, res, pInfo, actParms, - minTurnAngle, projectile, dInfo, beamContactFxId, beamPulseFxId, beamTextureId, - beamGlowTextureId); + return new MP1::CNewIntroBoss(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, CModelData{res}, pInfo, + actParms, minTurnAngle, projectile, dInfo, beamContactFxId, beamPulseFxId, + beamTextureId, beamGlowTextureId); } CEntity* ScriptLoader::LoadSpawnPoint(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { @@ -922,14 +926,16 @@ CEntity* ScriptLoader::LoadPickup(CStateManager& mgr, CInputStream& in, int prop CModelData data; - if (acsType == SBIG('ANCS')) - data = CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), head.x40_scale, animParms.GetInitialAnimation(), - true); - else - data = CStaticRes(staticModel, head.x40_scale); + if (acsType == SBIG('ANCS')) { + data = CModelData{CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), head.x40_scale, + animParms.GetInitialAnimation(), true)}; + } else { + data = CModelData{CStaticRes(staticModel, head.x40_scale)}; + } - if (extent.isZero()) + if (extent.isZero()) { aabb = data.GetBounds(head.x10_transform.getRotation()); + } return new CScriptPickup(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, std::move(data), actorParms, aabb, itemType, amount, capacity, pickupEffect, possibility, lifeTime, fadeInTime, @@ -1008,9 +1014,9 @@ CEntity* ScriptLoader::LoadBeetle(CStateManager& mgr, CInputStream& in, int prop const CAnimationParameters& animParams = pInfo.GetAnimationParameters(); CAnimRes animRes(animParams.GetACSFile(), animParams.GetCharacter(), scale, animParams.GetInitialAnimation(), true); - return new MP1::CBeetle(mgr.AllocateUniqueId(), name, info, xfrm, animRes, pInfo, flavor, entranceType, touchDamage, - platingVuln, tailAimReference, initialAttackDelay, retreatTime, unused, tailVuln, aParams, - tailRes); + return new MP1::CBeetle(mgr.AllocateUniqueId(), name, info, xfrm, CModelData{animRes}, pInfo, flavor, entranceType, + touchDamage, platingVuln, tailAimReference, initialAttackDelay, retreatTime, unused, tailVuln, + aParams, tailRes); } CEntity* ScriptLoader::LoadHUDMemo(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { @@ -1129,28 +1135,30 @@ CEntity* ScriptLoader::LoadDebris(CStateManager& mgr, CInputStream& in, int prop if (!EnsurePropertyCount(propCount, 18, "Debris")) return nullptr; - SScaledActorHead head = LoadScaledActorHead(in, mgr); - float zImpulse = in.readFloatBig(); - zeus::CVector3f velocity = zeus::CVector3f::ReadBig(in); + const SScaledActorHead head = LoadScaledActorHead(in, mgr); + const float zImpulse = in.readFloatBig(); + const zeus::CVector3f velocity = zeus::CVector3f::ReadBig(in); zeus::CColor endsColor; endsColor.readRGBABig(in); - float mass = in.readFloatBig(); - float restitution = in.readFloatBig(); - float duration = in.readFloatBig(); - CScriptDebris::EScaleType scaleType = CScriptDebris::EScaleType(in.readUint32Big()); - bool randomAngImpulse = in.readBool(); - CAssetId model = in.readUint32Big(); - CActorParameters aParams = LoadActorParameters(in); - CAssetId particleId = in.readUint32Big(); - zeus::CVector3f particleScale = zeus::CVector3f::ReadBig(in); - bool b1 = in.readBool(); - bool active = in.readBool(); + const float mass = in.readFloatBig(); + const float restitution = in.readFloatBig(); + const float duration = in.readFloatBig(); + const auto scaleType = CScriptDebris::EScaleType(in.readUint32Big()); + const bool randomAngImpulse = in.readBool(); + const CAssetId model = in.readUint32Big(); + const CActorParameters aParams = LoadActorParameters(in); + const CAssetId particleId = in.readUint32Big(); + const zeus::CVector3f particleScale = zeus::CVector3f::ReadBig(in); + const bool b1 = in.readBool(); + const bool active = in.readBool(); - if (!g_ResFactory->GetResourceTypeById(model).IsValid()) + if (!g_ResFactory->GetResourceTypeById(model).IsValid()) { return nullptr; + } + return new CScriptDebris(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, - CStaticRes(model, head.x40_scale), aParams, particleId, particleScale, zImpulse, velocity, - endsColor, mass, restitution, duration, scaleType, b1, randomAngImpulse, active); + CModelData{CStaticRes(model, head.x40_scale)}, aParams, particleId, particleScale, zImpulse, + velocity, endsColor, mass, restitution, duration, scaleType, b1, randomAngImpulse, active); } CEntity* ScriptLoader::LoadCameraShaker(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {