mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-23 19:59:16 +01:00
-added more security checks and mechanisms to wiiflow to increase stability
This commit is contained in:
parent
f036c92c45
commit
a780efc0cd
@ -35,6 +35,7 @@
|
||||
#include "nand.hpp"
|
||||
#include "config/config.hpp"
|
||||
#include "gecko/gecko.hpp"
|
||||
#include "gui/fmt.h"
|
||||
#include "gui/text.hpp"
|
||||
#include "loader/fs.h"
|
||||
#include "loader/nk.h"
|
||||
@ -73,7 +74,7 @@ u8 Channels::GetRequestedIOS(u64 title)
|
||||
else
|
||||
{
|
||||
char tmd[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
||||
sprintf(tmd, "/title/%08x/%08x/content/title.tmd", TITLE_UPPER(title), TITLE_LOWER(title));
|
||||
strncpy(tmd, fmt("/title/%08x/%08x/content/title.tmd", TITLE_UPPER(title), TITLE_LOWER(title)), ISFS_MAXPATH);
|
||||
titleTMD = ISFS_GetFile(tmd, &size, -1);
|
||||
}
|
||||
if(titleTMD == NULL)
|
||||
@ -117,12 +118,15 @@ bool Channels::GetAppNameFromTmd(u64 title, char *app, u32 *bootcontent)
|
||||
else
|
||||
{
|
||||
char tmd[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
||||
sprintf(tmd, "/title/%08x/%08x/content/title.tmd", TITLE_UPPER(title), TITLE_LOWER(title));
|
||||
strncpy(tmd, fmt("/title/%08x/%08x/content/title.tmd", TITLE_UPPER(title), TITLE_LOWER(title)), ISFS_MAXPATH);
|
||||
data = ISFS_GetFile(tmd, &size, -1);
|
||||
}
|
||||
if (data == NULL || size < 0x208)
|
||||
if(data == NULL || size < 0x208)
|
||||
{
|
||||
if(data != NULL)
|
||||
free(data);
|
||||
return ret;
|
||||
|
||||
}
|
||||
_tmd *tmd_file = (_tmd *)SIGNATURE_PAYLOAD((u32 *)data);
|
||||
u16 i;
|
||||
for(i = 0; i < tmd_file->num_contents; ++i)
|
||||
@ -130,7 +134,8 @@ bool Channels::GetAppNameFromTmd(u64 title, char *app, u32 *bootcontent)
|
||||
if(tmd_file->contents[i].index == 0)
|
||||
{
|
||||
*bootcontent = tmd_file->contents[i].cid;
|
||||
sprintf(app, "/title/%08x/%08x/content/%08x.app", TITLE_UPPER(title), TITLE_LOWER(title), *bootcontent);
|
||||
strncpy(app, fmt("/title/%08x/%08x/content/%08x.app",
|
||||
TITLE_UPPER(title), TITLE_LOWER(title), *bootcontent), ISFS_MAXPATH);
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1079,12 +1079,19 @@ void Nand::Patch_AHB()
|
||||
|
||||
u8 *Nand::GetEmuFile(const char *path, u32 *size, s32 len)
|
||||
{
|
||||
u32 filesize = 0;
|
||||
const char *tmp_path = fmt("%s%s", FullNANDPath, path);
|
||||
bool ret = fsop_GetFileSizeBytes(tmp_path, &filesize);
|
||||
if(ret == false || filesize == 0)
|
||||
if(path == NULL)
|
||||
return NULL;
|
||||
|
||||
char *tmp_path = fmt_malloc("%s%s", FullNANDPath, path);
|
||||
if(tmp_path == NULL)
|
||||
return NULL;
|
||||
u32 filesize = 0;
|
||||
bool ret = fsop_GetFileSizeBytes(tmp_path, &filesize);
|
||||
if(ret == false || filesize == 0)
|
||||
{
|
||||
MEM2_free(tmp_path);
|
||||
return NULL;
|
||||
}
|
||||
if(len > 0)
|
||||
filesize = min(filesize, (u32)len);
|
||||
u8 *tmp_buf = (u8*)MEM2_alloc(filesize);
|
||||
@ -1092,6 +1099,7 @@ u8 *Nand::GetEmuFile(const char *path, u32 *size, s32 len)
|
||||
fread(tmp_buf, filesize, 1, f);
|
||||
fclose(f);
|
||||
|
||||
MEM2_free(tmp_path);
|
||||
DCFlushRange(tmp_buf, filesize);
|
||||
*size = filesize;
|
||||
return tmp_buf;
|
||||
@ -1118,11 +1126,15 @@ u64 *Nand::GetChannels(u32 *count)
|
||||
|
||||
u8 *Nand::GetTMD(u64 title, u32 *size)
|
||||
{
|
||||
u8 *tmd_buf = NULL;
|
||||
u32 tmd_size = 0;
|
||||
const char *tmd_path = fmt("/title/%08x/%08x/content/title.tmd",
|
||||
char *tmd_path = fmt_malloc("/title/%08x/%08x/content/title.tmd",
|
||||
TITLE_UPPER(title), TITLE_LOWER(title));
|
||||
u8 *tmd_buf = GetEmuFile(tmd_path, &tmd_size);
|
||||
|
||||
if(tmd_path != NULL)
|
||||
{
|
||||
tmd_buf = GetEmuFile(tmd_path, &tmd_size);
|
||||
MEM2_free(tmd_path);
|
||||
}
|
||||
*size = tmd_size;
|
||||
return tmd_buf;
|
||||
}
|
||||
|
@ -132,7 +132,11 @@ bool PartitionHandle::Mount(int pos, const char *name, bool forceFAT)
|
||||
MountNameList.resize(pos + 1);
|
||||
|
||||
MountNameList[pos] = name;
|
||||
const char *DeviceSyn = fmt("%s:", name);
|
||||
char DeviceSyn[10];
|
||||
memcpy(DeviceSyn, name, 8);
|
||||
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.
|
||||
//! libfat does that by default so let's use it.
|
||||
@ -202,7 +206,11 @@ void PartitionHandle::UnMount(int pos)
|
||||
return;
|
||||
|
||||
WBFS_Close();
|
||||
const char *DeviceSyn = fmt("%s:", MountName(pos));
|
||||
char DeviceSyn[10];
|
||||
memcpy(DeviceSyn, MountName(pos), 8);
|
||||
strcat(DeviceSyn, ":");
|
||||
DeviceSyn[9] = '\0';
|
||||
|
||||
if(strncmp(GetFSName(pos), "WBFS", 4) == 0)
|
||||
{
|
||||
wbfs_t *wbfshandle = GetWbfsHandle(pos);
|
||||
|
@ -42,9 +42,13 @@ void GC_Disc::init(const char *path)
|
||||
*strrchr(GamePath, '/') = '\0';
|
||||
if(strchr(GamePath, '/') != NULL) //sys
|
||||
*strrchr(GamePath, '/') = '\0';
|
||||
const char *FstPath = fmt("%s/sys/fst.bin", GamePath);
|
||||
char *FstPath = fmt_malloc("%s/sys/fst.bin", GamePath);
|
||||
if(FstPath != NULL)
|
||||
{
|
||||
fsop_GetFileSizeBytes(FstPath, &FSTSize);
|
||||
f = fopen(FstPath, "rb");
|
||||
MEM2_free(FstPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "boxmesh.hpp"
|
||||
#include "text.hpp"
|
||||
#include "gecko/gecko.hpp"
|
||||
|
||||
#include "memory/mem2.hpp"
|
||||
using namespace std;
|
||||
|
||||
static guVector _GRRaxisx = (guVector){1, 0, 0}; // DO NOT MODIFY!!!
|
||||
@ -184,9 +184,12 @@ CFanartElement::CFanartElement(Config &cfg, const char *dir, int artwork)
|
||||
: m_artwork(artwork), m_isValid(false)
|
||||
{
|
||||
m_isValid = (TexHandle.fromImageFile(m_art, fmt("%s/artwork%d.png", dir, artwork)) == TE_OK);
|
||||
if (!m_isValid) return;
|
||||
if(!m_isValid)
|
||||
return;
|
||||
|
||||
const char *section = fmt("artwork%d", artwork);
|
||||
char *section = fmt_malloc("artwork%d", artwork);
|
||||
if(section == NULL)
|
||||
return;
|
||||
|
||||
m_show_on_top = cfg.getBool(section, "show_on_top", true);
|
||||
|
||||
@ -212,6 +215,8 @@ CFanartElement::CFanartElement(Config &cfg, const char *dir, int artwork)
|
||||
m_step_scaleY = m_event_duration == 0 ? 0 : (m_scaleY - m_event_scaleY) / m_event_duration;
|
||||
m_step_alpha = m_event_duration == 0 ? 0 : (m_alpha - m_event_alpha) / m_event_duration;
|
||||
m_step_angle = m_event_duration == 0 ? 0 : (m_angle - m_event_angle) / m_event_duration;
|
||||
|
||||
MEM2_free(section);
|
||||
}
|
||||
|
||||
void CFanartElement::Cleanup(void)
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "memory/mem2.hpp"
|
||||
|
||||
int currentStr = 0;
|
||||
static char fmt_buffer[MAX_USES][MAX_MSG_SIZE];
|
||||
@ -19,6 +20,22 @@ char *fmt(const char *format, ...)
|
||||
return fmt_buffer[currentStr];
|
||||
}
|
||||
|
||||
char *fmt_malloc(const char *format, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
|
||||
char *new_buffer = (char*)MEM2_alloc(MAX_MSG_SIZE);
|
||||
if(new_buffer != NULL)
|
||||
{
|
||||
vsnprintf(new_buffer, MAX_MSG_SIZE - 1, format, va);
|
||||
new_buffer[MAX_MSG_SIZE - 1] = '\0';
|
||||
}
|
||||
|
||||
va_end(va);
|
||||
return new_buffer;
|
||||
}
|
||||
|
||||
void Asciify(wchar_t *str)
|
||||
{
|
||||
const wchar_t *ptr = str;
|
||||
|
@ -14,6 +14,7 @@ enum {
|
||||
};
|
||||
|
||||
char *fmt(const char *format, ...);
|
||||
char *fmt_malloc(const char *format, ...);
|
||||
void Asciify(wchar_t *str);
|
||||
void Asciify2(char *str);
|
||||
|
||||
|
@ -566,7 +566,6 @@ const char *CMenu::_cfDomain(bool selected)
|
||||
void CMenu::_initCFThemeMenu()
|
||||
{
|
||||
TexData emptyTex;
|
||||
string domain;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
@ -581,12 +580,14 @@ void CMenu::_initCFThemeMenu()
|
||||
//
|
||||
for (int i = 0; i < 16; ++i)
|
||||
{
|
||||
domain = fmt("CFTHEME/VAL%i%c_%%s", i / 3 + 1, (char)(i % 3) + 'A');
|
||||
char *domain = fmt_malloc("CFTHEME/VAL%i%c_%%s", i / 3 + 1, (char)(i % 3) + 'A');
|
||||
if(domain == NULL) continue;
|
||||
x = 20 + (i / 4) * 150;
|
||||
y = 340 + (i % 4) * 32;
|
||||
m_cfThemeLblVal[i] = _addLabel(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(fmt(domain.c_str(), "MINUS"), theme.btnTexMinus, theme.btnTexMinusS, x, y, 32, 32);
|
||||
m_cfThemeBtnValP[i] = _addPicButton(fmt(domain.c_str(), "PLUS"), theme.btnTexPlus, theme.btnTexPlusS, x + 118, y, 32, 32);
|
||||
m_cfThemeLblVal[i] = _addLabel(fmt(domain, "BTN"), theme.btnFont, L"", x + 32, y, 86, 32, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
|
||||
m_cfThemeBtnValM[i] = _addPicButton(fmt(domain, "MINUS"), theme.btnTexMinus, theme.btnTexMinusS, x, y, 32, 32);
|
||||
m_cfThemeBtnValP[i] = _addPicButton(fmt(domain, "PLUS"), theme.btnTexPlus, theme.btnTexPlusS, x + 118, y, 32, 32);
|
||||
MEM2_free(domain);
|
||||
}
|
||||
for (int i = 0; i < 4; ++i)
|
||||
m_cfThemeLblValTxt[i] = _addLabel(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);
|
||||
|
@ -207,7 +207,8 @@ void CMenu::_initCodeMenu()
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
const char *codeText = fmt("CODE/%i_BTN", i);
|
||||
char *codeText = fmt_malloc("CODE/%i_BTN", i);
|
||||
if(codeText == NULL) continue;
|
||||
if (i > 0)
|
||||
{
|
||||
int x = i - 1;
|
||||
@ -218,6 +219,7 @@ void CMenu::_initCodeMenu()
|
||||
m_codeBtnKey[i] = _addButton(codeText, theme.btnFont, wfmt(L"%i", i), x, y, 100, 50, theme.btnFontColor);
|
||||
}
|
||||
_setHideAnim(m_codeBtnKey[i], codeText, 0, 0, 0.f, 0.f);
|
||||
MEM2_free(codeText);
|
||||
}
|
||||
_setHideAnim(m_codeBtnErase, "CODE/ERASE_BTN", 0, 0, -2.f, 0.f);
|
||||
_setHideAnim(m_codeBtnBack, "CODE/BACK_BTN", 0, 0, -2.f, 0.f);
|
||||
|
@ -437,7 +437,6 @@ int CMenu::_initNetwork()
|
||||
|
||||
int CMenu::_coverDownloader(bool missingOnly)
|
||||
{
|
||||
string path;
|
||||
vector<string> coverList;
|
||||
vector<dir_discHdr> pluginCoverList;
|
||||
|
||||
@ -484,28 +483,33 @@ int CMenu::_coverDownloader(bool missingOnly)
|
||||
_setThrdMsg(_t("dlmsg7", L"Listing covers to download..."), listWeight * (float)step / (float)nbSteps);
|
||||
LWP_MutexUnlock(m_mutex);
|
||||
++step;
|
||||
string id;
|
||||
char *path = NULL;
|
||||
const char *id = NULL;
|
||||
if(m_gameList[i].type == TYPE_PLUGIN)
|
||||
{
|
||||
char gamePath[256];
|
||||
if(string(m_gameList[i].path).find_last_of("/") != string::npos)
|
||||
strncpy(gamePath, &m_gameList[i].path[string(m_gameList[i].path).find_last_of("/")+1], sizeof(gamePath));
|
||||
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("%s/%s.png", m_boxPicDir.c_str(), gamePath);
|
||||
path = fmt_malloc("%s/%s.png", m_boxPicDir.c_str(), gamePath);
|
||||
id = path;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = (const char *)m_gameList[i].id;
|
||||
path = fmt("%s/%s.png", m_boxPicDir.c_str(), id.c_str());
|
||||
path = fmt_malloc("%s/%s.png", m_boxPicDir.c_str(), m_gameList[i].id);
|
||||
id = m_gameList[i].id;
|
||||
}
|
||||
if(!missingOnly || (!CoverFlow.fullCoverCached(id.c_str()) && !checkPNGFile(path.c_str())))
|
||||
if(!missingOnly || (id != NULL && !CoverFlow.fullCoverCached(id) && path != NULL && !checkPNGFile(path)))
|
||||
{
|
||||
if(m_gameList[i].type == TYPE_PLUGIN)
|
||||
pluginCoverList.push_back(m_gameList[i]);
|
||||
if(id != NULL)
|
||||
coverList.push_back(id);
|
||||
}
|
||||
if(path != NULL)
|
||||
MEM2_free(path);
|
||||
path = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -544,7 +548,7 @@ int CMenu::_coverDownloader(bool missingOnly)
|
||||
bool custom = false;
|
||||
int c_altCase = 0;
|
||||
|
||||
string newID = m_newID.getString(domain, coverList[i], coverList[i]);
|
||||
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]);
|
||||
@ -578,8 +582,8 @@ int CMenu::_coverDownloader(bool missingOnly)
|
||||
original = false;
|
||||
if (!success && !m_thrdStop && original)
|
||||
{
|
||||
path = fmt("%s/%s.png", m_boxPicDir.c_str(), coverList[i].c_str());
|
||||
if (!checkPNGFile(path.c_str()))
|
||||
char *path = fmt_malloc("%s/%s.png", m_boxPicDir.c_str(), coverList[i].c_str());
|
||||
if(path != NULL && !checkPNGFile(path))
|
||||
{
|
||||
for (u32 j = 0; !success && j < fmtURLBox.size() && !m_thrdStop; ++j)
|
||||
{
|
||||
@ -696,9 +700,9 @@ int CMenu::_coverDownloader(bool missingOnly)
|
||||
if (savePNG)
|
||||
{
|
||||
LWP_MutexLock(m_mutex);
|
||||
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), path.c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
||||
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), path), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
||||
LWP_MutexUnlock(m_mutex);
|
||||
fsop_WriteFile(path.c_str(), download.data, download.size);
|
||||
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);
|
||||
@ -710,16 +714,19 @@ int CMenu::_coverDownloader(bool missingOnly)
|
||||
}
|
||||
}
|
||||
}
|
||||
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() );
|
||||
if (!success && !m_thrdStop && c_gameTDB.IsLoaded() && c_altCase > 1 && custom)
|
||||
if(!success && !m_thrdStop && c_gameTDB.IsLoaded() && c_altCase > 1 && custom)
|
||||
{
|
||||
path = fmt("%s/%s.png", m_boxPicDir.c_str(), coverList[i].c_str());
|
||||
if (!checkPNGFile(path.c_str()))
|
||||
char *path = fmt_malloc("%s/%s.png", m_boxPicDir.c_str(), coverList[i].c_str());
|
||||
if(path != NULL && !checkPNGFile(path))
|
||||
{
|
||||
for (u32 j = 0; !success && j < fmtURLCBox.size() && !m_thrdStop; ++j)
|
||||
{
|
||||
@ -838,9 +845,9 @@ int CMenu::_coverDownloader(bool missingOnly)
|
||||
if (savePNG)
|
||||
{
|
||||
LWP_MutexLock(m_mutex);
|
||||
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), path.c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
||||
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), path), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
||||
LWP_MutexUnlock(m_mutex);
|
||||
fsop_WriteFile(path.c_str(), download.data, download.size);
|
||||
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);
|
||||
@ -852,15 +859,18 @@ int CMenu::_coverDownloader(bool missingOnly)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(path != NULL)
|
||||
MEM2_free(path);
|
||||
path = NULL;
|
||||
}
|
||||
break;
|
||||
case FLAT:
|
||||
if( m_downloadPrioVal&C_TYPE_ONOR )
|
||||
original = false;
|
||||
if (!success && !m_thrdStop && original)
|
||||
if(!success && !m_thrdStop && original)
|
||||
{
|
||||
path = fmt("%s/%s.png", m_picDir.c_str(), coverList[i].c_str());
|
||||
if (!checkPNGFile(path.c_str()))
|
||||
char *path = fmt_malloc("%s/%s.png", m_picDir.c_str(), coverList[i].c_str());
|
||||
if(path != NULL && !checkPNGFile(path))
|
||||
{
|
||||
// Try to get the front cover
|
||||
if (m_thrdStop) break;
|
||||
@ -979,9 +989,9 @@ int CMenu::_coverDownloader(bool missingOnly)
|
||||
if (savePNG)
|
||||
{
|
||||
LWP_MutexLock(m_mutex);
|
||||
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), path.c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
||||
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), path), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
||||
LWP_MutexUnlock(m_mutex);
|
||||
fsop_WriteFile(path.c_str(), download.data, download.size);
|
||||
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);
|
||||
@ -993,15 +1003,18 @@ int CMenu::_coverDownloader(bool missingOnly)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(path != NULL)
|
||||
MEM2_free(path);
|
||||
path = NULL;
|
||||
}
|
||||
break;
|
||||
case CFLAT:
|
||||
if( m_downloadPrioVal&C_TYPE_ONCU )
|
||||
custom = true;
|
||||
if (!success && !m_thrdStop && c_gameTDB.IsLoaded() && c_altCase > 1 && custom)
|
||||
if(!success && !m_thrdStop && c_gameTDB.IsLoaded() && c_altCase > 1 && custom)
|
||||
{
|
||||
path = fmt("%s/%s.png", m_picDir.c_str(), coverList[i].c_str());
|
||||
if (!checkPNGFile(path.c_str()))
|
||||
char *path = fmt_malloc("%s/%s.png", m_picDir.c_str(), coverList[i].c_str());
|
||||
if(path != NULL && !checkPNGFile(path))
|
||||
{
|
||||
// Try to get the front cover
|
||||
if (m_thrdStop) break;
|
||||
@ -1116,9 +1129,9 @@ int CMenu::_coverDownloader(bool missingOnly)
|
||||
if(savePNG)
|
||||
{
|
||||
LWP_MutexLock(m_mutex);
|
||||
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), path.c_str()), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
||||
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), path), listWeight + dlWeight * (float)(step + 1) / (float)nbSteps);
|
||||
LWP_MutexUnlock(m_mutex);
|
||||
fsop_WriteFile(path.c_str(), download.data, download.size);
|
||||
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);
|
||||
@ -1130,11 +1143,13 @@ int CMenu::_coverDownloader(bool missingOnly)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(path != NULL)
|
||||
MEM2_free(path);
|
||||
path = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
newID.clear();
|
||||
++step;
|
||||
}
|
||||
if(c_gameTDB.IsLoaded())
|
||||
@ -1172,8 +1187,8 @@ void CMenu::_download(string gameId)
|
||||
if(gameId.size() && CoverFlow.getHdr()->type == TYPE_PLUGIN)
|
||||
{
|
||||
char gamePath[256];
|
||||
if(string(CoverFlow.getHdr()->path).find_last_of("/") != string::npos)
|
||||
strncpy(gamePath, &CoverFlow.getHdr()->path[string(CoverFlow.getHdr()->path).find_last_of("/")+1], sizeof(gamePath));
|
||||
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;
|
||||
@ -1929,8 +1944,6 @@ int CMenu::_gametdbDownloader(CMenu *m)
|
||||
|
||||
int CMenu::_gametdbDownloaderAsync()
|
||||
{
|
||||
string langCode;
|
||||
|
||||
u32 bufferSize = 0x800000; // 8 MB
|
||||
u8 *buffer = (u8*)MEM2_alloc(bufferSize);
|
||||
if (buffer == NULL)
|
||||
@ -1940,7 +1953,7 @@ int CMenu::_gametdbDownloaderAsync()
|
||||
LWP_MutexUnlock(m_mutex);
|
||||
return 0;
|
||||
}
|
||||
langCode = m_loc.getString(m_curLanguage, "gametdb_code", "EN");
|
||||
const string &langCode = m_loc.getString(m_curLanguage, "gametdb_code", "EN");
|
||||
LWP_MutexLock(m_mutex);
|
||||
_setThrdMsg(_t("dlmsg1", L"Initializing network..."), 0.f);
|
||||
LWP_MutexUnlock(m_mutex);
|
||||
@ -1966,18 +1979,20 @@ int CMenu::_gametdbDownloaderAsync()
|
||||
}
|
||||
else
|
||||
{
|
||||
string zippath = fmt("%s/wiitdb.zip", m_settingsDir.c_str());
|
||||
|
||||
gprintf("Downloading file to '%s'\n", zippath.c_str());
|
||||
|
||||
fsop_deleteFile(zippath.c_str());
|
||||
|
||||
bool res = false;
|
||||
char *zippath = fmt_malloc("%s/wiitdb.zip", m_settingsDir.c_str());
|
||||
if(zippath != NULL)
|
||||
{
|
||||
gprintf("Writing file to '%s'\n", zippath);
|
||||
fsop_deleteFile(zippath);
|
||||
_setThrdMsg(wfmt(_fmt("dlmsg4", L"Saving %s"), "wiitdb.zip"), 1.f);
|
||||
bool res = fsop_WriteFile(zippath.c_str(), download.data, download.size);
|
||||
if (res == false)
|
||||
res = fsop_WriteFile(zippath, download.data, download.size);
|
||||
}
|
||||
if(res == false)
|
||||
{
|
||||
gprintf("Can't save zip file\n");
|
||||
|
||||
if(zippath != NULL)
|
||||
MEM2_free(zippath);
|
||||
LWP_MutexLock(m_mutex);
|
||||
_setThrdMsg(_t("dlmsg15", L"Couldn't save ZIP file"), 1.f);
|
||||
LWP_MutexUnlock(m_mutex);
|
||||
@ -1986,12 +2001,13 @@ int CMenu::_gametdbDownloaderAsync()
|
||||
{
|
||||
gprintf("Extracting zip file: ");
|
||||
|
||||
ZipFile zFile(zippath.c_str());
|
||||
ZipFile zFile(zippath);
|
||||
bool zres = zFile.ExtractAll(m_settingsDir.c_str());
|
||||
gprintf(zres ? "success\n" : "failed\n");
|
||||
|
||||
// We don't need the zipfile anymore
|
||||
fsop_deleteFile(zippath.c_str());
|
||||
fsop_deleteFile(zippath);
|
||||
MEM2_free(zippath);
|
||||
|
||||
// We should always remove the offsets file to make sure it's reloaded
|
||||
fsop_deleteFile(fmt("%s/gametdb_offsets.bin", m_settingsDir.c_str()));
|
||||
@ -2018,7 +2034,7 @@ int CMenu::_gametdbDownloaderAsync()
|
||||
|
||||
const char *banner_url = NULL;
|
||||
const char *banner_url_id3 = NULL;
|
||||
const char *banner_location = NULL;
|
||||
char *banner_location = NULL;
|
||||
u32 CMenu::_downloadBannerAsync(void *obj)
|
||||
{
|
||||
CMenu *m = (CMenu *)obj;
|
||||
@ -2057,6 +2073,7 @@ u32 CMenu::_downloadBannerAsync(void *obj)
|
||||
/* minimum 50kb */
|
||||
if (banner.data != NULL && banner.size > 51200 && banner.data[0] != '<')
|
||||
{
|
||||
if(banner_location != NULL)
|
||||
fsop_WriteFile(banner_location, banner.data, banner.size);
|
||||
LWP_MutexLock(m->m_mutex);
|
||||
m->_setThrdMsg(m->_t("dlmsg14", L"Done."), 1.f);
|
||||
@ -2091,7 +2108,9 @@ void CMenu::_downloadBnr(const char *gameID)
|
||||
base_url_id3.replace(base_url_id3.find(GAME_BNR_ID), strlen(GAME_BNR_ID), gameID, 3);
|
||||
banner_url_id3 = base_url_id3.c_str();
|
||||
|
||||
banner_location = fmt("%s/%s.bnr", m_customBnrDir.c_str(), gameID);
|
||||
banner_location = fmt_malloc("%s/%s.bnr", m_customBnrDir.c_str(), gameID);
|
||||
if(banner_location == NULL)
|
||||
return;
|
||||
|
||||
m_btnMgr.show(m_downloadPBar);
|
||||
m_btnMgr.setProgress(m_downloadPBar, 0.f);
|
||||
@ -2144,6 +2163,12 @@ void CMenu::_downloadBnr(const char *gameID)
|
||||
if (m_thrdStop && !m_thrdWorking)
|
||||
break;
|
||||
}
|
||||
if(banner_location != NULL)
|
||||
{
|
||||
MEM2_free(banner_location);
|
||||
banner_location = NULL;
|
||||
}
|
||||
|
||||
m_btnMgr.setText(m_downloadBtnCancel, _t("gm2", L"Back"));
|
||||
if (thread != LWP_THREAD_NULL)
|
||||
{
|
||||
|
@ -428,10 +428,8 @@ void CMenu::_game(bool launch)
|
||||
else if(BTN_MINUS_PRESSED)
|
||||
{
|
||||
const char *videoPath = fmt("%s/%.3s.thp", m_videoDir.c_str(), CoverFlow.getId());
|
||||
FILE *file = fopen(videoPath, "r");
|
||||
if(file)
|
||||
if(fsop_FileExist(videoPath))
|
||||
{
|
||||
fclose(file);
|
||||
MusicPlayer.Stop();
|
||||
m_gameSound.Stop();
|
||||
m_banner.SetShowBanner(false);
|
||||
|
@ -77,10 +77,10 @@ bool Plugin::AddPlugin(Config &plugin)
|
||||
NewPlugin.DisplayName.fromUTF8(PluginName.c_str());
|
||||
NewPlugin.consoleCoverID = plugin.getString(PLUGIN_INI_DEF,"consoleCoverID");
|
||||
|
||||
const char *bannerfilepath = fmt("%s/%s", pluginsDir.c_str(), plugin.getString(PLUGIN_INI_DEF,"bannerSound").c_str());
|
||||
fsop_GetFileSizeBytes(bannerfilepath, &NewPlugin.BannerSoundSize);
|
||||
const string &bannerfilepath = sfmt("%s/%s", pluginsDir.c_str(), plugin.getString(PLUGIN_INI_DEF,"bannerSound").c_str());
|
||||
fsop_GetFileSizeBytes(bannerfilepath.c_str(), &NewPlugin.BannerSoundSize);
|
||||
if(NewPlugin.BannerSoundSize > 0)
|
||||
NewPlugin.BannerSound = string(bannerfilepath);
|
||||
NewPlugin.BannerSound = bannerfilepath;
|
||||
Plugins.push_back(NewPlugin);
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user