mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-30 01:26:49 +01:00
a41166bb37
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.
47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
// Copyright 2020 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <string>
|
|
#include <tuple>
|
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
namespace NetPlay
|
|
{
|
|
struct SyncIdentifier
|
|
{
|
|
u64 dol_elf_size;
|
|
std::string game_id;
|
|
u16 revision;
|
|
u8 disc_number;
|
|
bool is_datel;
|
|
|
|
// 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.
|
|
std::array<u8, 20> sync_hash;
|
|
|
|
bool operator==(const SyncIdentifier& s) const
|
|
{
|
|
return std::tie(dol_elf_size, game_id, revision, disc_number, is_datel, sync_hash) ==
|
|
std::tie(s.dol_elf_size, s.game_id, s.revision, s.disc_number, s.is_datel, s.sync_hash);
|
|
}
|
|
bool operator!=(const SyncIdentifier& s) const { return !operator==(s); }
|
|
};
|
|
|
|
enum class SyncIdentifierComparison
|
|
{
|
|
SameGame,
|
|
DifferentVersion,
|
|
DifferentGame,
|
|
Unknown,
|
|
};
|
|
|
|
} // namespace NetPlay
|