Browse Source

Bugfix/version file creation (#1475)

* Added creation of version file to OTRExporter

* Removed creation of version file from other places

* Made path to version file portable

* Changed spaces to tabs in OTRExporter/Main.cpp
pull/1528/head
Dan Lilja 2 weeks ago committed by GitHub
parent
commit
b5b5a58302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      OTRExporter/OTRExporter/Main.cpp
  2. 4
      OTRExporter/extract_assets.py
  3. 1
      OTRGui/src/game/game.cpp
  4. 4
      OTRGui/src/impl/extractor/extractor.cpp

22
OTRExporter/OTRExporter/Main.cpp

@ -63,13 +63,29 @@ static void ExporterProgramEnd() @@ -63,13 +63,29 @@ static void ExporterProgramEnd()
{
if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory)
{
printf("Creating version file...\n");
// Get crc from rom
std::string romPath = Globals::Instance->baseRomPath.string();
std::vector<uint8_t> romData = File::ReadAllBytes(romPath);
uint32_t crc = BitConverter::ToUInt32BE(romData, 0x10);
// Write crc to version file
fs::path versionPath("Extract/version");
std::ofstream versionFile(versionPath.c_str(), std::ios::out | std::ios::binary);
versionFile.write((char*)&crc, sizeof(crc));
versionFile.flush();
versionFile.close();
printf("Created version file.\n");
printf("Generating OTR Archive...\n");
otrArchive = Ship::Archive::CreateArchive(otrFileName, 40000);
for (auto item : files)
{
for (auto item : files) {
auto fileData = item.second;
otrArchive->AddFile(item.first, (uintptr_t)fileData.data(), fileData.size());
otrArchive->AddFile(item.first, (uintptr_t)fileData.data(),
fileData.size());
}
// Add any additional files that need to be manually copied...

4
OTRExporter/extract_assets.py

@ -11,10 +11,6 @@ import argparse @@ -11,10 +11,6 @@ import argparse
def BuildOTR(xmlPath, rom, zapd_exe=None):
shutil.copytree("assets", "Extract/assets")
checksum = int(Z64Rom(rom).checksum.value, 16)
with open("Extract/version", "wb") as f:
f.write(struct.pack('<L', checksum))
if not zapd_exe:
zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out"

1
OTRGui/src/game/game.cpp

@ -91,7 +91,6 @@ void ExtractRom() @@ -91,7 +91,6 @@ void ExtractRom()
//MoonUtils::copy("tmp/baserom/Audioseq", "Extract/Audioseq");
//MoonUtils::copy("tmp/baserom/Audiotable", "Extract/Audiotable");
//MoonUtils::copy("tmp/baserom/version", "Extract/version");
MoonUtils::write("Extract/version", (char*)&version.crc, sizeof(version.crc));
MoonUtils::copy("assets/game/", "Extract/assets/");

4
OTRGui/src/impl/extractor/extractor.cpp

@ -81,7 +81,7 @@ void startWorker(RomVersion version) { @@ -81,7 +81,7 @@ void startWorker(RomVersion version) {
path += GetXMLVersion(version);
Util::write("tmp/baserom/version", (char*)&version.crc, sizeof(version.crc));
// Util::write("tmp/baserom/version", (char*)&version.crc, sizeof(version.crc));
if (oldExtractMode)
{
@ -144,4 +144,4 @@ void updateWorker(const std::string& output) { @@ -144,4 +144,4 @@ void updateWorker(const std::string& output) {
std::thread otr(BuildOTR, output);
otr.detach();
}
}
}

Loading…
Cancel
Save