#ifndef __DNAMP1_PAK_HPP__ #define __DNAMP1_PAK_HPP__ #include #include #include "../DNACommon/PAK.hpp" namespace Retro { namespace DNAMP1 { struct PAK : BigDNA { bool m_useLzo; bool m_noShare; PAK(bool useLzo, bool noShare) : m_useLzo(useLzo), m_noShare(noShare) {} DECL_EXPLICIT_DNA struct NameEntry : BigDNA { DECL_DNA DNAFourCC type; UniqueID32 id; Value nameLen; String name; }; struct Entry : BigDNA { DECL_DNA Value compressed; DNAFourCC type; UniqueID32 id; Value size; Value offset; UniqueResult unique; std::string name; /* backreferencing name for RE purposes */ std::unique_ptr getBuffer(const NOD::Node& pak, atUint64& szOut) const; inline PAKEntryReadStream beginReadStream(const NOD::Node& pak, atUint64 off=0) const { atUint64 sz; std::unique_ptr buf = getBuffer(pak, sz); return PAKEntryReadStream(std::move(buf), sz, off); } }; std::vector m_nameEntries; std::vector m_entries; std::vector m_firstEntries; std::unordered_map m_idMap; std::unordered_map m_nameMap; const Entry* lookupEntry(const UniqueID32& id) const { std::unordered_map::const_iterator result = m_idMap.find(id); if (result != m_idMap.end()) return result->second; return nullptr; } const Entry* lookupEntry(const std::string& name) const { std::unordered_map::const_iterator result = m_nameMap.find(name); if (result != m_nameMap.end()) return result->second; return nullptr; } std::string bestEntryName(const Entry& entry) const { /* Prefer named entries first */ for (const NameEntry& nentry : m_nameEntries) if (nentry.id == entry.id) return nentry.name; /* Otherwise return ID format string */ return entry.type.toString() + '_' + entry.id.toString(); } using IDType = UniqueID32; }; } } #endif // __DNAMP1_PAK_HPP__