mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-25 03:11:58 +01:00
-added proper banner caching using the wiiflow/cache folder, that
means we can properly see if cached or custom banner is loaded -corrected bug which didnt copy back the banner md5 before writing banner cache, means all cached banners dont have the security check anymore
This commit is contained in:
parent
e62dcd8a09
commit
24899a421a
@ -62,8 +62,9 @@ Banner::Banner(u8 *bnr, u32 bnr_size, u64 title, bool custom)
|
|||||||
|
|
||||||
memcpy(imetmd5, imet->md5, 16);
|
memcpy(imetmd5, imet->md5, 16);
|
||||||
memset(imet->md5, 0, 16);
|
memset(imet->md5, 0, 16);
|
||||||
|
|
||||||
MD5(md5, (unsigned char*)(imet), sizeof(IMET));
|
MD5(md5, (unsigned char*)(imet), sizeof(IMET));
|
||||||
|
memcpy(imet->md5, imetmd5, 16);
|
||||||
|
|
||||||
if(memcmp(imetmd5, md5, 16) == 0 || custom)
|
if(memcmp(imetmd5, md5, 16) == 0 || custom)
|
||||||
this->imet = imet;
|
this->imet = imet;
|
||||||
else
|
else
|
||||||
|
@ -284,9 +284,17 @@ void CMenu::init(void)
|
|||||||
m_app_update_zip = sfmt("%s/update.zip", m_appDir.c_str());
|
m_app_update_zip = sfmt("%s/update.zip", m_appDir.c_str());
|
||||||
m_data_update_zip = sfmt("%s/update.zip", m_dataDir.c_str());
|
m_data_update_zip = sfmt("%s/update.zip", m_dataDir.c_str());
|
||||||
|
|
||||||
m_bannerDir = m_cfg.getString("GENERAL", "dir_banners", sfmt("%s/banners", m_dataDir.c_str()));
|
m_customBnrDir = m_cfg.getString("GENERAL", "dir_custom_banners", sfmt("%s/custom_banners", m_dataDir.c_str()));
|
||||||
m_pluginsDir = m_cfg.getString("GENERAL", "dir_plugins", sfmt("%s/plugins", m_dataDir.c_str()));
|
m_pluginsDir = m_cfg.getString("GENERAL", "dir_plugins", sfmt("%s/plugins", m_dataDir.c_str()));
|
||||||
|
|
||||||
m_cacheDir = m_cfg.getString("GENERAL", "dir_cache", sfmt("%s/cache", m_dataDir.c_str()));
|
m_cacheDir = m_cfg.getString("GENERAL", "dir_cache", sfmt("%s/cache", m_dataDir.c_str()));
|
||||||
|
m_listCacheDir = m_cfg.getString("GENERAL", "dir_list_cache", sfmt("%s/lists", m_cacheDir.c_str()));
|
||||||
|
m_bnrCacheDir = m_cfg.getString("GENERAL", "dir_banner_cache", sfmt("%s/banners", m_cacheDir.c_str()));
|
||||||
|
|
||||||
|
m_txtCheatDir = m_cfg.getString("GENERAL", "dir_txtcheat", sfmt("%s/codes", m_dataDir.c_str()));
|
||||||
|
m_cheatDir = m_cfg.getString("GENERAL", "dir_cheat", sfmt("%s/gct", m_txtCheatDir.c_str()));
|
||||||
|
m_wipDir = m_cfg.getString("GENERAL", "dir_wip", sfmt("%s/wip", m_txtCheatDir.c_str()));
|
||||||
|
|
||||||
m_settingsDir = m_cfg.getString("GENERAL", "dir_settings", sfmt("%s/settings", m_dataDir.c_str()));
|
m_settingsDir = m_cfg.getString("GENERAL", "dir_settings", sfmt("%s/settings", m_dataDir.c_str()));
|
||||||
m_languagesDir = m_cfg.getString("GENERAL", "dir_languages", sfmt("%s/languages", m_dataDir.c_str()));
|
m_languagesDir = m_cfg.getString("GENERAL", "dir_languages", sfmt("%s/languages", m_dataDir.c_str()));
|
||||||
m_boxPicDir = m_cfg.getString("GENERAL", "dir_box_covers", sfmt("%s/boxcovers", m_dataDir.c_str()));
|
m_boxPicDir = m_cfg.getString("GENERAL", "dir_box_covers", sfmt("%s/boxcovers", m_dataDir.c_str()));
|
||||||
@ -296,10 +304,6 @@ void CMenu::init(void)
|
|||||||
m_videoDir = m_cfg.getString("GENERAL", "dir_trailers", sfmt("%s/trailers", m_dataDir.c_str()));
|
m_videoDir = m_cfg.getString("GENERAL", "dir_trailers", sfmt("%s/trailers", m_dataDir.c_str()));
|
||||||
m_fanartDir = m_cfg.getString("GENERAL", "dir_fanart", sfmt("%s/fanart", m_dataDir.c_str()));
|
m_fanartDir = m_cfg.getString("GENERAL", "dir_fanart", sfmt("%s/fanart", m_dataDir.c_str()));
|
||||||
m_screenshotDir = m_cfg.getString("GENERAL", "dir_screenshot", sfmt("%s/screenshots", m_dataDir.c_str()));
|
m_screenshotDir = m_cfg.getString("GENERAL", "dir_screenshot", sfmt("%s/screenshots", m_dataDir.c_str()));
|
||||||
m_txtCheatDir = m_cfg.getString("GENERAL", "dir_txtcheat", sfmt("%s/codes", m_dataDir.c_str()));
|
|
||||||
m_cheatDir = m_cfg.getString("GENERAL", "dir_cheat", sfmt("%s/gct", m_txtCheatDir.c_str()));
|
|
||||||
m_wipDir = m_cfg.getString("GENERAL", "dir_wip", sfmt("%s/wip", m_txtCheatDir.c_str()));
|
|
||||||
m_listCacheDir = m_cfg.getString("GENERAL", "dir_list_cache", sfmt("%s/lists", m_cacheDir.c_str()));
|
|
||||||
m_helpDir = m_cfg.getString("GENERAL", "dir_help", sfmt("%s/help", m_dataDir.c_str()));
|
m_helpDir = m_cfg.getString("GENERAL", "dir_help", sfmt("%s/help", m_dataDir.c_str()));
|
||||||
|
|
||||||
DeviceHandler::SetWatchdog(m_cfg.getUInt("GENERAL", "watchdog_timeout", 10));
|
DeviceHandler::SetWatchdog(m_cfg.getUInt("GENERAL", "watchdog_timeout", 10));
|
||||||
@ -328,12 +332,22 @@ void CMenu::init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cf.init(m_base_font, m_base_font_size, m_vid.vid_50hz());
|
m_cf.init(m_base_font, m_base_font_size, m_vid.vid_50hz());
|
||||||
|
|
||||||
//Make important folders first.
|
//Make important folders first.
|
||||||
fsop_MakeFolder((char *)m_dataDir.c_str()); //D'OH!
|
fsop_MakeFolder((char *)m_dataDir.c_str()); //D'OH!
|
||||||
|
|
||||||
|
fsop_MakeFolder((char *)m_customBnrDir.c_str());
|
||||||
|
fsop_MakeFolder((char *)m_pluginsDir.c_str());
|
||||||
|
|
||||||
fsop_MakeFolder((char *)m_cacheDir.c_str());
|
fsop_MakeFolder((char *)m_cacheDir.c_str());
|
||||||
|
fsop_MakeFolder((char *)m_listCacheDir.c_str());
|
||||||
|
fsop_MakeFolder((char *)m_bnrCacheDir.c_str());
|
||||||
|
|
||||||
|
fsop_MakeFolder((char *)m_txtCheatDir.c_str());
|
||||||
|
fsop_MakeFolder((char *)m_cheatDir.c_str());
|
||||||
|
fsop_MakeFolder((char *)m_wipDir.c_str());
|
||||||
|
|
||||||
fsop_MakeFolder((char *)m_settingsDir.c_str());
|
fsop_MakeFolder((char *)m_settingsDir.c_str());
|
||||||
fsop_MakeFolder((char *)m_languagesDir.c_str());
|
fsop_MakeFolder((char *)m_languagesDir.c_str());
|
||||||
fsop_MakeFolder((char *)m_boxPicDir.c_str());
|
fsop_MakeFolder((char *)m_boxPicDir.c_str());
|
||||||
@ -343,13 +357,7 @@ void CMenu::init(void)
|
|||||||
fsop_MakeFolder((char *)m_videoDir.c_str());
|
fsop_MakeFolder((char *)m_videoDir.c_str());
|
||||||
fsop_MakeFolder((char *)m_fanartDir.c_str());
|
fsop_MakeFolder((char *)m_fanartDir.c_str());
|
||||||
fsop_MakeFolder((char *)m_screenshotDir.c_str());
|
fsop_MakeFolder((char *)m_screenshotDir.c_str());
|
||||||
fsop_MakeFolder((char *)m_txtCheatDir.c_str());
|
|
||||||
fsop_MakeFolder((char *)m_cheatDir.c_str());
|
|
||||||
fsop_MakeFolder((char *)m_wipDir.c_str());
|
|
||||||
fsop_MakeFolder((char *)m_listCacheDir.c_str());
|
|
||||||
fsop_MakeFolder((char *)m_helpDir.c_str());
|
fsop_MakeFolder((char *)m_helpDir.c_str());
|
||||||
fsop_MakeFolder((char *)m_pluginsDir.c_str());
|
|
||||||
fsop_MakeFolder((char *)m_bannerDir.c_str());
|
|
||||||
|
|
||||||
// INI files
|
// INI files
|
||||||
m_cat.load(fmt("%s/" CAT_FILENAME, m_settingsDir.c_str()));
|
m_cat.load(fmt("%s/" CAT_FILENAME, m_settingsDir.c_str()));
|
||||||
|
@ -89,13 +89,14 @@ private:
|
|||||||
string m_themeDataDir;
|
string m_themeDataDir;
|
||||||
string m_appDir;
|
string m_appDir;
|
||||||
string m_dataDir;
|
string m_dataDir;
|
||||||
string m_bannerDir;
|
|
||||||
string m_pluginsDir;
|
string m_pluginsDir;
|
||||||
|
string m_customBnrDir;
|
||||||
string m_picDir;
|
string m_picDir;
|
||||||
string m_boxPicDir;
|
string m_boxPicDir;
|
||||||
string m_cpicDir;
|
|
||||||
string m_boxcPicDir;
|
string m_boxcPicDir;
|
||||||
string m_cacheDir;
|
string m_cacheDir;
|
||||||
|
string m_listCacheDir;
|
||||||
|
string m_bnrCacheDir;
|
||||||
string m_themeDir;
|
string m_themeDir;
|
||||||
string m_musicDir;
|
string m_musicDir;
|
||||||
string m_txtCheatDir;
|
string m_txtCheatDir;
|
||||||
@ -106,7 +107,6 @@ private:
|
|||||||
string m_screenshotDir;
|
string m_screenshotDir;
|
||||||
string m_settingsDir;
|
string m_settingsDir;
|
||||||
string m_languagesDir;
|
string m_languagesDir;
|
||||||
string m_listCacheDir;
|
|
||||||
string m_DMLgameDir;
|
string m_DMLgameDir;
|
||||||
string m_helpDir;
|
string m_helpDir;
|
||||||
|
|
||||||
|
@ -1523,16 +1523,36 @@ void CMenu::_gameSoundThread(CMenu *m)
|
|||||||
m->m_gamesound_changed = true;
|
m->m_gamesound_changed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool custom = false;
|
|
||||||
|
|
||||||
|
bool custom = false;
|
||||||
u8 *custom_bnr_file = NULL;
|
u8 *custom_bnr_file = NULL;
|
||||||
u32 custom_bnr_size = 0;
|
u32 custom_bnr_size = 0;
|
||||||
|
|
||||||
|
bool cached = false;
|
||||||
|
u8 *cached_bnr_file = NULL;
|
||||||
|
u32 cached_bnr_size = 0;
|
||||||
|
|
||||||
|
char cached_banner[256];
|
||||||
|
snprintf(cached_banner, sizeof(cached_banner), "%s/%.6s.bnr", m->m_bnrCacheDir.c_str(), m->m_cf.getHdr()->id);
|
||||||
|
FILE *fp = fopen(cached_banner, "rb");
|
||||||
|
if(fp)
|
||||||
|
{
|
||||||
|
cached = true;
|
||||||
|
fseek(fp, 0, SEEK_END);
|
||||||
|
cached_bnr_size = ftell(fp);
|
||||||
|
fseek(fp, 0, SEEK_SET);
|
||||||
|
cached_bnr_file = (u8*)MEM2_alloc(cached_bnr_size);
|
||||||
|
fread(cached_bnr_file, 1, cached_bnr_size, fp);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
char custom_banner[256];
|
char custom_banner[256];
|
||||||
snprintf(custom_banner, sizeof(custom_banner), "%s/%.6s.bnr", m->m_bannerDir.c_str(), m->m_cf.getHdr()->id);
|
snprintf(custom_banner, sizeof(custom_banner), "%s/%.6s.bnr", m->m_customBnrDir.c_str(), m->m_cf.getHdr()->id);
|
||||||
FILE *fp = fopen(custom_banner, "rb");
|
FILE *fp = fopen(custom_banner, "rb");
|
||||||
if(!fp)
|
if(!fp)
|
||||||
{
|
{
|
||||||
snprintf(custom_banner, sizeof(custom_banner), "%s/%.3s.bnr", m->m_bannerDir.c_str(), m->m_cf.getHdr()->id);
|
snprintf(custom_banner, sizeof(custom_banner), "%s/%.3s.bnr", m->m_customBnrDir.c_str(), m->m_cf.getHdr()->id);
|
||||||
fp = fopen(custom_banner, "rb");
|
fp = fopen(custom_banner, "rb");
|
||||||
if(!fp && m->m_cf.getHdr()->type == TYPE_GC_GAME)
|
if(!fp && m->m_cf.getHdr()->type == TYPE_GC_GAME)
|
||||||
{
|
{
|
||||||
@ -1553,14 +1573,15 @@ void CMenu::_gameSoundThread(CMenu *m)
|
|||||||
fread(custom_bnr_file, 1, custom_bnr_size, fp);
|
fread(custom_bnr_file, 1, custom_bnr_size, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
m->m_gameSoundHdr = m->m_cf.getHdr();
|
m->m_gameSoundHdr = m->m_cf.getHdr();
|
||||||
m->m_gamesound_changed = false;
|
m->m_gamesound_changed = false;
|
||||||
u32 sndSize = 0;
|
u32 sndSize = 0;
|
||||||
|
|
||||||
Banner *banner = custom_bnr_file != NULL ? new Banner((u8 *)custom_bnr_file, custom_bnr_size, 0, true) :
|
Banner *banner = cached ? new Banner((u8 *)cached_bnr_file, cached_bnr_size) :
|
||||||
|
(custom ? new Banner((u8 *)custom_bnr_file, custom_bnr_size, 0, true) :
|
||||||
(m->m_gameSoundHdr->type == TYPE_WII_GAME ? _extractBnr(m->m_gameSoundHdr) : (m->m_gameSoundHdr->type == TYPE_CHANNEL ?
|
(m->m_gameSoundHdr->type == TYPE_WII_GAME ? _extractBnr(m->m_gameSoundHdr) : (m->m_gameSoundHdr->type == TYPE_CHANNEL ?
|
||||||
_extractChannelBnr(TITLE_ID(m->m_gameSoundHdr->settings[0],m->m_gameSoundHdr->settings[1])) : NULL));
|
_extractChannelBnr(TITLE_ID(m->m_gameSoundHdr->settings[0],m->m_gameSoundHdr->settings[1])) : NULL)));
|
||||||
m->m_gameSoundHdr = NULL;
|
m->m_gameSoundHdr = NULL;
|
||||||
|
|
||||||
if (banner == NULL || !banner->IsValid())
|
if (banner == NULL || !banner->IsValid())
|
||||||
@ -1570,11 +1591,9 @@ void CMenu::_gameSoundThread(CMenu *m)
|
|||||||
delete banner;
|
delete banner;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(!custom)
|
else if(!custom && !cached)
|
||||||
{
|
{
|
||||||
char custom_banner[256];
|
FILE *fp = fopen(cached_banner, "wb");
|
||||||
snprintf(custom_banner, sizeof(custom_banner), "%s/%.6s.bnr", m->m_bannerDir.c_str(), m->m_cf.getHdr()->id);
|
|
||||||
FILE *fp = fopen(custom_banner, "wb");
|
|
||||||
fwrite(banner->GetBannerFile(), 1, banner->GetBannerFileSize(), fp);
|
fwrite(banner->GetBannerFile(), 1, banner->GetBannerFileSize(), fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user