diff --git a/OTRGui/src/game/game.cpp b/OTRGui/src/game/game.cpp index 3fc6438a8..bbb9530c6 100644 --- a/OTRGui/src/game/game.cpp +++ b/OTRGui/src/game/game.cpp @@ -41,6 +41,8 @@ void OTRGame::preload() { } void cleanTempData() { + MoonUtils::rm("assets/extractor/xmls/output"); + MoonUtils::rm("Extract/"); MoonUtils::rm("tmp/"); MoonUtils::mkdir("tmp/"); } @@ -67,7 +69,7 @@ void OTRGame::init(){ if(fs::exists("soh.exe") && !fs::exists("oot.otr")) { hide_second_btn = true; - sohFolder = "."; + sohFolder = "MAIN"; } } diff --git a/OTRGui/src/impl/baserom_extractor/baserom_extractor.cpp b/OTRGui/src/impl/baserom_extractor/baserom_extractor.cpp index 86be26f6c..0f5ef85f4 100644 --- a/OTRGui/src/impl/baserom_extractor/baserom_extractor.cpp +++ b/OTRGui/src/impl/baserom_extractor/baserom_extractor.cpp @@ -56,93 +56,18 @@ RomVersion GetVersion(FILE* rom) { version.crc = __bswap_32(version.crc); switch (version.crc) { - case OOT_NTSC_10: - version.version = "N64 NTSC 1.0"; - version.listPath = "ntsc_oot.txt"; - version.offset = OOT_OFF_NTSC_10; - break; - case OOT_NTSC_11: - version.version = "N64 NTSC 1.1"; - version.listPath = "ntsc_oot.txt"; - version.offset = OOT_OFF_NTSC_11; - break; - case OOT_NTSC_12: - version.version = "N64 NTSC 1.2"; - version.listPath = "ntsc_oot.txt"; - version.offset = OOT_OFF_NTSC_12; - break; - case OOT_PAL_10: - version.version = "N64 PAL 1.0"; - version.listPath = "pal_oot.txt"; - version.offset = OOT_OFF_PAL_10; - break; - case OOT_PAL_11: - version.version = "N64 PAL 1.1"; - version.listPath = "pal_oot.txt"; - version.offset = OOT_OFF_PAL_11; - break; - case OOT_NTSC_JP_GC: - version.version = "JP GameCube (MQ Disk)"; - version.listPath = "gamecube_mq.txt"; - version.offset = OOT_OFF_JP_GC; - break; - case OOT_NTSC_JP_GC_CE: - version.version = "GameCube (Collectors Edition Disk)"; - version.listPath = "gamecube_mq.txt"; - version.offset = OOT_OFF_JP_GC_CE; - break; - case OOT_NTSC_JP_MQ: - version.version = "JP Master Quest"; - version.listPath = "gamecube_mq.txt"; - version.offset = OOT_OFF_JP_MQ; - break; - case OOT_NTSC_US_MQ: - version.version = "NTSC Master Quest"; - version.listPath = "gamecube_mq.txt"; - version.offset = OOT_OFF_JP_MQ; - break; - case OOT_NTSC_US_GC: - version.version = "NTSC GameCube"; - version.listPath = "gamecube_mq.txt"; - version.offset = OOT_OFF_US_MQ; - break; - case OOT_PAL_GC: - version.version = "PAL GameCube"; - version.listPath = "gamecube_mq.txt"; - version.offset = OOT_OFF_PAL_GC; - break; - case OOT_PAL_MQ: - version.version = "PAL Master Quest"; - version.listPath = "pal_mq.txt"; - version.offset = OOT_OFF_PAL_MQ; - break; - case OOT_PAL_GC_DBG1: - version.version = "GameCube Debug 1.0"; - version.listPath = "dbg.txt"; - version.offset = OOT_OFF_PAL_GC_DBG1; - break; - case OOT_PAL_GC_DBG2: - version.version = "GameCube Debug 2.0"; - version.listPath = "dbg.txt"; - version.offset = OOT_OFF_PAL_GC_DBG2; - break; - case OOT_PAL_GC_MQ_DBG: - version.version = "GameCube MQ-Debug"; - version.listPath = "dbg.txt"; - version.offset = OOT_OFF_PAL_MQ_DBG; - break; - case OOT_IQUE_CN: - version.version = "OoT IQue"; - version.listPath = "ique.txt"; - version.offset = OOT_OFF_CN_IQUE; - break; - case OOT_IQUE_TW: - version.version = "TW IQue"; - version.listPath = "ique.txt"; - version.offset = OOT_OFF_TW_IQUE; - break; - default: - version.error = MoonUtils::format("Unknown CRC %x given: ", version.crc); + case OOT_PAL_GC_DBG1: + version.version = "GameCube Debug 1.0"; + version.listPath = "dbg.txt"; + version.offset = OOT_OFF_PAL_GC_DBG1; + break; + case OOT_PAL_GC_DBG2: + version.version = "GameCube Debug 2.0"; + version.listPath = "dbg.txt"; + version.offset = OOT_OFF_PAL_GC_DBG2; + break; + default: + version.error = MoonUtils::format("Unknown CRC %x given: ", version.crc); } return version; } diff --git a/OTRGui/src/impl/extractor/extractor.cpp b/OTRGui/src/impl/extractor/extractor.cpp index ec435a9e4..ab28191d2 100644 --- a/OTRGui/src/impl/extractor/extractor.cpp +++ b/OTRGui/src/impl/extractor/extractor.cpp @@ -37,7 +37,7 @@ void BuildOTR(const std::string output) { } setCurrentStep("Done!"); - if (output == ".") return; + if (output == "MAIN" || Util::normalize(output) == Util::normalize(fs::current_path().string())) return; const std::string outputPath = MoonUtils::join(output, "oot.otr"); if(MoonUtils::exists(outputPath)) MoonUtils::rm(outputPath); @@ -73,7 +73,7 @@ void startWorker() { const int num_threads = std::thread::hardware_concurrency(); ctpl::thread_pool pool(num_threads / 2); for(auto &file : files) { - if (file.find(".xml") != std::string::npos) xmlFiles.push_back(file); + if (MoonUtils::endsWith(file, ".xml")) xmlFiles.push_back(file); } for (auto& file : xmlFiles) { diff --git a/OTRGui/src/utils/mutils.cpp b/OTRGui/src/utils/mutils.cpp index 770df8423..8f5d1475f 100644 --- a/OTRGui/src/utils/mutils.cpp +++ b/OTRGui/src/utils/mutils.cpp @@ -51,6 +51,11 @@ namespace MoonUtils { return path; } + bool endsWith(const std::string& str, const char* suffix) { + const int suffixLen = basic_string::traits_type::length(suffix); + return str.size() >= suffixLen && 0 == str.compare(str.size() - suffixLen, suffixLen, suffix, suffixLen); + } + string join(string base, string file){ if( file == "/" ) return normalize(base + file); return normalize( (fs::path(base) / fs::path(file)).string() ); diff --git a/OTRGui/src/utils/mutils.h b/OTRGui/src/utils/mutils.h index eafdc13a7..46929ca3b 100644 --- a/OTRGui/src/utils/mutils.h +++ b/OTRGui/src/utils/mutils.h @@ -44,6 +44,7 @@ namespace MoonUtils { void writeFile(std::string path, std::string content); void dirscan(std::string path, std::vector &files); std::string extname(std::string file); + bool endsWith(const std::string& str, const char* suffix); std::wstring wide(const std::string& str); std::string narrow(const std::wstring& str);