-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;
default:
// ignore
gprintf("Uknown section %.4s\n", (char *) &section->magic);
gprintf("Unknown section %.4s\n", &section->magic);
break;
}
}

View File

@ -231,9 +231,10 @@ u32 Channels::Count()
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;
}

View File

@ -39,7 +39,7 @@ using namespace std;
typedef struct
{
u64 title;
u64 title;
char id[4];
wchar_t name[IMET_MAX_NAME_LEN+1];
} Channel;
@ -55,7 +55,7 @@ public:
u32 Count();
wchar_t *GetName(int index);
char *GetId(int index);
const char *GetId(int index);
u64 GetTitle(int index);
Channel *GetChannel(int index);

View File

@ -519,7 +519,7 @@ s32 Nand::__FlashNandFile(const char *source, const char *dest)
{
NandSize += fsize;
if(showprogress)
dumper(NandSize, 0x1f400000, 0x1f400000, NandSize, FilesDone, FoldersDone, (char *)"", data);
dumper(NandSize, 0x1f400000, 0x1f400000, NandSize, FilesDone, FoldersDone, "", data);
fclose(file);
return 0;
}
@ -573,7 +573,7 @@ s32 Nand::__FlashNandFile(const char *source, const char *dest)
if(showprogress)
{
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");
@ -581,7 +581,7 @@ s32 Nand::__FlashNandFile(const char *source, const char *dest)
if(showprogress)
{
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);
free(buffer);
@ -616,7 +616,7 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest)
{
NandSize += status->file_length;
if(showprogress)
dumper(NandSize, 0x1f400000, 0x1f400000, NandSize, FilesDone, FoldersDone, (char *)"", data);
dumper(NandSize, 0x1f400000, 0x1f400000, NandSize, FilesDone, FoldersDone, "", data);
ISFS_Close(fd);
free(status);
return 0;
@ -678,14 +678,14 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest)
if(showprogress)
{
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++;
if(showprogress)
{
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");
fclose(file);
@ -814,7 +814,7 @@ void Nand::CreateTitleTMD(dir_discHdr *hdr)
return;
u8 *titleTMD = NULL;
u32 tmd_size = wbfs_extract_file(disc, (char *) "TMD", (void **)&titleTMD);
u32 tmd_size = wbfs_extract_file(disc, (char*)"TMD", (void**)&titleTMD);
WBFS_CloseDisc(disc);
if(titleTMD == NULL)

View File

@ -25,7 +25,7 @@
#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 */
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(defVal != std::string())
if(!defVal.empty())
retval.push_back(defVal);
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)];
if(data.empty())
{
if(defVal != std::string())
if(!defVal.empty())
retval.push_back(defVal);
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);
}
string CCoverFlow::getId(void) const
const char *CCoverFlow::getId(void) const
{
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 "";
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
@ -1597,6 +1597,12 @@ void CCoverFlow::cancel(void)
_playSound(m_cancelSound);
}
void CCoverFlow::defaultLoad(void)
{
_loadAllCovers(0);
_updateAllTargets();
}
void CCoverFlow::_updateAllTargets(bool instant)
{
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;
}
bool CCoverFlow::start(const char *id)
bool CCoverFlow::start()
{
if (m_items.empty()) return true;
@ -1907,10 +1913,6 @@ bool CCoverFlow::start(const char *id)
m_jump = 0;
m_selected = false;
m_moved = true;
if (id == 0 || !findId(id, true))
_loadAllCovers(0);
_updateAllTargets();
startCoverLoader();
return true;
}
@ -2074,20 +2076,22 @@ bool CCoverFlow::mouseOver(int x, int y)
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);
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;
//
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;
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;
if (i >= m_items.size())
}
if(i >= m_items.size())
return false;
m_jump = 0;
if (instant)

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);
bool empty(void) const { return m_items.empty(); }
//
bool start(const char *id = NULL);
bool start();
void stopCoverLoader(bool empty = false);
void startCoverLoader(void);
void defaultLoad(void);
//
void simulateOtherScreenFormat(bool s);
// Commands
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 pageDown(void);
void nextLetter(wchar_t *c);
@ -125,8 +126,8 @@ public:
bool fullCoverCached(const char *id);
bool preCacheCover(const char *id, const u8 *png, bool full);
//
string getId(void) const;
string getNextId(void) const;
const char *getId(void) const;
const char *getNextId(void) const;
dir_discHdr * getHdr(void) const;
dir_discHdr * getNextHdr(void) const;
wstringEx getTitle(void) const;

View File

@ -51,11 +51,12 @@ s32 Disc_Wait(void)
int icounter = 0;
/* Wait for disc */
while (!(cover & 0x2))
while(!(cover & 0x2))
{
/* Get cover status */
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
// if no Game Disc is insert
@ -64,7 +65,6 @@ s32 Disc_Wait(void)
if(icounter > 10)
return -1;
}
return 0;
}
@ -82,11 +82,11 @@ s32 Disc_ReadGCHeader(void *outbuf)
s32 Disc_Type(bool gc)
{
s32 ret;
u32 check;
u32 magic;
s32 ret = 0;
u32 check = 0;
u32 magic = 0;
if (!gc)
if(!gc)
{
check = WII_MAGIC;
ret = Disc_ReadHeader(&wii_hdr);
@ -96,7 +96,7 @@ s32 Disc_Type(bool gc)
{
check = GC_MAGIC;
ret = Disc_ReadGCHeader(&gc_hdr);
if(strcmp((char *)gc_hdr.id, "GCOPDV") == 0)
if(memcmp(gc_hdr.id, "GCOPDV", 6) == 0)
magic = GC_MAGIC;
else
magic = gc_hdr.magic;

View File

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

View File

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

View File

@ -149,6 +149,7 @@ CMenu::CMenu()
m_use_sd_logging = false;
m_use_wifi_gecko = false;
init_network = false;
m_curGameId = NULL;
}
void CMenu::init()
@ -1946,8 +1947,11 @@ void CMenu::_initCF(void)
CoverFlow.setHQcover(m_cfg.getBool("GENERAL", "cover_use_hq", false));
CoverFlow.start();
if (m_curGameId.empty() || !CoverFlow.findId(m_curGameId.c_str(), true))
CoverFlow.findId(m_cfg.getString(domain, "current_item").c_str(), true);
bool path = (m_current_view == COVERFLOW_PLUGIN || m_current_view == COVERFLOW_HOMEBREW);
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)
@ -2565,35 +2569,14 @@ void CMenu::_cleanupDefaultFont()
m_wbf2_font = NULL;
}
string CMenu::_getId()
const char *CMenu::_getId()
{
string id;
if(!NoGameID(CoverFlow.getHdr()->type))
id = CoverFlow.getId();
const char *id = NULL;
dir_discHdr *hdr = CoverFlow.getHdr();
if(hdr->type == TYPE_HOMEBREW || hdr->type == TYPE_PLUGIN)
id = strrchr(hdr->path, '/') + 1;
else
{
dir_discHdr *hdr = CoverFlow.getHdr();
string tempname(hdr->path);
if(hdr->type == TYPE_HOMEBREW)
{
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
id = tempname;
}
}
id = CoverFlow.getId();
return id;
}
@ -2708,6 +2691,7 @@ void CMenu::TempLoadIOS(int IOS)
if(CurrentIOS.Version != IOS)
{
loadIOS(IOS, true);
Sys_Init();
Open_Inputs();
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());

View File

@ -78,7 +78,7 @@ private:
bool m_music_info;
s16 m_showtimer;
string m_curLanguage;
string m_curGameId;
const char *m_curGameId;
u8 m_numCFVersions;
@ -996,7 +996,7 @@ private:
void _buildMenus(void);
void _cleanupDefaultFont();
void _Theme_Cleanup();
string _getId(void);
const char *_getId(void);
const char *_domainFromView(void);
const char *_cfDomain(bool selected = false);
void UpdateCache(u32 view = COVERFLOW_MAX);
@ -1046,7 +1046,7 @@ private:
void _getGrabStatus(void);
static void _addDiscProgress(int status, int total, 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 _GCgameInstaller(void *obj);
static int _GCcopyGame(void *obj);

View File

@ -52,14 +52,14 @@ u32 CMenu::_downloadCheatFileAsync(void *obj)
return -2;
}
string id = CoverFlow.getId();
const char *id = CoverFlow.getId();
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] != '<')
{
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)
{
@ -80,10 +80,10 @@ void CMenu::_CheatSettings()
{
SetupInput();
string id = CoverFlow.getId();
const char *id = CoverFlow.getId();
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();
_textCheatSettings();
@ -124,8 +124,8 @@ void CMenu::_CheatSettings()
}
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.txt", m_txtCheatDir.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));
m_gcfg2.remove(id, "cheat");
m_gcfg2.remove(id, "hooktype");
break;
@ -157,17 +157,17 @@ void CMenu::_CheatSettings()
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.setInt(id, "hooktype", m_gcfg2.getInt(id, "hooktype", 1));
}
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, "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;
}
else if (m_btnMgr.selected(m_cheatBtnDownload))
@ -239,7 +239,7 @@ void CMenu::_CheatSettings()
}
_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();
if(txtavailable)
@ -252,7 +252,7 @@ void CMenu::_CheatSettings()
// cheat code not found, show result
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[1], sfmt(GECKOURL, type, id.c_str()));
m_btnMgr.setText(m_cheatLblItem[1], sfmt(GECKOURL, type, id));
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"));
amountOfChannels = ChannelHandle.Count();
string currentChanId = m_cfg.getString("GENERAL", "returnto" );
if (currentChanId.size() > 0)
const string &currentChanId = m_cfg.getString("GENERAL", "returnto");
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)));
break;

View File

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

View File

@ -263,7 +263,7 @@ static void _extractBnr(dir_discHdr *hdr)
if(disc != NULL)
{
void *bnr = NULL;
size = wbfs_extract_file(disc, (char *) "opening.bnr", &bnr);
size = wbfs_extract_file(disc, (char*)"opening.bnr", &bnr);
if(size > 0)
CurrentBanner.SetBanner((u8*)bnr, size);
WBFS_CloseDisc(disc);
@ -296,7 +296,7 @@ static u8 GetRequestedGameIOS(dir_discHdr *hdr)
if(disc != NULL)
{
u8 *titleTMD = NULL;
u32 tmd_size = wbfs_extract_file(disc, (char *) "TMD", (void **)&titleTMD);
u32 tmd_size = wbfs_extract_file(disc, (char*)"TMD", (void**)&titleTMD);
if(titleTMD != NULL && tmd_size > 0x18B)
IOS = titleTMD[0x18B];
WBFS_CloseDisc(disc);
@ -332,7 +332,7 @@ void CMenu::_showGame(void)
{
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 *bglq = NULL;
@ -439,7 +439,7 @@ void CMenu::_game(bool launch)
}
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");
if(file)
{
@ -778,40 +778,39 @@ void CMenu::_launch(dir_discHdr *hdr)
_launchChannel(hdr);
else if(hdr->type == TYPE_PLUGIN)
{
string title;
string path(hdr->path);
if(path.find(':') != string::npos)
char title[101];
memset(&title, 0, sizeof(title));
const char *path;
if(strchr(hdr->path, ':') != NULL)
{
path.erase(path.begin(), path.begin() + path.find_first_of('/') + 1);
title = string(path.begin() + path.find_last_of('/') + 1, path.end());
path.erase(path.end() - title.size() - 1, path.end());
strncpy(title, strrchr(hdr->path, '/') + 1, 100);
*strrchr(hdr->path, '/') = '\0';
path = strchr(hdr->path, '/') + 1;
}
else
{
char gametitle[64];
wcstombs(gametitle, hdr->title, 63);
title = gametitle;
path = hdr->path;
wcstombs(title, hdr->title, 63);
}
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);
string device(currentPartition == 0 ? "sd" :
(DeviceHandle.GetFSType(currentPartition) == PART_FS_NTFS ? "ntfs" : "usb"));
const char *device = (currentPartition == 0 ? "sd" : (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]);
_launchHomebrew(fmt("%s/%s", m_pluginsDir.c_str(), m_plugin.GetDolName(hdr->settings[0])), arguments);
}
else if(hdr->type == TYPE_HOMEBREW)
{
string title(&hdr->path[string(hdr->path).find_last_of("/")+1]);
char gamepath[128];
snprintf(gamepath, sizeof(gamepath), "%s/boot.dol", hdr->path);
if(!fsop_FileExist((const char*)gamepath))
snprintf(gamepath, sizeof(gamepath), "%s/boot.elf", hdr->path);
m_cfg.setString(HOMEBREW_DOMAIN, "current_item", title);
_launchHomebrew(gamepath, m_homebrewArgs);
const char *gamepath = fmt("%s/boot.dol", hdr->path);
if(!fsop_FileExist(gamepath))
gamepath = fmt("%s/boot.elf", hdr->path);
if(fsop_FileExist(gamepath))
{
m_cfg.setString(HOMEBREW_DOMAIN, "current_item", strrchr(hdr->path, '/') + 1);
_launchHomebrew(gamepath, m_homebrewArgs);
}
}
ShutdownBeforeExit();
Sys_Exit();
}
void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
@ -1579,7 +1578,7 @@ void CMenu::_gameSoundThread(CMenu *m)
fclose(fp);
}
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();
if(soundBin != NULL)

View File

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

View File

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

View File

@ -155,7 +155,7 @@ void CMenu::_setDumpMsg(const wstringEx &msg, float totprog, float 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;
m.m_progress = dumpprog == 0 ? 0.f : (float)dumpstat / (float)dumpprog;
@ -634,9 +634,9 @@ int CMenu::_NandFlasher(void *obj)
}
NandHandle.ResetCounters();
m.m_nandexentry = 1;
m.m_dumpsize = NandHandle.CalcFlashSize(source, CMenu::_ShowProgress, obj);
m.m_dumpsize = NandHandle.CalcFlashSize(source, _ShowProgress, obj);
m_nandext = true;
NandHandle.FlashToNAND(source, dest, CMenu::_ShowProgress, obj);
NandHandle.FlashToNAND(source, dest, _ShowProgress, obj);
m.m_thrdWorking = false;
LWP_MutexLock(m.m_mutex);

View File

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

View File

@ -19,12 +19,12 @@ int amount_of_providers = 0;
u8 register_card_provider(const char *url, const char *key)
{
if (strlen(url) > 0 && strlen(key) > 0 && strstr(url, "{KEY}") != NULL && strstr(url, "{ID6}") != NULL)
if(strlen(url) > 0 && strlen(key) > 0 && strstr(url, "{KEY}") != NULL && strstr(url, "{ID6}") != NULL)
{
providers = (struct provider*)MEM2_realloc(providers, (amount_of_providers + 1) * sizeof(struct provider));
memset(&providers[amount_of_providers], 0, sizeof(struct provider));
strncpy((char *) providers[amount_of_providers].url, url, 128);
strncpy((char *) providers[amount_of_providers].key, key, 48);
strncpy(providers[amount_of_providers].url, url, 128);
strncpy(providers[amount_of_providers].key, key, 48);
amount_of_providers++;
gprintf("Gamercard provider is valid!\n");
return 0;
@ -49,7 +49,7 @@ void add_game_to_card(const char *gameid)
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, "{ID6}", gameid, MAX_URL_SIZE);
gprintf("Gamertag URL:\n%s\n", url);

View File

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

View File

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

View File

@ -24,12 +24,12 @@ enum
enum
{
TYPE_WII_GAME = 0,
TYPE_GC_GAME,
TYPE_CHANNEL,
TYPE_PLUGIN,
TYPE_HOMEBREW,
TYPE_END
TYPE_WII_GAME = 0,
TYPE_GC_GAME,
TYPE_CHANNEL,
TYPE_PLUGIN,
TYPE_HOMEBREW,
TYPE_END
};
#define NoGameID(x) (x == TYPE_PLUGIN || x == TYPE_HOMEBREW)