From 64f796494d14b9262da48c4fdb6cec1a9a936788 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Sat, 10 Mar 2012 19:47:34 +0000 Subject: [PATCH] -if cheat gct file is on usb and trying to launch a gc game with this gct file it auto copy the file into the games folder of this game on sd card --- source/menu/menu_game.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index d9dec999..f58856f4 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -30,6 +30,7 @@ #include "homebrew.h" #include "defines.h" #include "gc/gc.h" +#include "gc/fileOps.h" //#define DML_THROUGH_MEM /*** Load game through mem.. Not compatible with regulair DML ***/ @@ -635,24 +636,38 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool DML) if(m_new_dml) { gprintf("Wiiflow DML: Launch game 'sd:/games/%s/game.iso' through memory\n", hdr->path); + DML_CFG *DMLCfg = (DML_CFG*)MEM2_alloc(sizeof(DML_CFG)); memset(DMLCfg, 0, sizeof(DML_CFG)); + snprintf(DMLCfg->GamePath, sizeof(DMLCfg->GamePath), "/games/%s/game.iso", hdr->path); DMLCfg->Magicbytes = 0xD1050CF6; DMLCfg->CfgVersion = 0x00000001; DMLCfg->VideoMode |= DML_VID_NONE; DMLCfg->Config |= DML_CFG_GAME_PATH; - snprintf(DMLCfg->GamePath, sizeof(DMLCfg->GamePath), "/games/%s/game.iso", hdr->path); + if(m_gcfg2.testOptBool((char *)hdr->hdr.id, "cheat", m_cfg.getBool("GAMES", "cheat", false))) { + const char *ptr; + + char old_cheat_path[256]; + snprintf(old_cheat_path, sizeof(old_cheat_path), "%s/%s", m_cheatDir.c_str(), fmt("%s.gct", hdr->hdr.id)); + DMLCfg->Config |= DML_CFG_CHEATS; DMLCfg->Config |= DML_CFG_CHEAT_PATH; - const char *ptr; - if(strstr(m_cheatDir.c_str(), "sd:/") != NULL) + + if(strstr(old_cheat_path, "sd:/") != NULL) { - ptr = &m_cheatDir.c_str()[3]; - snprintf(DMLCfg->CheatPath, sizeof(DMLCfg->CheatPath), "%s/%s", ptr, fmt("%s.gct", hdr->hdr.id)); + ptr = &old_cheat_path[3]; } - gprintf("Cheat dir: %s\n", DMLCfg->CheatPath); + else + { + char new_cheat_path[256]; + snprintf(new_cheat_path, sizeof(new_cheat_path), "%s/%s/%s", fmt(DML_DIR, DeviceName[SD]), hdr->path, fmt("%s.gct", hdr->hdr.id)); + fsop_CopyFile(old_cheat_path, new_cheat_path, NULL, NULL); + ptr = &new_cheat_path[3]; + } + strncpy(DMLCfg->CheatPath, ptr, sizeof(DMLCfg->CheatPath)); + gprintf("Cheat File: %s\n", DMLCfg->CheatPath); } memcpy((void *)0xC0001700, DMLCfg, sizeof(DML_CFG)); MEM2_free(DMLCfg);