Update OTRGui to extract MQ roms with the correct name (#2114)

* Extract MQ roms to oot-mq.otr as the game expects

* correctly export mq otrs and handle outside soh folder properly

* support mq export on old export method

Co-authored-by: Garrett Cox <garrettjcox@gmail.com>
This commit is contained in:
Adam Bird 2022-12-07 16:40:12 -05:00 committed by GitHub
parent 31947cd51b
commit 924e9147aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 14 deletions

View File

@ -67,7 +67,7 @@ void OTRGame::init(){
mat.shader = shader;
}
if((fs::exists("soh.exe") || fs::exists("soh.elf")) && !fs::exists("oot.otr")) {
if (fs::exists("soh.exe") || fs::exists("soh.elf")) {
hide_second_btn = true;
sohFolder = ".";
}
@ -83,7 +83,8 @@ void ExtractRom()
result.error = NULLSTR;
if (result.error == NULLSTR) {
if (MoonUtils::exists("oot.otr")) MoonUtils::rm("oot.otr");
if (MoonUtils::exists("oot.otr") && !version.isMQ) MoonUtils::rm("oot.otr");
if (MoonUtils::exists("oot-mq.otr") && version.isMQ) MoonUtils::rm("oot-mq.otr");
if (MoonUtils::exists("Extract")) MoonUtils::rm("Extract");
MoonUtils::mkdir("Extract");
@ -100,7 +101,7 @@ void ExtractRom()
}
void OTRGame::update(){
updateWorker(sohFolder);
updateWorker(sohFolder, version);
this->ModelRotation += 50 * GetFrameTime();
UpdateLightValues(shader, light);

View File

@ -60,86 +60,103 @@ RomVersion GetVersion(FILE* rom) {
version.version = "N64 NTSC 1.0";
version.listPath = "ntsc_oot.txt";
version.offset = OOT_OFF_NTSC_10;
version.isMQ = false;
break;
case OOT_NTSC_11:
version.version = "N64 NTSC 1.1";
version.listPath = "ntsc_oot.txt";
version.offset = OOT_OFF_NTSC_11;
version.isMQ = false;
break;
case OOT_NTSC_12:
version.version = "N64 NTSC 1.2";
version.listPath = "ntsc_oot.txt";
version.offset = OOT_OFF_NTSC_12;
version.isMQ = false;
break;
case OOT_PAL_10:
version.version = "N64 PAL 1.0";
version.listPath = "pal_oot.txt";
version.offset = OOT_OFF_PAL_10;
version.isMQ = false;
break;
case OOT_PAL_11:
version.version = "N64 PAL 1.1";
version.listPath = "pal_oot.txt";
version.offset = OOT_OFF_PAL_11;
version.isMQ = false;
break;
case OOT_NTSC_JP_GC:
version.version = "JP GameCube (MQ Disk)";
version.listPath = "gamecube.txt";
version.offset = OOT_OFF_JP_GC;
version.isMQ = true;
break;
case OOT_NTSC_JP_GC_CE:
version.version = "GameCube (Collectors Edition Disk)";
version.listPath = "gamecube.txt";
version.offset = OOT_OFF_JP_GC_CE;
version.isMQ = false;
break;
case OOT_NTSC_JP_MQ:
version.version = "JP Master Quest";
version.listPath = "gamecube.txt";
version.offset = OOT_OFF_JP_MQ;
version.isMQ = true;
break;
case OOT_NTSC_US_MQ:
version.version = "NTSC Master Quest";
version.listPath = "gamecube.txt";
version.offset = OOT_OFF_JP_MQ;
version.isMQ = true;
break;
case OOT_NTSC_US_GC:
version.version = "NTSC GameCube";
version.listPath = "gamecube.txt";
version.offset = OOT_OFF_US_MQ;
version.isMQ = true;
break;
case OOT_PAL_GC:
version.version = "PAL GameCube";
version.listPath = "gamecube_pal.txt";
version.offset = OOT_OFF_PAL_GC;
version.isMQ = false;
break;
case OOT_PAL_MQ:
version.version = "PAL Master Quest";
version.listPath = "gamecube_pal.txt";
version.offset = OOT_OFF_PAL_MQ;
version.isMQ = true;
break;
case OOT_PAL_GC_DBG1:
version.version = "GameCube Debug 1.0";
version.listPath = "dbg.txt";
version.offset = OOT_OFF_PAL_GC_DBG1;
version.isMQ = false;
break;
case OOT_PAL_GC_DBG2:
version.version = "GameCube Debug 2.0";
version.listPath = "dbg.txt";
version.offset = OOT_OFF_PAL_GC_DBG2;
version.isMQ = false;
break;
case OOT_PAL_GC_MQ_DBG:
version.version = "GameCube MQ-Debug";
version.listPath = "dbg.txt";
version.offset = OOT_OFF_PAL_MQ_DBG;
version.isMQ = true;
break;
case OOT_IQUE_CN:
version.version = "OoT IQue";
version.listPath = "ique.txt";
version.offset = OOT_OFF_CN_IQUE;
version.isMQ = false;
break;
case OOT_IQUE_TW:
version.version = "TW IQue";
version.listPath = "ique.txt";
version.offset = OOT_OFF_TW_IQUE;
version.isMQ = false;
break;
default:
version.error = MoonUtils::format("Unknown CRC %x given: ", version.crc);

View File

@ -9,6 +9,7 @@ struct RomVersion {
std::string version = "None";
std::string error = "None";
std::string listPath = "None";
bool isMQ;
int offset;
uint32_t crc;
};

View File

@ -36,7 +36,7 @@ std::string GetXMLVersion(RomVersion version)
return "ERROR";
}
void BuildOTR(const std::string output) {
void BuildOTR(const std::string output, RomVersion version) {
if (oldExtractMode)
{
std::string execStr = Util::format("assets/extractor/%s", isWindows() ? "ZAPD.exe" : "ZAPD.out") + " botr -se OTR";
@ -49,16 +49,28 @@ void BuildOTR(const std::string output) {
setCurrentStep("Done!");
if (output == ".") return;
const std::string outputPath = MoonUtils::join(output, "oot.otr");
if(MoonUtils::exists(outputPath)) MoonUtils::rm(outputPath);
// If a custom SoH folder was not selected, or the custom SOH folder is the same location as OTRGui,
// then the otr file should already be where it is expected
if (output == "." || output == MoonUtils::absolute(".")) {
return;
}
MoonUtils::copy("oot.otr", outputPath);
// Otherwise an outside SoH folder was selected so we need to copy the exported otr to the correct folder
const std::string otrName = version.isMQ ? "oot-mq.otr" : "oot.otr";
const std::string outputPath = MoonUtils::join(output, otrName);
if (MoonUtils::exists(outputPath)) MoonUtils::rm(outputPath);
MoonUtils::copy(otrName, outputPath);
}
void ExtractFile(std::string xmlPath, std::string outPath, std::string outSrcPath, RomVersion version) {
std::string otrExporterArgs = Util::format("--otrfile %s", version.isMQ ? "oot-mq.otr" : "oot.otr");
if (xmlPath.find("overlays") != std::string::npos) {
otrExporterArgs += " --static";
}
std::string execStr = Util::format("assets/extractor/%s", isWindows() ? "ZAPD.exe" : "ZAPD.out");
std::string args = Util::format(" e -eh -i %s -b tmp/baserom/ -o %s -osf %s -gsf 1 -rconf assets/extractor/Config_%s.xml -se OTR %s", xmlPath.c_str(), outPath.c_str(), outSrcPath.c_str(), GetXMLVersion(version).c_str(), xmlPath.find("overlays") != std::string::npos ? "--static" : "");
std::string args = Util::format(" e -eh -i %s -b tmp/baserom/ -o %s -osf %s -gsf 1 -rconf assets/extractor/Config_%s.xml -se OTR %s", xmlPath.c_str(), outPath.c_str(), outSrcPath.c_str(), GetXMLVersion(version).c_str(), otrExporterArgs);
ProcessResult result = NativeFS->LaunchProcess(execStr + args);
if (result.exitCode != 0) {
@ -110,8 +122,9 @@ void startWorker(RomVersion version) {
}
else
{
std::string otrExporterArgs = Util::format("--otrfile %s", version.isMQ ? "oot-mq.otr" : "oot.otr");
std::string execStr = Util::format("assets/extractor/%s", isWindows() ? "ZAPD.exe" : "ZAPD.out");
std::string args = Util::format(" ed -eh -i %s -b tmp/rom.z64 -fl assets/extractor/filelists -o %s -osf %s -gsf 1 -rconf assets/extractor/Config_%s.xml -se OTR %s", path.c_str(), (path + "/../").c_str(), (path + "/../").c_str(), GetXMLVersion(version).c_str(), "");
std::string args = Util::format(" ed -eh -i %s -b tmp/rom.z64 -fl assets/extractor/filelists -o %s -osf %s -gsf 1 -rconf assets/extractor/Config_%s.xml -se OTR %s", path.c_str(), (path + "/../").c_str(), (path + "/../").c_str(), GetXMLVersion(version).c_str(), otrExporterArgs.c_str());
ProcessResult result = NativeFS->LaunchProcess(execStr + args);
if (result.exitCode != 0) {
@ -127,7 +140,7 @@ void startWorker(RomVersion version) {
}
}
void updateWorker(const std::string& output) {
void updateWorker(const std::string& output, RomVersion version) {
if (maxResources > 0 && !buildingOtr && (extractedResources >= maxResources || !oldExtractMode))
{
setCurrentStep("Building OTR...");
@ -138,10 +151,10 @@ void updateWorker(const std::string& output) {
buildingOtr = true;
if (single_thread || !oldExtractMode){
BuildOTR(output);
BuildOTR(output, version);
return;
}
std::thread otr(BuildOTR, output);
std::thread otr(BuildOTR, output, version);
otr.detach();
}
}

View File

@ -8,4 +8,4 @@ enum Platforms {
struct RomVersion;
void startWorker(RomVersion version);
void updateWorker(const std::string& output);
void updateWorker(const std::string& output, RomVersion version);

View File

@ -102,6 +102,10 @@ namespace MoonUtils {
else fs::remove(path);
}
string absolute(string path) {
return normalize(fs::absolute(path).string());
}
string relative(string parent, string child){
return normalize(fs::relative(child, parent).string());
}

View File

@ -37,6 +37,7 @@ namespace MoonUtils {
bool exists(std::string path);
void mkdir(std::string path);
void rm(std::string path);
std::string absolute(std::string path);
std::string relative(std::string parent, std::string child);
void move(std::string src, std::string dst);
void copy(std::string src, std::string dst);