mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
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.
This commit is contained in:
@ -40,6 +40,7 @@ VolumeWAD::VolumeWAD(std::unique_ptr<BlobReader> reader) : m_reader(std::move(re
|
||||
m_ticket_size = m_reader->ReadSwapped<u32>(0x10).value_or(0);
|
||||
m_tmd_size = m_reader->ReadSwapped<u32>(0x14).value_or(0);
|
||||
m_data_size = m_reader->ReadSwapped<u32>(0x18).value_or(0);
|
||||
m_opening_bnr_size = m_reader->ReadSwapped<u32>(0x1C).value_or(0);
|
||||
|
||||
m_cert_chain_offset = Common::AlignUp(m_hdr_size, 0x40);
|
||||
m_ticket_offset = m_cert_chain_offset + Common::AlignUp(m_cert_chain_size, 0x40);
|
||||
@ -342,4 +343,22 @@ const BlobReader& VolumeWAD::GetBlobReader() const
|
||||
return *m_reader;
|
||||
}
|
||||
|
||||
std::array<u8, 20> VolumeWAD::GetSyncHash() const
|
||||
{
|
||||
// We can skip hashing the contents since the TMD contains hashes of the contents.
|
||||
// We specifically don't hash the ticket, since its console ID can differ without any problems.
|
||||
|
||||
mbedtls_sha1_context context;
|
||||
mbedtls_sha1_init(&context);
|
||||
mbedtls_sha1_starts_ret(&context);
|
||||
|
||||
AddTMDToSyncHash(&context, PARTITION_NONE);
|
||||
|
||||
ReadAndAddToSyncHash(&context, m_opening_bnr_offset, m_opening_bnr_size, PARTITION_NONE);
|
||||
|
||||
std::array<u8, 20> hash;
|
||||
mbedtls_sha1_finish_ret(&context, hash.data());
|
||||
return hash;
|
||||
}
|
||||
|
||||
} // namespace DiscIO
|
||||
|
Reference in New Issue
Block a user