@@ -99,7 +99,7 @@ void RedumpVerifier::Start(const Volume& volume)
99
99
ERROR_LOG (DISCIO, " Failed to fetch data from Redump.org, using old cached data instead" );
100
100
[[fallthrough]];
101
101
case DownloadStatus::Success:
102
- return ScanDatfile (ReadDatfile (system));
102
+ return ScanDatfile (ReadDatfile (system), system );
103
103
104
104
case DownloadStatus::SystemNotAvailable:
105
105
m_result = {Status::Error, Common::GetStringT (" Wii data is not public yet" )};
@@ -213,7 +213,8 @@ static std::vector<u8> ParseHash(const char* str)
213
213
return hash;
214
214
}
215
215
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)
217
218
{
218
219
pugi::xml_document doc;
219
220
if (!doc.load_buffer (data.data (), data.size ()))
@@ -223,10 +224,14 @@ std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const st
223
224
}
224
225
225
226
std::vector<PotentialMatch> potential_matches;
227
+ bool serials_exist = false ;
228
+ bool versions_exist = false ;
226
229
const pugi::xml_node datafile = doc.child (" datafile" );
227
230
for (const pugi::xml_node game : datafile.children (" game" ))
228
231
{
229
232
std::string version_string = game.child (" version" ).text ().as_string ();
233
+ if (!version_string.empty ())
234
+ versions_exist = true ;
230
235
231
236
// Strip out prefix (e.g. "v1.02" -> "02", "Rev 2" -> "2")
232
237
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
241
246
continue ;
242
247
243
248
const std::string serials = game.child (" serial" ).text ().as_string ();
249
+ if (!serials.empty ())
250
+ serials_exist = true ;
244
251
if (serials.empty () || StringBeginsWith (serials, " DS" ))
245
252
{
246
253
// 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
299
306
potential_match.hashes .sha1 = ParseHash (rom.attribute (" sha1" ).value ());
300
307
}
301
308
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
+
302
320
return potential_matches;
303
321
}
304
322
0 commit comments