2015-07-06 01:33:06 +00:00
|
|
|
#ifndef __DNAMP1_PAK_HPP__
|
|
|
|
#define __DNAMP1_PAK_HPP__
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
#include "../Logging.hpp"
|
|
|
|
#include "../DNACommon/DNACommon.hpp"
|
|
|
|
|
|
|
|
namespace Retro
|
|
|
|
{
|
|
|
|
namespace DNAMP1
|
|
|
|
{
|
|
|
|
|
|
|
|
class PAK : public BigDNA
|
|
|
|
{
|
|
|
|
public:
|
2015-07-12 04:26:26 +00:00
|
|
|
DECL_EXPLICIT_DNA
|
|
|
|
|
2015-07-06 01:33:06 +00:00
|
|
|
struct NameEntry : public BigDNA
|
|
|
|
{
|
2015-07-06 02:07:57 +00:00
|
|
|
DECL_DNA
|
2015-07-11 22:41:10 +00:00
|
|
|
FourCC type;
|
2015-07-06 01:33:06 +00:00
|
|
|
UniqueID32 id;
|
|
|
|
Value<atUint32> nameLen;
|
|
|
|
String<DNA_COUNT(nameLen)> name;
|
|
|
|
};
|
|
|
|
|
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
|
2015-07-06 01:33:06 +00:00
|
|
|
Value<atUint32> compressed;
|
2015-07-11 22:41:10 +00:00
|
|
|
FourCC type;
|
2015-07-06 01:33:06 +00:00
|
|
|
UniqueID32 id;
|
|
|
|
Value<atUint32> size;
|
|
|
|
Value<atUint32> offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<NameEntry> m_nameEntries;
|
|
|
|
std::vector<Entry> m_entries;
|
|
|
|
std::unordered_map<UniqueID32, Entry*> m_idMap;
|
|
|
|
std::unordered_map<std::string, Entry*> m_nameMap;
|
|
|
|
|
|
|
|
inline const Entry* lookupEntry(const UniqueID32& id) const
|
|
|
|
{
|
2015-07-06 02:07:57 +00:00
|
|
|
std::unordered_map<UniqueID32, Entry*>::const_iterator result = m_idMap.find(id);
|
2015-07-06 01:33:06 +00:00
|
|
|
if (result != m_idMap.end())
|
2015-07-06 02:07:57 +00:00
|
|
|
return result->second;
|
2015-07-06 01:33:06 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const Entry* lookupEntry(const std::string& name) const
|
|
|
|
{
|
2015-07-06 02:07:57 +00:00
|
|
|
std::unordered_map<std::string, Entry*>::const_iterator result = m_nameMap.find(name);
|
2015-07-06 01:33:06 +00:00
|
|
|
if (result != m_nameMap.end())
|
2015-07-06 02:07:57 +00:00
|
|
|
return result->second;
|
2015-07-06 01:33:06 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __DNAMP1_PAK_HPP__
|