Skip to content

Commit 56d37d7

Browse files
committed
RedumpVerifier: Show an error when datfile lacks serials or versions
This happens if someone manually downloads a regular datfile from redump.org and puts it where Dolphin stores datfiles. Dolphin needs "special" datfiles that contain fields for serials and versions. Before this change, all discs (except Datel discs) would show up as "Unknown disc" when using a regular datfile.
1 parent a7d4be7 commit 56d37d7

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Source/Core/DiscIO/VolumeVerifier.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void RedumpVerifier::Start(const Volume& volume)
9999
ERROR_LOG(DISCIO, "Failed to fetch data from Redump.org, using old cached data instead");
100100
[[fallthrough]];
101101
case DownloadStatus::Success:
102-
return ScanDatfile(ReadDatfile(system));
102+
return ScanDatfile(ReadDatfile(system), system);
103103

104104
case DownloadStatus::SystemNotAvailable:
105105
m_result = {Status::Error, Common::GetStringT("Wii data is not public yet")};
@@ -213,7 +213,8 @@ static std::vector<u8> ParseHash(const char* str)
213213
return hash;
214214
}
215215

216-
std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const std::vector<u8>& data)
216+
std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const std::vector<u8>& data,
217+
const std::string& system)
217218
{
218219
pugi::xml_document doc;
219220
if (!doc.load_buffer(data.data(), data.size()))
@@ -223,10 +224,14 @@ std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const st
223224
}
224225

225226
std::vector<PotentialMatch> potential_matches;
227+
bool serials_exist = false;
228+
bool versions_exist = false;
226229
const pugi::xml_node datafile = doc.child("datafile");
227230
for (const pugi::xml_node game : datafile.children("game"))
228231
{
229232
std::string version_string = game.child("version").text().as_string();
233+
if (!version_string.empty())
234+
versions_exist = true;
230235

231236
// Strip out prefix (e.g. "v1.02" -> "02", "Rev 2" -> "2")
232237
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
241246
continue;
242247

243248
const std::string serials = game.child("serial").text().as_string();
249+
if (!serials.empty())
250+
serials_exist = true;
244251
if (serials.empty() || StringBeginsWith(serials, "DS"))
245252
{
246253
// 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
299306
potential_match.hashes.sha1 = ParseHash(rom.attribute("sha1").value());
300307
}
301308

309+
if (!serials_exist || !versions_exist)
310+
{
311+
// If we reach this, the user has most likely downloaded a datfile manually,
312+
// so show a panic alert rather than just using ERROR_LOG
313+
314+
// i18n: "Serial" refers to serial numbers, e.g. RVL-RSBE-USA
315+
PanicAlertT("Serial and/or version data is missing from %s", GetPathForSystem(system).c_str());
316+
m_result = {Status::Error, Common::GetStringT("Failed to parse Redump.org data")};
317+
return {};
318+
}
319+
302320
return potential_matches;
303321
}
304322

Source/Core/DiscIO/VolumeVerifier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class RedumpVerifier final
8888

8989
static DownloadStatus DownloadDatfile(const std::string& system, DownloadStatus old_status);
9090
static std::vector<u8> ReadDatfile(const std::string& system);
91-
std::vector<PotentialMatch> ScanDatfile(const std::vector<u8>& data);
91+
std::vector<PotentialMatch> ScanDatfile(const std::vector<u8>& data, const std::string& system);
9292

9393
std::string m_game_id;
9494
u16 m_revision;

0 commit comments

Comments
 (0)