mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-04 03:15:53 +00:00
Proper world-pak detection
This commit is contained in:
parent
45494ec9aa
commit
a6c964a7c2
@ -30,13 +30,13 @@ public:
|
|||||||
: HECL::FourCC(n) {}
|
: HECL::FourCC(n) {}
|
||||||
|
|
||||||
Delete expl;
|
Delete expl;
|
||||||
inline void read(Athena::io::IStreamReader& reader)
|
void read(Athena::io::IStreamReader& reader)
|
||||||
{reader.readUBytesToBuf(fcc, 4);}
|
{reader.readUBytesToBuf(fcc, 4);}
|
||||||
inline void write(Athena::io::IStreamWriter& writer) const
|
void write(Athena::io::IStreamWriter& writer) const
|
||||||
{writer.writeUBytes((atUint8*)fcc, 4);}
|
{writer.writeUBytes((atUint8*)fcc, 4);}
|
||||||
inline void fromYAML(Athena::io::YAMLDocReader& reader)
|
void fromYAML(Athena::io::YAMLDocReader& reader)
|
||||||
{std::string rs = reader.readString(nullptr); strncpy(fcc, rs.c_str(), 4);}
|
{std::string rs = reader.readString(nullptr); strncpy(fcc, rs.c_str(), 4);}
|
||||||
inline void toYAML(Athena::io::YAMLDocWriter& writer) const
|
void toYAML(Athena::io::YAMLDocWriter& writer) const
|
||||||
{writer.writeString(nullptr, std::string(fcc, 4));}
|
{writer.writeString(nullptr, std::string(fcc, 4));}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -48,20 +48,20 @@ class UniqueID32 : public BigYAML
|
|||||||
uint32_t m_id = 0xffffffff;
|
uint32_t m_id = 0xffffffff;
|
||||||
public:
|
public:
|
||||||
Delete expl;
|
Delete expl;
|
||||||
inline operator bool() const {return m_id != 0xffffffff;}
|
operator bool() const {return m_id != 0xffffffff;}
|
||||||
inline void read(Athena::io::IStreamReader& reader)
|
void read(Athena::io::IStreamReader& reader)
|
||||||
{m_id = reader.readUint32Big();}
|
{m_id = reader.readUint32Big();}
|
||||||
inline void write(Athena::io::IStreamWriter& writer) const
|
void write(Athena::io::IStreamWriter& writer) const
|
||||||
{writer.writeUint32Big(m_id);}
|
{writer.writeUint32Big(m_id);}
|
||||||
inline void fromYAML(Athena::io::YAMLDocReader& reader)
|
void fromYAML(Athena::io::YAMLDocReader& reader)
|
||||||
{m_id = reader.readUint32(nullptr);}
|
{m_id = reader.readUint32(nullptr);}
|
||||||
inline void toYAML(Athena::io::YAMLDocWriter& writer) const
|
void toYAML(Athena::io::YAMLDocWriter& writer) const
|
||||||
{writer.writeUint32(nullptr, m_id);}
|
{writer.writeUint32(nullptr, m_id);}
|
||||||
|
|
||||||
inline bool operator!=(const UniqueID32& other) const {return m_id != other.m_id;}
|
bool operator!=(const UniqueID32& other) const {return m_id != other.m_id;}
|
||||||
inline bool operator==(const UniqueID32& other) const {return m_id == other.m_id;}
|
bool operator==(const UniqueID32& other) const {return m_id == other.m_id;}
|
||||||
inline uint32_t toUint32() const {return m_id;}
|
uint32_t toUint32() const {return m_id;}
|
||||||
inline std::string toString() const
|
std::string toString() const
|
||||||
{
|
{
|
||||||
char buf[9];
|
char buf[9];
|
||||||
snprintf(buf, 9, "%08X", m_id);
|
snprintf(buf, 9, "%08X", m_id);
|
||||||
@ -75,16 +75,16 @@ class UniqueID64 : public BigDNA
|
|||||||
uint64_t m_id = 0xffffffffffffffff;
|
uint64_t m_id = 0xffffffffffffffff;
|
||||||
public:
|
public:
|
||||||
Delete expl;
|
Delete expl;
|
||||||
inline operator bool() const {return m_id != 0xffffffffffffffff;}
|
operator bool() const {return m_id != 0xffffffffffffffff;}
|
||||||
inline void read(Athena::io::IStreamReader& reader)
|
void read(Athena::io::IStreamReader& reader)
|
||||||
{m_id = reader.readUint64Big();}
|
{m_id = reader.readUint64Big();}
|
||||||
inline void write(Athena::io::IStreamWriter& writer) const
|
void write(Athena::io::IStreamWriter& writer) const
|
||||||
{writer.writeUint64Big(m_id);}
|
{writer.writeUint64Big(m_id);}
|
||||||
|
|
||||||
inline bool operator!=(const UniqueID64& other) const {return m_id != other.m_id;}
|
bool operator!=(const UniqueID64& other) const {return m_id != other.m_id;}
|
||||||
inline bool operator==(const UniqueID64& other) const {return m_id == other.m_id;}
|
bool operator==(const UniqueID64& other) const {return m_id == other.m_id;}
|
||||||
inline uint64_t toUint64() const {return m_id;}
|
uint64_t toUint64() const {return m_id;}
|
||||||
inline std::string toString() const
|
std::string toString() const
|
||||||
{
|
{
|
||||||
char buf[17];
|
char buf[17];
|
||||||
snprintf(buf, 17, "%016" PRIX64, m_id);
|
snprintf(buf, 17, "%016" PRIX64, m_id);
|
||||||
@ -105,20 +105,20 @@ class UniqueID128 : public BigDNA
|
|||||||
public:
|
public:
|
||||||
Delete expl;
|
Delete expl;
|
||||||
UniqueID128() {m_id[0]=0xffffffffffffffff; m_id[1]=0xffffffffffffffff;}
|
UniqueID128() {m_id[0]=0xffffffffffffffff; m_id[1]=0xffffffffffffffff;}
|
||||||
inline operator bool() const
|
operator bool() const
|
||||||
{return m_id[0] != 0xffffffffffffffff && m_id[1] != 0xffffffffffffffff;}
|
{return m_id[0] != 0xffffffffffffffff && m_id[1] != 0xffffffffffffffff;}
|
||||||
inline void read(Athena::io::IStreamReader& reader)
|
void read(Athena::io::IStreamReader& reader)
|
||||||
{
|
{
|
||||||
m_id[0] = reader.readUint64Big();
|
m_id[0] = reader.readUint64Big();
|
||||||
m_id[1] = reader.readUint64Big();
|
m_id[1] = reader.readUint64Big();
|
||||||
}
|
}
|
||||||
inline void write(Athena::io::IStreamWriter& writer) const
|
void write(Athena::io::IStreamWriter& writer) const
|
||||||
{
|
{
|
||||||
writer.writeUint64Big(m_id[0]);
|
writer.writeUint64Big(m_id[0]);
|
||||||
writer.writeUint64Big(m_id[1]);
|
writer.writeUint64Big(m_id[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator!=(const UniqueID128& other) const
|
bool operator!=(const UniqueID128& other) const
|
||||||
{
|
{
|
||||||
#if __SSE__
|
#if __SSE__
|
||||||
__m128i vcmp = _mm_cmpeq_epi32(m_id128, other.m_id128);
|
__m128i vcmp = _mm_cmpeq_epi32(m_id128, other.m_id128);
|
||||||
@ -128,7 +128,7 @@ public:
|
|||||||
return (m_id[0] != other.m_id[0]) || (m_id[1] != other.m_id[1]);
|
return (m_id[0] != other.m_id[0]) || (m_id[1] != other.m_id[1]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
inline bool operator==(const UniqueID128& other) const
|
bool operator==(const UniqueID128& other) const
|
||||||
{
|
{
|
||||||
#if __SSE__
|
#if __SSE__
|
||||||
__m128i vcmp = _mm_cmpeq_epi32(m_id128, other.m_id128);
|
__m128i vcmp = _mm_cmpeq_epi32(m_id128, other.m_id128);
|
||||||
@ -138,9 +138,9 @@ public:
|
|||||||
return (m_id[0] == other.m_id[0]) && (m_id[1] == other.m_id[1]);
|
return (m_id[0] == other.m_id[0]) && (m_id[1] == other.m_id[1]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
inline uint64_t toHighUint64() const {return m_id[0];}
|
uint64_t toHighUint64() const {return m_id[0];}
|
||||||
inline uint64_t toLowUint64() const {return m_id[1];}
|
uint64_t toLowUint64() const {return m_id[1];}
|
||||||
inline std::string toString() const
|
std::string toString() const
|
||||||
{
|
{
|
||||||
char buf[33];
|
char buf[33];
|
||||||
snprintf(buf, 33, "%016" PRIX64 "%016" PRIX64, m_id[0], m_id[1]);
|
snprintf(buf, 33, "%016" PRIX64 "%016" PRIX64, m_id[0], m_id[1]);
|
||||||
@ -151,7 +151,7 @@ public:
|
|||||||
/* Case-insensitive comparator for std::map sorting */
|
/* Case-insensitive comparator for std::map sorting */
|
||||||
struct CaseInsensitiveCompare
|
struct CaseInsensitiveCompare
|
||||||
{
|
{
|
||||||
inline bool operator()(const std::string& lhs, const std::string& rhs) const
|
bool operator()(const std::string& lhs, const std::string& rhs) const
|
||||||
{
|
{
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
if (_stricmp(lhs.c_str(), rhs.c_str()) < 0)
|
if (_stricmp(lhs.c_str(), rhs.c_str()) < 0)
|
||||||
@ -163,7 +163,7 @@ struct CaseInsensitiveCompare
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
inline bool operator()(const std::wstring& lhs, const std::wstring& rhs) const
|
bool operator()(const std::wstring& lhs, const std::wstring& rhs) const
|
||||||
{
|
{
|
||||||
if (_wcsicmp(lhs.c_str(), rhs.c_str()) < 0)
|
if (_wcsicmp(lhs.c_str(), rhs.c_str()) < 0)
|
||||||
return true;
|
return true;
|
||||||
@ -248,28 +248,28 @@ namespace std
|
|||||||
template<>
|
template<>
|
||||||
struct hash<Retro::DNAFourCC>
|
struct hash<Retro::DNAFourCC>
|
||||||
{
|
{
|
||||||
inline size_t operator()(const Retro::DNAFourCC& fcc) const
|
size_t operator()(const Retro::DNAFourCC& fcc) const
|
||||||
{return fcc.toUint32();}
|
{return fcc.toUint32();}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct hash<Retro::UniqueID32>
|
struct hash<Retro::UniqueID32>
|
||||||
{
|
{
|
||||||
inline size_t operator()(const Retro::UniqueID32& id) const
|
size_t operator()(const Retro::UniqueID32& id) const
|
||||||
{return id.toUint32();}
|
{return id.toUint32();}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct hash<Retro::UniqueID64>
|
struct hash<Retro::UniqueID64>
|
||||||
{
|
{
|
||||||
inline size_t operator()(const Retro::UniqueID64& id) const
|
size_t operator()(const Retro::UniqueID64& id) const
|
||||||
{return id.toUint64();}
|
{return id.toUint64();}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct hash<Retro::UniqueID128>
|
struct hash<Retro::UniqueID128>
|
||||||
{
|
{
|
||||||
inline size_t operator()(const Retro::UniqueID128& id) const
|
size_t operator()(const Retro::UniqueID128& id) const
|
||||||
{return id.toHighUint64() ^ id.toLowUint64();}
|
{return id.toHighUint64() ^ id.toLowUint64();}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
if (m_pos >= m_sz)
|
if (m_pos >= m_sz)
|
||||||
LogDNACommon.report(LogVisor::FatalError, "PAK stream cursor overrun");
|
LogDNACommon.report(LogVisor::FatalError, "PAK stream cursor overrun");
|
||||||
}
|
}
|
||||||
inline void seek(atInt64 pos, Athena::SeekOrigin origin)
|
void seek(atInt64 pos, Athena::SeekOrigin origin)
|
||||||
{
|
{
|
||||||
if (origin == Athena::Begin)
|
if (origin == Athena::Begin)
|
||||||
m_pos = pos;
|
m_pos = pos;
|
||||||
@ -36,10 +36,10 @@ public:
|
|||||||
if (m_pos >= m_sz)
|
if (m_pos >= m_sz)
|
||||||
LogDNACommon.report(LogVisor::FatalError, "PAK stream cursor overrun");
|
LogDNACommon.report(LogVisor::FatalError, "PAK stream cursor overrun");
|
||||||
}
|
}
|
||||||
inline atUint64 position() const {return m_pos;}
|
atUint64 position() const {return m_pos;}
|
||||||
inline atUint64 length() const {return m_sz;}
|
atUint64 length() const {return m_sz;}
|
||||||
inline const atUint8* data() const {return m_buf.get();}
|
const atUint8* data() const {return m_buf.get();}
|
||||||
inline atUint64 readUBytesToBuf(void* buf, atUint64 len)
|
atUint64 readUBytesToBuf(void* buf, atUint64 len)
|
||||||
{
|
{
|
||||||
atUint64 bufEnd = m_pos + len;
|
atUint64 bufEnd = m_pos + len;
|
||||||
if (bufEnd > m_sz)
|
if (bufEnd > m_sz)
|
||||||
@ -63,7 +63,7 @@ struct UniqueResult
|
|||||||
const HECL::SystemString* layerName = nullptr;
|
const HECL::SystemString* layerName = nullptr;
|
||||||
UniqueResult() = default;
|
UniqueResult() = default;
|
||||||
UniqueResult(Type tp) : type(tp) {}
|
UniqueResult(Type tp) : type(tp) {}
|
||||||
inline HECL::ProjectPath uniquePath(const HECL::ProjectPath& pakPath) const
|
HECL::ProjectPath uniquePath(const HECL::ProjectPath& pakPath) const
|
||||||
{
|
{
|
||||||
if (type == UNIQUE_AREA)
|
if (type == UNIQUE_AREA)
|
||||||
{
|
{
|
||||||
@ -156,13 +156,13 @@ public:
|
|||||||
/* Add to global entry lookup */
|
/* Add to global entry lookup */
|
||||||
const typename BRIDGETYPE::PAKType& pak = bridge.getPAK();
|
const typename BRIDGETYPE::PAKType& pak = bridge.getPAK();
|
||||||
for (const auto& entry : pak.m_idMap)
|
for (const auto& entry : pak.m_idMap)
|
||||||
|
{
|
||||||
|
if (!pak.m_noShare)
|
||||||
{
|
{
|
||||||
auto sSearch = m_sharedEntries.find(entry.first);
|
auto sSearch = m_sharedEntries.find(entry.first);
|
||||||
if (sSearch != m_sharedEntries.end())
|
if (sSearch != m_sharedEntries.end())
|
||||||
continue;
|
continue;
|
||||||
auto uSearch = m_uniqueEntries.find(entry.first);
|
auto uSearch = m_uniqueEntries.find(entry.first);
|
||||||
if (!pak.m_noShare)
|
|
||||||
{
|
|
||||||
if (uSearch != m_uniqueEntries.end())
|
if (uSearch != m_uniqueEntries.end())
|
||||||
{
|
{
|
||||||
m_uniqueEntries.erase(uSearch);
|
m_uniqueEntries.erase(uSearch);
|
||||||
|
@ -19,7 +19,7 @@ static bool GetNoShare(const std::string& name)
|
|||||||
{
|
{
|
||||||
std::string lowerName = name;
|
std::string lowerName = name;
|
||||||
std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
|
std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
|
||||||
if (!name.compare(0, 7, "metroid"))
|
if (!lowerName.compare(0, 7, "metroid"))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ static bool GetNoShare(const std::string& name)
|
|||||||
{
|
{
|
||||||
std::string lowerName = name;
|
std::string lowerName = name;
|
||||||
std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
|
std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
|
||||||
if (!name.compare(0, 7, "metroid"))
|
if (!lowerName.compare(0, 7, "metroid"))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ static bool GetNoShare(const std::string& name)
|
|||||||
{
|
{
|
||||||
std::string lowerName = name;
|
std::string lowerName = name;
|
||||||
std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
|
std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
|
||||||
if (!name.compare(0, 7, "metroid"))
|
if (!lowerName.compare(0, 7, "metroid"))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user