metaforce/DataSpec/DNAMP3/PAK.hpp

68 lines
1.7 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2015-07-06 01:33:06 +00:00
#include <unordered_map>
2018-12-20 03:45:48 +00:00
#include <lzokay.hpp>
2016-03-04 23:04:53 +00:00
#include <nod/DiscBase.hpp>
2018-06-29 20:21:36 +00:00
#include "DataSpec/DNACommon/PAK.hpp"
2015-07-06 01:33:06 +00:00
2018-12-08 05:30:43 +00:00
namespace DataSpec::DNAMP3 {
2015-07-06 01:33:06 +00:00
2016-03-04 23:04:53 +00:00
extern const hecl::FourCC CMPD;
2015-07-14 00:38:48 +00:00
2018-12-08 05:30:43 +00:00
struct PAK : BigDNA {
bool m_noShare;
PAK(bool noShare) : m_noShare(noShare) {}
struct Header : BigDNA {
AT_DECL_DNA
Value<atUint32> version;
Value<atUint32> headSz;
Value<atUint8> md5sum[16];
Seek<40, athena::Current> seek;
} m_header;
struct NameEntry : BigDNA {
AT_DECL_DNA
String<-1> name;
DNAFourCC type;
UniqueID64 id;
};
struct Entry : BigDNA {
AT_DECL_DNA
Value<atUint32> compressed;
DNAFourCC type;
UniqueID64 id;
Value<atUint32> size;
Value<atUint32> offset;
UniqueResult unique;
std::string name;
std::unique_ptr<atUint8[]> getBuffer(const nod::Node& pak, atUint64& szOut) const;
inline PAKEntryReadStream beginReadStream(const nod::Node& pak, atUint64 off = 0) const {
atUint64 sz;
std::unique_ptr<atUint8[]> buf = getBuffer(pak, sz);
return PAKEntryReadStream(std::move(buf), sz, off);
}
};
std::vector<NameEntry> m_nameEntries;
std::unordered_map<UniqueID64, Entry> m_entries;
std::vector<UniqueID64> m_firstEntries;
std::unordered_map<std::string, UniqueID64> m_nameMap;
std::unordered_set<UniqueID64> m_dupeMREAs;
AT_DECL_EXPLICIT_DNA
const Entry* lookupEntry(const UniqueID64& id) const;
const Entry* lookupEntry(std::string_view name) const;
std::string bestEntryName(const nod::Node& pakNode, const Entry& entry, bool& named) const;
bool mreaHasDupeResources(const UniqueID64& id) const { return m_dupeMREAs.find(id) != m_dupeMREAs.cend(); }
typedef UniqueID64 IDType;
2015-07-06 01:33:06 +00:00
};
2018-12-08 05:30:43 +00:00
} // namespace DataSpec::DNAMP3