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
This commit is contained in:
parent
d6d7ffd3da
commit
b5b5a58302
|
@ -63,13 +63,29 @@ static void ExporterProgramEnd()
|
||||||
{
|
{
|
||||||
if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory)
|
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");
|
printf("Generating OTR Archive...\n");
|
||||||
otrArchive = Ship::Archive::CreateArchive(otrFileName, 40000);
|
otrArchive = Ship::Archive::CreateArchive(otrFileName, 40000);
|
||||||
|
|
||||||
for (auto item : files)
|
for (auto item : files) {
|
||||||
{
|
|
||||||
auto fileData = item.second;
|
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...
|
// Add any additional files that need to be manually copied...
|
||||||
|
|
|
@ -11,10 +11,6 @@ import argparse
|
||||||
def BuildOTR(xmlPath, rom, zapd_exe=None):
|
def BuildOTR(xmlPath, rom, zapd_exe=None):
|
||||||
shutil.copytree("assets", "Extract/assets")
|
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:
|
if not zapd_exe:
|
||||||
zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out"
|
zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out"
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,6 @@ void ExtractRom()
|
||||||
//MoonUtils::copy("tmp/baserom/Audioseq", "Extract/Audioseq");
|
//MoonUtils::copy("tmp/baserom/Audioseq", "Extract/Audioseq");
|
||||||
//MoonUtils::copy("tmp/baserom/Audiotable", "Extract/Audiotable");
|
//MoonUtils::copy("tmp/baserom/Audiotable", "Extract/Audiotable");
|
||||||
//MoonUtils::copy("tmp/baserom/version", "Extract/version");
|
//MoonUtils::copy("tmp/baserom/version", "Extract/version");
|
||||||
MoonUtils::write("Extract/version", (char*)&version.crc, sizeof(version.crc));
|
|
||||||
|
|
||||||
MoonUtils::copy("assets/game/", "Extract/assets/");
|
MoonUtils::copy("assets/game/", "Extract/assets/");
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ void startWorker(RomVersion version) {
|
||||||
|
|
||||||
path += GetXMLVersion(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)
|
if (oldExtractMode)
|
||||||
{
|
{
|
||||||
|
@ -144,4 +144,4 @@ void updateWorker(const std::string& output) {
|
||||||
std::thread otr(BuildOTR, output);
|
std::thread otr(BuildOTR, output);
|
||||||
otr.detach();
|
otr.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue