From 210aa774d554bb9818d79030bbc26b8eb2c500b2 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 13 Sep 2015 14:17:58 +0200 Subject: DolphinWX: Only read titles.txt once titles.txt is read into a map and passed to the GameListItem constructor, making game list scanning a bit more efficient. ISOPropreties's constructor is changed to take a GameListItem as an argument instead of creating one on its own, because ISOPropreties doesn't have the titles.txt map that the GameListItem constructor wants. --- Source/Core/DolphinWX/ISOFile.cpp | 41 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 30 deletions(-) (limited to 'Source/Core/DolphinWX/ISOFile.cpp') diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index 00f707529b..28051d0fb0 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,7 @@ static std::string GetLanguageString(DiscIO::IVolume::ELanguage language, std::m return ""; } -GameListItem::GameListItem(const std::string& _rFileName) +GameListItem::GameListItem(const std::string& _rFileName, const std::unordered_map& custom_titles) : m_FileName(_rFileName) , m_emu_state(0) , m_FileSize(0) @@ -135,38 +136,18 @@ GameListItem::GameListItem(const std::string& _rFileName) if (!m_has_custom_name) { - // Attempt to load game titles from titles.txt - // http://www.gametdb.com/Wii/Downloads - std::ifstream titlestxt; - OpenFStream(titlestxt, File::GetUserPath(D_LOAD_IDX) + "titles.txt", std::ios::in); + std::string game_id = m_UniqueID; - if (!titlestxt.is_open()) - OpenFStream(titlestxt, File::GetUserPath(D_LOAD_IDX) + "wiitdb.txt", std::ios::in); + // Ignore publisher ID for WAD files + if (m_Platform == DiscIO::IVolume::WII_WAD) + game_id.erase(game_id.size() - 2); - if (titlestxt.is_open() && GetUniqueID().size() >= 4) + auto end = custom_titles.end(); + auto it = custom_titles.find(game_id); + if (it != end) { - while (!titlestxt.eof()) - { - std::string line; - - if (!std::getline(titlestxt, line) && titlestxt.eof()) - break; - - const size_t equals_index = line.find('='); - std::string game_id = m_UniqueID; - - // Ignore publisher ID for WAD files - if (m_Platform == DiscIO::IVolume::WII_WAD) - game_id.erase(game_id.size() - 2); - - if (line.substr(0, equals_index - 1) == game_id) - { - m_custom_name = StripSpaces(line.substr(equals_index + 1)); - m_has_custom_name = true; - break; - } - } - titlestxt.close(); + m_custom_name = it->second; + m_has_custom_name = true; } } } -- cgit v1.2.3