diff --git a/out/boot.dol b/out/boot.dol index 6e4095cb..a3635f07 100644 Binary files a/out/boot.dol and b/out/boot.dol differ diff --git a/source/config/config.cpp b/source/config/config.cpp index 4fe729ec..62fcc334 100644 --- a/source/config/config.cpp +++ b/source/config/config.cpp @@ -165,7 +165,7 @@ bool Config::load(const char *filename) if (!file.bad() && !file.fail()) { line = trimEnd(line); - if (line.empty() || line[0] == '#') continue; + if (line.empty() || line[0] == '#' || line[0] == '\0') continue; if (line[0] == '[') { string::size_type i = line.find_first_of(']'); diff --git a/source/list/ListGenerator.cpp b/source/list/ListGenerator.cpp index 05da621c..43591454 100644 --- a/source/list/ListGenerator.cpp +++ b/source/list/ListGenerator.cpp @@ -79,21 +79,26 @@ static void AddISO(const char *GameID, const char *GameTitle, const char *GamePa if(GameID != NULL) strncpy(ListElement.id, GameID, 6); if(GamePath != NULL) strncpy(ListElement.path, GamePath, sizeof(ListElement.path) - 1); ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, GameColor).intVal(); - const char *CustomTitle = CustomTitles.getString("TITLES", ListElement.id).c_str(); + char CustomTitle[64]; + memset(CustomTitle, 0, sizeof(CustomTitle)); + strncpy(CustomTitle, CustomTitles.getString("TITLES", ListElement.id).c_str(), 63); + const char *gameTDB_Title = NULL; if(gameTDB.IsLoaded()) { if(ListElement.casecolor == GameColor) ListElement.casecolor = gameTDB.GetCaseColor(ListElement.id); ListElement.wifi = gameTDB.GetWifiPlayers(ListElement.id); ListElement.players = gameTDB.GetPlayers(ListElement.id); - if(CustomTitle == NULL || CustomTitle[0] == '\0') - gameTDB.GetTitle(ListElement.id, CustomTitle); + if(strlen(CustomTitle) == 0) + gameTDB.GetTitle(ListElement.id, gameTDB_Title); } if(!ValidColor(ListElement.casecolor)) ListElement.casecolor = CoverFlow.InternalCoverColor(ListElement.id, GameColor); - if(CustomTitle != NULL && CustomTitle[0] != '\0') + if(strlen(CustomTitle) > 0) mbstowcs(ListElement.title, CustomTitle, 63); + else if(gameTDB_Title != NULL && gameTDB_Title[0] != '\0') + mbstowcs(ListElement.title, gameTDB_Title, 63); else if(GameTitle != NULL) mbstowcs(ListElement.title, GameTitle, 63); Asciify(ListElement.title); @@ -183,8 +188,10 @@ static void Create_Plugin_List(char *FullPath) char PluginMagicWord[9]; memset(PluginMagicWord, 0, sizeof(PluginMagicWord)); strncpy(PluginMagicWord, fmt("%08x", m_cacheList.Magic), 8); - const char *CustomTitle = CustomTitles.getString(PluginMagicWord, FolderTitle).c_str(); - if(CustomTitle != NULL && CustomTitle[0] != '\0') + char CustomTitle[64]; + memset(CustomTitle, 0, sizeof(CustomTitle)); + strncpy(CustomTitle, CustomTitles.getString(PluginMagicWord, FolderTitle).c_str(), 63); + if(strlen(CustomTitle) > 0) mbstowcs(ListElement.title, CustomTitle, 63); else mbstowcs(ListElement.title, FolderTitle, 63); @@ -236,18 +243,23 @@ static void Create_Channel_List(bool realNAND) else strncpy(ListElement.id, chan->id, 4); ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, 0xFFFFFF).intVal(); - const char *CustomTitle = CustomTitles.getString("TITLES", ListElement.id).c_str(); + char CustomTitle[64]; + memset(CustomTitle, 0, sizeof(CustomTitle)); + strncpy(CustomTitle, CustomTitles.getString("TITLES", ListElement.id).c_str(), 63); + const char *gameTDB_Title = NULL; if(gameTDB.IsLoaded()) { if(ListElement.casecolor == 0xFFFFFF) ListElement.casecolor = gameTDB.GetCaseColor(ListElement.id); ListElement.wifi = gameTDB.GetWifiPlayers(ListElement.id); ListElement.players = gameTDB.GetPlayers(ListElement.id); - if(CustomTitle == NULL || CustomTitle[0] == '\0') - gameTDB.GetTitle(ListElement.id, CustomTitle); + if(strlen(CustomTitle) == 0) + gameTDB.GetTitle(ListElement.id, gameTDB_Title); } - if(CustomTitle != NULL && CustomTitle[0] != '\0') + if(strlen(CustomTitle) > 0) mbstowcs(ListElement.title, CustomTitle, 63); + else if(gameTDB_Title != NULL && gameTDB_Title[0] != '\0') + mbstowcs(ListElement.title, gameTDB_Title, 63); else wcsncpy(ListElement.title, chan->name, 64); if(realNAND) diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 21d8fe71..bdf07e33 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -54,6 +54,7 @@ private: u8 enabledPluginsCount; u8 m_catStartPage; u8 m_max_categories; + char single_sourcebtn[16]; bool m_clearCats; bool m_newGame; bool show_mem; diff --git a/source/menu/menu_download.cpp b/source/menu/menu_download.cpp index 05e565d6..c3509498 100644 --- a/source/menu/menu_download.cpp +++ b/source/menu/menu_download.cpp @@ -434,8 +434,7 @@ int CMenu::_initNetwork() int CMenu::_coverDownloader(bool missingOnly) { - vector coverList; - //vector pluginCoverList; + vector coverIDList; int count = 0, countFlat = 0; float listWeight = missingOnly ? 0.125f : 0.f; // 1/8 of the progress bar for testing the PNGs we already have @@ -467,53 +466,42 @@ int CMenu::_coverDownloader(bool missingOnly) c_gameTDB.OpenFile(fmt("%s/wiitdb.xml", m_settingsDir.c_str())); c_gameTDB.SetLanguageCode(m_curLanguage.c_str()); } - - //Config m_checksums; - //m_checksums.load(fmt("%s/%s", m_settingsDir.c_str(), PLUGIN_CRCS_FILENAME)); - + char path[256]; + char id[7]; + + /* create list of cover ID's that need downloading */ if (m_coverDLGameId.empty()) { - coverList.reserve(m_gameList.size()); + coverIDList.reserve(m_gameList.size()); for (u32 i = 0; i < m_gameList.size() && !m_thrdStop; ++i) { LWP_MutexLock(m_mutex); _setThrdMsg(_t("dlmsg7", L"Listing covers to download..."), listWeight * (float)step / (float)nbSteps); LWP_MutexUnlock(m_mutex); ++step; - char *path = NULL; - const char *id = NULL; - if(m_gameList[i].type == TYPE_PLUGIN) - { + + memset(path, 0, sizeof(path)); + memset(id, 0, sizeof(id)); + if(m_gameList[i].type == TYPE_PLUGIN || m_gameList[i].type == TYPE_HOMEBREW) continue; - /* char gamePath[256]; - if(strchr(m_gameList[i].path, '/') != NULL) - strncpy(gamePath, strrchr(m_gameList[i].path, '/') + 1, sizeof(gamePath)); - else - strncpy(gamePath, m_gameList[i].path, sizeof(gamePath)); - path = fmt_malloc("%s/%s.png", m_boxPicDir.c_str(), gamePath); - id = path;*/ - } else { - path = fmt_malloc("%s/%s.png", m_boxPicDir.c_str(), m_gameList[i].id); - id = m_gameList[i].id; + strncpy(id, m_gameList[i].id, 6); + strncpy(path, fmt("%s/%s.png", m_boxPicDir.c_str(), id), 255); } - if(!missingOnly || (id != NULL && !CoverFlow.fullCoverCached(id) && path != NULL && !checkPNGFile(path))) + if(!missingOnly || (strlen(id) > 0 && !CoverFlow.fullCoverCached(id) && strlen(path) > 0 && !checkPNGFile(path))) { - //if(m_gameList[i].type == TYPE_PLUGIN) - // pluginCoverList.push_back(m_gameList[i]); - if(id != NULL) - coverList.push_back(id); + if(strlen(id) > 0) + coverIDList.push_back(id); } - if(path != NULL) - MEM2_free(path); - path = NULL; } } else - coverList.push_back(m_coverDLGameId); + coverIDList.push_back(m_coverDLGameId); - u32 n = coverList.size(); + u32 n = coverIDList.size(); + + /* initialize network connection */ if (n > 0 && !m_thrdStop) { step = 0; @@ -532,30 +520,33 @@ int CMenu::_coverDownloader(bool missingOnly) } m_thrdStepLen = dlWeight / (float)nbSteps; + /* download covers in the list */ Config m_newID; m_newID.load(fmt("%s/newid.ini", m_settingsDir.c_str())); - m_newID.setString("CHANNELS", "WFSF", "DWFA"); u32 CoverType = 0; - for(u32 i = 0; i < coverList.size() && !m_thrdStop; ++i) + for(u32 i = 0; i < coverIDList.size() && !m_thrdStop; ++i) { + string coverID = coverIDList[i]; string url; - const char *domain = "NEWID"; bool success = false; bool original = true; bool custom = false; int c_altCase = 0; - const string &newID = m_newID.getString(domain, coverList[i], coverList[i]); - - if(!newID.empty() && strncasecmp(newID.c_str(), coverList[i].c_str(), coverList[i].length()) == 0) - m_newID.remove(domain, coverList[i]); - else if(!newID.empty()) + if(m_newID.loaded()) { - gprintf("old id = %s\nnew id = %s\n", coverList[i].c_str(), newID.c_str()); + const string &newID = m_newID.getString("NEWID", coverID, coverID); + if(!newID.empty() && strncasecmp(newID.c_str(), coverID.c_str(), coverID.length()) == 0) + m_newID.remove("NEWID", coverID); + else if(!newID.empty()) + { + gprintf("old id = %s\nnew id = %s\n", coverID.c_str(), newID.c_str()); + coverID = newID; + } } - for( int p = 0; p < 4; ++p ) + for(int p = 0; p < 4; ++p) { switch(p) { @@ -573,22 +564,22 @@ int CMenu::_coverDownloader(bool missingOnly) break; } - switch( CoverType ) + switch(CoverType) { case BOX: - if( m_downloadPrioVal&C_TYPE_ONOR ) + if(m_downloadPrioVal & C_TYPE_ONOR) original = false; - if (!success && !m_thrdStop && original) + if(!success && !m_thrdStop && original) { - char *path = fmt_malloc("%s/%s.png", m_boxPicDir.c_str(), coverList[i].c_str()); - if(path != NULL && !checkPNGFile(path)) + memset(path, 0, sizeof(path)); + strncpy(path, fmt("%s/%s.png", m_boxPicDir.c_str(), coverID.c_str()), 255); + + /* if cover png doesn't already exist download it */ + if(strlen(path) > 0 && !checkPNGFile(path)) { - for (u32 j = 0; !success && j < fmtURLBox.size() && !m_thrdStop; ++j) + for(u32 j = 0; !success && j < fmtURLBox.size() && !m_thrdStop; ++j) { - /*if(pluginCoverList.size() && pluginCoverList[i].type == TYPE_PLUGIN) - url = m_plugin.GenerateCoverLink(pluginCoverList[i], fmtURLBox[j], m_checksums); - else*/ - url = makeURL(fmtURLBox[j], newID, countryCode(newID)); + url = makeURL(fmtURLBox[j], coverID, countryCode(coverID)); if (j == 0) ++step; m_thrdStep = listWeight + dlWeight * (float)step / (float)nbSteps; LWP_MutexLock(m_mutex); @@ -596,96 +587,94 @@ int CMenu::_coverDownloader(bool missingOnly) LWP_MutexUnlock(m_mutex); download = downloadfile(buffer, bufferSize, url.c_str(), CMenu::_downloadProgress, this); - for( int o = 0; o < 12; ++o ) + for(int o = 0; o < 12; ++o) { bool tdl = false; if(download.data != NULL && download.size > 0 && checkPNGBuf(download.data)) break; - //if(pluginCoverList.size() && pluginCoverList[i].type == TYPE_PLUGIN) - // break; switch( o ) { case EN: - if(( newID[3] == 'E' || newID[3] == 'X' || newID[3] == 'Y' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN ) + if((coverID[3] == 'E' || coverID[3] == 'X' || coverID[3] == 'Y' || coverID[3] == 'P') && m_downloadPrioVal & C_TYPE_EN) { - url = makeURL(fmtURLBox[j], newID, "EN"); + url = makeURL(fmtURLBox[j], coverID, "EN"); tdl = true; } break; case JA: - if(newID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA) + if(coverID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA) { - url = makeURL(fmtURLBox[j], newID, "JA"); + url = makeURL(fmtURLBox[j], coverID, "JA"); tdl = true; } break; case FR: - if((newID[3] == 'F' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR) + if((coverID[3] == 'F' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR) { - url = makeURL(fmtURLBox[j], newID, "FR"); + url = makeURL(fmtURLBox[j], coverID, "FR"); tdl = true; } break; case DE: - if((newID[3] == 'D' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE) + if((coverID[3] == 'D' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE) { - url = makeURL(fmtURLBox[j], newID, "DE"); + url = makeURL(fmtURLBox[j], coverID, "DE"); tdl = true; } break; case ES: - if((newID[3] == 'S' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES) + if((coverID[3] == 'S' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES) { - url = makeURL(fmtURLBox[j], newID, "ES"); + url = makeURL(fmtURLBox[j], coverID, "ES"); tdl = true; } break; case IT: - if((newID[3] == 'I' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT) + if((coverID[3] == 'I' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT) { - url = makeURL(fmtURLBox[j], newID, "IT"); + url = makeURL(fmtURLBox[j], coverID, "IT"); tdl = true; } break; case NL: - if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL) + if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL) { - url = makeURL(fmtURLBox[j], newID, "NL"); + url = makeURL(fmtURLBox[j], coverID, "NL"); tdl = true; } break; case PT: - if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT) + if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT) { - url = makeURL(fmtURLBox[j], newID, "PT"); + url = makeURL(fmtURLBox[j], coverID, "PT"); tdl = true; } break; case RU: - if((newID[3] == 'R' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU) + if((coverID[3] == 'R' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU) { - url = makeURL(fmtURLBox[j], newID, "RU"); + url = makeURL(fmtURLBox[j], coverID, "RU"); tdl = true; } break; case KO: - if(newID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO) + if(coverID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO) { - url = makeURL(fmtURLBox[j], newID, "KO"); + url = makeURL(fmtURLBox[j], coverID, "KO"); tdl = true; } break; case AU: - if(newID[3] == 'W' && m_downloadPrioVal&C_TYPE_ZHCN) + if(coverID[3] == 'W' && m_downloadPrioVal&C_TYPE_ZHCN) { - url = makeURL(fmtURLBox[j], newID, "ZH"); + url = makeURL(fmtURLBox[j], coverID, "ZH"); tdl = true; } break; case ZHCN: break; } - if ( tdl ) + if(tdl) { LWP_MutexLock(m_mutex); _setThrdMsg(wfmt(_fmt("dlmsg3", L"Downloading from %s"), url.c_str()), m_thrdStep); @@ -705,35 +694,31 @@ int CMenu::_coverDownloader(bool missingOnly) fsop_WriteFile(path, download.data, download.size); } LWP_MutexLock(m_mutex); - _setThrdMsg(wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverList[i].c_str()).c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps); + _setThrdMsg(wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str()).c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps); LWP_MutexUnlock(m_mutex); - if (CoverFlow.preCacheCover(coverList[i].c_str(), download.data, true)) + if(CoverFlow.preCacheCover(coverID.c_str(), download.data, true)) { ++count; success = true; } } } - if(path != NULL) - MEM2_free(path); - path = NULL; } break; case CBOX: if( m_downloadPrioVal&C_TYPE_ONCU ) custom = true; - c_altCase = c_gameTDB.GetCaseVersions( coverList[i].c_str() ); + c_altCase = c_gameTDB.GetCaseVersions( coverID.c_str() ); if(!success && !m_thrdStop && c_gameTDB.IsLoaded() && c_altCase > 1 && custom) { - char *path = fmt_malloc("%s/%s.png", m_boxPicDir.c_str(), coverList[i].c_str()); - if(path != NULL && !checkPNGFile(path)) + memset(path, 0, sizeof(path)); + strncpy(path, fmt("%s/%s.png", m_boxPicDir.c_str(), coverID.c_str()), 255); + + if(strlen(path) > 0 && !checkPNGFile(path)) { for (u32 j = 0; !success && j < fmtURLCBox.size() && !m_thrdStop; ++j) { - /*if(pluginCoverList.size() && pluginCoverList[i].type == TYPE_PLUGIN) - url = m_plugin.GenerateCoverLink(pluginCoverList[i], fmtURLCBox[j], m_checksums); - else*/ - url = makeURL(fmtURLCBox[j], newID, countryCode(newID)); + url = makeURL(fmtURLCBox[j], coverID, countryCode(coverID)); if (j == 0) ++step; m_thrdStep = listWeight + dlWeight * (float)step / (float)nbSteps; LWP_MutexLock(m_mutex); @@ -745,84 +730,82 @@ int CMenu::_coverDownloader(bool missingOnly) bool tdl = false; if(download.data != NULL && download.size > 0 && checkPNGBuf(download.data)) break; - //if(pluginCoverList.size() && pluginCoverList[i].type == TYPE_PLUGIN) - // break; switch( o ) { case EN: - if(( newID[3] == 'E' || newID[3] == 'X' || newID[3] == 'Y' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN ) + if(( coverID[3] == 'E' || coverID[3] == 'X' || coverID[3] == 'Y' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN ) { - url = makeURL(fmtURLCBox[j], newID, "EN"); + url = makeURL(fmtURLCBox[j], coverID, "EN"); tdl = true; } break; case JA: - if(newID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA) + if(coverID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA) { - url = makeURL(fmtURLCBox[j], newID, "JA"); + url = makeURL(fmtURLCBox[j], coverID, "JA"); tdl = true; } break; case FR: - if((newID[3] == 'F' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR) + if((coverID[3] == 'F' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR) { - url = makeURL(fmtURLCBox[j], newID, "FR"); + url = makeURL(fmtURLCBox[j], coverID, "FR"); tdl = true; } break; case DE: - if((newID[3] == 'D' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE) + if((coverID[3] == 'D' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE) { - url = makeURL(fmtURLCBox[j], newID, "DE"); + url = makeURL(fmtURLCBox[j], coverID, "DE"); tdl = true; } break; case ES: - if((newID[3] == 'S' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES) + if((coverID[3] == 'S' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES) { - url = makeURL(fmtURLCBox[j], newID, "ES"); + url = makeURL(fmtURLCBox[j], coverID, "ES"); tdl = true; } break; case IT: - if((newID[3] == 'I' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT) + if((coverID[3] == 'I' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT) { - url = makeURL(fmtURLCBox[j], newID, "IT"); + url = makeURL(fmtURLCBox[j], coverID, "IT"); tdl = true; } break; case NL: - if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL) + if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL) { - url = makeURL(fmtURLCBox[j], newID, "NL"); + url = makeURL(fmtURLCBox[j], coverID, "NL"); tdl = true; } break; case PT: - if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT) + if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT) { - url = makeURL(fmtURLCBox[j], newID, "PT"); + url = makeURL(fmtURLCBox[j], coverID, "PT"); tdl = true; } break; case RU: - if((newID[3] == 'R' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU) + if((coverID[3] == 'R' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU) { - url = makeURL(fmtURLCBox[j], newID, "RU"); + url = makeURL(fmtURLCBox[j], coverID, "RU"); tdl = true; } break; case KO: - if(newID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO) + if(coverID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO) { - url = makeURL(fmtURLCBox[j], newID, "KO"); + url = makeURL(fmtURLCBox[j], coverID, "KO"); tdl = true; } break; case AU: - if(newID[3] == 'W' && m_downloadPrioVal&C_TYPE_ZHCN) + if(coverID[3] == 'W' && m_downloadPrioVal&C_TYPE_ZHCN) { - url = makeURL(fmtURLCBox[j], newID, "ZH"); + url = makeURL(fmtURLCBox[j], coverID, "ZH"); tdl = true; } break; @@ -850,18 +833,15 @@ int CMenu::_coverDownloader(bool missingOnly) fsop_WriteFile(path, download.data, download.size); } LWP_MutexLock(m_mutex); - _setThrdMsg(wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverList[i].c_str()).c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps); + _setThrdMsg(wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str()).c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps); LWP_MutexUnlock(m_mutex); - if (CoverFlow.preCacheCover(coverList[i].c_str(), download.data, true)) + if (CoverFlow.preCacheCover(coverID.c_str(), download.data, true)) { ++count; success = true; } } } - if(path != NULL) - MEM2_free(path); - path = NULL; } break; case FLAT: @@ -869,17 +849,16 @@ int CMenu::_coverDownloader(bool missingOnly) original = false; if(!success && !m_thrdStop && original) { - char *path = fmt_malloc("%s/%s.png", m_picDir.c_str(), coverList[i].c_str()); - if(path != NULL && !checkPNGFile(path)) + memset(path, 0, sizeof(path)); + strncpy(path, fmt("%s/%s.png", m_picDir.c_str(), coverID.c_str()), 255); + + if(strlen(path) > 0 && !checkPNGFile(path)) { // Try to get the front cover if (m_thrdStop) break; for (u32 j = 0; !success && j < fmtURLFlat.size() && !m_thrdStop; ++j) { - /*if(pluginCoverList.size() && pluginCoverList[i].type == TYPE_PLUGIN) - url = m_plugin.GenerateCoverLink(pluginCoverList[i], fmtURLFlat[j], m_checksums); - else*/ - url = makeURL(fmtURLFlat[j], newID, countryCode(newID)); + url = makeURL(fmtURLFlat[j], coverID, countryCode(coverID)); LWP_MutexLock(m_mutex); _setThrdMsg(wfmt(_fmt("dlmsg8", L"Full cover not found. Downloading from %s"), url.c_str()), listWeight + dlWeight * (float)step / (float)nbSteps); LWP_MutexUnlock(m_mutex); @@ -890,84 +869,82 @@ int CMenu::_coverDownloader(bool missingOnly) bool tdl = false; if(download.data != NULL && download.size > 0 && checkPNGBuf(download.data)) break; - //if(pluginCoverList.size() && pluginCoverList[i].type == TYPE_PLUGIN) - // break; switch( o ) { case EN: - if(( newID[3] == 'E' || newID[3] == 'X' || newID[3] == 'Y' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN ) + if(( coverID[3] == 'E' || coverID[3] == 'X' || coverID[3] == 'Y' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN ) { - url = makeURL(fmtURLFlat[j], newID, "EN"); + url = makeURL(fmtURLFlat[j], coverID, "EN"); tdl = true; } break; case JA: - if(newID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA) + if(coverID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA) { - url = makeURL(fmtURLFlat[j], newID, "JA"); + url = makeURL(fmtURLFlat[j], coverID, "JA"); tdl = true; } break; case FR: - if((newID[3] == 'F' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR) + if((coverID[3] == 'F' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR) { - url = makeURL(fmtURLFlat[j], newID, "FR"); + url = makeURL(fmtURLFlat[j], coverID, "FR"); tdl = true; } break; case DE: - if((newID[3] == 'D' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE) + if((coverID[3] == 'D' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE) { - url = makeURL(fmtURLFlat[j], newID, "DE"); + url = makeURL(fmtURLFlat[j], coverID, "DE"); tdl = true; } break; case ES: - if((newID[3] == 'S' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES) + if((coverID[3] == 'S' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES) { - url = makeURL(fmtURLFlat[j], newID, "ES"); + url = makeURL(fmtURLFlat[j], coverID, "ES"); tdl = true; } break; case IT: - if((newID[3] == 'I' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT) + if((coverID[3] == 'I' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT) { - url = makeURL(fmtURLFlat[j], newID, "IT"); + url = makeURL(fmtURLFlat[j], coverID, "IT"); tdl = true; } break; case NL: - if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL) + if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL) { - url = makeURL(fmtURLFlat[j], newID, "NL"); + url = makeURL(fmtURLFlat[j], coverID, "NL"); tdl = true; } break; case PT: - if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT) + if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT) { - url = makeURL(fmtURLFlat[j], newID, "PT"); + url = makeURL(fmtURLFlat[j], coverID, "PT"); tdl = true; } break; case RU: - if((newID[3] == 'R' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU) + if((coverID[3] == 'R' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU) { - url = makeURL(fmtURLFlat[j], newID, "RU"); + url = makeURL(fmtURLFlat[j], coverID, "RU"); tdl = true; } break; case KO: - if(newID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO) + if(coverID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO) { - url = makeURL(fmtURLFlat[j], newID, "KO"); + url = makeURL(fmtURLFlat[j], coverID, "KO"); tdl = true; } break; case AU: - if(newID[3] == 'W' && m_downloadPrioVal&C_TYPE_ZHCN) + if(coverID[3] == 'W' && m_downloadPrioVal&C_TYPE_ZHCN) { - url = makeURL(fmtURLFlat[j], newID, "ZH"); + url = makeURL(fmtURLFlat[j], coverID, "ZH"); tdl = true; } break; @@ -994,18 +971,15 @@ int CMenu::_coverDownloader(bool missingOnly) fsop_WriteFile(path, download.data, download.size); } LWP_MutexLock(m_mutex); - _setThrdMsg(wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverList[i].c_str()).c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps); + _setThrdMsg(wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str()).c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps); LWP_MutexUnlock(m_mutex); - if (CoverFlow.preCacheCover(coverList[i].c_str(), download.data, false)) + if (CoverFlow.preCacheCover(coverID.c_str(), download.data, false)) { ++countFlat; success = true; } } } - if(path != NULL) - MEM2_free(path); - path = NULL; } break; case CFLAT: @@ -1013,14 +987,16 @@ int CMenu::_coverDownloader(bool missingOnly) custom = true; if(!success && !m_thrdStop && c_gameTDB.IsLoaded() && c_altCase > 1 && custom) { - char *path = fmt_malloc("%s/%s.png", m_picDir.c_str(), coverList[i].c_str()); - if(path != NULL && !checkPNGFile(path)) + memset(path, 0, sizeof(path)); + strncpy(path, fmt("%s/%s.png", m_picDir.c_str(), coverID.c_str()), 255); + + if(strlen(path) > 0 && !checkPNGFile(path)) { // Try to get the front cover if (m_thrdStop) break; for (u32 j = 0; !success && j < fmtURLCFlat.size() && !m_thrdStop; ++j) { - url = makeURL(fmtURLCFlat[j], newID, countryCode(newID)); + url = makeURL(fmtURLCFlat[j], coverID, countryCode(coverID)); LWP_MutexLock(m_mutex); _setThrdMsg(wfmt(_fmt("dlmsg8", L"Full cover not found. Downloading from %s"), url.c_str()), listWeight + dlWeight * (float)step / (float)nbSteps); LWP_MutexUnlock(m_mutex); @@ -1035,79 +1011,79 @@ int CMenu::_coverDownloader(bool missingOnly) switch( o ) { case EN: - if(( newID[3] == 'E' || newID[3] == 'X' || newID[3] == 'Y' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN ) + if(( coverID[3] == 'E' || coverID[3] == 'X' || coverID[3] == 'Y' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_EN ) { - url = makeURL(fmtURLCFlat[j], newID, "EN"); + url = makeURL(fmtURLCFlat[j], coverID, "EN"); tdl = true; } break; case JA: - if(newID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA) + if(coverID[3] == 'J' && m_downloadPrioVal&C_TYPE_JA) { - url = makeURL(fmtURLCFlat[j], newID, "JA"); + url = makeURL(fmtURLCFlat[j], coverID, "JA"); tdl = true; } break; case FR: - if((newID[3] == 'F' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR) + if((coverID[3] == 'F' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_FR) { - url = makeURL(fmtURLCFlat[j], newID, "FR"); + url = makeURL(fmtURLCFlat[j], coverID, "FR"); tdl = true; } break; case DE: - if((newID[3] == 'D' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE) + if((coverID[3] == 'D' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_DE) { - url = makeURL(fmtURLCFlat[j], newID, "DE"); + url = makeURL(fmtURLCFlat[j], coverID, "DE"); tdl = true; } break; case ES: - if((newID[3] == 'S' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES) + if((coverID[3] == 'S' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_ES) { - url = makeURL(fmtURLCFlat[j], newID, "ES"); + url = makeURL(fmtURLCFlat[j], coverID, "ES"); tdl = true; } break; case IT: - if((newID[3] == 'I' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT) + if((coverID[3] == 'I' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_IT) { - url = makeURL(fmtURLCFlat[j], newID, "IT"); + url = makeURL(fmtURLCFlat[j], coverID, "IT"); tdl = true; } break; case NL: - if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL) + if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_NL) { - url = makeURL(fmtURLCFlat[j], newID, "NL"); + url = makeURL(fmtURLCFlat[j], coverID, "NL"); tdl = true; } break; case PT: - if(newID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT) + if(coverID[3] == 'P' && m_downloadPrioVal&C_TYPE_PT) { - url = makeURL(fmtURLCFlat[j], newID, "PT"); + url = makeURL(fmtURLCFlat[j], coverID, "PT"); tdl = true; } break; case RU: - if((newID[3] == 'R' || newID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU) + if((coverID[3] == 'R' || coverID[3] == 'P') && m_downloadPrioVal&C_TYPE_RU) { - url = makeURL(fmtURLCFlat[j], newID, "RU"); + url = makeURL(fmtURLCFlat[j], coverID, "RU"); tdl = true; } break; case KO: - if(newID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO) + if(coverID[3] == 'K' && m_downloadPrioVal&C_TYPE_KO) { - url = makeURL(fmtURLCFlat[j], newID, "KO"); + url = makeURL(fmtURLCFlat[j], coverID, "KO"); tdl = true; } break; case AU: - if((newID[3] == 'P' || newID[3] == 'Y' || newID[3] == 'X') && m_downloadPrioVal&C_TYPE_ZHCN) + if((coverID[3] == 'P' || coverID[3] == 'Y' || coverID[3] == 'X') && m_downloadPrioVal&C_TYPE_ZHCN) { - url = makeURL(fmtURLCFlat[j], newID, "ZH"); + url = makeURL(fmtURLCFlat[j], coverID, "ZH"); tdl = true; } break; @@ -1134,18 +1110,15 @@ int CMenu::_coverDownloader(bool missingOnly) fsop_WriteFile(path, download.data, download.size); } LWP_MutexLock(m_mutex); - _setThrdMsg(wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverList[i].c_str()).c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps); + _setThrdMsg(wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str()).c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps); LWP_MutexUnlock(m_mutex); - if (CoverFlow.preCacheCover(coverList[i].c_str(), download.data, false)) + if (CoverFlow.preCacheCover(coverID.c_str(), download.data, false)) { ++countFlat; success = true; } } } - if(path != NULL) - MEM2_free(path); - path = NULL; } break; } @@ -1154,9 +1127,9 @@ int CMenu::_coverDownloader(bool missingOnly) } if(c_gameTDB.IsLoaded()) c_gameTDB.CloseFile(); - coverList.clear(); - //m_checksums.unload(); - m_newID.unload(); + coverIDList.clear(); + if(m_newID.loaded()) + m_newID.unload(); } LWP_MutexLock(m_mutex); if (countFlat == 0) @@ -1165,8 +1138,7 @@ int CMenu::_coverDownloader(bool missingOnly) _setThrdMsg(wfmt(_fmt("dlmsg9", L"%i/%i files downloaded. %i are front covers only."), count + countFlat, n, countFlat), 1.f); LWP_MutexUnlock(m_mutex); m_thrdWorking = false; - //pluginCoverList.clear(); - free(buffer); + MEM2_free(buffer); return 0; } @@ -1184,17 +1156,7 @@ void CMenu::_download(string gameId) m_thrdStop = false; m_thrdMessageAdded = false; - /*if(gameId.size() && CoverFlow.getHdr()->type == TYPE_PLUGIN) - { - char gamePath[256]; - if(strchr(CoverFlow.getHdr()->path, '/') != NULL) - strncpy(gamePath, strrchr(CoverFlow.getHdr()->path, '/') + 1, sizeof(gamePath)); - else - strncpy(gamePath, CoverFlow.getHdr()->path, sizeof(gamePath)); - m_coverDLGameId = gamePath; - } - else*/ - m_coverDLGameId = gameId; + m_coverDLGameId = gameId; while(!m_exit) { @@ -1218,7 +1180,7 @@ void CMenu::_download(string gameId) { if ((m_btnMgr.selected(m_downloadBtnAll) || m_btnMgr.selected(m_downloadBtnMissing) || !gameId.empty()) && !m_thrdWorking) { - m_refreshGameList = true; + m_refreshGameList = true;// bool dlAll = m_btnMgr.selected(m_downloadBtnAll); m_btnMgr.show(m_downloadPBar); m_btnMgr.setProgress(m_downloadPBar, 0.f); diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index 3a1f6424..3c81dc20 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -1055,6 +1055,8 @@ int CMenu::_getCFVersion() return m_cfg.getInt("PLUGIN_CFVERSION", m_plugin.PluginMagicWord, 1); } } + else if(strlen(single_sourcebtn)) + return m_cfg.getInt("PLUGIN_CFVERSION", single_sourcebtn, 1); } return m_cfg.getInt(_domainFromView(), "last_cf_mode", 1); } @@ -1075,6 +1077,11 @@ void CMenu::_setCFVersion(int version) } } } + else if(strlen(single_sourcebtn)) + { + m_cfg.setInt("PLUGIN_CFVERSION", single_sourcebtn, version); + return; + } } m_cfg.setInt(_domainFromView(), "last_cf_mode", version); } diff --git a/source/menu/menu_source.cpp b/source/menu/menu_source.cpp index 5b161e65..998ad2f4 100644 --- a/source/menu/menu_source.cpp +++ b/source/menu/menu_source.cpp @@ -36,6 +36,7 @@ void CMenu::_sourceFlow() else m_cfg.remove(SOURCEFLOW_DOMAIN, "current_item"); + memset(single_sourcebtn, 0, 16); memset(btn_selected, 0, 16); strncpy(btn_selected, fmt("BUTTON_%i", hdr->settings[0]), 15); source = m_source.getString(btn_selected, "source", ""); @@ -67,6 +68,7 @@ void CMenu::_sourceFlow() } else if(source == "allplugins") { + strncpy(single_sourcebtn, btn_selected, 16); m_current_view = COVERFLOW_PLUGIN; for(k = 0; k < m_numPlugins; ++k) m_plugin.SetEnablePlugin(m_cfg, k, 2); /* force enable */ @@ -75,8 +77,10 @@ void CMenu::_sourceFlow() { magicNums.clear(); magicNums = m_source.getStrings(btn_selected, "magic", ','); - if(magicNums.size() > 0 ) + if(magicNums.size() > 0) { + if(magicNums.size() > 1) + strncpy(single_sourcebtn, btn_selected, 16); m_current_view = COVERFLOW_PLUGIN; for(k = 0; k < m_numPlugins; ++k) m_plugin.SetEnablePlugin(m_cfg, k, 1); /* force disable */ @@ -271,8 +275,20 @@ bool CMenu::_Source() } if(selectedBtns == 1) { + memset(single_sourcebtn, 0, 16); memset(btn_selected, 0, 16); strncpy(btn_selected, fmt("BUTTON_%i", sourceBtn), 15); + + source = m_source.getString(btn_selected, "source", ""); + if(source == "allplugins") + strncpy(single_sourcebtn, btn_selected, 16); + else if(source == "plugin") + { + magicNums.clear(); + magicNums = m_source.getStrings(btn_selected, "magic", ','); + if(magicNums.size() > 1) + strncpy(single_sourcebtn, btn_selected, 16); + } _setSrcOptions(); } @@ -329,6 +345,7 @@ bool CMenu::_Source() } if(!m_multisource && i <12) { + memset(single_sourcebtn, 0, 16); exitSource = true; m_catStartPage = 1; if(source == "dml") @@ -359,6 +376,7 @@ bool CMenu::_Source() } else if(source == "allplugins") { + strncpy(single_sourcebtn, btn_selected, 16); m_current_view = COVERFLOW_PLUGIN; for(k = 0; k < m_numPlugins; ++k) m_plugin.SetEnablePlugin(m_cfg, k, 2); /* force enable */ @@ -374,6 +392,8 @@ bool CMenu::_Source() magicNums = m_source.getStrings(btn_selected, "magic", ','); if(magicNums.size() > 0) { + if(magicNums.size() > 1) + strncpy(single_sourcebtn, btn_selected, 16); for(vector::iterator itr = magicNums.begin(); itr != magicNums.end(); itr++) { s8 exist = m_plugin.GetPluginPosition(strtoul(itr->c_str(), NULL, 16));// make sure magic# is valid @@ -562,6 +582,7 @@ void CMenu::_setSrcOptions(void) void CMenu::_initSourceMenu() { + memset(single_sourcebtn, 0, 16); m_use_source = false; themeName = m_cfg.getString("GENERAL", "theme", "default").c_str(); if(!m_source.load(fmt("%s/%s/%s", m_sourceDir.c_str(), themeName, SOURCE_FILENAME))) diff --git a/source/plugin/plugin.cpp b/source/plugin/plugin.cpp index cfff955a..9d797f0f 100644 --- a/source/plugin/plugin.cpp +++ b/source/plugin/plugin.cpp @@ -226,7 +226,9 @@ vector Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 { if(strlen(GameDomain) < 2) break; - const char *GameName = ini.getString(GameDomain, "description").c_str(); + char GameName[64]; + memset(GameName, 0, sizeof(GameName)); + strncpy(GameName, ini.getString(GameDomain, "description").c_str(), 63); if(strlen(GameName) < 2 || strncasecmp(Device, ini.getString(GameDomain, "path").c_str(), 2) != 0) { GameDomain = ini.nextDomain().c_str();