metaforce/DataSpec/DNAMP3/PAK.hpp

77 lines
1.7 KiB
C++
Raw Normal View History

2015-07-06 01:33:06 +00:00
#ifndef __DNAMP3_PAK_HPP__
#define __DNAMP3_PAK_HPP__
#include <unordered_map>
2015-07-14 00:38:48 +00:00
#include <lzo/lzo1x.h>
2016-03-04 23:04:53 +00:00
#include <nod/DiscBase.hpp>
2015-08-22 01:58:41 +00:00
#include "../DNACommon/PAK.hpp"
2015-07-06 01:33:06 +00:00
2016-02-13 09:02:47 +00:00
namespace DataSpec
2015-07-06 01:33:06 +00:00
{
namespace DNAMP3
{
2016-03-04 23:04:53 +00:00
extern const hecl::FourCC CMPD;
2015-07-14 00:38:48 +00:00
struct PAK : BigDNA
2015-07-06 01:33:06 +00:00
{
bool m_noShare;
PAK(bool noShare) : m_noShare(noShare) {}
2015-07-07 03:22:44 +00:00
struct Header : BigDNA
2015-07-06 01:33:06 +00:00
{
2015-07-06 02:07:57 +00:00
DECL_DNA
2015-07-06 01:33:06 +00:00
Value<atUint32> version;
Value<atUint32> headSz;
Value<atUint8> md5sum[16];
2016-03-04 23:04:53 +00:00
Seek<40, athena::Current> seek;
2015-07-06 01:33:06 +00:00
} m_header;
2015-07-07 03:22:44 +00:00
struct NameEntry : BigDNA
2015-07-06 01:33:06 +00:00
{
2015-07-06 02:07:57 +00:00
DECL_DNA
2015-07-06 01:33:06 +00:00
String<-1> name;
2015-08-23 06:42:29 +00:00
DNAFourCC type;
2015-07-06 01:33:06 +00:00
UniqueID64 id;
};
2015-07-07 03:22:44 +00:00
struct Entry : BigDNA
2015-07-06 01:33:06 +00:00
{
2015-07-06 02:07:57 +00:00
DECL_DNA
Value<atUint32> compressed;
2015-08-23 06:42:29 +00:00
DNAFourCC type;
2015-07-06 01:33:06 +00:00
UniqueID64 id;
2015-07-06 02:07:57 +00:00
Value<atUint32> size;
Value<atUint32> offset;
UniqueResult unique;
std::string name;
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;
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<UniqueID64, Entry> m_entries;
std::vector<UniqueID64> m_firstEntries;
std::unordered_map<std::string, UniqueID64> m_nameMap;
2015-07-06 01:33:06 +00:00
2015-07-10 05:28:08 +00:00
DECL_EXPLICIT_DNA
2015-07-06 01:33:06 +00:00
2017-03-10 18:00:40 +00:00
const Entry* lookupEntry(const UniqueID64& id) const;
const Entry* lookupEntry(const std::string& name) const;
std::string bestEntryName(const Entry& entry, bool& named) const;
2015-07-28 23:53:57 +00:00
typedef UniqueID64 IDType;
2015-07-06 01:33:06 +00:00
};
}
}
#endif // __DNAMP3_PAK_HPP__