Merge pull request #8446 from JosJuice/redump-regular-datfile-warning
RedumpVerifier: Show an error when datfile lacks serials or versions
This commit is contained in:
commit
0f4c971326
|
@ -99,7 +99,7 @@ void RedumpVerifier::Start(const Volume& volume)
|
||||||
ERROR_LOG(DISCIO, "Failed to fetch data from Redump.org, using old cached data instead");
|
ERROR_LOG(DISCIO, "Failed to fetch data from Redump.org, using old cached data instead");
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case DownloadStatus::Success:
|
case DownloadStatus::Success:
|
||||||
return ScanDatfile(ReadDatfile(system));
|
return ScanDatfile(ReadDatfile(system), system);
|
||||||
|
|
||||||
case DownloadStatus::SystemNotAvailable:
|
case DownloadStatus::SystemNotAvailable:
|
||||||
m_result = {Status::Error, Common::GetStringT("Wii data is not public yet")};
|
m_result = {Status::Error, Common::GetStringT("Wii data is not public yet")};
|
||||||
|
@ -213,7 +213,8 @@ static std::vector<u8> ParseHash(const char* str)
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const std::vector<u8>& data)
|
std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const std::vector<u8>& data,
|
||||||
|
const std::string& system)
|
||||||
{
|
{
|
||||||
pugi::xml_document doc;
|
pugi::xml_document doc;
|
||||||
if (!doc.load_buffer(data.data(), data.size()))
|
if (!doc.load_buffer(data.data(), data.size()))
|
||||||
|
@ -223,10 +224,14 @@ std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const st
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<PotentialMatch> potential_matches;
|
std::vector<PotentialMatch> potential_matches;
|
||||||
|
bool serials_exist = false;
|
||||||
|
bool versions_exist = false;
|
||||||
const pugi::xml_node datafile = doc.child("datafile");
|
const pugi::xml_node datafile = doc.child("datafile");
|
||||||
for (const pugi::xml_node game : datafile.children("game"))
|
for (const pugi::xml_node game : datafile.children("game"))
|
||||||
{
|
{
|
||||||
std::string version_string = game.child("version").text().as_string();
|
std::string version_string = game.child("version").text().as_string();
|
||||||
|
if (!version_string.empty())
|
||||||
|
versions_exist = true;
|
||||||
|
|
||||||
// Strip out prefix (e.g. "v1.02" -> "02", "Rev 2" -> "2")
|
// Strip out prefix (e.g. "v1.02" -> "02", "Rev 2" -> "2")
|
||||||
const size_t last_non_numeric = version_string.find_last_not_of("0123456789");
|
const size_t last_non_numeric = version_string.find_last_not_of("0123456789");
|
||||||
|
@ -241,6 +246,8 @@ std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const st
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const std::string serials = game.child("serial").text().as_string();
|
const std::string serials = game.child("serial").text().as_string();
|
||||||
|
if (!serials.empty())
|
||||||
|
serials_exist = true;
|
||||||
if (serials.empty() || StringBeginsWith(serials, "DS"))
|
if (serials.empty() || StringBeginsWith(serials, "DS"))
|
||||||
{
|
{
|
||||||
// GC Datel discs have no serials in Redump, Wii Datel discs have serials like "DS000101"
|
// GC Datel discs have no serials in Redump, Wii Datel discs have serials like "DS000101"
|
||||||
|
@ -299,6 +306,17 @@ std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const st
|
||||||
potential_match.hashes.sha1 = ParseHash(rom.attribute("sha1").value());
|
potential_match.hashes.sha1 = ParseHash(rom.attribute("sha1").value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!serials_exist || !versions_exist)
|
||||||
|
{
|
||||||
|
// If we reach this, the user has most likely downloaded a datfile manually,
|
||||||
|
// so show a panic alert rather than just using ERROR_LOG
|
||||||
|
|
||||||
|
// i18n: "Serial" refers to serial numbers, e.g. RVL-RSBE-USA
|
||||||
|
PanicAlertT("Serial and/or version data is missing from %s", GetPathForSystem(system).c_str());
|
||||||
|
m_result = {Status::Error, Common::GetStringT("Failed to parse Redump.org data")};
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
return potential_matches;
|
return potential_matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ private:
|
||||||
|
|
||||||
static DownloadStatus DownloadDatfile(const std::string& system, DownloadStatus old_status);
|
static DownloadStatus DownloadDatfile(const std::string& system, DownloadStatus old_status);
|
||||||
static std::vector<u8> ReadDatfile(const std::string& system);
|
static std::vector<u8> ReadDatfile(const std::string& system);
|
||||||
std::vector<PotentialMatch> ScanDatfile(const std::vector<u8>& data);
|
std::vector<PotentialMatch> ScanDatfile(const std::vector<u8>& data, const std::string& system);
|
||||||
|
|
||||||
std::string m_game_id;
|
std::string m_game_id;
|
||||||
u16 m_revision;
|
u16 m_revision;
|
||||||
|
|
Loading…
Reference in New Issue