mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-07-13 16:43:11 -07:00
Added support for multiple game versions (#107)
* WIP Multiversion support * GC PAL Non-MQ support complete * Updated OtrGui to handle different game versions * Added version file * Added new extract mode to ZAPD and optimized OTR gen time * Fixed bug causing crash * Further optimized OTRExporter, saving around ~20 seconds. * ZAPD is now multi-threaded. * Fixed merge issue * Fixed memory leak and fog issue on pause screen. * Additional fog fixes. Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
This commit is contained in:
parent
572e9fb9d0
commit
c80f9fbd57
1203 changed files with 30620 additions and 501 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "utils/mutils.h"
|
||||
#include "ctpl/ctpl_stl.h"
|
||||
#include <thread>
|
||||
#include <impl/baserom_extractor/baserom_extractor.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define PLATFORM Platforms::WINDOWS
|
||||
|
@ -13,6 +14,7 @@
|
|||
#endif
|
||||
namespace Util = MoonUtils;
|
||||
|
||||
bool oldExtractMode = false;
|
||||
static int maxResources = 0;
|
||||
static int extractedResources = 0;
|
||||
bool buildingOtr = false;
|
||||
|
@ -22,19 +24,29 @@ bool isWindows() {
|
|||
return (PLATFORM == Platforms::WINDOWS);
|
||||
}
|
||||
|
||||
void BuildOTR(const std::string output) {
|
||||
Util::copy("tmp/baserom/Audiobank", "Extract/Audiobank");
|
||||
Util::copy("tmp/baserom/Audioseq", "Extract/Audioseq");
|
||||
Util::copy("tmp/baserom/Audiotable", "Extract/Audiotable");
|
||||
|
||||
Util::copy("assets/game/", "Extract/assets/");
|
||||
|
||||
std::string execStr = Util::format("assets/extractor/%s", isWindows() ? "ZAPD.exe" : "ZAPD.out") + " botr -se OTR";
|
||||
ProcessResult result = NativeFS->LaunchProcess(execStr);
|
||||
if(result.exitCode != 0) {
|
||||
std::cout << "\nError when building the OTR file with error code: " << result.exitCode << " !" << std::endl;
|
||||
std::cout << "Aborting...\n" << std::endl;
|
||||
std::string GetXMLVersion(RomVersion version)
|
||||
{
|
||||
switch (version.crc)
|
||||
{
|
||||
case OOT_PAL_GC_DBG1: return "GC_NMQ_D";
|
||||
case OOT_PAL_GC_DBG2: return "GC_MQ_D";
|
||||
case OOT_PAL_GC: return "GC_NMQ_PAL_F";
|
||||
}
|
||||
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
void BuildOTR(const std::string output) {
|
||||
if (oldExtractMode)
|
||||
{
|
||||
std::string execStr = Util::format("assets/extractor/%s", isWindows() ? "ZAPD.exe" : "ZAPD.out") + " botr -se OTR";
|
||||
ProcessResult result = NativeFS->LaunchProcess(execStr);
|
||||
if (result.exitCode != 0) {
|
||||
std::cout << "\nError when building the OTR file with error code: " << result.exitCode << " !" << std::endl;
|
||||
std::cout << "Aborting...\n" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
setCurrentStep("Done!");
|
||||
|
||||
if (output == ".") return;
|
||||
|
@ -44,9 +56,9 @@ void BuildOTR(const std::string output) {
|
|||
MoonUtils::copy("oot.otr", outputPath);
|
||||
}
|
||||
|
||||
void ExtractFile(std::string xmlPath, std::string outPath, std::string outSrcPath) {
|
||||
void ExtractFile(std::string xmlPath, std::string outPath, std::string outSrcPath, RomVersion version) {
|
||||
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.xml -se OTR %s", xmlPath.c_str(), outPath.c_str(), outSrcPath.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(), xmlPath.find("overlays") != std::string::npos ? "--static" : "");
|
||||
ProcessResult result = NativeFS->LaunchProcess(execStr + args);
|
||||
|
||||
if (result.exitCode != 0) {
|
||||
|
@ -55,49 +67,78 @@ void ExtractFile(std::string xmlPath, std::string outPath, std::string outSrcPat
|
|||
}
|
||||
}
|
||||
|
||||
void ExtractFunc(std::string fullPath) {
|
||||
void ExtractFunc(std::string fullPath, RomVersion version) {
|
||||
std::vector<std::string> path = Util::split(fullPath, Util::pathSeparator());
|
||||
std::string outPath = Util::join(Util::join("assets/extractor/xmls/output", path[4]), Util::basename(fullPath));
|
||||
Util::mkdir(outPath);
|
||||
ExtractFile(fullPath, outPath, outPath);
|
||||
ExtractFile(fullPath, outPath, outPath, version);
|
||||
setCurrentStep("Extracting: " + Util::basename(fullPath));
|
||||
extractedResources++;
|
||||
}
|
||||
|
||||
void startWorker() {
|
||||
std::string path = "assets/extractor/xmls";
|
||||
std::vector<std::string> files;
|
||||
Util::dirscan(path, files);
|
||||
std::vector<std::string> xmlFiles;
|
||||
void startWorker(RomVersion version) {
|
||||
std::string path = "assets/extractor/xmls/";
|
||||
|
||||
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);
|
||||
}
|
||||
path += GetXMLVersion(version);
|
||||
|
||||
for (auto& file : xmlFiles) {
|
||||
if(single_thread) {
|
||||
ExtractFunc(file);
|
||||
} else {
|
||||
pool.push([file](int) {
|
||||
ExtractFunc(file);
|
||||
});
|
||||
Util::write("tmp/baserom/version", (char*)&version.crc, sizeof(version.crc));
|
||||
|
||||
|
||||
if (oldExtractMode)
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
Util::dirscan(path, files);
|
||||
std::vector<std::string> xmlFiles;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
maxResources = xmlFiles.size();
|
||||
for (auto& file : xmlFiles) {
|
||||
if (single_thread) {
|
||||
ExtractFunc(file, version);
|
||||
}
|
||||
else {
|
||||
pool.push([file, version](int) {
|
||||
ExtractFunc(file, version);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
maxResources = xmlFiles.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
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 + "../", path + "../", GetXMLVersion(version).c_str(), "");
|
||||
ProcessResult result = NativeFS->LaunchProcess(execStr + args);
|
||||
|
||||
if (result.exitCode != 0) {
|
||||
std::cout << "\nError when extracting the ROM with error code: " << result.exitCode << " !" << std::endl;
|
||||
std::cout << "Aborting...\n" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("All done?\n");
|
||||
}
|
||||
|
||||
maxResources = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void updateWorker(const std::string& output) {
|
||||
if (maxResources > 0 && !buildingOtr && extractedResources >= maxResources) {
|
||||
if (maxResources > 0 && !buildingOtr && (extractedResources >= maxResources || !oldExtractMode))
|
||||
{
|
||||
setCurrentStep("Building OTR...");
|
||||
if (skipFrames < 3) {
|
||||
skipFrames++;
|
||||
return;
|
||||
}
|
||||
buildingOtr = true;
|
||||
if (single_thread){
|
||||
|
||||
if (single_thread || !oldExtractMode){
|
||||
BuildOTR(output);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue