From e4df9ddf827575b92d2d236d930f6a283040b655 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Sat, 21 Apr 2012 17:15:35 +0000 Subject: [PATCH] -added support for gc games extracted with crediars new tool GCReEx for DML v1.0 -changed small thing about plugin loading in code --- source/list/cachedlist.cpp | 2 +- source/list/cachedlist.hpp | 3 ++- source/list/list.cpp | 40 ++++++++++++++++++++++++++++---------- source/list/list.hpp | 2 +- source/menu/menu.cpp | 19 ++++++++++-------- 5 files changed, 45 insertions(+), 21 deletions(-) diff --git a/source/list/cachedlist.cpp b/source/list/cachedlist.cpp index d60d2c43..9016607f 100644 --- a/source/list/cachedlist.cpp +++ b/source/list/cachedlist.cpp @@ -79,7 +79,7 @@ void CachedList::Load(string path, string containing, string m_lastLanguage) gprintf("Calling list to update filelist\n"); safe_vector pathlist; - list.GetPaths(pathlist, containing, path, m_wbfsFS); + list.GetPaths(pathlist, containing, path, m_wbfsFS, update_dml); list.GetHeaders(pathlist, *this, m_settingsDir, m_curLanguage, m_DMLgameDir, m_plugin); path.append("/touch.db"); diff --git a/source/list/cachedlist.hpp b/source/list/cachedlist.hpp index 6b0a1f30..b9eaffc5 100644 --- a/source/list/cachedlist.hpp +++ b/source/list/cachedlist.hpp @@ -64,6 +64,8 @@ class CachedList : public safe_vector void Remove(u32 index) {if(m_loaded) CCache(*this, m_database, index, REMOVE);} /* Remove One */ void SetLanguage(string curLanguage) { m_curLanguage = curLanguage; } + void LoadPluginConfig(const char* name) { m_plugin.load(name); } + void UnloadPluginConfig() {m_plugin.unload(); }; private: string make_db_name(string path); @@ -80,7 +82,6 @@ class CachedList : public safe_vector string m_lastLanguage; string m_discinf; string m_DMLgameDir; -public: Config m_plugin; }; diff --git a/source/list/list.cpp b/source/list/list.cpp index 2534d8bd..2961a2b4 100644 --- a/source/list/list.cpp +++ b/source/list/list.cpp @@ -7,7 +7,7 @@ #include "gc.h" template -void CList::GetPaths(safe_vector &pathlist, string containing, string directory, bool wbfs_fs) +void CList::GetPaths(safe_vector &pathlist, string containing, string directory, bool wbfs_fs, bool dml) { if (!wbfs_fs) { @@ -18,6 +18,7 @@ void CList::GetPaths(safe_vector &pathlist, string containing, string safe_vector compares = stringToVector(containing, '|'); safe_vector temp_pathlist; + bool foundDMLgame; struct dirent *ent; /* Read primary entries */ @@ -49,20 +50,34 @@ void CList::GetPaths(safe_vector &pathlist, string containing, string { dir_itr = opendir((*templist).c_str()); if (!dir_itr) continue; + if(dml) + foundDMLgame = false; /* Read secondary entries */ while((ent = readdir(dir_itr)) != NULL) { - if(ent->d_type != DT_REG) continue; - if (strlen(ent->d_name) < 8) continue; - - for(safe_vector::iterator compare = compares.begin(); compare != compares.end(); compare++) - if (strcasestr(ent->d_name, (*compare).c_str()) != NULL) + if(ent->d_type == DT_REG && strlen(ent->d_name) > 7) + { + for(safe_vector::iterator compare = compares.begin(); compare != compares.end(); compare++) { - //gprintf("Pushing %s to the list.\n", sfmt("%s/%s", (*templist).c_str(), ent->d_name).c_str()); - pathlist.push_back(sfmt("%s/%s", (*templist).c_str(), ent->d_name)); + if (strcasestr(ent->d_name, (*compare).c_str()) != NULL) + { + //gprintf("Pushing %s to the list.\n", sfmt("%s/%s", (*templist).c_str(), ent->d_name).c_str()); + pathlist.push_back(sfmt("%s/%s", (*templist).c_str(), ent->d_name)); + if(dml) + foundDMLgame = true; + break; + } + } + } + else if(dml && foundDMLgame == false) + { + if(strcasestr(ent->d_name, "sys") != NULL) + { + temp_pathlist.push_back(sfmt("%s/%s", (*templist).c_str(), ent->d_name)); break; } + } } closedir(dir_itr); } @@ -129,11 +144,12 @@ void CList::GetHeaders(safe_vector pathlist, safe_vectorPathToDriveType((*itr).c_str())]; - if(strcasecmp(filename, "game.iso") == 0 && strstr((*itr).c_str(), sfmt((strncmp(dml_partition, "sd", 2) != 0) ? DMLgameUSBDir.c_str() : DML_DIR, dml_partition).c_str()) != NULL) + if((strcasecmp(filename, "game.iso") == 0 || strcasecmp(filename, "boot.bin") == 0) && strstr((*itr).c_str(), sfmt((strncmp(dml_partition, "sd", 2) != 0) ? DMLgameUSBDir.c_str() : DML_DIR, dml_partition).c_str()) != NULL) { FILE *fp = fopen((*itr).c_str(), "rb"); if( fp ) @@ -161,6 +177,8 @@ void CList::GetHeaders(safe_vector pathlist, safe_vector::GetHeaders(safe_vector pathlist, safe_vector &pathlist, string containing, string directory, bool wbfs_fs = false); + void GetPaths(safe_vector &pathlist, string containing, string directory, bool wbfs_fs = false, bool dml = false); void GetHeaders(safe_vector pathlist, safe_vector &headerlist, string, string, string, Config &plugin); void GetChannels(safe_vector &headerlist, string, u32, string); private: diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index e269a74a..7c736d88 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -1938,9 +1938,9 @@ bool CMenu::_loadDmlList() gprintf("%s\n", DeviceName[currentPartition]); DeviceHandler::Instance()->Open_WBFS(currentPartition); if(currentPartition != SD) - m_gameList.Load(sfmt(m_DMLgameDir.c_str(), DeviceName[currentPartition]), ".iso", m_cfg.getString("DML", "lastlanguage", "EN").c_str()); + m_gameList.Load(sfmt(m_DMLgameDir.c_str(), DeviceName[currentPartition]), "boot.bin|.iso", m_cfg.getString("DML", "lastlanguage", "EN").c_str()); else - m_gameList.Load(sfmt(DML_DIR, DeviceName[currentPartition]), ".iso", m_cfg.getString("DML", "lastlanguage", "EN").c_str()); + m_gameList.Load(sfmt(DML_DIR, DeviceName[currentPartition]), "boot.bin|.iso", m_cfg.getString("DML", "lastlanguage", "EN").c_str()); m_cfg.setString("DML", "lastlanguage", m_loc.getString(m_curLanguage, "gametdb_code", "EN")); m_cfg.save(); return m_gameList.size() > 0 ? true : false; @@ -1961,6 +1961,7 @@ bool CMenu::_loadEmuList() pdir = opendir(m_pluginsDir.c_str()); safe_vector emuList; + Config m_plugin_cfg; while ((pent = readdir(pdir)) != NULL) { @@ -1970,16 +1971,18 @@ bool CMenu::_loadEmuList() continue; if(strcasestr(pent->d_name, ".ini") != NULL) { - m_gameList.m_plugin.load(fmt("%s/%s", m_pluginsDir.c_str(), pent->d_name)); - if(m_gameList.m_plugin.loaded()) + m_plugin_cfg.load(fmt("%s/%s", m_pluginsDir.c_str(), pent->d_name)); + if(m_plugin_cfg.loaded()) { - m_plugin.AddPlugin(m_gameList.m_plugin); + m_plugin.AddPlugin(m_plugin_cfg); m_gameList.clear(); - if(strcasestr(m_gameList.m_plugin.getString("PLUGIN","romDir","").c_str(), "scummvm.ini") == NULL) + if(strcasestr(m_plugin_cfg.getString("PLUGIN","romDir","").c_str(), "scummvm.ini") == NULL) { - m_gameList.Load(sfmt("%s:/%s", DeviceName[currentPartition], m_gameList.m_plugin.getString("PLUGIN","romDir","").c_str()), m_gameList.m_plugin.getString("PLUGIN","fileTypes","").c_str(), m_cfg.getString("EMULATOR", "lastlanguage", "EN").c_str()); + m_gameList.LoadPluginConfig(fmt("%s/%s", m_pluginsDir.c_str(), pent->d_name)); + m_gameList.Load(sfmt("%s:/%s", DeviceName[currentPartition], m_plugin_cfg.getString("PLUGIN","romDir","").c_str()), m_plugin_cfg.getString("PLUGIN","fileTypes","").c_str(), m_cfg.getString("EMULATOR", "lastlanguage", "EN").c_str()); for(safe_vector::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++) emuList.push_back(*tmp_itr); + m_gameList.UnloadPluginConfig(); } else { @@ -1991,7 +1994,7 @@ bool CMenu::_loadEmuList() emuList.push_back(*tmp_itr); } } - m_gameList.m_plugin.unload(); + m_plugin_cfg.unload(); } } closedir(pdir);