-cleaned up some more shit, should give us more free mem and speed

-maybe fixed that strange wii button power off codedump
This commit is contained in:
fix94.1 2012-12-27 20:22:40 +00:00
parent 29a7c2e943
commit 4cb521304f
25 changed files with 164 additions and 176 deletions

View File

@ -85,7 +85,7 @@ bool WiiFont::Load(const u8 *file)
break; break;
default: default:
// ignore // ignore
gprintf("Uknown section %.4s\n", (char *) &section->magic); gprintf("Unknown section %.4s\n", &section->magic);
break; break;
} }
} }

View File

@ -231,9 +231,10 @@ u32 Channels::Count()
return this->size(); return this->size();
} }
char * Channels::GetId(int index) const char *Channels::GetId(int index)
{ {
if (index < 0 || index > (int)Count() - 1) return (char *) ""; if(index < 0 || index > (int)Count() - 1)
return "";
return this->at(index).id; return this->at(index).id;
} }

View File

@ -55,7 +55,7 @@ public:
u32 Count(); u32 Count();
wchar_t *GetName(int index); wchar_t *GetName(int index);
char *GetId(int index); const char *GetId(int index);
u64 GetTitle(int index); u64 GetTitle(int index);
Channel *GetChannel(int index); Channel *GetChannel(int index);

View File

@ -519,7 +519,7 @@ s32 Nand::__FlashNandFile(const char *source, const char *dest)
{ {
NandSize += fsize; NandSize += fsize;
if(showprogress) if(showprogress)
dumper(NandSize, 0x1f400000, 0x1f400000, NandSize, FilesDone, FoldersDone, (char *)"", data); dumper(NandSize, 0x1f400000, 0x1f400000, NandSize, FilesDone, FoldersDone, "", data);
fclose(file); fclose(file);
return 0; return 0;
} }
@ -573,7 +573,7 @@ s32 Nand::__FlashNandFile(const char *source, const char *dest)
if(showprogress) if(showprogress)
{ {
const char *file = strrchr(dest, '/')+1; const char *file = strrchr(dest, '/')+1;
dumper(NandDone, NandSize, fsize, FileDone, FilesDone, FoldersDone, (char *)file, data); dumper(NandDone, NandSize, fsize, FileDone, FilesDone, FoldersDone, file, data);
} }
} }
gprintf(" done!\n"); gprintf(" done!\n");
@ -581,7 +581,7 @@ s32 Nand::__FlashNandFile(const char *source, const char *dest)
if(showprogress) if(showprogress)
{ {
const char *file = strrchr(dest, '/')+1; const char *file = strrchr(dest, '/')+1;
dumper(NandDone, NandSize, fsize, FileDone, FilesDone, FoldersDone, (char *)file, data); dumper(NandDone, NandSize, fsize, FileDone, FilesDone, FoldersDone, file, data);
} }
ISFS_Close(fd); ISFS_Close(fd);
free(buffer); free(buffer);
@ -616,7 +616,7 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest)
{ {
NandSize += status->file_length; NandSize += status->file_length;
if(showprogress) if(showprogress)
dumper(NandSize, 0x1f400000, 0x1f400000, NandSize, FilesDone, FoldersDone, (char *)"", data); dumper(NandSize, 0x1f400000, 0x1f400000, NandSize, FilesDone, FoldersDone, "", data);
ISFS_Close(fd); ISFS_Close(fd);
free(status); free(status);
return 0; return 0;
@ -678,14 +678,14 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest)
if(showprogress) if(showprogress)
{ {
const char *file = strrchr(source, '/')+1; const char *file = strrchr(source, '/')+1;
dumper(NandDone, NandSize, status->file_length, FileDone, FilesDone, FoldersDone, (char *)file, data); dumper(NandDone, NandSize, status->file_length, FileDone, FilesDone, FoldersDone, file, data);
} }
} }
FilesDone++; FilesDone++;
if(showprogress) if(showprogress)
{ {
const char *file = strrchr(source, '/')+1; const char *file = strrchr(source, '/')+1;
dumper(NandDone, NandSize, status->file_length, FileDone, FilesDone, FoldersDone, (char *)file, data); dumper(NandDone, NandSize, status->file_length, FileDone, FilesDone, FoldersDone, file, data);
} }
gprintf(" done!\n"); gprintf(" done!\n");
fclose(file); fclose(file);

View File

@ -25,7 +25,7 @@
#define BLOCK 2048 #define BLOCK 2048
typedef void (*dump_callback_t)(int dumpstat, int dumpprog, int filestat, int fileprog, int files, int folders, char *tmess, void *user_data); typedef void (*dump_callback_t)(int dumpstat, int dumpprog, int filestat, int fileprog, int files, int folders, const char *tmess, void *user_data);
/* 'NAND Device' structure */ /* 'NAND Device' structure */
typedef struct nandDevice typedef struct nandDevice

View File

@ -336,7 +336,7 @@ vector<string> Config::getStrings(const string &domain, const string &key, char
if(domain.empty() || key.empty()) if(domain.empty() || key.empty())
{ {
if(defVal != std::string()) if(!defVal.empty())
retval.push_back(defVal); retval.push_back(defVal);
return retval; return retval;
} }
@ -344,7 +344,7 @@ vector<string> Config::getStrings(const string &domain, const string &key, char
string &data = m_domains[upperCase(domain)][lowerCase(key)]; string &data = m_domains[upperCase(domain)][lowerCase(key)];
if(data.empty()) if(data.empty())
{ {
if(defVal != std::string()) if(!defVal.empty())
retval.push_back(defVal); retval.push_back(defVal);
return retval; return retval;
} }

View File

@ -1499,16 +1499,16 @@ void CCoverFlow::_loadCover(int i, int item)
m_covers[i].title.setText(m_font, m_items[item].hdr->title); m_covers[i].title.setText(m_font, m_items[item].hdr->title);
} }
string CCoverFlow::getId(void) const const char *CCoverFlow::getId(void) const
{ {
if (m_covers.empty() || m_items.empty()) return ""; if (m_covers.empty() || m_items.empty()) return "";
return string(m_items[loopNum(m_covers[m_range / 2].index + m_jump, m_items.size())].hdr->id); return m_items[loopNum(m_covers[m_range / 2].index + m_jump, m_items.size())].hdr->id;
} }
string CCoverFlow::getNextId(void) const const char *CCoverFlow::getNextId(void) const
{ {
if (m_covers.empty() || m_items.empty()) return ""; if (m_covers.empty() || m_items.empty()) return "";
return string(m_items[loopNum(m_covers[m_range / 2].index + m_jump + 1, m_items.size())].hdr->id); return m_items[loopNum(m_covers[m_range / 2].index + m_jump + 1, m_items.size())].hdr->id;
} }
dir_discHdr * CCoverFlow::getHdr(void) const dir_discHdr * CCoverFlow::getHdr(void) const
@ -1597,6 +1597,12 @@ void CCoverFlow::cancel(void)
_playSound(m_cancelSound); _playSound(m_cancelSound);
} }
void CCoverFlow::defaultLoad(void)
{
_loadAllCovers(0);
_updateAllTargets();
}
void CCoverFlow::_updateAllTargets(bool instant) void CCoverFlow::_updateAllTargets(bool instant)
{ {
m_targetCameraPos = m_selected ? m_loSelected.camera : m_loNormal.camera; m_targetCameraPos = m_selected ? m_loSelected.camera : m_loNormal.camera;
@ -1840,7 +1846,7 @@ bool CCoverFlow::_sortByWifiPlayers(CItem item1, CItem item2)
return item1.hdr->wifi < item2.hdr->wifi; return item1.hdr->wifi < item2.hdr->wifi;
} }
bool CCoverFlow::start(const char *id) bool CCoverFlow::start()
{ {
if (m_items.empty()) return true; if (m_items.empty()) return true;
@ -1907,10 +1913,6 @@ bool CCoverFlow::start(const char *id)
m_jump = 0; m_jump = 0;
m_selected = false; m_selected = false;
m_moved = true; m_moved = true;
if (id == 0 || !findId(id, true))
_loadAllCovers(0);
_updateAllTargets();
startCoverLoader();
return true; return true;
} }
@ -2074,19 +2076,21 @@ bool CCoverFlow::mouseOver(int x, int y)
return m_vid.stencilVal(x, y) == (int)m_range / 2 + 1; return m_vid.stencilVal(x, y) == (int)m_range / 2 + 1;
} }
bool CCoverFlow::findId(const char *id, bool instant) bool CCoverFlow::findId(const char *id, bool instant, bool path)
{ {
LockMutex lock(m_mutex); LockMutex lock(m_mutex);
u32 i, curPos = _currentPos(); u32 i, curPos = _currentPos();
if (m_items.empty() || (instant && m_covers.empty())) if(m_items.empty() || (instant && m_covers.empty()) || strlen(id) == 0)
return false; return false;
// //
for (i = 0; i < m_items.size(); ++i) for (i = 0; i < m_items.size(); ++i)
if(memcmp(m_items[i].hdr->id, id, strlen(id)) == 0) {
if(path && memcmp(strrchr(m_items[i].hdr->path, '/')+1, id, strlen(id)) == 0)
break; break;
else if (strlen(id) > 6 && memcmp(&m_items[i].hdr->path[string(m_items[i].hdr->path).find_last_of("/")+1], id, strlen(id)) == 0) else if(!path && memcmp(m_items[i].hdr->id, id, strlen(id)) == 0)
break; break;
}
if(i >= m_items.size()) if(i >= m_items.size())
return false; return false;
m_jump = 0; m_jump = 0;

View File

@ -47,14 +47,15 @@ public:
void addItem(dir_discHdr *hdr, const char *picPath, const char *boxPicPath, const char *blankBoxPicPath, int playcount = 0, unsigned int lastPlayed = 0); void addItem(dir_discHdr *hdr, const char *picPath, const char *boxPicPath, const char *blankBoxPicPath, int playcount = 0, unsigned int lastPlayed = 0);
bool empty(void) const { return m_items.empty(); } bool empty(void) const { return m_items.empty(); }
// //
bool start(const char *id = NULL); bool start();
void stopCoverLoader(bool empty = false); void stopCoverLoader(bool empty = false);
void startCoverLoader(void); void startCoverLoader(void);
void defaultLoad(void);
// //
void simulateOtherScreenFormat(bool s); void simulateOtherScreenFormat(bool s);
// Commands // Commands
void tick(void); void tick(void);
bool findId(const char *id, bool instant = false); bool findId(const char *id, bool instant = false, bool path = false);
void pageUp(void); void pageUp(void);
void pageDown(void); void pageDown(void);
void nextLetter(wchar_t *c); void nextLetter(wchar_t *c);
@ -125,8 +126,8 @@ public:
bool fullCoverCached(const char *id); bool fullCoverCached(const char *id);
bool preCacheCover(const char *id, const u8 *png, bool full); bool preCacheCover(const char *id, const u8 *png, bool full);
// //
string getId(void) const; const char *getId(void) const;
string getNextId(void) const; const char *getNextId(void) const;
dir_discHdr * getHdr(void) const; dir_discHdr * getHdr(void) const;
dir_discHdr * getNextHdr(void) const; dir_discHdr * getNextHdr(void) const;
wstringEx getTitle(void) const; wstringEx getTitle(void) const;

View File

@ -55,7 +55,8 @@ s32 Disc_Wait(void)
{ {
/* Get cover status */ /* Get cover status */
s32 ret = WDVD_GetCoverStatus(&cover); s32 ret = WDVD_GetCoverStatus(&cover);
if (ret < 0) return ret; if(ret < 0)
return ret;
// 10 tries to make sure it doesn´t "freeze" in Install dialog // 10 tries to make sure it doesn´t "freeze" in Install dialog
// if no Game Disc is insert // if no Game Disc is insert
@ -64,7 +65,6 @@ s32 Disc_Wait(void)
if(icounter > 10) if(icounter > 10)
return -1; return -1;
} }
return 0; return 0;
} }
@ -82,9 +82,9 @@ s32 Disc_ReadGCHeader(void *outbuf)
s32 Disc_Type(bool gc) s32 Disc_Type(bool gc)
{ {
s32 ret; s32 ret = 0;
u32 check; u32 check = 0;
u32 magic; u32 magic = 0;
if(!gc) if(!gc)
{ {
@ -96,7 +96,7 @@ s32 Disc_Type(bool gc)
{ {
check = GC_MAGIC; check = GC_MAGIC;
ret = Disc_ReadGCHeader(&gc_hdr); ret = Disc_ReadGCHeader(&gc_hdr);
if(strcmp((char *)gc_hdr.id, "GCOPDV") == 0) if(memcmp(gc_hdr.id, "GCOPDV", 6) == 0)
magic = GC_MAGIC; magic = GC_MAGIC;
else else
magic = gc_hdr.magic; magic = gc_hdr.magic;

View File

@ -309,8 +309,8 @@ s32 GCDump::DumpGame()
multigamedisc = true; multigamedisc = true;
__AnalizeMultiDisc(); __AnalizeMultiDisc();
__DiscReadRaw(ReadBuffer, NextOffset, sizeof(gc_discHdr)); __DiscReadRaw(ReadBuffer, NextOffset, sizeof(gc_discHdr));
memcpy(gc_hdr.title, ReadBuffer + 0x20, 64);
memcpy(gc_hdr.id, ReadBuffer, 6); memcpy(gc_hdr.id, ReadBuffer, 6);
strcpy(gc_hdr.title, (char *)ReadBuffer+0x20);
} }
Asciify2(gc_hdr.title); Asciify2(gc_hdr.title);
@ -560,8 +560,8 @@ s32 GCDump::CheckSpace(u32 *needed, bool comp)
multigamedisc = true; multigamedisc = true;
__AnalizeMultiDisc(); __AnalizeMultiDisc();
__DiscReadRaw(ReadBuffer, NextOffset, sizeof(gc_discHdr)); __DiscReadRaw(ReadBuffer, NextOffset, sizeof(gc_discHdr));
memcpy(gc_hdr.id, ReadBuffer, sizeof(gc_hdr.id)); memcpy(gc_hdr.title, ReadBuffer + 0x20, 64);
strcpy(gc_hdr.title, (char *)ReadBuffer+0x20); memcpy(gc_hdr.id, ReadBuffer, 6);
} }
Asciify2(gc_hdr.title); Asciify2(gc_hdr.title);

View File

@ -19,8 +19,8 @@
#include "wiiuse/wpad.h" #include "wiiuse/wpad.h"
/* Variables */ /* Variables */
volatile bool reset = false; bool reset = false;
volatile bool shutdown = false; bool shutdown = false;
volatile u8 ExitOption = 0; volatile u8 ExitOption = 0;
const char *NeekPath = NULL; const char *NeekPath = NULL;
@ -57,6 +57,8 @@ void Close_Inputs(void)
bool Sys_Exiting(void) bool Sys_Exiting(void)
{ {
DCFlushRange(&reset, 32);
DCFlushRange(&shutdown, 32);
return reset || shutdown; return reset || shutdown;
} }

View File

@ -149,6 +149,7 @@ CMenu::CMenu()
m_use_sd_logging = false; m_use_sd_logging = false;
m_use_wifi_gecko = false; m_use_wifi_gecko = false;
init_network = false; init_network = false;
m_curGameId = NULL;
} }
void CMenu::init() void CMenu::init()
@ -1946,8 +1947,11 @@ void CMenu::_initCF(void)
CoverFlow.setHQcover(m_cfg.getBool("GENERAL", "cover_use_hq", false)); CoverFlow.setHQcover(m_cfg.getBool("GENERAL", "cover_use_hq", false));
CoverFlow.start(); CoverFlow.start();
if (m_curGameId.empty() || !CoverFlow.findId(m_curGameId.c_str(), true)) bool path = (m_current_view == COVERFLOW_PLUGIN || m_current_view == COVERFLOW_HOMEBREW);
CoverFlow.findId(m_cfg.getString(domain, "current_item").c_str(), true); if((m_curGameId != NULL && !CoverFlow.findId(m_curGameId, true, path)) ||
!CoverFlow.findId(m_cfg.getString(domain, "current_item").c_str(), true, path))
CoverFlow.defaultLoad();
CoverFlow.startCoverLoader();
} }
void CMenu::_mainLoopCommon(bool withCF, bool adjusting) void CMenu::_mainLoopCommon(bool withCF, bool adjusting)
@ -2565,35 +2569,14 @@ void CMenu::_cleanupDefaultFont()
m_wbf2_font = NULL; m_wbf2_font = NULL;
} }
string CMenu::_getId() const char *CMenu::_getId()
{
string id;
if(!NoGameID(CoverFlow.getHdr()->type))
id = CoverFlow.getId();
else
{ {
const char *id = NULL;
dir_discHdr *hdr = CoverFlow.getHdr(); dir_discHdr *hdr = CoverFlow.getHdr();
string tempname(hdr->path); if(hdr->type == TYPE_HOMEBREW || hdr->type == TYPE_PLUGIN)
if(hdr->type == TYPE_HOMEBREW) id = strrchr(hdr->path, '/') + 1;
{
tempname.assign(&tempname[tempname.find_last_of('/') + 1]);
id = tempname;
}
else if(hdr->type == TYPE_PLUGIN)
{
if(tempname.find(':') != string::npos)
{
tempname.erase(0, tempname.find_first_of('/')+1);
string dirName = tempname.substr(0, tempname.find_first_of('/')+1);
tempname.assign(&tempname[tempname.find_last_of('/') + 1]);
if(tempname.find_last_of('.') != string::npos)
tempname.erase(tempname.find_last_of('.'), tempname.size() - tempname.find_last_of('.'));
id = dirName+tempname;
}
else else
id = tempname; id = CoverFlow.getId();
}
}
return id; return id;
} }
@ -2708,6 +2691,7 @@ void CMenu::TempLoadIOS(int IOS)
if(CurrentIOS.Version != IOS) if(CurrentIOS.Version != IOS)
{ {
loadIOS(IOS, true); loadIOS(IOS, true);
Sys_Init();
Open_Inputs(); Open_Inputs();
for(int chan = WPAD_MAX_WIIMOTES-2; chan >= 0; chan--) for(int chan = WPAD_MAX_WIIMOTES-2; chan >= 0; chan--)
WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height()); WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height());

View File

@ -78,7 +78,7 @@ private:
bool m_music_info; bool m_music_info;
s16 m_showtimer; s16 m_showtimer;
string m_curLanguage; string m_curLanguage;
string m_curGameId; const char *m_curGameId;
u8 m_numCFVersions; u8 m_numCFVersions;
@ -996,7 +996,7 @@ private:
void _buildMenus(void); void _buildMenus(void);
void _cleanupDefaultFont(); void _cleanupDefaultFont();
void _Theme_Cleanup(); void _Theme_Cleanup();
string _getId(void); const char *_getId(void);
const char *_domainFromView(void); const char *_domainFromView(void);
const char *_cfDomain(bool selected = false); const char *_cfDomain(bool selected = false);
void UpdateCache(u32 view = COVERFLOW_MAX); void UpdateCache(u32 view = COVERFLOW_MAX);
@ -1046,7 +1046,7 @@ private:
void _getGrabStatus(void); void _getGrabStatus(void);
static void _addDiscProgress(int status, int total, void *user_data); static void _addDiscProgress(int status, int total, void *user_data);
static void _Messenger(int message, int info, char *cinfo, void *user_data); static void _Messenger(int message, int info, char *cinfo, void *user_data);
static void _ShowProgress(int dumpstat, int dumpprog, int filestat, int fileprog, int files, int folders, char *tmess, void *user_data); static void _ShowProgress(int dumpstat, int dumpprog, int filestat, int fileprog, int files, int folders, const char *tmess, void *user_data);
static int _gameInstaller(void *obj); static int _gameInstaller(void *obj);
static int _GCgameInstaller(void *obj); static int _GCgameInstaller(void *obj);
static int _GCcopyGame(void *obj); static int _GCcopyGame(void *obj);

View File

@ -52,14 +52,14 @@ u32 CMenu::_downloadCheatFileAsync(void *obj)
return -2; return -2;
} }
string id = CoverFlow.getId(); const char *id = CoverFlow.getId();
char type = id[0] == 'S' ? 'R' : id[0]; char type = id[0] == 'S' ? 'R' : id[0];
block cheatfile = downloadfile(buffer, bufferSize, fmt(GECKOURL, type, id.c_str()), CMenu::_downloadProgress, m); block cheatfile = downloadfile(buffer, bufferSize, fmt(GECKOURL, type, id), CMenu::_downloadProgress, m);
if (cheatfile.data != NULL && cheatfile.size > 65 && cheatfile.data[0] != '<') if (cheatfile.data != NULL && cheatfile.size > 65 && cheatfile.data[0] != '<')
{ {
FILE *file = fopen(fmt("%s/%s.txt", m->m_txtCheatDir.c_str(), id.c_str()), "wb"); FILE *file = fopen(fmt("%s/%s.txt", m->m_txtCheatDir.c_str(), id), "wb");
if (file != NULL) if (file != NULL)
{ {
@ -80,10 +80,10 @@ void CMenu::_CheatSettings()
{ {
SetupInput(); SetupInput();
string id = CoverFlow.getId(); const char *id = CoverFlow.getId();
m_cheatSettingsPage = 1; m_cheatSettingsPage = 1;
int txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id.c_str())); int txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id));
_showCheatSettings(); _showCheatSettings();
_textCheatSettings(); _textCheatSettings();
@ -124,8 +124,8 @@ void CMenu::_CheatSettings()
} }
else if ((WBTN_2_HELD && WBTN_1_PRESSED) || (WBTN_1_HELD && WBTN_2_PRESSED)) else if ((WBTN_2_HELD && WBTN_1_PRESSED) || (WBTN_1_HELD && WBTN_2_PRESSED))
{ {
remove(fmt("%s/%s.gct", m_cheatDir.c_str(), id.c_str())); remove(fmt("%s/%s.gct", m_cheatDir.c_str(), id));
remove(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id.c_str())); remove(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id));
m_gcfg2.remove(id, "cheat"); m_gcfg2.remove(id, "cheat");
m_gcfg2.remove(id, "hooktype"); m_gcfg2.remove(id, "hooktype");
break; break;
@ -157,17 +157,17 @@ void CMenu::_CheatSettings()
if (selected) if (selected)
{ {
m_cheatfile.createGCT(fmt("%s/%s.gct", m_cheatDir.c_str(), id.c_str())); m_cheatfile.createGCT(fmt("%s/%s.gct", m_cheatDir.c_str(), id));
m_gcfg2.setOptBool(id, "cheat", 1); m_gcfg2.setOptBool(id, "cheat", 1);
m_gcfg2.setInt(id, "hooktype", m_gcfg2.getInt(id, "hooktype", 1)); m_gcfg2.setInt(id, "hooktype", m_gcfg2.getInt(id, "hooktype", 1));
} }
else else
{ {
remove(fmt("%s/%s.gct", m_cheatDir.c_str(), id.c_str())); remove(fmt("%s/%s.gct", m_cheatDir.c_str(), id));
m_gcfg2.remove(id, "cheat"); m_gcfg2.remove(id, "cheat");
m_gcfg2.remove(id, "hooktype"); m_gcfg2.remove(id, "hooktype");
} }
m_cheatfile.createTXT(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id.c_str())); m_cheatfile.createTXT(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id));
break; break;
} }
else if (m_btnMgr.selected(m_cheatBtnDownload)) else if (m_btnMgr.selected(m_cheatBtnDownload))
@ -239,7 +239,7 @@ void CMenu::_CheatSettings()
} }
_hideCheatDownload(); _hideCheatDownload();
txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id.c_str())); txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id));
_showCheatSettings(); _showCheatSettings();
if(txtavailable) if(txtavailable)
@ -252,7 +252,7 @@ void CMenu::_CheatSettings()
// cheat code not found, show result // cheat code not found, show result
char type = id[0] == 'S' ? 'R' : id[0]; char type = id[0] == 'S' ? 'R' : id[0];
m_btnMgr.setText(m_cheatLblItem[0], _t("cheat4", L"Download not found.")); m_btnMgr.setText(m_cheatLblItem[0], _t("cheat4", L"Download not found."));
m_btnMgr.setText(m_cheatLblItem[1], sfmt(GECKOURL, type, id.c_str())); m_btnMgr.setText(m_cheatLblItem[1], sfmt(GECKOURL, type, id));
m_btnMgr.show(m_cheatLblItem[1]); m_btnMgr.show(m_cheatLblItem[1]);
} }
} }

View File

@ -77,12 +77,12 @@ void CMenu::_showConfig4(void)
ChannelHandle.Init(m_loc.getString(m_curLanguage, "gametdb_code", "EN")); ChannelHandle.Init(m_loc.getString(m_curLanguage, "gametdb_code", "EN"));
amountOfChannels = ChannelHandle.Count(); amountOfChannels = ChannelHandle.Count();
string currentChanId = m_cfg.getString("GENERAL", "returnto" ); const string &currentChanId = m_cfg.getString("GENERAL", "returnto");
if (currentChanId.size() > 0) if(!currentChanId.empty())
{ {
for(int i = 0; i < amountOfChannels; i++) for(int i = 0; i < amountOfChannels; i++)
{ {
if (currentChanId == ChannelHandle.GetId(i)) if(strncmp(currentChanId.c_str(), ChannelHandle.GetId(i), 4) == 0)
{ {
channelName = custom_titles.getWString("TITLES", currentChanId, titles.getWString("TITLES", currentChanId, ChannelHandle.GetName(i))); channelName = custom_titles.getWString("TITLES", currentChanId, titles.getWString("TITLES", currentChanId, ChannelHandle.GetName(i)));
break; break;

View File

@ -119,9 +119,7 @@ wstringEx CMenu::_optBoolToString(int i)
void CMenu::_showGameSettings(void) void CMenu::_showGameSettings(void)
{ {
wstringEx title(_t("cfgg1", L"Settings")); wstringEx title(_t("cfgg1", L"Settings"));
title += L" ["; title.append(wfmt(L" [%.6s]", CoverFlow.getId()));
title += wstringEx(CoverFlow.getId());
title += L"]";
m_btnMgr.setText(m_gameSettingsLblTitle, title); m_btnMgr.setText(m_gameSettingsLblTitle, title);
_setBg(m_gameSettingsBg, m_gameSettingsBg); _setBg(m_gameSettingsBg, m_gameSettingsBg);
m_btnMgr.show(m_gameSettingsLblPage); m_btnMgr.show(m_gameSettingsLblPage);
@ -405,7 +403,7 @@ void CMenu::_showGameSettings(void)
if(m_gameSettingsLblUser[i] != -1) if(m_gameSettingsLblUser[i] != -1)
m_btnMgr.show(m_gameSettingsLblUser[i]); m_btnMgr.show(m_gameSettingsLblUser[i]);
string id(CoverFlow.getId()); const char *id = CoverFlow.getId();
int page = m_gameSettingsPage; int page = m_gameSettingsPage;
u32 maxpage = g_numGCfPages; u32 maxpage = g_numGCfPages;
@ -471,7 +469,7 @@ void CMenu::_showGameSettings(void)
void CMenu::_gameSettings(void) void CMenu::_gameSettings(void)
{ {
m_gcfg2.load(fmt("%s/" GAME_SETTINGS2_FILENAME, m_settingsDir.c_str())); m_gcfg2.load(fmt("%s/" GAME_SETTINGS2_FILENAME, m_settingsDir.c_str()));
string id(CoverFlow.getId()); const char *id = CoverFlow.getId();
m_gameSettingsPage = 1; m_gameSettingsPage = 1;
_showGameSettings(); _showGameSettings();
@ -719,9 +717,9 @@ void CMenu::_gameSettings(void)
if (m_btnMgr.selected(m_gameSettingsBtnCover)) if (m_btnMgr.selected(m_gameSettingsBtnCover))
{ {
CoverFlow.stopCoverLoader(true); // Empty cover cache CoverFlow.stopCoverLoader(true); // Empty cover cache
remove(fmt("%s/%s.png", m_picDir.c_str(), CoverFlow.getId().c_str())); remove(fmt("%s/%s.png", m_picDir.c_str(), id));
remove(fmt("%s/%s.png", m_boxPicDir.c_str(), CoverFlow.getId().c_str())); remove(fmt("%s/%s.png", m_boxPicDir.c_str(), id));
remove(fmt("%s/%s.wfc", m_cacheDir.c_str(), CoverFlow.getId().c_str())); remove(fmt("%s/%s.wfc", m_cacheDir.c_str(), id));
CoverFlow.startCoverLoader(); CoverFlow.startCoverLoader();
} }
} }

View File

@ -332,7 +332,7 @@ void CMenu::_showGame(void)
{ {
CoverFlow.showCover(); CoverFlow.showCover();
if (m_fa.load(m_cfg, m_fanartDir.c_str(), CoverFlow.getId().c_str())) if(m_fa.load(m_cfg, m_fanartDir.c_str(), CoverFlow.getId()))
{ {
const STexture *bg = NULL; const STexture *bg = NULL;
const STexture *bglq = NULL; const STexture *bglq = NULL;
@ -439,7 +439,7 @@ void CMenu::_game(bool launch)
} }
else if(BTN_MINUS_PRESSED) else if(BTN_MINUS_PRESSED)
{ {
const char *videoPath = fmt("%s/%.3s.thp", m_videoDir.c_str(), CoverFlow.getId().c_str()); const char *videoPath = fmt("%s/%.3s.thp", m_videoDir.c_str(), CoverFlow.getId());
FILE *file = fopen(videoPath, "r"); FILE *file = fopen(videoPath, "r");
if(file) if(file)
{ {
@ -778,41 +778,40 @@ void CMenu::_launch(dir_discHdr *hdr)
_launchChannel(hdr); _launchChannel(hdr);
else if(hdr->type == TYPE_PLUGIN) else if(hdr->type == TYPE_PLUGIN)
{ {
string title; char title[101];
string path(hdr->path); memset(&title, 0, sizeof(title));
if(path.find(':') != string::npos) const char *path;
if(strchr(hdr->path, ':') != NULL)
{ {
path.erase(path.begin(), path.begin() + path.find_first_of('/') + 1); strncpy(title, strrchr(hdr->path, '/') + 1, 100);
title = string(path.begin() + path.find_last_of('/') + 1, path.end()); *strrchr(hdr->path, '/') = '\0';
path.erase(path.end() - title.size() - 1, path.end()); path = strchr(hdr->path, '/') + 1;
} }
else else
{ {
char gametitle[64]; path = hdr->path;
wcstombs(gametitle, hdr->title, 63); wcstombs(title, hdr->title, 63);
title = gametitle;
} }
string loader(m_pluginsDir);
if(loader.find("usb") != string::npos)
loader.erase(3,1);
loader.append("/WiiFlowLoader.dol");
m_cfg.setString(PLUGIN_DOMAIN, "current_item", title); m_cfg.setString(PLUGIN_DOMAIN, "current_item", title);
string device(currentPartition == 0 ? "sd" : const char *device = (currentPartition == 0 ? "sd" : (DeviceHandle.GetFSType(currentPartition) == PART_FS_NTFS ? "ntfs" : "usb"));
(DeviceHandle.GetFSType(currentPartition) == PART_FS_NTFS ? "ntfs" : "usb")); const char *loader = fmt("%s:/%s/WiiFlowLoader.dol", device, strchr(m_pluginsDir.c_str(), '/') + 1);
vector<string> arguments = m_plugin.CreateArgs(device, path, title, loader, hdr->settings[0]); vector<string> arguments = m_plugin.CreateArgs(device, path, title, loader, hdr->settings[0]);
_launchHomebrew(fmt("%s/%s", m_pluginsDir.c_str(), m_plugin.GetDolName(hdr->settings[0])), arguments); _launchHomebrew(fmt("%s/%s", m_pluginsDir.c_str(), m_plugin.GetDolName(hdr->settings[0])), arguments);
} }
else if(hdr->type == TYPE_HOMEBREW) else if(hdr->type == TYPE_HOMEBREW)
{ {
string title(&hdr->path[string(hdr->path).find_last_of("/")+1]); const char *gamepath = fmt("%s/boot.dol", hdr->path);
char gamepath[128]; if(!fsop_FileExist(gamepath))
snprintf(gamepath, sizeof(gamepath), "%s/boot.dol", hdr->path); gamepath = fmt("%s/boot.elf", hdr->path);
if(!fsop_FileExist((const char*)gamepath)) if(fsop_FileExist(gamepath))
snprintf(gamepath, sizeof(gamepath), "%s/boot.elf", hdr->path); {
m_cfg.setString(HOMEBREW_DOMAIN, "current_item", title); m_cfg.setString(HOMEBREW_DOMAIN, "current_item", strrchr(hdr->path, '/') + 1);
_launchHomebrew(gamepath, m_homebrewArgs); _launchHomebrew(gamepath, m_homebrewArgs);
} }
} }
ShutdownBeforeExit();
Sys_Exit();
}
void CMenu::_launchGC(dir_discHdr *hdr, bool disc) void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
{ {
@ -1579,7 +1578,7 @@ void CMenu::_gameSoundThread(CMenu *m)
fclose(fp); fclose(fp);
} }
m_banner.LoadBanner(m->m_wbf1_font, m->m_wbf2_font); m_banner.LoadBanner(m->m_wbf1_font, m->m_wbf2_font);
soundBin = CurrentBanner.GetFile((char *)"sound.bin", &sndSize); soundBin = CurrentBanner.GetFile("sound.bin", &sndSize);
CurrentBanner.ClearBanner(); CurrentBanner.ClearBanner();
if(soundBin != NULL) if(soundBin != NULL)

View File

@ -316,7 +316,7 @@ void CMenu::_textGameInfo(void)
{ {
char GameID[7]; char GameID[7];
GameID[6] = '\0'; GameID[6] = '\0';
strncpy(GameID, CoverFlow.getId().c_str(), 6); strncpy(GameID, CoverFlow.getId(), 6);
if(gametdb.GetTitle(GameID, TMP_Char)) if(gametdb.GetTitle(GameID, TMP_Char))
{ {
gameinfo_Title_w.fromUTF8(TMP_Char); gameinfo_Title_w.fromUTF8(TMP_Char);

View File

@ -176,7 +176,7 @@ void CMenu::_showMain(void)
void CMenu::LoadView(void) void CMenu::LoadView(void)
{ {
m_curGameId = CoverFlow.getId(); m_curGameId = NULL;
_hideMain(true); _hideMain(true);
CoverFlow.clear(); CoverFlow.clear();
if(!m_vid.showingWaitMessage()) if(!m_vid.showingWaitMessage())

View File

@ -155,7 +155,7 @@ void CMenu::_setDumpMsg(const wstringEx &msg, float totprog, float fileprog)
m_fileProgress = fileprog; m_fileProgress = fileprog;
} }
void CMenu::_ShowProgress(int dumpstat, int dumpprog, int filesize, int fileprog, int files, int folders, char *tmess, void *user_data) void CMenu::_ShowProgress(int dumpstat, int dumpprog, int filesize, int fileprog, int files, int folders, const char *tmess, void *user_data)
{ {
CMenu &m = *(CMenu *)user_data; CMenu &m = *(CMenu *)user_data;
m.m_progress = dumpprog == 0 ? 0.f : (float)dumpstat / (float)dumpprog; m.m_progress = dumpprog == 0 ? 0.f : (float)dumpstat / (float)dumpprog;
@ -634,9 +634,9 @@ int CMenu::_NandFlasher(void *obj)
} }
NandHandle.ResetCounters(); NandHandle.ResetCounters();
m.m_nandexentry = 1; m.m_nandexentry = 1;
m.m_dumpsize = NandHandle.CalcFlashSize(source, CMenu::_ShowProgress, obj); m.m_dumpsize = NandHandle.CalcFlashSize(source, _ShowProgress, obj);
m_nandext = true; m_nandext = true;
NandHandle.FlashToNAND(source, dest, CMenu::_ShowProgress, obj); NandHandle.FlashToNAND(source, dest, _ShowProgress, obj);
m.m_thrdWorking = false; m.m_thrdWorking = false;
LWP_MutexLock(m.m_mutex); LWP_MutexLock(m.m_mutex);

View File

@ -281,7 +281,9 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
bool upd_emu = false; bool upd_emu = false;
bool out = false; bool out = false;
dir_discHdr *CF_Hdr = CoverFlow.getHdr(); dir_discHdr *CF_Hdr = CoverFlow.getHdr();
string cfPos = CoverFlow.getNextId(); char cfPos[7];
cfPos[6] = '\0';
strncpy(cfPos, CoverFlow.getNextId(), 6);
SetupInput(); SetupInput();
_showWBFS(op); _showWBFS(op);
@ -350,7 +352,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
out = true; out = true;
break; break;
} }
cfPos = string(GameID); strncpy(cfPos, GameID, 6);
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, wii_hdr.title)); m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, wii_hdr.title));
done = true; done = true;
upd_usb = true; upd_usb = true;
@ -369,7 +371,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
out = true; out = true;
break; break;
} }
cfPos = string(GameID); strncpy(cfPos, GameID, 6);
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, gc_hdr.title)); m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, gc_hdr.title));
done = true; done = true;
upd_dml = true; upd_dml = true;
@ -450,7 +452,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
m_btnMgr.hide(m_wbfsBtnGo); m_btnMgr.hide(m_wbfsBtnGo);
m_btnMgr.show(m_wbfsLblMessage); m_btnMgr.show(m_wbfsLblMessage);
m_btnMgr.setText(m_wbfsLblMessage, L""); m_btnMgr.setText(m_wbfsLblMessage, L"");
cfPos = string(CF_Hdr->id); strncpy(cfPos, CF_Hdr->id, 6);
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop10", L"Copying [%s] %s..."), CF_Hdr->id, CoverFlow.getTitle().toUTF8().c_str())); m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop10", L"Copying [%s] %s..."), CF_Hdr->id, CoverFlow.getTitle().toUTF8().c_str()));
done = true; done = true;
upd_dml = true; upd_dml = true;
@ -501,7 +503,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
UpdateCache(COVERFLOW_PLUGIN); UpdateCache(COVERFLOW_PLUGIN);
_loadList(); _loadList();
_initCF(); _initCF();
CoverFlow.findId(cfPos.c_str(), true); CoverFlow.findId(cfPos, true);
} }
else else
{ {

View File

@ -23,8 +23,8 @@ u8 register_card_provider(const char *url, const char *key)
{ {
providers = (struct provider*)MEM2_realloc(providers, (amount_of_providers + 1) * sizeof(struct provider)); providers = (struct provider*)MEM2_realloc(providers, (amount_of_providers + 1) * sizeof(struct provider));
memset(&providers[amount_of_providers], 0, sizeof(struct provider)); memset(&providers[amount_of_providers], 0, sizeof(struct provider));
strncpy((char *) providers[amount_of_providers].url, url, 128); strncpy(providers[amount_of_providers].url, url, 128);
strncpy((char *) providers[amount_of_providers].key, key, 48); strncpy(providers[amount_of_providers].key, key, 48);
amount_of_providers++; amount_of_providers++;
gprintf("Gamercard provider is valid!\n"); gprintf("Gamercard provider is valid!\n");
return 0; return 0;
@ -49,7 +49,7 @@ void add_game_to_card(const char *gameid)
for(i = 0; i < amount_of_providers && providers != NULL; i++) for(i = 0; i < amount_of_providers && providers != NULL; i++)
{ {
strcpy(url, (char *) providers[i].url); strcpy(url, providers[i].url);
str_replace(url, "{KEY}", providers[i].key, MAX_URL_SIZE); str_replace(url, "{KEY}", providers[i].key, MAX_URL_SIZE);
str_replace(url, "{ID6}", gameid, MAX_URL_SIZE); str_replace(url, "{ID6}", gameid, MAX_URL_SIZE);
gprintf("Gamertag URL:\n%s\n", url); gprintf("Gamertag URL:\n%s\n", url);

View File

@ -79,10 +79,7 @@ bool Plugin::AddPlugin(Config &plugin)
fclose(fp); fclose(fp);
} }
else else
{
NewPlugin.BannerSound = std::string();
NewPlugin.BannerSoundSize = 0; NewPlugin.BannerSoundSize = 0;
}
Plugins.push_back(NewPlugin); Plugins.push_back(NewPlugin);
return false; return false;
} }
@ -194,34 +191,34 @@ vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, const char *Device, u32
if(!ini.loaded()) if(!ini.loaded())
return gameHeader; return gameHeader;
const string *GameDomain = &ini.firstDomain(); const char *GameDomain = ini.firstDomain().c_str();
dir_discHdr ListElement; dir_discHdr ListElement;
while(1) while(1)
{ {
if(GameDomain->size() < 2) if(strlen(GameDomain) < 2)
break; break;
const string &GameName = ini.getString(*GameDomain, "description"); const char *GameName = ini.getString(GameDomain, "description").c_str();
if(GameName.size() < 2 || strncasecmp(Device, ini.getString(*GameDomain, "path").c_str(), 2) != 0) if(strlen(GameName) < 2 || strncasecmp(Device, ini.getString(GameDomain, "path").c_str(), 2) != 0)
{ {
GameDomain = &ini.nextDomain(); GameDomain = ini.nextDomain().c_str();
continue; continue;
} }
memset((void*)&ListElement, 0, sizeof(dir_discHdr)); memset((void*)&ListElement, 0, sizeof(dir_discHdr));
strncpy(ListElement.id, PLUGIN_INI_DEF, 6); strncpy(ListElement.id, PLUGIN_INI_DEF, 6);
ListElement.casecolor = Plugins.back().caseColor; ListElement.casecolor = Plugins.back().caseColor;
mbstowcs(ListElement.title, GameName.c_str(), 63); mbstowcs(ListElement.title, GameName, 63);
strncpy(ListElement.path, GameDomain->c_str(), sizeof(ListElement.path)); strncpy(ListElement.path, GameDomain, sizeof(ListElement.path));
gprintf("Found: %s\n", GameDomain->c_str()); gprintf("Found: %s\n", GameDomain);
ListElement.settings[0] = MagicWord; ListElement.settings[0] = MagicWord;
ListElement.type = TYPE_PLUGIN; ListElement.type = TYPE_PLUGIN;
gameHeader.push_back(ListElement); gameHeader.push_back(ListElement);
GameDomain = &ini.nextDomain(); GameDomain = ini.nextDomain().c_str();
} }
return gameHeader; return gameHeader;
} }
vector<string> Plugin::CreateArgs(const string& device, const string& path, vector<string> Plugin::CreateArgs(const char *device, const char *path,
const string& title, const string& loader, u32 magic) const char *title, const char *loader, u32 magic)
{ {
vector<string> args; vector<string> args;
Plugin_Pos = GetPluginPosition(magic); Plugin_Pos = GetPluginPosition(magic);

View File

@ -64,8 +64,8 @@ public:
bool PluginExist(u8 pos); bool PluginExist(u8 pos);
void SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode = 0); void SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode = 0);
const vector<bool> &GetEnabledPlugins(Config &cfg); const vector<bool> &GetEnabledPlugins(Config &cfg);
vector<string> CreateArgs(const string& device, const string& path, vector<string> CreateArgs(const char *device, const char *path,
const string& title, const string& loader, u32 magic); const char *title, const char *loader, u32 magic);
void init(const string& m_pluginsDir); void init(const string& m_pluginsDir);
void Cleanup(); void Cleanup();
void EndAdd(); void EndAdd();