mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29: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:
@ -12,6 +12,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <mbedtls/sha1.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Swap.h"
|
||||
@ -138,6 +140,13 @@ public:
|
||||
virtual u64 GetRawSize() const = 0;
|
||||
virtual const BlobReader& GetBlobReader() const = 0;
|
||||
|
||||
// This hash is intended to be (but is not guaranteed to be):
|
||||
// 1. Identical for discs with no differences that affect netplay/TAS sync
|
||||
// 2. Different for discs with differences that affect netplay/TAS sync
|
||||
// 3. Much faster than hashing the entire disc
|
||||
// The way the hash is calculated may change with updates to Dolphin.
|
||||
virtual std::array<u8, 20> GetSyncHash() const = 0;
|
||||
|
||||
protected:
|
||||
template <u32 N>
|
||||
std::string DecodeString(const char (&data)[N]) const
|
||||
@ -151,6 +160,10 @@ protected:
|
||||
return CP1252ToUTF8(string);
|
||||
}
|
||||
|
||||
void ReadAndAddToSyncHash(mbedtls_sha1_context* context, u64 offset, u64 length,
|
||||
const Partition& partition) const;
|
||||
void AddTMDToSyncHash(mbedtls_sha1_context* context, const Partition& partition) const;
|
||||
|
||||
virtual u32 GetOffsetShift() const { return 0; }
|
||||
static std::map<Language, std::string> ReadWiiNames(const std::vector<char16_t>& data);
|
||||
|
||||
|
Reference in New Issue
Block a user