diff options
| author | JosJuice <josjuice@gmail.com> | 2020-06-07 22:58:03 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2020-08-02 22:46:53 +0200 |
| commit | a41166bb376820389d9863ce23cf6fab20cb3b5f (patch) | |
| tree | 833fb8c0479af02a23f88d650838d542fa012b00 /Source/Core/DiscIO/DiscExtractor.cpp | |
| parent | 25ebc3c07c6310924d662b2209f9ba5d08006ea6 (diff) | |
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.
Diffstat (limited to 'Source/Core/DiscIO/DiscExtractor.cpp')
| -rw-r--r-- | Source/Core/DiscIO/DiscExtractor.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
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<u64> GetApploaderSize(const Volume& volume, const Partition& partition) +{ + constexpr u64 header_size = 0x20; + const std::optional<u32> apploader_size = volume.ReadSwapped<u32>(0x2440 + 0x14, partition); + const std::optional<u32> trailer_size = volume.ReadSwapped<u32>(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<u32> apploader_size = volume.ReadSwapped<u32>(0x2440 + 0x14, partition); - const std::optional<u32> trailer_size = volume.ReadSwapped<u32>(0x2440 + 0x18, partition); - constexpr u32 header_size = 0x20; - if (!apploader_size || !trailer_size) + const std::optional<u64> 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); } |
