mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -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:
@ -4,11 +4,17 @@
|
||||
|
||||
#include "DiscIO/VolumeDisc.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <mbedtls/sha1.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "DiscIO/DiscExtractor.h"
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/Filesystem.h"
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
@ -90,4 +96,35 @@ bool VolumeDisc::IsNKit() const
|
||||
return ReadSwapped<u32>(0x200, PARTITION_NONE) == NKIT_MAGIC;
|
||||
}
|
||||
|
||||
void VolumeDisc::AddGamePartitionToSyncHash(mbedtls_sha1_context* context) const
|
||||
{
|
||||
const Partition partition = GetGamePartition();
|
||||
|
||||
// All headers at the beginning of the partition, plus the apploader
|
||||
ReadAndAddToSyncHash(context, 0, 0x2440 + GetApploaderSize(*this, partition).value_or(0),
|
||||
partition);
|
||||
|
||||
// Boot DOL (may be missing if this is a Datel disc)
|
||||
const std::optional<u64> dol_offset = GetBootDOLOffset(*this, partition);
|
||||
if (dol_offset)
|
||||
{
|
||||
ReadAndAddToSyncHash(context, *dol_offset,
|
||||
GetBootDOLSize(*this, partition, *dol_offset).value_or(0), partition);
|
||||
}
|
||||
|
||||
// File system
|
||||
const std::optional<u64> fst_offset = GetFSTOffset(*this, partition);
|
||||
if (fst_offset)
|
||||
ReadAndAddToSyncHash(context, *fst_offset, GetFSTSize(*this, partition).value_or(0), partition);
|
||||
|
||||
// opening.bnr (name and banner)
|
||||
const FileSystem* file_system = GetFileSystem(partition);
|
||||
if (file_system)
|
||||
{
|
||||
std::unique_ptr<FileInfo> file_info = file_system->FindFileInfo("opening.bnr");
|
||||
if (file_info && !file_info->IsDirectory())
|
||||
ReadAndAddToSyncHash(context, file_info->GetOffset(), file_info->GetSize(), partition);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace DiscIO
|
||||
|
Reference in New Issue
Block a user