From 91f5236109cc08df656aceb4644f38762911e294 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 13 Jul 2015 15:07:15 -1000 Subject: [PATCH] fixed standalone game detection --- DataSpec/SpecBase.cpp | 19 +------------------ DataSpec/SpecBase.hpp | 1 + DataSpec/SpecMP1.cpp | 10 +++++++++- DataSpec/SpecMP2.cpp | 10 +++++++++- DataSpec/SpecMP3.cpp | 10 +++++++++- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index b34fbef80..ebb4cd424 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -10,35 +10,18 @@ bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector disc = NOD::OpenDiscFromImage(info.srcpath.c_str(), isWii); if (!disc) - { - LogModule.report(LogVisor::Error, _S("'%s' not a valid Nintendo disc image"), info.srcpath.c_str()); return false; - } const char* gameID = disc->getHeader().gameID; - bool valid = false; bool standalone = true; if (isWii) { if (!memcmp(gameID, "R3M", 3)) - { - valid = true; standalone = false; - } - else if (!memcmp(gameID, "R3IJ01", 6)) - valid = true; - } - else - { - if (!memcmp(gameID, "GM8", 3)) - valid = true; } - if (!valid) - { - LogModule.report(LogVisor::Error, "%.6s (%s) is not supported", gameID, disc->getHeader().gameTitle); + if (standalone && !checkStandaloneID(gameID)) return false; - } char region = disc->getHeader().gameID[3]; static const HECL::SystemString regNONE = _S(""); diff --git a/DataSpec/SpecBase.hpp b/DataSpec/SpecBase.hpp index 13c8da49c..43a82839c 100644 --- a/DataSpec/SpecBase.hpp +++ b/DataSpec/SpecBase.hpp @@ -24,6 +24,7 @@ struct SpecBase : HECL::Database::IDataSpec std::unordered_set& implicitsOut); void doPackage(const HECL::Database::Project& project, const PackagePassInfo& info); + virtual bool checkStandaloneID(const char* id) const=0; virtual bool checkFromStandaloneDisc(NOD::DiscBase& disc, const HECL::SystemString& regstr, const std::vector& args, diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index f3e54dbf5..df58ee651 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -11,6 +11,13 @@ namespace Retro struct SpecMP1 : SpecBase { + bool checkStandaloneID(const char* id) const + { + if (!memcmp(id, "GM8", 3)) + return true; + return false; + } + struct DiscPAK { const NOD::DiscBase::IPartition::Node& node; @@ -133,7 +140,8 @@ struct SpecMP1 : SpecBase rep.desc = _S("Metroid Prime ") + regstr; if (buildInfo) { - HECL::SystemStringView buildView(buildInfo); + std::string buildStr(buildInfo); + HECL::SystemStringView buildView(buildStr); rep.desc += _S(" (") + buildView.sys_str() + _S(")"); } diff --git a/DataSpec/SpecMP2.cpp b/DataSpec/SpecMP2.cpp index f255494bf..38a973564 100644 --- a/DataSpec/SpecMP2.cpp +++ b/DataSpec/SpecMP2.cpp @@ -11,6 +11,13 @@ namespace Retro struct SpecMP2 : SpecBase { + bool checkStandaloneID(const char* id) const + { + if (!memcmp(id, "G2M", 3)) + return true; + return false; + } + struct DiscPAK { const NOD::DiscBase::IPartition::Node& node; @@ -133,7 +140,8 @@ struct SpecMP2 : SpecBase rep.desc = _S("Metroid Prime 2 ") + regstr; if (buildInfo) { - HECL::SystemStringView buildView(buildInfo); + std::string buildStr(buildInfo); + HECL::SystemStringView buildView(buildStr); rep.desc += _S(" (") + buildView.sys_str() + _S(")"); } diff --git a/DataSpec/SpecMP3.cpp b/DataSpec/SpecMP3.cpp index 5769c26f2..3a5fe6a27 100644 --- a/DataSpec/SpecMP3.cpp +++ b/DataSpec/SpecMP3.cpp @@ -12,6 +12,13 @@ namespace Retro struct SpecMP3 : SpecBase { + bool checkStandaloneID(const char* id) const + { + if (!memcmp(id, "RM3", 3)) + return true; + return false; + } + struct DiscPAK { const NOD::DiscBase::IPartition::Node& node; @@ -147,7 +154,8 @@ struct SpecMP3 : SpecBase rep.desc = _S("Metroid Prime 3 ") + regstr; if (buildInfo) { - HECL::SystemStringView buildView(buildInfo); + std::string buildStr(buildInfo); + HECL::SystemStringView buildView(buildStr); rep.desc += _S(" (") + buildView.sys_str() + _S(")"); }