diff --git a/out/bins/app_booter.bin b/out/bins/app_booter.bin index 5b6e1c35..195e0c3f 100644 Binary files a/out/bins/app_booter.bin and b/out/bins/app_booter.bin differ diff --git a/out/bins/ext_booter.bin b/out/bins/ext_booter.bin index e1f67849..1aea4aa1 100644 Binary files a/out/bins/ext_booter.bin and b/out/bins/ext_booter.bin differ diff --git a/out/bins/ext_loader.bin b/out/bins/ext_loader.bin index f392664c..71f243d1 100644 Binary files a/out/bins/ext_loader.bin and b/out/bins/ext_loader.bin differ diff --git a/out/boot.dol b/out/boot.dol index a3635f07..59eb4ee0 100644 Binary files a/out/boot.dol and b/out/boot.dol differ diff --git a/source/channel/nand.cpp b/source/channel/nand.cpp index c9486ccf..8acf9413 100644 --- a/source/channel/nand.cpp +++ b/source/channel/nand.cpp @@ -250,8 +250,8 @@ void Nand::__GetNameList(const char *source, namelist **entries, int *count) u32 i, j, k, l; u32 numentries = 0; char *names = NULL; - char curentry[ISFS_MAXPATH]; - char entrypath[ISFS_MAXPATH]; + char curentry[ISFS_MAXPATH];//64 + char entrypath[ISFS_MAXPATH];//64 s32 ret = ISFS_ReadDir(source, NULL, &numentries); names = (char *)memalign(32, ALIGN32((ISFS_MAXPATH) * numentries)); @@ -284,11 +284,12 @@ void Nand::__GetNameList(const char *source, namelist **entries, int *count) strcpy((*entries)[i].name, curentry); - if(source[strlen(source)-1] == '/') - snprintf(entrypath, sizeof(entrypath), "%s%s", source, curentry); - else - snprintf(entrypath, sizeof(entrypath), "%s/%s", source, curentry); - + /* this could still cause a buffer overrun */ + strcpy(entrypath, source); + if(source[strlen(source)-1] != '/') + strcat(entrypath, "/"); + strcat(entrypath, curentry); + ret = ISFS_ReadDir(entrypath, NULL, &l); (*entries)[i].type = ret < 0 ? 0 : 1; } @@ -774,8 +775,8 @@ s32 Nand::__DumpNandFile(const char *source, const char *dest) s32 Nand::__FlashNandFolder(const char *source, const char *dest) { - char nsource[MAX_FAT_PATH]; - char ndest[ISFS_MAXPATH]; + char nsource[MAX_FAT_PATH];//1024 + char ndest[ISFS_MAXPATH];//64 DIR *dir_iter; struct dirent *ent; @@ -789,11 +790,12 @@ s32 Nand::__FlashNandFolder(const char *source, const char *dest) if(ent->d_name[0] == '.') continue; - if(dest[strlen(dest)-1] == '/') - snprintf(ndest, sizeof(ndest), "%s%s", dest, ent->d_name); - else - snprintf(ndest, sizeof(ndest), "%s/%s", dest, ent->d_name); - + /* this could still cause a buffer overrun */ + strcpy(ndest, dest); + if(dest[strlen(dest)-1] != '/') + strcat(ndest, "/"); + strcat(ndest, ent->d_name); + if(source[strlen(source)-1] == '/') snprintf(nsource, sizeof(nsource), "%s%s", source, ent->d_name); else @@ -830,11 +832,12 @@ s32 Nand::__DumpNandFolder(const char *source, const char *dest) for(i = 0; i < cnt; i++) { - if(source[strlen(source)-1] == '/') - snprintf(nsource, sizeof(nsource), "%s%s", source, names[i].name); - else - snprintf(nsource, sizeof(nsource), "%s/%s", source, names[i].name); - + /* this could still cause a buffer overrun */ + strcpy(nsource, source); + if(source[strlen(source)-1] != '/') + strcat(nsource, "/"); + strcat(nsource, names[i].name); + if(!names[i].type) { __FATify(tdest, nsource); diff --git a/source/devicemounter/usbstorage.c b/source/devicemounter/usbstorage.c index c69cd897..c70af57c 100644 --- a/source/devicemounter/usbstorage.c +++ b/source/devicemounter/usbstorage.c @@ -69,7 +69,7 @@ u32 hdd_sector_size[2] = { 512, 512 }; bool first = false; int usb_libogc_mode = 0; -inline s32 __USBStorage_isMEM2Buffer(const void *buffer) +static inline s32 __USBStorage_isMEM2Buffer(const void *buffer) { u32 high_addr = ((u32)buffer) >> 24; return(high_addr == 0x90) || (high_addr == 0xD0); diff --git a/source/fileOps/fileOps.c b/source/fileOps/fileOps.c index 3536ff90..6c73efa4 100644 --- a/source/fileOps/fileOps.c +++ b/source/fileOps/fileOps.c @@ -63,7 +63,7 @@ u64 fsop_GetFolderBytes(const char *source) { DIR *pdir; struct dirent *pent; - char newSource[300]; + char newSource[1024]; u64 bytes = 0; pdir = opendir(source); @@ -247,7 +247,7 @@ static bool doCopyFolder(const char *source, const char *target, progress_callba { DIR *pdir; struct dirent *pent; - char newSource[300], newTarget[300]; + char newSource[1024], newTarget[1024]; bool ret = true; // If target folder doesn't exist, create it ! @@ -288,7 +288,7 @@ void fsop_deleteFolder(const char *source) { DIR *pdir; struct dirent *pent; - char newSource[300]; + char newSource[1024]; pdir = opendir(source); diff --git a/source/gc/gc.cpp b/source/gc/gc.cpp index 704e0b81..007dca4e 100644 --- a/source/gc/gc.cpp +++ b/source/gc/gc.cpp @@ -264,7 +264,7 @@ void DEVO_SetOptions(const char *isopath, const char *gameID, u8 videomode, u8 l struct stat st; int data_fd; char iso2path[256]; - iso2path[255] = '\0'; + memset(iso2path, 0, sizeof(iso2path)); stat(isopath, &st); FILE *f = fopen(isopath, "rb"); @@ -293,15 +293,15 @@ void DEVO_SetOptions(const char *isopath, const char *gameID, u8 videomode, u8 l char *ptz = strstr(iso2path, "game.iso"); if(ptz != NULL) { - strncpy(ptz, "gam1.iso", 8); + memcpy(ptz, "gam1.iso", 8); f = fopen(iso2path, "rb"); if(f == NULL) { - strncpy(ptz, "gam2.iso", 8); + memcpy(ptz, "gam2.iso", 8); f = fopen(iso2path, "rb"); if(f == NULL) { - strncpy(ptz, "disc2.iso", 9); + memcpy(ptz, "disc2.iso", 9); f = fopen(iso2path, "rb"); } } @@ -379,11 +379,11 @@ void DEVO_SetOptions(const char *isopath, const char *gameID, u8 videomode, u8 l case 2:// PAL60 480i rmode = &TVEurgb60Hz480IntDf; rmode_reg = 5;// VI_EURGB60 - default: + break; case 3:// NTSC 480i + default: rmode = &TVNtsc480IntDf; break; - } /* Set video mode register */ diff --git a/source/gui/coverflow.cpp b/source/gui/coverflow.cpp index 3312ce9d..d4d03c3f 100644 --- a/source/gui/coverflow.cpp +++ b/source/gui/coverflow.cpp @@ -655,8 +655,7 @@ void CCoverFlow::startCoverLoader(void) m_loadingCovers = true; m_moved = true; - LWP_CreateThread(&coverLoaderThread, (void*(*)(void*))CCoverFlow::_coverLoader, - (void*)this, coverThreadStack, coverThreadStackSize, 30); + LWP_CreateThread(&coverLoaderThread, _coverLoader, this, coverThreadStack, coverThreadStackSize, 30); gprintf("Coverflow started!\n"); } @@ -2936,8 +2935,9 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank return _loadCoverTexPNG(i, box, hq, blankBoxCover) ? CL_OK : CL_ERROR; } -int CCoverFlow::_coverLoader(CCoverFlow *cf) +void * CCoverFlow::_coverLoader(void *obj) { + CCoverFlow *cf = static_cast(obj); cf->m_coverThrdBusy = true; CLRet ret; u32 firstItem; diff --git a/source/gui/coverflow.hpp b/source/gui/coverflow.hpp index cfb8d509..11b23e4f 100644 --- a/source/gui/coverflow.hpp +++ b/source/gui/coverflow.hpp @@ -360,7 +360,7 @@ private: static bool _sortByWifiPlayers(CItem item1, CItem item2); private: - static int _coverLoader(CCoverFlow *cf); + static void * _coverLoader(void *obj); static float _step(float cur, float tgt, float spd); private: CCoverFlow(const CCoverFlow &); diff --git a/source/gui/texture.cpp b/source/gui/texture.cpp index 66a49043..bedcd31a 100644 --- a/source/gui/texture.cpp +++ b/source/gui/texture.cpp @@ -222,7 +222,7 @@ TexErr STexture::fromImageFile(TexData &dest, const char *filename, u8 f, u32 mi u8 *Image = fsop_ReadFile(filename, &fileSize); if(Image == NULL) { - strncpy((char*)filename+(strlen(filename)-3), "jp", 2); + memcpy((char*)filename+(strlen(filename)-3), "jp", 2);// change .png to .jpg Image = fsop_ReadFile(filename, &fileSize); } if(Image == NULL) diff --git a/source/gui/video.cpp b/source/gui/video.cpp index 43ff7fb8..9d4f36ad 100644 --- a/source/gui/video.cpp +++ b/source/gui/video.cpp @@ -553,8 +553,9 @@ void CVideo::render(void) GX_InvalidateTexAll(); } -void CVideo::_showWaitMessages(CVideo *m) +void * CVideo::_showWaitMessages(void *obj) { + CVideo *m = static_cast(obj); m->m_showingWaitMessages = true; u32 frames = m->m_waitMessageDelay * 50; u32 waitFrames = frames; @@ -600,6 +601,7 @@ void CVideo::_showWaitMessages(CVideo *m) } //gprintf("Wait Message Thread: End\n"); m->m_showingWaitMessages = false; + return NULL; } void CVideo::hideWaitMessage() @@ -664,8 +666,7 @@ void CVideo::waitMessage(const vector &tex, float delay) wiiLightStartThread(); /* onscreen animation */ m_showWaitMessage = true; - LWP_CreateThread(&waitThread, (void *(*)(void *))_showWaitMessages, - (void*)this, waitMessageStack, waitMessageStackSize, LWP_PRIO_HIGHEST); + LWP_CreateThread(&waitThread, _showWaitMessages, this, waitMessageStack, waitMessageStackSize, LWP_PRIO_HIGHEST); } } diff --git a/source/gui/video.hpp b/source/gui/video.hpp index 32987613..32603e62 100644 --- a/source/gui/video.hpp +++ b/source/gui/video.hpp @@ -120,7 +120,7 @@ private: void _drawAASceneWithAlpha(float w, float h); void _setViewPort(float x, float y, float w, float h); void _clearScreen(); - static void _showWaitMessages(CVideo *m); + static void * _showWaitMessages(void *obj); private: CVideo(const CVideo &); }; diff --git a/source/list/ListGenerator.cpp b/source/list/ListGenerator.cpp index 43591454..76697209 100644 --- a/source/list/ListGenerator.cpp +++ b/source/list/ListGenerator.cpp @@ -180,7 +180,7 @@ static void Create_Plugin_List(char *FullPath) memset((void*)&ListElement, 0, sizeof(dir_discHdr)); strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1); - strncpy(ListElement.id, "PLUGIN", 6); + memcpy(ListElement.id, "PLUGIN", 6); FolderTitle = strrchr(FullPath, '/') + 1; *strrchr(FolderTitle, '.') = '\0'; @@ -211,7 +211,7 @@ static void Create_Homebrew_List(char *FullPath) ListElement.index = m_cacheList.size(); *strrchr(FullPath, '/') = '\0'; strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1); - strncpy(ListElement.id, "HB_APP", 6); + memcpy(ListElement.id, "HB_APP", 6); FolderTitle = strrchr(FullPath, '/') + 1; ListElement.casecolor = CustomTitles.getColor("COVERS", FolderTitle, 0xFFFFFF).intVal(); @@ -239,7 +239,7 @@ static void Create_Channel_List(bool realNAND) ListElement.settings[0] = TITLE_UPPER(chan->title); ListElement.settings[1] = TITLE_LOWER(chan->title); if(chan->title == HBC_108) - strncpy(ListElement.id, "JODI", 4); + memcpy(ListElement.id, "JODI", 4); else strncpy(ListElement.id, chan->id, 4); ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, 0xFFFFFF).intVal(); @@ -385,13 +385,16 @@ void ListGenerator::createSFList(u8 maxBtns, Config &m_sourceMenuCfg, const stri memset((void*)&ListElement, 0, sizeof(dir_discHdr)); ListElement.index = m_cacheList.size(); - strncpy(ListElement.id, "SOURCE", 6); + memcpy(ListElement.id, "SOURCE", 6); strncpy(ListElement.path, path, sizeof(ListElement.path) - 1); ListElement.casecolor = 0xFFFFFF; ListElement.type = TYPE_SOURCE; ListElement.settings[0] = i; - const char *title = m_sourceMenuCfg.getString(btn_selected, "title", fmt("title_%i", i)).c_str(); - mbstowcs(ListElement.title, title, 63); + //const char *title = m_sourceMenuCfg.getString(btn_selected, "title", fmt("title_%i", i)).c_str(); + char SourceTitle[64]; + memset(SourceTitle, 0, sizeof(SourceTitle)); + strncpy(SourceTitle, m_sourceMenuCfg.getString(btn_selected, "title", fmt("title_%i", i)).c_str(), 63); + mbstowcs(ListElement.title, SourceTitle, 63); Asciify(ListElement.title); m_cacheList.push_back(ListElement); } diff --git a/source/loader/gc_disc_dump.cpp b/source/loader/gc_disc_dump.cpp index 68f01c45..b44c38b4 100644 --- a/source/loader/gc_disc_dump.cpp +++ b/source/loader/gc_disc_dump.cpp @@ -290,12 +290,12 @@ s32 GCDump::DumpGame() char *FSTNameOff = NULL; - char folder[MAX_FAT_PATH]; - memset(folder, 0, MAX_FAT_PATH); - char gamepath[MAX_FAT_PATH]; - memset(gamepath, 0, MAX_FAT_PATH); + char folder[MAX_FAT_PATH + 76]; + memset(folder, 0, sizeof(folder)); + char gamepath[MAX_FAT_PATH + 90]; + memset(gamepath, 0, sizeof(gamepath)); char basedir[MAX_FAT_PATH]; - memset(basedir, 0, MAX_FAT_PATH); + memset(basedir, 0, sizeof(basedir)); strncpy(basedir, fmt(gc_gamesDir, gamepartition), MAX_FAT_PATH); while(!gamedone) @@ -409,7 +409,7 @@ s32 GCDump::DumpGame() { char *ptz = strstr(gamepath, "game.iso"); if(ptz != NULL) - strncpy(ptz, "gam1.iso", 8); + memcpy(ptz, "gam1.iso", 8); } gprintf("Writing %s\n", gamepath); if(compressed) diff --git a/source/loader/sys.c b/source/loader/sys.c index 190ea001..4f57374b 100644 --- a/source/loader/sys.c +++ b/source/loader/sys.c @@ -39,6 +39,7 @@ void Open_Inputs(void) WUPC_Init(); WPAD_Init(); DS3_Init(); + //drc /* Set POWER button callback */ WPAD_SetPowerButtonCallback(__Wpad_PowerCallback); diff --git a/source/loader/wbfs_ext.c b/source/loader/wbfs_ext.c index 3697925f..df2d859d 100644 --- a/source/loader/wbfs_ext.c +++ b/source/loader/wbfs_ext.c @@ -146,9 +146,9 @@ s32 WBFS_Ext_RemoveGame(u8 *discid, char *gamepath) { DIR *dir_iter; struct dirent *ent; - char file[MAX_FAT_PATH]; + char file[MAX_FAT_PATH + 768];//not sure why 768 but whatever char folder[MAX_FAT_PATH]; - STRCOPY(folder, gamepath); + STRCOPY(folder, gamepath);//STRCOPY ? char *p = strrchr(folder, '/'); if(p) *p = 0; @@ -160,6 +160,7 @@ s32 WBFS_Ext_RemoveGame(u8 *discid, char *gamepath) { snprintf(file, sizeof(file), "%s/%s", folder, ent->d_name); remove(file); + break; } } closedir(dir_iter); diff --git a/source/memory/memory.h b/source/memory/memory.h index 3b8d863a..1ce52cf3 100644 --- a/source/memory/memory.h +++ b/source/memory/memory.h @@ -36,7 +36,7 @@ #define HW_GPIOB_OUT ((vu32*)0xCD8000C0) #define HW_AHBPROT ((vu32*)0xCD800064) #define HW_PROCESSOR ((vu32*)0xCD8005A0) -#define MEM_PROT ((vu32)0xCD8B420A) +#define MEM_PROT (0xCD8B420A) #define HW_AES_CMD ((vu32)0x0D020000) #define HW_AES_SRC ((vu32)0x0D020004) diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index d0cb7904..323c80c7 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -1973,6 +1973,16 @@ void CMenu::_initCF(void) CoverFlow.clear(); CoverFlow.reserve(m_gameList.size()); + char requiredCats[10]; + char selectedCats[10]; + char hiddenCats[10]; + strcpy(requiredCats, m_cat.getString("GENERAL", "required_categories").c_str()); + strcpy(selectedCats, m_cat.getString("GENERAL", "selected_categories").c_str()); + strcpy(hiddenCats, m_cat.getString("GENERAL", "hidden_categories").c_str()); + u8 numReqCats = strlen(requiredCats); + u8 numSelCats = strlen(selectedCats); + u8 numHidCats = strlen(hiddenCats); + for(vector::iterator hdr = m_gameList.begin(); hdr != m_gameList.end(); ++hdr) { const char *id = NULL; @@ -1994,13 +2004,13 @@ void CMenu::_initCF(void) strcat(tmp1, tmp2); id = tmp1;*/ } - else if(hdr->type == TYPE_HOMEBREW) + if(hdr->type == TYPE_HOMEBREW) { CoverFlow.addItem(&(*hdr), 0, 0); continue; //id = strrchr(hdr->path, '/') + 1; } - else if(hdr->type == TYPE_PLUGIN) + if(hdr->type == TYPE_PLUGIN) { strncpy(m_plugin.PluginMagicWord, fmt("%08x", hdr->settings[0]), 8); wcstombs(tmp2, hdr->title, 64); @@ -2020,37 +2030,26 @@ void CMenu::_initCF(void) id = tmp1; } } + if((!m_favorites || m_gcfg1.getBool(favDomain, id, false)) && (!m_locked || !m_gcfg1.getBool(adultDomain, id, false))) { - const char *catDomain = NULL; - switch(hdr->type) - { - case TYPE_CHANNEL: - catDomain = "NAND"; - break; - case TYPE_EMUCHANNEL: - catDomain = "CHANNELS"; - break; - case TYPE_GC_GAME: - catDomain = "GAMECUBE"; - break; - case TYPE_WII_GAME: - catDomain = "WII"; - break; - default: - catDomain = m_plugin.PluginMagicWord; - break; - } - const char *requiredCats = m_cat.getString("GENERAL", "required_categories").c_str(); - const char *selectedCats = m_cat.getString("GENERAL", "selected_categories").c_str(); - const char *hiddenCats = m_cat.getString("GENERAL", "hidden_categories").c_str(); - u8 numReqCats = strlen(requiredCats); - u8 numSelCats = strlen(selectedCats); - u8 numHidCats = strlen(hiddenCats); + string catDomain = ""; + if(hdr->type == TYPE_CHANNEL) + catDomain = "NAND"; + else if(hdr->type == TYPE_EMUCHANNEL) + catDomain = "CHANNELS"; + else if(hdr->type == TYPE_GC_GAME) + catDomain = "GAMECUBE"; + else if(hdr->type == TYPE_WII_GAME) + catDomain = "WII"; + else + catDomain = m_plugin.PluginMagicWord; + if(numReqCats != 0 || numSelCats != 0 || numHidCats != 0) // if all 0 skip checking cats and show all games { - const char *idCats = m_cat.getString(catDomain, hdr->type == TYPE_PLUGIN? catID : id).c_str(); + char idCats[10]; + strcpy(idCats, m_cat.getString(catDomain, hdr->type == TYPE_PLUGIN? catID : id).c_str()); u8 numIdCats = strlen(idCats); bool inaCat = false; bool inHiddenCat = false; diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index bdf07e33..d5fc2088 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -398,8 +398,8 @@ private: s16 m_downloadBtnKOs; s16 m_downloadBtnZHCNs; s16 m_downloadBtnAUs; - static s8 _versionDownloaderInit(CMenu *m); - static s8 _versionTxtDownloaderInit(CMenu *m); + static void * _versionDownloaderInit(void *obj); + static void * _versionTxtDownloaderInit(void *obj); s8 _versionDownloader(); s8 _versionTxtDownloader(); //Game menu @@ -1122,7 +1122,7 @@ private: void _cleanupBanner(bool gamechange = false); void _cleanupVideo(); bool _startVideo(); - static int _pThread(void *obj); + static void * _pThread(void *obj); void _start_pThread(void); void _stop_pThread(void); lwp_t m_thrdPtr; @@ -1152,10 +1152,10 @@ private: void _setThrdMsg(const wstringEx &msg, float progress); void _setDumpMsg(const wstringEx &msg, float progress, float fileprog); int _coverDownloader(bool missingOnly); - static int _coverDownloaderAll(CMenu *m); - static int _coverDownloaderMissing(CMenu *m); + static void * _coverDownloaderAll(void *obj); + static void * _coverDownloaderMissing(void *obj); static bool _downloadProgress(void *obj, int size, int position); - static int _gametdbDownloader(CMenu *m); + static void * _gametdbDownloader(void *obj); int _gametdbDownloaderAsync(); static s32 _networkComplete(s32 result, void *usrData); @@ -1165,8 +1165,8 @@ private: void LoadView(void); static void _addDiscProgress(int status, int total, 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 _GCcopyGame(void *obj); + static void * _gameInstaller(void *obj); + static void * _GCcopyGame(void *obj); bool _searchGamesByID(const char *gameId); int _GCgameInstaller(); float m_progress; @@ -1179,8 +1179,8 @@ private: int m_nandexentry; wstringEx _optBoolToString(int b); void _stopSounds(void); - static int _NandDumper(void *obj); - static int _NandFlasher(void *obj); + static void * _NandDumper(void *obj); + static void * _NandFlasher(void *obj); int _FindEmuPart(string &emuPath, bool searchvalid, bool savesnand); bool _checkSave(string id, bool nand); bool _TestEmuNand(int epart, const char *path, bool indept); @@ -1188,13 +1188,13 @@ private: void _FullNandCheck(void); void _listEmuNands(const char *path, vector &emuNands); - static u32 _downloadCheatFileAsync(void *obj); - static u32 _downloadBannerAsync(void *obj); - static u32 _downloadUrlAsync(void *obj); + static void * _downloadCheatFileAsync(void *obj); + static void * _downloadBannerAsync(void *obj); + static void * _downloadUrlAsync(void *obj); void _playGameSound(void); void _stopGameSoundThread(void); - static void _gameSoundThread(CMenu *m); + static void * _gameSoundThread(void *obj); static void _load_installed_cioses(); diff --git a/source/menu/menu_cheat.cpp b/source/menu/menu_cheat.cpp index 90cef3a8..9f5947bc 100644 --- a/source/menu/menu_cheat.cpp +++ b/source/menu/menu_cheat.cpp @@ -24,7 +24,7 @@ void CMenu::_showCheatDownload(void) m_btnMgr.show(m_downloadPBar); } -u32 CMenu::_downloadCheatFileAsync(void *obj) +void * CMenu::_downloadCheatFileAsync(void *obj) { CMenu *m = (CMenu *)obj; if (!m->m_thrdWorking) @@ -39,7 +39,7 @@ u32 CMenu::_downloadCheatFileAsync(void *obj) if (m->_initNetwork() < 0) { m->m_thrdWorking = false; - return -1; + return 0; } u32 bufferSize = 0x080000; // Maximum download size 512kb @@ -47,7 +47,7 @@ u32 CMenu::_downloadCheatFileAsync(void *obj) if(buffer == NULL) { m->m_thrdWorking = false; - return -2; + return 0; } const char *id = CoverFlow.getId(); @@ -64,7 +64,7 @@ u32 CMenu::_downloadCheatFileAsync(void *obj) } free(buffer); m->m_thrdWorking = false; - return -3; + return 0; } void CMenu::_CheatSettings() @@ -176,8 +176,7 @@ void CMenu::_CheatSettings() m_thrdWorking = true; lwp_t thread = LWP_THREAD_NULL; - LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_downloadCheatFileAsync, - (void *)this, downloadStack, downloadStackSize, 40); + LWP_CreateThread(&thread, _downloadCheatFileAsync, this, downloadStack, downloadStackSize, 40); while(m_thrdWorking) { _mainLoopCommon(); diff --git a/source/menu/menu_download.cpp b/source/menu/menu_download.cpp index c3509498..e7064af1 100644 --- a/source/menu/menu_download.cpp +++ b/source/menu/menu_download.cpp @@ -79,6 +79,7 @@ static string countryCode(const string &gameId) case CONF_LANG_DUTCH: return "NL"; } + return "other"; case 'A': switch (CONF_GetArea()) { @@ -335,17 +336,21 @@ bool CMenu::_downloadProgress(void *obj, int size, int position) return !m->m_thrdStop; } -int CMenu::_coverDownloaderAll(CMenu *m) +void * CMenu::_coverDownloaderAll(void *obj) { - if (!m->m_thrdWorking) return 0; + CMenu *m = static_cast(obj); + if(!m->m_thrdWorking) + return 0; m->_coverDownloader(false); m->m_thrdWorking = false; return 0; } -int CMenu::_coverDownloaderMissing(CMenu *m) +void * CMenu::_coverDownloaderMissing(void *obj) { - if (!m->m_thrdWorking) return 0; + CMenu *m = static_cast(obj); + if(!m->m_thrdWorking) + return 0; m->_coverDownloader(true); m->m_thrdWorking = false; return 0; @@ -434,22 +439,20 @@ int CMenu::_initNetwork() int CMenu::_coverDownloader(bool missingOnly) { - vector coverIDList; - int count = 0, countFlat = 0; float listWeight = missingOnly ? 0.125f : 0.f; // 1/8 of the progress bar for testing the PNGs we already have float dlWeight = 1.f - listWeight; - u32 bufferSize = 0x280000; // Maximum download size 2 MB - u8 *buffer = (u8*)MEM2_alloc(bufferSize); - if(buffer == NULL) + Config m_newID; + m_newID.load(fmt("%s/newid.ini", m_settingsDir.c_str())); + + GameTDB c_gameTDB; + if(m_settingsDir.size() > 0) { - LWP_MutexLock(m_mutex); - _setThrdMsg(_t("dlmsg27", L"Not enough memory!"), 1.f); - LWP_MutexUnlock(m_mutex); - m_thrdWorking = false; - return 0; + c_gameTDB.OpenFile(fmt("%s/wiitdb.xml", m_settingsDir.c_str())); + c_gameTDB.SetLanguageCode(m_curLanguage.c_str()); } + bool savePNG = m_cfg.getBool("GENERAL", "keep_png", true); vector fmtURLBox = stringToVector(m_cfg.getString("GENERAL", "url_full_covers", FMT_BPIC_URL), '|'); @@ -460,20 +463,15 @@ int CMenu::_coverDownloader(bool missingOnly) u32 nbSteps = m_gameList.size(); u32 step = 0; - GameTDB c_gameTDB; - if (m_settingsDir.size() > 0) - { - c_gameTDB.OpenFile(fmt("%s/wiitdb.xml", m_settingsDir.c_str())); - c_gameTDB.SetLanguageCode(m_curLanguage.c_str()); - } char path[256]; char id[7]; - + vector coverIDList; + /* create list of cover ID's that need downloading */ - if (m_coverDLGameId.empty()) + if(m_coverDLGameId.empty()) { coverIDList.reserve(m_gameList.size()); - for (u32 i = 0; i < m_gameList.size() && !m_thrdStop; ++i) + for(u32 i = 0; i < m_gameList.size() && !m_thrdStop; ++i) { LWP_MutexLock(m_mutex); _setThrdMsg(_t("dlmsg7", L"Listing covers to download..."), listWeight * (float)step / (float)nbSteps); @@ -489,7 +487,7 @@ int CMenu::_coverDownloader(bool missingOnly) strncpy(id, m_gameList[i].id, 6); strncpy(path, fmt("%s/%s.png", m_boxPicDir.c_str(), id), 255); } - if(!missingOnly || (strlen(id) > 0 && !CoverFlow.fullCoverCached(id) && strlen(path) > 0 && !checkPNGFile(path))) + if(!missingOnly || (strlen(path) > 0 && fsop_FileExist(path))) { if(strlen(id) > 0) coverIDList.push_back(id); @@ -500,29 +498,48 @@ int CMenu::_coverDownloader(bool missingOnly) coverIDList.push_back(m_coverDLGameId); u32 n = coverIDList.size(); - + + u32 bufferSize = 0x280000; // Maximum download size 2 MB + u8 *buffer = (u8*)MEM2_alloc(bufferSize); + if(buffer == NULL) + { + LWP_MutexLock(m_mutex); + _setThrdMsg(_t("dlmsg27", L"Not enough memory!"), 1.f); + LWP_MutexUnlock(m_mutex); + m_thrdWorking = false; + if(c_gameTDB.IsLoaded()) + c_gameTDB.CloseFile(); + coverIDList.clear(); + if(m_newID.loaded()) + m_newID.unload(); + return 0; + } + /* initialize network connection */ - if (n > 0 && !m_thrdStop) + if(n > 0 && !m_thrdStop) { step = 0; nbSteps = 1 + n * 2; LWP_MutexLock(m_mutex); _setThrdMsg(_t("dlmsg1", L"Initializing network..."), listWeight + dlWeight * (float)step / (float)nbSteps); LWP_MutexUnlock(m_mutex); - if (_initNetwork() < 0) + if(_initNetwork() < 0) { LWP_MutexLock(m_mutex); _setThrdMsg(_t("dlmsg2", L"Network initialization failed!"), 1.f); LWP_MutexUnlock(m_mutex); m_thrdWorking = false; - free(buffer); + MEM2_free(buffer); + if(c_gameTDB.IsLoaded()) + c_gameTDB.CloseFile(); + coverIDList.clear(); + if(m_newID.loaded()) + m_newID.unload(); return 0; } m_thrdStepLen = dlWeight / (float)nbSteps; /* download covers in the list */ - Config m_newID; - m_newID.load(fmt("%s/newid.ini", m_settingsDir.c_str())); u32 CoverType = 0; for(u32 i = 0; i < coverIDList.size() && !m_thrdStop; ++i) @@ -546,8 +563,10 @@ int CMenu::_coverDownloader(bool missingOnly) } } + /* try downloading the cover 4 times but a different type each time.*/ for(int p = 0; p < 4; ++p) { + /* the cover type (BOX, CBOX, FLAT, CFLAT) is different each time based on m_downloadPrioVal */ switch(p) { case 0: @@ -577,20 +596,23 @@ int CMenu::_coverDownloader(bool missingOnly) /* if cover png doesn't already exist download it */ if(strlen(path) > 0 && !checkPNGFile(path)) { - for(u32 j = 0; !success && j < fmtURLBox.size() && !m_thrdStop; ++j) + /* each fmtURL may have more than one URL */ + for(u8 j = 0; !success && j < fmtURLBox.size() && !m_thrdStop; ++j) { url = makeURL(fmtURLBox[j], coverID, countryCode(coverID)); + if (j == 0) ++step; m_thrdStep = listWeight + dlWeight * (float)step / (float)nbSteps; LWP_MutexLock(m_mutex); - _setThrdMsg(wfmt(_fmt("dlmsg3", L"Downloading from %s"), url.c_str()), m_thrdStep); + // add in n count decreasing + _setThrdMsg(wfmt(_fmt("dlmsg3", L"Downloading %i/%i from %s"), i + 1, n, url.c_str()), m_thrdStep); LWP_MutexUnlock(m_mutex); download = downloadfile(buffer, bufferSize, url.c_str(), CMenu::_downloadProgress, this); for(int o = 0; o < 12; ++o) { bool tdl = false; - if(download.data != NULL && download.size > 0 && checkPNGBuf(download.data)) + if(download.data != NULL && download.size > 0)// && checkPNGBuf(download.data)) break; switch( o ) { @@ -683,7 +705,7 @@ int CMenu::_coverDownloader(bool missingOnly) } } - if(download.data == NULL || download.size == 0 || !checkPNGBuf(download.data)) + if(download.data == NULL || download.size == 0)// || !checkPNGBuf(download.data)) continue; if (savePNG) @@ -1125,11 +1147,6 @@ int CMenu::_coverDownloader(bool missingOnly) } ++step; } - if(c_gameTDB.IsLoaded()) - c_gameTDB.CloseFile(); - coverIDList.clear(); - if(m_newID.loaded()) - m_newID.unload(); } LWP_MutexLock(m_mutex); if (countFlat == 0) @@ -1137,8 +1154,14 @@ int CMenu::_coverDownloader(bool missingOnly) else _setThrdMsg(wfmt(_fmt("dlmsg9", L"%i/%i files downloaded. %i are front covers only."), count + countFlat, n, countFlat), 1.f); LWP_MutexUnlock(m_mutex); + m_thrdWorking = false; MEM2_free(buffer); + if(c_gameTDB.IsLoaded()) + c_gameTDB.CloseFile(); + coverIDList.clear(); + if(m_newID.loaded()) + m_newID.unload(); return 0; } @@ -1197,11 +1220,9 @@ void CMenu::_download(string gameId) m_thrdWorking = true; gameId.clear(); if (dlAll) - LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_coverDownloaderAll, - (void *)this, downloadStack, downloadStackSize, 40); + LWP_CreateThread(&thread, _coverDownloaderAll, this, downloadStack, downloadStackSize, 40); else - LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_coverDownloaderMissing, - (void *)this, downloadStack, downloadStackSize, 40); + LWP_CreateThread(&thread, _coverDownloaderMissing, this, downloadStack, downloadStackSize, 40); } else if (m_btnMgr.selected(m_downloadBtnPrioM) && !m_thrdWorking) { @@ -1428,8 +1449,7 @@ void CMenu::_download(string gameId) _updateGametdb = true; - LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_gametdbDownloader, - (void *)this, downloadStack, downloadStackSize, 40); + LWP_CreateThread(&thread, _gametdbDownloader, this, downloadStack, downloadStackSize, 40); } else if (m_btnMgr.selected(m_downloadBtnCancel)) { @@ -1604,10 +1624,13 @@ void CMenu::_textDownload(void) m_btnMgr.setText(m_downloadBtnBack, _t("dl18", L"Back")); } -s8 CMenu::_versionTxtDownloaderInit(CMenu *m) //Handler to download versions txt file +void * CMenu::_versionTxtDownloaderInit(void *obj) //Handler to download versions txt file { - if (!m->m_thrdWorking) return 0; - return m->_versionTxtDownloader(); + CMenu *m = static_cast(obj); + if(!m->m_thrdWorking) + return 0; + m->_versionTxtDownloader(); + return 0; } s8 CMenu::_versionTxtDownloader() // code to download new version txt file @@ -1694,11 +1717,13 @@ s8 CMenu::_versionTxtDownloader() // code to download new version txt file return 0; } -s8 CMenu::_versionDownloaderInit(CMenu *m) //Handler to download new dol +void * CMenu::_versionDownloaderInit(void *obj) //Handler to download new dol { - if (!m->m_thrdWorking) + CMenu *m = static_cast(obj); + if(!m->m_thrdWorking) return 0; - return m->_versionDownloader(); + m->_versionDownloader(); + return 0; } s8 CMenu::_versionDownloader() // code to download new version @@ -1887,10 +1912,13 @@ out: return 0; } -int CMenu::_gametdbDownloader(CMenu *m) +void * CMenu::_gametdbDownloader(void *obj) { - if (!m->m_thrdWorking) return 0; - return m->_gametdbDownloaderAsync(); + CMenu *m = static_cast(obj); + if(!m->m_thrdWorking) + return 0; + m->_gametdbDownloaderAsync(); + return 0; } int CMenu::_gametdbDownloaderAsync() @@ -1983,10 +2011,10 @@ int CMenu::_gametdbDownloaderAsync() const char *banner_url = NULL; const char *banner_url_id3 = NULL; char *banner_location = NULL; -u32 CMenu::_downloadBannerAsync(void *obj) +void * CMenu::_downloadBannerAsync(void *obj) { CMenu *m = (CMenu *)obj; - if (!m->m_thrdWorking) + if(!m->m_thrdWorking) return 0; m->m_thrdStop = false; @@ -1995,13 +2023,13 @@ u32 CMenu::_downloadBannerAsync(void *obj) m->_setThrdMsg(m->_t("cfgbnr7", L"Downloading banner..."), 0); LWP_MutexUnlock(m->m_mutex); - if (m->_initNetwork() < 0) + if(m->_initNetwork() < 0) { LWP_MutexLock(m->m_mutex); m->_setThrdMsg(m->_t("dlmsg2", L"Network initialization failed!"), 1.f); LWP_MutexUnlock(m->m_mutex); m->m_thrdWorking = false; - return -1; + return 0; } u32 bufferSize = 0x400000; /* 4mb max */ @@ -2012,14 +2040,14 @@ u32 CMenu::_downloadBannerAsync(void *obj) m->_setThrdMsg(m->_t("dlmsg27", L"Not enough memory!"), 1.f); LWP_MutexUnlock(m->m_mutex); m->m_thrdWorking = false; - return -2; + return 0; } block banner = downloadfile(buffer, bufferSize, banner_url, CMenu::_downloadProgress, m); if(banner.data == NULL || banner.size < 0x5000) banner = downloadfile(buffer, bufferSize, banner_url_id3, CMenu::_downloadProgress, m); /* minimum 50kb */ - if (banner.data != NULL && banner.size > 51200 && banner.data[0] != '<') + if(banner.data != NULL && banner.size > 51200 && banner.data[0] != '<') { if(banner_location != NULL) fsop_WriteFile(banner_location, banner.data, banner.size); @@ -2037,8 +2065,9 @@ u32 CMenu::_downloadBannerAsync(void *obj) LWP_MutexUnlock(m->m_mutex); m->m_thrdWorking = false; free(buffer); - return -3; + return 0; } + return 0; } static const char *GAME_BNR_ID = "{gameid}"; @@ -2069,8 +2098,7 @@ void CMenu::_downloadBnr(const char *gameID) m_thrdWorking = true; lwp_t thread = LWP_THREAD_NULL; - LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_downloadBannerAsync, - (void *)this, downloadStack, downloadStackSize, 40); + LWP_CreateThread(&thread, _downloadBannerAsync, this, downloadStack, downloadStackSize, 40); wstringEx prevMsg; while(m_thrdWorking) @@ -2137,7 +2165,7 @@ void CMenu::_downloadBnr(const char *gameID) } const char *url_dl = NULL; -void CMenu::_downloadUrl(const char *url, u8 **dl_file, u32 *dl_size) +void CMenu::_downloadUrl(const char *url, u8 **dl_file, u32 *dl_size)// nothing uses this { m_file = NULL; m_filesize = 0; @@ -2152,8 +2180,7 @@ void CMenu::_downloadUrl(const char *url, u8 **dl_file, u32 *dl_size) m_thrdWorking = true; lwp_t thread = LWP_THREAD_NULL; - LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_downloadUrlAsync, - (void *)this, downloadStack, downloadStackSize, 40); + LWP_CreateThread(&thread, _downloadUrlAsync, this, downloadStack, downloadStackSize, 40); wstringEx prevMsg; while(m_thrdWorking) @@ -2212,7 +2239,7 @@ void CMenu::_downloadUrl(const char *url, u8 **dl_file, u32 *dl_size) url_dl = url; } -u32 CMenu::_downloadUrlAsync(void *obj) +void * CMenu::_downloadUrlAsync(void *obj) { CMenu *m = (CMenu *)obj; if (!m->m_thrdWorking) @@ -2227,7 +2254,7 @@ u32 CMenu::_downloadUrlAsync(void *obj) if(m->_initNetwork() < 0 || url_dl == NULL) { m->m_thrdWorking = false; - return -1; + return 0; } u32 bufferSize = 0x400000; /* 4mb max */ @@ -2235,7 +2262,7 @@ u32 CMenu::_downloadUrlAsync(void *obj) if(m->m_buffer == NULL) { m->m_thrdWorking = false; - return -2; + return 0; } block file = downloadfile(m->m_buffer, bufferSize, url_dl, CMenu::_downloadProgress, m); DCFlushRange(m->m_buffer, bufferSize); diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index ba5fd3ba..31baf2ce 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -1209,8 +1209,9 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc) else { // otherwise copy cheat file from wiiflow cheat folder to Game folder - snprintf(CheatPath, sizeof(CheatPath), "%s%s.gct", GC_Path, id); - fsop_CopyFile(fmt("%s/%s.gct", m_cheatDir.c_str(), id), CheatPath, NULL, NULL); + char GC_game_dir[strlen(GC_Path) + 11]; + snprintf(GC_game_dir, sizeof(GC_game_dir), "%s%s.gct", GC_Path, id); + fsop_CopyFile(fmt("%s/%s.gct", m_cheatDir.c_str(), id), GC_game_dir, NULL, NULL); //might add err msg here if copy error } } @@ -1483,7 +1484,12 @@ void CMenu::_launchChannel(dir_discHdr *hdr) u8 patchVidMode = min(m_gcfg2.getUInt(id, "patch_video_modes", 0), ARRAY_SIZE(CMenu::_vidModePatch) - 1u); int aspectRatio = min(m_gcfg2.getUInt(id, "aspect_ratio", 0), ARRAY_SIZE(CMenu::_AspectRatio) - 1) - 1;// -1,0,1 - const char *rtrn = m_gcfg2.getBool(id, "returnto", true) ? m_cfg.getString("GENERAL", "returnto").c_str() : NULL; + + //u32 returnTo = 0; + //const char *rtrn = m_cfg.getString("GENERAL", "returnto").c_str(); + //if(strlen(rtrn) == 4) + // returnTo = rtrn[0] << 24 | rtrn[1] << 16 | rtrn[2] << 8 | rtrn[3]; + const char *rtrn = m_cfg.getString("GENERAL", "returnto").c_str(); u32 returnTo = rtrn[0] << 24 | rtrn[1] << 16 | rtrn[2] << 8 | rtrn[3]; u8 *cheatFile = NULL; @@ -1696,7 +1702,9 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd, bool disc_cfg) int language = min(m_gcfg2.getUInt(id, "language", 0), ARRAY_SIZE(CMenu::_languages) - 1u); language = (language == 0) ? min(m_cfg.getUInt("GENERAL", "game_language", 0), ARRAY_SIZE(CMenu::_languages) - 1u) : language; - const char *rtrn = m_cfg.getString("GENERAL", "returnto", "").c_str(); + const char *rtrn = m_cfg.getString("GENERAL", "returnto").c_str(); + u32 returnTo = rtrn[0] << 24 | rtrn[1] << 16 | rtrn[2] << 8 | rtrn[3]; + int aspectRatio = min(m_gcfg2.getUInt(id, "aspect_ratio", 0), ARRAY_SIZE(CMenu::_AspectRatio) - 1u) - 1; u8 patchVidMode = min(m_gcfg2.getUInt(id, "patch_video_modes", 0), ARRAY_SIZE(CMenu::_vidModePatch) - 1u); @@ -1723,9 +1731,10 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd, bool disc_cfg) bool need_config = false; bool need_miis = false; - char testpath[MAX_FAT_PATH]; + //char testpath[MAX_FAT_PATH]; char basepath[MAX_FAT_PATH]; snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPart], emuPath.c_str()); + char testpath[strlen(basepath) + 42]; // does not check to see if actual tmd exist just if the folder exist if(!_checkSave(id, false))//if save is not on emunand @@ -1774,7 +1783,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd, bool disc_cfg) u8 *cheatFile = NULL; u8 *gameconfig = NULL; - u32 cheatSize = 0, gameconfigSize = 0, returnTo = 0; + u32 cheatSize = 0, gameconfigSize = 0; m_gcfg1.setInt("PLAYCOUNT", id, m_gcfg1.getInt("PLAYCOUNT", id, 0) + 1); m_gcfg1.setUInt("LASTPLAYED", id, time(NULL)); @@ -1789,8 +1798,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd, bool disc_cfg) _loadFile(cheatFile, cheatSize, m_cheatDir.c_str(), fmt("%s.gct", id.c_str())); _loadFile(gameconfig, gameconfigSize, m_txtCheatDir.c_str(), "gameconfig.txt"); - if(strlen(rtrn) == 4) - returnTo = rtrn[0] << 24 | rtrn[1] << 16 | rtrn[2] << 8 | rtrn[3]; int userIOS = m_gcfg2.getInt(id, "ios", 0); int gameIOS = dvd && !neek2o() ? userIOS : GetRequestedGameIOS(hdr); @@ -1971,8 +1978,9 @@ struct IMD5Header } ATTRIBUTE_PACKED; // loads game banner and sound to be played by mainloop -void CMenu::_gameSoundThread(CMenu *m) +void * CMenu::_gameSoundThread(void *obj) { + CMenu *m = (CMenu*)obj; m->m_soundThrdBusy = true; m->m_gamesound_changed = false; CurrentBanner.ClearBanner();//clear current banner from memory @@ -2015,7 +2023,7 @@ void CMenu::_gameSoundThread(CMenu *m) if(m->m_gameSound.IsLoaded()) m->m_gamesound_changed = true; m->m_soundThrdBusy = false; - return; + return NULL; } } else @@ -2066,7 +2074,7 @@ void CMenu::_gameSoundThread(CMenu *m) if(m->m_gameSound.IsLoaded()) m->m_gamesound_changed = true; m->m_soundThrdBusy = false; - return; + return NULL; } if(custom_bnr_file == NULL)/* no custom and not GC game try cached banner id6 only*/ { @@ -2105,7 +2113,7 @@ void CMenu::_gameSoundThread(CMenu *m) m_banner.DeleteBanner(); CurrentBanner.ClearBanner(); m->m_soundThrdBusy = false; - return; + return NULL; } //save new wii or channel banner to cache folder, gc and custom banners are not cached if(cached_bnr_file == NULL && custom_bnr_file == NULL) @@ -2131,7 +2139,7 @@ void CMenu::_gameSoundThread(CMenu *m) m->m_gameSound.FreeMemory(); m_banner.DeleteBanner(); m->m_soundThrdBusy = false; - return; + return NULL; } } else @@ -2152,6 +2160,7 @@ void CMenu::_gameSoundThread(CMenu *m) m->m_gameSound.FreeMemory(); } m->m_soundThrdBusy = false; + return NULL; } u8 *GameSoundStack = NULL; @@ -2166,7 +2175,7 @@ void CMenu::_playGameSound(void)// starts banner and gamesound loading thread if(m_gameSoundThread != LWP_THREAD_NULL) _stopGameSoundThread(); GameSoundStack = (u8*)MEM2_lo_alloc(GameSoundSize); - LWP_CreateThread(&m_gameSoundThread, (void *(*)(void *))CMenu::_gameSoundThread, (void*)this, GameSoundStack, GameSoundSize, 60); + LWP_CreateThread(&m_gameSoundThread, _gameSoundThread, this, GameSoundStack, GameSoundSize, 60); } void CMenu::_stopGameSoundThread()//stops banner and gamesound loading thread diff --git a/source/menu/menu_input.cpp b/source/menu/menu_input.cpp index 2c4eedc8..66a23617 100644 --- a/source/menu/menu_input.cpp +++ b/source/menu/menu_input.cpp @@ -69,6 +69,7 @@ void CMenu::ScanInput() WPAD_ScanPads(); PAD_ScanPads(); DS3_ScanPads(); + //drc ButtonsPressed(); ButtonsHeld(); @@ -130,6 +131,7 @@ void CMenu::ScanInput() ShowNextZone(); ShowGameZone(); } + extern "C" { extern bool shutdown; }; void CMenu::ButtonsPressed() { @@ -150,6 +152,7 @@ void CMenu::ButtonsPressed() wii_btnsPressed[chan] = WPAD_ButtonsDown(chan); gc_btnsPressed |= PAD_ButtonsDown(chan); wupc_btnsPressed[chan] = WUPC_ButtonsDown(chan); + //drc } } } @@ -162,6 +165,7 @@ void CMenu::ButtonsHeld() wii_btnsHeld[chan] = WPAD_ButtonsHeld(chan); gc_btnsHeld |= PAD_ButtonsHeld(chan); wupc_btnsHeld[chan] = WUPC_ButtonsHeld(chan); + //drc } } @@ -238,8 +242,7 @@ void CMenu::LeftStick() } else { - if(pointerhidedelay[chan] > 0 && !wii_btnsHeld[chan] && !wii_btnsPressed[chan] - && !gc_btnsHeld && !gc_btnsPressed) + if(pointerhidedelay[chan] > 0 && !wii_btnsHeld[chan] && !wii_btnsPressed[chan] && !gc_btnsHeld && !gc_btnsPressed) pointerhidedelay[chan]--; } if (pointerhidedelay[chan] == 0) @@ -310,9 +313,9 @@ bool CMenu::wii_btnRepeat(u8 btn) else m_wpadDownDelay = 0; } - else if(btn == WBTN_LEFT || DBTN_LEFT) + else if(btn == WBTN_LEFT) { - if(WBTN_LEFT_HELD || DBTN_LEFT_PRESSED) + if(WBTN_LEFT_HELD) { if(m_wpadLeftDelay == 0 || m_wpadLeftDelay >= g_repeatDelay) b = true; diff --git a/source/menu/menu_nandemu.cpp b/source/menu/menu_nandemu.cpp index 921efd62..e47acfc2 100644 --- a/source/menu/menu_nandemu.cpp +++ b/source/menu/menu_nandemu.cpp @@ -204,20 +204,19 @@ void CMenu::_FullNandCheck(void) bool need_config = false; bool need_miis = false; - char testpath[MAX_FAT_PATH]; - char basepath[MAX_FAT_PATH]; - snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPart], emuPath.c_str()); + string testpath; + string basepath = DeviceName[emuPart] + ':' + emuPath; //check config files - snprintf(testpath, sizeof(testpath), "%s/shared2/sys/SYSCONF", basepath); - if(!fsop_FileExist(testpath)) + testpath.assign(basepath + "/shared2/sys/SYSCONF"); + if(!fsop_FileExist(testpath.c_str())) need_config = true; - snprintf(testpath, sizeof(testpath), "%s/title/00000001/00000002/data/setting.txt", basepath); - if(!fsop_FileExist(testpath)) + testpath.assign(basepath + "/title/00000001/00000002/data/setting.txt"); + if(!fsop_FileExist(testpath.c_str())) need_config = true; // Check Mii's - snprintf(testpath, sizeof(testpath), "%s/shared2/menu/FaceLib/RFL_DB.dat", basepath); - if(!fsop_FileExist(testpath)) + testpath.assign(basepath + "/shared2/menu/FaceLib/RFL_DB.dat"); + if(!fsop_FileExist(testpath.c_str())) need_miis = true; NandHandle.PreNandCfg(need_miis, need_config);//copy to emunand if needed @@ -623,7 +622,7 @@ int CMenu::_NandEmuCfg(void) m_thrdStop = false; m_thrdProgress = 0.f; m_thrdWorking = true; - LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_NandDumper, (void *)this, 0, 32768, 40); + LWP_CreateThread(&thread, _NandDumper, this, 0, 32768, 40); } } else if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnNandSelectP) || m_btnMgr.selected(m_nandemuBtnNandSelectM))) @@ -738,7 +737,7 @@ int CMenu::_FlashSave(string gameId) m_thrdStop = false; m_thrdProgress = 0.f; m_thrdWorking = true; - LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_NandFlasher, (void *)this, 0, 32768, 40); + LWP_CreateThread(&thread, _NandFlasher, this, 0, 32768, 40); } if(!m_thrdWorking && (BTN_HOME_PRESSED || BTN_B_PRESSED || (BTN_A_PRESSED && m_btnMgr.selected(m_nandemuBtnBack)))) break; @@ -848,7 +847,7 @@ int CMenu::_AutoExtractSave(string gameId)// called from wii game config menu or m_thrdStop = false; m_thrdProgress = 0.f; m_thrdWorking = true; - LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_NandDumper, (void *)this, 0, 32768, 40); + LWP_CreateThread(&thread, _NandDumper, this, 0, 32768, 40); } else if(BTN_A_PRESSED && m_btnMgr.selected(m_nandemuBtnDisable))//create new save { @@ -887,7 +886,7 @@ int CMenu::_AutoExtractSave(string gameId)// called from wii game config menu or return 1; } -int CMenu::_NandFlasher(void *obj) +void * CMenu::_NandFlasher(void *obj) { CMenu &m = *(CMenu *)obj; @@ -928,7 +927,7 @@ int CMenu::_NandFlasher(void *obj) return 0; } -int CMenu::_NandDumper(void *obj) +void * CMenu::_NandDumper(void *obj) { CMenu &m = *(CMenu *)obj; diff --git a/source/menu/menu_system.cpp b/source/menu/menu_system.cpp index fd42c574..a39220e3 100644 --- a/source/menu/menu_system.cpp +++ b/source/menu/menu_system.cpp @@ -47,8 +47,7 @@ void CMenu::_system() m_btnMgr.setProgress(m_downloadPBar, 0.f); m_thrdStop = false; m_thrdWorking = true; - LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_versionTxtDownloaderInit, - (void *)this, downloadStack, downloadStackSize, 40); + LWP_CreateThread(&thread, _versionTxtDownloaderInit, this, downloadStack, downloadStackSize, 40); } if (m_showtimer > 0 && !m_thrdWorking) { @@ -113,8 +112,7 @@ void CMenu::_system() m_data_update_url = fmt("%s/r%i/data.zip", ("http://nintendont.gxarena.com/banners"), newVer); m_showtimer = 120; - LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_versionDownloaderInit, - (void *)this, downloadStack, downloadStackSize, 40); + LWP_CreateThread(&thread, _versionDownloaderInit, this, downloadStack, downloadStackSize, 40); if (m_exit && !m_thrdWorking) { m_thrdStop = true; diff --git a/source/menu/menu_wad.cpp b/source/menu/menu_wad.cpp index c52d6b25..ef7e5cf5 100644 --- a/source/menu/menu_wad.cpp +++ b/source/menu/menu_wad.cpp @@ -342,7 +342,7 @@ int getTID(const char *path, u64 *tid) return 0; } -int CMenu::_pThread(void *obj) +void * CMenu::_pThread(void *obj) { CMenu *m = (CMenu*)obj; while(m->m_thrdInstalling) @@ -381,7 +381,7 @@ void CMenu::_start_pThread(void) m_thrdProgress = 0.f; m_thrdWritten = 0; m_thrdTotal = 0; - LWP_CreateThread(&m_thrdPtr, (void *(*)(void *))_pThread, (void*)this, 0, 8 * 1024, 64); + LWP_CreateThread(&m_thrdPtr, _pThread, this, 0, 8 * 1024, 64); } void CMenu::_stop_pThread(void) diff --git a/source/menu/menu_wbfs.cpp b/source/menu/menu_wbfs.cpp index 80ee3a89..aec16c12 100644 --- a/source/menu/menu_wbfs.cpp +++ b/source/menu/menu_wbfs.cpp @@ -106,7 +106,7 @@ void CMenu::GC_Messenger(int message, int info, char *cinfo) m_thrdMessageAdded = true; } -int CMenu::_gameInstaller(void *obj) +void * CMenu::_gameInstaller(void *obj) { CMenu &m = *(CMenu *)obj; int ret; @@ -115,7 +115,7 @@ int CMenu::_gameInstaller(void *obj) if(!WBFS_Mounted()) { m.m_thrdWorking = false; - return -1; + return NULL; } u64 comp_size = 0, real_size = 0; f32 free, used; @@ -127,7 +127,7 @@ int CMenu::_gameInstaller(void *obj) m._setThrdMsg(wfmt(m._fmt("wbfsop10", L"Not enough space: %lld blocks needed, %i available"), comp_size, free), 0.f); LWP_MutexUnlock(m.m_mutex); //m.m_thrdWorking = false; - ret = -1; + //ret = -1; } else { @@ -137,7 +137,7 @@ int CMenu::_gameInstaller(void *obj) ret = WBFS_AddGame(_addDiscProgress, obj); LWP_MutexLock(m.m_mutex); - if (ret == 0) + if(ret == 0) m._setThrdMsg(m._t("wbfsop8", L"Game installed, press B to exit."), 1.f); else m._setThrdMsg(m._t("wbfsop9", L"An error has occurred"), 1.f); @@ -146,7 +146,7 @@ int CMenu::_gameInstaller(void *obj) } WBFS_Close(); m.m_thrdWorking = false; - return ret; + return NULL; } int CMenu::_GCgameInstaller() @@ -213,7 +213,7 @@ int CMenu::_GCgameInstaller() return ret; } -int CMenu::_GCcopyGame(void *obj) +void * CMenu::_GCcopyGame(void *obj) { CMenu &m = *(CMenu *)obj; @@ -345,7 +345,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op) m_thrdWorking = true; m_thrdProgress = 0.f; m_thrdMessageAdded = false; - LWP_CreateThread(&thread, (void *(*)(void *))_gameInstaller, (void *)this, 0, 8 * 1024, 64); + LWP_CreateThread(&thread, _gameInstaller, this, 0, 8 * 1024, 64); } else if(Disc_IsGC() == 0) { diff --git a/source/plugin/plugin.cpp b/source/plugin/plugin.cpp index 9d797f0f..6da1530d 100644 --- a/source/plugin/plugin.cpp +++ b/source/plugin/plugin.cpp @@ -235,7 +235,7 @@ vector Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 continue; } memset((void*)&ListElement, 0, sizeof(dir_discHdr)); - strncpy(ListElement.id, PLUGIN, 6); + memcpy(ListElement.id, PLUGIN, 6); ListElement.casecolor = Plugins.back().caseColor; mbstowcs(ListElement.title, GameName, 63); strncpy(ListElement.path, GameDomain, sizeof(ListElement.path)); diff --git a/source/unzip/ZipFile.cpp b/source/unzip/ZipFile.cpp index 02580550..582eba5d 100644 --- a/source/unzip/ZipFile.cpp +++ b/source/unzip/ZipFile.cpp @@ -68,7 +68,7 @@ bool ZipFile::ExtractAll(const char *dest) return false; char writepath[1024]; - char filename[1024]; + char filename[256]; memset(filename, 0, sizeof(filename)); int ret = unzGoToFirstFile(File);