mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
GCMemcardDirectory: Compare GCI files in GetFileNamesForGameID() by their identity instead of their default filename.
This commit is contained in:
parent
4b0312ecf8
commit
1089d3cab6
@ -125,8 +125,7 @@ bool GCMemcardDirectory::LoadGCI(Memcard::GCIFile gci)
|
||||
|
||||
// This is only used by NetPlay but it made sense to put it here to keep the relevant code together
|
||||
std::vector<std::string> GCMemcardDirectory::GetFileNamesForGameID(const std::string& directory,
|
||||
const std::string& game_id,
|
||||
bool card_encoding_is_shift_jis)
|
||||
const std::string& game_id)
|
||||
{
|
||||
std::vector<std::string> filenames;
|
||||
|
||||
@ -134,7 +133,7 @@ std::vector<std::string> GCMemcardDirectory::GetFileNamesForGameID(const std::st
|
||||
if (game_id.length() >= 4 && game_id != "00000000")
|
||||
game_code = Common::swap32(reinterpret_cast<const u8*>(game_id.c_str()));
|
||||
|
||||
std::vector<std::string> loaded_saves;
|
||||
std::vector<Memcard::DEntry> loaded_saves;
|
||||
for (const std::string& file_name : Common::DoFileSearch({directory}, {".gci"}))
|
||||
{
|
||||
File::IOFile gci_file(file_name, "rb");
|
||||
@ -147,9 +146,11 @@ std::vector<std::string> GCMemcardDirectory::GetFileNamesForGameID(const std::st
|
||||
if (!gci_file.ReadBytes(&gci.m_gci_header, Memcard::DENTRY_SIZE))
|
||||
continue;
|
||||
|
||||
const std::string gci_filename =
|
||||
GenerateDefaultGCIFilename(gci.m_gci_header, card_encoding_is_shift_jis);
|
||||
if (std::find(loaded_saves.begin(), loaded_saves.end(), gci_filename) != loaded_saves.end())
|
||||
const auto same_identity_save_it = std::find_if(
|
||||
loaded_saves.begin(), loaded_saves.end(), [&gci](const Memcard::DEntry& entry) {
|
||||
return Memcard::HasSameIdentity(gci.m_gci_header, entry);
|
||||
});
|
||||
if (same_identity_save_it != loaded_saves.end())
|
||||
continue;
|
||||
|
||||
const u16 num_blocks = gci.m_gci_header.m_block_count;
|
||||
@ -169,7 +170,7 @@ std::vector<std::string> GCMemcardDirectory::GetFileNamesForGameID(const std::st
|
||||
|
||||
if (game_code == Common::swap32(gci.m_gci_header.m_gamecode.data()))
|
||||
{
|
||||
loaded_saves.push_back(gci_filename);
|
||||
loaded_saves.push_back(gci.m_gci_header);
|
||||
filenames.push_back(file_name);
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,7 @@ public:
|
||||
GCMemcardDirectory& operator=(GCMemcardDirectory&&) = delete;
|
||||
|
||||
static std::vector<std::string> GetFileNamesForGameID(const std::string& directory,
|
||||
const std::string& game_id,
|
||||
bool card_encoding_is_shift_jis);
|
||||
const std::string& game_id);
|
||||
void FlushToFile();
|
||||
void FlushThread();
|
||||
s32 Read(u32 src_address, s32 length, u8* dest_address) override;
|
||||
|
@ -1734,8 +1734,8 @@ bool NetPlayServer::SyncSaveData(const SaveSyncInfo& sync_info)
|
||||
|
||||
if (File::IsDirectory(path))
|
||||
{
|
||||
std::vector<std::string> files = GCMemcardDirectory::GetFileNamesForGameID(
|
||||
path + DIR_SEP, sync_info.game->GetGameID(), gamecube_region == DiscIO::Region::NTSC_J);
|
||||
std::vector<std::string> files =
|
||||
GCMemcardDirectory::GetFileNamesForGameID(path + DIR_SEP, sync_info.game->GetGameID());
|
||||
|
||||
pac << static_cast<u8>(files.size());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user