diff --git a/DataSpec/DNACommon/CMakeLists.txt b/DataSpec/DNACommon/CMakeLists.txt index 3603e402a..a96ac6ac7 100644 --- a/DataSpec/DNACommon/CMakeLists.txt +++ b/DataSpec/DNACommon/CMakeLists.txt @@ -9,6 +9,7 @@ add_library(DNACommon ${liblist} PAK.hpp PAK.cpp GX.hpp + FSM2.hpp FSM2.cpp MLVL.hpp MLVL.cpp CMDL.cpp MAPA.cpp @@ -25,7 +26,7 @@ add_library(DNACommon ParticleCommon.cpp FONT.hpp FONT.cpp DeafBabe.hpp - BabeDead.hpp + BabeDead.hpp RigInverter.hpp RigInverter.cpp Tweaks/ITweakGame.hpp Tweaks/ITweakParticle.hpp diff --git a/DataSpec/DNACommon/FSM2.cpp b/DataSpec/DNACommon/FSM2.cpp new file mode 100644 index 000000000..cc45b8e47 --- /dev/null +++ b/DataSpec/DNACommon/FSM2.cpp @@ -0,0 +1,1018 @@ +#include +#include +#include + +#include "FSM2.hpp" + +namespace DataSpec +{ +namespace DNAFSM2 +{ +logvisor::Module LogDNAFSM2("urde::DNAFSM2"); + +template +void FSM2::Header::read(athena::io::IStreamReader& __dna_reader) +{ + /* magic */ + magic.read(__dna_reader); + /* version */ + version = __dna_reader.readUint32Big(); +} + +template +void FSM2::Header::write(athena::io::IStreamWriter& __dna_writer) const +{ + /* magic */ + magic.write(__dna_writer); + /* version */ + __dna_writer.writeUint32Big(version); +} + +template +void FSM2::Header::read(athena::io::YAMLDocReader& __dna_docin) +{ + /* magic */ + __dna_docin.enumerate("magic", magic); + /* version */ + version = __dna_docin.readUint32("version"); +} + +template +void FSM2::Header::write(athena::io::YAMLDocWriter& __dna_docout) const +{ + /* magic */ + __dna_docout.enumerate("magic", magic); + /* version */ + __dna_docout.writeUint32("version", version); +} + +template +const char* FSM2::Header::DNAType() +{ + return "FSM2::Header"; +} + +template +size_t FSM2::Header::binarySize(size_t __isz) const +{ + __isz = magic.binarySize(__isz); + return __isz + 4; +} + +template +void FSM2::CommonStruct::read(athena::io::IStreamReader& __dna_reader) +{ + /* name */ + name = __dna_reader.readString(-1); + /* unknown */ + unknown = __dna_reader.readUint32Big(); +} + +template +void FSM2::CommonStruct::write(athena::io::IStreamWriter& __dna_writer) const +{ + /* name */ + __dna_writer.writeString(name, -1); + /* unknown */ + __dna_writer.writeUint32Big(unknown); +} + +template +void FSM2::CommonStruct::read(athena::io::YAMLDocReader& __dna_docin) +{ + /* name */ + name = __dna_docin.readString("name"); + /* unknown */ + unknown = __dna_docin.readUint32("unknown"); +} + +template +void FSM2::CommonStruct::write(athena::io::YAMLDocWriter& __dna_docout) const +{ + /* name */ + __dna_docout.writeString("name", name); + /* unknown */ + __dna_docout.writeUint32("unknown", unknown); +} + +template +const char* FSM2::CommonStruct::DNAType() +{ + return "FSM2::CommonStruct"; +} + +template +size_t FSM2::CommonStruct::binarySize(size_t __isz) const +{ + __isz += name.size() + 1; + __isz += 4; + return __isz; +} + +template +void FSM2::FSMV1::read(athena::io::IStreamReader& __dna_reader) +{ + /* stateCount */ + stateCount = __dna_reader.readUint32Big(); + /* unknown1Count */ + unknown1Count = __dna_reader.readUint32Big(); + /* unknown2Count */ + unknown2Count = __dna_reader.readUint32Big(); + /* unknown3Count */ + unknown3Count = __dna_reader.readUint32Big(); + /* states */ + __dna_reader.enumerate(states, stateCount); + /* unknown1 */ + __dna_reader.enumerate(unknown1, unknown1Count); + /* unknown2 */ + __dna_reader.enumerate(unknown2, unknown2Count); + /* unknown3 */ + __dna_reader.enumerate(unknown3, unknown3Count); +} + +template +void FSM2::FSMV1::write(athena::io::IStreamWriter& __dna_writer) const +{ + /* stateCount */ + __dna_writer.writeUint32Big(stateCount); + /* unknown1Count */ + __dna_writer.writeUint32Big(unknown1Count); + /* unknown2Count */ + __dna_writer.writeUint32Big(unknown2Count); + /* unknown3Count */ + __dna_writer.writeUint32Big(unknown3Count); + /* states */ + __dna_writer.enumerate(states); + /* unknown1 */ + __dna_writer.enumerate(unknown1); + /* unknown2 */ + __dna_writer.enumerate(unknown2); + /* unknown3 */ + __dna_writer.enumerate(unknown3); +} + +template +void FSM2::FSMV1::read(athena::io::YAMLDocReader& __dna_docin) +{ + /* states */ + stateCount = __dna_docin.enumerate("states", states); + /* unknown1 */ + unknown1Count = __dna_docin.enumerate("unknown1", unknown1); + /* unknown2 */ + unknown2Count = __dna_docin.enumerate("unknown2", unknown2); + /* unknown3 */ + unknown3Count = __dna_docin.enumerate("unknown3", unknown3); +} + +template +void FSM2::FSMV1::write(athena::io::YAMLDocWriter& __dna_docout) const +{ + /* states */ + __dna_docout.enumerate("states", states); + /* unknown1 */ + __dna_docout.enumerate("unknown1", unknown1); + /* unknown2 */ + __dna_docout.enumerate("unknown2", unknown2); + /* unknown3 */ + __dna_docout.enumerate("unknown3", unknown3); +} + +template +const char* FSM2::FSMV1::DNAType() +{ + return "FSM2::FSMV1"; +} + +template +size_t FSM2::FSMV1::binarySize(size_t __isz) const +{ + __isz = __EnumerateSize(__isz, states); + __isz = __EnumerateSize(__isz, unknown1); + __isz = __EnumerateSize(__isz, unknown2); + __isz = __EnumerateSize(__isz, unknown3); + return __isz + 16; +} + +template +void FSM2::FSMV1::State::read(athena::io::IStreamReader& __dna_reader) +{ + /* name */ + name = __dna_reader.readString(-1); + /* unknownCount */ + unknownCount = __dna_reader.readUint32Big(); + /* unknown */ + __dna_reader.enumerate(unknown, unknownCount); +} + +template +void FSM2::FSMV1::State::write(athena::io::IStreamWriter& __dna_writer) const +{ + /* name */ + __dna_writer.writeString(name, -1); + /* unknownCount */ + __dna_writer.writeUint32Big(unknownCount); + /* unknown */ + __dna_writer.enumerate(unknown); +} + +template +void FSM2::FSMV1::State::read(athena::io::YAMLDocReader& __dna_docin) +{ + /* name */ + name = __dna_docin.readString("name"); + /* unknownCount squelched */ + /* unknown */ + unknownCount = __dna_docin.enumerate("unknown", unknown); +} + +template +void FSM2::FSMV1::State::write(athena::io::YAMLDocWriter& __dna_docout) const +{ + /* name */ + __dna_docout.writeString("name", name); + /* unknownCount squelched */ + /* unknown */ + __dna_docout.enumerate("unknown", unknown); +} + +template +const char* FSM2::FSMV1::State::DNAType() +{ + return "FSM2::FSMV1::State"; +} + +template +size_t FSM2::FSMV1::State::binarySize(size_t __isz) const +{ + __isz += name.size() + 1; + __isz = __EnumerateSize(__isz, unknown); + return __isz + 4; +} + +template +void FSM2::FSMV1::Unknown1::read(athena::io::IStreamReader& __dna_reader) +{ + /* name */ + name = __dna_reader.readString(-1); + /* unknown1 */ + unknown1 = __dna_reader.readFloatBig(); + /* unknown2Count */ + unknown2Count = __dna_reader.readUint32Big(); + /* unknown2 */ + __dna_reader.enumerate(unknown2, unknown2Count); + /* unknown3 */ + unknown3 = __dna_reader.readUByte(); +} + +template +void FSM2::FSMV1::Unknown1::write(athena::io::IStreamWriter& __dna_writer) const +{ + /* name */ + __dna_writer.writeString(name, -1); + /* unknown1 */ + __dna_writer.writeFloatBig(unknown1); + /* unknown2Count */ + __dna_writer.writeUint32Big(unknown2Count); + /* unknown2 */ + __dna_writer.enumerate(unknown2); + /* unknown3 */ + __dna_writer.writeUByte(unknown3); +} + +template +void FSM2::FSMV1::Unknown1::read(athena::io::YAMLDocReader& __dna_docin) +{ + /* name */ + name = __dna_docin.readString("name"); + /* unknown1 */ + unknown1 = __dna_docin.readFloat("unknown1"); + /* unknown2Count squelched */ + /* unknown2 */ + unknown2Count = __dna_docin.enumerate("unknown2", unknown2); + /* unknown3 */ + unknown3 = __dna_docin.readUByte("unknown3"); +} + +template +void FSM2::FSMV1::Unknown1::write(athena::io::YAMLDocWriter& __dna_docout) const +{ + /* name */ + __dna_docout.writeString("name", name); + /* unknown1 */ + __dna_docout.writeFloat("unknown1", unknown1); + /* unknown2Count squelched */ + /* unknown2 */ + __dna_docout.enumerate("unknown2", unknown2); + /* unknown3 */ + __dna_docout.writeUByte("unknown3", unknown3); +} + +template +const char* FSM2::FSMV1::Unknown1::DNAType() +{ + return "FSM2::FSMV1::Unknown1"; +} + +template +size_t FSM2::FSMV1::Unknown1::binarySize(size_t __isz) const +{ + __isz += name.size() + 1; + __isz = __EnumerateSize(__isz, unknown2); + return __isz + 9; +} + +template +void FSM2::FSMV1::Unknown2::read(athena::io::IStreamReader& __dna_reader) +{ + /* name */ + name = __dna_reader.readString(-1); + /* unknownCount */ + unknownCount = __dna_reader.readUint32Big(); + /* unknown */ + __dna_reader.enumerate(unknown, unknownCount); +} + +template +void FSM2::FSMV1::Unknown2::write(athena::io::IStreamWriter& __dna_writer) const +{ + /* name */ + __dna_writer.writeString(name, -1); + /* unknownCount */ + __dna_writer.writeUint32Big(unknownCount); + /* unknown */ + __dna_writer.enumerate(unknown); +} + +template +void FSM2::FSMV1::Unknown2::read(athena::io::YAMLDocReader& __dna_docin) +{ + /* name */ + name = __dna_docin.readString("name"); + /* unknownCount squelched */ + /* unknown */ + unknownCount = __dna_docin.enumerate("unknown", unknown); +} + +template +void FSM2::FSMV1::Unknown2::write(athena::io::YAMLDocWriter& __dna_docout) const +{ + /* name */ + __dna_docout.writeString("name", name); + /* unknownCount squelched */ + /* unknown */ + __dna_docout.enumerate("unknown", unknown); +} + +template +const char* FSM2::FSMV1::Unknown2::DNAType() +{ + return "FSM2::FSMV1::Unknown2"; +} + +template +size_t FSM2::FSMV1::Unknown2::binarySize(size_t __isz) const +{ + __isz += name.size() + 1; + __isz = __EnumerateSize(__isz, unknown); + return __isz + 4; +} + +template +void FSM2::FSMV1::Unknown3::read(athena::io::IStreamReader& __dna_reader) +{ + /* name */ + name = __dna_reader.readString(-1); + /* unknownCount */ + unknownCount = __dna_reader.readUint32Big(); + /* unknown */ + __dna_reader.enumerate(unknown, unknownCount); + /* fsmId */ + fsmId.read(__dna_reader); +} + +template +void FSM2::FSMV1::Unknown3::write(athena::io::IStreamWriter& __dna_writer) const +{ + /* name */ + __dna_writer.writeString(name, -1); + /* unknownCount */ + __dna_writer.writeUint32Big(unknownCount); + /* unknown */ + __dna_writer.enumerate(unknown); + /* fsmId */ + fsmId.write(__dna_writer); +} + +template +void FSM2::FSMV1::Unknown3::read(athena::io::YAMLDocReader& __dna_docin) +{ + /* name */ + name = __dna_docin.readString("name"); + /* unknownCount squelched */ + /* unknown */ + unknownCount = __dna_docin.enumerate("unknown", unknown); + /* fsmId */ + __dna_docin.enumerate("fsmId", fsmId); +} + +template +void FSM2::FSMV1::Unknown3::write(athena::io::YAMLDocWriter& __dna_docout) const +{ + /* name */ + __dna_docout.writeString("name", name); + /* unknownCount squelched */ + /* unknown */ + __dna_docout.enumerate("unknown", unknown); + /* fsmId */ + __dna_docout.enumerate("fsmId", fsmId); + +} + +template +const char* FSM2::FSMV1::Unknown3::DNAType() +{ + return "FSM2::FSMV1::Unknown3"; +} + +template +size_t FSM2::FSMV1::Unknown3::binarySize(size_t __isz) const +{ + __isz += name.size() + 1; + __isz = __EnumerateSize(__isz, unknown); + __isz = fsmId.binarySize(__isz); + return __isz + 4; +} + +template +void FSM2::FSMV2::read(athena::io::IStreamReader& __dna_reader) +{ + /* stateCount */ + stateCount = __dna_reader.readUint32Big(); + /* unknown1Count */ + unknown1Count = __dna_reader.readUint32Big(); + /* unknown2Count */ + unknown2Count = __dna_reader.readUint32Big(); + /* unknown3Count */ + unknown3Count = __dna_reader.readUint32Big(); + /* states */ + __dna_reader.enumerate(states, stateCount); + /* unknown1 */ + __dna_reader.enumerate(unknown1, unknown1Count); + /* unknown2 */ + __dna_reader.enumerate(unknown2, unknown2Count); + /* unknown3 */ + __dna_reader.enumerate(unknown3, unknown3Count); +} + +template +void FSM2::FSMV2::write(athena::io::IStreamWriter& __dna_writer) const +{ + /* stateCount */ + __dna_writer.writeUint32Big(stateCount); + /* unknown1Count */ + __dna_writer.writeUint32Big(unknown1Count); + /* unknown2Count */ + __dna_writer.writeUint32Big(unknown2Count); + /* unknown3Count */ + __dna_writer.writeUint32Big(unknown3Count); + /* states */ + __dna_writer.enumerate(states); + /* unknown1 */ + __dna_writer.enumerate(unknown1); + /* unknown2 */ + __dna_writer.enumerate(unknown2); + /* unknown3 */ + __dna_writer.enumerate(unknown3); +} + +template +void FSM2::FSMV2::read(athena::io::YAMLDocReader& __dna_docin) +{ + /* states */ + stateCount = __dna_docin.enumerate("states", states); + /* unknown1 */ + unknown1Count = __dna_docin.enumerate("unknown1", unknown1); + /* unknown2 */ + unknown2Count = __dna_docin.enumerate("unknown2", unknown2); + /* unknown3 */ + unknown3Count = __dna_docin.enumerate("unknown3", unknown3); +} + +template +void FSM2::FSMV2::write(athena::io::YAMLDocWriter& __dna_docout) const +{ + /* states */ + __dna_docout.enumerate("states", states); + /* unknown1 */ + __dna_docout.enumerate("unknown1", unknown1); + /* unknown2 */ + __dna_docout.enumerate("unknown2", unknown2); + /* unknown3 */ + __dna_docout.enumerate("unknown3", unknown3); +} + +template +const char* FSM2::FSMV2::DNAType() +{ + return "FSM2::FSMV2"; +} + +template +size_t FSM2::FSMV2::binarySize(size_t __isz) const +{ + __isz = __EnumerateSize(__isz, states); + __isz = __EnumerateSize(__isz, unknown1); + __isz = __EnumerateSize(__isz, unknown2); + __isz = __EnumerateSize(__isz, unknown3); + return __isz + 16; +} + +template +void FSM2::FSMV2::State::read(athena::io::IStreamReader& __dna_reader) +{ + /* name */ + name = __dna_reader.readString(-1); + /* unknown1 */ + unknown1 = __dna_reader.readUint32Big(); + /* unknown2 */ + unknown2 = __dna_reader.readUint32Big(); + /* unknown3 */ + unknown3 = __dna_reader.readUint32Big(); + /* unknown4 */ + unknown4 = __dna_reader.readUint32Big(); + /* unknown5Count */ + unknown5Count = __dna_reader.readUint32Big(); + /* unknown5 */ + __dna_reader.enumerate(unknown5, unknown5Count); +} + +template +void FSM2::FSMV2::State::write(athena::io::IStreamWriter& __dna_writer) const +{ + /* name */ + __dna_writer.writeString(name, -1); + /* unknown1 */ + __dna_writer.writeUint32Big(unknown1); + /* unknown2 */ + __dna_writer.writeUint32Big(unknown2); + /* unknown3 */ + __dna_writer.writeUint32Big(unknown3); + /* unknown4 */ + __dna_writer.writeUint32Big(unknown4); + /* unknown5Count */ + __dna_writer.writeUint32Big(unknown5Count); + /* unknown5 */ + __dna_writer.enumerate(unknown5); +} + +template +void FSM2::FSMV2::State::read(athena::io::YAMLDocReader& __dna_docin) +{ + /* name */ + name = __dna_docin.readString("name"); + /* unknown1 */ + unknown1 = __dna_docin.readUint32("unknown1"); + /* unknown2 */ + unknown2 = __dna_docin.readUint32("unknown2"); + /* unknown3 */ + unknown3 = __dna_docin.readUint32("unknown3"); + /* unknown4 */ + unknown4 = __dna_docin.readUint32("unknown4"); + /* unknown5Count squelched */ + /* unknown5 */ + unknown5Count = __dna_docin.enumerate("unknown5", unknown5); +} + +template +void FSM2::FSMV2::State::write(athena::io::YAMLDocWriter& __dna_docout) const +{ + /* name */ + __dna_docout.writeString("name", name); + /* unknown1 */ + __dna_docout.writeUint32("unknown1", unknown1); + /* unknown2 */ + __dna_docout.writeUint32("unknown2", unknown2); + /* unknown3 */ + __dna_docout.writeUint32("unknown3", unknown3); + /* unknown4 */ + __dna_docout.writeUint32("unknown4", unknown4); + /* unknown5Count squelched */ + /* unknown5 */ + __dna_docout.enumerate("unknown5", unknown5); +} + +template +const char* FSM2::FSMV2::State::DNAType() +{ + return "FSM2::FSMV2::State"; +} + +template +size_t FSM2::FSMV2::State::binarySize(size_t __isz) const +{ + __isz += name.size() + 1; + __isz = __EnumerateSize(__isz, unknown5); + return __isz + 20; +} + +template +void FSM2::FSMV2::Unknown1::read(athena::io::IStreamReader& __dna_reader) +{ + /* name */ + name = __dna_reader.readString(-1); + /* unknown1 */ + unknown1 = __dna_reader.readUint32Big(); + /* unknown2 */ + unknown2 = __dna_reader.readUint32Big(); + /* unknown3 */ + unknown3 = __dna_reader.readUint32Big(); + /* unknown4 */ + unknown4 = __dna_reader.readUint32Big(); + /* unknown5 */ + unknown5 = __dna_reader.readFloatBig(); + /* unknown6Count */ + unknown6Count = __dna_reader.readUint32Big(); + /* unknown6 */ + __dna_reader.enumerate(unknown6, unknown6Count); + /* unknown7 */ + unknown7 = __dna_reader.readUByte(); +} + +template +void FSM2::FSMV2::Unknown1::write(athena::io::IStreamWriter& __dna_writer) const +{ + /* name */ + __dna_writer.writeString(name, -1); + /* unknown1 */ + __dna_writer.writeUint32Big(unknown1); + /* unknown2 */ + __dna_writer.writeUint32Big(unknown2); + /* unknown3 */ + __dna_writer.writeUint32Big(unknown3); + /* unknown4 */ + __dna_writer.writeUint32Big(unknown4); + /* unknown5 */ + __dna_writer.writeUint32Big(unknown5); + /* unknown6Count */ + __dna_writer.writeFloatBig(unknown6Count); + /* unknown6 */ + __dna_writer.enumerate(unknown6); + /* unknown6 */ + __dna_writer.writeUByte(unknown7); +} + +template +void FSM2::FSMV2::Unknown1::read(athena::io::YAMLDocReader& __dna_docin) +{ + /* name */ + name = __dna_docin.readString("name"); + /* unknown1 */ + unknown1 = __dna_docin.readUint32("unknown1"); + /* unknown2 */ + unknown2 = __dna_docin.readUint32("unknown2"); + /* unknown3 */ + unknown3 = __dna_docin.readUint32("unknown3"); + /* unknown4 */ + unknown4 = __dna_docin.readUint32("unknown4"); + /* unknown5 */ + unknown5 = __dna_docin.readFloat("unknown5"); + /* unknown6Count squelched */ + /* unknown6 */ + unknown6Count = __dna_docin.enumerate("unknown6", unknown6); + /* unknown7 */ + unknown7 = __dna_docin.readUByte("unknown7"); +} + +template +void FSM2::FSMV2::Unknown1::write(athena::io::YAMLDocWriter& __dna_docout) const +{ + /* name */ + __dna_docout.writeString("name", name); + /* unknown1 */ + __dna_docout.writeUint32("unknown1", unknown1); + /* unknown2 */ + __dna_docout.writeUint32("unknown2", unknown2); + /* unknown3 */ + __dna_docout.writeUint32("unknown3", unknown3); + /* unknown4 */ + __dna_docout.writeUint32("unknown4", unknown4); + /* unknown5 */ + __dna_docout.writeFloat("unknown5", unknown5); + /* unknown6Count squelched */ + /* unknown6 */ + __dna_docout.enumerate("unknown6", unknown6); + /* unknown7 */ + __dna_docout.writeUByte("unknown7", unknown7); +} + +template +const char* FSM2::FSMV2::Unknown1::DNAType() +{ + return "FSM2::FSMV2::Unknown1"; +} + +template +size_t FSM2::FSMV2::Unknown1::binarySize(size_t __isz) const +{ + __isz += name.size() + 1; + __isz = __EnumerateSize(__isz, unknown6); + return __isz + 25; +} + +template +void FSM2::FSMV2::Unknown2::read(athena::io::IStreamReader& __dna_reader) +{ + /* name */ + name = __dna_reader.readString(-1); + /* unknown1 */ + unknown1 = __dna_reader.readUint32Big(); + /* unknown2 */ + unknown2 = __dna_reader.readUint32Big(); + /* unknown3 */ + unknown3 = __dna_reader.readUint32Big(); + /* unknown4 */ + unknown4 = __dna_reader.readUint32Big(); + /* unknown5Count */ + unknown5Count = __dna_reader.readUint32Big(); + /* unknown5 */ + __dna_reader.enumerate(unknown5, unknown5Count); +} + +template +void FSM2::FSMV2::Unknown2::write(athena::io::IStreamWriter& __dna_writer) const +{ + /* name */ + __dna_writer.writeString(name, -1); + /* unknown1 */ + __dna_writer.writeUint32Big(unknown1); + /* unknown2 */ + __dna_writer.writeUint32Big(unknown2); + /* unknown3 */ + __dna_writer.writeUint32Big(unknown3); + /* unknown4 */ + __dna_writer.writeUint32Big(unknown4); + /* unknown5Count */ + __dna_writer.writeUint32Big(unknown5Count); + /* unknown5 */ + __dna_writer.enumerate(unknown5); +} + +template +void FSM2::FSMV2::Unknown2::read(athena::io::YAMLDocReader& __dna_docin) +{ + /* name */ + name = __dna_docin.readString("name"); + /* unknown1 */ + unknown1 = __dna_docin.readUint32("unknown1"); + /* unknown2 */ + unknown2 = __dna_docin.readUint32("unknown2"); + /* unknown3 */ + unknown3 = __dna_docin.readUint32("unknown3"); + /* unknown4 */ + unknown4 = __dna_docin.readUint32("unknown4"); + /* unknown5Count squelched */ + /* unknown5 */ + unknown5Count = __dna_docin.enumerate("unknown5", unknown5); +} + +template +void FSM2::FSMV2::Unknown2::write(athena::io::YAMLDocWriter& __dna_docout) const +{ + /* name */ + __dna_docout.writeString("name", name); + /* unknown1 */ + __dna_docout.writeUint32("unknown1", unknown1); + /* unknown2 */ + __dna_docout.writeUint32("unknown2", unknown2); + /* unknown3 */ + __dna_docout.writeUint32("unknown3", unknown3); + /* unknown4 */ + __dna_docout.writeUint32("unknown4", unknown4); + /* unknown5Count squelched */ + /* unknown5 */ + __dna_docout.enumerate("unknown5", unknown5); +} + +template +const char* FSM2::FSMV2::Unknown2::DNAType() +{ + return "FSM2::FSMV2::Unknown2"; +} + +template +size_t FSM2::FSMV2::Unknown2::binarySize(size_t __isz) const +{ + __isz += name.size() + 1; + __isz = __EnumerateSize(__isz, unknown5); + return __isz + 20; +} + +template +void FSM2::FSMV2::Unknown3::read(athena::io::IStreamReader& __dna_reader) +{ + /* name */ + name = __dna_reader.readString(-1); + /* unknown1 */ + unknown1 = __dna_reader.readUint32Big(); + /* unknown2 */ + unknown2 = __dna_reader.readUint32Big(); + /* unknown3 */ + unknown3 = __dna_reader.readUint32Big(); + /* unknown4 */ + unknown4 = __dna_reader.readUint32Big(); + /* unknown5Count */ + unknown5Count = __dna_reader.readUint32Big(); + /* unknown5 */ + __dna_reader.enumerate(unknown5, unknown5Count); + /* fsmId */ + fsmId.read(__dna_reader); +} + +template +void FSM2::FSMV2::Unknown3::write(athena::io::IStreamWriter& __dna_writer) const +{ + /* name */ + __dna_writer.writeString(name, -1); + /* unknown1 */ + __dna_writer.writeUint32Big(unknown1); + /* unknown2 */ + __dna_writer.writeUint32Big(unknown2); + /* unknown3 */ + __dna_writer.writeUint32Big(unknown3); + /* unknown4 */ + __dna_writer.writeUint32Big(unknown4); + /* unknown5Count */ + __dna_writer.writeUint32Big(unknown5Count); + /* unknown5 */ + __dna_writer.enumerate(unknown5); + /* fsmId */ + fsmId.write(__dna_writer); +} + +template +void FSM2::FSMV2::Unknown3::read(athena::io::YAMLDocReader& __dna_docin) +{ + /* name */ + name = __dna_docin.readString("name"); + /* unknown1 */ + unknown1 = __dna_docin.readUint32("unknown1"); + /* unknown2 */ + unknown2 = __dna_docin.readUint32("unknown2"); + /* unknown3 */ + unknown3 = __dna_docin.readUint32("unknown3"); + /* unknown4 */ + unknown4 = __dna_docin.readUint32("unknown4"); + /* unknown5Count squelched */ + /* unknown5 */ + unknown5Count = __dna_docin.enumerate("unknown5", unknown5); + /* fsmId */ + __dna_docin.enumerate("fsmId", fsmId); +} + +template +void FSM2::FSMV2::Unknown3::write(athena::io::YAMLDocWriter& __dna_docout) const +{ + /* name */ + __dna_docout.writeString("name", name); + /* unknown1 */ + __dna_docout.writeUint32("unknown1", unknown1); + /* unknown2 */ + __dna_docout.writeUint32("unknown2", unknown2); + /* unknown3 */ + __dna_docout.writeUint32("unknown3", unknown3); + /* unknown4 */ + __dna_docout.writeUint32("unknown4", unknown4); + /* unknown5Count squelched */ + /* unknown5 */ + __dna_docout.enumerate("unknown5", unknown5); + /* fsmId */ + __dna_docout.enumerate("fsmId", fsmId); +} + +template +const char* FSM2::FSMV2::Unknown3::DNAType() +{ + return "FSM2::FSMV2::Unknown3"; +} + +template +size_t FSM2::FSMV2::Unknown3::binarySize(size_t __isz) const +{ + __isz += name.size() + 1; + __isz = __EnumerateSize(__isz, unknown5); + __isz = fsmId.binarySize(__isz); + return __isz + 20; +} + + +template +void FSM2::read(athena::io::IStreamReader& in) +{ + header.read(in); + if (header.magic != SBIG('FSM2')) + { + LogDNAFSM2.report(logvisor::Fatal, "Invalid FSM2 magic '%.4s' expected 'FSM2'", header.magic.toString().c_str()); + return; + } + + if (header.version == 1) + detail.reset(new FSMV1); + else if (header.version == 2) + detail.reset(new FSMV2); + else + { + LogDNAFSM2.report(logvisor::Fatal, "Invalid FSM2 version '%i'", header.version); + return; + } + + detail->read(in); +} + +template +void FSM2::write(athena::io::IStreamWriter& out) const +{ + header.write(out); + detail->write(out); +} + +template +void FSM2::read(athena::io::YAMLDocReader& in) +{ + header.read(in); + if (header.magic != SBIG('FSM2')) + { + LogDNAFSM2.report(logvisor::Fatal, "Invalid FSM2 magic '%.4s' expected 'FSM2'", header.magic.toString().c_str()); + return; + } + + if (header.version == 1) + detail.reset(new FSMV1); + else if (header.version == 2) + detail.reset(new FSMV2); + else + { + LogDNAFSM2.report(logvisor::Fatal, "Invalid FSM2 version '%i'", header.version); + return; + } + + detail->read(in); +} + +template +void FSM2::write(athena::io::YAMLDocWriter& out) const +{ + header.write(out); + detail->write(out); +} + +template +size_t FSM2::binarySize(size_t __isz) const +{ + __isz = header.binarySize(__isz); + return detail->binarySize(__isz); +} + +template +const char* FSM2::DNAType() { return "urde::FSM2"; } + +template +const char* FSM2::DNATypeV() const { return FSM2::DNAType(); } + +template struct FSM2; +template struct FSM2; + +template +bool ExtractFSM2(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) +{ + FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w")); + if (fp) + { + FSM2 fsm2; + fsm2.read(rs); + fsm2.toYAMLFile(fp); + fclose(fp); + return true; + } + return false; +} +template bool ExtractFSM2(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath); +template bool ExtractFSM2(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath); + +template +bool WriteFSM2(const FSM2& fsm2, const hecl::ProjectPath& outPath) +{ + athena::io::FileWriter w(outPath.getAbsolutePath(), true, false); + if (w.hasError()) + return false; + fsm2.write(w); + int64_t rem = w.position() % 32; + if (rem) + for (int64_t i=0 ; i<32-rem ; ++i) + w.writeBytes((atInt8*)"\xff", 1); + return true; +} +template bool WriteFSM2(const FSM2& fsm2, const hecl::ProjectPath& outPath); +template bool WriteFSM2(const FSM2& fsm2, const hecl::ProjectPath& outPath); + +} +} diff --git a/DataSpec/DNACommon/FSM2.hpp b/DataSpec/DNACommon/FSM2.hpp new file mode 100644 index 000000000..c81f68186 --- /dev/null +++ b/DataSpec/DNACommon/FSM2.hpp @@ -0,0 +1,163 @@ +#ifndef __COMMON_FSM2_HPP__ +#define __COMMON_FSM2_HPP__ + +#include "PAK.hpp" +#include "DNACommon.hpp" +#include "athena/FileWriter.hpp" + +namespace DataSpec +{ +namespace DNAFSM2 +{ +struct IFSM : BigYAML +{ + Delete _d; +}; + +template +struct FSM2 : BigYAML +{ + struct Header : BigYAML + { + DECL_YAML + DNAFourCC magic; + Value version; + } header; + + struct CommonStruct : BigYAML + { + DECL_YAML + String<-1> name; + Value unknown; + }; + + struct FSMV1 : IFSM + { + DECL_YAML + Value stateCount; + Value unknown1Count; + Value unknown2Count; + Value unknown3Count; + struct State : BigYAML + { + DECL_YAML + String<-1> name; + Value unknownCount; + Vector unknown; + }; + + struct Unknown1 : BigYAML + { + DECL_YAML + String<-1> name; + Value unknown1; + Value unknown2Count; + Vector unknown2; + Value unknown3; + }; + + struct Unknown2 : BigYAML + { + DECL_YAML + String<-1> name; + Value unknownCount; + Vector unknown; + }; + + struct Unknown3 : BigYAML + { + DECL_YAML + String<-1> name; + Value unknownCount; + Vector unknown; + IDType fsmId; + }; + + Vector states; + Vector unknown1; + Vector unknown2; + Vector unknown3; + }; + + struct FSMV2 : IFSM + { + DECL_YAML + Value stateCount; + Value unknown1Count; + Value unknown2Count; + Value unknown3Count; + struct State : BigYAML + { + DECL_YAML + String<-1> name; + Value unknown1; + Value unknown2; + Value unknown3; + Value unknown4; + Value unknown5Count; + Vector unknown5; + }; + + struct Unknown1 : BigYAML + { + DECL_YAML + String<-1> name; + Value unknown1; + Value unknown2; + Value unknown3; + Value unknown4; + Value unknown5; + Value unknown6Count; + Vector unknown6; + Value unknown7; + }; + + struct Unknown2 : BigYAML + { + DECL_YAML + String<-1> name; + Value unknown1; + Value unknown2; + Value unknown3; + Value unknown4; + Value unknown5Count; + Vector unknown5; + }; + + struct Unknown3 : BigYAML + { + DECL_YAML + String<-1> name; + Value unknown1; + Value unknown2; + Value unknown3; + Value unknown4; + Value unknown5Count; + Vector unknown5; + IDType fsmId; + }; + + Vector states; + Vector unknown1; + Vector unknown2; + Vector unknown3; + }; + + void read(athena::io::IStreamReader& in); + void write(athena::io::IStreamWriter& out) const; + void read(athena::io::YAMLDocReader& in); + void write(athena::io::YAMLDocWriter& out) const; + std::unique_ptr detail; + size_t binarySize(size_t __isz) const; + static const char* DNAType(); + const char* DNATypeV() const; +}; + +template +bool ExtractFSM2(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath); +template +bool WriteFSM2(const FSM2& fsm2, const hecl::ProjectPath& outPath); + +} +} +#endif // __COMMON_FSM2_HPP__ diff --git a/DataSpec/DNAMP2/DNAMP2.cpp b/DataSpec/DNAMP2/DNAMP2.cpp index 495ab1384..2094ebd99 100644 --- a/DataSpec/DNAMP2/DNAMP2.cpp +++ b/DataSpec/DNAMP2/DNAMP2.cpp @@ -7,6 +7,7 @@ #include "MREA.hpp" #include "MAPA.hpp" #include "AFSM.hpp" +#include "../DNACommon/FSM2.hpp" #include "../DNACommon/TXTR.hpp" #include "../DNACommon/FONT.hpp" @@ -230,6 +231,8 @@ ResExtractor PAKBridge::LookupExtractor(const DNAMP1::PAK::Entry& ent return {nullptr, MREA::Extract, {_S(".blend")}, 4}; case SBIG('MAPA'): return {nullptr, MAPA::Extract, {_S(".blend")}, 4}; + case SBIG('FSM2'): + return {DNAFSM2::ExtractFSM2, nullptr, {_S(".yaml")}}; case SBIG('FONT'): return {DNAFont::ExtractFONT, nullptr, {_S(".yaml")}}; } diff --git a/DataSpec/DNAMP3/DNAMP3.cpp b/DataSpec/DNAMP3/DNAMP3.cpp index 138c998fc..28adbe23d 100644 --- a/DataSpec/DNAMP3/DNAMP3.cpp +++ b/DataSpec/DNAMP3/DNAMP3.cpp @@ -10,6 +10,7 @@ #include "MAPA.hpp" #include "../DNACommon/TXTR.hpp" #include "../DNACommon/FONT.hpp" +#include "../DNACommon/FSM2.hpp" namespace DataSpec { @@ -238,6 +239,8 @@ ResExtractor PAKBridge::LookupExtractor(const PAK::Entry& entry) return {nullptr, MREA::Extract, {_S(".blend")}, 4}; case SBIG('MAPA'): return {nullptr, MAPA::Extract, {_S(".blend")}, 4}; + case SBIG('FSM2'): + return {DNAFSM2::ExtractFSM2, nullptr, {_S(".yaml")}}; case SBIG('FONT'): return {DNAFont::ExtractFONT, nullptr, {_S(".yaml")}}; }