metaforce/DataSpec/DNACommon/SWHC.cpp

52 lines
1.6 KiB
C++
Raw Normal View History

#include "DataSpec/DNACommon/SWHC.hpp"
#include "DataSpec/DNACommon/PAK.hpp"
2018-12-08 05:30:43 +00:00
namespace DataSpec::DNAParticle {
2016-03-28 08:54:02 +00:00
template struct PPImpl<_SWSH<UniqueID32>>;
template struct PPImpl<_SWSH<UniqueID64>>;
AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_SWSH<UniqueID32>>)
AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_SWSH<UniqueID64>>)
2018-02-22 07:24:51 +00:00
template <>
2019-10-01 07:38:03 +00:00
std::string_view SWSH<UniqueID32>::DNAType() {
return "SWSH<UniqueID32>"sv;
2016-03-28 08:54:02 +00:00
}
2018-12-08 05:30:43 +00:00
template <>
2019-10-01 07:38:03 +00:00
std::string_view SWSH<UniqueID64>::DNAType() {
return "SWSH<UniqueID64>"sv;
2016-03-28 08:54:02 +00:00
}
template <class IDType>
2018-12-08 05:30:43 +00:00
bool ExtractSWSH(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) {
athena::io::FileWriter writer(outPath.getAbsolutePath());
if (writer.isOpen()) {
SWSH<IDType> swsh;
swsh.read(rs);
athena::io::ToYAMLStream(swsh, writer);
return true;
}
return false;
2016-03-28 08:54:02 +00:00
}
template bool ExtractSWSH<UniqueID32>(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
template bool ExtractSWSH<UniqueID64>(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
template <class IDType>
2018-12-08 05:30:43 +00:00
bool WriteSWSH(const SWSH<IDType>& swsh, const hecl::ProjectPath& outPath) {
athena::io::FileWriter w(outPath.getAbsolutePath(), true, false);
if (w.hasError())
return false;
swsh.write(w);
int64_t rem = w.position() % 32;
if (rem)
for (int64_t i = 0; i < 32 - rem; ++i)
w.writeUByte(0xff);
return true;
2016-03-28 08:54:02 +00:00
}
template bool WriteSWSH<UniqueID32>(const SWSH<UniqueID32>& swsh, const hecl::ProjectPath& outPath);
template bool WriteSWSH<UniqueID64>(const SWSH<UniqueID64>& swsh, const hecl::ProjectPath& outPath);
2018-12-08 05:30:43 +00:00
} // namespace DataSpec::DNAParticle