From 4df672d357c487e7c9ef2e72a7db14b8b475bef4 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Fri, 4 May 2012 12:30:43 +0000 Subject: [PATCH] -removed alot of unneeded .c_str() -replaced alot of sfmt with fmt -replaced a few sprintf with snprintf --- source/gc/fileOps.c | 8 ++--- source/gui/coverflow.cpp | 8 ++--- source/gui/fanart.cpp | 12 +++---- source/gui/text.cpp | 5 --- source/gui/text.hpp | 6 ++++ source/list/cachedlist.cpp | 2 +- source/list/list.cpp | 4 +-- source/loader/gc_disc.cpp | 8 ++--- source/menu/menu.cpp | 62 ++++++++++++++++---------------- source/menu/menu_about.cpp | 4 +-- source/menu/menu_categories.cpp | 30 ++++++++-------- source/menu/menu_cftheme.cpp | 12 +++---- source/menu/menu_cheat.cpp | 6 ++-- source/menu/menu_code.cpp | 2 +- source/menu/menu_config4.cpp | 4 +-- source/menu/menu_config_adv.cpp | 6 ++-- source/menu/menu_config_game.cpp | 2 +- source/menu/menu_download.cpp | 6 ++-- source/menu/menu_game.cpp | 14 ++++---- source/menu/menu_gameinfo.cpp | 2 +- source/menu/menu_main.cpp | 16 ++++----- source/menu/menu_nandemu.cpp | 2 +- source/menu/menu_wbfs.cpp | 4 +-- source/plugin/plugin.cpp | 2 +- 24 files changed, 114 insertions(+), 113 deletions(-) diff --git a/source/gc/fileOps.c b/source/gc/fileOps.c index 77fd8778..d1ca3b6f 100644 --- a/source/gc/fileOps.c +++ b/source/gc/fileOps.c @@ -75,7 +75,7 @@ u64 fsop_GetFolderBytes (char *source) if (strcmp (pent->d_name, ".") == 0 || strcmp (pent->d_name, "..") == 0) continue; - sprintf (newSource, "%s/%s", source, pent->d_name); + snprintf(newSource, sizeof(newSource), "%s/%s", source, pent->d_name); // If it is a folder... recurse... if (fsop_DirExist (newSource)) @@ -284,8 +284,8 @@ static bool doCopyFolder (char *source, char *target, progress_callback_t spinne if (strcmp (pent->d_name, ".") == 0 || strcmp (pent->d_name, "..") == 0) continue; - sprintf (newSource, "%s/%s", source, pent->d_name); - sprintf (newTarget, "%s/%s", target, pent->d_name); + snprintf(newSource, sizeof(newSource), "%s/%s", source, pent->d_name); + snprintf(newTarget, sizeof(newTarget), "%s/%s", target, pent->d_name); // If it is a folder... recurse... if (fsop_DirExist(newSource)) @@ -326,7 +326,7 @@ void fsop_deleteFolder(char *source) if (strcmp (pent->d_name, ".") == 0 || strcmp (pent->d_name, "..") == 0) continue; - sprintf (newSource, "%s/%s", source, pent->d_name); + snprintf (newSource, sizeof(newSource), "%s/%s", source, pent->d_name); // If it is a folder... recurse... if (fsop_DirExist(newSource)) diff --git a/source/gui/coverflow.cpp b/source/gui/coverflow.cpp index a63813d9..aadcd3e0 100644 --- a/source/gui/coverflow.cpp +++ b/source/gui/coverflow.cpp @@ -2476,7 +2476,7 @@ bool CCoverFlow::preCacheCover(const char *id, const u8 *png, bool full) SmartBuf zBuffer = m_compressCache ? smartMem2Alloc(zBufferSize) : tex.data; if (!!zBuffer && (!m_compressCache || compress(zBuffer.get(), &zBufferSize, tex.data.get(), bufSize) == Z_OK)) { - FILE *file = fopen(sfmt("%s/%s.wfc", m_cachePath.c_str(), id).c_str(), "wb"); + FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), id), "wb"); if (file != 0) { SWFCHeader header(tex, full, m_compressCache); @@ -2493,7 +2493,7 @@ bool CCoverFlow::fullCoverCached(const char *id) { bool found = false; - FILE *file = fopen(sfmt("%s/%s.wfc", m_cachePath.c_str(), id).c_str(), "rb"); + FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), id), "rb"); if (file != 0) { SWFCHeader header; @@ -2532,7 +2532,7 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq) SmartBuf zBuffer = m_compressCache ? smartMem2Alloc(zBufferSize) : tex.data; if (!!zBuffer && (!m_compressCache || compress(zBuffer.get(), &zBufferSize, tex.data.get(), bufSize) == Z_OK)) { - FILE *file = fopen(sfmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == 0x4c4f4c4f ? &m_items[i].hdr->path[std::string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)).c_str(), "wb"); + FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == 0x4c4f4c4f ? &m_items[i].hdr->path[std::string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)), "wb"); if (file != 0) { SWFCHeader header(tex, box, m_compressCache); @@ -2599,7 +2599,7 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq) // Try to find the texture in the cache if (!m_cachePath.empty()) { - FILE *file = fopen(sfmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == 0x4c4f4c4f ? &m_items[i].hdr->path[std::string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)).c_str(), "rb"); + FILE *file = fopen(fmt("%s/%s.wfc", m_cachePath.c_str(), (m_items[i].hdr->hdr.gc_magic == 0x4c4f4c4f ? &m_items[i].hdr->path[std::string(m_items[i].hdr->path).find_last_of("/")] : (char*)m_items[i].hdr->hdr.id)), "rb"); if (file != 0) { bool success = false; diff --git a/source/gui/fanart.cpp b/source/gui/fanart.cpp index 34c9a0d4..715f22db 100644 --- a/source/gui/fanart.cpp +++ b/source/gui/fanart.cpp @@ -38,19 +38,19 @@ bool CFanart::load(Config &m_globalConfig, const char *path, const char *id) const char *dir = fmt("%s/%s", path, id); STexture fanBg, fanBgLq; - STexture::TexErr texErr = fanBg.fromPNGFile(sfmt("%s/background.png", dir).c_str(), GX_TF_RGBA8); + STexture::TexErr texErr = fanBg.fromPNGFile(fmt("%s/background.png", dir), GX_TF_RGBA8); if (texErr == STexture::TE_ERROR) { dir = fmt("%s/%.3s", path, id); - texErr = fanBg.fromPNGFile(sfmt("%s/background.png", dir).c_str(), GX_TF_RGBA8); + texErr = fanBg.fromPNGFile(fmt("%s/background.png", dir), GX_TF_RGBA8); } if (texErr == STexture::TE_OK) { - m_cfg.load(sfmt("%s/%s.ini", dir, id).c_str()); - if (!m_cfg.loaded()) m_cfg.load(sfmt("%s/%.3s.ini", dir, id).c_str()); + m_cfg.load(fmt("%s/%s.ini", dir, id)); + if (!m_cfg.loaded()) m_cfg.load(fmt("%s/%.3s.ini", dir, id)); - fanBgLq.fromPNGFile(sfmt("%s/background_lq.png", dir).c_str(), GX_TF_RGBA8); + fanBgLq.fromPNGFile(fmt("%s/background_lq.png", dir), GX_TF_RGBA8); for (int i = 1; i <= 6; i++) { @@ -176,7 +176,7 @@ void CFanart::draw(bool front) CFanartElement::CFanartElement(Config &cfg, const char *dir, int artwork) : m_artwork(artwork), m_isValid(false) { - m_isValid = m_art.fromPNGFile(sfmt("%s/artwork%d.png", dir, artwork).c_str(), GX_TF_RGBA8) == STexture::TE_OK; + m_isValid = m_art.fromPNGFile(fmt("%s/artwork%d.png", dir, artwork), GX_TF_RGBA8) == STexture::TE_OK; if (!m_isValid) return; const char *section = fmt("artwork%d", artwork); diff --git a/source/gui/text.cpp b/source/gui/text.cpp index f3ab8c0c..5f20fba0 100644 --- a/source/gui/text.cpp +++ b/source/gui/text.cpp @@ -7,11 +7,6 @@ static const wchar_t *g_whitespaces = L" \f\n\r\t\v"; // Simplified use of sprintf const char *fmt(const char *format, ...) { - enum { - MAX_MSG_SIZE = 512, - MAX_USES = 8 - }; - static int currentStr = 0; currentStr = (currentStr + 1) % MAX_USES; diff --git a/source/gui/text.hpp b/source/gui/text.hpp index 262ccf7c..08437888 100644 --- a/source/gui/text.hpp +++ b/source/gui/text.hpp @@ -54,6 +54,12 @@ private: }; // Nothing to do with CText. Q&D helpers for string formating. + +enum { + MAX_MSG_SIZE = 512, + MAX_USES = 8 +}; + const char *fmt(const char *format, ...); std::string sfmt(const char *format, ...); wstringEx wfmt(const wstringEx &format, ...); diff --git a/source/list/cachedlist.cpp b/source/list/cachedlist.cpp index 31299d9c..e24a6e22 100644 --- a/source/list/cachedlist.cpp +++ b/source/list/cachedlist.cpp @@ -28,7 +28,7 @@ void CachedList::Load(string path, string containing, string m_lastLanguage, update_emu = strcasestr(path.c_str(), m_plugin.getString("PLUGIN","romDir","").c_str()) != NULL && force_update[COVERFLOW_EMU]; const char* partition = DeviceName[DeviceHandler::Instance()->PathToDriveType(path.c_str())]; - update_dml = strcasestr(path.c_str(), sfmt(strncmp(partition, "sd", 2) != 0 ? m_DMLgameDir.c_str() : "%s:/games", partition).c_str()) != NULL && force_update[COVERFLOW_DML]; + update_dml = strcasestr(path.c_str(), fmt(strncmp(partition, "sd", 2) != 0 ? m_DMLgameDir.c_str() : "%s:/games", partition)) != NULL && force_update[COVERFLOW_DML]; gprintf("update_games=%d update_homebrew=%d update_dml=%d, update_emu=%d\n", update_games, update_homebrew, update_dml, update_emu); if(update_games || update_homebrew || update_dml || update_emu) diff --git a/source/list/list.cpp b/source/list/list.cpp index ce2c816f..0a6608f8 100644 --- a/source/list/list.cpp +++ b/source/list/list.cpp @@ -131,7 +131,7 @@ void CList::GetHeaders(safe_vector pathlist, safe_vector 0) { - gameTDB.OpenFile(sfmt("%s/wiitdb.xml", settingsDir.c_str()).c_str()); + gameTDB.OpenFile(fmt("%s/wiitdb.xml", settingsDir.c_str())); if(curLanguage.size() == 0) curLanguage = "EN"; gameTDB.SetLanguageCode(curLanguage.c_str()); } @@ -470,7 +470,7 @@ void CList::GetChannels(safe_vector &headerlist, strin GameTDB gameTDB; if (settingsDir.size() > 0) { - gameTDB.OpenFile(sfmt("%s/wiitdb.xml", settingsDir.c_str()).c_str()); + gameTDB.OpenFile(fmt("%s/wiitdb.xml", settingsDir.c_str())); if(curLanguage.size() == 0) curLanguage = "EN"; gameTDB.SetLanguageCode(curLanguage.c_str()); } diff --git a/source/loader/gc_disc.cpp b/source/loader/gc_disc.cpp index 201367a7..bd86b144 100644 --- a/source/loader/gc_disc.cpp +++ b/source/loader/gc_disc.cpp @@ -289,14 +289,14 @@ s32 GCDump::DumpGame() Asciify2(gcheader.title); - snprintf(folder, sizeof(folder), sfmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition).c_str()); + snprintf(folder, sizeof(folder), fmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition)); if(!fsop_DirExist(folder)) { gprintf("Creating directory: %s\n", folder); makedir(folder); } memset(folder, 0, sizeof(folder)); - snprintf(folder, sizeof(folder), "%s/%s [%.06s]%s", sfmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition).c_str(), gcheader.title, (char *)gcheader.id, Disc ? "2" : ""); + snprintf(folder, sizeof(folder), "%s/%s [%.06s]%s", fmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition), gcheader.title, (char *)gcheader.id, Disc ? "2" : ""); if(!fsop_DirExist(folder)) { gprintf("Creating directory: %s\n", folder); @@ -369,7 +369,7 @@ s32 GCDump::DumpGame() if(writeexfiles) { memset(folder, 0, sizeof(folder)); - snprintf(folder, sizeof(folder), "%s/%s [%.06s]%s/sys", sfmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition).c_str(), gcheader.title, (char *)gcheader.id, Disc ? "2" : ""); + snprintf(folder, sizeof(folder), "%s/%s [%.06s]%s/sys", fmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition), gcheader.title, (char *)gcheader.id, Disc ? "2" : ""); if(!fsop_DirExist(folder)) { gprintf("Creating directory: %s\n", folder); @@ -389,7 +389,7 @@ s32 GCDump::DumpGame() gc_done += __DiscWrite(gamepath, 0x2440+NextOffset, ApploaderSize, ReadBuffer); } - snprintf(gamepath, sizeof(gamepath), "%s/%s [%.06s]%s/game.iso", sfmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition).c_str(), gcheader.title, (char *)gcheader.id, Disc ? "2" : ""); + snprintf(gamepath, sizeof(gamepath), "%s/%s [%.06s]%s/game.iso", fmt((strncmp(gamepartition, "sd", 2) != 0) ? usb_dml_game_dir : DML_DIR, gamepartition), gcheader.title, (char *)gcheader.id, Disc ? "2" : ""); gprintf("Writing %s\n", gamepath); if(compressed) diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index a81137c5..0bac511f 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -151,7 +151,7 @@ void CMenu::init(void) Playlog_Delete(); for(int i = SD; i <= USB8; i++) //Find the first partition with a wiiflow.ini - if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(sfmt("%s:/%s/" CFG_FILENAME, DeviceName[i], APPDATA_DIR2).c_str(), &dummy) == 0) + if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s/" CFG_FILENAME, DeviceName[i], APPDATA_DIR2), &dummy) == 0) { drive = DeviceName[i]; break; @@ -159,7 +159,7 @@ void CMenu::init(void) if(drive == check) //No wiiflow.ini found for(int i = SD; i <= USB8; i++) //Find the first partition with a boot.dol - if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(sfmt("%s:/%s/boot.dol", DeviceName[i], APPDATA_DIR2).c_str(), &dummy) == 0) + if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s/boot.dol", DeviceName[i], APPDATA_DIR2), &dummy) == 0) { drive = DeviceName[i]; break; @@ -167,7 +167,7 @@ void CMenu::init(void) if(drive == check) //No boot.dol found for(int i = SD; i <= USB8; i++) //Find the first partition with apps/wiiflow folder - if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(sfmt("%s:/%s", DeviceName[i], APPDATA_DIR2).c_str(), &dummy) == 0) + if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s", DeviceName[i], APPDATA_DIR2), &dummy) == 0) { drive = DeviceName[i]; break; @@ -178,7 +178,7 @@ void CMenu::init(void) if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS) { drive = DeviceName[i]; - makedir((char *)sfmt("%s:/%s", DeviceName[i], APPDATA_DIR2).c_str()); //Make the apps dir, so saving wiiflow.ini does not fail. + makedir((char *)fmt("%s:/%s", DeviceName[i], APPDATA_DIR2)); //Make the apps dir, so saving wiiflow.ini does not fail. break; } @@ -195,7 +195,7 @@ void CMenu::init(void) m_appDir = sfmt("%s:/%s", drive, APPDATA_DIR2); gprintf("Wiiflow boot.dol Location: %s\n", m_appDir.c_str()); - m_cfg.load(sfmt("%s/" CFG_FILENAME, m_appDir.c_str()).c_str()); + m_cfg.load(fmt("%s/" CFG_FILENAME, m_appDir.c_str())); //Gecko Output to SD if(!WriteToSD) @@ -211,7 +211,7 @@ void CMenu::init(void) if (onUSB) { for(int i = USB1; i <= USB8; i++) //Look for first partition with a wiiflow folder in root - if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(sfmt("%s:/%s", DeviceName[i], APPDATA_DIR).c_str(), &dummy) == 0) + if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s", DeviceName[i], APPDATA_DIR), &dummy) == 0) { drive = DeviceName[i]; break; @@ -221,7 +221,7 @@ void CMenu::init(void) if(drive == check && onUSB) //No wiiflow folder found in root of any usb partition, and data_on_usb=yes for(int i = USB1; i <= USB8; i++) // Try first USB partition with wbfs folder. - if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(sfmt(GAMES_DIR, DeviceName[i]).c_str(), &dummy) == 0) + if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(fmt(GAMES_DIR, DeviceName[i]), &dummy) == 0) { drive = DeviceName[i]; break; @@ -261,7 +261,7 @@ void CMenu::init(void) m_new_dml = m_cfg.getBool("DML", "dml_r52+", true); m_DMLgameDir = sfmt("%%s:/%s", m_cfg.getString("DML", "dir_usb_games", "games").c_str()); - m_cfg.getString("NAND", "path", "").c_str(); + m_cfg.getString("NAND", "path", ""); m_cfg.getInt("NAND", "partition", 0); m_cfg.getBool("NAND", "disable", true); @@ -311,7 +311,7 @@ void CMenu::init(void) } if (DeviceHandler::Instance()->IsInserted(i) && ((m_current_view == COVERFLOW_USB && DeviceHandler::Instance()->GetFSType(i) == PART_FS_WBFS) - || stat(sfmt(checkDir, DeviceName[i]).c_str(), &dummy) == 0)) + || stat(fmt(checkDir, DeviceName[i]), &dummy) == 0)) { gprintf("Setting Emu NAND to Partition: %i\n",currentPartition); m_cfg.setInt(domain, "partition", i); @@ -340,10 +340,10 @@ void CMenu::init(void) makedir((char *)m_helpDir.c_str()); // INI files - m_cat.load(sfmt("%s/" CAT_FILENAME, m_settingsDir.c_str()).c_str()); + m_cat.load(fmt("%s/" CAT_FILENAME, m_settingsDir.c_str())); string themeName = m_cfg.getString("GENERAL", "theme", "DEFAULT"); m_themeDataDir = sfmt("%s/%s", m_themeDir.c_str(), themeName.c_str()); - m_theme.load(sfmt("%s.ini", m_themeDataDir.c_str()).c_str()); + m_theme.load(fmt("%s.ini", m_themeDataDir.c_str())); m_plugin.init(m_pluginsDir); @@ -382,11 +382,11 @@ void CMenu::init(void) defaultMenuLanguage = 2; //Brazilian m_curLanguage = CMenu::_translations[m_cfg.getInt("GENERAL", "language", defaultMenuLanguage)]; - if (!m_loc.load(sfmt("%s/%s.ini", m_languagesDir.c_str(), m_curLanguage.c_str()).c_str())) + if (!m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), m_curLanguage.c_str()))) { m_cfg.setInt("GENERAL", "language", 0); m_curLanguage = CMenu::_translations[0]; - m_loc.load(sfmt("%s/%s.ini", m_languagesDir.c_str(), m_curLanguage.c_str()).c_str()); + m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), m_curLanguage.c_str())); } bool extcheck = m_cfg.getBool("GENERAL", "extended_list_check", true); @@ -402,7 +402,7 @@ void CMenu::init(void) for(int chan = WPAD_MAX_WIIMOTES-2; chan >= 0; chan--) { - m_cursor[chan].init(sfmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString("GENERAL", sfmt("pointer%i", chan+1).c_str()).c_str()).c_str(), + m_cursor[chan].init(fmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString("GENERAL", fmt("pointer%i", chan+1)).c_str()), m_vid.wide(), pShadowColor, pShadowX, pShadowY, pShadowBlur, chan); WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height()); } @@ -419,8 +419,8 @@ void CMenu::init(void) m_disable_exit = exit_to == EXIT_TO_DISABLE; if(exit_to == EXIT_TO_BOOTMII && (!DeviceHandler::Instance()->IsInserted(SD) || - stat(sfmt("%s:/bootmii/armboot.bin",DeviceName[SD]).c_str(), &dummy) != 0 || - stat(sfmt("%s:/bootmii/ppcboot.elf", DeviceName[SD]).c_str(), &dummy) != 0)) + stat(fmt("%s:/bootmii/armboot.bin",DeviceName[SD]), &dummy) != 0 || + stat(fmt("%s:/bootmii/ppcboot.elf", DeviceName[SD]), &dummy) != 0)) exit_to = EXIT_TO_HBC; Sys_ExitTo(exit_to); @@ -452,8 +452,8 @@ void CMenu::init(void) { gprintf("Found gamercard provider: %s\n",(*itr).c_str()); register_card_provider( - m_cfg.getString("GAMERCARD", sfmt("%s_url", (*itr).c_str())).c_str(), - m_cfg.getString("GAMERCARD", sfmt("%s_key", (*itr).c_str())).c_str() + m_cfg.getString("GAMERCARD", fmt("%s_url", (*itr).c_str())).c_str(), + m_cfg.getString("GAMERCARD", fmt("%s_key", (*itr).c_str())).c_str() ); } } @@ -595,8 +595,8 @@ void CMenu::_loadCFLayout(int version, bool forceAA, bool otherScrnFmt) { bool homebrew = m_current_view == COVERFLOW_HOMEBREW; bool smallbox = (homebrew || m_current_view == COVERFLOW_EMU) && m_cfg.getBool(_domainFromView(), "smallbox", true); - string domain(smallbox ? (homebrew ? sfmt("_BREWFLOW_%i", version).c_str() : sfmt("_EMUFLOW_%i", version).c_str()) : sfmt("_COVERFLOW_%i", version).c_str()); - string domainSel(smallbox ? (homebrew ? sfmt("_BREWFLOW_%i_S", version).c_str() : sfmt("_EMUFLOW_%i_S", version).c_str()) : sfmt("_COVERFLOW_%i_S", version).c_str()); + string domain(smallbox ? (homebrew ? fmt("_BREWFLOW_%i", version) : fmt("_EMUFLOW_%i", version)) : fmt("_COVERFLOW_%i", version)); + string domainSel(smallbox ? (homebrew ? fmt("_BREWFLOW_%i_S", version) : fmt("_EMUFLOW_%i_S", version)) : fmt("_COVERFLOW_%i_S", version)); bool sf = otherScrnFmt; int max_fsaa = m_theme.getInt(domain, "max_fsaa", 3); @@ -1076,7 +1076,7 @@ SFont CMenu::_font(CMenu::FontSet &fontSet, const char *domain, const char *key, // TTF not found in memory, load it to create a new font SFont retFont; - if (!useDefault && retFont.fromFile(sfmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()).c_str(), fonts[0].res, fonts[1].res, fonts[2].res, index)) + if (!useDefault && retFont.fromFile(fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()), fonts[0].res, fonts[1].res, fonts[2].res, index)) { // Theme Font fontSet[CMenu::FontDesc(upperCase(filename.c_str()), fonts[0].res)] = retFont; @@ -1111,7 +1111,7 @@ safe_vector CMenu::_textures(TexSet &texSet, const char *domain, const textures.push_back(i->second); } STexture tex; - if (STexture::TE_OK == tex.fromPNGFile(sfmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()).c_str(), GX_TF_RGBA8, ALLOC_MEM2)) + if (STexture::TE_OK == tex.fromPNGFile(fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()), GX_TF_RGBA8, ALLOC_MEM2)) { texSet[filename] = tex; textures.push_back(tex); @@ -1136,7 +1136,7 @@ STexture CMenu::_texture(CMenu::TexSet &texSet, const char *domain, const char * return i->second; STexture tex; - if (STexture::TE_OK == tex.fromPNGFile(sfmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()).c_str(), GX_TF_RGBA8, ALLOC_MEM2)) + if (STexture::TE_OK == tex.fromPNGFile(fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()), GX_TF_RGBA8, ALLOC_MEM2)) { texSet[filename] = tex; return tex; @@ -1157,7 +1157,7 @@ SmartGuiSound CMenu::_sound(CMenu::SoundSet &soundSet, const char *domain, const if (i == soundSet.end()) { if(strncmp(filename.c_str(), name.c_str(), name.size()) != 0) - soundSet[upperCase(filename.c_str())] = SmartGuiSound(new GuiSound(sfmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()).c_str())); + soundSet[upperCase(filename.c_str())] = SmartGuiSound(new GuiSound(fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()))); else soundSet[upperCase(filename.c_str())] = SmartGuiSound(new GuiSound(snd, len, filename, isAllocated)); @@ -1180,7 +1180,7 @@ SmartGuiSound CMenu::_sound(CMenu::SoundSet &soundSet, const char *domain, const CMenu::SoundSet::iterator i = soundSet.find(upperCase(filename.c_str())); if (i == soundSet.end()) { - soundSet[upperCase(filename.c_str())] = SmartGuiSound(new GuiSound(sfmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()).c_str())); + soundSet[upperCase(filename.c_str())] = SmartGuiSound(new GuiSound(fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()))); return soundSet[upperCase(filename.c_str())]; } return i->second; @@ -1456,9 +1456,9 @@ void CMenu::_initCF(void) m_cf.reserve(m_gameList.size()); m_gamelistdump = m_cfg.getBool(domain, "dump_list", true); - if(m_gamelistdump) m_dump.load(sfmt("%s/titlesdump.ini", m_settingsDir.c_str()).c_str()); + if(m_gamelistdump) m_dump.load(fmt("%s/titlesdump.ini", m_settingsDir.c_str())); - m_gcfg1.load(sfmt("%s/gameconfig1.ini", m_settingsDir.c_str()).c_str()); + m_gcfg1.load(fmt("%s/gameconfig1.ini", m_settingsDir.c_str())); string id; for (u32 i = 0; i < m_gameList.size(); ++i) { @@ -1508,15 +1508,15 @@ void CMenu::_initCF(void) string coverFolder(m_plugin.GetCoverFolderName(m_gameList[i].hdr.magic)); //if(tempname.find_last_of('.') != string::npos) // tempname.erase(tempname.find_last_of('.'), tempname.size() - tempname.find_last_of('.')); - m_cf.addItem(&m_gameList[i], sfmt("%s/%s/%s.png", m_picDir.c_str(), coverFolder.c_str(), tempname.c_str()).c_str(), sfmt("%s/%s/%s.png", m_boxPicDir.c_str(), coverFolder.c_str(), tempname.c_str()).c_str(), playcount, lastPlayed); + m_cf.addItem(&m_gameList[i], fmt("%s/%s/%s.png", m_picDir.c_str(), coverFolder.c_str(), tempname.c_str()), fmt("%s/%s/%s.png", m_boxPicDir.c_str(), coverFolder.c_str(), tempname.c_str()), playcount, lastPlayed); } else if (m_current_view != COVERFLOW_HOMEBREW) - m_cf.addItem(&m_gameList[i], sfmt("%s/%s.png", m_picDir.c_str(), id.c_str()).c_str(), sfmt("%s/%s.png", m_boxPicDir.c_str(), id.c_str()).c_str(), playcount, lastPlayed); + m_cf.addItem(&m_gameList[i], fmt("%s/%s.png", m_picDir.c_str(), id.c_str()), fmt("%s/%s.png", m_boxPicDir.c_str(), id.c_str()), playcount, lastPlayed); else { string s = sfmt("%s", m_gameList[i].path); string f = s.substr(0, s.find_last_of("/")); - m_cf.addItem(&m_gameList[i], sfmt("%s/icon.png", f.c_str()).c_str(), sfmt("%s/%s.png", m_boxPicDir.c_str(), id.c_str()).c_str(), playcount, lastPlayed); + m_cf.addItem(&m_gameList[i], fmt("%s/icon.png", f.c_str()), fmt("%s/%s.png", m_boxPicDir.c_str(), id.c_str()), playcount, lastPlayed); } } @@ -1629,7 +1629,7 @@ void CMenu::_mainLoopCommon(bool withCF, bool blockReboot, bool adjusting) timeinfo = localtime(&rawtime); strftime(buffer,80,"%b-%d-20%y-%Hh%Mm%Ss.png",timeinfo); gprintf("Screenshot taken and saved to: %s/%s\n", m_screenshotDir.c_str(), buffer); - m_vid.TakeScreenshot(sfmt("%s/%s", m_screenshotDir.c_str(), buffer).c_str()); + m_vid.TakeScreenshot(fmt("%s/%s", m_screenshotDir.c_str(), buffer)); if (!!m_cameraSound) m_cameraSound->Play(255); } diff --git a/source/menu/menu_about.cpp b/source/menu/menu_about.cpp index faf1b459..26f6e6ad 100644 --- a/source/menu/menu_about.cpp +++ b/source/menu/menu_about.cpp @@ -127,9 +127,9 @@ void CMenu::_textAbout(void) m_btnMgr.setText(m_aboutLblTitle, wfmt(_fmt("appname", L"%s (%s-r%s)"), APP_NAME, APP_VERSION, SVN_REV), false); char *help = (char*)calloc(4096, sizeof(char)); - FILE * f = fopen(sfmt("%s/%s.txt", m_helpDir.c_str(), m_curLanguage.c_str()).c_str(), "r"); + FILE * f = fopen(fmt("%s/%s.txt", m_helpDir.c_str(), m_curLanguage.c_str()), "r"); if (f == NULL) - f = fopen(sfmt("%s/english.txt", m_helpDir.c_str()).c_str(), "r"); + f = fopen(fmt("%s/english.txt", m_helpDir.c_str()), "r"); if (f == NULL) strcpy(help, "ERROR: No Help File Found"); else diff --git a/source/menu/menu_categories.cpp b/source/menu/menu_categories.cpp index 1eb7f513..0247fa23 100644 --- a/source/menu/menu_categories.cpp +++ b/source/menu/menu_categories.cpp @@ -185,21 +185,21 @@ void CMenu::_initCategorySettingsMenu(CMenu::SThemeData &theme) m_categoryBtnCats[0] = _addPicButton(theme, "CATEGORY/CAT_0_BTNS", theme.checkboxon, theme.checkboxons, 30, 390, 44, 48); for (int i = 1; i < 6; ++i) { // Page 1 - m_categoryLblCat[i] = _addLabel(theme, sfmt("CATEGORY/CAT_%i", i).c_str(), theme.lblFont, L"", 85, (42+i*58), 230, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE); - m_categoryBtnCat[i] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTN", i).c_str(), theme.checkboxoff, theme.checkboxoffs, 30, (42+i*58), 44, 48); - m_categoryBtnCats[i] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTNS", i).c_str(), theme.checkboxon, theme.checkboxons, 30, (42+i*58), 44, 48); + m_categoryLblCat[i] = _addLabel(theme, fmt("CATEGORY/CAT_%i", i), theme.lblFont, L"", 85, (42+i*58), 230, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE); + m_categoryBtnCat[i] = _addPicButton(theme, fmt("CATEGORY/CAT_%i_BTN", i), theme.checkboxoff, theme.checkboxoffs, 30, (42+i*58), 44, 48); + m_categoryBtnCats[i] = _addPicButton(theme, fmt("CATEGORY/CAT_%i_BTNS", i), theme.checkboxon, theme.checkboxons, 30, (42+i*58), 44, 48); // right half - m_categoryLblCat[i+5] = _addLabel(theme, sfmt("CATEGORY/CAT_%i", i+5).c_str(), theme.txtFont, L"", 380, (42+i*58), 230, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE); - m_categoryBtnCat[i+5] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTN", i+5).c_str(), theme.checkboxoff, theme.checkboxoffs, 325, (42+i*58), 44, 48); - m_categoryBtnCats[i+5] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTNS", i+5).c_str(), theme.checkboxon, theme.checkboxons, 325, (42+i*58), 44, 48); + m_categoryLblCat[i+5] = _addLabel(theme, fmt("CATEGORY/CAT_%i", i+5), theme.txtFont, L"", 380, (42+i*58), 230, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE); + m_categoryBtnCat[i+5] = _addPicButton(theme, fmt("CATEGORY/CAT_%i_BTN", i+5), theme.checkboxoff, theme.checkboxoffs, 325, (42+i*58), 44, 48); + m_categoryBtnCats[i+5] = _addPicButton(theme, fmt("CATEGORY/CAT_%i_BTNS", i+5), theme.checkboxon, theme.checkboxons, 325, (42+i*58), 44, 48); // Page 2 - m_categoryLblCat[i+10] = _addLabel(theme, sfmt("CATEGORY/CAT_%i", i+10).c_str(), theme.lblFont, L"", 85, (42+i*58), 230, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE); - m_categoryBtnCat[i+10] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTN", i+10).c_str(), theme.checkboxoff, theme.checkboxoffs, 30, (42+i*58), 44, 48); - m_categoryBtnCats[i+10] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTNS", i+10).c_str(), theme.checkboxon, theme.checkboxons, 30, (42+i*58), 44, 48); + m_categoryLblCat[i+10] = _addLabel(theme, fmt("CATEGORY/CAT_%i", i+10), theme.lblFont, L"", 85, (42+i*58), 230, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE); + m_categoryBtnCat[i+10] = _addPicButton(theme, fmt("CATEGORY/CAT_%i_BTN", i+10), theme.checkboxoff, theme.checkboxoffs, 30, (42+i*58), 44, 48); + m_categoryBtnCats[i+10] = _addPicButton(theme, fmt("CATEGORY/CAT_%i_BTNS", i+10), theme.checkboxon, theme.checkboxons, 30, (42+i*58), 44, 48); // right half - m_categoryLblCat[i+15] = _addLabel(theme, sfmt("CATEGORY/CAT_%i", i+15).c_str(), theme.txtFont, L"", 380, (42+i*58), 230, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE); - m_categoryBtnCat[i+15] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTN", i+15).c_str(), theme.checkboxoff, theme.checkboxoffs, 325, (42+i*58), 44, 48); - m_categoryBtnCats[i+15] = _addPicButton(theme, sfmt("CATEGORY/CAT_%i_BTNS", i+15).c_str(), theme.checkboxon, theme.checkboxons, 325, (42+i*58), 44, 48); + m_categoryLblCat[i+15] = _addLabel(theme, fmt("CATEGORY/CAT_%i", i+15), theme.txtFont, L"", 380, (42+i*58), 230, 48, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE); + m_categoryBtnCat[i+15] = _addPicButton(theme, fmt("CATEGORY/CAT_%i_BTN", i+15), theme.checkboxoff, theme.checkboxoffs, 325, (42+i*58), 44, 48); + m_categoryBtnCats[i+15] = _addPicButton(theme, fmt("CATEGORY/CAT_%i_BTNS", i+15), theme.checkboxon, theme.checkboxons, 325, (42+i*58), 44, 48); } _setHideAnim(m_categoryLblTitle, "CATEGORY/TITLE", 0, -200, 0.f, 1.f); _setHideAnim(m_categoryLblPage, "CATEGORY/PAGE_BTN", 0, 200, 1.f, 0.f); @@ -207,9 +207,9 @@ void CMenu::_initCategorySettingsMenu(CMenu::SThemeData &theme) _setHideAnim(m_categoryBtnPageP, "CATEGORY/PAGE_PLUS", 0, 200, 1.f, 0.f); _setHideAnim(m_categoryBtnBack, "CATEGORY/BACK_BTN", 0, 200, 1.f, 0.f); for (int i = 0; i < 21; ++i) { - _setHideAnim(m_categoryBtnCat[i], sfmt("CATEGORY/CAT_%i_BTN", i).c_str(), 0, 0, 1.f, 0.f); - _setHideAnim(m_categoryBtnCats[i], sfmt("CATEGORY/CAT_%i_BTNS", i).c_str(), 0, 0, 1.f, 0.f); - _setHideAnim(m_categoryLblCat[i], sfmt("CATEGORY/CAT_%i", i).c_str(), 0, 0, 1.f, 0.f); + _setHideAnim(m_categoryBtnCat[i], fmt("CATEGORY/CAT_%i_BTN", i), 0, 0, 1.f, 0.f); + _setHideAnim(m_categoryBtnCats[i], fmt("CATEGORY/CAT_%i_BTNS", i), 0, 0, 1.f, 0.f); + _setHideAnim(m_categoryLblCat[i], fmt("CATEGORY/CAT_%i", i), 0, 0, 1.f, 0.f); m_categoryBtn[i] = m_categoryBtnCat[i]; } _hideCategorySettings(true); diff --git a/source/menu/menu_cftheme.cpp b/source/menu/menu_cftheme.cpp index 7bab36ce..525add2b 100644 --- a/source/menu/menu_cftheme.cpp +++ b/source/menu/menu_cftheme.cpp @@ -328,7 +328,7 @@ void CMenu::_cfTheme(void) { m_theme.clear(); m_theme.unload(); - m_theme.load(sfmt("%s/%s.ini", m_themeDir.c_str(), m_cfg.getString("GENERAL", "theme", "defaut").c_str()).c_str()); + m_theme.load(fmt("%s/%s.ini", m_themeDir.c_str(), m_cfg.getString("GENERAL", "theme", "defaut").c_str())); break; } else if (BTN_UP_PRESSED) @@ -409,7 +409,7 @@ void CMenu::_cfTheme(void) { m_theme.clear(); m_theme.unload(); - m_theme.load(sfmt("%s/%s.ini", m_themeDir.c_str(), m_cfg.getString("GENERAL", "theme", "defaut").c_str()).c_str()); + m_theme.load(fmt("%s/%s.ini", m_themeDir.c_str(), m_cfg.getString("GENERAL", "theme", "defaut").c_str())); break; } else if (m_btnMgr.selected(m_cfThemeBtnAlt) && m_current_view != COVERFLOW_HOMEBREW && m_current_view != COVERFLOW_EMU) @@ -584,12 +584,12 @@ void CMenu::_initCFThemeMenu(CMenu::SThemeData &theme) domain = sfmt("CFTHEME/VAL%i%c_%%s", i / 3 + 1, (char)(i % 3) + 'A'); x = 20 + (i / 4) * 150; y = 340 + (i % 4) * 32; - m_cfThemeLblVal[i] = _addLabel(theme, sfmt(domain.c_str(), "BTN").c_str(), theme.btnFont, L"", x + 32, y, 86, 32, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC); - m_cfThemeBtnValM[i] = _addPicButton(theme, sfmt(domain.c_str(), "MINUS").c_str(), theme.btnTexMinus, theme.btnTexMinusS, x, y, 32, 32); - m_cfThemeBtnValP[i] = _addPicButton(theme, sfmt(domain.c_str(), "PLUS").c_str(), theme.btnTexPlus, theme.btnTexPlusS, x + 118, y, 32, 32); + m_cfThemeLblVal[i] = _addLabel(theme, fmt(domain.c_str(), "BTN"), theme.btnFont, L"", x + 32, y, 86, 32, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC); + m_cfThemeBtnValM[i] = _addPicButton(theme, fmt(domain.c_str(), "MINUS"), theme.btnTexMinus, theme.btnTexMinusS, x, y, 32, 32); + m_cfThemeBtnValP[i] = _addPicButton(theme, fmt(domain.c_str(), "PLUS"), theme.btnTexPlus, theme.btnTexPlusS, x + 118, y, 32, 32); } for (int i = 0; i < 4; ++i) - m_cfThemeLblValTxt[i] = _addLabel(theme, sfmt("CFTHEME/VAL%i_LBL", i + 1).c_str(), theme.lblFont, L"", 20 + i * 150, 100, 150, 240, theme.lblFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_BOTTOM, emptyTex); + m_cfThemeLblValTxt[i] = _addLabel(theme, fmt("CFTHEME/VAL%i_LBL", i + 1), theme.lblFont, L"", 20 + i * 150, 100, 150, 240, theme.lblFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_BOTTOM, emptyTex); _hideCFTheme(true); } diff --git a/source/menu/menu_cheat.cpp b/source/menu/menu_cheat.cpp index a2d053d3..42c11c3d 100644 --- a/source/menu/menu_cheat.cpp +++ b/source/menu/menu_cheat.cpp @@ -54,7 +54,7 @@ u32 CMenu::_downloadCheatFileAsync(void *obj) string id = m->m_cf.getId(); char type = id[0] == 'S' ? 'R' : id[0]; - block cheatfile = downloadfile(buffer.get(), bufferSize, sfmt(GECKOURL, type, id.c_str()).c_str(),CMenu::_downloadProgress, m); + block cheatfile = downloadfile(buffer.get(), bufferSize, fmt(GECKOURL, type, id.c_str()), CMenu::_downloadProgress, m); if (cheatfile.data != NULL && cheatfile.size > 65 && cheatfile.data[0] != '<') { @@ -360,8 +360,8 @@ void CMenu::_initCheatSettingsMenu(CMenu::SThemeData &theme) _setHideAnim(m_cheatBtnPageP, "CHEAT/PAGE_PLUS", 0, 0, 1.f, -1.f); for (int i=0;i 0) { - c_gameTDB.OpenFile(sfmt("%s/wiitdb.xml", m_settingsDir.c_str()).c_str()); + c_gameTDB.OpenFile(fmt("%s/wiitdb.xml", m_settingsDir.c_str())); c_gameTDB.SetLanguageCode(m_curLanguage.c_str()); } @@ -524,7 +524,7 @@ int CMenu::_coverDownloader(bool missingOnly) m_thrdStepLen = dlWeight / (float)nbSteps; Config m_newID; - m_newID.load(sfmt("%s/newid.ini", m_settingsDir.c_str()).c_str()); + m_newID.load(fmt("%s/newid.ini", m_settingsDir.c_str())); m_newID.setString("CHANNELS", "WFSF", "DWFA"); u32 CoverType = 0; @@ -1973,7 +1973,7 @@ int CMenu::_gametdbDownloaderAsync() LWP_MutexUnlock(m_mutex); m_thrdStep = 0.0f; m_thrdStepLen = 1.0f; - download = downloadfile(buffer.get(), bufferSize, sfmt(GAMETDB_URL, langCode.c_str()).c_str(), CMenu::_downloadProgress, this); + download = downloadfile(buffer.get(), bufferSize, fmt(GAMETDB_URL, langCode.c_str()), CMenu::_downloadProgress, this); if (download.data == 0) { LWP_MutexLock(m_mutex); diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 1a1714e6..ec48e70c 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -347,7 +347,7 @@ static void setLanguage(int l) void CMenu::_game(bool launch) { - m_gcfg1.load(sfmt("%s/gameconfig1.ini", m_settingsDir.c_str()).c_str()); + m_gcfg1.load(fmt("%s/gameconfig1.ini", m_settingsDir.c_str())); if (!launch) { SetupInput(); @@ -482,7 +482,7 @@ void CMenu::_game(bool launch) if(currentPartition != SD && hdr->hdr.gc_magic == 0xc2339f3d) { char gcfolder[300]; - sprintf(gcfolder, "%s [%s]", m_cf.getTitle().toUTF8().c_str(), (char *)hdr->hdr.id); + snprintf(gcfolder, sizeof(gcfolder), "%s [%s]", m_cf.getTitle().toUTF8().c_str(), (char *)hdr->hdr.id); if (GC_GameIsInstalled((char *)hdr->hdr.id, DeviceName[SD], DML_DIR)) { memset(hdr->path, 0, sizeof(hdr->path)); @@ -636,7 +636,7 @@ void CMenu::_directlaunch(const string &id) void CMenu::_launch(dir_discHdr *hdr) { - m_gcfg2.load(sfmt("%s/gameconfig2.ini", m_settingsDir.c_str()).c_str()); + m_gcfg2.load(fmt("%s/gameconfig2.ini", m_settingsDir.c_str())); if(hdr->hdr.gc_magic == 0x4c4f4c4f) { string title(&hdr->path[std::string(hdr->path).find_last_of("/")+1]); @@ -1116,13 +1116,13 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) Nand::Instance()->CreatePath("%s:/wiiflow/nandemu", DeviceName[emuPartition]); m_cfg.setString("GAMES", "savepath", STDEMU_DIR); emuPath = m_cfg.getString("GAMES", "savepath", STDEMU_DIR); - snprintf(basepath, 64, "%s:%s", DeviceName[emuPartition], emuPath.c_str()); + snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPartition], emuPath.c_str()); if(emuSave == 4) createnand = true; } else { - snprintf(basepath, 64, "%s:%s", DeviceName[emuPartition], emuPath.c_str()); + snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPartition], emuPath.c_str()); if(emuSave == 4) { DIR *d; @@ -1271,7 +1271,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) if (ret < 0) { gprintf("Set USB failed: %d\n", ret); - error(wfmt(L"Set USB failed: %d\n", ret).c_str()); + error(wfmt(L"Set USB failed: %d\n", ret)); if (iosLoaded) Sys_LoadMenu(); return; } @@ -1326,7 +1326,7 @@ void CMenu::_initGameMenu(CMenu::SThemeData &theme) texSettingsSel.fromPNG(btngamecfgs_png); _addUserLabels(theme, m_gameLblUser, ARRAY_SIZE(m_gameLblUser), "GAME"); m_gameBg = _texture(theme.texSet, "GAME/BG", "texture", theme.bg); - if (m_theme.loaded() && STexture::TE_OK == bgLQ.fromPNGFile(sfmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString("GAME/BG", "texture").c_str()).c_str(), GX_TF_CMPR, ALLOC_MEM2, 64, 64)) + if (m_theme.loaded() && STexture::TE_OK == bgLQ.fromPNGFile(fmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString("GAME/BG", "texture").c_str()), GX_TF_CMPR, ALLOC_MEM2, 64, 64)) m_gameBgLQ = bgLQ; m_gameBtnPlay = _addButton(theme, "GAME/PLAY_BTN", theme.btnFont, L"", 420, 344, 200, 56, theme.btnFontColor); diff --git a/source/menu/menu_gameinfo.cpp b/source/menu/menu_gameinfo.cpp index 04ccb5a5..c5d50405 100644 --- a/source/menu/menu_gameinfo.cpp +++ b/source/menu/menu_gameinfo.cpp @@ -303,7 +303,7 @@ void CMenu::_textGameInfo(void) cnt_controls = 0; GameTDB m_gametdb; - m_gametdb.OpenFile(sfmt("%s/wiitdb.xml", m_settingsDir.c_str()).c_str()); + m_gametdb.OpenFile(fmt("%s/wiitdb.xml", m_settingsDir.c_str())); m_gametdb.SetLanguageCode(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str()); titlecheck = m_gametdb.IsLoaded() && m_gametdb.GetGameXMLInfo(m_cf.getId().c_str(), &gameinfo); diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index 1c710e1a..6041f5db 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -209,7 +209,7 @@ void CMenu::LoadView(void) m_showtimer=60; char gui_name[20]; - sprintf(gui_name,"%s [%s]",_domainFromView(),mode); + snprintf(gui_name, sizeof(gui_name), "%s [%s]", _domainFromView(),mode); m_btnMgr.setText(m_mainLblNotice, (string)gui_name); m_btnMgr.show(m_mainLblNotice); } @@ -240,7 +240,7 @@ int CMenu::main(void) MusicPlayer::Instance()->Play(); GameTDB m_gametdb; - m_gametdb.OpenFile(sfmt("%s/wiitdb.xml", m_settingsDir.c_str()).c_str()); + m_gametdb.OpenFile(fmt("%s/wiitdb.xml", m_settingsDir.c_str())); m_GameTDBLoaded=false; if( m_gametdb.IsLoaded() ) { @@ -296,8 +296,8 @@ int CMenu::main(void) { struct stat dummy; if(DeviceHandler::Instance()->IsInserted(SD) && - stat(sfmt("%s:/bootmii/armboot.bin", DeviceName[SD]).c_str(), &dummy) == 0 && - stat(sfmt("%s:/bootmii/ppcboot.elf", DeviceName[SD]).c_str(), &dummy) == 0) + stat(fmt("%s:/bootmii/armboot.bin", DeviceName[SD]), &dummy) == 0 && + stat(fmt("%s:/bootmii/ppcboot.elf", DeviceName[SD]), &dummy) == 0) Sys_ExitTo(EXIT_TO_BOOTMII); else Sys_ExitTo(EXIT_TO_HBC); } @@ -472,7 +472,7 @@ int CMenu::main(void) m_showtimer=60; char gui_name[20]; - sprintf(gui_name,"%s [%s]",_domainFromView(),partition); + snprintf(gui_name, sizeof(gui_name), "%s [%s]", _domainFromView(),partition); m_btnMgr.setText(m_mainLblNotice, (string)gui_name); m_btnMgr.show(m_mainLblNotice); @@ -568,8 +568,8 @@ int CMenu::main(void) else if(BTN_2_HELD) //Check that the files are there, or ios will hang. { if(DeviceHandler::Instance()->IsInserted(SD) && - stat(sfmt("%s:/bootmii/armboot.bin", DeviceName[SD]).c_str(), &dummy) == 0 && - stat(sfmt("%s:/bootmii/ppcboot.elf", DeviceName[SD]).c_str(), &dummy) == 0) + stat(fmt("%s:/bootmii/armboot.bin", DeviceName[SD]), &dummy) == 0 && + stat(fmt("%s:/bootmii/ppcboot.elf", DeviceName[SD]), &dummy) == 0) Sys_ExitTo(EXIT_TO_BOOTMII); else Sys_ExitTo(EXIT_TO_HBC); } @@ -830,7 +830,7 @@ void CMenu::_initMainMenu(CMenu::SThemeData &theme) STexture emptyTex; m_mainBg = _texture(theme.texSet, "MAIN/BG", "texture", theme.bg); - if (m_theme.loaded() && STexture::TE_OK == bgLQ.fromPNGFile(sfmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString("MAIN/BG", "texture").c_str()).c_str(), GX_TF_CMPR, ALLOC_MEM2, 64, 64)) + if (m_theme.loaded() && STexture::TE_OK == bgLQ.fromPNGFile(fmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString("MAIN/BG", "texture").c_str()), GX_TF_CMPR, ALLOC_MEM2, 64, 64)) m_mainBgLQ = bgLQ; texQuit.fromPNG(btnquit_png); diff --git a/source/menu/menu_nandemu.cpp b/source/menu/menu_nandemu.cpp index 3ffa10b4..7d1a8945 100644 --- a/source/menu/menu_nandemu.cpp +++ b/source/menu/menu_nandemu.cpp @@ -499,7 +499,7 @@ int CMenu::_NandDumper(void *obj) m.m_cfg.save(); char basepath[64]; - snprintf(basepath, 64, "%s:%s", DeviceName[emuPartition], emuPath.c_str()); + snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPartition], emuPath.c_str()); LWP_MutexLock(m.m_mutex); m._setDumpMsg(L"Calculating space needed for extraction...", 0.f, 0.f); diff --git a/source/menu/menu_wbfs.cpp b/source/menu/menu_wbfs.cpp index c6d29a87..62f19630 100644 --- a/source/menu/menu_wbfs.cpp +++ b/source/menu/menu_wbfs.cpp @@ -171,7 +171,7 @@ int CMenu::_GCgameInstaller(void *obj) } char partition[6]; - sprintf(partition,"%s:/",DeviceName[currentPartition]); + snprintf(partition, sizeof(partition), "%s:/", DeviceName[currentPartition]); u32 needed = 0; @@ -374,7 +374,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op) else { char source[300]; - snprintf(source, sizeof(source), "%s/%s", sfmt((currentPartition != SD) ? m_DMLgameDir.c_str() : DML_DIR, DeviceName[currentPartition]).c_str(), (char *)m_cf.getHdr()->path); + snprintf(source, sizeof(source), "%s/%s", fmt((currentPartition != SD) ? m_DMLgameDir.c_str() : DML_DIR, DeviceName[currentPartition]), (char *)m_cf.getHdr()->path); fsop_deleteFolder(source); upd_dml = true; } diff --git a/source/plugin/plugin.cpp b/source/plugin/plugin.cpp index dfab8f4d..8dba60f3 100644 --- a/source/plugin/plugin.cpp +++ b/source/plugin/plugin.cpp @@ -126,7 +126,7 @@ safe_vector Plugin::ParseScummvmINI(Config &ini, string Device) safe_vector gameHeader; if(!ini.loaded()) return gameHeader; - string game = ini.firstDomain().c_str(); + string game(ini.firstDomain()); dir_discHdr tmp; while(1) {