GameDatabase: Fix identification of misnamed-exe games

This commit is contained in:
Stenzek
2023-11-29 23:05:27 +10:00
parent 35799aba47
commit 4ac4388b08
5 changed files with 51 additions and 12 deletions

View File

@ -41,6 +41,7 @@ enum : u32
};
static Entry* GetMutableEntry(const std::string_view& serial);
static const Entry* GetEntryForId(const std::string_view& code);
static bool LoadFromCache();
static bool SaveToCache();
@ -149,15 +150,32 @@ std::string GameDatabase::GetSerialForPath(const char* path)
const GameDatabase::Entry* GameDatabase::GetEntryForDisc(CDImage* image)
{
std::string id;
System::GetGameDetailsFromImage(image, &id, nullptr);
System::GameHash hash;
System::GetGameDetailsFromImage(image, &id, &hash);
const Entry* entry = GetEntryForGameDetails(id, hash);
if (entry)
return entry;
Log_WarningPrintf("No entry found for disc '%s'", id.c_str());
return nullptr;
}
const GameDatabase::Entry* GameDatabase::GetEntryForGameDetails(const std::string& id, u64 hash)
{
const Entry* entry;
if (!id.empty())
{
const Entry* entry = GetEntryForId(id);
entry = GetEntryForId(id);
if (entry)
return entry;
}
Log_WarningPrintf("No entry found for disc '%s'", id.c_str());
// some games with invalid serials use the hash
entry = GetEntryForId(System::GetGameHashId(hash));
if (entry)
return entry;
return nullptr;
}

View File

@ -92,7 +92,7 @@ void EnsureLoaded();
void Unload();
const Entry* GetEntryForDisc(CDImage* image);
const Entry* GetEntryForId(const std::string_view& code);
const Entry* GetEntryForGameDetails(const std::string& id, u64 hash);
const Entry* GetEntryForSerial(const std::string_view& serial);
std::string GetSerialForDisc(CDImage* image);
std::string GetSerialForPath(const char* path);

View File

@ -216,7 +216,7 @@ bool GameList::GetDiscListEntry(const std::string& path, Entry* entry)
System::GetGameDetailsFromImage(cdi.get(), &id, &entry->hash);
// try the database first
const GameDatabase::Entry* dentry = GameDatabase::GetEntryForId(id);
const GameDatabase::Entry* dentry = GameDatabase::GetEntryForGameDetails(id, entry->hash);
if (dentry)
{
// pull from database

View File

@ -3346,7 +3346,7 @@ void System::UpdateRunningGame(const char* path, CDImage* image, bool booting)
std::string id;
GetGameDetailsFromImage(image, &id, &s_running_game_hash);
s_running_game_entry = GameDatabase::GetEntryForId(id);
s_running_game_entry = GameDatabase::GetEntryForGameDetails(id, s_running_game_hash);
if (s_running_game_entry)
{
s_running_game_serial = s_running_game_entry->serial;