diff --git a/out/bins/ext_booter.bin b/out/bins/ext_booter.bin index cc23978a..c9fddcaa 100644 Binary files a/out/bins/ext_booter.bin and b/out/bins/ext_booter.bin differ diff --git a/out/boot.dol b/out/boot.dol index 6c2d59cc..371f535d 100644 Binary files a/out/boot.dol and b/out/boot.dol differ diff --git a/resources/wiiflow_game_booter/source/main.cpp b/resources/wiiflow_game_booter/source/main.cpp index 1e9515fb..d3e76b05 100644 --- a/resources/wiiflow_game_booter/source/main.cpp +++ b/resources/wiiflow_game_booter/source/main.cpp @@ -97,24 +97,24 @@ int main() Hermes_shadow_mload(); } prog(20); - Disc_Open(normalCFG.GameBootType); + Disc_Open(normalCFG.GameBootType);// sets Disc_ID u32 offset = 0; Disc_FindPartition(&offset); WDVD_OpenPartition(offset, &GameIOS); Disc_SetLowMem(); if(normalCFG.vidMode == 5) normalCFG.patchVidMode = 1; //progressive mode requires this - vmode = Disc_SelectVMode(normalCFG.vidMode, &vmode_reg); + vmode = Disc_SelectVMode(normalCFG.vidMode, &vmode_reg);// requires Disc_ID[3] AppEntrypoint = Apploader_Run(normalCFG.vidMode, vmode, normalCFG.vipatch, normalCFG.countryString, normalCFG.patchVidMode, normalCFG.aspectRatio, normalCFG.returnTo, normalCFG.patchregion, normalCFG.private_server, normalCFG.server_addr, normalCFG.patchFix480p, normalCFG.deflicker, normalCFG.BootType); WDVD_Close(); } else if(normalCFG.BootType == TYPE_CHANNEL) { - vmode = Disc_SelectVMode(normalCFG.vidMode, &vmode_reg); ISFS_Initialize(); - AppEntrypoint = LoadChannel(normalCFG.title, normalCFG.use_dol, &GameIOS); + AppEntrypoint = LoadChannel(normalCFG.title, normalCFG.use_dol, &GameIOS);// sets Disc_ID ISFS_Deinitialize(); + vmode = Disc_SelectVMode(normalCFG.vidMode, &vmode_reg);// requires Disc_ID[3] PatchChannel(normalCFG.vidMode, vmode, normalCFG.vipatch, normalCFG.countryString, normalCFG.patchVidMode, normalCFG.aspectRatio, normalCFG.returnTo, normalCFG.private_server, normalCFG.server_addr, normalCFG.patchFix480p, normalCFG.deflicker, normalCFG.BootType); } diff --git a/source/defines.h b/source/defines.h index 9bcce557..75facb3d 100644 --- a/source/defines.h +++ b/source/defines.h @@ -1,6 +1,6 @@ #define APP_NAME "WiiFlow WFL" -#define APP_VERSION "5.5.0" +#define APP_VERSION "5.5.1" #define APP_DATA_DIR "wiiflow" #define APPS_DIR "apps/wiiflow" diff --git a/source/devicemounter/PartitionHandle.cpp b/source/devicemounter/PartitionHandle.cpp index 061529c3..c02ec406 100644 --- a/source/devicemounter/PartitionHandle.cpp +++ b/source/devicemounter/PartitionHandle.cpp @@ -125,7 +125,7 @@ bool PartitionHandle::Mount(int pos, const char *name, bool forceFAT) if(valid(pos)) UnMount(pos); - if(!name) + if(!name || strlen(name) > 8) return false; if(pos >= (int)MountNameList.size()) @@ -133,9 +133,8 @@ bool PartitionHandle::Mount(int pos, const char *name, bool forceFAT) MountNameList[pos] = name; char DeviceSyn[10]; - memcpy(DeviceSyn, name, 8); + strcpy(DeviceSyn, name); strcat(DeviceSyn, ":"); - DeviceSyn[9] = '\0'; //! Some stupid partition manager think they don't need to edit the freaken MBR. //! So we need to check the first 64 sectors and see if some partition is there. diff --git a/source/gui/coverflow.cpp b/source/gui/coverflow.cpp index 1ce11600..aa9f9891 100644 --- a/source/gui/coverflow.cpp +++ b/source/gui/coverflow.cpp @@ -204,7 +204,6 @@ CCoverFlow::CCoverFlow(void) m_compressTextures = true; m_compressCache = false; m_deletePicsAfterCaching = false; - m_pluginCacheFolders = false; m_box = true; m_smallBox = false; m_useHQcover = false; @@ -263,10 +262,9 @@ CCoverFlow::~CCoverFlow(void) LWP_MutexDestroy(m_mutex); } -void CCoverFlow::setCachePath(const char *path, bool pluginCacheFolders) +void CCoverFlow::setCachePath(const char *path) { m_cachePath = path; - m_pluginCacheFolders = pluginCacheFolders; } void CCoverFlow::setTextureQuality(float lodBias, int aniso, bool edgeLOD) @@ -2769,7 +2767,7 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank strncpy(wfcTitle, fmt("%s", getFilenameId(m_items[i].hdr)), sizeof(wfcTitle) - 1); /* get coverfolder for plugins, sourceflow, and homebrew */ - if(m_items[i].hdr->type == TYPE_PLUGIN && m_pluginCacheFolders) + if(m_items[i].hdr->type == TYPE_PLUGIN) wfcCoverDir = m_plugin.GetCoverFolderName(m_items[i].hdr->settings[0]); if(m_items[i].hdr->type == TYPE_SOURCE) wfcCoverDir = "sourceflow"; @@ -2782,7 +2780,17 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank if(m_smallBox) strncpy(full_path, fmt("%s/%s/%s_small.wfc", m_cachePath.c_str(), wfcCoverDir, wfcTitle), MAX_FAT_PATH); else + { strncpy(full_path, fmt("%s/%s/%s.wfc", m_cachePath.c_str(), wfcCoverDir, wfcTitle), MAX_FAT_PATH); + /*if(!fsop_FileExist(full_path)) + { + if(strrchr(wfcTitle, '.') != NULL) + { + *strrchr(wfcTitle, '.') = '\0'; + strncpy(full_path, fmt("%s/%s/%s.wfc", m_cachePath.c_str(), wfcCoverDir, wfcTitle), MAX_FAT_PATH); + } + }*/ + } } else { diff --git a/source/gui/coverflow.hpp b/source/gui/coverflow.hpp index 56bc4e11..ca9fff98 100644 --- a/source/gui/coverflow.hpp +++ b/source/gui/coverflow.hpp @@ -126,7 +126,7 @@ class CCoverFlow void stopSound(void); // void applySettings(void); - void setCachePath(const char *path, bool pluginCacheFolders); + void setCachePath(const char *path); bool fullCoverCached(const char *wfcPath); bool cacheCoverBuffer(const char *wfcPath, const u8 *png, bool full); bool cacheCoverFile(const char *wfcPath, const char *coverPath, bool full); @@ -289,7 +289,6 @@ class CCoverFlow bool m_compressCache; std::string m_cachePath; bool m_deletePicsAfterCaching; - bool m_pluginCacheFolders; bool m_mirrorBlur; float m_mirrorAlpha; float m_txtMirrorAlpha; diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 04181806..216f0a7c 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -670,7 +670,7 @@ void CMenu::_loadCFCfg() const char *domain = "_COVERFLOW"; //gprintf("Preparing to load sounds from %s\n", m_themeDataDir.c_str()); - CoverFlow.setCachePath(m_cacheDir.c_str(), m_cfg.getBool(PLUGIN_DOMAIN, "subfolder_cache", true)); + CoverFlow.setCachePath(m_cacheDir.c_str()); CoverFlow.setBufferSize(m_cfg.getInt("GENERAL", "cover_buffer", 20)); // Coverflow Sounds CoverFlow.setSounds( @@ -2633,7 +2633,7 @@ bool CMenu::_loadPluginList() void CMenu::_stopSounds(void) { // Fade out sounds - int fade_rate = m_cfg.getInt("GENERAL", "music_fade_rate", 8); + int fade_rate = 20; if(!MusicPlayer.IsStopped()) { @@ -2885,14 +2885,14 @@ const char *CMenu::getBoxPath(const dir_discHdr *element) { if(element->type == TYPE_PLUGIN) { - const char *tempname = element->path; - if(strchr(element->path, '/') != NULL) - tempname = strrchr(element->path, '/') + 1; + const char *filename = fmt("%s", element->path); + if(strchr(filename, '/') != NULL) + { + filename = fmt("%s", strrchr(element->path, '/') + 1); + } + const char *coverFolder = m_plugin.GetCoverFolderName(element->settings[0]); - if(strlen(coverFolder) > 0) - return fmt("%s/%s/%s.png", m_boxPicDir.c_str(), coverFolder, tempname); - else - return fmt("%s/%s.png", m_boxPicDir.c_str(), tempname); + return fmt("%s/%s/%s.png", m_boxPicDir.c_str(), coverFolder, filename); } else if(element->type == TYPE_HOMEBREW)// use folder name for the png name return fmt("%s/homebrew/%s.png", m_boxPicDir.c_str(), strrchr(element->path, '/') + 1); diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 08ce49b1..884c96be 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -41,7 +41,7 @@ void CMenu::_extractBnr(const dir_discHdr *hdr) void CMenu::_setCurrentItem(const dir_discHdr *hdr) { - const char *title = CoverFlow.getFilenameId(hdr); + const char *fn_id = CoverFlow.getFilenameId(hdr); if(m_current_view == COVERFLOW_PLUGIN) { if(hdr->type == TYPE_PLUGIN) @@ -60,11 +60,11 @@ void CMenu::_setCurrentItem(const dir_discHdr *hdr) strncpy(m_plugin.PluginMagicWord, "48425257", 9); } m_cfg.setString(PLUGIN_DOMAIN, "cur_magic", m_plugin.PluginMagicWord); - m_cfg.setString("plugin_item", m_plugin.PluginMagicWord, title); + m_cfg.setString("plugin_item", m_plugin.PluginMagicWord, fn_id); } else { - m_cfg.setString(_domainFromView(), "current_item", title); + m_cfg.setString(_domainFromView(), "current_item", fn_id); if(m_source_cnt > 1) m_cfg.setInt("MULTI", "current_item_type", hdr->type); } @@ -100,16 +100,16 @@ void CMenu::_hideGame(bool instant) void CMenu::_showGame(void) { const dir_discHdr *GameHdr = CoverFlow.getHdr(); - const char *coverDir = NULL; const char *FanartPath = NULL; - if(GameHdr->type == TYPE_PLUGIN) - coverDir = m_plugin.GetCoverFolderName(GameHdr->settings[0]); - if(coverDir == NULL || strlen(coverDir) == 0) - FanartPath = fmt("%s", m_fanartDir.c_str()); + /* set fanart path */ + if(GameHdr->type == TYPE_PLUGIN) + FanartPath = fmt("%s/%s", m_fanartDir.c_str(), m_plugin.GetCoverFolderName(GameHdr->settings[0])); else - FanartPath = fmt("%s/%s", m_fanartDir.c_str(), coverDir); - if(m_fa.load(m_cfg, FanartPath, CoverFlow.getHdr())) + FanartPath = fmt("%s", m_fanartDir.c_str()); + + /* Load fanart config if available */ + if(m_fa.load(m_cfg, FanartPath, GameHdr)) { const TexData *bg = NULL; const TexData *bglq = NULL; @@ -117,7 +117,7 @@ void CMenu::_showGame(void) _setBg(*bg, *bglq); CoverFlow.hideCover(); } - else + else // no fanart config so we show the cover and game menu background { CoverFlow.showCover(); if(customBg) @@ -143,57 +143,39 @@ void CMenu::_cleanupVideo() movie.DeInit(); } -static const char *getVideoPath(const string &videoDir, const char *videoId) -{ - const char *coverDir = NULL; - const char *videoPath = NULL; - if(CoverFlow.getHdr()->type == TYPE_PLUGIN) - coverDir = m_plugin.GetCoverFolderName(CoverFlow.getHdr()->settings[0]); - - if(coverDir == NULL || strlen(coverDir) == 0) - videoPath = fmt("%s/%s", videoDir.c_str(), videoId); - else - videoPath = fmt("%s/%s/%s", videoDir.c_str(), coverDir, videoId); - return videoPath; -} - -static const char *getVideoDefaultPath(const string &videoDir) -{ - //strncpy(m_plugin.PluginMagicWord, fmt("%08x", CoverFlow.getHdr()->settings[0]), 8); - const char *videoPath = fmt("%s/%s", videoDir.c_str(), m_plugin.PluginMagicWord); - return videoPath; -} - bool CMenu::_startVideo() { const dir_discHdr *GameHdr = CoverFlow.getHdr(); + const char *videoPath = NULL; + const char *THP_Path = NULL; - const char *videoId = NULL; - char curId3[4]; - memset(curId3, 0, 4); - if(!NoGameID(GameHdr->type)) - { //id3 - memcpy(curId3, GameHdr->id, 3); - videoId = curId3; - } - else - videoId = CoverFlow.getFilenameId(GameHdr);//title.ext - - //dev:/wiiflow/trailers/{coverfolder}/title.ext.thp or dev:/wiiflow/trailers/id3.thp - const char *videoPath = getVideoPath(m_videoDir, videoId); - const char *THP_Path = fmt("%s.thp", videoPath); - if(!fsop_FileExist(THP_Path)) + if(GameHdr->type == TYPE_PLUGIN) { - if(GameHdr->type == TYPE_PLUGIN) + const char *fn = CoverFlow.getFilenameId(GameHdr);//title.ext + const char *coverDir = m_plugin.GetCoverFolderName(GameHdr->settings[0]); + videoPath = fmt("%s/%s/%s", m_videoDir.c_str(), coverDir, fn); + THP_Path = fmt("%s.thp", videoPath); + if(!fsop_FileExist(THP_Path)) { - //dev:/wiiflow/trailers/magic#.thp - videoPath = getVideoDefaultPath(m_videoDir); - THP_Path = fmt("%s.thp", videoPath); + if(strrchr(videoPath, '.') != NULL) + { + *strrchr(videoPath, '.') = '\0'; + THP_Path = fmt("%s.thp", videoPath); + } + if(!fsop_FileExist(THP_Path))//default video for all games of this plugin + { + videoPath = fmt("%s/%s", m_videoDir.c_str(), m_plugin.PluginMagicWord);// use magic number as the filename + THP_Path = fmt("%s.thp", videoPath); + } } - else if(!NoGameID(GameHdr->type)) + } + else + { + videoPath = fmt("%s/%s.3", m_videoDir.c_str(), GameHdr->id);// try id3 first + THP_Path = fmt("%s.thp", videoPath); + if(!fsop_FileExist(THP_Path)) { - //id6 - videoPath = getVideoPath(m_videoDir, GameHdr->id); + videoPath = fmt("%s/%s", m_videoDir.c_str(), GameHdr->id); THP_Path = fmt("%s.thp", videoPath); } } @@ -880,27 +862,31 @@ void * CMenu::_gameSoundThread(void *obj) char cached_banner[256]; cached_banner[255] = '\0'; - /* plugin individual game sound */ - char game_sound[256]; - game_sound[255] = '\0'; - const dir_discHdr *GameHdr = CoverFlow.getHdr(); if(GameHdr->type == TYPE_PLUGIN) { - const char *coverDir = NULL; - coverDir = m_plugin.GetCoverFolderName(GameHdr->settings[0]); + char game_sound[256]; + game_sound[255] = '\0'; + char fileNameFull[128]; + fileNameFull[127] = '\0'; + char fileName[128]; + fileName[127] = '\0'; + + strncpy(fileNameFull, CoverFlow.getFilenameId(GameHdr), sizeof(fileNameFull) - 1); + strcpy(fileName, fileNameFull); + if(strrchr(fileName, '.') != NULL) + *strrchr(fileName, '.') = '\0';// remove .ext - if(coverDir == NULL || strlen(coverDir) == 0) - { - strncpy(custom_banner, fmt("%s/%s.bnr", m->m_customBnrDir.c_str(), CoverFlow.getFilenameId(GameHdr)), 255); - strncpy(game_sound, fmt("%s/gamesounds/%s", m->m_dataDir.c_str(), CoverFlow.getFilenameId(GameHdr)), 251);//save for .ext - } - else - { - strncpy(custom_banner, fmt("%s/%s/%s.bnr", m->m_customBnrDir.c_str(), coverDir, CoverFlow.getFilenameId(GameHdr)), 255); - strncpy(game_sound, fmt("%s/gamesounds/%s/%s", m->m_dataDir.c_str(), coverDir, CoverFlow.getFilenameId(GameHdr)), 251); - } + const char *coverDir = m_plugin.GetCoverFolderName(GameHdr->settings[0]); + + strncpy(custom_banner, fmt("%s/%s/%s.bnr", m->m_customBnrDir.c_str(), coverDir, fileNameFull), sizeof(custom_banner) - 1); + if(!fsop_FileExist(custom_banner)) + strncpy(custom_banner, fmt("%s/%s/%s.bnr", m->m_customBnrDir.c_str(), coverDir, fileName), sizeof(custom_banner) - 1); + + strncpy(game_sound, fmt("%s/gamesounds/%s/%s", m->m_dataDir.c_str(), coverDir, fileNameFull), sizeof(game_sound) - 1); + if(!fsop_FileExist(game_sound)) + strncpy(game_sound, fmt("%s/gamesounds/%s/%s", m->m_dataDir.c_str(), coverDir, fileName), sizeof(game_sound) - 1); /* get plugin rom custom banner */ fsop_GetFileSizeBytes(custom_banner, &custom_bnr_size); @@ -916,17 +902,16 @@ void * CMenu::_gameSoundThread(void *obj) /* if no banner try getting snap shot */ if((custom_bnr_size == 0 || custom_bnr_file == NULL) && m->m_platform.loaded()) { - gprintf("trying to get snapshot\n"); + //gprintf("trying to get snapshot\n"); m_banner.DeleteBanner(); char GameID[7]; - GameID[6] = '\0'; - char platformName[264]; + char platformName[16]; const char *TMP_Char = NULL; GameTDB gametdb; strncpy(m_plugin.PluginMagicWord, fmt("%08x", GameHdr->settings[0]), 8); - snprintf(platformName, sizeof(platformName), "%s", m->m_platform.getString("PLUGINS", m_plugin.PluginMagicWord).c_str()); - strcpy(GameID, GameHdr->id); + snprintf(platformName, sizeof(platformName), "%s", m->m_platform.getString("PLUGINS", m_plugin.PluginMagicWord, "").c_str()); + strcpy(GameID, GameHdr->id);// GameHdr->id is null terminated if(strlen(platformName) != 0 && strcasecmp(GameID, "PLUGIN") != 0) { @@ -949,8 +934,8 @@ void * CMenu::_gameSoundThread(void *obj) else { char title[64]; - wcstombs(title, GameHdr->title, 63); title[63] = '\0'; + wcstombs(title, GameHdr->title, sizeof(title) - 1); ShortName = title; } @@ -1009,11 +994,7 @@ void * CMenu::_gameSoundThread(void *obj) TexHandle.Cleanup(m->m_game_snap); TexHandle.Cleanup(m->m_game_overlay); } - } - if(custom_bnr_size == 0 || custom_bnr_file == NULL) - { /* try to get plugin rom gamesound or just the default plugin gamesound */ - m_banner.DeleteBanner(); bool found = false; if(fsop_FileExist(fmt("%s.mp3", game_sound))) { @@ -1040,9 +1021,6 @@ void * CMenu::_gameSoundThread(void *obj) m->m_gameSound.Load(m_plugin.GetBannerSound(GameHdr->settings[0]), m_plugin.GetBannerSoundSize()); if(m->m_gameSound.IsLoaded()) m->m_gamesound_changed = true; - } - if(custom_bnr_size == 0 || custom_bnr_file == NULL)// no custom banner so we are done. exit sound thread. - { m->m_soundThrdBusy = false; return NULL; } diff --git a/source/menu/menu_home.cpp b/source/menu/menu_home.cpp index 031f9b5b..6e7a4dac 100644 --- a/source/menu/menu_home.cpp +++ b/source/menu/menu_home.cpp @@ -524,7 +524,6 @@ int CMenu::_sfCacheCoversNeeded()// for sourceflow int CMenu::_cacheCovers() { CoverFlow.stopCoverLoader(true); - bool m_pluginCacheFolders = m_cfg.getBool(PLUGIN_DOMAIN, "subfolder_cache", true); char coverPath[MAX_FAT_PATH];//1024 char wfcPath[MAX_FAT_PATH+20]; @@ -574,7 +573,7 @@ int CMenu::_cacheCovers() } /* get cache folder path */ - if(hdr->type == TYPE_PLUGIN && m_pluginCacheFolders) + if(hdr->type == TYPE_PLUGIN) snprintf(cachePath, sizeof(cachePath), "%s/%s", m_cacheDir.c_str(), m_plugin.GetCoverFolderName(hdr->settings[0])); else if(m_sourceflow) snprintf(cachePath, sizeof(cachePath), "%s/sourceflow", m_cacheDir.c_str()); diff --git a/source/plugin/plugin.cpp b/source/plugin/plugin.cpp index 246e0e92..d7d424c8 100644 --- a/source/plugin/plugin.cpp +++ b/source/plugin/plugin.cpp @@ -70,13 +70,12 @@ void Plugin::init(const string& m_pluginsDir) continue; m_plugin_cfg.load(iniFile->c_str()); if(m_plugin_cfg.loaded() && Plugins.size() < 255)// max plugins count = 255 - { m_plugin.AddPlugin(m_plugin_cfg, *iniFile); - } + m_plugin_cfg.unload(); } + std::sort(Plugins.begin(), Plugins.end(), PluginOptions_cmp); } - std::sort(Plugins.begin(), Plugins.end(), PluginOptions_cmp); } void Plugin::Cleanup() @@ -87,11 +86,14 @@ void Plugin::Cleanup() void Plugin::AddPlugin(Config &plugin, const string &iniPath) { PluginOptions NewPlugin; + string magic = plugin.getString(PLUGIN, "magic", ""); + if(magic.empty())// no magic number don't add to list. + return; NewPlugin.path = iniPath; NewPlugin.DolName = plugin.getString(PLUGIN, "dolFile"); - NewPlugin.coverFolder = plugin.getString(PLUGIN, "coverFolder"); - NewPlugin.magic = strtoul(plugin.getString(PLUGIN, "magic").c_str(), NULL, 16); - NewPlugin.caseColor = strtoul(plugin.getString(PLUGIN, "coverColor").c_str(), NULL, 16); + NewPlugin.coverFolder = plugin.getString(PLUGIN, "coverFolder", magic);// no coverfolder use magic as folder name + NewPlugin.magic = strtoul(magic.c_str(), NULL, 16); + NewPlugin.caseColor = strtoul(plugin.getString(PLUGIN, "coverColor", "000000").c_str(), NULL, 16); NewPlugin.romPartition = plugin.getInt(PLUGIN, "rompartition", -1); NewPlugin.romDir = plugin.getString(PLUGIN, "romDir"); NewPlugin.fileTypes = plugin.getString(PLUGIN, "fileTypes");