Keep track of GameTDB ID separately from game ID

The difference between Dolphin's game IDs and GameTDB's game IDs
is that GameTDB uses four characters for non-disc titles, whereas
Dolphin uses six characters for all titles.

This fixes:

- TitleDatabase considering Datel discs to be NHL Hitz 2002
- Gecko code downloading not working for discs with IDs starting with P
- Cover downloading mixing up discs with channels (e.g. Mario Kart Wii
  and Mario Kart Channel) and making extra HTTP requests. (Android was
  actually doing a better job at this than DolphinQt!)
This commit is contained in:
JosJuice
2019-02-23 17:49:06 +01:00
parent d27036eb77
commit 8842a0f402
23 changed files with 106 additions and 84 deletions

View File

@ -323,6 +323,20 @@ std::string TMDReader::GetGameID() const
return StringFromFormat("%016" PRIx64, GetTitleId());
}
std::string TMDReader::GetGameTDBID() const
{
const u8* begin = m_bytes.data() + offsetof(TMDHeader, title_id) + 4;
const u8* end = begin + 4;
const bool all_printable =
std::all_of(begin, end, [](char c) { return std::isprint(c, std::locale::classic()); });
if (all_printable)
return std::string(begin, end);
return StringFromFormat("%016" PRIx64, GetTitleId());
}
u16 TMDReader::GetNumContents() const
{
return Common::swap16(m_bytes.data() + offsetof(TMDHeader, num_contents));

View File

@ -205,9 +205,15 @@ public:
// Constructs a 6-character game ID in the format typically used by Dolphin.
// If the 6-character game ID would contain unprintable characters,
// the title ID converted to hexadecimal is returned instead.
// the title ID converted to 16 hexadecimal digits is returned instead.
std::string GetGameID() const;
// Constructs a 4-character game ID in the format typically used by GameTDB.
// If the 4-character game ID would contain unprintable characters,
// the title ID converted to 16 hexadecimal digits is returned instead
// (a format which GameTDB does not actually use).
std::string GetGameTDBID() const;
u16 GetNumContents() const;
bool GetContent(u16 index, Content* content) const;
std::vector<Content> GetContents() const;