2015-07-06 01:33:06 +00:00
|
|
|
#ifndef __DNAMP1_PAK_HPP__
|
|
|
|
#define __DNAMP1_PAK_HPP__
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
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
|
|
|
|
2017-12-29 08:08:12 +00:00
|
|
|
namespace DataSpec::DNAMP1
|
2015-07-06 01:33:06 +00:00
|
|
|
{
|
|
|
|
|
2015-07-13 06:29:12 +00:00
|
|
|
struct PAK : BigDNA
|
2015-07-06 01:33:06 +00:00
|
|
|
{
|
2015-07-18 04:33:38 +00:00
|
|
|
bool m_useLzo;
|
2015-09-21 23:36:15 +00:00
|
|
|
bool m_noShare;
|
|
|
|
PAK(bool useLzo, bool noShare) : m_useLzo(useLzo), m_noShare(noShare) {}
|
2018-02-22 07:24:51 +00:00
|
|
|
AT_DECL_EXPLICIT_DNA
|
2015-07-12 04:26:26 +00:00
|
|
|
|
2015-07-13 06:29:12 +00:00
|
|
|
struct NameEntry : BigDNA
|
2015-07-06 01:33:06 +00:00
|
|
|
{
|
2018-02-22 07:24:51 +00:00
|
|
|
AT_DECL_DNA
|
2015-08-23 06:42:29 +00:00
|
|
|
DNAFourCC type;
|
2015-07-06 01:33:06 +00:00
|
|
|
UniqueID32 id;
|
|
|
|
Value<atUint32> nameLen;
|
2018-02-25 08:23:27 +00:00
|
|
|
String<AT_DNA_COUNT(nameLen)> name;
|
2015-07-06 01:33:06 +00:00
|
|
|
};
|
|
|
|
|
2015-07-07 03:22:44 +00:00
|
|
|
struct Entry : BigDNA
|
2015-07-06 01:33:06 +00:00
|
|
|
{
|
2018-02-22 07:24:51 +00:00
|
|
|
AT_DECL_DNA
|
2015-07-06 01:33:06 +00:00
|
|
|
Value<atUint32> compressed;
|
2015-08-23 06:42:29 +00:00
|
|
|
DNAFourCC type;
|
2015-07-06 01:33:06 +00:00
|
|
|
UniqueID32 id;
|
|
|
|
Value<atUint32> size;
|
|
|
|
Value<atUint32> offset;
|
2015-08-04 02:14:47 +00:00
|
|
|
UniqueResult unique;
|
2015-11-10 02:07:15 +00:00
|
|
|
std::string name; /* backreferencing name for RE purposes */
|
2015-07-14 00:38:48 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
std::unique_ptr<atUint8[]> getBuffer(const nod::Node& pak, atUint64& szOut) const;
|
|
|
|
inline PAKEntryReadStream beginReadStream(const nod::Node& pak, atUint64 off=0) const
|
2015-07-14 00:38:48 +00:00
|
|
|
{
|
|
|
|
atUint64 sz;
|
2015-07-18 04:33:38 +00:00
|
|
|
std::unique_ptr<atUint8[]> buf = getBuffer(pak, sz);
|
|
|
|
return PAKEntryReadStream(std::move(buf), sz, off);
|
2015-07-14 00:38:48 +00:00
|
|
|
}
|
2015-07-06 01:33:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<NameEntry> m_nameEntries;
|
2017-03-10 18:00:40 +00:00
|
|
|
std::unordered_map<UniqueID32, Entry> m_entries;
|
|
|
|
std::vector<UniqueID32> m_firstEntries;
|
|
|
|
std::unordered_map<std::string, UniqueID32> m_nameMap;
|
2018-04-07 20:55:57 +00:00
|
|
|
std::unordered_set<UniqueID32> m_dupeMREAs;
|
2015-07-06 01:33:06 +00:00
|
|
|
|
2017-03-10 18:00:40 +00:00
|
|
|
const Entry* lookupEntry(const UniqueID32& id) const;
|
2017-11-13 06:19:18 +00:00
|
|
|
const Entry* lookupEntry(std::string_view name) const;
|
2018-09-03 00:46:16 +00:00
|
|
|
std::string bestEntryName(const nod::Node& pakNode, const Entry& entry, bool& named) const;
|
2015-07-28 23:53:57 +00:00
|
|
|
|
2018-04-07 20:55:57 +00:00
|
|
|
bool mreaHasDupeResources(const UniqueID32& id) const
|
|
|
|
{ return m_dupeMREAs.find(id) != m_dupeMREAs.cend(); }
|
|
|
|
|
2015-10-27 00:19:03 +00:00
|
|
|
using IDType = UniqueID32;
|
2015-07-06 01:33:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __DNAMP1_PAK_HPP__
|