summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouist103 <35883445+louist103@users.noreply.github.com>2025-03-30 18:30:52 -0400
committerlouist103 <35883445+louist103@users.noreply.github.com>2025-03-30 18:30:52 -0400
commit68673b8061a4c3fc9da427686463a43de91e4f29 (patch)
treebef266fcec261adcfd3ec7b769e53ff729af65b4
parenta9dea598b603336cf23f25464cae9eb9c399dbd9 (diff)
OOT Fixes
-rw-r--r--OTRExporter/AnimationExporter.cpp5
-rw-r--r--OTRExporter/CKeyFrameExporter.cpp2
-rw-r--r--OTRExporter/CKeyFrameExporter.h3
-rw-r--r--OTRExporter/DisplayListExporter.cpp39
-rw-r--r--OTRExporter/Exporter.h2
-rw-r--r--OTRExporter/Main.cpp50
-rw-r--r--OTRExporter/Main.h2
-rw-r--r--OTRExporter/RoomExporter.cpp2
-rw-r--r--OTRExporter/TextMMExporter.cpp2
-rw-r--r--OTRExporter/TextMMExporter.h5
-rw-r--r--OTRExporter/TextureAnimationExporter.cpp4
-rw-r--r--OTRExporter/TextureAnimationExporter.h5
-rw-r--r--OTRExporter/VersionInfo.cpp5
-rwxr-xr-xextract_assets.py14
14 files changed, 103 insertions, 37 deletions
diff --git a/OTRExporter/AnimationExporter.cpp b/OTRExporter/AnimationExporter.cpp
index 32e47d0..6a5bf7b 100644
--- a/OTRExporter/AnimationExporter.cpp
+++ b/OTRExporter/AnimationExporter.cpp
@@ -1,5 +1,10 @@
#include "AnimationExporter.h"
+#ifdef GAME_MM
#include <resource/type/Animation.h>
+#elif GAME_OOT
+#include "../../soh/soh/resource/type/Animation.h"
+#endif
+
#include <Globals.h>
#include "DisplayListExporter.h"
#undef FindResource
diff --git a/OTRExporter/CKeyFrameExporter.cpp b/OTRExporter/CKeyFrameExporter.cpp
index 30c3e40..cbc2d9a 100644
--- a/OTRExporter/CKeyFrameExporter.cpp
+++ b/OTRExporter/CKeyFrameExporter.cpp
@@ -1,3 +1,4 @@
+#ifdef GAME_MM
#include "CKeyFrameExporter.h"
#include "DisplayListExporter.h"
#include "Globals.h"
@@ -101,3 +102,4 @@ void OTRExporter_CKeyFrameAnim::Save(ZResource* res, const fs::path& outPath, Bi
writer->Write(anim->unk_10);
writer->Write(anim->duration);
}
+#endif
diff --git a/OTRExporter/CKeyFrameExporter.h b/OTRExporter/CKeyFrameExporter.h
index 6e8fe45..d071b35 100644
--- a/OTRExporter/CKeyFrameExporter.h
+++ b/OTRExporter/CKeyFrameExporter.h
@@ -1,5 +1,5 @@
#pragma once
-
+#ifdef GAME_MM
#include "ZResource.h"
#include "ZCKeyFrame.h"
#include "ZCkeyFrameAnim.h"
@@ -16,3 +16,4 @@ class OTRExporter_CKeyFrameAnim : public OTRExporter {
public:
virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override;
};
+#endif
diff --git a/OTRExporter/DisplayListExporter.cpp b/OTRExporter/DisplayListExporter.cpp
index 5865320..f6f5382 100644
--- a/OTRExporter/DisplayListExporter.cpp
+++ b/OTRExporter/DisplayListExporter.cpp
@@ -1017,7 +1017,7 @@ std::string OTRExporter_DisplayList::GetParentFolderName(ZResource* res)
return oName;
}
-
+#ifdef GAME_MM
std::string OTRExporter_DisplayList::GetPrefix(ZResource* res)
{
std::string oName = res->parent->GetOutName();
@@ -1047,3 +1047,40 @@ std::string OTRExporter_DisplayList::GetPrefix(ZResource* res)
return prefix;
}
+#elif GAME_OOT
+std::string OTRExporter_DisplayList::GetPrefix(ZResource* res)
+{
+ std::string oName = res->parent->GetOutName();
+ std::string prefix = "";
+ std::string xmlPath = StringHelper::Replace(res->parent->GetXmlFilePath().string(), "\\", "/");
+
+ if (StringHelper::Contains(oName, "_scene") || StringHelper::Contains(oName, "_room")) {
+ 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)) {
+ if (Globals::Instance->rom->IsMQ()) {
+ prefix = "scenes/mq";
+ } else {
+ prefix = "scenes/nonmq";
+ }
+ }
+ }
+ else if (StringHelper::Contains(xmlPath, "objects/"))
+ prefix = "objects";
+ else if (StringHelper::Contains(xmlPath, "textures/"))
+ prefix = "textures";
+ else if (StringHelper::Contains(xmlPath, "overlays/"))
+ prefix = "overlays";
+ else if (StringHelper::Contains(xmlPath, "misc/"))
+ prefix = "misc";
+ else if (StringHelper::Contains(xmlPath, "text/"))
+ prefix = "text";
+ else if (StringHelper::Contains(xmlPath, "code/"))
+ prefix = "code";
+
+ return prefix;
+}
+#endif
diff --git a/OTRExporter/Exporter.h b/OTRExporter/Exporter.h
index b1214c7..a6a4f08 100644
--- a/OTRExporter/Exporter.h
+++ b/OTRExporter/Exporter.h
@@ -8,7 +8,7 @@
#ifdef GAME_MM
#include "../../mm/2s2h/resource/type/2shResourceType.h"
#elif GAME_OOT
-#include "../../soh/soh/resource/type/SoHResourceType.h"
+#include "../../soh/soh/resource/type/SohResourceType.h"
#endif
class OTRExporter : public ZResourceExporter
{
diff --git a/OTRExporter/Main.cpp b/OTRExporter/Main.cpp
index 0941356..dc65556 100644
--- a/OTRExporter/Main.cpp
+++ b/OTRExporter/Main.cpp
@@ -30,12 +30,18 @@
#include <mutex>
#include <ExporterArchiveO2R.h>
-std::string otrFileName = "mm.zip";
-std::string customOtrFileName = "";
+#include "ExporterArchiveOTR.h"
+#ifdef GAME_MM
+std::string otrFileName = "mm.o2r";
+
+#elif GAME_OOT
+std::string archiveFileName = "oot.o2r";
+#endif
+std::string customArchiveFileName = "";
std::string customAssetsPath = "";
std::string portVersionString = "0.0.0";
-std::shared_ptr<ExporterArchive> otrArchive;
+std::shared_ptr<ExporterArchive> archive;
BinaryWriter* fileWriter;
std::chrono::steady_clock::time_point fileStart, resStart;
std::map<std::string, std::vector<char>> files;
@@ -56,19 +62,19 @@ static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileM
printf("BOTR: Generating OTR Archive...\n");
- otrArchive = std::make_shared<ExporterArchiveO2R>(otrFileName, true);
+ archive = std::make_shared<ExporterArchiveO2R>(archiveFileName, true);
- if (DiskFile::Exists(otrFileName))
- otrArchive->Load(true);
+ if (DiskFile::Exists(archiveFileName))
+ archive->Load(true);
else
- otrArchive->CreateArchive(40000);
+ archive->CreateArchive(40000);
auto lst = Directory::ListFiles("Extract");
for (auto item : lst)
{
auto fileData = DiskFile::ReadAllBytes(item);
- otrArchive->AddFile(StringHelper::Split(item, "Extract/")[1], fileData.data(), fileData.size());
+ archive->AddFile(StringHelper::Split(item, "Extract/")[1], fileData.data(), fileData.size());
}
}
}
@@ -143,16 +149,16 @@ static void ExporterProgramEnd()
printf("Created version file.\n");
printf("Generating OTR Archive...\n");
- otrArchive = std::make_shared<ExporterArchiveO2R>(otrFileName, true);
- otrArchive->CreateArchive(40000);
+ archive = std::make_shared<ExporterArchiveO2R>(archiveFileName, true);
+ archive->CreateArchive(40000);
printf("Adding game version file.\n");
auto versionStreamBuffer = versionStream->ToVector();
- otrArchive->AddFile("version", (void*)versionStreamBuffer.data(), versionStream->GetLength());
+ archive->AddFile("version", (void*)versionStreamBuffer.data(), versionStream->GetLength());
printf("Adding portVersion file.\n");
auto portVersionStreamBuffer = portVersionStream->ToVector();
- otrArchive->AddFile("portVersion", (void*)portVersionStreamBuffer.data(), portVersionStream->GetLength());
+ archive->AddFile("portVersion", (void*)portVersionStreamBuffer.data(), portVersionStream->GetLength());
for (const auto& item : files)
{
@@ -166,17 +172,17 @@ static void ExporterProgramEnd()
}
}
const auto& fileData = item.second;
- otrArchive->AddFile(fName, (void*)fileData.data(), fileData.size());
+ archive->AddFile(fName, (void*)fileData.data(), fileData.size());
}
- otrArchive = nullptr;
+ archive = nullptr;
}
delete fileWriter;
files.clear();
// Generate custom otr file for extra assets
- if (customAssetsPath == "" || customOtrFileName == "" || DiskFile::Exists(customOtrFileName)) {
+ if (customAssetsPath == "" || customArchiveFileName == "" || DiskFile::Exists(customArchiveFileName)) {
printf("No Custom Assets path or otr file name provided, otr file already exists. Nothing to do.\n");
return;
}
@@ -188,7 +194,7 @@ static void ExporterProgramEnd()
const auto& lst = Directory::ListFiles(customAssetsPath);
printf("Generating Custom OTR Archive...\n");
- auto customOtr = std::make_unique<ExporterArchiveO2R>(customOtrFileName, true);
+ auto customOtr = std::make_unique<ExporterArchiveO2R>(customArchiveFileName, true);
customOtr->CreateArchive(40000);
printf("Adding portVersion file.\n");
@@ -271,10 +277,10 @@ static void ExporterParseArgs(int argc, char* argv[], int& i)
std::string arg = argv[i];
if (arg == "--otrfile") {
- otrFileName = argv[i + 1];
+ archiveFileName = argv[i + 1];
i++;
} else if (arg == "--customOtrFile") {
- customOtrFileName = argv[i + 1];
+ customArchiveFileName = argv[i + 1];
i++;
} else if (arg == "--customAssetsPath") {
customAssetsPath = argv[i + 1];
@@ -420,13 +426,15 @@ void ImportExporters()
exporterSet->exporters[ZResourceType::Array] = new OTRExporter_Array();
exporterSet->exporters[ZResourceType::Path] = new OTRExporter_Path();
exporterSet->exporters[ZResourceType::Text] = new OTRExporter_Text();
+#ifdef GAME_MM
exporterSet->exporters[ZResourceType::TextMM] = new OTRExporter_TextMM();
+ exporterSet->exporters[ZResourceType::KeyFrameSkel] = new OTRExporter_CKeyFrameSkel();
+ exporterSet->exporters[ZResourceType::KeyFrameAnimation] = new OTRExporter_CKeyFrameAnim();
+ exporterSet->exporters[ZResourceType::TextureAnimation] = new OTRExporter_TextureAnimation();
+#endif
exporterSet->exporters[ZResourceType::Blob] = new OTRExporter_Blob();
exporterSet->exporters[ZResourceType::Mtx] = new OTRExporter_MtxExporter();
exporterSet->exporters[ZResourceType::Audio] = new OTRExporter_Audio();
- exporterSet->exporters[ZResourceType::TextureAnimation] = new OTRExporter_TextureAnimation();
- exporterSet->exporters[ZResourceType::KeyFrameSkel] = new OTRExporter_CKeyFrameSkel();
- exporterSet->exporters[ZResourceType::KeyFrameAnimation] = new OTRExporter_CKeyFrameAnim();
Globals::AddExporter("OTR", exporterSet);
InitVersionInfo();
diff --git a/OTRExporter/Main.h b/OTRExporter/Main.h
index 6bdc77d..8c7118e 100644
--- a/OTRExporter/Main.h
+++ b/OTRExporter/Main.h
@@ -3,7 +3,7 @@
#include <libultraship/bridge.h>
#include "ExporterArchive.h"
-extern std::shared_ptr<ExporterArchive> otrArchive;
+extern std::shared_ptr<ExporterArchive> archive;
extern std::map<std::string, std::vector<char>> files;
void AddFile(std::string fName, std::vector<char> data);
diff --git a/OTRExporter/RoomExporter.cpp b/OTRExporter/RoomExporter.cpp
index 979a98b..2db8554 100644
--- a/OTRExporter/RoomExporter.cpp
+++ b/OTRExporter/RoomExporter.cpp
@@ -543,6 +543,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite
}
break;
}
+#ifdef GAME_MM
case RoomCommand::SetAnimatedMaterialList: {
SetAnimatedMaterialList* list = (SetAnimatedMaterialList*)cmd;
std::string listName;
@@ -561,6 +562,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite
break;
}
+#endif
case RoomCommand::SetMinimapList: {
SetMinimapList* list = (SetMinimapList*)cmd;
diff --git a/OTRExporter/TextMMExporter.cpp b/OTRExporter/TextMMExporter.cpp
index c7c424a..f74d686 100644
--- a/OTRExporter/TextMMExporter.cpp
+++ b/OTRExporter/TextMMExporter.cpp
@@ -1,3 +1,4 @@
+#ifdef GAME_MM
#include "TextMMExporter.h"
#include "../ZAPD/ZFile.h"
@@ -21,3 +22,4 @@ void OTRExporter_TextMM::Save(ZResource* res, const fs::path& outPath, BinaryWri
writer->Write(txt->messages[i].msg);
}
}
+#endif \ No newline at end of file
diff --git a/OTRExporter/TextMMExporter.h b/OTRExporter/TextMMExporter.h
index 4df80a1..d236fd5 100644
--- a/OTRExporter/TextMMExporter.h
+++ b/OTRExporter/TextMMExporter.h
@@ -1,5 +1,5 @@
#pragma once
-
+#ifdef GAME_MM
#include "ZResource.h"
#include "ZTextMM.h"
#include "Exporter.h"
@@ -9,4 +9,5 @@ class OTRExporter_TextMM : public OTRExporter
{
public:
virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override;
-}; \ No newline at end of file
+};
+#endif
diff --git a/OTRExporter/TextureAnimationExporter.cpp b/OTRExporter/TextureAnimationExporter.cpp
index b5acf89..e44d382 100644
--- a/OTRExporter/TextureAnimationExporter.cpp
+++ b/OTRExporter/TextureAnimationExporter.cpp
@@ -1,3 +1,4 @@
+#ifdef GAME_MM
#define NO_GDI
#define WIN32_LEAN_AND_MEAN
#include "ZFile.h"
@@ -121,4 +122,5 @@ void OTRExporter_TextureAnimation::Save(ZResource* res, const fs::path& outPath,
}
}
}
-} \ No newline at end of file
+}
+#endif
diff --git a/OTRExporter/TextureAnimationExporter.h b/OTRExporter/TextureAnimationExporter.h
index 1ac12d3..5d8d2be 100644
--- a/OTRExporter/TextureAnimationExporter.h
+++ b/OTRExporter/TextureAnimationExporter.h
@@ -1,5 +1,7 @@
#pragma once
+#ifdef GAME_MM
+
#include "ZResource.h"
#include "ZTextureAnimation.h"
#include "Exporter.h"
@@ -9,4 +11,5 @@ class OTRExporter_TextureAnimation : public OTRExporter
{
public:
virtual void Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer) override;
-}; \ No newline at end of file
+};
+#endif
diff --git a/OTRExporter/VersionInfo.cpp b/OTRExporter/VersionInfo.cpp
index 7cb57aa..39bb70e 100644
--- a/OTRExporter/VersionInfo.cpp
+++ b/OTRExporter/VersionInfo.cpp
@@ -1,7 +1,10 @@
#include "VersionInfo.h"
#include <libultraship/bridge.h>
+#ifdef GAME_MM
#include "../../mm/2s2h/resource/type/2shResourceType.h"
-
+#elif GAME_OOT
+#include "../../soh/soh/resource/type/SohResourceType.h"
+#endif
std::map<uint32_t, uint32_t> resourceVersions;
void InitVersionInfo()
diff --git a/extract_assets.py b/extract_assets.py
index 0eed59a..645ab85 100755
--- a/extract_assets.py
+++ b/extract_assets.py
@@ -8,16 +8,16 @@ import struct
import subprocess
import argparse
-def BuildOTR(xmlPath, rom, zapd_exe=None, genHeaders=None, customAssetsPath=None, customOtrFile=None, portVer=None, isMM):
+def BuildOTR(xmlPath, rom, isMM, zapd_exe=None, genHeaders=None, customAssetsPath=None, customOtrFile=None, portVer=None):
if not zapd_exe:
zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out"
exec_cmd = [zapd_exe, "ed", "-i", xmlPath, "-b", rom, "-fl", "CFG/filelists",
"-o", "placeholder", "-osf", "placeholder", "-rconf"]
if isMM:
- exec_cmd.extend("CFG/Config_MM.xml")
+ exec_cmd.extend(["CFG/Config_MM.xml"])
else:
- exec_cmd.extend("CFG/Config.xml")
+ exec_cmd.extend(["CFG/Config.xml"])
# generate headers, but not otrs by excluding the otr exporter
if genHeaders:
@@ -26,10 +26,10 @@ def BuildOTR(xmlPath, rom, zapd_exe=None, genHeaders=None, customAssetsPath=None
# generate otrs, but not headers
if isMM:
exec_cmd.extend(["-gsf", "0", "-se", "OTR", "--customAssetsPath", customAssetsPath,
- "--customOtrFile", customOtrFile, "--otrfile", "mm.zip"])
+ "--customOtrFile", customOtrFile, "--otrfile", "soh.o2r"])
else:
exec_cmd.extend(["-gsf", "0", "-se", "OTR", "--customAssetsPath", customAssetsPath,
- "--customOtrFile", customOtrFile, "--otrfile", "oot.otr"])
+ "--customOtrFile", customOtrFile, "--otrfile", "oot.o2r"])
if portVer:
@@ -87,8 +87,8 @@ def main():
roms = [ Z64Rom(args.rom) ] if args.rom else rom_chooser.chooseROM(args.verbose, args.non_interactive)
for rom in roms:
- BuildOTR(os.path.join(args.xml_root, rom.version.xml_ver), rom.file_path, zapd_exe=args.zapd_exe, genHeaders=args.gen_headers,
- customAssetsPath=args.custom_assets_path, customOtrFile=args.custom_otr_file, portVer=args.port_ver, rom_info.is_mm(args.rom))
+ BuildOTR(os.path.join(args.xml_root, rom.version.xml_ver), rom.file_path, rom.version.is_mm, zapd_exe=args.zapd_exe, genHeaders=args.gen_headers,
+ customAssetsPath=args.custom_assets_path, customOtrFile=args.custom_otr_file, portVer=args.port_ver)
if __name__ == "__main__":
main()