From a41166bb376820389d9863ce23cf6fab20cb3b5f Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 7 Jun 2020 22:58:03 +0200 Subject: Make netplay's "same game" check more robust Instead of comparing the game ID, revision, disc number and name, we can compare a hash of important parts of the disc including all the aforementioned data but also additional data such as the FST. The primary reason why I'm making this change is to let us catch more desyncs before they happen, but this should also fix https://bugs.dolphin-emu.org/issues/12115. As a bonus, the UI can now distinguish the case where a client doesn't have the game at all from the case where a client has the wrong version of the game. --- Source/Core/DiscIO/DiscExtractor.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'Source/Core/DiscIO/DiscExtractor.cpp') diff --git a/Source/Core/DiscIO/DiscExtractor.cpp b/Source/Core/DiscIO/DiscExtractor.cpp index 3c2a67568d..b12b56b5c2 100644 --- a/Source/Core/DiscIO/DiscExtractor.cpp +++ b/Source/Core/DiscIO/DiscExtractor.cpp @@ -245,19 +245,26 @@ bool ExportBI2Data(const Volume& volume, const Partition& partition, return ExportData(volume, partition, 0x440, 0x2000, export_filename); } +std::optional GetApploaderSize(const Volume& volume, const Partition& partition) +{ + constexpr u64 header_size = 0x20; + const std::optional apploader_size = volume.ReadSwapped(0x2440 + 0x14, partition); + const std::optional trailer_size = volume.ReadSwapped(0x2440 + 0x18, partition); + if (!apploader_size || !trailer_size) + return std::nullopt; + + return header_size + *apploader_size + *trailer_size; +} + bool ExportApploader(const Volume& volume, const Partition& partition, const std::string& export_filename) { if (!IsDisc(volume.GetVolumeType())) return false; - std::optional apploader_size = volume.ReadSwapped(0x2440 + 0x14, partition); - const std::optional trailer_size = volume.ReadSwapped(0x2440 + 0x18, partition); - constexpr u32 header_size = 0x20; - if (!apploader_size || !trailer_size) + const std::optional apploader_size = GetApploaderSize(volume, partition); + if (!apploader_size) return false; - *apploader_size += *trailer_size + header_size; - DEBUG_LOG(DISCIO, "Apploader size -> %x", *apploader_size); return ExportData(volume, partition, 0x2440, *apploader_size, export_filename); } -- cgit v1.2.3