Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into pull-master-into-mm
Browse files Browse the repository at this point in the history
  • Loading branch information
Archez committed Mar 4, 2024
2 parents 01ed7e8 + ca1e199 commit 53c20f3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion ZAPD/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Globals
bool forceUnaccountedStatic = false;
bool otrMode = true;
bool buildRawTexture = false;
bool onlyGenSohOtr = false;
bool onlyGenCustomOtr = false;

ZRom* rom = nullptr;
std::vector<ZFile*> files;
Expand Down
34 changes: 19 additions & 15 deletions ZAPD/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,26 @@ extern "C" int zapd_main(int argc, char* argv[])

// Parse File Mode
ExporterSet* exporterSet = Globals::Instance->GetExporterSet();

if(Globals::Instance->onlyGenSohOtr) {
exporterSet->endProgramFunc();

delete g;
return 0;
// We've parsed through our commands once. If an exporter exists, it's been set by now.
// Now we'll parse through them again but pass them on to our exporter if one is available.
if (exporterSet != nullptr && exporterSet->parseArgsFunc != nullptr) {
for (int32_t i = 2; i < argc; i++) {
exporterSet->parseArgsFunc(argc, argv, i);
}
}


if (Globals::Instance->onlyGenCustomOtr) {
if (exporterSet != nullptr) {
exporterSet->endProgramFunc();
} else {
printf("Error: No exporter set, unable to make custom otr.\n");
}

delete g;
return 0;
}

std::string buildMode = argv[1];
ZFileMode fileMode = ParseFileMode(buildMode, exporterSet);

Expand All @@ -197,14 +209,6 @@ extern "C" int zapd_main(int argc, char* argv[])
if (fileMode == ZFileMode::ExtractDirectory)
Globals::Instance->rom = new ZRom(Globals::Instance->baseRomPath.string());

// We've parsed through our commands once. If an exporter exists, it's been set by now.
// Now we'll parse through them again but pass them on to our exporter if one is available.
if (exporterSet != nullptr && exporterSet->parseArgsFunc != nullptr)
{
for (int32_t i = 2; i < argc; i++)
exporterSet->parseArgsFunc(argc, argv, i);
}

if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO)
printf("ZAPD: Zelda Asset Processor For Decomp: %s\n", gBuildHash);

Expand Down Expand Up @@ -585,7 +589,7 @@ void Arg_SetBuildRawTexture([[maybe_unused]] int& i, [[maybe_unused]] char* argv

void Arg_SetNoRomMode([[maybe_unused]] int& i, [[maybe_unused]] char* argv[])
{
Globals::Instance->onlyGenSohOtr = true;
Globals::Instance->onlyGenCustomOtr = true;
}

int HandleExtract(ZFileMode fileMode, ExporterSet* exporterSet)
Expand Down
12 changes: 10 additions & 2 deletions ZAPD/ZResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,16 @@ std::string ZResource::GetSourceOutputHeader([[maybe_unused]] const std::string&
if (StringHelper::Contains(outName, "_room_") ||
StringHelper::Contains(outName, "_scene") ||
(StringHelper::Contains(parent->GetXmlFilePath().string(), "/scenes/") ||
StringHelper::Contains(parent->GetXmlFilePath().string(), "\\scenes\\")))
prefix = "scenes/nonmq";
StringHelper::Contains(parent->GetXmlFilePath().string(), "\\scenes\\"))) {
prefix = "scenes/shared";

// Regex for xml paths that are dungeons with unique MQ variants (only the main dungeon, not boss rooms)
std::regex dungeonsWithMQ(R"(((ydan)|(ddan)|(bdan)|(Bmori1)|(HIDAN)|(MIZUsin)|(jyasinzou)|(HAKAdan)|(HAKAdanCH)|(ice_doukutu)|(men)|(ganontika))\.xml)");

if (StringHelper::Contains(xmlPath, "dungeons/") && std::regex_search(xmlPath, dungeonsWithMQ)) {
prefix = "scenes/nonmq";
}
}
else if (StringHelper::Contains(xmlPath, "objects/"))
prefix = "objects";
else if (StringHelper::Contains(xmlPath, "textures/"))
Expand Down

0 comments on commit 53c20f3

Please sign in to comment.